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): trace paired CLI phases in publisher group [A7,C7]

Corey Olson7e0d068de52c
diff --git a/src/cli-main.js b/src/cli-main.js
index 98b66b1a..ce60596a 100644
--- a/src/cli-main.js
+++ b/src/cli-main.js
@@ -290,7 +290,9 @@ async function runMain(argv, streams) {
(await import('./person.js')).requirePersonChannel(io.personChannel);
io.caller('person');
}
+ traceServeStartup('cli-bind-start');
checkoutSession = await bindCheckoutSession(io, parsed.positionals, parsed.values);
+ traceServeStartup('cli-bind-ready');
if (checkoutSession?.lease) CHECKOUT_LEASES.set(io, checkoutSession.lease);
} catch (error) {
if (!(error instanceof Refused)) throw error;
@@ -302,13 +304,16 @@ async function runMain(argv, streams) {
}
}
try {
+ traceServeStartup('cli-trunk-start');
if (needsRepo) await rememberTrunk(io, git);
+ traceServeStartup('cli-trunk-ready');
traceServeStartup('cli-command-preamble-start');
// The relay and baseline work loads only where a relay token, relay state, a link or a pending result exists.
/** Load the work around the command when any of it could act here, or null. */
const syncWork = async () => (sync && (await import('./local-state.js')).syncMayAct(io.cwd) ? import('./cli-sync.js') : null);
await (await syncWork())?.syncBefore(io, main);
traceServeStartup('cli-command-preamble-ready');
+ traceServeStartup('cli-command-dispatch');
const code = await runCommand(argv, io);
traceServeStartup('cli-command-returned');
if (code === 0) await checkoutSession?.finish?.();
@@ -317,8 +322,11 @@ async function runMain(argv, streams) {
traceServeStartup('cli-final-sync-ready');
const status = io.exitCode(code);
if (status === 0 && needsRepo && !parsed?.values['dry-run']) (await import('./blocks.js')).clearCompletedBlocks(io);
+ traceServeStartup('cli-post-sync-ready');
if (status !== 0) await io.prepareRefusal();
+ traceServeStartup('cli-flush-start');
io.flush(status);
+ traceServeStartup('cli-flush-ready');
return status;
} finally {
CHECKOUT_LEASES.delete(io);
diff --git a/test/export-lock-diagnostic.test.js b/test/export-lock-diagnostic.test.js
deleted file mode 100644
index eacce09e..00000000
--- a/test/export-lock-diagnostic.test.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/** Temporary private live-lock diagnostic for #1181; not a product acceptance contract [A7,H16,C7]. */
-import assert from 'node:assert/strict';
-import { test } from 'node:test';
-import { locked } from '../src/relay-lock.js';
-import { legacyRelayClientFixture } from './relay-client-fixture.js';
-
-test('private export diagnostic distinguishes a live relay lock from local export work [A7,H16,C7]', async t => {
- const box = await legacyRelayClientFixture(t);
- await box.link();
- let acquired;
- let release;
- const ready = new Promise(resolve => { acquired = resolve; });
- const released = new Promise(resolve => { release = resolve; });
- const holder = locked(box.linkFile, async () => {
- t.diagnostic('private relay lock acquired by diagnostic process ' + process.pid);
- acquired();
- await released;
- });
- await ready;
- try {
- const result = await box.cliWithSnapshotUploads(0, 'export');
- assert.equal(result.code, 0, 'a local export should complete while the independent private relay sender is held');
- } finally {
- release();
- await holder;
- t.diagnostic('private relay lock released');
- }
-});
diff --git a/test/relay-client-fixture.js b/test/relay-client-fixture.js
index c95a5877..c4756c61 100644
--- a/test/relay-client-fixture.js
+++ b/test/relay-client-fixture.js
@@ -142,7 +142,7 @@ export { childResult as relayFixtureChild };
* fixture once used, a loaded machine kept the test process busy enough that browser replies queued past their
* deadlines (#955, #979). A case that needs a faster poll passes pollMs by name and says why.
*/
-export async function relayClientFixture(t, { cliChildren, coordinatorModel, accountStorageBytes, pollMs = 200 } = {}) {
+export async function relayClientFixture(t, { cliChildren, coordinatorModel, accountStorageBytes, pollMs = 200, traceCliPhases = false } = {}) {
const scratch = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-relay-cleanup-')));
const root = join(scratch, 'repo');
const home = join(scratch, 'home');
@@ -563,9 +563,9 @@ 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 phaseFile = (traceCliPhases || 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,
+ const childEnv = traceSnapshotWrites ? { ...phaseEnv, PULLBOARD_TEST_RELAY_TRACE_FILE: traceFile,
PULLBOARD_TEST_RELAY_TRACE_ORIGIN: origin,
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;
@@ -589,9 +589,9 @@ globalThis.fetch = function tracedFetch(input, init) {
} finally {
if (phaseFile) {
try {
- t.diagnostic('export CLI phase timing: ' + JSON.stringify({ child: cliChildIndex,
+ t.diagnostic('private CLI phase timing: ' + JSON.stringify({ child: cliChildIndex, command: args[0],
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); }
+ } catch (error) { t.diagnostic('private CLI phase timing unavailable: ' + error.code); }
}
}
if (traceSnapshotWrites) result.snapshotTrace = childTrace();
diff --git a/test/relay-person-requests.test.js b/test/relay-person-requests.test.js
index 20e1a238..9712ef46 100644
--- a/test/relay-person-requests.test.js
+++ b/test/relay-person-requests.test.js
@@ -277,7 +277,7 @@ test('real paired Chrome approval remains pending until coordinator applies and
skip: !findChromeExecutable() && 'Chrome is not installed',
timeout: approvalFlowTimeoutMs(APPROVAL_FLOW_CLI_CHILDREN),
}, async t => {
- const box = await relayClientFixture(t, { cliChildren: APPROVAL_FLOW_CLI_CHILDREN });
+ const box = await relayClientFixture(t, { cliChildren: APPROVAL_FLOW_CLI_CHILDREN, traceCliPhases: true });
const title = 'PERSON_REQUEST_APPROVAL_FIXTURE';
const id = 'G98';
const row = addPendingSpecRow(box, id);