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.

fix(test): wait for bisection progress [C7]

Corey Olsonf16828267f4e
diff --git a/test/fixture-progress.js b/test/fixture-progress.js
new file mode 100644
index 00000000..0b1fa663
--- /dev/null
+++ b/test/fixture-progress.js
@@ -0,0 +1,28 @@
+/** Wait for a private child handshake without treating continuing work as a speed failure [C7]. */
+import { performance } from 'node:perf_hooks';
+import { setTimeout as pauseFor } from 'node:timers/promises';
+
+/**
+ * Fail when the child exits or stops advancing, not after an absolute elapsed deadline.
+ * progress returns a monotonically growing count of observed output or fixture marker bytes.
+ */
+export async function waitForFixtureProgress({ child, ready, progress, description,
+ quietMs = 20_000, now = () => performance.now(), pause = pauseFor }) {
+ let observedProgress = progress();
+ let advancedAt = now();
+ for (;;) {
+ if (child.exitCode !== null || child.signalCode !== null) {
+ throw new Error(`${description}: child exited (code ${child.exitCode}, signal ${child.signalCode})`);
+ }
+ if (ready()) return;
+ const currentProgress = progress();
+ const at = now();
+ if (currentProgress > observedProgress) {
+ observedProgress = currentProgress;
+ advancedAt = at;
+ } else if (at - advancedAt >= quietMs) {
+ throw new Error(`${description}: child made no progress for ${quietMs} ms`);
+ }
+ await pause(25);
+ }
+}
diff --git a/test/fixture-progress.test.js b/test/fixture-progress.test.js
new file mode 100644
index 00000000..837a053d
--- /dev/null
+++ b/test/fixture-progress.test.js
@@ -0,0 +1,54 @@
+/** Private-child progress waits retain liveness and hang controls [C7]. */
+import assert from 'node:assert/strict';
+import { test } from 'node:test';
+import { waitForFixtureProgress } from './fixture-progress.js';
+
+test('a progressing fixture may cross the old total deadline [C7]', async () => {
+ let clock = 0;
+ await waitForFixtureProgress({
+ child: { exitCode: null, signalCode: null },
+ ready: () => clock >= 60_000,
+ progress: () => Math.floor(clock / 10_000),
+ description: 'progressing fixture',
+ now: () => clock,
+ pause: async () => {
+ clock += 5_000;
+ assert.ok(clock <= 60_000, 'the ready handshake must end the wait');
+ },
+ });
+ assert.equal(clock, 60_000);
+});
+
+test('an alive fixture with no progress fails at the quiet window [C7]', async () => {
+ let clock = 0;
+ await assert.rejects(waitForFixtureProgress({
+ child: { exitCode: null, signalCode: null },
+ ready: () => false,
+ progress: () => 0,
+ description: 'stalled fixture',
+ now: () => clock,
+ pause: async () => {
+ clock += 5_000;
+ assert.ok(clock <= 20_000, 'a stalled wait must stop at its quiet window');
+ },
+ }), /stalled fixture: child made no progress for 20000 ms/u);
+ assert.equal(clock, 20_000);
+});
+
+test('an exited fixture fails before the quiet window [C7]', async () => {
+ let clock = 0;
+ const child = { exitCode: null, signalCode: null };
+ await assert.rejects(waitForFixtureProgress({
+ child,
+ ready: () => false,
+ progress: () => 0,
+ description: 'exited fixture',
+ now: () => clock,
+ pause: async () => {
+ clock += 5_000;
+ assert.equal(clock, 5_000, 'an exited child must not wait for another poll');
+ child.exitCode = 7;
+ },
+ }), /exited fixture: child exited \(code 7, signal null\)/u);
+ assert.equal(clock, 5_000);
+});
diff --git a/test/land.test.js b/test/land.test.js
index 9b6d9f24..a9e899ae 100644
--- a/test/land.test.js
+++ b/test/land.test.js
@@ -9,6 +9,7 @@ import { exportBoard, importBoard } from '../src/exchange.js';
import { landingFailures, landingSubject } from '../src/land.js';
import { createE2eHelpers } from './e2e-helpers.js';
import { startFixtureChild, runFixtureChild } from './fixture-child.js';
+import { waitForFixtureProgress } from './fixture-progress.js';
import { assertNoRemoteLanding } from './land-no-remote-fixture.js';
import { MARKER_NOT_YET, readMarker } from './land-marker-fixture.js';
import { assertLandingStopIdentity } from './land-stop-fixture.js';
@@ -1262,13 +1263,21 @@ test('land bisect adoption retains completed gates, isolated diagnostics and ori
writeFileSync(box.trace, '');
writeFileSync(box.hold, '3');
const child = startFixtureChild(process.execPath, [BIN, 'land', '--json'], { cwd: box.repo, env: box.env, detached: true, stdio: ['ignore', 'pipe', 'pipe'] });
- child.stdout.resume(); child.stderr.resume();
+ let outputBytes = 0;
+ child.stdout.on('data', part => { outputBytes += Buffer.byteLength(part); });
+ child.stderr.on('data', part => { outputBytes += Buffer.byteLength(part); });
const closed = new Promise((resolveClose) => child.once('close', (status, signal) => resolveClose({ status, signal })));
t.after(() => {
writeFileSync(box.release, 'release');
if (child.exitCode === null && child.signalCode === null) { try { process.kill(-child.pid, 'SIGKILL'); } catch {} }
});
- await waitFor(() => existsSync(box.entered), 'third full gate inside bisection', 20000); // budget: hang ceiling for the third private bisection gate entry handshake; no throughput claim.
+ await waitForFixtureProgress({
+ child,
+ ready: () => existsSync(box.entered),
+ progress: () => outputBytes + [box.calls, box.trace].reduce((bytes, file) =>
+ bytes + (existsSync(file) ? readFileSync(file).length : 0), 0),
+ description: 'third full gate inside bisection',
+ });
const interrupted = json(box, box.repo, 'resume').landingBatches.at(-1);
assert.equal(interrupted.items.length, 2, 'the current half differs from the original four candidates');
assert.equal(interrupted.gateResults.length, 2);