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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
feat(gate): the landing gate runs in shards across machines [C7,V4]
Corey Olson056af015bb07
diff --git a/bin/run-tests.js b/bin/run-tests.jsindex c5498a3c..4069a778 100644--- a/bin/run-tests.js+++ b/bin/run-tests.js@@ -17,6 +17,9 @@ const runner = fileURLToPath(import.meta.url);const LANDING_RUN_ENV = 'PULLBOARD_LANDING_RUN';const LANDING_WORKER_STARTS_ENV = 'PULLBOARD_LANDING_WORKER_STARTS';const LANDING_ATTEMPT_ENV = 'PULLBOARD_LANDING_ATTEMPT';+// Mirrors src/landing-shards.js; this preload stays free of that module until a landing needs it.+const LANDING_SHARD_ENV = 'PULLBOARD_LANDING_SHARD';+const LANDING_FILE_TIMES_ENV = 'PULLBOARD_LANDING_FILE_TIMES';export const DEFAULT_TEST_TIMEOUT_MS = 660_000;export const DEFAULT_TEST_FILE_TIMEOUT_MS = 30_000;// Worker identity startup retries stay below the ordinary per-file ceiling even if ps is unavailable.@@ -210,6 +213,8 @@ function testEnvironment(sandbox, gateMarkers = {}) {// Model a plain user terminal; person-boundary tests inject agent markers explicitly.for (const key of AGENT_SHELL_MARKERS) delete env[key];for (const key of SSH_SHELL_MARKERS) delete env[key];+ // A test that starts its own run-tests is never a shard of this landing.+ delete env[LANDING_SHARD_ENV];env.HOME = home;env.USERPROFILE = home;env.PULLBOARD_HOME = home;@@ -1299,18 +1304,39 @@ async function main(args) {}let signal = null;/** Keep sandbox lifetime inside the held lease, including the complete child process. */+ const shardLabel = process.env[LANDING_SHARD_ENV];const run = async (gateMarkers) => {const sandbox = mkdtempSync(join(tmpdir(), 'pullboard-test-run-'));+ // A shard of a sharded landing reports each file's wall time back to its orchestrator.+ const fileTimes = shardLabel ? join(sandbox, 'landing-file-times.jsonl') : '';+ if (fileTimes) process.env[LANDING_FILE_TIMES_ENV] = fileTimes;try {const result = await executeTests(args, sandbox, gateMarkers, fullSuite, concurrency);signal = result.signal;process.exitCode = result.status ?? 1;+ if (fileTimes) (await import('../src/landing-shards.js')).printShardFileTimes(fileTimes);} finally { rmSync(sandbox, { recursive: true, force: true }); }};try {const { GATE_SLOT_HELD_ENV, GATE_SLOT_POOL_ENV, GATE_SLOT_TOKEN_ENV, gateSlotEnvironment, inheritedGateSlot } = await import('../src/resources.js');const scopedMarker = process.env[GATE_SLOT_POOL_ENV] || process.env[GATE_SLOT_TOKEN_ENV];const legacyHeld = process.env[GATE_SLOT_HELD_ENV] === '1';+ // A full landing run with landingShards above 1 fans its files out instead of running them here.+ if (fullSuite && process.env[LANDING_RUN_ENV] === '1' && !shardLabel) {+ const { landingShardCount } = await import('../src/gate.js');+ const count = landingShardCount(process.cwd());+ if (count > 1) {+ const files = isGitWorkTree(process.cwd(), process.env) ? trackedDefaultTestFiles(process.cwd(), process.env) : [];+ if (!files.length) throw new Error('a sharded landing gate needs tracked Node test files; commit them or set landingShards to 1');+ const inherited = scopedMarker ? inheritedGateSlot({ root: process.cwd(), browser }) : null;+ const { runLandingShards } = await import('../src/landing-shards.js');+ const { testsNeedBrowser } = await import('../src/browser-admission.js');+ const result = await runLandingShards({ root: process.cwd(), runner, files, count, inherited,+ needsBrowser: shardFiles => testsNeedBrowser(process.cwd(), shardFiles) });+ process.exitCode = result.isGreen ? 0 : 1;+ return;+ }+ }if (scopedMarker) {const inherited = inheritedGateSlot({ root: process.cwd(), browser });if (inherited) await run(gateSlotEnvironment(inherited));@@ -1365,6 +1391,17 @@ if (process.argv[1] && resolve(process.argv[1]) === runner) {await main(process.argv.slice(2));} else if (process.argv[1]) {process.env.PULLBOARD_TEST_FILE = process.argv[1];+ const fileTimes = process.env[LANDING_FILE_TIMES_ENV];+ // Only this test file reports; anything it starts is not one of the shard's files.+ delete process.env[LANDING_FILE_TIMES_ENV];+ if (fileTimes && process.env.NODE_TEST_CONTEXT === 'child-v8') {+ // One line per test file process: its wall time from start to exit, for the next shard plan.+ const timedFile = relative(process.cwd(), resolve(process.argv[1]));+ process.once('exit', () => {+ try { appendFileSync(fileTimes, `${JSON.stringify({ file: timedFile, ms: Math.round(process.uptime() * 1000) })}\n`); }+ catch { /* A missing time only weakens the next shard plan. */ }+ });+ }const startsPath = process.env[LANDING_WORKER_STARTS_ENV];const attempt = process.env[LANDING_ATTEMPT_ENV];const landingWorker = Boolean(startsPath && attempt);diff --git a/docs/api.md b/docs/api.mdindex fd626f8b..afe84616 100644--- a/docs/api.md+++ b/docs/api.md@@ -334,6 +334,8 @@ Row approval and decline first record the person's exact decision through the saThe landing gate sets `PULLBOARD_LANDING_RUN=1` only for its test runner. In that mode, the runner requires process isolation and POSIX process identities; it stops scheduling files after the first test-file failure, interrupts files already running, and reports the failure, interrupted files, and selected files not run. Landing early-stop fails before starting tests on Windows because the runner cannot safely identify and drain owned worker descendants there. It uses Node's execution-ordered test completion events; ordinary focused runs and all non-landing gates keep normal scheduling. The runner clears this marker for test workers and nested commands. If a process-identity census stays unavailable, tests still determine the gate result; the runner reports cleanup as `UNVERIFIED` and does not signal processes whose identity it could not establish. A `UNVERIFIED` cleanup report means descendant cleanup was not confirmed.+With `landingShards: N` in `pullboard.json` (a whole number from 1 to 64; absent or 1 keeps one run), the landing run of `bin/run-tests.js` splits the tracked test files into N shards. It balances them by each file's wall time from the last sharded landing, kept in the repository's `pullboard/landing-file-times.json`; with no times it balances by file count. The first shard uses the gate's own slot. Each other shard takes a landing-priority gate slot, locally or on a registered runner. The run is green only if every shard is green. The first red shard stops the others, which are reported as `stopped`. A shard whose runner fails mid-run prints `landing shard <i>/<n>: runner <host> failed mid-shard; rerunning shard <i>/<n> locally` and reruns on a local slot. The merged log prints one `# landing shard <i>/<n> on <host>: <green|red|stopped> in <ms> ms` line per shard and one `# landing file <i>/<n> <host> <ms|-> <path>` line per file. It also names how the plan was balanced (`history`, `history and average` or `file count`) and, once history exists, the slowest recorded file as `# landing floor: <ms> ms <path>`, since no shard count can finish sooner. The gate profile carries the same fields as `landingShards.balance`, `landingShards.floor`, `landingShards.shards` and `landingShards.files`. Every shard takes any free gate slot, so a runner with two slots can run two shards, and each local shard needing Chrome still waits for the machine's `browserSlots`.+Only the person can run `pullboard land --waive <test> --until <date> --reason "why"`. A waiver retains every test in the full gate. The batch records its exact tree and each failing test with its covering live waiver; pre-push validates that distinct proof and creates no ordinary green stamp. Expired waivers cannot authorize a push. Existing gate-stamped pushes and `pullboard merged` remain available.diff --git a/src/config.js b/src/config.jsindex b5948861..fdb5558b 100644--- a/src/config.js+++ b/src/config.js@@ -162,6 +162,9 @@ export function configProblems(config) {if (config.submitGate !== undefined && config.submitGate !== 'landing') {problems.push('"submitGate" is "landing" when the full suite should be deferred until landing');}+ if (config.landingShards !== undefined && (!Number.isSafeInteger(config.landingShards) || config.landingShards < 1 || config.landingShards > 64)) {+ problems.push('"landingShards" is a whole number from 1 to 64: how many shards the landing gate splits its test files into');+ }if (config.affectedTests !== undefined && (typeof config.affectedTests !== 'string' || !config.affectedTests.trim())) {problems.push('"affectedTests" is a nonempty command prefix used to run selected test files');}diff --git a/src/gate.js b/src/gate.jsindex d605a9a3..60e794fc 100644--- a/src/gate.js+++ b/src/gate.js@@ -18,6 +18,7 @@ import { browserFreeChecksEnabled, loadMachineSettings } from './settings.js';import { selectAffectedTests } from './affected-tests.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';const STAMP = 'pullboard-gate-green';@@ -62,6 +63,26 @@ export function testConcurrency(root, cores = performanceCores()) {return { files, browser: Math.min(files, browser) };}+/**+ * How many shards the landing gate's test files split into: `landingShards` in pullboard.json,+ * 1 when absent, which keeps today's single run.+ *+ * @param {string} root+ * @returns {number}+ */+export function landingShardCount(root) {+ const file = join(root, 'pullboard.json');+ if (!existsSync(file)) return 1;+ let config;+ try { config = JSON.parse(readFileSync(file, 'utf8')); }+ catch { throw new Refused('BAD_CONFIG', 'pullboard.json must be valid JSON before running tests'); }+ const count = config?.landingShards ?? 1;+ if (!Number.isSafeInteger(count) || count < 1 || count > 64) {+ throw new Refused('BAD_CONFIG', 'landingShards must be a whole number from 1 to 64; set it in pullboard.json, or remove it for one landing run');+ }+ return count;+}+/*** The lines of a failure worth an agent's attention: each line that looks like a failure with the* lines under it that say why, then the end of the output, within one cap, so a refusal or a retry@@ -235,7 +256,8 @@ export async function runProfiledShellAsync(root, command, { waitMs = 0, gateSlo/** Keep raw remote TAP intact while resolving its measured filenames against the local source. */function runTiming(run, command) {- const profile = timingFromOutput(run.output, timingRunner(command));+ const shards = landingShardProfile(run.output);+ const profile = { ...timingFromOutput(run.output, timingRunner(command)), ...(shards ? { landingShards: shards } : {}) };if (!run.executionRunner) return profile;/** Relocate only paths inside the actual remote checkout, never a foreign absolute path. */const localPath = path => {@@ -286,6 +308,20 @@ export function writeTimingProfile(path, profile) {format: sanitize(profile.format ?? 'none', 'format'),unavailable: sanitize(profile.unavailable ?? null, 'availability'),...(profile.executionRunner ? { executionRunner: sanitize(profile.executionRunner, 'execution runner') } : {}),+ ...(profile.landingShards ? { landingShards: {+ balance: sanitize(String(profile.landingShards.balance ?? 'unknown'), 'landing balance'),+ floor: profile.landingShards.floor && validDuration(profile.landingShards.floor.ms)+ ? { path: sanitize(String(profile.landingShards.floor.path), 'landing floor path'), ms: profile.landingShards.floor.ms } : null,+ // One entry per attempt, so a failed runner attempt stays beside its local rerun.+ shards: (profile.landingShards.shards ?? []).map(shard => ({ shard: sanitize(String(shard.shard), 'landing shard'),+ attempt: Number.isSafeInteger(shard.attempt) ? shard.attempt : 1,+ host: sanitize(String(shard.host), 'landing shard host'), status: sanitize(String(shard.status), 'landing shard status'),+ reason: shard.reason ? sanitize(String(shard.reason), 'landing shard reason') : null,+ wallMs: validDuration(shard.wallMs) ? shard.wallMs : null })),+ files: (profile.landingShards.files ?? []).filter(file => typeof file?.path === 'string').map(file => ({+ path: sanitize(file.path, 'landing file path'), shard: sanitize(String(file.shard), 'landing file shard'),+ host: sanitize(String(file.host), 'landing file host'), durationMs: validDuration(file.durationMs) ? file.durationMs : null })),+ } } : {}),...(profile.executionSource ? { executionSource: {commit: sanitize(profile.executionSource.commit, 'execution commit'),tree: sanitize(profile.executionSource.tree, 'execution tree'),diff --git a/src/landing-shards.js b/src/landing-shards.jsnew file mode 100644index 00000000..e15a7442--- /dev/null+++ b/src/landing-shards.js@@ -0,0 +1,371 @@+/**+ * The landing gate in shards [C7,V4]: split the tracked test files into balanced shards, run each on+ * a free local gate slot or a registered runner, and report one result. One red shard stops the rest,+ * and a shard whose runner fails mid-run reruns locally.+ */+import { spawn } from 'node:child_process';+import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';+import { dirname, join } from 'node:path';+import { randomUUID } from 'node:crypto';+import { repoInfo } from './git.js';+import {+ BROWSER_SLOT_HELD_ENV,+ GATE_SLOT_HELD_ENV,+ GATE_SLOT_POOL_ENV,+ GATE_SLOT_TOKEN_ENV,+ gateSlotEnvironment,+} from './resources.js';++/** Environment variable naming the shard a nested run-tests process runs, as `<i>/<n>`. */+export const LANDING_SHARD_ENV = 'PULLBOARD_LANDING_SHARD';+/** Environment variable naming the file where each test file process appends its wall time. */+export const LANDING_FILE_TIMES_ENV = 'PULLBOARD_LANDING_FILE_TIMES';+/** Prefix of the per-file wall-time lines a shard prints for its orchestrator. */+export const FILE_TIME_LINE = '# landing-file-ms ';++const GATE_MARKERS = [GATE_SLOT_HELD_ENV, GATE_SLOT_POOL_ENV, GATE_SLOT_TOKEN_ENV, BROWSER_SLOT_HELD_ENV];+// Budget: a stopped local shard gets this long to drain after TERM before its group is killed.+const STOP_GRACE_MS = 10_000;++/** Where the last landing's per-file wall times live, shared by every worktree of the repository. */+export function fileTimesPath(root) {+ return join(repoInfo(root).commonDir, 'pullboard', 'landing-file-times.json');+}++/** Read the last per-file wall times; a missing or unreadable record means none are known. */+export function readFileTimes(root) {+ try {+ const value = JSON.parse(readFileSync(fileTimesPath(root), 'utf8'));+ if (!value || typeof value !== 'object' || Array.isArray(value)) return {};+ return Object.fromEntries(Object.entries(value.files ?? {}).filter(([, ms]) => Number.isFinite(ms) && ms >= 0));+ } catch { return {}; }+}++/** Keep the newest wall time for every file this landing measured, beside the older ones. */+function writeFileTimes(root, measured) {+ const path = fileTimesPath(root);+ const files = { ...readFileTimes(root), ...measured };+ mkdirSync(dirname(path), { recursive: true, mode: 0o700 });+ const temporary = `${path}.${process.pid}.${randomUUID()}.tmp`;+ writeFileSync(temporary, `${JSON.stringify({ version: 1, files }, null, 2)}\n`, { mode: 0o600 });+ renameSync(temporary, path);+}++/** Normalize a test file path to its repository-relative form, without a leading `./`. */+export function fileKey(file) {+ return String(file).replace(/^\.\//u, '');+}++/**+ * Split files into at most `count` shards by weight, heaviest first onto the lightest shard.+ * A file with a known wall time weighs that time; with no times at all every file weighs one, so the+ * split falls back to file count. A new file weighs the average known time. Empty shards are dropped.+ *+ * @param {string[]} files+ * @param {number} count+ * @param {Record<string, number>} [times] - Last wall time in ms by repository-relative path.+ * @returns {{ files: string[], weight: number }[]}+ */+export function planLandingShards(files, count, times = {}) {+ const known = files.map(file => times[fileKey(file)]).filter(ms => Number.isFinite(ms));+ const average = known.length ? known.reduce((sum, ms) => sum + ms, 0) / known.length : 1;+ const weight = file => known.length ? (Number.isFinite(times[fileKey(file)]) ? times[fileKey(file)] : average) : 1;+ const ordered = [...files].sort((a, b) => weight(b) - weight(a) || a.localeCompare(b));+ const shards = Array.from({ length: Math.max(1, count) }, () => ({ files: [], weight: 0 }));+ for (const file of ordered) {+ const lightest = shards.reduce((best, shard) => shard.weight < best.weight+ || (shard.weight === best.weight && shard.files.length < best.files.length) ? shard : best);+ lightest.files.push(file);+ lightest.weight += weight(file);+ }+ for (const shard of shards) shard.files.sort((a, b) => a.localeCompare(b));+ return shards.filter(shard => shard.files.length);+}++/**+ * Name how a plan was balanced: by the last measured per-file wall times when every file has one,+ * by those times with new files at their average when some do, and by file count when none do.+ *+ * @param {string[]} files+ * @param {Record<string, number>} [times]+ * @returns {'history'|'history and average'|'file count'}+ */+export function landingBalance(files, times = {}) {+ const known = files.filter(file => Number.isFinite(times[fileKey(file)])).length;+ return known === files.length && known ? 'history' : known ? 'history and average' : 'file count';+}++/** The slowest file with a recorded wall time, which no shard count can beat; null with no history. */+export function landingFloor(files, times = {}) {+ let floor = null;+ for (const file of files) {+ const ms = times[fileKey(file)];+ if (Number.isFinite(ms) && (!floor || ms > floor.ms)) floor = { path: fileKey(file), ms: Math.round(ms) };+ }+ return floor;+}++/** Read the per-file wall-time lines a shard printed, keeping the longest report for each file. */+export function shardFileTimes(output) {+ const times = {};+ for (const line of String(output).split(/\r?\n/u)) {+ if (!line.startsWith(FILE_TIME_LINE)) continue;+ const rest = line.slice(FILE_TIME_LINE.length);+ const space = rest.indexOf(' ');+ const ms = Number(rest.slice(0, space));+ const file = fileKey(rest.slice(space + 1));+ if (space > 0 && Number.isFinite(ms) && ms >= 0 && file) times[file] = Math.max(times[file] ?? 0, ms);+ }+ return times;+}++/** The process environment without this process's own gate markers, so a shard never reuses them. */+function withoutGateMarkers(env) {+ const copy = { ...env };+ for (const key of GATE_MARKERS) delete copy[key];+ return copy;+}++/** Quote one word for the runner's POSIX shell. */+function word(value) {+ return `'${String(value).replaceAll("'", "'\\''")}'`;+}++/** Stop a detached shard's whole process group: TERM, then KILL after its grace. */+async function stopGroup(child, closed) {+ const signal = name => { try { process.kill(-child.pid, name); } catch (error) { if (error.code !== 'ESRCH') throw error; } };+ signal('SIGTERM');+ const timer = setTimeout(() => signal('SIGKILL'), STOP_GRACE_MS);+ await closed;+ clearTimeout(timer);+ signal('SIGKILL');+}++/** Run one shard's files in a local child run-tests that inherits the shard's own gate lease. */+async function runLocalShard({ root, runner, files, label, lease, stop }) {+ const env = { ...withoutGateMarkers(process.env), ...gateSlotEnvironment(lease),+ PULLBOARD_LANDING_RUN: '1', [LANDING_SHARD_ENV]: label };+ // Its own process group, so a stop reaches the shard's test files and their children together.+ const child = spawn(process.execPath, [runner, ...files], { cwd: root, env, detached: true, stdio: ['ignore', 'pipe', 'pipe'] });+ const chunks = [];+ child.stdout.setEncoding('utf8').on('data', part => chunks.push(part));+ child.stderr.setEncoding('utf8').on('data', part => chunks.push(part));+ const closed = new Promise(resolveClose => {+ child.once('error', error => { chunks.push(`\n${error.message}\n`); resolveClose({ status: 1, signal: null }); });+ child.once('close', (status, signal) => resolveClose({ status, signal }));+ });+ const onStop = () => { stopGroup(child, closed).catch(() => {}); };+ if (stop.aborted) onStop();+ else stop.addEventListener('abort', onStop, { once: true });+ const { status, signal } = await closed;+ stop.removeEventListener('abort', onStop);+ return { isGreen: status === 0 && !signal, output: chunks.join('') };+}++/** A shard's acquisition stopped waiting because the shard ran elsewhere or the landing stopped. */+class NotNeeded extends Error {}++/**+ * Run the landing gate's test files as `count` shards and return one result.+ *+ * The slot this process already holds is a lane of its own: it runs the first shard, then any shard+ * no other slot has taken yet. Every other shard also queues for a slot of its own, locally or on a+ * runner, and whichever slot reaches it first runs it. So a landing always finishes on its own slot,+ * and two landings that hold the only two slots cannot wait on each other.+ *+ * A red shard is a test failure: it stops the others and the landing is red, with no retry. Only an+ * infrastructure failure of a runner (a dropped transport or a runner refusal) reruns that shard,+ * locally, after a named line; both attempts stay in the merged log and profile.+ *+ * @param {{ root: string, runner: string, files: string[], count: number, inherited?: object|null,+ * needsBrowser?: (files: string[]) => Promise<boolean>, write?: (text: string) => void }} options+ * `runner` is this repository's bin/run-tests.js; `inherited` is the gate lease this process already+ * holds; `write` receives the merged log.+ * @returns {Promise<{ isGreen: boolean, balance: string, shards: object[], files: object[] }>}+ */+export async function runLandingShards({ root, runner, files, count, inherited = null, needsBrowser = async () => true, write = text => process.stdout.write(text) }) {+ const { withGateSlot } = await import('./gate.js');+ const { RunnerDropped, runOnRunnerAsync } = await import('./runners.js');+ const { Refused } = await import('./refused.js');+ const history = readFileTimes(root);+ const plan = planLandingShards(files, count, history);+ const balance = landingBalance(files, history);+ const total = plan.length;+ const stopper = new AbortController();+ const stop = stopper.signal;+ let firstFailure = null;+ // The parent's own markers would make every shard reuse its one lease; each lane passes its own.+ const saved = Object.fromEntries(GATE_MARKERS.map(key => [key, process.env[key]]));+ for (const key of GATE_MARKERS) delete process.env[key];+ write(`# landing shards: ${total} balanced by ${balance} (${plan.map((shard, index) => `${index + 1}/${total} ${shard.files.length} files`).join(', ')})\n`);+ const floor = landingFloor(files, history);+ // The slowest single file bounds the gate however many shards there are.+ if (floor) write(`# landing floor: ${floor.ms} ms ${floor.path}\n`);++ let wake = () => {};+ let changed = new Promise(resolveChange => { wake = resolveChange; });+ /** Tell the parent's lane that a shard became free to take or finished. */+ const signalChange = () => { const resolveChange = wake; changed = new Promise(next => { wake = next; }); resolveChange(); };+ const entries = await Promise.all(plan.map(async (shard, index) => ({ shard, label: `${index + 1}/${total}`,+ browser: await needsBrowser(shard.files), claimed: false, localOnly: false, done: false, attempts: [], status: null })));++ /** Run one attempt of a shard on a lease: a local child, or the runner it names. */+ const attempt = async (entry, lease) => {+ const started = Date.now();+ const number = entry.attempts.length + 1;+ if (!lease.runner) {+ const run = await runLocalShard({ root, runner, files: entry.shard.files, label: entry.label, lease, stop });+ return { attempt: number, host: 'local', outcome: run.isGreen ? 'green' : 'red', output: run.output, wallMs: Date.now() - started };+ }+ const command = `${LANDING_SHARD_ENV}=${word(entry.label)} ${['node', './bin/run-tests.js', ...entry.shard.files].map(word).join(' ')}`;+ try {+ const run = await runOnRunnerAsync(root, command, { runner: lease.runner, source: lease.source, browser: lease.browser,+ metadata: { ...(lease.runMetadata ?? {}), landing: true }, signal: stop });+ return { attempt: number, host: lease.runner.host, outcome: run.isGreen ? 'green' : 'red', output: run.output, wallMs: Date.now() - started };+ } catch (error) {+ // A stop ends the runner's transport on purpose; that shard was stopped, not dropped.+ if (stop.aborted) return { attempt: number, host: lease.runner.host, outcome: 'stopped', output: '', wallMs: Date.now() - started };+ // Infrastructure, not a test result: the runner could not give this shard a complete answer.+ if (error instanceof RunnerDropped || error instanceof Refused) {+ const reason = error instanceof RunnerDropped ? 'runner transport lost' : `runner refused: ${error.code}`;+ return { attempt: number, host: lease.runner.host, outcome: 'infrastructure', reason, output: '', wallMs: Date.now() - started };+ }+ throw error;+ }+ };++ /** Record an attempt's outcome, stopping the landing at the first test failure. */+ const settle = (entry, record) => {+ const stopped = record.outcome !== 'green' && (stop.aborted || firstFailure !== null);+ const status = record.outcome === 'infrastructure' && !stopped ? 'infrastructure' : stopped ? 'stopped' : record.outcome;+ entry.attempts.push({ ...record, status });+ write(`# landing shard ${entry.label} attempt ${record.attempt} on ${record.host}: ${status}${record.reason ? ` (${record.reason})` : ''} in ${record.wallMs} ms\n`);+ if (record.output) write(record.output.endsWith('\n') ? record.output : `${record.output}\n`);+ if (status === 'infrastructure') {+ write(`landing shard ${entry.label}: runner ${record.host} failed mid-shard; rerunning shard ${entry.label} locally\n`);+ entry.claimed = false;+ entry.localOnly = true;+ acquire(entry);+ } else {+ entry.done = true;+ entry.status = status;+ if (status === 'red') {+ firstFailure = entry.label;+ stopper.abort();+ }+ }+ signalChange();+ };++ /** Run a claimed shard on a lease, unless the landing already stopped. */+ const runOnLease = async (entry, lease) => {+ if (entry.done) return;+ if (stop.aborted) {+ entry.done = true;+ entry.status = 'stopped';+ entry.attempts.push({ attempt: entry.attempts.length + 1, host: 'none', outcome: 'stopped', status: 'stopped', wallMs: 0, output: '' });+ write(`# landing shard ${entry.label} attempt ${entry.attempts.length} on none: stopped in 0 ms\n`);+ signalChange();+ return;+ }+ entry.running = true;+ try { settle(entry, await attempt(entry, lease)); }+ finally { entry.running = false; }+ };++ const failures = [];+ /** Queue this shard for a slot of its own; the parent's lane may take it first. */+ const acquire = (entry) => {+ const localOnly = entry.localOnly;+ const running = withGateSlot(root, async lease => {+ if (entry.claimed || entry.done) return;+ entry.claimed = true;+ await runOnLease(entry, lease);+ }, { landing: true, browser: entry.browser, remote: !localOnly, kind: 'landing', item: `shard ${entry.label}`,+ onWait: () => { if (entry.claimed || entry.done || stop.aborted) throw new NotNeeded(); } });+ running.catch(error => {+ if (error instanceof NotNeeded) {+ // A stopped shard that was only waiting for a slot is recorded as stopped here.+ if (stop.aborted && !entry.done && !entry.running) runOnLease(entry, {}).catch(() => {});+ return;+ }+ failures.push(error);+ stopper.abort();+ signalChange();+ });+ };++ /** The parent's own slot: run free shards one after another until every shard is done. */+ const lane = async () => {+ while (!entries.every(entry => entry.done) && !failures.length) {+ const next = entries.find(entry => !entry.claimed && !entry.done);+ if (!next) { await changed; continue; }+ next.claimed = true;+ await runOnLease(next, inherited);+ }+ };++ let shards;+ try {+ for (const entry of entries) if (!inherited || entry !== entries[0]) acquire(entry);+ if (inherited) await lane();+ while (!entries.every(entry => entry.done) && !failures.length) await changed;+ if (failures.length) throw failures[0];+ shards = entries;+ } finally {+ for (const [key, value] of Object.entries(saved)) if (value !== undefined) process.env[key] = value;+ }+ const merged = [];+ const measured = {};+ for (const entry of shards) {+ const last = entry.attempts.at(-1);+ const times = shardFileTimes(last?.output ?? '');+ for (const file of entry.shard.files.map(fileKey)) {+ const ms = times[file];+ if (Number.isFinite(ms)) measured[file] = ms;+ merged.push({ path: file, shard: entry.label, host: last?.host ?? 'none', durationMs: Number.isFinite(ms) ? ms : null });+ }+ }+ for (const file of merged.sort((a, b) => a.path.localeCompare(b.path))) {+ write(`# landing file ${file.shard} ${file.host} ${file.durationMs ?? '-'} ${file.path}\n`);+ }+ const isGreen = shards.every(entry => entry.status === 'green');+ write(`# landing result: ${isGreen ? 'green' : `red, first failure in shard ${firstFailure ?? shards.find(entry => entry.status !== 'green')?.label}`}\n`);+ if (Object.keys(measured).length) writeFileTimes(root, measured);+ return { isGreen, balance,+ shards: shards.map(entry => ({ shard: entry.label, status: entry.status,+ attempts: entry.attempts.map(({ output, ...record }) => record) })),+ files: merged };+}++/** Read the merged shard lines from a gate log into profile fields, or null for an unsharded run. */+export function landingShardProfile(output) {+ const shards = [];+ const files = [];+ let balance = null;+ let floor = null;+ for (const line of String(output).split(/\r?\n/u)) {+ const plan = /^# landing shards: \d+ balanced by (history|history and average|file count) \(/u.exec(line);+ if (plan) balance = plan[1];+ const slowest = /^# landing floor: (\d+) ms (.+)$/u.exec(line);+ if (slowest) floor = { path: slowest[2], ms: Number(slowest[1]) };+ const shard = /^# landing shard (\d+\/\d+) attempt (\d+) on (\S+): (green|red|stopped|infrastructure)(?: \(([^)]*)\))? in (\d+) ms$/u.exec(line);+ if (shard) shards.push({ shard: shard[1], attempt: Number(shard[2]), host: shard[3], status: shard[4], reason: shard[5] ?? null, wallMs: Number(shard[6]) });+ const file = /^# landing file (\d+\/\d+) (\S+) (\d+|-) (.+)$/u.exec(line);+ if (file) files.push({ path: file[4], shard: file[1], host: file[2], durationMs: file[3] === '-' ? null : Number(file[3]) });+ }+ return shards.length ? { balance, floor, shards, files } : null;+}++/** Print this shard's per-file wall times for its orchestrator; a missing record prints nothing. */+export function printShardFileTimes(path, write = text => process.stdout.write(text)) {+ if (!path || !existsSync(path)) return;+ const times = {};+ for (const line of readFileSync(path, 'utf8').split('\n')) {+ try {+ const { file, ms } = JSON.parse(line);+ if (typeof file === 'string' && Number.isFinite(ms)) times[fileKey(file)] = Math.max(times[fileKey(file)] ?? 0, ms);+ } catch { /* A torn last line from a killed file process carries no time. */ }+ }+ for (const [file, ms] of Object.entries(times)) write(`${FILE_TIME_LINE}${Math.round(ms)} ${file}\n`);+}diff --git a/test/landing-shards.test.js b/test/landing-shards.test.jsnew file mode 100644index 00000000..3f2068ed--- /dev/null+++ b/test/landing-shards.test.js@@ -0,0 +1,269 @@+/** The landing gate splits its test files into shards across local slots and runners [C7,V4]. */+import assert from 'node:assert/strict';+import { spawn } from 'node:child_process';+import { chmodSync, copyFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join, resolve } from 'node:path';+import { pathToFileURL } from 'node:url';+import { test } from 'node:test';+import { configProblems, defaults } from '../src/config.js';+import { landingShardCount } from '../src/gate.js';+import { landingBalance, landingFloor, planLandingShards, shardFileTimes } from '../src/landing-shards.js';+import { runFixtureChild } from './fixture-child.js';++const SOURCE = resolve(import.meta.dirname, '..');+const BIN = join(SOURCE, 'bin', 'pullboard.js');+const HOST = 'fixture-host';+const NAMES = ['a', 'b', 'c', 'd', 'e', 'f'];++/** Run Git in a fixture repository and fail with its context. */+function git(cwd, env, ...args) {+ const result = runFixtureChild('git', args, { cwd, env, encoding: 'utf8' });+ assert.equal(result.status, 0, result.context);+ return result.stdout.trim();+}++/**+ * Make a local ssh stand-in that runs the worker command in a second private machine home.+ * With `dropOnce`, its first session kills the worker as soon as a test file starts on the runner,+ * the way a runner that loses power mid-shard looks to the controller.+ */+function installSshStandIn({ bin, worker, home, machineHome, markers, dropOnce }) {+ const source = `#!/usr/bin/env node+import { existsSync, readdirSync, writeFileSync } from 'node:fs';+import { spawn } from 'node:child_process';+const argv = process.argv.slice(2);+const divider = argv.indexOf('--');+const host = argv[divider + 1];+const remoteCommand = argv[divider + 2];+if (host !== ${JSON.stringify(HOST)}) process.exit(255);+const dropFlag = ${JSON.stringify(dropOnce ?? '')};+const drop = dropFlag && !existsSync(dropFlag);+if (drop) writeFileSync(dropFlag, 'dropped\\n');+const env = { PATH: process.env.PATH, HOME: ${JSON.stringify(home)}, TMPDIR: process.env.TMPDIR,+ PULLBOARD_HOME: ${JSON.stringify(home)}, PULLBOARD_MACHINE_HOME: ${JSON.stringify(machineHome)}, LANG: 'C', LC_ALL: 'C', TZ: 'UTC' };+const child = spawn('/bin/sh', ['-c', remoteCommand], { cwd: ${JSON.stringify(worker)}, env, stdio: ['pipe', 'pipe', 'pipe'] });+child.stdout.pipe(process.stdout);+child.stderr.pipe(process.stderr);+process.stdin.pipe(child.stdin);+if (drop) {+ const timer = setInterval(() => {+ if (!readdirSync(${JSON.stringify(markers)}).some(name => name.endsWith('.runner.started'))) return;+ clearInterval(timer);+ process.kill(child.pid, 'SIGHUP');+ process.exit(255);+ }, 20);+}+child.once('close', (code, signal) => { process.exitCode = signal ? 128 : (code ?? 255); });+`;+ const ssh = join(bin, 'ssh');+ writeFileSync(ssh, source, { mode: 0o700 });+ chmodSync(ssh, 0o700);+}++/** A fixture test file: it marks where it ran and behaves as the current mode file says. */+function fixtureTestFile(name, { markers, mode }) {+ return `import { test } from 'node:test';+import { existsSync, readFileSync, writeFileSync } from 'node:fs';+const name = ${JSON.stringify(name)};+const host = process.cwd().includes('worker-home') ? 'runner' : 'local';+const mode = existsSync(${JSON.stringify(mode)}) ? readFileSync(${JSON.stringify(mode)}, 'utf8').trim() : 'green';+const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));+test('fixture file ' + name, async () => {+ writeFileSync(${JSON.stringify(markers)} + '/' + name + '.' + host + '.started', '');+ if (mode === 'fail' && name === 'a') throw new Error('fixture failure in file a');+ if (mode === 'late-fail' && name === 'a') { await sleep(6_000); throw new Error('late fixture failure in file a'); }+ // Long enough that only a stop can end the other files before the scenario's deadline.+ await sleep(mode === 'fail' || (mode === 'drop' && host === 'runner') ? 40_000 : 1_500);+ writeFileSync(${JSON.stringify(markers)} + '/' + name + '.' + host + '.finished', '');+});+`;+}++/** Build a committed fixture project holding this Pullboard's runner and six test files. */+function fixture({ runner = true, repoNames = ['repo'] } = {}) {+ const dir = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-landing-shards-')));+ const home = join(dir, 'home');+ const machineHome = join(home, '.pullboard');+ const remoteHome = join(dir, 'worker-home');+ const remoteMachineHome = join(remoteHome, '.pullboard');+ const repos = repoNames.map(name => join(dir, name));+ const repo = repos[0];+ const worker = join(dir, 'second-machine');+ const bin = join(dir, 'bin');+ const markers = join(dir, 'markers');+ const mode = join(dir, 'mode');+ for (const folder of [home, machineHome, remoteHome, remoteMachineHome, worker, bin, markers, ...repos.map(path => join(path, 'test'))]) mkdirSync(folder, { recursive: true });+ writeFileSync(join(machineHome, 'settings.json'), JSON.stringify({ gateSlots: 2, browserSlots: 2 }));+ const env = {+ ...process.env, HOME: home, PULLBOARD_HOME: home, PULLBOARD_MACHINE_HOME: machineHome,+ PATH: `${bin}:${process.env.PATH}`, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1',+ GIT_AUTHOR_NAME: 'Landing Shards Fixture', GIT_AUTHOR_EMAIL: '[email protected]',+ GIT_COMMITTER_NAME: 'Landing Shards Fixture', GIT_COMMITTER_EMAIL: '[email protected]',+ };+ for (const key of Object.keys(env)) {+ if (/^PULLBOARD_(GATE_SLOT|BROWSER_SLOT|LANDING)/u.test(key) || ['GIT_DIR', 'GIT_WORK_TREE', 'GIT_INDEX_FILE'].includes(key)) delete env[key];+ }+ for (const path of repos) {+ copyFileSync(join(SOURCE, 'package.json'), join(path, 'package.json'));+ cpSync(join(SOURCE, 'src'), join(path, 'src'), { recursive: true });+ cpSync(join(SOURCE, 'bin'), join(path, 'bin'), { recursive: true });+ for (const name of NAMES) writeFileSync(join(path, 'test', `${name}.test.js`), fixtureTestFile(name, { markers, mode }));+ writeFileSync(join(path, 'pullboard.json'), JSON.stringify({ gate: 'node bin/run-tests.js', landingShards: 3 }));+ git(path, env, 'init', '-q', '-b', 'main');+ git(path, env, 'add', '.');+ git(path, env, 'commit', '-q', '-m', 'test: landing shards fixture');+ }+ if (runner) {+ const added = runFixtureChild(process.execPath, [BIN, 'runner', 'add', HOST, '--slots', '1', '--browser', '1', '--json'], { cwd: repo, env, encoding: 'utf8' });+ assert.equal(added.status, 0, added.context);+ }+ return { dir, repo, repos, env, bin, worker, remoteHome, remoteMachineHome, markers, mode };+}++/** Clear a scenario's markers and pick its mode. */+function scenario(box, mode, { dropOnce } = {}) {+ rmSync(box.markers, { recursive: true, force: true });+ mkdirSync(box.markers);+ writeFileSync(box.mode, `${mode}\n`);+ installSshStandIn({ bin: box.bin, worker: box.worker, home: box.remoteHome, machineHome: box.remoteMachineHome,+ markers: box.markers, dropOnce: dropOnce ? join(box.dir, `dropped-${mode}`) : '' });+}++/**+ * Run the fixture's landing gate (the same runGate call `gate --landing` makes) in its own process+ * group. Past its deadline the whole group is stopped and the scenario fails naming itself.+ */+async function landingGate(box, label, deadlineMs, repo = box.repo) {+ const gateUrl = pathToFileURL(join(repo, 'src', 'gate.js')).href;+ const configUrl = pathToFileURL(join(repo, 'src', 'config.js')).href;+ const script = `const { runGate } = await import(${JSON.stringify(gateUrl)});+const { loadConfig } = await import(${JSON.stringify(configUrl)});+const root = ${JSON.stringify(repo)};+const gate = await runGate(root, loadConfig(root), { landing: true, trustStamp: false, agent: 'landing-shards-fixture' });+process.stdout.write(JSON.stringify({ isGreen: gate.isGreen, output: gate.output, profile: gate.profile }));`;+ const child = spawn(process.execPath, ['--input-type=module', '-e', script], { cwd: repo, env: box.env, detached: true, stdio: ['ignore', 'pipe', 'pipe'] });+ let stdout = '';+ let stderr = '';+ child.stdout.setEncoding('utf8').on('data', part => { stdout += part; });+ child.stderr.setEncoding('utf8').on('data', part => { stderr += part; });+ const closed = new Promise(resolveClose => child.once('close', (status, signal) => resolveClose({ status, signal })));+ let timer;+ const deadline = new Promise(resolveDeadline => { timer = setTimeout(() => resolveDeadline(null), deadlineMs); });+ const ended = await Promise.race([closed, deadline]);+ clearTimeout(timer);+ if (!ended) {+ for (const signal of ['SIGTERM', 'SIGKILL']) { try { process.kill(-child.pid, signal); } catch { /* already gone */ } }+ await closed;+ throw new Error(`landing gate scenario "${label}" passed its ${deadlineMs} ms deadline\n${stdout.slice(-4_000)}\n${stderr.slice(-4_000)}`);+ }+ assert.equal(ended.status, 0, `scenario "${label}": the gate process failed\n${stderr.slice(-4_000)}`);+ return { ...JSON.parse(stdout), stderr };+}++/** The merged log's per-file lines as {file: {shard, host}}. */+function mergedFiles(output) {+ const files = {};+ for (const match of output.matchAll(/^# landing file (\d+\/\d+) (\S+) (\d+|-) (.+)$/gmu)) {+ assert.equal(files[match[4]], undefined, `${match[4]} is listed once`);+ files[match[4]] = { shard: match[1], host: match[2] };+ }+ return files;+}++/** Markers left by the fixture files, as a sorted list. */+function marks(box, suffix) {+ return readdirSync(box.markers).filter(name => name.endsWith(suffix)).sort();+}++test('a landing gate split into shards reports one result [C7,V4]', { timeout: 300_000 }, async (t) => { // budget: three bounded landing scenarios on one fixture.+ // The planner: no times balances by count; known times put the heavy files on their own shards.+ const six = NAMES.map(name => `./test/${name}.test.js`);+ assert.deepEqual(planLandingShards(six, 3).map(shard => shard.files.length), [2, 2, 2]);+ const weighted = planLandingShards(six, 3, { 'test/a.test.js': 900, 'test/b.test.js': 800, 'test/c.test.js': 100, 'test/d.test.js': 100, 'test/e.test.js': 100, 'test/f.test.js': 100 });+ assert.deepEqual(weighted.map(shard => shard.files), [['./test/a.test.js'], ['./test/b.test.js'], ['./test/c.test.js', './test/d.test.js', './test/e.test.js', './test/f.test.js']]);+ assert.equal(landingBalance(six), 'file count', 'with no history the plan names its file-count fallback');+ assert.equal(landingBalance(six, { 'test/a.test.js': 900 }), 'history and average');+ assert.equal(landingBalance(six, Object.fromEntries(NAMES.map(name => [`test/${name}.test.js`, 10]))), 'history');+ assert.deepEqual(landingFloor(six, { 'test/a.test.js': 900, 'test/b.test.js': 50 }), { path: 'test/a.test.js', ms: 900 });+ assert.equal(landingFloor(six), null);+ assert.deepEqual(shardFileTimes('# landing-file-ms 42 test/a.test.js\nnoise\n'), { 'test/a.test.js': 42 });+ assert.equal(configProblems({ ...defaults(), landingShards: 0 }).some(problem => problem.includes('"landingShards"')), true);+ assert.deepEqual(configProblems({ ...defaults(), landingShards: 3 }), []);++ const box = fixture();+ t.after(() => rmSync(box.dir, { recursive: true, force: true }));+ assert.equal(landingShardCount(box.repo), 3);++ // Green: three shards, one of them on the runner, every file once, one green result.+ scenario(box, 'green');+ const green = await landingGate(box, 'green', 120_000);+ assert.equal(green.isGreen, true, green.output);+ const files = mergedFiles(green.output);+ assert.deepEqual(Object.keys(files).sort(), NAMES.map(name => `test/${name}.test.js`));+ assert.deepEqual([...new Set(Object.values(files).map(file => file.shard))].sort(), ['1/3', '2/3', '3/3']);+ assert.ok(Object.values(files).some(file => file.host === HOST), `one shard runs on the registered runner\n${green.output}`);+ assert.ok(Object.values(files).some(file => file.host === 'local'), 'the others run on local slots');+ assert.match(green.output, /^# landing result: green$/mu);+ assert.match(green.output, /^# landing shards: 3 balanced by file count \(/mu, 'the first landing has no history');+ assert.equal(green.profile.landingShards.balance, 'file count');+ assert.equal(green.profile.landingShards.files.length, 6, 'the profile names every file once');+ assert.ok(green.profile.landingShards.files.every(file => file.shard && file.host));+ assert.equal(green.profile.landingShards.shards.filter(shard => shard.status === 'green').length, 3);+ assert.equal(marks(box, '.finished').length, 6);+ // Every file's measured wall time is kept, so the next landing balances by real history.+ const history = JSON.parse(readFileSync(join(box.repo, '.git', 'pullboard', 'landing-file-times.json'), 'utf8'));+ assert.deepEqual(Object.keys(history.files).sort(), NAMES.map(name => `test/${name}.test.js`));+ assert.ok(Object.values(history.files).every(ms => Number.isFinite(ms) && ms > 0), 'each file has a measured wall time');+ assert.ok(green.profile.landingShards.files.every(file => Number.isFinite(file.durationMs) && file.durationMs > 0));++ // One failing file: the gate goes red and the other shards are stopped, long before their files end.+ scenario(box, 'fail');+ const red = await landingGate(box, 'failing shard', 60_000);+ assert.equal(red.isGreen, false, red.output);+ assert.match(red.output, /^# landing shard \d\/3 attempt 1 on \S+: red in \d+ ms$/mu);+ assert.equal([...red.output.matchAll(/^# landing shard \d\/3 attempt \d+ on \S+: stopped in \d+ ms$/gmu)].length, 2, red.output);+ // A test failure is not infrastructure: nothing reruns and nothing falls back.+ assert.doesNotMatch(red.output, /rerunning shard|infrastructure/u);+ assert.equal(red.profile.landingShards.shards.length, 3, 'one attempt per shard');+ assert.match(red.output, /^# landing result: red, first failure in shard \d\/3$/mu);+ assert.match(red.output, /^# landing shards: 3 balanced by history \(/mu, 'the second landing balances by the first one\'s wall times');+ assert.match(red.output, /^# landing floor: \d+ ms test\/[a-f]\.test\.js$/mu, 'the slowest recorded file is named as the floor');+ assert.equal(green.profile.landingShards.floor, null, 'with no history there is no floor yet');+ assert.ok(red.profile.landingShards.floor.ms > 0);+ // Every other file sleeps far past this scenario's deadline, so none finishing means each was stopped.+ assert.deepEqual(marks(box, '.finished'), [], 'no stopped file ran to its end');++ // A shard that fails after the others went green still makes the whole landing red.+ scenario(box, 'late-fail');+ const late = await landingGate(box, 'late failing shard', 60_000);+ assert.equal(late.isGreen, false, late.output);+ assert.ok(late.profile.landingShards.shards.some(shard => shard.status === 'green'), `another shard was green first\n${late.output}`);+ assert.equal(late.profile.landingShards.shards.filter(shard => shard.status === 'red').length, 1);++ // A runner killed mid-shard: its shard reruns locally with a named line and the gate stays green.+ scenario(box, 'drop', { dropOnce: true });+ const dropped = await landingGate(box, 'killed runner', 150_000);+ assert.equal(dropped.isGreen, true, dropped.output);+ const rerun = /^landing shard (\d\/3): runner fixture-host failed mid-shard; rerunning shard \1 locally$/mu.exec(dropped.output);+ assert.ok(rerun, `the rerun is named\n${dropped.output}`);+ const label = rerun[1].replace('/', '\\/');+ // Both attempts stay in the log and the profile: the failed runner attempt first, then the local rerun.+ assert.match(dropped.output, new RegExp(`^# landing shard ${label} attempt 1 on ${HOST}: infrastructure \\(runner transport lost\\) in \\d+ ms$`, 'mu'));+ assert.match(dropped.output, new RegExp(`^# landing shard ${label} attempt 2 on local: green in \\d+ ms$`, 'mu'));+ const attempts = dropped.profile.landingShards.shards.filter(shard => shard.shard === rerun[1]);+ assert.deepEqual(attempts.map(shard => [shard.attempt, shard.host, shard.status]), [[1, HOST, 'infrastructure'], [2, 'local', 'green']]);+ assert.ok(marks(box, '.runner.started').length > 0, 'the shard had started on the runner');+ assert.deepEqual(marks(box, '.finished').filter(name => name.endsWith('.local.finished')).length, 6, 'every file finished locally');++ // Two sharded landings at once on a machine with only two slots and no runner: each parent holds+ // one slot and runs its own shards on it, so neither waits forever on the other's.+ const pair = fixture({ runner: false, repoNames: ['first', 'second'] });+ t.after(() => rmSync(pair.dir, { recursive: true, force: true }));+ scenario(pair, 'green');+ const both = await Promise.all(pair.repos.map((repo, index) => landingGate(pair, `concurrent landing ${index + 1}`, 120_000, repo)));+ for (const landing of both) {+ assert.equal(landing.isGreen, true, landing.output);+ assert.equal(Object.keys(mergedFiles(landing.output)).length, 6);+ }+});