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.

feat(gate): a short check never waits behind whole suites [C7]

Corey Olsonf5c723d5f3a0
diff --git a/bin/run-tests.js b/bin/run-tests.js
index 93e4be33..e7b1c910 100644
--- a/bin/run-tests.js
+++ b/bin/run-tests.js
@@ -1379,7 +1379,7 @@ async function main(args) {
}
}
if (scopedMarker) {
- const inherited = inheritedGateSlot({ root: process.cwd(), browser, fullSuite: !shortEligible });
+ const inherited = inheritedGateSlot({ root: process.cwd(), browser, namedFiles: shortEligible });
if (inherited) await run(gateSlotEnvironment(inherited));
else await acquire();
} else if (legacyHeld) {
diff --git a/docs/api.md b/docs/api.md
index 1cae332b..2ec55359 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -8,14 +8,14 @@ Decision shouts without a recipient go to the agent's coordinator, or to `person
A successful command returns the fields listed below. `version` is always the number `1`. The catalog lists required top-level fields; nested objects and arrays are command data, and optional top-level fields may be added.
-Resource pool output includes the configured `gate.shortSlots`; holder entries identify an assigned `slot` (`gate` or `short`), and queued entries may report `requestedSlot: "short-eligible"`. These fields describe queue allocation and do not change the `gateSlots` value.
-
-`pullboard settings` reads machine-wide settings from the OS account's `~/.pullboard/settings.json`; the gate queue database is beside it. This location does not follow `HOME` or `PULLBOARD_HOME`, so agents with private board homes still share one machine gate limit. Set `PULLBOARD_MACHINE_HOME` to an explicit directory only when a separate private machine settings and gate pool is intended; tests use this override. `pullboard settings gateSlots <n>` changes the ordinary gate queue capacity, which defaults to `2`. `pullboard settings gate.shortSlots <n>` sets the optional named-check pool (default `0`, off). Short capacity does not increase `gateSlots`, and whole suites never use it. Capacity changes are refused while the shared gate queue is active, so existing holders and FIFO order remain intact.
+`pullboard settings` reads machine-wide settings from the OS account's `~/.pullboard/settings.json`; the gate queue database is beside it. This location does not follow `HOME` or `PULLBOARD_HOME`, so agents with private board homes still share one machine gate limit. Set `PULLBOARD_MACHINE_HOME` to an explicit directory only when a separate private machine settings and gate pool is intended; tests use this override. `pullboard settings gateSlots <n>` changes the gate queue capacity, which defaults to `2`. Capacity changes are refused while a gate is running or waiting, so existing holders and FIFO order remain intact.
Browser-free check admission is opt-in per machine with `"gate": { "browserFreeChecks": true }` in `~/.pullboard/settings.json`; it defaults to `false`. When enabled, the reviewed test classifier can let checks use a CPU-only gate slot. An absent or false setting keeps every check browser-gated, and uncertain or unsupported test commands remain browser-gated even when enabled. The same setting controls the wider frozen-check classification introduced in 0.8.26.
The machine gate pool admits landings first and then everything else in arrival order. A machine opts in to reviews first with `"gate": { "queue": { "reviewsFirst": true } }` in `~/.pullboard/settings.json`: the pool then admits landing runs, then reviews, then submits and item checks, then focused and other runs, first come first served within each class. `gate.queue.agingMinutes` (a positive whole number, default `30`) is how long a waiting run waits before it moves up one class, so no class starves; it is used only while `reviewsFirst` is true. `pullboard settings` prints both values, and `pullboard resources` names the order in effect.
+Short gate slots are opt-in per machine with `pullboard settings gate.shortSlots <n>`, stored as `"gate": { "shortSlots": n }`; the default `0` keeps them off and the pool behaves as before. With `n` above `0`, up to `n` runs that name their test files (a `pullboard check` or a review whose check is a literal `node bin/run-tests.js` call over test files, or a direct `node bin/run-tests.js <files>`) are admitted on short slots while every gate slot is held. Whole suites, directories, landings, diagnostics and anything the parser cannot read never use them, and a child that does not name its files cannot reuse a short lease (`SHORT_SLOT_FULL_SUITE`). Short slots do not add to `gateSlots`, and browser runs still count against `browserSlots`. `pullboard settings` prints `gate.shortSlots`; `pullboard resources --json` reports `shortSlots`, each gate holder's `slot` (`gate` or `short`), and `requestedSlot: "short-eligible"` on a waiting run that may take one.
+
When `add` or `edit` supplies a new nonempty check, it records the item before measuring that check in a background temporary checkout of the captured `main` commit. Use `--wait` to wait for the measurement before returning, or `args.wait: true` for an HTTP add/edit move. The item returned by `add`, `edit`, `show`, and `next --verify` may include `item_check_baseline`: `{command, main, result, request?, seconds?, reason?, warning?}`. `main` is the commit id or `null`, and `result` is `pending`, `green`, `red`, or `unavailable`. A background request carries an opaque `request` identity; an older completion cannot overwrite a newly edited or cleared check.
An item's HTTP detail, and each item in the full board state, include `check` and, when recorded, `checkBaseline` with the same observation fields. A green result carries `warning: "CRITERION_PROVES_NOTHING"`; text output names that warning when showing or reserving the item for review, and when filing it with `--wait`. An exact match with the project gate configured at that main commit records green with `reason: "repo gate"` without running it again. A missing main records unavailable with `reason: "no main"` and still files the item. Changing the check replaces this observation; clearing it removes the observation. Captured observations and completions travel through ordered board moves, so replicas store results without executing commands. A completed result awaiting relay delivery stays on the measuring device and is retried by the next normal CLI command.
diff --git a/src/browser-admission.js b/src/browser-admission.js
index acdd30a4..06de7b2b 100644
--- a/src/browser-admission.js
+++ b/src/browser-admission.js
@@ -224,73 +224,24 @@ function browserFallback(onFallback, file, reason) {
return true;
}
-/** Parse the same literal frozen-runner grammar used by browser admission, returning a reason on uncertainty. */
-async function explicitCheckSelection(root, command, { env = process.env } = {}) {
- if (env.NODE_OPTIONS) return { file: '<frozen check>', reason: 'NODE_OPTIONS may load an unclassified module' };
+/** Parse the frozen check and classify its explicit test files, failing closed on unknown shell. */
+export async function checkNeedsBrowser(root, command, { commit, env = process.env, onFallback } = {}) {
+ if (env.NODE_OPTIONS) return browserFallback(onFallback, '<frozen check>', 'NODE_OPTIONS may load an unclassified module');
let words = literalShellWords(command);
if (!words) {
const inner = capturedRunner(command);
- if (!inner) return { file: '<frozen check>', reason: 'shell syntax is outside the supported literal capture form' };
+ if (!inner) return browserFallback(onFallback, '<frozen check>', 'shell syntax is outside the supported literal capture form');
const grep = resolveExecutable('grep', env.PATH);
- if (!grep || !['/usr/bin/grep', '/bin/grep'].includes(await realpath(grep).catch(() => ''))) {
- return { file: '<frozen check>', reason: 'capture wrapper does not resolve the system grep' };
- }
+ if (!grep || !['/usr/bin/grep', '/bin/grep'].includes(await realpath(grep).catch(() => ''))) return browserFallback(onFallback, '<frozen check>', 'capture wrapper does not resolve the system grep');
words = literalShellWords(inner);
}
- if (!words || words.length < 3) return { file: '<frozen check>', reason: 'command is not an explicit Node test selection' };
+ if (!words || words.length < 3) return browserFallback(onFallback, '<frozen check>', 'command is not an explicit Node test selection');
const node = resolveExecutable(words[0], env.PATH);
- if (!node || await realpath(node).catch(() => '') !== await realpath(process.execPath).catch(() => '')) {
- return { file: '<frozen check>', reason: 'Node executable does not resolve to this runtime' };
- }
- if (resolve(root, words[1]) !== resolve(root, TEST_RUNNER)) {
- return { file: '<frozen check>', reason: 'runner is not bin/run-tests.js in this repository' };
- }
+ if (!node || await realpath(node).catch(() => '') !== await realpath(process.execPath).catch(() => '')) return browserFallback(onFallback, '<frozen check>', 'Node executable does not resolve to this runtime');
+ const runner = resolve(root, words[1]);
+ if (runner !== resolve(root, TEST_RUNNER)) return browserFallback(onFallback, '<frozen check>', 'runner is not bin/run-tests.js in this repository');
const files = explicitRunnerFiles(words.slice(2));
- if (!files) return { file: '<frozen check>', reason: 'runner options or test selection are not statically understood' };
- return { files };
-}
-
-/** Return exact parser-backed named files only when the runner and selected files are real in-root sources.
- * @param {string} root
- * @param {string} command
- * @param {{commit?:string,env?:NodeJS.ProcessEnv}} [options]
- * @returns {Promise<string[]|null>}
- */
-export async function explicitCheckFiles(root, command, { commit, env = process.env } = {}) {
- const selection = await explicitCheckSelection(root, command, { env });
- if (!selection.files) return null;
- if (commit) {
- const committed = committedFiles(root, commit);
- if (!committed) return null;
- const runner = committed.get(TEST_RUNNER);
- if (!runner || runner.type !== 'blob' || !['100644', '100755'].includes(runner.mode)) return null;
- if (selection.files.some(file => {
- const entry = committed.get(file);
- return !entry || entry.type !== 'blob' || !['100644', '100755'].includes(entry.mode);
- })) return null;
- return selection.files;
- }
- const runnerPath = resolve(root, TEST_RUNNER);
- if (await realpath(runnerPath).catch(() => '') !== await realpath(resolve(root, TEST_RUNNER)).catch(() => '')) return null;
- const runnerInfo = await lstat(runnerPath).catch(() => null);
- let runnerInside = false;
- try { runnerInside = await staysInside(root, runnerPath); } catch { /* unresolved paths remain ordinary */ }
- if (!runnerInfo?.isFile() || runnerInfo.isSymbolicLink() || !runnerInside) return null;
- for (const file of selection.files) {
- const absolute = resolve(root, file);
- const info = await lstat(absolute).catch(() => null);
- let inside = false;
- try { inside = await staysInside(root, absolute); } catch { /* unresolved paths remain ordinary */ }
- if (!info?.isFile() || info.isSymbolicLink() || !inside) return null;
- }
- return selection.files;
-}
-
-/** Parse the frozen check and classify its explicit test files, failing closed on unknown shell. */
-export async function checkNeedsBrowser(root, command, { commit, env = process.env, onFallback } = {}) {
- const selection = await explicitCheckSelection(root, command, { env });
- if (!selection.files) return browserFallback(onFallback, selection.file, selection.reason);
- const { files } = selection;
+ if (!files) return browserFallback(onFallback, '<frozen check>', 'runner options or test selection are not statically understood');
if (files.some(file => file === JOURNEYS_TEST || file === 'test/cockpit' || file.startsWith('test/cockpit/'))) return true;
if (commit) {
const committed = committedFiles(root, commit);
@@ -298,7 +249,6 @@ export async function checkNeedsBrowser(root, command, { commit, env = process.e
if (!runnerEntry || runnerEntry.type !== 'blob' || !['100644', '100755'].includes(runnerEntry.mode)) return browserFallback(onFallback, TEST_RUNNER, 'committed runner is missing or is not a regular file');
return testsNeedBrowserInTree(root, files, committed, onFallback);
}
- const runner = resolve(root, TEST_RUNNER);
if (await realpath(runner).catch(() => '') !== await realpath(resolve(root, TEST_RUNNER)).catch(() => '')) return browserFallback(onFallback, TEST_RUNNER, 'runner resolves outside the expected repository path');
const runnerInfo = await lstat(runner).catch(() => null);
let runnerInside = false;
@@ -307,6 +257,49 @@ export async function checkNeedsBrowser(root, command, { commit, env = process.e
return testsNeedBrowser(root, files, { onFallback });
}
+/**
+ * Name the test files a check runs when it is a literal bin/run-tests.js call over regular in-repository
+ * test files, or return null. Only such a check may take a short gate slot (gate.shortSlots); anything
+ * uncertain, a directory or discovery included, stays an ordinary run. Kept apart from checkNeedsBrowser
+ * so short-slot admission never changes how a check is classified for the browser.
+ *
+ * @param {string} root
+ * @param {string} command
+ * @param {{ commit?: string, env?: NodeJS.ProcessEnv }} [options] - commit reads the files from that tree
+ * @returns {Promise<string[] | null>}
+ */
+export async function explicitCheckFiles(root, command, { commit, env = process.env } = {}) {
+ if (env.NODE_OPTIONS) return null;
+ let words = literalShellWords(command);
+ if (!words) {
+ const inner = capturedRunner(command);
+ const grep = inner ? resolveExecutable('grep', env.PATH) : null;
+ if (!grep || !['/usr/bin/grep', '/bin/grep'].includes(await realpath(grep).catch(() => ''))) return null;
+ words = literalShellWords(inner);
+ }
+ if (!words || words.length < 3) return null;
+ const node = resolveExecutable(words[0], env.PATH);
+ if (!node || await realpath(node).catch(() => '') !== await realpath(process.execPath).catch(() => '')) return null;
+ if (resolve(root, words[1]) !== resolve(root, TEST_RUNNER)) return null;
+ const files = explicitRunnerFiles(words.slice(2));
+ if (!files) return null;
+ if (commit) {
+ const committed = committedFiles(root, commit);
+ const regular = path => {
+ const entry = committed?.get(path);
+ return Boolean(entry) && entry.type === 'blob' && ['100644', '100755'].includes(entry.mode);
+ };
+ return [TEST_RUNNER, ...files].every(regular) ? files : null;
+ }
+ for (const path of [TEST_RUNNER, ...files]) {
+ const absolute = resolve(root, path);
+ const info = await lstat(absolute).catch(() => null);
+ const inside = await staysInside(root, absolute).catch(() => false);
+ if (!info?.isFile() || info.isSymbolicLink() || !inside) return null;
+ }
+ return files;
+}
+
/** Convert an in-root absolute or relative selection to a normalized repository-relative path. */
function repositoryPath(root, file) {
if (typeof file !== 'string' || !file) return null;
diff --git a/src/cli.js b/src/cli.js
index b951e558..c7d4220a 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -85,7 +85,7 @@ import { flowLines, flowAlertLine } from './stats-flow.js';
import { releaseHeadlinesBetween } from './changelog.js';
import { exportBoard, importBoard } from './exchange.js';
import { addSigner, assertRequiredSigners, defaultPrincipal, hasSignerFile } from './signature.js';
-import { addRunner, browserFreeChecksEnabled, gateQueueSettings, loadMachineSettings, setBrowserSlots, setGateShortSlots, setGateSlots } from './settings.js';
+import { addRunner, browserFreeChecksEnabled, gateQueueSettings, gateShortSlots, loadMachineSettings, setBrowserSlots, setGateShortSlots, setGateSlots } from './settings.js';
import { formatSnapshotLimit, pendingSnapshotSize, pendingCheckpointProblem, relayCommandReceipt, relayCommandReceiptReported, relayLinked, relayOff, relayOn, relayOperation, relayRecover, relayRecovered, relayRevoke, relayStatus, relayTokens, syncRelay } from './relay.js';
import { autoLinkProject, relayOnAll, revokeRelayDevice, unlinkedRelayProjects } from './relay-setup.js';
import { readRelayMachine } from './relay-machine.js';
@@ -1925,24 +1925,23 @@ function readCommands(io, { first, second, rest, values }) {
resources: () => {
const ctx = context(io);
const agents = withBoard(ctx, (board) => store.listAgents(board));
- const machineSettings = loadMachineSettings();
- const browserSlots = machineSettings.browserSlots;
- const shortSlots = machineSettings.gate.shortSlots;
+ const browserSlots = loadMachineSettings().browserSlots;
const resources = [
...listResources({ scope: 'machine' }).map((resource) => ({ ...resource, scope: 'machine' })),
...listResources({ scope: 'repo', root: ctx.info.root }).map((resource) => ({ ...resource, scope: 'repo' })),
];
const runners = runnerResourceStatus(loadMachineSettings().runners ?? []);
const queue = gateQueueSettings();
- io.result?.({ resources, runners, browserSlots, queue, gate: { shortSlots } });
+ const shortSlots = gateShortSlots();
+ io.result?.({ resources, runners, browserSlots, queue, shortSlots });
io.say(`browserSlots (machine setting): ${browserSlots}`);
io.say(`machine queue order (gate.queue.reviewsFirst ${queue.reviewsFirst}): ${queue.reviewsFirst ? `landing, review, submit, other; a waiting run moves up one class every ${queue.agingMinutes} minutes` : 'landings first, then arrival'}`);
- io.say(`gate.shortSlots (machine setting): ${shortSlots}`);
+ if (shortSlots) io.say(`gate.shortSlots (machine setting): ${shortSlots}; runs that name their test files may use them while every gate slot is busy`);
if (!resources.length) io.say('no resources have been used');
for (const resource of resources) {
io.say(`${resource.name} (${resource.scope}, capacity ${resource.capacity})${resource.order === 'arrival' ? '; an older pullboard is waiting, so this line is in arrival order, landings first' : ''}`);
- for (const holder of resource.holders) io.say(` held by ${agentDisplayName(agents, ctx.config, holder.agent)}${holder.repo ? ` in ${holder.repo}` : ''}${resourceRunLabel(holder)} since ${holder.since}`);
- resource.line.forEach((waiter, index) => io.say(` ${index + 1}. waiting: ${agentDisplayName(agents, ctx.config, waiter.agent)}${waiter.repo ? ` in ${waiter.repo}` : ''}${resourceRunLabel(waiter)}; class ${waiter.queueClass}${waiter.agedFrom ? `, aged up from ${waiter.agedFrom}` : ''}`));
+ for (const holder of resource.holders) io.say(` held by ${agentDisplayName(agents, ctx.config, holder.agent)}${holder.repo ? ` in ${holder.repo}` : ''}${resourceRunLabel(holder, shortSlots)} since ${holder.since}`);
+ resource.line.forEach((waiter, index) => io.say(` ${index + 1}. waiting: ${agentDisplayName(agents, ctx.config, waiter.agent)}${waiter.repo ? ` in ${waiter.repo}` : ''}${resourceRunLabel(waiter, shortSlots)}; class ${waiter.queueClass}${waiter.agedFrom ? `, aged up from ${waiter.agedFrom}` : ''}`));
}
for (const runner of runners) io.say(`runner ${runner.host}: ${runner.inUse}/${runner.slots} slots, ${runner.browserInUse}/${runner.browser} browser${runner.unavailable ? ' (unavailable; re-register after checking the host)' : ''}`);
return 0;
@@ -2471,9 +2470,8 @@ async function verifyHere(ctx, id, { second, values }) {
if (digest !== item.item_frozen_digest) throw new Refused('CRITERIA_CHANGED', 'the criterion changed; ask the coordinator to refreeze this item before checking it');
const trunk = requireTrunkMerge(root, commit);
refuseUnverifiedStack(root, board, item, commit, trunk);
- const frozenCommand = frozenCheck(item);
- const shortEligible = Boolean(await explicitCheckFiles(root, frozenCommand, { commit }));
- const browser = !browserFreeChecksEnabled() || await checkNeedsBrowser(root, frozenCommand, { commit, onFallback: browserAdmissionReporter(ctx.io, ctx.io.relayJson) });
+ const browser = !browserFreeChecksEnabled() || await checkNeedsBrowser(root, frozenCheck(item), { commit, onFallback: browserAdmissionReporter(ctx.io, ctx.io.relayJson) });
+ const shortEligible = Boolean(await explicitCheckFiles(root, frozenCheck(item), { commit }));
check = await withGateSlot(root, (lease) => checkAtCommit(root, item, { waitMs: lease.waitMs, gateLease: lease }), { browser, agent: me.id, item: String(id), kind: 'review', itemCheck: true, shortEligible, onWait: gateWaitReporter(ctx.io) });
refuseSandboxBlocked(check);
verificationProfile = check.profile ?? null;
@@ -2955,8 +2953,8 @@ function workCommands(io, args) {
throw new Refused('CHECK_CONFIRM', `the check set by ${authorName} was not run: ${check}; run pullboard check ${item.item_id} --yes after reading the command, or answer yes at the prompt`);
}
}
- const shortEligible = Boolean(await explicitCheckFiles(ctx.info.root, check));
const browser = !browserFreeChecksEnabled() || await checkNeedsBrowser(ctx.info.root, check, { onFallback: browserAdmissionReporter(io, values.json) });
+ const shortEligible = Boolean(await explicitCheckFiles(ctx.info.root, check));
const run = await withGateSlot(ctx.info.root, (lease) => runProfiledShell(ctx.info.root, check, { waitMs: lease.waitMs, artifactPrefix: `pullboard-check-${item.item_id}`, persistLog: true, gateLease: lease }), { browser, agent: caller, item: String(item.item_id), kind: 'check', itemCheck: true, shortEligible, onWait: gateWaitReporter(io) });
refuseSandboxBlocked(run);
io.result?.({ id: item.item_id, green: run.isGreen, seconds: run.seconds, check, by, report: run.isGreen ? '' : digestOf(run.output) });
@@ -3136,10 +3134,13 @@ function workCommands(io, args) {
};
}
-/** Label the kind and item of a queued run without hiding older queue-class labels. */
-function resourceRunLabel(entry) {
+/** Label the kind and item of a queued run without hiding older queue-class labels.
+ * With short slots on, a holder also names the slot it holds and a waiter says it may take a short one.
+ */
+function resourceRunLabel(entry, shortSlots = 0) {
const priority = entry.landing ? 'landing' : entry.itemCheck ? 'item check' : entry.diagnostic ? 'diagnostic' : '';
- const details = [entry.slot === 'short' ? 'short slot' : '', entry.requestedSlot === 'short-eligible' ? 'short eligible' : '', entry.kind !== priority ? entry.kind : '', entry.item ? `#${entry.item}` : '', entry.browser ? 'browser' : ''].filter(Boolean);
+ const slot = !shortSlots ? '' : entry.slot ? `${entry.slot} slot` : entry.requestedSlot === 'short-eligible' ? 'may use a short slot' : '';
+ const details = [slot, entry.kind !== priority ? entry.kind : '', entry.item ? `#${entry.item}` : '', entry.browser ? 'browser' : ''].filter(Boolean);
return `${priority ? ` (${priority})` : ''}${details.length ? ` (${details.join(', ')})` : ''}`;
}
@@ -3182,27 +3183,34 @@ function settingsCommand(io, { first, second, rest }) {
const settings = loadMachineSettings();
const queue = gateQueueSettings();
// The result names the queue order in effect, defaults included; the file keeps only what was set.
- io.result?.({ settings: { ...settings, gate: { ...settings.gate, queue: { ...settings.gate?.queue, ...queue } } } });
+ const shortSlots = gateShortSlots();
+ io.result?.({ settings: { ...settings, gate: { ...settings.gate, queue: { ...settings.gate?.queue, ...queue }, shortSlots } } });
io.say(`gateSlots: ${settings.gateSlots}`);
io.say(`browserSlots: ${settings.browserSlots}`);
io.say(`gate.queue.reviewsFirst: ${queue.reviewsFirst}${queue.reviewsFirst ? '' : ' (landings first, then arrival order)'}`);
io.say(`gate.queue.agingMinutes: ${queue.agingMinutes}${queue.reviewsFirst ? '' : ' (used only while reviewsFirst is true)'}`);
- io.say(`gate.shortSlots: ${settings.gate.shortSlots}`);
+ io.say(`gate.shortSlots: ${shortSlots}${shortSlots ? '' : ' (off; runs that name their test files wait for a gate slot)'}`);
return 0;
}
if (!['gateSlots', 'browserSlots', 'gate.shortSlots'].includes(first) || !second || rest.length) {
throw new Refused('USAGE', 'pullboard settings gateSlots <n> | browserSlots <n> | gate.shortSlots <n>');
}
- const pattern = first === 'gate.shortSlots' ? /^(?:0|[1-9]\d*)$/u : /^[1-9]\d*$/u;
- if (!pattern.test(second) || !Number.isSafeInteger(Number(second))) {
- if (first === 'gate.shortSlots') throw new Refused('BAD_SHORT_SLOTS', 'gate.shortSlots must be a nonnegative integer');
+ if (first === 'gate.shortSlots') {
+ if (!/^(?:0|[1-9]\d*)$/u.test(second) || !Number.isSafeInteger(Number(second))) {
+ throw new Refused('BAD_SHORT_SLOTS', 'gate.shortSlots must be a whole number, 0 or more; run pullboard settings gate.shortSlots <n>');
+ }
+ const settings = setGateShortSlots(Number(second));
+ io.result?.({ settings });
+ io.say(`gate.shortSlots set to ${settings.gate.shortSlots}`);
+ return 0;
+ }
+ if (!/^[1-9]\d*$/u.test(second) || !Number.isSafeInteger(Number(second))) {
if (first === 'gateSlots') throw new Refused('USAGE', 'pullboard settings gateSlots <positive integer>');
- throw new Refused('BAD_BROWSER_SLOTS', `browserSlots must be a positive integer; run pullboard settings browserSlots <n>`);
+ throw new Refused(first === 'browserSlots' ? 'BAD_BROWSER_SLOTS' : 'BAD_GATE_SLOTS', `${first} must be a positive integer; run pullboard settings ${first} <n>`);
}
- const settings = first === 'browserSlots' ? setBrowserSlots(Number(second))
- : first === 'gate.shortSlots' ? setGateShortSlots(Number(second)) : setGateSlots(Number(second));
+ const settings = first === 'browserSlots' ? setBrowserSlots(Number(second)) : setGateSlots(Number(second));
io.result?.({ settings });
- io.say(`${first} set to ${first === 'gate.shortSlots' ? settings.gate.shortSlots : settings[first]}`);
+ io.say(`${first} set to ${settings[first]}`);
return 0;
}
diff --git a/src/gate.js b/src/gate.js
index afe76efd..91999c9b 100644
--- a/src/gate.js
+++ b/src/gate.js
@@ -14,9 +14,9 @@ import { gitChildEnv, gitPath, headTree, invalidateGitFacts, isClean, untracked
import { secretsIn } from './hooks.js';
import { Refused } from './refused.js';
import { GATE_SLOT_HELD_ENV, gateSlotEnvironment, inheritedGateSlot, takeResource } from './resources.js';
-import { browserFreeChecksEnabled, loadMachineSettings } from './settings.js';
+import { browserFreeChecksEnabled, gateShortSlots, loadMachineSettings } from './settings.js';
import { selectAffectedTests } from './affected-tests.js';
-import { checkNeedsBrowser, explicitCheckFiles, testsNeedBrowser } from './browser-admission.js';
+import { checkNeedsBrowser, testsNeedBrowser } from './browser-admission.js';
import { timingFromOutput, timingRunner } from './timing.js';
import { landingShardProfile } from './landing-shards.js';
import { RunnerDropped, runOnRunner, runOnRunnerAsync, runnerSource } from './runners.js';
@@ -498,26 +498,27 @@ function hasPipeline(command) {
/** Run work under the machine queue: landings first, then every other eligible waiter in arrival order.
*
* @param {string} root - Checkout used to locate the machine resource database.
+ * shortEligible marks a run that names its test files: with gate.shortSlots above 0 it may take a
+ * short slot when every ordinary slot is held, and a full suite can never inherit that slot.
+ *
* @param {(lease: { waitMs: number, token?: string, pool?: string, browser?: boolean, slotClass?: 'gate'|'short', release: () => void }) => any | Promise<any>} action - Work to perform while holding a slot.
* @param {{ landing?: boolean, itemCheck?: boolean, shortEligible?: boolean, diagnostic?: boolean, browser?: boolean, agent?: string, item?: string|number, kind?: string, onWait?: (state: object) => void }} [options] - Queue class and progress reporter.
* @returns {Promise<any>} The action's result after releasing its lease.
*/
export async function withGateSlot(root, action, { landing = false, itemCheck = false, shortEligible = false, diagnostic = false, browser = false, remote = true, agent, item = '', kind = '', onWait } = {}) {
- if (shortEligible && (landing || diagnostic)) throw new Refused('BAD_SHORT_SLOT_REQUEST', 'short gate slots are only available to named non-landing, non-diagnostic runs');
- const inherited = inheritedGateSlot({ root, browser, fullSuite: !shortEligible });
+ const inherited = inheritedGateSlot({ root, browser, namedFiles: shortEligible });
if (inherited) {
try { return await action(inherited); }
finally { inherited.release(); }
}
const settingsProvider = () => loadMachineSettings();
const capacityProvider = () => settingsProvider().gateSlots;
- const shortCapacityProvider = () => settingsProvider().gate.shortSlots;
const source = runnerSource(root);
let lease = await takeResource({
name: 'gate',
capacity: capacityProvider(),
capacityProvider,
- shortCapacityProvider,
+ shortCapacityProvider: () => gateShortSlots(),
shortEligible,
browserCapacityProvider: () => settingsProvider().browserSlots,
scope: 'machine',
@@ -538,7 +539,7 @@ export async function withGateSlot(root, action, { landing = false, itemCheck =
try {
while (true) {
lease.source = source;
- lease.runMetadata = { landing, itemCheck, shortEligible, diagnostic, item: String(item), kind };
+ lease.runMetadata = { landing, itemCheck, diagnostic, item: String(item), kind };
try { return await action(lease); }
catch (error) {
if (!(error instanceof RunnerDropped) || !lease.runner || !lease.requeueRunner) throw error;
@@ -625,21 +626,6 @@ export async function runSubmitGate(root, config, { base, trunk, changed, check,
? (proofFiles.length > 0 && (!allowBrowserFreeChecks || await testsNeedBrowser(root, proofFiles, { onFallback: onBrowserFallback })))
: (selection.full || !allowBrowserFreeChecks || await testsNeedBrowser(root, proofFiles, { onFallback: onBrowserFallback }));
const browser = checkUsesBrowser || proofUsesBrowser;
- // Only an explicit runner command over exactly the selected files can use short capacity.
- // Opaque configured runners, opaque item checks, and full selections stay ordinary.
- const proofCommand = proofFiles.length && config.affectedTests?.trim()
- ? `${config.affectedTests.trimEnd()} ${proofFiles.map(path => commandWord('./' + path)).join(' ')}`
- : '';
- // The parser accepts canonical repository-relative test paths; the executed command keeps its existing ./ spelling.
- const proofSelectionCommand = proofFiles.length && config.affectedTests?.trim()
- ? `${config.affectedTests.trimEnd()} ${proofFiles.map(commandWord).join(' ')}`
- : '';
- const parsedProofFiles = proofSelectionCommand ? await explicitCheckFiles(root, proofSelectionCommand) : null;
- const exactNamedProof = parsedProofFiles !== null
- && JSON.stringify(parsedProofFiles) === JSON.stringify(proofFiles);
- const namedCheck = check ? await explicitCheckFiles(root, check) : [];
- const shortEligible = namedCheck !== null && (!proofFiles.length || exactNamedProof)
- && (Boolean(check) || proofFiles.length > 0) && (deferFullFallback || !selection.full);
return await withGateSlot(root, (lease) => {
const startedAt = Date.now();
const log = gitPath(root, 'pullboard-submit.log');
@@ -678,13 +664,14 @@ export async function runSubmitGate(root, config, { base, trunk, changed, check,
if (!deferFullFallback && selection.full) proof = fullGateRun(root, config, false, { waitMs: proofWait, log: proofLog, gateLease: lease });
else if (!proofFiles.length) proof = { isGreen: true, output: '', seconds: 0, isCached: false, log: '' };
else {
- proof = { ...runProfiledShell(root, proofCommand, { waitMs: proofWait, profileFile: `${proofLog}.profile.json`, gateLease: lease }), isCached: false, log: proofLog };
+ const command = `${config.affectedTests.trimEnd()} ${proofFiles.map(path => commandWord('./' + path)).join(' ')}`;
+ proof = { ...runProfiledShell(root, command, { waitMs: proofWait, profileFile: `${proofLog}.profile.json`, gateLease: lease }), isCached: false, log: proofLog };
writeFileSync(proofLog, proof.output);
}
const phase = deferFullFallback ? `submit invariants: ${invariants.length ? invariants.join(', ') : 'none'}; full suite deferred to the landing gate` : selection.full ? 'full gate' : 'affected tests';
writeFileSync(log, `item check:\n${criterion.output}\n${phase}:\n${proof.output}`);
return finish(proof);
- }, { browser, agent, item, kind, itemCheck: true, shortEligible, onWait });
+ }, { browser, agent, item, kind, itemCheck: true, onWait });
}
/** Describe precisely which submission proof ran, including absent checks and full fallbacks. */
diff --git a/src/help.js b/src/help.js
index a1185b07..d78bfcaa 100644
--- a/src/help.js
+++ b/src/help.js
@@ -24,6 +24,7 @@ Set up
pullboard settings [gateSlots <n> | browserSlots <n>] view or set machine capacity (gate default 2; browser default 1)
browser-free check slots are opt-in: gate.browserFreeChecks in ~/.pullboard/settings.json (default false)
reviews-first queue order is opt-in: gate.queue.reviewsFirst (default false), gate.queue.agingMinutes (default 30)
+ short slots for runs that name their test files are opt-in: pullboard settings gate.shortSlots <n> (default 0)
pullboard runner add <ssh-host> --slots <n> --browser <n> [--node <remote-path>] [--root <remote-path>]
register SSH test capacity; no runner sign-in; root defaults to ~/.pullboard-runner
pullboard view [--project] [--port N] [--no-open] every project on this machine in your browser; default http://127.0.0.1:${DEFAULT_VIEW_PORT}
diff --git a/src/next-steps.js b/src/next-steps.js
index bde998fc..7e9c843e 100644
--- a/src/next-steps.js
+++ b/src/next-steps.js
@@ -42,8 +42,8 @@ export const NEXT_STEPS = Object.freeze({
BAD_LANE: 'choose a lane name made of lowercase letters, digits and dashes, then retry pullboard lane add',
BAD_LANE_PATH: 'give pullboard lane add a folder path inside the repository, relative to its root',
BAD_GATE_SLOTS: 'choose a positive gateSlots value no lower than browserSlots shown by pullboard settings: pullboard settings gateSlots <n>',
- BAD_SHORT_SLOTS: 'set a nonnegative gate.shortSlots value: pullboard settings gate.shortSlots <n>',
- BAD_SHORT_SLOT_REQUEST: 'use a parser-confirmed named non-landing machine gate request; opaque and other requests use ordinary gate slots',
+ BAD_SHORT_SLOTS: 'choose gate.shortSlots as a whole number, 0 or more (0 turns short slots off): pullboard settings gate.shortSlots <n>',
+ BAD_SHORT_SLOT_REQUEST: 'ask for a short slot only from a machine gate run that names its test files; landings and diagnostics use ordinary gate slots',
BAD_BROWSER_SLOTS: 'choose browserSlots from 1 through gateSlots shown by pullboard settings: pullboard settings browserSlots <n>',
BAD_MACHINE_SETTINGS: 'fix or remove the machine settings file the message names, then run pullboard settings',
MACHINE_HOME_NOT_WRITABLE: 'give the agent write access to the named machine-home directory, or run the command outside the sandbox',
@@ -126,7 +126,7 @@ export const NEXT_STEPS = Object.freeze({
GATE_SLOT_LEASE_REQUIRED: 'start the child test process with the live gate lease',
GATE_SLOT_MARKER_INVALID: 'restart the child with gateSlotEnvironment(lease)',
GATE_SLOT_TOKEN_REQUIRED: 'restart the child with gateSlotEnvironment(lease)',
- SHORT_SLOT_FULL_SUITE: 'start the full suite through the ordinary gate queue; short slots are only for named files',
+ SHORT_SLOT_FULL_SUITE: 'run the whole suite outside the short check, where it queues for an ordinary gate slot; short slots are only for runs that name their test files',
GIT_GRAFTS: 'ask the coordinator to remove the git graft file: pullboard shout coordinator "please remove .git/info/grafts"',
HEAD_NOT_NEW: 'commit the rework, then pullboard submit <id>',
HELD: 'take another item: pullboard next',
diff --git a/src/resources.js b/src/resources.js
index d12960b7..0181c658 100644
--- a/src/resources.js
+++ b/src/resources.js
@@ -20,7 +20,6 @@ export const GATE_SLOT_HELD_ENV = 'PULLBOARD_GATE_SLOT_HELD';
export const GATE_SLOT_POOL_ENV = 'PULLBOARD_GATE_SLOT_POOL';
export const GATE_SLOT_TOKEN_ENV = 'PULLBOARD_GATE_SLOT_TOKEN';
export const BROWSER_SLOT_HELD_ENV = 'PULLBOARD_BROWSER_SLOT_HELD';
-export const GATE_SLOT_CLASS_ENV = 'PULLBOARD_GATE_SLOT_CLASS';
/** Reserve a distinct resource row for each configured remote host. */
function runnerResourceName(host) { return `runner:${host}`; }
@@ -28,15 +27,13 @@ function runnerResourceName(host) { return `runner:${host}`; }
/** Build child markers that identify the exact machine queue lease and its browser capacity. */
export function gateSlotEnvironment(lease) {
if (lease?.runner) throw new Refused('REMOTE_GATE_SLOT_NOT_INHERITABLE', 'remote runner leases cannot be inherited through local gate markers');
- if (!lease || lease.name !== 'gate' || lease.scope !== 'machine' || typeof lease.pool !== 'string' || typeof lease.token !== 'string'
- || !['gate', 'short'].includes(lease.slotClass)) {
+ if (!lease || lease.name !== 'gate' || lease.scope !== 'machine' || typeof lease.pool !== 'string' || typeof lease.token !== 'string') {
throw new Refused('GATE_SLOT_LEASE_REQUIRED', 'pass the live machine gate lease when starting a child test process');
}
return {
[GATE_SLOT_HELD_ENV]: '1',
[GATE_SLOT_POOL_ENV]: lease.pool,
[GATE_SLOT_TOKEN_ENV]: lease.token,
- [GATE_SLOT_CLASS_ENV]: lease.slotClass,
[BROWSER_SLOT_HELD_ENV]: lease.browser ? '1' : '',
};
}
@@ -534,7 +531,7 @@ export async function takeResource(options) {
const currentCapacity = options.capacityProvider?.() ?? capacity;
const currentShortCapacity = options.shortCapacityProvider?.() ?? 0;
if (!Number.isSafeInteger(currentCapacity) || currentCapacity < 1) throw new Refused('BAD_RESOURCE_CAPACITY', 'resource capacity must be a positive integer');
- if (!Number.isSafeInteger(currentShortCapacity) || currentShortCapacity < 0) throw new Refused('BAD_SHORT_SLOTS', 'gate.shortSlots must be a nonnegative integer');
+ if (!Number.isSafeInteger(currentShortCapacity) || currentShortCapacity < 0) throw new Refused('BAD_SHORT_SLOTS', 'gate.shortSlots must be a whole number, 0 or more; run pullboard settings gate.shortSlots <n>');
const row = db.prepare('SELECT capacity FROM resource WHERE name = ?').get(name);
if (row && row.capacity !== currentCapacity) {
const state = snapshot(db, name);
@@ -692,11 +689,13 @@ export async function takeResource(options) {
}
}
-/** Reuse a same-machine gate lease in a child without queueing or acquiring a partial browser slot. */
-export function inheritedGateSlot({ root = process.cwd(), browser = false, fullSuite = true } = {}) {
+/** Reuse a same-machine gate lease in a child without queueing or acquiring a partial browser slot.
+ * The live holder row says whether the lease is a short slot; only a run that names its test files
+ * (namedFiles) may reuse one, so a whole suite started under a short check queues for a real slot.
+ */
+export function inheritedGateSlot({ root = process.cwd(), browser = false, namedFiles = false } = {}) {
const markedPool = process.env[GATE_SLOT_POOL_ENV] ?? '';
const token = process.env[GATE_SLOT_TOKEN_ENV] ?? '';
- const markedClass = process.env[GATE_SLOT_CLASS_ENV] ?? 'gate';
if (!markedPool && !token) return null;
if (!markedPool) throw new Refused('GATE_SLOT_MARKER_INVALID', 'the inherited gate token has no pool marker; start the child with gateSlotEnvironment(lease)');
const pool = canonicalResourceFile(machineResourceFile());
@@ -711,8 +710,7 @@ export function inheritedGateSlot({ root = process.cwd(), browser = false, fullS
} finally { db.close(); }
if (!holder) throw new Refused('GATE_SLOT_LEASE_LOST', 'the inherited gate lease is missing or expired; remove stale gate markers or let the parent reacquire the gate slot');
const slotClass = holder.shortSlot === 1 ? 'short' : 'gate';
- if (markedClass !== slotClass) throw new Refused('GATE_SLOT_MARKER_INVALID', 'the inherited slot class does not match its live gate lease; restart the parent runner');
- if (slotClass === 'short' && fullSuite) throw new Refused('SHORT_SLOT_FULL_SUITE', 'a full suite cannot inherit a short gate slot; start it through the ordinary gate queue');
+ if (slotClass === 'short' && !namedFiles) throw new Refused('SHORT_SLOT_FULL_SUITE', 'a run that does not name its test files cannot reuse a short gate slot; start it outside the short check so it queues for an ordinary slot');
const expectedBrowserMarker = holder.browser === 1 ? '1' : '';
if (process.env[BROWSER_SLOT_HELD_ENV] !== expectedBrowserMarker) throw new Refused('GATE_SLOT_MARKER_INVALID', 'the inherited browser marker does not match its live gate lease; restart the child with gateSlotEnvironment(lease)');
if (browser && holder.browser !== 1) throw new Refused('BROWSER_SLOT_REQUIRED', 'the inherited gate lease does not hold the browser slot; release it and reacquire gate with browser: true before launching Chrome');
diff --git a/src/settings.js b/src/settings.js
index afa17214..dd0a500f 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -18,7 +18,7 @@ const DEFAULT_SHORT_SLOTS = 0;
export function loadMachineSettings() {
const file = machineSettingsFile();
const value = readMachineSettingsFile(file);
- if (!value) return { gateSlots: DEFAULT_GATE_SLOTS, browserSlots: DEFAULT_BROWSER_SLOTS, gate: { shortSlots: DEFAULT_SHORT_SLOTS } };
+ if (!value) return { gateSlots: DEFAULT_GATE_SLOTS, browserSlots: DEFAULT_BROWSER_SLOTS };
if (value.gate?.browserFreeChecks !== undefined && typeof value.gate.browserFreeChecks !== 'boolean') {
throw new Refused('BAD_MACHINE_SETTINGS', `gate.browserFreeChecks in ${file} must be true or false`);
}
@@ -27,14 +27,14 @@ export function loadMachineSettings() {
if (!Number.isSafeInteger(gateSlots) || gateSlots < 1) {
throw new Refused('BAD_GATE_SLOTS', `gateSlots in ${file} must be a positive integer; run pullboard settings gateSlots <n>`);
}
- const shortSlots = value.gate?.shortSlots ?? DEFAULT_SHORT_SLOTS;
- if (!Number.isSafeInteger(shortSlots) || shortSlots < 0) {
- throw new Refused('BAD_SHORT_SLOTS', `gate.shortSlots in ${file} must be a nonnegative integer; run pullboard settings gate.shortSlots <n>`);
- }
const browserSlots = value.browserSlots ?? DEFAULT_BROWSER_SLOTS;
if (!Number.isSafeInteger(browserSlots) || browserSlots < 1 || browserSlots > gateSlots) {
throw new Refused('BAD_BROWSER_SLOTS', `browserSlots in ${file} must be a positive integer no greater than gateSlots (${gateSlots}); run pullboard settings browserSlots <n>`);
}
+ const shortSlots = value.gate?.shortSlots;
+ if (shortSlots !== undefined && (!Number.isSafeInteger(shortSlots) || shortSlots < 0)) {
+ throw new Refused('BAD_SHORT_SLOTS', `gate.shortSlots in ${file} must be a whole number, 0 or more; run pullboard settings gate.shortSlots <n>`);
+ }
const runners = value.runners ?? [];
if (!Array.isArray(runners)) throw new Refused('BAD_MACHINE_SETTINGS', 'runners must be an array; use pullboard runner add <ssh-host> --slots <n> --browser <n>');
const seen = new Set();
@@ -43,7 +43,7 @@ export function loadMachineSettings() {
if (seen.has(runner.host)) throw new Refused('BAD_MACHINE_SETTINGS', 'runner hosts must be unique; remove the duplicate machine setting');
seen.add(runner.host);
}
- return { ...value, gateSlots, browserSlots, gate: { ...value.gate, shortSlots }, ...(runners.length ? { runners } : {}) };
+ return { ...value, gateSlots, browserSlots, ...(runners.length ? { runners } : {}) };
}
/** Browser-free check admission is deliberately opt-in per machine. */
@@ -75,16 +75,28 @@ export function setGateSlots(capacity) {
return next;
}
-/** Set short admission capacity only while the shared gate queue is idle. */
-export function setGateShortSlots(capacity) {
- if (!Number.isSafeInteger(capacity) || capacity < 0) throw new Refused('BAD_SHORT_SLOTS', 'gate.shortSlots must be a nonnegative integer; run pullboard settings gate.shortSlots <n>');
+/**
+ * Short gate slots admit runs that name their test files while every ordinary slot is busy.
+ * The default 0 keeps them off, so the pool behaves exactly as it did before the setting existed.
+ */
+export function gateShortSlots() {
+ return loadMachineSettings().gate?.shortSlots ?? DEFAULT_SHORT_SLOTS;
+}
+
+/** Set the short slot count only while the gate pool is idle, like gateSlots, so no holder changes class mid-run. */
+export function setGateShortSlots(count) {
+ if (!Number.isSafeInteger(count) || count < 0) throw new Refused('BAD_SHORT_SLOTS', 'gate.shortSlots must be a whole number, 0 or more; run pullboard settings gate.shortSlots <n>');
let next;
- const current = loadMachineSettings();
- setResourceCapacity({ name: 'gate', capacity: current.gateSlots, scope: 'machine', persist: () => {
- const latest = loadMachineSettings();
- next = { ...latest, gate: { ...latest.gate, shortSlots: capacity } };
- writeMachineSettings(next);
- } });
+ try {
+ setResourceCapacity({ name: 'gate', capacity: loadMachineSettings().gateSlots, scope: 'machine', persist: () => {
+ const current = loadMachineSettings();
+ next = { ...current, gate: { ...current.gate, shortSlots: count } };
+ writeMachineSettings(next);
+ } });
+ } catch (error) {
+ if (error?.code !== 'RESOURCE_BUSY') throw error;
+ throw new Refused('RESOURCE_BUSY', `the gate pool is in use; wait for it to become idle, then retry pullboard settings gate.shortSlots ${count}`);
+ }
return next;
}
diff --git a/test/gate-resource.test.js b/test/gate-resource.test.js
index 9bd40154..0052e8b0 100644
--- a/test/gate-resource.test.js
+++ b/test/gate-resource.test.js
@@ -6,7 +6,7 @@ import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
import { after, test } from 'node:test';
import { pathToFileURL } from 'node:url';
-import { BROWSER_SLOT_HELD_ENV, GATE_SLOT_CLASS_ENV, GATE_SLOT_HELD_ENV, GATE_SLOT_POOL_ENV, GATE_SLOT_TOKEN_ENV } from '../src/resources.js';
+import { BROWSER_SLOT_HELD_ENV, GATE_SLOT_HELD_ENV, GATE_SLOT_POOL_ENV, GATE_SLOT_TOKEN_ENV } from '../src/resources.js';
const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');
const RUNNER = resolve(import.meta.dirname, '../bin/run-tests.js');
@@ -74,17 +74,17 @@ function launchTestRunner(box, root, args, marker, release, extraEnv = {}) {
return child;
}
-/** Launch a synthetic ordinary or short gate lease holder until released. */
-function launchLeaseFixture(box, root, name, started, release, waiting, shortEligible = false) {
+/** Launch a real process that holds the production diagnostic resource class until released. */
+function launchDiagnostic(box, root, name, started, release, waiting) {
const script = join(box.dir, `${name}.mjs`);
writeFileSync(script, `import { existsSync, renameSync, writeFileSync } from 'node:fs';
import { withGateSlot } from ${JSON.stringify(GATE_MODULE)};
-/** Publish a complete fixture marker atomically. */
+/** Publish a complete handshake so its visible file always contains its value. */
function publish(file, value) { writeFileSync(file + '.tmp', value); renameSync(file + '.tmp', file); }
-await withGateSlot(process.cwd(), async lease => {
- publish(${JSON.stringify(started)}, lease.slotClass);
+await withGateSlot(process.cwd(), async () => {
+ publish(${JSON.stringify(started)}, 'started');
while (!existsSync(${JSON.stringify(release)})) await new Promise(done => setTimeout(done, 10));
-}, { shortEligible: ${JSON.stringify(shortEligible)}, kind: 'fixture-lease', agent: ${JSON.stringify(name)}, onWait: state => publish(${JSON.stringify(waiting)}, String(state.position)) });
+}, { diagnostic: true, kind: 'main-red', agent: ${JSON.stringify(name)}, onWait: state => publish(${JSON.stringify(waiting)}, String(state.position)) });
`);
const child = spawn(process.execPath, [script], { cwd: root, env: box.env, detached: true, stdio: ['ignore', 'pipe', 'pipe'] });
child.stdoutText = '';
@@ -101,20 +101,17 @@ await withGateSlot(process.cwd(), async lease => {
return child;
}
-/** Create one named-file probe that records the inherited gate class and can wait for release. */
+/** Create a probe project whose one named test file records the gate lease it runs under, then waits for release. */
function shortProbeSuite(box, name) {
const root = join(box.dir, name);
- const tests = join(root, 'test');
- mkdirSync(tests, { recursive: true });
- writeFileSync(join(tests, 'short-probe.test.js'), `import { existsSync, renameSync, writeFileSync } from 'node:fs';
+ mkdirSync(join(root, 'test'), { recursive: true });
+ writeFileSync(join(root, 'test', 'short-probe.test.js'), `import { existsSync, renameSync, writeFileSync } from 'node:fs';
import { test } from 'node:test';
test(${JSON.stringify(PROBE_NAME)}, async () => {
const marker = process.env.${PROBE_PATH_ENV};
if (marker) {
- const temporary = marker + '.tmp';
- writeFileSync(temporary, JSON.stringify({ slotClass: process.env[${JSON.stringify(GATE_SLOT_CLASS_ENV)}],
- pool: process.env[${JSON.stringify(GATE_SLOT_POOL_ENV)}], token: process.env[${JSON.stringify(GATE_SLOT_TOKEN_ENV)}] }));
- renameSync(temporary, marker);
+ writeFileSync(marker + '.tmp', JSON.stringify({ pool: process.env.${GATE_SLOT_POOL_ENV}, token: process.env.${GATE_SLOT_TOKEN_ENV} }));
+ renameSync(marker + '.tmp', marker);
}
const release = process.env.${PROBE_RELEASE_ENV};
while (release && !existsSync(release)) await new Promise(done => setTimeout(done, 10));
@@ -123,45 +120,28 @@ test(${JSON.stringify(PROBE_NAME)}, async () => {
return root;
}
-/** Launch a child that proves a named-file lease refuses full-suite inheritance. */
-function fullSuiteInheritanceProbe(box, root, lease) {
- const script = join(box.dir, 'full-suite-inheritance.mjs');
+/** Ask, from a child holding the given lease's markers, to reuse it for a run that does not name its files. */
+function wholeSuiteInheritance(box, root, lease) {
+ const script = join(box.dir, 'whole-suite-inheritance.mjs');
writeFileSync(script, `import { inheritedGateSlot } from ${JSON.stringify(RESOURCE_MODULE)};
try {
- inheritedGateSlot({ root: process.cwd(), fullSuite: true });
- process.exitCode = 2;
-} catch (error) {
- process.stdout.write(String(error.code ?? 'unknown'));
- if (error.code !== 'SHORT_SLOT_FULL_SUITE') process.exitCode = 1;
-}
+ inheritedGateSlot({ root: process.cwd() });
+ process.stdout.write('inherited');
+} catch (error) { process.stdout.write(String(error.code)); }
`);
- return spawnSync(process.execPath, [script], { cwd: root, env: {
- ...box.env, [GATE_SLOT_HELD_ENV]: '1', [GATE_SLOT_POOL_ENV]: lease.pool,
- [GATE_SLOT_TOKEN_ENV]: lease.token, [GATE_SLOT_CLASS_ENV]: lease.slotClass,
- [BROWSER_SLOT_HELD_ENV]: '',
- }, encoding: 'utf8' });
-}
-
-/** Set the fixture machine capacities through the public settings command. */
-function setShortSlots(box, root, gateSlots, shortSlots) {
- const gate = spawnSync(process.execPath, [BIN, 'settings', 'gateSlots', String(gateSlots)], { cwd: root, env: box.env, encoding: 'utf8' });
- assert.equal(gate.status, 0, gate.failure ?? gate.stderr);
- const short = spawnSync(process.execPath, [BIN, 'settings', 'gate.shortSlots', String(shortSlots)], { cwd: root, env: box.env, encoding: 'utf8' });
- assert.equal(short.status, 0, short.failure ?? short.stderr);
+ return spawnSync(process.execPath, [script], { cwd: root, encoding: 'utf8', env: { ...box.env, [GATE_SLOT_HELD_ENV]: '1',
+ [GATE_SLOT_POOL_ENV]: lease.pool, [GATE_SLOT_TOKEN_ENV]: lease.token, [BROWSER_SLOT_HELD_ENV]: '' } });
}
-/** Launch a synthetic main-red diagnostic holder, which must stay in ordinary capacity. */
-function launchDiagnostic(box, root, name, started, release, waiting) {
- const script = join(box.dir, `${name}.mjs`);
- writeFileSync(script, `import { existsSync, renameSync, writeFileSync } from 'node:fs';
+/** Queue a plain gate lease that names no test files and needs no browser, like an opaque item check. */
+function launchOrdinaryLease(box, root, { marker, release, waiting }) {
+ const script = join(box.dir, 'ordinary-lease.mjs');
+ writeFileSync(script, `import { existsSync, writeFileSync } from 'node:fs';
import { withGateSlot } from ${JSON.stringify(GATE_MODULE)};
-/** Publish a complete handshake so its visible file always contains its value. */
-/** Publish a complete fixture marker atomically. */
-function publish(file, value) { writeFileSync(file + '.tmp', value); renameSync(file + '.tmp', file); }
await withGateSlot(process.cwd(), async () => {
- publish(${JSON.stringify(started)}, 'started');
+ writeFileSync(${JSON.stringify(marker)}, 'started');
while (!existsSync(${JSON.stringify(release)})) await new Promise(done => setTimeout(done, 10));
-}, { diagnostic: true, kind: 'main-red', agent: ${JSON.stringify(name)}, onWait: state => publish(${JSON.stringify(waiting)}, String(state.position)) });
+}, { kind: 'fixture-ordinary', onWait: () => writeFileSync(${JSON.stringify(waiting)}, 'waiting') });
`);
const child = spawn(process.execPath, [script], { cwd: root, env: box.env, detached: true, stdio: ['ignore', 'pipe', 'pipe'] });
child.stdoutText = '';
@@ -178,6 +158,30 @@ await withGateSlot(process.cwd(), async () => {
return child;
}
+/** Run one pullboard command in a fixture, require success, and return its output. */
+function pullboard(box, root, args) {
+ const result = spawnSync(process.execPath, [BIN, ...args], { cwd: root, env: box.env, encoding: 'utf8' });
+ assert.equal(result.status, 0, `${args.join(' ')}: ${result.failure ?? ''}${result.stdout}${result.stderr}`);
+ return result.stdout;
+}
+
+/** Fill both gate slots with real whole-suite runs and wait until each one's probe is running. */
+async function wholeSuiteHolders(box, names) {
+ const runs = names.map(name => {
+ const marker = join(box.dir, `${name}.started`);
+ const release = join(box.dir, `${name}.release`);
+ return { marker, release, child: launchTestRunner(box, probeSuite(box, name), [], marker, release) };
+ });
+ await waitFor(() => runs.every(run => existsSync(run.marker)), 'every gate slot to hold a whole-suite run');
+ return runs;
+}
+
+/** Release every probe and wait for its runner, so a failed assertion leaves no fixture process behind. */
+async function releaseAll(runs) {
+ for (const run of runs) writeFileSync(run.release, 'release\n');
+ return Promise.all(runs.map(run => run.child.closed));
+}
+
/** Create a clean gate repo whose start and end record observable execution, optionally waiting for a release file. */
function gateRepo(box, name, delay = 0.25, releaseFile = null) {
const root = join(box.dir, name);
@@ -639,126 +643,110 @@ syncBuiltinESMExports();
assert.equal(readFileSync(marker, 'utf8'), '1', 'the final marker contains the complete slot value');
});
-test('short classification accepts only explicit parser-backed named runner commands [C7]', async () => {
+test('a short slot is offered only to a literal runner call over regular test files [C7]', async () => {
const { explicitCheckFiles } = await import(BROWSER_ADMISSION_MODULE);
const root = process.cwd();
- assert.deepEqual(await explicitCheckFiles(root, `${quote(process.execPath)} bin/run-tests.js test/gate-resource.test.js`), ['test/gate-resource.test.js']);
- assert.equal(await explicitCheckFiles(root, 'npm test test/gate-resource.test.js'), null, 'opaque configured runners remain ordinary');
- assert.equal(await explicitCheckFiles(root, 'node bin/run-tests.js $(printf test/gate-resource.test.js)'), null, 'shell expansion is not classified');
- assert.equal(await explicitCheckFiles(root, 'node bin/run-tests.js --unknown test/gate-resource.test.js'), null, 'unknown options stay ordinary');
- assert.equal(await explicitCheckFiles(root, 'node bin/run-tests.js test/gate-resource.test.js', { env: { ...process.env, NODE_OPTIONS: '--trace-warnings' } }), null, 'runtime injection stays ordinary');
- assert.equal(await explicitCheckFiles(root, 'node bin/run-tests.js test/short-missing.test.js'), null, 'missing files stay ordinary');
- const committed = runFixtureChild('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' });
- assert.equal(committed.status, 0, committed.stderr);
- assert.deepEqual(await explicitCheckFiles(root, `${quote(process.execPath)} bin/run-tests.js test/gate-resource.test.js`, { commit: committed.stdout.trim() }),
- ['test/gate-resource.test.js'], 'frozen checks classify the submitted file map');
+ const named = `${quote(process.execPath)} bin/run-tests.js test/gate-resource.test.js`;
+ assert.deepEqual(await explicitCheckFiles(root, named), ['test/gate-resource.test.js']);
+ assert.deepEqual(await explicitCheckFiles(root, `out=$(${named} 2>&1); printf '%s\\n' "$out"; printf '%s\\n' "$out" | grep -Eq '^[[:space:]]*ok [0-9]+ - .*probe' && printf '%s\\n' "$out" | grep -Eq '^# fail 0$'`), ['test/gate-resource.test.js'], 'the frozen-check capture form names its files');
+ assert.equal(await explicitCheckFiles(root, `${quote(process.execPath)} bin/run-tests.js`), null, 'a whole suite is not short');
+ assert.equal(await explicitCheckFiles(root, `${quote(process.execPath)} bin/run-tests.js test/`), null, 'a directory is not short');
+ assert.equal(await explicitCheckFiles(root, 'npm test test/gate-resource.test.js'), null, 'an opaque runner is not short');
+ assert.equal(await explicitCheckFiles(root, 'node bin/run-tests.js $(printf test/gate-resource.test.js)'), null, 'shell expansion is not short');
+ assert.equal(await explicitCheckFiles(root, 'node bin/run-tests.js --unknown test/gate-resource.test.js'), null, 'an unknown option is not short');
+ assert.equal(await explicitCheckFiles(root, 'node bin/run-tests.js test/short-missing.test.js'), null, 'a missing file is not short');
+ assert.equal(await explicitCheckFiles(root, named, { env: { ...process.env, NODE_OPTIONS: '--trace-warnings' } }), null, 'NODE_OPTIONS is not short');
+ const head = runFixtureChild('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' });
+ assert.equal(head.status, 0, head.stderr);
+ assert.deepEqual(await explicitCheckFiles(root, named, { commit: head.stdout.trim() }), ['test/gate-resource.test.js'], 'a review reads the files from the submitted tree');
});
test('a short check never waits behind whole suites [C7]', async () => {
- const enabled = fixture();
- const holderRoots = [gateRepo(enabled, 'whole-one'), gateRepo(enabled, 'whole-two')];
- const gateRoot = holderRoots[0];
- const focusedRoot = shortProbeSuite(enabled, 'short-focused');
- const defaultSettings = spawnSync(process.execPath, [BIN, 'settings', '--json'], { cwd: gateRoot, env: enabled.env, encoding: 'utf8' });
- assert.equal(defaultSettings.status, 0, defaultSettings.failure ?? defaultSettings.stderr);
- assert.equal(JSON.parse(defaultSettings.stdout).settings.gate.shortSlots, 0, 'short capacity defaults to off');
- setShortSlots(enabled, gateRoot, 2, 1);
- const settingsView = spawnSync(process.execPath, [BIN, 'settings', '--json'], { cwd: gateRoot, env: enabled.env, encoding: 'utf8' });
- assert.equal(settingsView.status, 0, settingsView.failure ?? settingsView.stderr);
- assert.equal(JSON.parse(settingsView.stdout).settings.gate.shortSlots, 1);
- const invalidShortSlots = spawnSync(process.execPath, [BIN, 'settings', 'gate.shortSlots', '--json', '--', '-1'], { cwd: gateRoot, env: enabled.env, encoding: 'utf8' });
- assert.notEqual(invalidShortSlots.status, 0, 'negative short capacity is refused');
- assert.match(`${invalidShortSlots.stdout}${invalidShortSlots.stderr}`, /BAD_SHORT_SLOTS|nonnegative integer/u);
- const releases = holderRoots.map((_, index) => join(enabled.dir, `release-whole-${index}`));
- const started = holderRoots.map((_, index) => join(enabled.dir, `whole-${index}.started`));
- const waiting = holderRoots.map((_, index) => join(enabled.dir, `whole-${index}.waiting`));
- const holders = holderRoots.map((root, index) => launchLeaseFixture(enabled, root, `whole-${index}`, started[index], releases[index], waiting[index]));
- let short;
- let wholeWaiter;
- let directoryRun;
- const directoryStarted = join(enabled.dir, 'directory-request.started');
- const directoryRelease = join(enabled.dir, 'release-directory-request');
- const requestRelease = join(enabled.dir, 'release-short-request');
- const requestStarted = join(enabled.dir, 'short-request.started');
- const fullRelease = join(enabled.dir, 'release-full-request');
- const fullStarted = join(enabled.dir, 'full-request.started');
- const fullWaiting = join(enabled.dir, 'full-request.waiting');
+ const box = fixture();
+ const settingsRoot = gateRepo(box, 'settings-view');
+ assert.equal(JSON.parse(pullboard(box, settingsRoot, ['settings', '--json'])).settings.gate.shortSlots, 0, 'gate.shortSlots defaults to 0');
+ assert.match(pullboard(box, settingsRoot, ['settings']), /^gate\.shortSlots: 0 \(off/mu, 'pullboard settings shows the default');
+ const refused = spawnSync(process.execPath, [BIN, 'settings', 'gate.shortSlots', 'two'], { cwd: settingsRoot, env: box.env, encoding: 'utf8' });
+ assert.notEqual(refused.status, 0);
+ assert.match(`${refused.stdout}${refused.stderr}`, /BAD_SHORT_SLOTS/u);
+ // Whole suites take a browser slot too; two of them fill a two-slot gate only with two browser slots.
+ pullboard(box, settingsRoot, ['settings', 'gateSlots', '2']);
+ pullboard(box, settingsRoot, ['settings', 'browserSlots', '2']);
+ pullboard(box, settingsRoot, ['settings', 'gate.shortSlots', '1']);
+ assert.equal(JSON.parse(pullboard(box, settingsRoot, ['settings', '--json'])).settings.gate.shortSlots, 1);
+ assert.match(pullboard(box, settingsRoot, ['settings']), /^gate\.shortSlots: 1$/mu, 'pullboard settings shows the value');
+
+ const holders = await wholeSuiteHolders(box, ['whole-one', 'whole-two']);
+ const waiting = [];
try {
- await waitFor(() => started.every(file => existsSync(file)), 'both synthetic ordinary gate leases to hold');
- wholeWaiter = launchLeaseFixture(enabled, gateRoot, 'ordinary-request', fullStarted, fullRelease, fullWaiting, false);
- await waitFor(() => existsSync(fullWaiting), 'an earlier ordinary-class request to queue behind the holders');
- directoryRun = launchTestRunner(enabled, focusedRoot, ['test/'], directoryStarted, directoryRelease);
- await waitFor(() => existsSync(directoryStarted) || directoryRun.stderrText.includes('waiting for a gate slot:') || directoryRun.exitCode !== null,
- 'the directory selection to report admission or its queued state');
- assert.ok(directoryRun.stderrText.includes('waiting for a gate slot:'), 'a directory operand must queue in the ordinary pool');
- assert.equal(existsSync(directoryStarted), false, 'a whole-directory selection cannot use a short slot');
- short = launchTestRunner(enabled, focusedRoot, ['--disable-warning', 'ExperimentalWarning', '--title', 'short-focused-probe', 'test/short-probe.test.js'], requestStarted, requestRelease);
- await waitFor(() => existsSync(requestStarted) || short.stderrText.includes('waiting for a gate slot:'),
- 'the named-file runner to publish admission or its queued state');
- assert.ok(existsSync(requestStarted), 'a named-file run starts before the ordinary holders release');
- const shortLease = JSON.parse(readFileSync(requestStarted, 'utf8'));
- assert.equal(shortLease.slotClass, 'short', 'the named test inherits the assigned short slot class');
- const fullInheritance = fullSuiteInheritanceProbe(enabled, gateRoot, shortLease);
- assert.equal(fullInheritance.status, 0, fullInheritance.stderr);
- assert.equal(fullInheritance.stdout, 'SHORT_SLOT_FULL_SUITE', 'a full-suite child cannot inherit a short lease');
- assert.equal(existsSync(fullStarted), false, 'an ordinary-class request cannot use the available short slot');
- const status = spawnSync(process.execPath, [BIN, 'resources', '--json'], { cwd: gateRoot, env: enabled.env, encoding: 'utf8' });
- assert.equal(status.status, 0, status.failure ?? status.stderr);
- const resourceOutput = JSON.parse(status.stdout);
- assert.equal(resourceOutput.gate.shortSlots, 1, 'pool status reports configured short capacity');
- const gateStatus = resourceOutput.resources.find(resource => resource.name === 'gate');
- assert.equal(gateStatus.holders.filter(holder => holder.slot === 'short').length, 1, 'pool status labels the actual short holder');
- assert.equal(gateStatus.capacity, 2, 'short capacity is not added to ordinary gateSlots');
- assert.equal(gateStatus.holders.filter(holder => holder.slot === 'gate').length, 2, 'ordinary holders retain the gate slot class');
+ // Each waiter below is offered the free short slot on its first poll, so starting there would show at once.
+ const ordinary = { marker: join(box.dir, 'ordinary.started'), release: join(box.dir, 'ordinary.release'), waiting: join(box.dir, 'ordinary.waiting') };
+ ordinary.child = launchOrdinaryLease(box, settingsRoot, ordinary);
+ waiting.push(ordinary);
+ assert.equal(await waitFor(() => (existsSync(ordinary.marker) ? 'ran' : existsSync(ordinary.waiting) ? 'waiting' : false), 'an unnamed run to start or queue'),
+ 'waiting', 'a run that does not name its test files never takes the short slot, even with no browser');
+ const wholeWaiter = { marker: join(box.dir, 'whole-waiter.started'), release: join(box.dir, 'whole-waiter.release') };
+ wholeWaiter.child = launchTestRunner(box, probeSuite(box, 'whole-waiter'), [], wholeWaiter.marker, wholeWaiter.release);
+ waiting.push(wholeWaiter);
+ await waitFor(() => wholeWaiter.child.stderrText.includes('waiting for a gate slot:'), 'a third whole suite to queue');
+ const directory = { marker: join(box.dir, 'directory.started'), release: join(box.dir, 'directory.release') };
+ directory.child = launchTestRunner(box, shortProbeSuite(box, 'directory-run'), ['test/'], directory.marker, directory.release);
+ waiting.push(directory);
+ await waitFor(() => directory.child.stderrText.includes('waiting for a gate slot:'), 'a directory run to queue');
+ const queued = JSON.parse(pullboard(box, settingsRoot, ['resources', '--json'])).resources.find(resource => resource.name === 'gate').line;
+ assert.deepEqual(queued.map(waiter => waiter.kind), ['fixture-ordinary', 'gate', 'focused']);
+ assert.equal(queued[1].requestedSlot, undefined, 'a whole suite is never offered a short slot');
+ assert.equal(queued[2].requestedSlot, undefined, 'a directory run is never offered a short slot');
+ const shortRoot = shortProbeSuite(box, 'short-run');
+ const short = { marker: join(box.dir, 'short.started'), release: join(box.dir, 'short.release') };
+ short.child = launchTestRunner(box, shortRoot, ['--test-name-pattern', PROBE_PATTERN, 'test/short-probe.test.js'], short.marker, short.release);
+ waiting.push(short);
+ const outcome = await waitFor(() => (existsSync(short.marker) ? 'ran' : short.child.stderrText.includes('waiting for a gate slot:') ? 'waiting' : false), 'the named-file run to start or queue');
+ assert.equal(outcome, 'ran', 'with gate.shortSlots 1 a named-file run starts while both gate slots hold whole suites');
+ assert.deepEqual([ordinary, wholeWaiter, directory].map(run => existsSync(run.marker)), [false, false, false], 'the runs queued ahead of it still wait');
+
+ const status = JSON.parse(pullboard(box, settingsRoot, ['resources', '--json']));
+ assert.equal(status.shortSlots, 1, 'pool status reports gate.shortSlots');
+ const gate = status.resources.find(resource => resource.name === 'gate');
+ assert.equal(gate.capacity, 2, 'short slots do not raise gateSlots');
+ assert.deepEqual(gate.holders.map(holder => [holder.kind, holder.slot]).sort(), [['focused', 'short'], ['gate', 'gate'], ['gate', 'gate']],
+ 'pool status names the slot each run holds');
+ const text = pullboard(box, settingsRoot, ['resources']);
+ const gateText = text.slice(text.indexOf('\ngate (machine'));
+ assert.equal((gateText.match(/held by .*\(short slot, focused\)/gu) ?? []).length, 1, 'the text status names the short slot');
+ assert.equal((gateText.match(/held by .*\(gate slot, gate, browser\)/gu) ?? []).length, 2, 'the text status names each gate slot');
+ const reuse = wholeSuiteInheritance(box, settingsRoot, JSON.parse(readFileSync(short.marker, 'utf8')));
+ assert.equal(reuse.stdout, 'SHORT_SLOT_FULL_SUITE', 'a whole suite cannot reuse a short lease from inside the short check');
} finally {
- for (const release of [...releases, requestRelease, fullRelease, directoryRelease]) writeFileSync(release, 'release\n');
- await Promise.all([...holders, short, wholeWaiter, directoryRun].filter(Boolean).map(child => child.closed));
+ await releaseAll([...holders, ...waiting]);
}
- for (const child of [...holders, short, wholeWaiter, directoryRun].filter(Boolean)) {
- const result = await child.closed;
- if (child === directoryRun && result.code !== 0) {
- assert.equal(result.code, 1, `${child.stderrText}${child.stdoutText}`);
- assert.match(child.stdoutText, /ERR_UNSUPPORTED_DIR_IMPORT/u, 'this runtime may refuse directory operands after ordinary admission');
- } else assert.equal(result.code, 0, `${child.stderrText}${child.stdoutText}`);
- assert.equal(result.signal, null);
+ for (const run of [...holders, ...waiting]) {
+ const { code } = await run.child.closed;
+ // Node refuses a directory operand once the run is admitted; only its queueing is under test here.
+ if (run.child.stdoutText.includes('ERR_UNSUPPORTED_DIR_IMPORT')) assert.equal(code, 1);
+ else assert.equal(code, 0, `${run.child.stderrText}${run.child.stdoutText}`);
}
- const disabled = fixture();
- const disabledRoot = gateRepo(disabled, 'whole-disabled-one');
- const disabledRoot2 = gateRepo(disabled, 'whole-disabled-two');
- setShortSlots(disabled, disabledRoot, 2, 0);
- const disabledReleases = [join(disabled.dir, 'release-disabled-1'), join(disabled.dir, 'release-disabled-2')];
- const disabledStarts = [join(disabled.dir, 'disabled-one.started'), join(disabled.dir, 'disabled-two.started')];
- const disabledWaits = [join(disabled.dir, 'disabled-one.waiting'), join(disabled.dir, 'disabled-two.waiting')];
- const disabledHolders = [
- launchLeaseFixture(disabled, disabledRoot, 'disabled-one', disabledStarts[0], disabledReleases[0], disabledWaits[0]),
- launchLeaseFixture(disabled, disabledRoot2, 'disabled-two', disabledStarts[1], disabledReleases[1], disabledWaits[1]),
- ];
- let disabledRequest;
- const disabledRequestRelease = join(disabled.dir, 'release-disabled-request');
- const disabledRequestStarted = join(disabled.dir, 'disabled-request.started');
+ const off = fixture();
+ const offRoot = gateRepo(off, 'settings-off');
+ pullboard(off, offRoot, ['settings', 'gateSlots', '2']);
+ pullboard(off, offRoot, ['settings', 'browserSlots', '2']);
+ pullboard(off, offRoot, ['settings', 'gate.shortSlots', '0']);
+ const offHolders = await wholeSuiteHolders(off, ['off-one', 'off-two']);
+ const named = { marker: join(off.dir, 'named.started'), release: join(off.dir, 'named.release') };
try {
- await waitFor(() => disabledStarts.every(file => existsSync(file)), 'both disabled-pool ordinary leases to hold');
- const disabledFocusedRoot = shortProbeSuite(disabled, 'disabled-focused');
- disabledRequest = launchTestRunner(disabled, disabledFocusedRoot, ['--disable-warning', 'ExperimentalWarning', '--title', 'disabled-focused-probe', 'test/short-probe.test.js'], disabledRequestStarted, disabledRequestRelease);
- await waitFor(() => disabledRequest.stderrText.includes('waiting for a gate slot:'), 'the named run-tests request to wait when shortSlots is zero');
- assert.equal(existsSync(disabledRequestStarted), false, 'zero shortSlots preserves ordinary full-pool blocking');
- const waitingStatus = spawnSync(process.execPath, [BIN, 'resources', '--json'], { cwd: disabledRoot, env: disabled.env, encoding: 'utf8' });
- assert.equal(waitingStatus.status, 0, waitingStatus.failure ?? waitingStatus.stderr);
- const waitingGate = JSON.parse(waitingStatus.stdout).resources.find(resource => resource.name === 'gate');
- assert.ok(waitingGate.line.some(waiter => waiter.requestedSlot === 'short-eligible'), 'pool status identifies a queued short-eligible request');
- for (const release of disabledReleases) writeFileSync(release, 'release\n');
- await waitFor(() => existsSync(disabledRequestStarted), 'the named request to proceed after an ordinary slot is released');
- assert.equal(JSON.parse(readFileSync(disabledRequestStarted, 'utf8')).slotClass, 'gate');
+ named.child = launchTestRunner(off, shortProbeSuite(off, 'named-off'), ['--test-name-pattern', PROBE_PATTERN, 'test/short-probe.test.js'], named.marker, named.release);
+ const outcome = await waitFor(() => (existsSync(named.marker) ? 'ran' : named.child.stderrText.includes('waiting for a gate slot:') ? 'waiting' : false), 'the named-file run to start or queue');
+ assert.equal(outcome, 'waiting', 'with gate.shortSlots 0 a named-file run waits for a gate slot, as before');
+ const gate = JSON.parse(pullboard(off, offRoot, ['resources', '--json'])).resources.find(resource => resource.name === 'gate');
+ assert.equal(gate.line.length, 1);
+ assert.equal(gate.line[0].requestedSlot, 'short-eligible', 'the waiting run is marked as one that names its files');
+ writeFileSync(offHolders[0].release, 'release\n');
+ await waitFor(() => existsSync(named.marker), 'the named-file run to start once a gate slot frees');
} finally {
- for (const release of [...disabledReleases, disabledRequestRelease]) writeFileSync(release, 'release\n');
- await Promise.all([...disabledHolders, disabledRequest].filter(Boolean).map(child => child.closed));
- }
- for (const child of [...disabledHolders, disabledRequest].filter(Boolean)) {
- const result = await child.closed;
- assert.equal(result.code, 0, `${child.stderrText}${child.stdoutText}`);
- assert.equal(result.signal, null);
+ await releaseAll(named.child ? [...offHolders, named] : offHolders);
}
+ for (const run of named.child ? [...offHolders, named] : offHolders) assert.equal((await run.child.closed).code, 0, `${run.child.stderrText}${run.child.stdoutText}`);
});
test('a focused run queues behind a held gate slot [Q4,C7]', async () => {
diff --git a/test/machine.test.js b/test/machine.test.js
index fc0aada7..43102c08 100644
--- a/test/machine.test.js
+++ b/test/machine.test.js
@@ -32,6 +32,8 @@ const NOT_MOVES = {
BAD_MACHINE_SETTINGS: 'machine-wide settings checked before a command runs',
BAD_GATE_SLOTS: 'machine-wide gate capacity checked before a command runs',
BAD_BROWSER_SLOTS: 'machine-wide browser capacity checked before a command runs',
+ BAD_SHORT_SLOTS: 'machine-wide short gate slot count checked before a command runs',
+ BAD_SHORT_SLOT_REQUEST: 'only a machine gate run that names its test files may ask for a short slot, checked before admission',
BAD_RESOURCE_NAME: 'machine resource names are validated before admission',
RESERVED_RUNNER_RESOURCE: 'runner resource rows are managed by machine admission rather than item moves',
BAD_RESOURCE_CAPACITY: 'machine resource capacity is validated before admission',
@@ -63,6 +65,7 @@ const NOT_MOVES = {
GATE_SLOT_MARKER_INVALID: 'an inherited machine gate capability is validated before nested work starts',
GATE_SLOT_TOKEN_REQUIRED: 'an inherited machine gate capability needs its exact lease token',
GATE_SLOT_LEASE_LOST: 'the exact machine gate lease must still be live before nested work starts',
+ SHORT_SLOT_FULL_SUITE: 'a short gate lease is reused only by nested work that names its test files',
BROWSER_SLOT_REQUIRED: 'browser capacity must be held before a nested browser command can run',
NO_AGENT: 'a linked coordinator must already be registered before an item move',
REMOTE_COORDINATOR_MODEL: 'a linked replica cannot redeclare the coordinator model; use the coordinator checkout',