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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
feat(view): the flow report keeps its hosted origin headers [N26]
Corey Olsona7601541c575
diff --git a/src/serve.js b/src/serve.jsindex 24159d0e..f43c8de2 100644--- a/src/serve.js+++ b/src/serve.js@@ -605,7 +605,10 @@ export async function serveView({ port = 0, secret = randomBytes(18).toString('b: 'this view answers its own page and https://app.pullboard.dev only' });}res.setHeader('vary', 'Origin');- if (hosted) res.setHeader('access-control-allow-origin', HOSTED_ORIGIN);+ if (hosted) {+ res.setHeader('access-control-allow-origin', HOSTED_ORIGIN);+ res.setHeader('access-control-expose-headers', 'x-pullboard-report-validator');+ }if (req.method === 'OPTIONS') {const asked = String(req.headers['access-control-request-headers'] ?? '').toLowerCase().split(',').map((name) => name.trim()).filter(Boolean);const route = url.pathname.startsWith('/api/') || url.pathname === '/local/protocol';diff --git a/src/view/page-script-2.js b/src/view/page-script-2.jsindex 807d37d6..7f19fd93 100644--- a/src/view/page-script-2.js+++ b/src/view/page-script-2.js@@ -824,6 +824,9 @@ async function api(path, body) {const reply = await jsonRequest(path, body, base, headers); if (boardId && source?.kind === 'local' && path.includes('/state') && reply?.state) return { ...reply, state: { ...reply.state, root: source.board.root } }; return reply;}+// Transport-only report identities never become public state fields or persisted browser data.+const reportValidators = new WeakMap();+/** Use one JSON request primitive, capturing its local route and session before awaiting a reply. */async function jsonRequest(path, body, base, headers, cache, format = 'json') {const session = localSession;@@ -841,6 +844,9 @@ async function jsonRequest(path, body, base, headers, cache, format = 'json') {if (refusal && typeof refusal === 'object') error.code = refusal.code;throw error;}+ const report = json?.state?.proofStats?.flow?.report ?? json?.delta?.replace?.proofStats?.flow?.report;+ const reportValidator = res.headers.get('x-pullboard-report-validator');+ if (report && typeof report === 'object' && /^[a-f0-9]{64}:[0-9]+$/.test(reportValidator ?? '')) reportValidators.set(report, reportValidator);return json;}diff --git a/src/view/page-script-3.js b/src/view/page-script-3.jsindex b83a1576..8ba5ecc7 100644--- a/src/view/page-script-3.js+++ b/src/view/page-script-3.js@@ -425,10 +425,12 @@ async function revokeCredential(id) {/*** A board read as text with its clock readings blanked: the flow's observation time (asOf) and each queue's oldest age* (ageMinutes) are stamped afresh on every read, so two reads that differ only there show the same board (#644).+ * Authenticated local report metadata compares recorded facts and native expiry, not display-only duration increments.* Matching whole JSON keys is safe: a quote inside any string value is escaped, so no title can look like one.*/function boardText(state) {- return JSON.stringify(state).replace(/"(asOf|ageMinutes)":(?:"[^"]*"|[-+.0-9eE]+|null)/g, '"$1":null');+ return JSON.stringify(state, (_key, value) => value && typeof value === 'object' && reportValidators.has(value)+ ? { reportValidator: reportValidators.get(value) } : value).replace(/"(asOf|ageMinutes)":(?:"[^"]*"|[-+.0-9eE]+|null)/g, '"$1":null');}/** Show each queue's oldest age from the board on hand in place: the one thing on the page that moves with the clock alone. */diff --git a/test/cockpit/fixture.js b/test/cockpit/fixture.jsindex 87cb5172..af732c50 100644--- a/test/cockpit/fixture.js+++ b/test/cockpit/fixture.js@@ -401,7 +401,7 @@ async function openPage(view, { width = 1280, later = 0, store = null, hold = farequests.push({ path, method: init?.method ?? 'GET', body: init?.body ? JSON.parse(init.body) : null });const answer = held.then(() => fetchLive(`${view.base}${path}`, { ...init, signal: init.signal ?? AbortSignal.timeout(30_000) })).then(async (res) => {const body = await res.json();- return { ok: res.ok, status: res.status, json: async () => body };+ return { ok: res.ok, status: res.status, headers: res.headers, json: async () => body };});inflight.add(answer);const done = () => inflight.delete(answer);diff --git a/test/cockpit/local-origin.test.js b/test/cockpit/local-origin.test.jsindex 243a5d77..8ad21dd8 100644--- a/test/cockpit/local-origin.test.js+++ b/test/cockpit/local-origin.test.js@@ -732,6 +732,14 @@ test('a foreign origin or wrong Host is refused by the local view [N26,A2]', { tassert.equal(read.status, 200, 'the hosted page reads with its header');assert.equal(read.headers['access-control-allow-origin'], HOSTED);const id = JSON.parse(read.body).boards[0].id;+ const state = await call(view, `/api/v1/boards/${id}/state`, { headers: { ...key, origin: HOSTED } });+ assert.equal(state.status, 200);+ assert.match(state.headers['x-pullboard-report-validator'], /^[a-f0-9]{64}:[0-9]+$/u);+ assert.equal(state.headers['access-control-expose-headers'], 'x-pullboard-report-validator',+ 'the already-allowed hosted browser may read the report token under CORS, without extra request authority');+ const sameOriginState = await call(view, `/api/v1/boards/${id}/state`, { headers: { ...key, origin: view.base } });+ assert.equal(sameOriginState.headers['access-control-expose-headers'], undefined,+ 'same-origin reads need no new cross-origin permission');const shout = JSON.stringify({ verb: 'shout', args: { to: 'all', text: 'from the hosted page' } });const plain = await call(view, `/api/v1/boards/${id}/moves`, { method: 'POST', headers: { ...key, origin: HOSTED, 'content-type': 'text/plain' }, body: shout });assert.equal(plain.status, 400, 'a write that is not JSON is refused, as a form could send it');