From 6671045e4aa6451cfa673b51a0f2dac781a0efa1 Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:25:25 +0900 Subject: [PATCH 01/13] Refactor observation handling in run.mjs --- examples/livesay-pack/run.mjs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/examples/livesay-pack/run.mjs b/examples/livesay-pack/run.mjs index c821f9e..ca62b30 100644 --- a/examples/livesay-pack/run.mjs +++ b/examples/livesay-pack/run.mjs @@ -40,6 +40,14 @@ async function targetInfo(path, commit) { return { dir, commit, contentHash: hash(JSON.stringify(entries)) }; } +/** Serializable browser predicate; absolute elapsed time survives same-tab navigation. */ +export function observationComplete({ids, baselineOrigin, grace, observationStart}) { + const snapshot = window.__livesayProbe?.snapshot(); + const excluded = performance.timeOrigin === baselineOrigin ? ids : []; + const answers = snapshot?.answers.filter(a => !excluded.includes(a.id)) ?? []; + return answers.length > 0 && answers.every(a => a.outcome !== 'running' && Number.isFinite(a.endedAt)) && performance.timeOrigin + performance.now() - observationStart >= grace && snapshot.capturedAt - Math.max(...answers.map(a => a.endedAt)) >= grace; +} + export async function runPack(config, livesay) { const scenes = normalizeScenes(config.scenes).map(scene => ({ ...scene, route: normalizeRoute(applyRouteParams(scene.route, config.params).route) })); if (scenes.some(s => /\[[^\]]+\]|:[A-Za-z_]/.test(s.route))) throw new Error('Resolve scene route parameters in manifest params'); @@ -73,23 +81,19 @@ export async function runPack(config, livesay) { try { await livesay.installProbe(page); } catch { failures.push({ side: capture.side, scene: capture.scene, reason: 'probe-install-failed' }); } }, async beforeScene(page, capture) { - try { const snapshot = await livesay.readProbeSnapshot(page); baselines.set(key(capture), snapshot.answers.map(a => a.id)); } catch {} + try { const snapshot = await livesay.readProbeSnapshot(page); baselines.set(key(capture), { ids: snapshot.answers.map(a => a.id), timeOrigin: await page.evaluate(() => performance.timeOrigin) }); } catch {} }, async beforeScreenshot(page, capture) { if (!capture.scene) return; try { const oldIds = baselines.get(key(capture)); if (!oldIds) throw new Error('scene start snapshot missing'); - const observationStart = (await livesay.readProbeSnapshot(page)).capturedAt; - await page.waitForFunction(({ids, grace, observationStart}) => { - const snapshot = window.__livesayProbe?.snapshot(); - const answers = snapshot?.answers.filter(a => !ids.includes(a.id)) ?? []; - // Every newly observed answer gets its own full grace. A later answer - // resets the boundary; bounded timeout leaves sustained streams unverified. - return answers.length > 0 && answers.every(a => a.outcome !== 'running' && Number.isFinite(a.endedAt)) && snapshot.capturedAt - observationStart >= grace && snapshot.capturedAt - Math.max(...answers.map(a => a.endedAt)) >= grace; - }, {ids: oldIds, grace: graceMs, observationStart}, { timeout: 1500 + graceMs * 3, polling: 50 }); + const observationStart = await page.evaluate(() => performance.timeOrigin + performance.now()); + await page.waitForFunction(observationComplete, {ids: oldIds.ids, baselineOrigin: oldIds.timeOrigin, grace: graceMs, observationStart}, { timeout: 1500 + graceMs * 3, polling: 50 }); const snapshot = await livesay.readProbeSnapshot(page); - if (!snapshot.events.length || !snapshot.answers.filter(a => !oldIds.includes(a.id)).length || snapshot.answers.some(a => a.outcome === 'running')) throw new Error('empty recording'); + const currentOrigin = await page.evaluate(() => performance.timeOrigin); + const ids = currentOrigin === oldIds.timeOrigin ? oldIds.ids : []; + if (!snapshot.events.length || !snapshot.answers.filter(a => !ids.includes(a.id)).length || snapshot.answers.some(a => a.outcome === 'running')) throw new Error('empty recording'); const report = livesay.audit(snapshot, { profile: 'nvda-like' }); const item = { binding: { ...binding }, scene: capture.scene, side: capture.side, report }; captures.set(key(capture), item); From acd9f4a16bc44e7b454f7ecda15898dbada6adc3 Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:25:32 +0900 Subject: [PATCH 02/13] Update test.mjs --- examples/livesay-pack/test.mjs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/examples/livesay-pack/test.mjs b/examples/livesay-pack/test.mjs index 6dc57b7..202cde8 100644 --- a/examples/livesay-pack/test.mjs +++ b/examples/livesay-pack/test.mjs @@ -5,7 +5,7 @@ import { tmpdir } from 'node:os'; import { join, resolve } from 'node:path'; import { pathToFileURL } from 'node:url'; import { execFileSync } from 'node:child_process'; -import { runPack, bindEvidence } from './run.mjs'; +import { runPack, bindEvidence, observationComplete } from './run.mjs'; const livesay = await import(pathToFileURL(resolve(process.argv[2])).href); const config = JSON.parse(await readFile(process.argv[3], 'utf8')); test('binding refuses scene, step/viewport, and either commit drift', () => { @@ -74,3 +74,18 @@ test('final action asynchronous answer is observed after earlier answer grace el c.scenes[0].steps=[{action:'click',selector:'#open'},{action:'wait',selector:'#last'},{action:'click',selector:'#last'}]; const pack=await runPack(c,livesay);assert.equal(pack.rows[0].status,'verified');assert.match(pack.rows[0].transcripts.head.join(' '),/Last completed/); }); + +test('observation predicate rejects old completed answers until final-action quiet time',()=>{ + const old=globalThis.window; + try { + globalThis.window={__livesayProbe:{snapshot:()=>({capturedAt:9000,answers:[{id:'x',endedAt:100,outcome:'done'}]})}}; + const now=performance.timeOrigin+performance.now(); + const args={ids:[],baselineOrigin:performance.timeOrigin,grace:1200,observationStart:now}; + assert.equal(observationComplete(args),false); + assert.equal(observationComplete({...args,observationStart:now-1300}),true); + } finally {globalThis.window=old;} +}); +test('same-tab document navigation does not reset absolute observation elapsed time',async()=>{ + const c=await fixture(`if(location.pathname==='/second'){const p=window.__livesayProbe;p.mark('start',{id:'x'});document.querySelector('#result').textContent='Navigation completed.';p.mark('done',{id:'x'});}document.querySelector('#open').onclick=()=>{const p=window.__livesayProbe;p.mark('start',{id:'x'});p.mark('done',{id:'x'});setTimeout(()=>location.href='/second',700);};`); + const pack=await runPack(c,livesay);assert.equal(pack.rows[0].status,'verified');assert.match(pack.rows[0].transcripts.head.join(' '),/Navigation completed/); +}); From b076c98c383bf68c695942ed5d6520d0dd0f868f Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:31:33 +0900 Subject: [PATCH 03/13] Update run.mjs --- examples/livesay-pack/run.mjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/livesay-pack/run.mjs b/examples/livesay-pack/run.mjs index ca62b30..2e2cd42 100644 --- a/examples/livesay-pack/run.mjs +++ b/examples/livesay-pack/run.mjs @@ -43,7 +43,9 @@ async function targetInfo(path, commit) { /** Serializable browser predicate; absolute elapsed time survives same-tab navigation. */ export function observationComplete({ids, baselineOrigin, grace, observationStart}) { const snapshot = window.__livesayProbe?.snapshot(); - const excluded = performance.timeOrigin === baselineOrigin ? ids : []; + // A document replacement loses the prior probe transcript. Never call it verified. + if (performance.timeOrigin !== baselineOrigin) return false; + const excluded = ids; const answers = snapshot?.answers.filter(a => !excluded.includes(a.id)) ?? []; return answers.length > 0 && answers.every(a => a.outcome !== 'running' && Number.isFinite(a.endedAt)) && performance.timeOrigin + performance.now() - observationStart >= grace && snapshot.capturedAt - Math.max(...answers.map(a => a.endedAt)) >= grace; } @@ -92,7 +94,8 @@ export async function runPack(config, livesay) { await page.waitForFunction(observationComplete, {ids: oldIds.ids, baselineOrigin: oldIds.timeOrigin, grace: graceMs, observationStart}, { timeout: 1500 + graceMs * 3, polling: 50 }); const snapshot = await livesay.readProbeSnapshot(page); const currentOrigin = await page.evaluate(() => performance.timeOrigin); - const ids = currentOrigin === oldIds.timeOrigin ? oldIds.ids : []; + if (currentOrigin !== oldIds.timeOrigin) throw new Error('cross-document evidence lost'); + const ids = oldIds.ids; if (!snapshot.events.length || !snapshot.answers.filter(a => !ids.includes(a.id)).length || snapshot.answers.some(a => a.outcome === 'running')) throw new Error('empty recording'); const report = livesay.audit(snapshot, { profile: 'nvda-like' }); const item = { binding: { ...binding }, scene: capture.scene, side: capture.side, report }; From 0bbd9e515c2512d4798bd966897d611cede8e04a Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:31:40 +0900 Subject: [PATCH 04/13] Update tests for document navigation and origin validation --- examples/livesay-pack/test.mjs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/livesay-pack/test.mjs b/examples/livesay-pack/test.mjs index 202cde8..0d31325 100644 --- a/examples/livesay-pack/test.mjs +++ b/examples/livesay-pack/test.mjs @@ -85,7 +85,16 @@ test('observation predicate rejects old completed answers until final-action qui assert.equal(observationComplete({...args,observationStart:now-1300}),true); } finally {globalThis.window=old;} }); -test('same-tab document navigation does not reset absolute observation elapsed time',async()=>{ +test('same-tab document navigation is unverified because the old transcript is lost',async()=>{ const c=await fixture(`if(location.pathname==='/second'){const p=window.__livesayProbe;p.mark('start',{id:'x'});document.querySelector('#result').textContent='Navigation completed.';p.mark('done',{id:'x'});}document.querySelector('#open').onclick=()=>{const p=window.__livesayProbe;p.mark('start',{id:'x'});p.mark('done',{id:'x'});setTimeout(()=>location.href='/second',700);};`); - const pack=await runPack(c,livesay);assert.equal(pack.rows[0].status,'verified');assert.match(pack.rows[0].transcripts.head.join(' '),/Navigation completed/); + const pack=await runPack(c,livesay);assert.equal(pack.rows[0].status,'unverified');assert.equal(pack.rows[0].announcement,null); +}); + +test('different document origin cannot validate even complete destination answers',()=>{ + const old=globalThis.window; + try { + globalThis.window={__livesayProbe:{snapshot:()=>({capturedAt:9000,answers:[{id:'x',endedAt:100,outcome:'done'}]})}}; + const now=performance.timeOrigin+performance.now(); + assert.equal(observationComplete({ids:['x'],baselineOrigin:performance.timeOrigin-100,grace:1200,observationStart:now-5000}),false); + } finally {globalThis.window=old;} }); From 6df976cfc2042c90c6387a2d06ea967148ab71de Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:31:46 +0900 Subject: [PATCH 05/13] Update README with notes on observation and navigation --- examples/livesay-pack/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/livesay-pack/README.md b/examples/livesay-pack/README.md index db81d03..f56af7d 100644 --- a/examples/livesay-pack/README.md +++ b/examples/livesay-pack/README.md @@ -90,3 +90,9 @@ maximum). Thus graceMs controls both observation time and the overall marker wait bound. Answers beginning after the quiet observation window are outside this bounded sample contract. Use an explicit final SceneSpec wait/expect for your app's readiness signal rather than arbitrary long asynchronous work. + +Cross-document navigation during a scene or observation is deliberately +UNVERIFIED: the previous document's probe transcript cannot be recovered and +might contain an unfinished answer. This example does not join transcripts +across documents or claim that a completed destination answer proves the prior +answer ended. SPA state changes without document replacement are supported. From 63e3341f45281a92ec0f51eef30fac69fb63f34e Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:37:43 +0900 Subject: [PATCH 06/13] Update run.mjs --- examples/livesay-pack/run.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/livesay-pack/run.mjs b/examples/livesay-pack/run.mjs index 2e2cd42..554ed29 100644 --- a/examples/livesay-pack/run.mjs +++ b/examples/livesay-pack/run.mjs @@ -44,7 +44,7 @@ async function targetInfo(path, commit) { export function observationComplete({ids, baselineOrigin, grace, observationStart}) { const snapshot = window.__livesayProbe?.snapshot(); // A document replacement loses the prior probe transcript. Never call it verified. - if (performance.timeOrigin !== baselineOrigin) return false; + if (performance.timeOrigin !== baselineOrigin) return 'document-changed'; const excluded = ids; const answers = snapshot?.answers.filter(a => !excluded.includes(a.id)) ?? []; return answers.length > 0 && answers.every(a => a.outcome !== 'running' && Number.isFinite(a.endedAt)) && performance.timeOrigin + performance.now() - observationStart >= grace && snapshot.capturedAt - Math.max(...answers.map(a => a.endedAt)) >= grace; From b55cb5bd87f173415175e28e78cccae850cab7f3 Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:37:49 +0900 Subject: [PATCH 07/13] Update test.mjs --- examples/livesay-pack/test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/livesay-pack/test.mjs b/examples/livesay-pack/test.mjs index 0d31325..fde1ac6 100644 --- a/examples/livesay-pack/test.mjs +++ b/examples/livesay-pack/test.mjs @@ -95,6 +95,6 @@ test('different document origin cannot validate even complete destination answer try { globalThis.window={__livesayProbe:{snapshot:()=>({capturedAt:9000,answers:[{id:'x',endedAt:100,outcome:'done'}]})}}; const now=performance.timeOrigin+performance.now(); - assert.equal(observationComplete({ids:['x'],baselineOrigin:performance.timeOrigin-100,grace:1200,observationStart:now-5000}),false); + assert.equal(observationComplete({ids:['x'],baselineOrigin:performance.timeOrigin-100,grace:1200,observationStart:now-5000}),'document-changed'); } finally {globalThis.window=old;} }); From 4eddb1d9e5d0d228b699037ee98dd36630e97e4c Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:43:59 +0900 Subject: [PATCH 08/13] Update run.mjs --- examples/livesay-pack/run.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/livesay-pack/run.mjs b/examples/livesay-pack/run.mjs index 554ed29..a88f986 100644 --- a/examples/livesay-pack/run.mjs +++ b/examples/livesay-pack/run.mjs @@ -100,7 +100,12 @@ export async function runPack(config, livesay) { const report = livesay.audit(snapshot, { profile: 'nvda-like' }); const item = { binding: { ...binding }, scene: capture.scene, side: capture.side, report }; captures.set(key(capture), item); - } catch { failures.push({ side: capture.side, scene: capture.scene, reason: 'announcement-unverified' }); } + } catch { + failures.push({ side: capture.side, scene: capture.scene, reason: 'announcement-unverified' }); + const baseline = baselines.get(key(capture)); + const origin = await page.evaluate(() => performance.timeOrigin).catch(() => null); + if (baseline && origin !== baseline.timeOrigin) throw new Error('Cross-document scene is blocked; no destination screenshot comparison'); + } }, }; // Do not inherit an unrelated ambient .proofshot.json. From 37dd4ffb6a108e6f22dbacdce4c3d4894d153926 Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:44:06 +0900 Subject: [PATCH 09/13] Update test.mjs From 8e95de1f5ed53789dbc83deaa418e143a7c1ed29 Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:44:11 +0900 Subject: [PATCH 10/13] Update README.md --- examples/livesay-pack/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/livesay-pack/README.md b/examples/livesay-pack/README.md index f56af7d..ad4e4dd 100644 --- a/examples/livesay-pack/README.md +++ b/examples/livesay-pack/README.md @@ -96,3 +96,6 @@ UNVERIFIED: the previous document's probe transcript cannot be recovered and might contain an unfinished answer. This example does not join transcripts across documents or claim that a completed destination answer proves the prior answer ended. SPA state changes without document replacement are supported. + +A cross-document scene is also blocked on the visual side: no destination +loading screenshot is presented as a successful before/after comparison. From a9f2a60b3fbf2e5b949dfae58e7126bb5dcc090f Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:50:06 +0900 Subject: [PATCH 11/13] Update run.mjs --- examples/livesay-pack/run.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/livesay-pack/run.mjs b/examples/livesay-pack/run.mjs index a88f986..88bd190 100644 --- a/examples/livesay-pack/run.mjs +++ b/examples/livesay-pack/run.mjs @@ -83,13 +83,15 @@ export async function runPack(config, livesay) { try { await livesay.installProbe(page); } catch { failures.push({ side: capture.side, scene: capture.scene, reason: 'probe-install-failed' }); } }, async beforeScene(page, capture) { - try { const snapshot = await livesay.readProbeSnapshot(page); baselines.set(key(capture), { ids: snapshot.answers.map(a => a.id), timeOrigin: await page.evaluate(() => performance.timeOrigin) }); } catch {} + const timeOrigin = await page.evaluate(() => performance.timeOrigin); + baselines.set(key(capture), { ids: null, timeOrigin }); + try { const snapshot = await livesay.readProbeSnapshot(page); baselines.set(key(capture), { ids: snapshot.answers.map(a => a.id), timeOrigin }); } catch {} }, async beforeScreenshot(page, capture) { if (!capture.scene) return; try { const oldIds = baselines.get(key(capture)); - if (!oldIds) throw new Error('scene start snapshot missing'); + if (!oldIds || !oldIds.ids) throw new Error('scene start snapshot missing'); const observationStart = await page.evaluate(() => performance.timeOrigin + performance.now()); await page.waitForFunction(observationComplete, {ids: oldIds.ids, baselineOrigin: oldIds.timeOrigin, grace: graceMs, observationStart}, { timeout: 1500 + graceMs * 3, polling: 50 }); const snapshot = await livesay.readProbeSnapshot(page); From aee952f6730e142c971a2e8c3c724300c0da0514 Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:50:12 +0900 Subject: [PATCH 12/13] Update test.mjs --- examples/livesay-pack/test.mjs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/livesay-pack/test.mjs b/examples/livesay-pack/test.mjs index fde1ac6..1d0d58e 100644 --- a/examples/livesay-pack/test.mjs +++ b/examples/livesay-pack/test.mjs @@ -98,3 +98,10 @@ test('different document origin cannot validate even complete destination answer assert.equal(observationComplete({ids:['x'],baselineOrigin:performance.timeOrigin-100,grace:1200,observationStart:now-5000}),'document-changed'); } finally {globalThis.window=old;} }); + +test('missing initial probe still blocks a cross-document visual comparison',async()=>{ + const c=await fixture(`document.querySelector('#open').onclick=()=>{location.href='/second';};`); + c.scenes[0].expect='#result'; + const broken={...livesay,readProbeSnapshot:async()=>{throw new Error('no probe');}}; + const pack=await runPack(c,broken);assert.equal(pack.rows[0].status,'unverified');assert.equal(pack.rows[0].visual.status,'error');assert.equal(pack.rows[0].visual.images.after,undefined); +}); From bfb2f51584f3bf8adaadf43dd2b65ea6bb37f4b0 Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:54:21 +0900 Subject: [PATCH 13/13] Update test.mjs --- examples/livesay-pack/test.mjs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/livesay-pack/test.mjs b/examples/livesay-pack/test.mjs index 1d0d58e..b59f7aa 100644 --- a/examples/livesay-pack/test.mjs +++ b/examples/livesay-pack/test.mjs @@ -100,8 +100,9 @@ test('different document origin cannot validate even complete destination answer }); test('missing initial probe still blocks a cross-document visual comparison',async()=>{ - const c=await fixture(`document.querySelector('#open').onclick=()=>{location.href='/second';};`); - c.scenes[0].expect='#result'; + const c=await fixture(`if(location.pathname==='/second'){document.querySelector('#result').id='arrived';document.querySelector('#arrived').textContent='Arrived';}document.querySelector('#open').onclick=()=>{setTimeout(()=>location.href='/second',700);};`); + c.scenes[0].steps.push({action:'wait',selector:'#arrived'}); + c.scenes[0].expect='#arrived'; const broken={...livesay,readProbeSnapshot:async()=>{throw new Error('no probe');}}; - const pack=await runPack(c,broken);assert.equal(pack.rows[0].status,'unverified');assert.equal(pack.rows[0].visual.status,'error');assert.equal(pack.rows[0].visual.images.after,undefined); + const pack=await runPack(c,broken);assert.equal(pack.rows[0].status,'unverified');assert.equal(pack.rows[0].visual.status,'error');assert.equal(pack.rows[0].visual.images.after,undefined);assert.match(pack.rows[0].visual.error,/Cross-document scene is blocked/); });