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
test(view): only a harness navigation's own commit orphans reads [N40]
Corey Olsona44a0955c3cb
diff --git a/test/cockpit/journey-routes.js b/test/cockpit/journey-routes.jsindex 4491866f..db9b87a4 100644--- a/test/cockpit/journey-routes.js+++ b/test/cockpit/journey-routes.js@@ -51,7 +51,7 @@ export async function journeyForwardHeaders(chrome, asked, condition, pauses) {** @param {string} url - The paused request's URL.* @param {number} pausedAt - When it paused (performance.now()).- * @param {number[]} commits - Main-frame commits seen after the harness's first navigation (performance.now()).+ * @param {number[]} commits - The main-frame commits that answered the harness's own navigations, one each (performance.now()).*/export function journeyNavigationOrphan(url, pausedAt, commits) {return new URL(url).pathname.startsWith('/api/') && commits.some((committedAt) => committedAt > pausedAt);@@ -73,10 +73,15 @@ export async function routeJourneyOrigins(chrome, site, view, slow = null, pauseconst commits = [];const tasks = [];let navigatedAt = -Infinity;+ // Each harness navigation arms one commit; a commit the page makes on its own never counts (#935 review).+ let awaitingCommit = false;const listener = ({ data }) => {const message = JSON.parse(String(data));// A main-frame commit after the harness navigated replaces the document whose paused reads Chrome then retires.- if (message.method === 'Page.frameNavigated' && !message.params.frame?.parentId && Number.isFinite(navigatedAt)) commits.push(performance.now());+ if (message.method === 'Page.frameNavigated' && !message.params.frame?.parentId && awaitingCommit) {+ awaitingCommit = false;+ commits.push(performance.now());+ }if (message.method !== 'Fetch.requestPaused') return;const pausedAt = performance.now();tasks.push((async () => {@@ -143,7 +148,7 @@ export async function routeJourneyOrigins(chrome, site, view, slow = null, pauseawait Promise.all(tasks);await chrome.send('Fetch.disable');for (const entry of retired) {- if (journeyNavigationOrphan(entry.url, entry.pausedAt, commits)) { if (orphaned.length < 64) orphaned.push(entry.kind); }+ if (journeyNavigationOrphan(entry.url, entry.pausedAt, commits)) orphaned.push(entry.kind);else failures.push(entry.failure);}assert.deepEqual(failures, [], `owned hosted and loopback HTTP routes finish without cancelling event streams (orphaned by navigation: ${JSON.stringify(orphaned)})`);@@ -151,6 +156,7 @@ export async function routeJourneyOrigins(chrome, site, view, slow = null, pause/** Navigate the page, marking the moment so requests already paused for the old document are known as orphaned. */stop.navigate = async (url) => {navigatedAt = performance.now();+ awaitingCommit = true;await chrome.send('Page.navigate', { url });};return stop;diff --git a/test/cockpit/journey-routes.test.js b/test/cockpit/journey-routes.test.jsindex 13540e7f..52a123f7 100644--- a/test/cockpit/journey-routes.test.js+++ b/test/cockpit/journey-routes.test.js@@ -17,9 +17,11 @@ function retiredInterceptionChrome() {if (method === 'Page.navigate') queueMicrotask(() => socket.dispatchEvent(new MessageEvent('message', { data: JSON.stringify({ method: 'Page.frameNavigated', params: { frame: { id: 'main' } } }) })));return {};};+ // A main-frame commit the page makes on its own, with no harness navigation pending.+ const commit = () => socket.dispatchEvent(new MessageEvent('message', { data: JSON.stringify({ method: 'Page.frameNavigated', params: { frame: { id: 'main' } } }) }));const pause = (id) => socket.dispatchEvent(new MessageEvent('message', { data: JSON.stringify({ method: 'Fetch.requestPaused',params: { requestId: id, resourceType: 'XHR', request: { url: JOURNEY_HOSTED + '/api/v2/boards/b/objects/' + id, method: 'GET', headers: {} } } }) }));- return { socket, send, pause };+ return { socket, send, pause, commit };}test('only an API read paused before the journey\'s navigation commits is set aside as orphaned [N40,N26]', async () => {@@ -35,6 +37,14 @@ test('only an API read paused before the journey\'s navigation commits is set asawait failingRoute.navigate('about:blank');after.pause('paused-after');await assert.rejects(failingRoute(), (error) => /Invalid InterceptionId/u.test(error.message) && /orphaned by navigation: \[\]/u.test(error.message));+ // A commit the page makes on its own after the harness's navigation committed orphans nothing (#935 review).+ const unowned = retiredInterceptionChrome();+ const unownedRoute = await routeJourneyOrigins(unowned, site, site);+ await unownedRoute.navigate('about:blank');+ unowned.pause('paused-before-unowned-commit');+ await new Promise((settled) => { setImmediate(settled); });+ unowned.commit();+ await assert.rejects(unownedRoute(), (error) => /Invalid InterceptionId/u.test(error.message) && /orphaned by navigation: \[\]/u.test(error.message));assert.equal(journeyNavigationOrphan(JOURNEY_HOSTED + '/index.html', 1, [2]), false, 'a page asset is never an orphan');assert.equal(journeyNavigationOrphan(JOURNEY_HOSTED + '/api/v1/boards', 3, [2]), false, 'a read that paused after the commit is not an orphan');assert.equal(journeyNavigationOrphan(JOURNEY_HOSTED + '/api/v1/boards', 1, []), false, 'without a commit nothing is an orphan');