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.

test(core): observe stalled export phases [A7,C7]

Corey Olsonbdb7ea606ca7
diff --git a/src/cli-main.js b/src/cli-main.js
index 2698a048..98b66b1a 100644
--- a/src/cli-main.js
+++ b/src/cli-main.js
@@ -310,8 +310,11 @@ async function runMain(argv, streams) {
await (await syncWork())?.syncBefore(io, main);
traceServeStartup('cli-command-preamble-ready');
const code = await runCommand(argv, io);
+ traceServeStartup('cli-command-returned');
if (code === 0) await checkoutSession?.finish?.();
+ traceServeStartup('cli-final-sync-start');
if (code === 0) await (await syncWork())?.retrySync(io);
+ traceServeStartup('cli-final-sync-ready');
const status = io.exitCode(code);
if (status === 0 && needsRepo && !parsed?.values['dry-run']) (await import('./blocks.js')).clearCompletedBlocks(io);
if (status !== 0) await io.prepareRefusal();
diff --git a/test/relay-client-fixture.js b/test/relay-client-fixture.js
index 3ad91818..c95a5877 100644
--- a/test/relay-client-fixture.js
+++ b/test/relay-client-fixture.js
@@ -563,9 +563,11 @@ globalThis.fetch = function tracedFetch(input, init) {
/** Observe only this child's received work; retries consume the same finite six-unit allowance. */
const observedWork = () => ({ legacyUploads: snapshotWriteCount - writesBefore,
...Object.fromEntries(Object.entries(pageWork).map(([name, count]) => [name, count - pagesBefore[name]])) });
+ const phaseFile = args[0] === 'export' ? join(scratch, `export-phase-${cliChildIndex}-${Date.now()}.jsonl`) : null;
+ const phaseEnv = phaseFile ? { ...env, PULLBOARD_STARTUP_TRACE_ENTRY: CLI, PULLBOARD_STARTUP_TRACE_FILE: phaseFile } : env;
const childEnv = traceSnapshotWrites ? { ...env, PULLBOARD_TEST_RELAY_TRACE_FILE: traceFile,
PULLBOARD_TEST_RELAY_TRACE_ORIGIN: origin,
- NODE_OPTIONS: [env.NODE_OPTIONS, '--import=' + pathToFileURL(tracePreload).href].filter(Boolean).join(' ') } : env;
+ NODE_OPTIONS: [env.NODE_OPTIONS, '--import=' + pathToFileURL(tracePreload).href].filter(Boolean).join(' ') } : phaseEnv;
const traceLinesBefore = traceSnapshotWrites ? readFileSync(traceFile, 'utf8').split('\n').filter(Boolean).length : 0;
const initialUploads = traceSnapshotWrites ? 0 : snapshotUploads ?? DEFAULT_SNAPSHOT_UPLOADS;
/** Read only this child’s sanitized fetch records, retaining evidence before fixture cleanup. */
@@ -584,6 +586,13 @@ globalThis.fetch = function tracedFetch(input, init) {
throw new Error(`${message}; safe snapshot transport evidence: ${evidence}`, { cause: error });
}
throw error;
+ } finally {
+ if (phaseFile) {
+ try {
+ t.diagnostic('export CLI phase timing: ' + JSON.stringify({ child: cliChildIndex,
+ phases: existsSync(phaseFile) ? readFileSync(phaseFile, 'utf8').trim().split('\n').filter(Boolean).map(line => JSON.parse(line)) : [] }));
+ } catch (error) { t.diagnostic('export CLI phase timing unavailable: ' + error.code); }
+ }
}
if (traceSnapshotWrites) result.snapshotTrace = childTrace();
if (cliChildren) {