Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(relay): restore paged snapshot composition checks [H5,C7]

Corey Olson0aa7426455ed
diff --git a/src/relay-page-cache.js b/src/relay-page-cache.js
index 7de1572f..0c2e5cec 100644
--- a/src/relay-page-cache.js
+++ b/src/relay-page-cache.js
@@ -1,11 +1,21 @@
/** Private device-only cipher cache and durable upload graph; no board key or decrypted record is stored [H15,H17]. */
import { createHash } from 'node:crypto';
-import { closeSync, lstatSync, mkdirSync, openSync } from 'node:fs';
+import {
+ closeSync,
+ lstatSync,
+ mkdirSync,
+ openSync,
+} from 'node:fs';
import { homedir } from 'node:os';
import { join } from 'node:path';
import { DatabaseSync } from 'node:sqlite';
import { Refused } from './refused.js';
-import { PAGE_CIPHER_BYTES, PAGE_FANOUT, pageReference, sealedPageFingerprint } from './sealed-pages.js';
+import {
+ PAGE_CIPHER_BYTES,
+ PAGE_FANOUT,
+ pageReference,
+ sealedPageFingerprint,
+} from './sealed-pages.js';
/** Refuse a damaged private cache without repeating any bytes or private fingerprints. */
function invalid() { return new Refused('RELAY_PAGE_CACHE', 'Restore private relay page cache storage, or remove this device cache and retry the saved snapshot.'); }
diff --git a/src/relay-page-client.js b/src/relay-page-client.js
index 4e02fdf1..0cab371d 100644
--- a/src/relay-page-client.js
+++ b/src/relay-page-client.js
@@ -3,10 +3,16 @@ import { Refused } from './refused.js';
import { legacyPageRoute } from './relay-page-support.js';
import { relayStorage } from './relay-storage.js';
export { relayStorage, relayStorageLine } from './relay-storage.js';
-import { createRelayPageCache, snapshotSourceId } from './relay-page-cache.js';
+import {
+ createRelayPageCache,
+ snapshotSourceId,
+} from './relay-page-cache.js';
import { openPagedSnapshot } from './relay-page-layout.js';
import { writePagedSnapshot } from './relay-page-writer.js';
-import { PAGE_CIPHER_BYTES, pageReference } from './sealed-pages.js';
+import {
+ PAGE_CIPHER_BYTES,
+ pageReference,
+} from './sealed-pages.js';
const PAGE_CAPABILITIES = new WeakMap();
diff --git a/src/relay-page-layout.js b/src/relay-page-layout.js
index a6744336..52bb9da3 100644
--- a/src/relay-page-layout.js
+++ b/src/relay-page-layout.js
@@ -1,6 +1,13 @@
/** One native snapshot with a small current presentation and separately addressed sealed history [H15,H17]. */
import { Refused } from './refused.js';
-import { PAGE_FANOUT, pageReference, readSealedDescriptor, readSealedValue, writeSealedDescriptor, writeSealedValue } from './sealed-pages.js';
+import {
+ PAGE_FANOUT,
+ pageReference,
+ readSealedDescriptor,
+ readSealedValue,
+ writeSealedDescriptor,
+ writeSealedValue,
+} from './sealed-pages.js';
const FORMAT = 'pullboard-paged-snapshot/1';
const BATCH_BYTES = 131_072;
diff --git a/src/relay-page-writer.js b/src/relay-page-writer.js
index 896fbb08..19015886 100644
--- a/src/relay-page-writer.js
+++ b/src/relay-page-writer.js
@@ -1,5 +1,8 @@
/** Native snapshot projection uses the same lifecycle fields as the local API [A2,H17]. */
-import { itemSummary, withListFields } from './item-list.js';
+import {
+ itemSummary,
+ withListFields,
+} from './item-list.js';
import { encodePagedSnapshot } from './relay-page-layout.js';
/** Project current list fields without pulling the native lifecycle implementation into phone readers. */
diff --git a/src/relay-upload-pause.js b/src/relay-upload-pause.js
index 065c11d4..34cda5a0 100644
--- a/src/relay-upload-pause.js
+++ b/src/relay-upload-pause.js
@@ -1,5 +1,8 @@
/** A blocked upload probes small metadata and reports once per real device session [H15,H17]. */
-import { createRelayPageCache, snapshotSourceId } from './relay-page-cache.js';
+import {
+ createRelayPageCache,
+ snapshotSourceId,
+} from './relay-page-cache.js';
import { relayStorage } from './relay-storage.js';
import { agentSessionDigest } from './person.js';
import { Refused } from './refused.js';
diff --git a/src/relay.js b/src/relay.js
index 533f12dd..0026b0c9 100644
--- a/src/relay.js
+++ b/src/relay.js
@@ -1,4 +1,10 @@
-import { clearUploadPauseNotices, firstUploadPauseNotice, permanentUploadRefusal, uploadPauseType, uploadRetryReady } from './relay-upload-pause.js';
+import {
+ clearUploadPauseNotices,
+ firstUploadPauseNotice,
+ permanentUploadRefusal,
+ uploadPauseType,
+ uploadRetryReady,
+} from './relay-upload-pause.js';
/** Opt-in, sealed relay ordering, with crash-safe migration from the older mirror [H1,H3,H5,H16,H17,P5]. */
import {
createHash,
@@ -102,7 +108,11 @@ import {
requireRelayOnChannel,
} from './person.js';
import { listApiProjects } from './projects.js';
-import { relaySnapshotRequest, relayStorage, relayStorageLine } from './relay-page-client.js';
+import {
+ relaySnapshotRequest,
+ relayStorage,
+ relayStorageLine,
+} from './relay-page-client.js';
export { relayStorageLine };
export const DEFAULT_RELAY = 'https://app.pullboard.dev';
diff --git a/src/sealed-pages.js b/src/sealed-pages.js
index ce7b85b3..9baf93d0 100644
--- a/src/sealed-pages.js
+++ b/src/sealed-pages.js
@@ -1,6 +1,9 @@
/** Bounded, device-sealed snapshot objects; plaintext and private cache fingerprints never reach the relay [H15,H17]. */
import { Refused } from './refused.js';
-import { seal, unseal } from './seal.js';
+import {
+ seal,
+ unseal,
+} from './seal.js';
export const PAGE_BYTES = 262_144;
export const PAGE_FANOUT = 64;
diff --git a/test/relay-empty-phone-fixture.js b/test/relay-empty-phone-fixture.js
index 00dd2d1d..ff3177d4 100644
--- a/test/relay-empty-phone-fixture.js
+++ b/test/relay-empty-phone-fixture.js
@@ -4,7 +4,7 @@ import { createRelayBrowserHandler } from '../relay/browser-page.js';
import { startChrome } from './relay-browser-fixture.js';
/** Serve only synthetic authorized metadata and keep the production browser transport and device storage. */
-export async function emptyPhoneFixture(t, { linked = true, savedKey = false, enrolled = false, delayed = false, phone = true } = {}) {
+export async function emptyPhoneFixture(t, { linked = true, savedKey = false, enrolled = false, delayed = false, phone = true, warnings = [] } = {}) {
const board = { id: 'a'.repeat(32), repository: 'fixture/empty-project' };
let releaseListing;
const listingReady = delayed ? new Promise(resolve => { releaseListing = resolve; }) : Promise.resolve();
@@ -17,7 +17,7 @@ export async function emptyPhoneFixture(t, { linked = true, savedKey = false, en
if (path.startsWith('/api/')) {
let body = { version: 1 };
let status = 200;
- if (path === '/api/v1/boards') { await listingReady; body.boards = linked ? [board] : []; }
+ if (path === '/api/v1/boards') { await listingReady; body.boards = linked ? [board] : []; body.warnings = warnings; }
else if (path === '/api/v1/devices/session') body.account = 'fixture-account';
else if (/\/devices\/[^/]+\/boards$/u.test(path)) body.wraps = [];
else if (/\/devices\/[^/]+\/approvals$/u.test(path)) body.approvals = [];
diff --git a/test/relay-person-page.test.js b/test/relay-person-page.test.js
index a76d7f87..9c8dda7f 100644
--- a/test/relay-person-page.test.js
+++ b/test/relay-person-page.test.js
@@ -72,6 +72,18 @@ test('a signed-in second computer names a linked board blocker without asking to
});
});
+test('a phone shows its account quota warning while its already-linked board still needs pairing [H5,H17]', chromeOptions, async t => {
+ const message = 'Fixture relay storage is full. Run pullboard relay status on the computer with this board.';
+ const box = await emptyPhoneFixture(t, { warnings: [{ code: 'ACCOUNT_STORAGE_LIMIT', message }] });
+ await box.chrome.waitFor("document.querySelector('#relay-notice')?.textContent.includes('Fixture relay storage is full')");
+ const shown = await emptyPhoneScreen(box.chrome);
+ assert.equal(shown.visible, true);
+ assert.ok(shown.text.includes(message), 'the actual quota warning is visible in the phone screen, not hidden under it');
+ assert.match(shown.text, /not paired/iu, 'the independently observed pairing blocker still names its own step');
+ assert.ok(shown.commands.includes('pullboard relay pair'));
+ assert.equal(shown.text.includes('pullboard relay on --all'), false, 'a linked board is not asked to share again');
+});
+
/** Wait for a private native setup transition without repeating its command or weakening an assertion. */
async function phoneSetupState(read, message) {
const deadline = Date.now() + 20_000; // budget: declared hang ceiling for a private enrollment/approval metadata transition.
@@ -114,7 +126,7 @@ window.fetch = (input, options) => {
window.fetch = async (input, options) => {
const url = new URL(typeof input === 'string' ? input : input.url, location.href);
const response = await authorizedPhoneFetch(input, options);
- if (url.pathname === ${JSON.stringify('/api/v1/boards/' + publisher + '/state')} && response.ok) {
+ if (${JSON.stringify(['/api/v1/boards/' + publisher + '/state', '/api/v2/boards/' + publisher + '/state'])}.includes(url.pathname) && response.ok) {
return new Response(JSON.stringify({ version: 1, error: { code: 'NO_SNAPSHOT', message: 'This private phone snapshot is unavailable.' } }), {
status: 404, headers: { 'content-type': 'application/json' },
});