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(runner): end admission wait when execution is ready [C7]

Corey Olsonb1b71cb03469
diff --git a/src/runner-worker.js b/src/runner-worker.js
index ff4d7625..1561ec9b 100644
--- a/src/runner-worker.js
+++ b/src/runner-worker.js
@@ -972,6 +972,7 @@ async function main() {
setupStep = 'command start';
const browserRefusal = join(runDirectory, 'browser-refusal.json');
const commandEnv = { ...env, PULLBOARD_LANDING_RUN: spec.landing === true ? '1' : '0', [api.BROWSER_REFUSAL_FILE_ENV]: browserRefusal, ...(typeof spec.browserByLaunch === 'boolean' ? { PULLBOARD_TEST_BROWSER_BY_LAUNCH: spec.browserByLaunch ? '1' : '0' } : {}), PULLBOARD_LANDING_WAIVERS: JSON.stringify(spec.landing === true ? spec.waivers ?? [] : []) };
+ process.stderr.write(`PULLBOARD_RUNNER_READY ${spec.id}\n`);
final = { ...(spec.trustedMode ? await runPrivateCheck(spec, root, commandEnv, sink, tracker) : await runCommand(spec, root, commandEnv, sink, tracker)), root };
if (final.code !== 0 && existsSync(browserRefusal)) final.browserRefused = true;
} catch (error) {
diff --git a/src/runners.js b/src/runners.js
index bc70c4bf..bf89b916 100644
--- a/src/runners.js
+++ b/src/runners.js
@@ -685,8 +685,8 @@ export async function runOnRunnerAsync(root, command, options) {
let rawBytes = 0, head = Buffer.alloc(0), tail = Buffer.alloc(0);
const half = 4 * 1024 ** 2;
const abort = () => { error ??= new Error('runner transport canceled'); child.stdin.destroy(); child.kill('SIGTERM'); };
- // Only admission is bounded here. NEED is emitted after the worker owns its gate slot;
- // an admitted test may run longer than the runner wait without being truncated.
+ // Bound connection, worker admission and checkout, until READY immediately before execution.
+ // An executing test keeps its existing test timeout and may outlive the runner wait.
if (Number.isSafeInteger(options.runnerWaitDeadline)) runnerWaitTimer = setTimeout(() => {
abort();
// Budget: a non-responsive SSH child cannot retain a local reservation forever.
@@ -725,6 +725,7 @@ export async function runOnRunnerAsync(root, command, options) {
let newline;
while ((newline = control.indexOf('\n')) >= 0) {
const line = control.slice(0, newline); control = control.slice(newline + 1);
+ if (line === `PULLBOARD_RUNNER_READY ${request.spec.id}`) clearTimeout(runnerWaitTimer);
const cleanupPrefix = `PULLBOARD_RUNNER_CLEANUP_UNVERIFIED ${request.spec.id} `;
if (line.startsWith(cleanupPrefix)) cleanupReason = line.slice(cleanupPrefix.length, cleanupPrefix.length + 240);
if (line === `PULLBOARD_RUNNER_CLEANUP_TIMEOUT ${request.spec.id}`) {
@@ -735,7 +736,6 @@ export async function runOnRunnerAsync(root, command, options) {
if (!line.startsWith(prefix)) continue;
if (requested) { error = new Error('duplicate runner inventory'); child.kill(); return; }
requested = true;
- clearTimeout(runnerWaitTimer);
transfer = (async () => {
const inventory = JSON.parse(Buffer.from(line.slice(prefix.length), 'base64').toString('utf8'));
if (!Array.isArray(inventory.tips) || inventory.tips.length > 1024
diff --git a/test/runner-wait-deadline.test.js b/test/runner-wait-deadline.test.js
index ceef54be..e7dd8075 100644
--- a/test/runner-wait-deadline.test.js
+++ b/test/runner-wait-deadline.test.js
@@ -16,14 +16,14 @@ after(cleanupFixtureChildren);
after(cleanupToolingSnapshots);
/** Build the real loopback SSH transport in an isolated machine, with a short private deadline. */
-function fixture({ hold = '', runnerWaitMs = 60 } = {}) {
+function fixture({ hold = '', runnerWaitMs = 60, dropFirst = !hold } = {}) {
const box = e2e.project('true');
const paths = Object.fromEntries(['bin', 'worker', 'remoteHome', 'remoteMachine'].map(name => [name, join(box.dir, name)]));
for (const path of Object.values(paths)) mkdirSync(path, { recursive: true });
const requests = join(box.dir, 'requests.jsonl');
const starts = join(box.dir, 'starts.jsonl');
installSshStandIn({ bin: paths.bin, worker: paths.worker, home: paths.remoteHome,
- machineHome: paths.remoteMachine, requests, starts, hold, dropFirst: !hold });
+ machineHome: paths.remoteMachine, requests, starts, hold, dropFirst });
box.env.PATH = paths.bin + ':' + box.env.PATH;
const added = cli(box.repo, box.env, 'runner', 'add', HOST + '-drop', '--slots', '1', '--browser', '1');
assert.equal(added.status, 0, fixtureResultContext(added));
@@ -160,3 +160,25 @@ test('the public runner deadline setting has a five-minute default and rejects u
assert.equal(readFileSync(file, 'utf8'), before, 'invalid settings never replace the last valid deadline');
}
});
+
+test('an executing runner command keeps its test budget after the admission deadline [C7]', async () => {
+ const box = fixture({ runnerWaitMs: 5_000, dropFirst: false });
+ const previous = [process.env.PULLBOARD_HOME, process.env.PULLBOARD_MACHINE_HOME];
+ process.env.PULLBOARD_HOME = box.env.PULLBOARD_HOME;
+ process.env.PULLBOARD_MACHINE_HOME = box.env.PULLBOARD_MACHINE_HOME;
+ let held;
+ try {
+ held = await takeResource({ name: 'gate', scope: 'machine', root: box.repo, capacity: 1, agent: 'admitted-run-local-holder' });
+ const result = await runThroughGate(box.repo, box.env,
+ 'node -e "setTimeout(()=>console.log(\'ADMITTED_LONG_COMMAND\'),6000)"', { requests: box.requests });
+ assert.equal(result.status, 0, fixtureResultContext(result));
+ assert.match(result.stdout, /ADMITTED_LONG_COMMAND/u);
+ assert.equal(gateResult(result.stdout).runner, HOST + '-drop', 'a ready runner is not canceled or duplicated locally');
+ assert.equal(readFileSync(box.requests, 'utf8').trim().split('\n').length, 1);
+ } finally {
+ held?.release();
+ for (const [index, key] of ['PULLBOARD_HOME', 'PULLBOARD_MACHINE_HOME'].entries()) {
+ if (previous[index] === undefined) delete process.env[key]; else process.env[key] = previous[index];
+ }
+ }
+});