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(land): record process states on custody failure [Q3,C7]

Corey Olson788d14b8cce2
diff --git a/test/landing-queue-fixture.js b/test/landing-queue-fixture.js
index ba7abcd0..7d8ef640 100644
--- a/test/landing-queue-fixture.js
+++ b/test/landing-queue-fixture.js
@@ -1,5 +1,6 @@
/** Public, real-Git landing contention fixture; no private drill data is used [B3,R3,Q1,Q2,E8]. */
import assert from 'node:assert/strict';
+import { spawnSync } from 'node:child_process';
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import * as store from '../src/board.js';
@@ -24,6 +25,12 @@ function alive(pid) {
catch (error) { if (error.code === 'ESRCH') return false; throw error; }
}
+/** Retain actual states for only this fixture's known PIDs when a custody assertion fails. */
+function processObservation(pids) {
+ const result = spawnSync('/bin/ps', ['-o', 'pid=,ppid=,pgid=,stat=', '-p', pids.join(',')], { encoding: 'utf8' });
+ return { status: result.status, states: result.stdout?.trim() ?? '', error: result.error?.code ?? null };
+}
+
/** Build two independent items and accept the higher id first through actual CLI checks. */
function acceptedPair(helpers, box, staleAfterFirst) {
const entries = [1, 2].map(number => {
@@ -121,8 +128,15 @@ export async function landingQueueCase(t, helpers, { staleAfterFirst = false, ki
} else if (killGuardian) {
process.kill(holder.guardianPid, 'SIGKILL'); // This exact PID came from this private command's bound guardian.
} else first.kill('SIGSTOP'); // Keep IPC connected while the authority owner cannot renew or run its own watchdog.
- await helpers.waitFor(() => !alive(holder.guardianPid) && !alive(blockedGatePid), 'the guardian and blocked gate stop without releasing their marker',
- suspendParent ? 45_000 : 8_000); // Budget: actual 30s lease expiry plus owned-process drain; not a speed threshold.
+ try {
+ await helpers.waitFor(() => !alive(holder.guardianPid) && !alive(blockedGatePid), 'the guardian and blocked gate stop without releasing their marker',
+ suspendParent ? 45_000 : 8_000); // Budget: actual 30s lease expiry plus owned-process drain; not a speed threshold.
+ } catch (error) {
+ const batch = readBoard(box, board => store.landingBatches(board).at(-1));
+ error.message += '; custody observation: ' + JSON.stringify({ processes: processObservation([first.pid, holder.guardianPid, blockedGatePid, second.pid]),
+ firstExit: first.exitCode, secondExit: second.exitCode, batchState: batch.state, revision: batch.revision, releaseExists: existsSync(release) });
+ throw error;
+ }
if (suspendParent) {
const successor = await second.closed;
assert.equal(successor.code, 0, successor.failure ?? 'the queued adopter lands only after the previous gate is dead');