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(core): match landing hosts and hold test defects [E27,E28,E29]
Corey Olsonadc26d15902c
diff --git a/docs/formats.md b/docs/formats.mdindex 5cbad3e0..fe910ea1 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -113,7 +113,7 @@ The board file is in the repository's Git common directory at `.git/pullboard/bo| `row grammar` | `1` | `SPEC_GRAMMAR_VERSION` in `src/spec.js`; optional `<!-- pullboard-grammar N -->` line in either file (absence means the current grammar) | Both files share the version. A declared version must match; an incompatible grammar change requires a coordinated version bump and compatible files. No automatic conversion occurs. || `board schema` | `2` | `SCHEMA_VERSION` in `src/board.js`, persisted as `PRAGMA user_version` | Create missing tables and indexes, add missing columns in place with declared defaults, restore missing or changed triggers, and remove stale machine triggers without replacing rows. || `event log` | `1` | `EVENT_LOG_VERSION` in `src/board.js`, persisted in `board_meta` as `event_log_version` | Older event-log versions upgrade in place; newer versions are refused with `EVENT_LOG_VERSION`. Preserve event rows when the board schema changes. |-| `move engine` | `73` | `ENGINE_VERSION` in `src/machine.js`, carried as `engine` in every sealed executable move | Bump when a move's meaning changes, independently of the event log and sealed envelope. A newer engine is refused with `ENGINE_VERSION`, naming both versions and asking you to upgrade Pullboard. |+| `move engine` | `79` | `ENGINE_VERSION` in `src/machine.js`, carried as `engine` in every sealed executable move | Bump when a move's meaning changes, independently of the event log and sealed envelope. A newer engine is refused with `ENGINE_VERSION`, naming both versions and asking you to upgrade Pullboard. |<!-- format-versions:end -->Relay transport capability `apiVersion: 2` is independent of these versions and@@ -196,6 +196,12 @@ Engine 72 (`COORDINATOR_HOLD_ENGINE`) holds a linked board's coordinator at oneEngine 73 (`PEOPLE_ENGINE`) names people and lets approvers alone act as the person. The relay stamps each stored record's sender with the GitHub login behind it, the engine the sender declared and, on a board that names approvers, `approver: true|false` for a person sender. Replaying a move made at engine 73 or later, every event it writes carries `person`, that login, beside `event_by`, the agent or seat. A move that carries out a recorded phone request carries the request sender's login instead, and a `relay_refused` event carries the login of the person who tried the move or request. `pullboard.json` may list `approvers`, GitHub logins, at most fifty; leaving it out keeps today's behaviour. On a board that names them, every replica refuses with `NOT_APPROVER` a person move (a row or sentinel decision, an answer, hold or fact as the person, a person request shout) or a phone request to answer, hold or decide rows whose sender is not an approver, and the relay refuses an unlink or snapshot replacement from anyone else. A record whose seal no key opens, from an engine no newer than the replica's, is set aside as `relay_refused` with code `RELAY_SEAL`, and replay goes on; one from a newer engine still asks for an upgrade.+Engine 79 (`LANDING_ENVIRONMENT_ENGINE`) records the actual executor's exact `{platform, arch, node}` on new machine-run verdicts and gate receipts. An explicit `null` means unknown; historical receipts without the field keep their original canonical bytes and replay semantics. Landing batches retain their executor and flag accepted verdicts from a different or unknown environment. Earlier engines refuse moves carrying these fields before applying them.++An optional `landing.environment` in `pullboard.json` requires all three exact fields. The matching machine must also opt into this board with `pullboard settings landing.pool on`; `off` removes its opt-in. Machine settings store the board IDs in `landing.pools`. A constrained landing runs on that matching, opted-in coordinator host; generic SSH runners are not members of a board's landing pool. Omitting the policy retains normal runner selection. A mismatch is refused before creating or gating a batch.++Engine 79 also adds `recordLandingTestDefect`. A red batch whose bisection finds no item culprit records a neutral repair item and a `landing-test-defect` event with its test path, content hash, red-tree blob, original trunk blob, failure names, batch ID and trunk branch. Its batch remains `test-defect`, and further landings on that trunk stop before another gate runs. A committed correction to the test on the trunk, or live existing waivers covering every recorded failure, releases the hold. Candidate-only changes and uncommitted edits do not release it. A waiver keeps the red tree and its waived failures explicit. Existing culprit and flake diagnosis retain their meanings; older engines cannot revise or finish a batch carrying these fields.+The CLI declares its engine in every relay request's `X-Pullboard-Engine` header.A linked board requires at least engine 48 after issuing any agent token or machine credential, includingrevoked or expired ones; before engine 48 these minimums were 3 and 6. The minimum survives reopening the auth database;diff --git a/src/board.js b/src/board.jsindex e6582620..cfe9f0b4 100644--- a/src/board.js+++ b/src/board.js@@ -13,6 +13,7 @@ import {checkedLandingCommit,} from './verdict-reviews.js';export { verdictReviewProblem, verdictsFor, acceptedVerdict, checkedLandingCommit };+export { landingTestDefects, recordLandingTestDefect } from './landing-test-defects.js';import {randomBytes,randomUUID,@@ -61,6 +62,8 @@ import {} from './machine.js';import { LOCAL_LANDING_ENGINE } from './land-engine.js';import { SPEC_APPROVAL_ENGINE } from './spec-approval-engine.js';+import { LANDING_ENVIRONMENT_ENGINE } from './landing-environment-engine.js';+import { carriesLandingEnvironment, environmentProblem } from './execution-environment.js';import { Refused } from './refused.js';import { refuseMaskedExit } from './check-mask.js';import {@@ -1570,12 +1573,14 @@ function reserveWithin(board, id, { agentId, leaseMs, policy, familyPolicy = 'of* @param {{ agentId: string, decision: string, reason?: string, note?: string, cause?: string, head: string, digest: string, policy: string, familyPolicy?: string, check?: 'none' | 'green', review?: {commit: string, head?: string, trunk: string, paths: string[]}, implies?: number[], impliesId?: string }} verdict - implies: items this verdict changes (B29)* @returns {{ decision: string, reason: string, check?: 'none' | 'green' }}*/-export function verify(board, id, { agentId, decision, reason, note = '', cause, head, digest, policy, familyPolicy = 'off', check, review, implies, impliesId, reopenFirstRefusalMinutes }) {+export function verify(board, id, { agentId, decision, reason, note = '', cause, head, digest, policy, familyPolicy = 'off', check, review, implies, impliesId, reopenFirstRefusalMinutes, environment }) {const verb = { ACCEPT: 'accept', REJECT: 'reject' }[decision];if (!verb) throw new Refused('BAD_DECISION', 'the decision is accept or reject');const isAccept = verb === 'accept';const code = isAccept ? ACCEPT_REASON : reason;const engine = board.executionEngineVersion ?? ENGINE_VERSION;+ if (environment !== undefined && engine < LANDING_ENVIRONMENT_ENGINE) throw new Refused('ENGINE_VERSION', `verdict environments require engine ${LANDING_ENVIRONMENT_ENGINE}`);+ if (environment !== undefined && environment !== null && environmentProblem(environment)) throw new Refused('VERDICT_ENVIRONMENT', 'a verdict environment needs exact platform, arch and Node version');const declaration = MOVES.find(move => move.verb === verb);const newReview = engine >= VERDICT_REVIEW_ENGINE && review !== undefined;// Without the new sealed metadata, old moves keep their exact submitted-only semantics.@@ -1627,6 +1632,7 @@ export function verify(board, id, { agentId, decision, reason, note = '', cause,const detail = { ...reservation, reason: code, commit: item.item_commit, ...(!isAccept && cause !== undefined && cause !== null ? { cause } : {}) };if (isAccept && engine >= SPEC_APPROVAL_ENGINE) detail.note = note.trim();if (isAccept && check !== undefined) detail.check = check;+ if (environment !== undefined) detail.environment = environment;if (newReview) detail.review = { commit: review.commit, ...(Object.hasOwn(review, 'head') ? { head: review.head } : {}), trunk: review.trunk, paths: [...review.paths] };logEvent(board, agentId, verb, id, implies?.length ? { ...detail, implies } : detail, returnedAt);const trigger = board.lastEvent;@@ -2672,6 +2678,11 @@ export { landingBatches };/** Append one coordinator-owned batch revision without changing the board schema [B3,R3]. */export function recordLandingBatch(board, { agentId, batch, revision = 0 }) {coordinatorOnly(agentId, 'records landing batches');+ if (carriesLandingEnvironment(batch) && (board.executionEngineVersion ?? ENGINE_VERSION) < LANDING_ENVIRONMENT_ENGINE) throw new Refused('ENGINE_VERSION', `landing environments and test defects require engine ${LANDING_ENVIRONMENT_ENGINE}`);+ if (batch?.environmentWarnings !== undefined && !Array.isArray(batch.environmentWarnings)) throw new Refused('LAND_BATCH', 'landing environment warnings are a list');+ const environments = [batch?.environment, ...(Array.isArray(batch?.gateResults) ? batch.gateResults : []).map(gate => gate?.environment),+ ...(batch?.environmentWarnings ?? []).flatMap(warning => [warning?.recorded, warning?.landing])];+ if (environments.some(environment => environment !== undefined && environment !== null && environmentProblem(environment))) throw new Refused('LAND_BATCH', 'a landing executor needs exact platform, arch and Node version');if (carriesFlakeDiagnostics(batch) && (board.executionEngineVersion ?? ENGINE_VERSION) < NATIVE_FLAKE_ENGINE) {throw new Refused('ENGINE_VERSION', `typed landing diagnostics require engine ${NATIVE_FLAKE_ENGINE}; upgrade Pullboard`);}@@ -2684,6 +2695,8 @@ export function recordLandingBatch(board, { agentId, batch, revision = 0 }) {}return atomic(board, () => {const previous = landingBatches(board).find((entry) => entry.id === batch.id);+ if (carriesLandingEnvironment(previous) && (board.executionEngineVersion ?? ENGINE_VERSION) < LANDING_ENVIRONMENT_ENGINE) throw new Refused('ENGINE_VERSION', `this batch requires engine ${LANDING_ENVIRONMENT_ENGINE}`);+ if (previous && ['environment', 'testDefects'].some(key => Object.hasOwn(previous, key) && !Object.hasOwn(batch, key))) throw new Refused('LAND_BATCH', 'a landing revision keeps its recorded executor and test defects');preserveInvariantEvidence(previous, evidence, board.executionEngineVersion ?? ENGINE_VERSION);validateLandingRevision(previous, batch, revision);const recorded = { ...batch, revision: revision + 1, updatedAt: now(board) };@@ -2760,6 +2773,7 @@ export function finishLandingBatch(board, { agentId, id, tip }) {return atomic(board, () => {const batch = landingBatches(board).find((entry) => entry.id === id);if (!batch || batch.tip !== tip) throw new Refused('LAND_BATCH', 'the pushed tip must match its recorded batch; run pullboard land --adopt');+ if (carriesLandingEnvironment(batch) && (board.executionEngineVersion ?? ENGINE_VERSION) < LANDING_ENVIRONMENT_ENGINE) throw new Refused('ENGINE_VERSION', `this batch requires engine ${LANDING_ENVIRONMENT_ENGINE}`);if (batch.state === 'landed') return batch;if (batch.state !== 'pushed' && !(batch.state === 'trunk' && (board.executionEngineVersion ?? ENGINE_VERSION) >= LOCAL_LANDING_ENGINE)) throw new Refused('LAND_NOT_PUSHED', 'record a successful push before landing receipts; run pullboard land --adopt');for (const entry of batch.items) {diff --git a/src/commands/settings.js b/src/commands/settings.jsindex 89ed41b6..b7d18e8f 100644--- a/src/commands/settings.js+++ b/src/commands/settings.js@@ -14,10 +14,22 @@ import {setBrowserSlots,setGateShortSlots,setGateSlots,+ setLandingPool,} from '../settings.js';+import { context, withBoard } from '../cli.js';+import { boardId } from '../board.js';/** Read or update machine-wide gate capacity. */export function settingsCommand(io, { first, second, rest }) {+ if (first === 'landing.pool') {+ if (!['on', 'off'].includes(second) || rest.length) throw new Refused('USAGE', 'pullboard settings landing.pool on|off in the board this machine should land');+ const ctx = context(io);+ const board = withBoard(ctx, boardId);+ const settings = setLandingPool(board, second === 'on');+ io.result?.({ settings, board });+ io.say(`this board's landing pool: ${second}`);+ return 0;+ }if (!first && !second && !rest.length) {const settings = loadMachineSettings();const queue = gateQueueSettings();diff --git a/src/commands/verify.js b/src/commands/verify.jsindex 177a5faa..5e1810c6 100644--- a/src/commands/verify.js+++ b/src/commands/verify.js@@ -195,6 +195,7 @@ export async function verifyHere(ctx, id, { second, values }) {policy: ctx.config.verify.policy,familyPolicy: ctx.config.verify.family,review,+ environment: check?.environment ?? null,...(decision === 'ACCEPT' ? { check: check.checked ? 'green' : 'none' } : {}),...(implies ? { implies } : {}),}]);diff --git a/src/config.js b/src/config.jsindex 44febc63..1355b9c8 100644--- a/src/config.js+++ b/src/config.js@@ -8,6 +8,7 @@ import {} from 'node:fs';import { join } from 'node:path';import { Refused } from './refused.js';+import { environmentProblem } from './execution-environment.js';export const CONFIG_FILE = 'pullboard.json';export const COORDINATOR = 'coordinator';@@ -203,8 +204,11 @@ export function configProblems(config) {problems.push('"landingShards" is a whole number from 1 to 64: how many shards the landing gate splits its test files into');}if (typeof config.staticChecks !== 'string') problems.push('"staticChecks" is an optional project static-check command');- if (config.landing !== undefined && (typeof config.landing !== 'object' || config.landing === null || Object.keys(config.landing).some(key => key !== 'publish') || ![undefined, 'separate'].includes(config.landing.publish))) {- problems.push('"landing" is optional; { "publish": "separate" } lands on the local trunk and pushes only through pullboard publish');+ if (config.landing !== undefined && (typeof config.landing !== 'object' || config.landing === null || Array.isArray(config.landing)+ || Object.keys(config.landing).some(key => !['publish', 'environment'].includes(key)) || ![undefined, 'separate'].includes(config.landing.publish))) {+ problems.push('"landing" has optional publish: "separate" and environment: { platform, arch, node }');+ } else if (config.landing?.environment !== undefined && environmentProblem(config.landing.environment)) {+ problems.push(`"landing.environment" ${environmentProblem(config.landing.environment)}`);}if (config.positiveControl !== undefined && (typeof config.positiveControl !== 'string' || !config.positiveControl.trim())) {problems.push('"positiveControl" is a nonempty command for a known-good case the gate must pass, like "node --test test/known-good.test.js"');diff --git a/src/engine.js b/src/engine.jsindex ed5129dd..69aaa9cf 100644--- a/src/engine.js+++ b/src/engine.js@@ -66,6 +66,8 @@ import { LOCAL_LANDING_ENGINE } from './land-engine.js';import { REVIEW_SKIP_ENGINE } from './review-skip-engine.js';import { COORDINATOR_HOLD_ENGINE } from './coordinator-hold-engine.js';import { requireCoordinatorHold } from './coordinator-hold.js';+import { LANDING_ENVIRONMENT_ENGINE } from './landing-environment-engine.js';+import { carriesLandingEnvironment } from './execution-environment.js';const ITEM_ID_FIRST_ARGUMENT = new Set(['acceptCheck', 'editItem', 'escalate', 'recordAttempt', 'claim', 'release', 'submit', 'reserveReview', 'verify', 'merged', 'withdraw', 'refreeze', 'reopen', 'appendFact']);@@ -76,7 +78,7 @@ export const ENGINE_OPERATIONS = Object.freeze(['withdraw', 'refreeze', 'reopen', 'shout', 'passDecision', 'answerDecision', 'holdLane', 'releaseLane', 'holdItem', 'releaseItemHold','addMilestone', 'editMilestoneItems', 'orderMilestoneItems', 'moveMilestone', 'editMilestone', 'removeMilestone', 'shipMilestone','recordRowDecisions', 'applyRowDecisions', 'draftSpecRow', 'appendFact', 'recordSpecApprovalBaseline',- 'recordLandingBatch', 'recordLandingWaiver', 'recordLandingFlake', 'finishLandingBatch', 'acceptCheck',+ 'recordLandingBatch', 'recordLandingWaiver', 'recordLandingFlake', 'recordLandingTestDefect', 'finishLandingBatch', 'acceptCheck','recordHealthFindings', 'proposeSentinel', 'decideSentinel', 'beginSentinelRun', 'finishSentinelRun','recordFlakeObservation', 'recordGateRun', 'declareJob', 'recordJobRun', 'takeCoordinator',]);@@ -87,6 +89,13 @@ const OPERATION_ENGINE = Object.freeze({ draftSpecRow: ROW_DRAFT_ENGINE, orderMi/** Dependency edits, causes, sealed reviews, submission proofs, trunk conflicts, health observations and milestone targets retain distinct recorded engine meanings. */function minimumOperationEngine(operation, args, board, at) {+ if (operation === 'recordLandingTestDefect' || operation === 'verify' && args[1]?.environment !== undefined+ || operation === 'recordGateRun' && Object.hasOwn(args[0]?.receipt ?? {}, 'environment')+ || operation === 'recordLandingBatch' && carriesLandingEnvironment(args[0]?.batch)) return LANDING_ENVIRONMENT_ENGINE;+ if (board && ['recordLandingBatch', 'finishLandingBatch'].includes(operation)) {+ const id = operation === 'recordLandingBatch' ? args[0]?.batch?.id : args[0]?.id;+ if (store.landingBatches(board).some(batch => batch.id === id && carriesLandingEnvironment(batch))) return LANDING_ENVIRONMENT_ENGINE;+ }if (['verify', 'reopen'].includes(operation) && args[1]?.reopenFirstRefusalMinutes !== undefined|| ['claim', 'release'].includes(operation) && board && firstRefusal(board, args[0], at)) return REOPEN_FIRST_REFUSAL_ENGINE;// A batch landed on the local trunk before it is published (#801).diff --git a/src/execution-environment.js b/src/execution-environment.jsnew file mode 100644index 00000000..a918bb99--- /dev/null+++ b/src/execution-environment.js@@ -0,0 +1,32 @@+/** Exact executor identity for gate receipts and landing policy [E27,E28]. */++/** Capture this process on the host that actually executes the command. */+export function executionEnvironment() {+ return { platform: process.platform, arch: process.arch, node: process.versions.node };+}++/** Validate bounded identity without substituting this host for an unknown old receipt. */+export function environmentProblem(value) {+ if (!value || typeof value !== 'object' || Array.isArray(value)+ || Object.keys(value).length !== 3 || !['platform', 'arch', 'node'].every(key => Object.hasOwn(value, key))) return 'needs platform, arch and node';+ if (!['platform', 'arch'].every(key => typeof value[key] === 'string' && /^[a-z0-9_]{1,32}$/u.test(value[key]))) return 'platform and arch are bounded system identifiers';+ if (typeof value.node !== 'string' || value.node.length > 80 || !/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u.test(value.node)) return 'node names one exact Node version';+ return '';+}++/** Require all three exact fields; unknown historical environments never match by inference. */+export function sameEnvironment(left, right) {+ return !environmentProblem(left) && !environmentProblem(right)+ && ['platform', 'arch', 'node'].every(key => left[key] === right[key]);+}++/** Name an executor when an old verdict differs from its landing host. */+export function environmentLabel(value) {+ return environmentProblem(value) ? 'an unknown environment' : `${value.platform}/${value.arch}, Node ${value.node}`;+}++/** Typed landing fields require the engine that understands their hold and executor semantics. */+export function carriesLandingEnvironment(batch) {+ return ['environment', 'environmentWarnings', 'testDefects'].some(key => Object.hasOwn(batch ?? {}, key))+ || batch?.state === 'test-defect' || Array.isArray(batch?.gateResults) && batch.gateResults.some(gate => Object.hasOwn(gate ?? {}, 'environment'));+}diff --git a/src/gate-run-receipt.js b/src/gate-run-receipt.jsindex 76dbbbf9..a0485d8e 100644--- a/src/gate-run-receipt.js+++ b/src/gate-run-receipt.js@@ -11,6 +11,7 @@ import {join,} from 'node:path';import { tryGit } from './git.js';+import { environmentProblem } from './execution-environment.js';/** The folder beside the board that holds gate run receipts. */export const RECEIPT_FOLDER = 'gate-receipts';@@ -63,6 +64,7 @@ export function receiptFields(value) {/** The checks behind receiptFields; each malformed field throws, and receiptFields turns that into null. */function checkedFields(value) {const bad = () => new TypeError('malformed gate receipt');+ if (Object.hasOwn(value ?? {}, 'environment') && value.environment !== null && environmentProblem(value.environment)) throw bad();if (!value || value.version !== 1 || !ID.test(value.id ?? '') || !['gate', 'land', 'submit'].includes(value.kind) || !SHA.test(value.tree ?? '')|| !SHA.test(value.head ?? '') || value.main !== null && !SHA.test(value.main ?? '') || !DIGEST.test(value.command ?? '')|| typeof value.green !== 'boolean' || !Array.isArray(value.failures) || value.failures.length > MOST_FAILURES@@ -76,7 +78,8 @@ function checkedFields(value) {if (!load || !Array.isArray(load.average) || load.average.length !== 3 || load.average.some((number) => !Number.isFinite(number) || number < 0)|| !Number.isSafeInteger(load.cpus) || load.cpus < 1 || !Number.isSafeInteger(load.freeMB) || load.freeMB < 0) throw bad();return { version: 1, id: value.id, kind: value.kind, tree: value.tree, head: value.head, main: value.main, command: value.command,- green: value.green, failures, load: { average: [...load.average], cpus: load.cpus, freeMB: load.freeMB }, at: value.at };+ green: value.green, failures, load: { average: [...load.average], cpus: load.cpus, freeMB: load.freeMB }, at: value.at,+ ...(Object.hasOwn(value, 'environment') ? { environment: value.environment } : {}) };}/**diff --git a/src/gate.js b/src/gate.jsindex 56d185b4..67e76436 100644--- a/src/gate.js+++ b/src/gate.js@@ -37,6 +37,8 @@ import {tmpdir,} from 'node:os';import { fileURLToPath } from 'node:url';+import { environmentProblem, executionEnvironment } from './execution-environment.js';+import { constrainedLandingHost } from './landing-host.js';import {gitChildEnv,gitPath,@@ -266,6 +268,7 @@ export function isStampedGreen(root) {*/export function runShell(root, command, { pipefail = false, env = {}, stages = false } = {}) {const started = Date.now();+ const environment = executionEnvironment();const options = { cwd: root, env: { ...gitChildEnv(root), ...env }, shell: true, stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8', maxBuffer: 2 ** 30 };let prefix = '';if (pipefail) {@@ -287,12 +290,12 @@ export function runShell(root, command, { pipefail = false, env = {}, stages = fconst raw = `${result.stdout ?? ''}${result.stderr ?? ''}`;const seconds = Math.round((Date.now() - started) / 1000);const blocked = (output) => (result.status === 0 ? null : sandboxBlockedOperation(root, output));- if (!stages) return { isGreen: result.status === 0, output: raw, seconds, sandboxBlocked: blocked(raw) };- if (!split) return { isGreen: result.status === 0, output: raw, seconds, stages: null, sandboxBlocked: blocked(raw) };+ if (!stages) return { isGreen: result.status === 0, output: raw, seconds, environment, sandboxBlocked: blocked(raw) };+ if (!split) return { isGreen: result.status === 0, output: raw, seconds, environment, stages: null, sandboxBlocked: blocked(raw) };const staged = readStages(raw, marker, split.length);// Each pipeline component's own status rides on its stage, so no failing producer hides behind a later one.const withPipes = staged.stages.map((stage, index) => (pipeStatuses?.[index] ? { ...stage, pipeline: pipeStatuses[index] } : stage));- return { isGreen: result.status === 0, seconds, ...staged, stages: withPipes, sandboxBlocked: blocked(staged.output) };+ return { isGreen: result.status === 0, seconds, environment, ...staged, stages: withPipes, sandboxBlocked: blocked(staged.output) };}/** Refuse an environment-blocked proof after its ordinary raw logs and timings are persisted. */@@ -333,6 +336,7 @@ export function runProfiledShell(root, command, { waitMs = 0, artifactDirectory,browser: gateLease.browser, pipefail, stages, waivers: landing ? waivers : [], metadata: { ...(gateLease.runMetadata ?? {}), landing } }) }: runShell(root, command, { pipefail, env: inherited, stages });gateLease?.tracker?.mark('ranAt');+ if (gateLease) gateLease.environment = run.environment ?? null;const sandboxBlocked = run.isGreen ? null : run.sandboxBlocked ?? (run.executionRunner// The controller cannot realpath remote files; retain the network denial signal without treating remote paths as local paths.? sandboxBlockedOperation(root, run.output, { includeFilePaths: false })@@ -358,6 +362,7 @@ export async function runProfiledShellAsync(root, command, { waitMs = 0, gateSloif (gateLease?.runner) {const run = await runOnRunnerAsync(root, command, { runner: gateLease.runner, source: gateLease.source,browser: gateLease.browser, metadata: { ...(gateLease.runMetadata ?? {}), landing } });+ gateLease.environment = run.environment ?? null;gateLease.tracker?.mark('ranAt');const wallMs = Math.max(0, Date.now() - started);const profilePath = join(dirname(gitPath(root, LOG)), `pullboard-gate-${randomUUID()}.profile.json`);@@ -371,6 +376,7 @@ export async function runProfiledShellAsync(root, command, { waitMs = 0, gateSlo[LANDING_RUN_ENV]: landing ? '1' : '0',};const env = { ...gitChildEnv(root), ...inherited };+ const environment = executionEnvironment();const child = spawn(`(\n${command}\n) 2>&1`, { cwd: root, env, shell: true, stdio: ['ignore', 'pipe', 'pipe'] });const chunks = [];let bytes = 0;@@ -387,6 +393,7 @@ export async function runProfiledShellAsync(root, command, { waitMs = 0, gateSlochild.once('error', error => { failure = error; });const status = await new Promise(resolveClose => child.once('close', resolveClose));gateLease?.tracker?.mark('ranAt');+ if (gateLease) gateLease.environment = environment;invalidateGitFacts();const output = chunks.join('') + (overflow ? '\nFocused comparison output exceeded one GiB.\n' : '')+ (failure ? `\n${failure.message}\n` : '');@@ -394,13 +401,13 @@ export async function runProfiledShellAsync(root, command, { waitMs = 0, gateSloconst profilePath = join(dirname(gitPath(root, LOG)), `pullboard-gate-${randomUUID()}.profile.json`);const profile = writeTimingProfile(profilePath, { ...timingFromOutput(output, timingRunner(command)),waitMs: Math.max(0, Math.round(waitMs)), wallMs, receipt: settleReceipt(gateLease) });- return { isGreen: status === 0 && !overflow && !failure, sandboxBlocked: status === 0 ? null : sandboxBlockedOperation(root, output), output, seconds: Math.round(wallMs / 1000), profile, profilePath, logPath: null };+ return { isGreen: status === 0 && !overflow && !failure, environment, sandboxBlocked: status === 0 ? null : sandboxBlockedOperation(root, output), output, seconds: Math.round(wallMs / 1000), profile, profilePath, logPath: null };}/** Close a gated run's receipt (#836) as its evidence is written; the slot's release records this same receipt. */function settleReceipt(lease) {if (!lease?.tracker) return undefined;- lease.receipt = receiptOf(lease.tracker, { kind: lease.receiptKind, slot: lease.slot });+ lease.receipt = { ...receiptOf(lease.tracker, { kind: lease.receiptKind, slot: lease.slot }), environment: lease.environment ?? null };return lease.receipt;}@@ -457,6 +464,7 @@ export function writeTimingProfile(path, profile) {runner: sanitize(profile.runner ?? 'shell', 'runner'),format: sanitize(profile.format ?? 'none', 'format'),unavailable: sanitize(profile.unavailable ?? null, 'availability'),+ ...(Object.hasOwn(profile, 'environment') ? { environment: environmentProblem(profile.environment) ? null : profile.environment } : {}),...(profile.executionRunner ? { executionRunner: sanitize(profile.executionRunner, 'execution runner') } : {}),...(profile.receipt ? { receipt: { ...profile.receipt, slot: { kind: sanitize(profile.receipt.slot?.kind, 'slot kind'), reason: sanitize(profile.receipt.slot?.reason, 'slot reason') } } } : {}),...(profile.landingShards ? { landingShards: {@@ -525,6 +533,8 @@ export async function withGateSlot(root, action, options = {}) {/** One gate admission and its action; withGateSlot may call it again for a local rerun. */async function withOneGateSlot(root, action, { landing = false, itemCheck = false, shortEligible = false, diagnostic = false, browser = false, remote = true, agent, item = '', kind = '', onWait, onReceipt, readMemory = readMachineMemory } = {}) {+ // Generic SSH capacity has no board-owned landing membership; a constrained landing stays on its checked host.+ if (landing && constrainedLandingHost(root)) remote = false;const tracker = startReceipt();const receiptKind = kind || (landing ? 'landing' : 'gate');/** Hand the run its receipt tracker and slot, then record its receipt once the slot is released (#836). */@@ -655,7 +665,7 @@ function leaveRunReceipt(root, config, run, { before, kind }) {}const local = { average: loadavg(), cpus: availableParallelism(), freeMB: Math.floor(freemem() / 1048576) };const receipt = receiptFields({ version: 1, id: randomUUID(), kind, tree: before, head, main: policy.commit, command: createHash('sha256').update(config.gate).digest('hex'),- green: run.isGreen, failures: [...failures.values()], load: Array.isArray(run.executionLoad?.average) ? run.executionLoad : local, at: new Date().toISOString() });+ green: run.isGreen, failures: [...failures.values()], load: Array.isArray(run.executionLoad?.average) ? run.executionLoad : local, at: new Date().toISOString(), environment: run.environment ?? null });if (!receipt) return null;mkdirSync(store, { recursive: true, mode: 0o700 });writeFileSync(join(store, `${receipt.id}.json`), receiptBody(receipt), { flag: 'wx', mode: 0o600 });@@ -675,7 +685,7 @@ function fullGateRun(root, config, trustStamp = false, { waitMs = 0, log = gitPaconst receiptId = run.sandboxBlocked ? null : leaveRunReceipt(root, config, run, { before, kind });refuseSandboxBlocked(run);if (isGreen && before !== null && committedTree(root) === before) writeFileSync(gitPath(root, STAMP), `${before}\n`);- return { isGreen, isCached: false, output, seconds, log, profile, profilePath, receiptId, ...(run.executionRoot ? { executionRoot: run.executionRoot } : {}),+ return { isGreen, isCached: false, output, seconds, log, profile, profilePath, receiptId, environment: run.environment ?? null, ...(run.executionRoot ? { executionRoot: run.executionRoot } : {}),// A remote run's host load and pinned main reach the flake diagnostics with it (#925)....(run.executionRunner ? { executionRunner: run.executionRunner, executionMain: run.executionMain ?? null, executionLoad: run.executionLoad ?? null } : {}), ...(stages ? { stages: run.stages } : {}) };}@@ -694,12 +704,13 @@ function fullGateRun(root, config, trustStamp = false, { waitMs = 0, log = gitPa*/function gateRunRecord(root, config, isGreen, gateLease) {const at = new Date().toISOString();+ const environment = gateLease?.environment ?? null;const positiveControl = config.positiveControl?.trim() ? config.positiveControl : null;- if (!positiveControl) return { at, green: isGreen, control: null, gate: config.gate, positiveControl };+ if (!positiveControl) return { at, green: isGreen, control: null, gate: config.gate, positiveControl, environment };const control = runProfiledShell(root, positiveControl, { gateLease, artifactPrefix: 'pullboard-gate-control', persistLog: true });// A control the environment refused says nothing about the gate, the same rule that keeps a refused gate run out of the record.const result = control.sandboxBlocked ? null : control.isGreen;- return { at, green: isGreen, control: result, gate: config.gate, positiveControl, controlLog: control.logPath, controlProfile: control.profilePath };+ return { at, green: isGreen, control: result, gate: config.gate, positiveControl, environment, controlLog: control.logPath, controlProfile: control.profilePath };}/** Quote a fixed executable or selected path without permitting shell expansion. */diff --git a/src/help.js b/src/help.jsindex 629142c7..f390de57 100644--- a/src/help.js+++ b/src/help.js@@ -427,12 +427,13 @@ function overviewHelp(groups, firstRun = false) {}/** The settings forms settingsCommand dispatches with a value; each gets its own help, from this list (N2). */-export const SETTING_FORMS = Object.freeze(['gateSlots', 'browserSlots', 'gate.shortSlots']);+export const SETTING_FORMS = Object.freeze(['gateSlots', 'browserSlots', 'gate.shortSlots', 'landing.pool']);/** Help for each settings form the printed usage did not already name, so each form is covered (N2). */function settingFormHelp(commands) {return Object.fromEntries(SETTING_FORMS.filter((form) => !commands[`settings ${form}`]).map((form) => [`settings ${form}`, Object.freeze({- usages: [`pullboard settings ${form} <n>`], flags: [], example: `pullboard settings ${form} 2`, notes: [],+ usages: [`pullboard settings ${form} ${form === 'landing.pool' ? 'on|off' : '<n>'}`], flags: [],+ example: `pullboard settings ${form} ${form === 'landing.pool' ? 'on' : '2'}`, notes: [],})]));}diff --git a/src/land.js b/src/land.jsindex fb0b199e..1e7484f6 100644--- a/src/land.js+++ b/src/land.js@@ -42,6 +42,8 @@ import {import { testsNeedBrowser } from './browser-admission.js';import { laneOf } from './lanes.js';import { Refused } from './refused.js';+import { requireLandingHost } from './landing-host.js';+import { environmentLabel, sameEnvironment } from './execution-environment.js';import { browserFreeChecksEnabled } from './settings.js';import { landingFileTimes } from './submit-invariants.js';import {@@ -62,6 +64,30 @@ function testHash(root, file) {catch { return null; }}+/** Read a committed test identity; an uncommitted edit cannot release a trunk hold. */+function testBlob(root, commit, file) {+ const result = tryGit(root, ['rev-parse', '--verify', `${commit}:${file}`]);+ return result.status === 0 ? result.stdout : null;+}++/** A test defect holds every batch on its trunk until the committed test changes or every failure is waived. */+function heldTestDefects(root, board, trunk) {+ return store.landingTestDefects(board).filter(defect => {+ if (defect.branch !== trunk.branch) return false;+ const blob = testBlob(root, trunk.commit, defect.test);+ return !(blob && blob !== defect.trunkBlob) && !defect.names.every(name => store.landingWaiverFor(board, { file: defect.test, name }));+ });+}++/** Keep each verdict's recorded executor distinct from the actual landing host. */+function environmentWarnings(board, items, environment) {+ return items.flatMap(entry => {+ const verdict = store.acceptedVerdict(board, store.getItem(board, entry.id));+ const recorded = verdict?.environment ?? null;+ return sameEnvironment(recorded, environment) ? [] : [{ item: entry.id, recorded, landing: environment }];+ });+}+/** Derive failing test identities from TAP or spec reporter names and source locations, refusing unknown paths. */export function landingFailures(output, root, { excludeCancelled = false } = {}) {const failures = [];@@ -306,9 +332,11 @@ async function gateGroup(state, label) {submissions: state.batch.items.map(({ id, commit }) => ({ id, commit })),failures: [...new Set(landingFailures(gate.output, state.batch.root, { excludeCancelled: true }).map(failure => failure.file).filter(Boolean))],fileTimes: landingFileTimes(state.batch.root, gate.profile) };- await save(state, { gateResults: [...state.gates.values()].map(({ tree: testedTree, isGreen, failures, accounted, complete, requiresGreen, logPath: log, flakeDiagnostics }) =>+ const warnings = gate.environment ? environmentWarnings(state.board, state.batch.items, gate.environment) : [];+ for (const warning of warnings) state.say(`#${warning.item} was checked on ${environmentLabel(warning.recorded)}; this landing ran on ${environmentLabel(warning.landing)}`);+ await save(state, { environmentWarnings: warnings, gateResults: [...state.gates.values()].map(({ tree: testedTree, isGreen, failures, accounted, complete, requiresGreen, logPath: log, flakeDiagnostics, environment: executor }) =>({ tree: testedTree, isGreen, failures, accounted: accounted ?? null, complete: complete ?? null, requiresGreen: Boolean(requiresGreen), logPath: log,- ...(flakeDiagnostics ? { flakeDiagnostics } : {}) })),+ environment: executor ?? null, ...(flakeDiagnostics ? { flakeDiagnostics } : {}) })),invariantEvidence: { ...evidence, gates: [...evidence.gates, tested] } });return result;}@@ -539,6 +567,24 @@ async function fileFlakes(state, gate, files) {state.say(`flake: ${files.join(', ')}; nothing landed; fix the test or ask the person for an expiring waiver`);}+/** File a neutral test defect for the exact no-culprit red and leave its proof available for a waiver. */+async function fileTestDefects(state, gate) {+ const defects = [];+ const files = [...new Set(gate.failures.map(failure => failure.file).filter(Boolean))];+ if (!files.length) throw new Refused('LAND_DIAGNOSTIC', 'the no-culprit gate did not identify a failing test file');+ for (const file of files) {+ const owner = laneOf(state.config, file);+ const lane = owner === 'coordinator' ? store.getItem(state.board, state.batch.items[0].id).item_lane : owner;+ defects.push(await state.write('recordLandingTestDefect', [{ agentId: 'coordinator', test: file,+ hash: testHash(state.batch.root, file), blob: testBlob(state.batch.root, state.batch.tip, file),+ trunkBlob: testBlob(state.root, state.batch.base, file),+ names: gate.failures.filter(failure => failure.file === file).map(failure => failure.name),+ lane, batchId: state.batch.id, branch: state.batch.branch }]));+ }+ await save(state, { state: 'test-defect', failures: gate.failures, testDefects: defects });+ state.say(`the trunk is held by a test defect: ${files.join(', ')}; correct the test or ask an approver for an expiring waiver`);+}+/** Name the remote a landing pushes the trunk to: the trunk branch's own remote, else origin [B3]. */function landingRemoteName(root, branch) {return tryGit(root, ['config', '--get', `branch.${branch.replace(/^refs\/heads\//u, '')}.remote`]).stdout || 'origin';@@ -709,6 +755,7 @@ async function finishTrunk(state) {/** Build, gate, diagnose and durably land one coordinator batch; all external actions stay in its worktree. */export async function land({ root, board, config, write, say, owner, maximum = Infinity, dryRun = false, adopt = false, onWait }) {+ const environment = dryRun ? null : requireLandingHost(store.boardId(board), config);// Quarantine is read from the accepted main policy this landing runs under, never from a branch.board.quarantineEnabled = () => config.flakes?.quarantine === true;let trunk = mainCheckout(root);@@ -718,6 +765,8 @@ export async function land({ root, board, config, write, say, owner, maximum = Itrunk = mainCheckout(root);}if (!trunk?.commit) throw new Refused('LAND_TRUNK', 'landing needs the coordinator’s primary branch; return its checkout to the trunk');+ const testDefects = heldTestDefects(root, board, trunk);+ if (!dryRun && testDefects.length) throw new Refused('LAND_TEST_DEFECT', `this trunk is held by ${testDefects.map(defect => `#${defect.item} (${defect.test})`).join(', ')}; correct the committed test or ask an approver for an expiring waiver`);const unfinished = store.landingBatches(board).findLast((batch) => batch.state !== 'landed' && batch.state !== 'blocked');const selected = candidates(board, root, trunk.commit, maximum);const stale = selected.blocked.find(item => item.code === 'STALE_VERDICT');@@ -735,7 +784,7 @@ export async function land({ root, board, config, write, say, owner, maximum = I}return { batch: null, landed: [], conflicts, blocked: selected.blocked, culprits: [], flakes: [], items: selected.ready.map((item) => item.item_id) };}- if (unfinished && !adopt && unfinished.state !== 'flaky') throw new Refused('LAND_ADOPT', `batch ${unfinished.id} is ${unfinished.state}; inspect pullboard resume, then run pullboard land --adopt`);+ if (unfinished && !adopt && !['flaky', 'test-defect'].includes(unfinished.state)) throw new Refused('LAND_ADOPT', `batch ${unfinished.id} is ${unfinished.state}; inspect pullboard resume, then run pullboard land --adopt`);if (adopt && !unfinished) throw new Refused('LAND_ADOPT', 'there is no interrupted landing batch; run pullboard land');let batch = unfinished;if (batch?.state === 'flaky') {@@ -759,6 +808,7 @@ export async function land({ root, board, config, write, say, owner, maximum = Iconst id = randomUUID();const directory = join(repoInfo(root).commonDir, 'pullboard', 'landings', id);batch = { version: 1, id, base: trunk.commit, tip: trunk.commit, branch: trunk.branch, root: join(directory, 'worktree'),+ ...(environment ? { environment } : {}),candidates: selected.ready.map(landingEntry),items: selected.ready.map(landingEntry), conflicts: [], blocked: selected.blocked,state: 'merging', owner, logPath: join(directory, 'logs', 'batch.log'), revision: 0 };@@ -800,8 +850,11 @@ export async function land({ root, board, config, write, say, owner, maximum = Igate = await gateGroup(state, 'green-items');proof = gate.isGreen ? null : waivedProof(state, gate);if (!gate.isGreen && !proof) {- await save(state, { state: 'blocked', failures: gate.failures, culprits: state.culprits });- throw new Refused('LAND_INTERACTION', 'the individually green items fail together; nothing retries or lands; inspect the batch’s failing tests');+ if (!state.culprits.length) { await fileTestDefects(state, gate); state.flaky = true; }+ else {+ await save(state, { state: 'blocked', failures: gate.failures, culprits: state.culprits });+ throw new Refused('LAND_INTERACTION', 'the individually green items fail together; nothing retries or lands; inspect the batch’s failing tests');+ }}}} else if (!state.flaky) await save(state, { state: 'blocked', culprits: state.culprits });diff --git a/src/landing-environment-engine.js b/src/landing-environment-engine.jsnew file mode 100644index 00000000..bc15a4c1--- /dev/null+++ b/src/landing-environment-engine.js@@ -0,0 +1,2 @@+/** Executor environments and no-culprit landing defects [E27,E28,E29]. */+export const LANDING_ENVIRONMENT_ENGINE = 79;diff --git a/src/landing-host.js b/src/landing-host.jsnew file mode 100644index 00000000..e9a8bf28--- /dev/null+++ b/src/landing-host.js@@ -0,0 +1,27 @@+/** A constrained landing runs only on an opted-in host whose actual environment matches [E27,E28]. */+import { DatabaseSync } from 'node:sqlite';+import { join } from 'node:path';+import { repoInfo } from './git.js';+import { mainPolicy } from './trusted-policy.js';+import { loadMachineSettings } from './settings.js';+import { environmentLabel, executionEnvironment, sameEnvironment } from './execution-environment.js';+import { Refused } from './refused.js';++/** Check one machine's own choice; a board policy never opts another machine in. */+export function requireLandingHost(board, config) {+ const required = config.landing?.environment;+ if (!required) return null;+ const actual = executionEnvironment();+ if (!sameEnvironment(required, actual)) throw new Refused('LAND_ENVIRONMENT', `this host is ${environmentLabel(actual)}; this board lands on ${environmentLabel(required)}; run land on a matching machine`);+ if (!(loadMachineSettings().landing?.pools ?? []).includes(board)) throw new Refused('LAND_HOST_NOT_JOINED', 'this machine has not joined this board’s landing pool; run pullboard settings landing.pool on here');+ return actual;+}++/** Read the immutable policy before admission; never open the board inside a queue transaction. */+export function constrainedLandingHost(root) {+ const config = mainPolicy(root).config;+ if (!config.landing?.environment) return null;+ const database = new DatabaseSync(join(repoInfo(root).commonDir, 'pullboard', 'board.sqlite'), { readOnly: true });+ try { return requireLandingHost(database.prepare("SELECT meta_value FROM board_meta WHERE meta_key = 'board_id'").get()?.meta_value, config); }+ finally { database.close(); }+}diff --git a/src/landing-test-defects.js b/src/landing-test-defects.jsnew file mode 100644index 00000000..26c205fe--- /dev/null+++ b/src/landing-test-defects.js@@ -0,0 +1,38 @@+/** Durable test defects hold a trunk when bisection identifies no item culprit [E29]. */+import { addItem, atomic, logEvent } from './board.js';+import { COORDINATOR } from './config.js';+import { ENGINE_VERSION } from './machine.js';+import { LANDING_ENVIRONMENT_ENGINE } from './landing-environment-engine.js';+import { Refused } from './refused.js';++/** Read the latest defect for each trunk and test, without rewriting its prior evidence. */+export function landingTestDefects(board) {+ const defects = new Map();+ for (const row of board.db.prepare("SELECT event_detail FROM event WHERE event_kind = 'landing-test-defect' ORDER BY event_id").all()) {+ const { defect } = JSON.parse(row.event_detail);+ defects.set(`${defect.branch}\0${defect.test}`, defect);+ }+ return [...defects.values()];+}++/** File a neutral repair item: an interaction is not proof that a named item or test is flaky. */+export function recordLandingTestDefect(board, { agentId, test, hash, blob, trunkBlob, names, lane, batchId, branch }) {+ if (agentId !== COORDINATOR) throw new Refused('COORDINATOR_ONLY', 'only the coordinator files a landing test defect');+ if ((board.executionEngineVersion ?? ENGINE_VERSION) < LANDING_ENVIRONMENT_ENGINE) throw new Refused('ENGINE_VERSION', `landing test defects require engine ${LANDING_ENVIRONMENT_ENGINE}`);+ if (typeof test !== 'string' || test.length > 4096 || /[\r\n\0]/u.test(test) || test.startsWith('/') || test.includes('\\') || test.split('/').some(part => !part || part === '.' || part === '..')+ || !/^[a-f0-9]{64}$/u.test(hash ?? '') || !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(blob ?? '')+ || trunkBlob !== null && !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(trunkBlob ?? '')+ || !Array.isArray(names) || !names.length || names.length > 500 || names.some(name => typeof name !== 'string' || !name || name.length > 8192 || /[\r\n\0]/u.test(name))+ || typeof batchId !== 'string' || !/^[a-f0-9-]{36}$/u.test(batchId) || typeof branch !== 'string' || !branch || branch.length > 1024 || /[\r\n\0]/u.test(branch)) {+ throw new Refused('LAND_TEST_DEFECT', 'a landing test defect needs its exact test, source identity, failures, batch and trunk');+ }+ return atomic(board, () => {+ const previous = landingTestDefects(board).find(defect => defect.branch === branch && defect.test === test && defect.hash === hash);+ if (previous?.batchId === batchId && names.every(name => previous.names.includes(name))) return previous;+ const item = previous?.item ?? addItem(board, { by: agentId, lane, title: `Landing test defect: ${test}`,+ criterion: `${test} passes with the combined accepted work; the landing failed without an item culprit: ${names.join('; ')}`, route: 'strong' });+ const defect = { test, hash, blob, trunkBlob, names: [...new Set([...(previous?.names ?? []), ...names])], item, batchId, branch };+ logEvent(board, agentId, 'landing-test-defect', item, { engine: LANDING_ENVIRONMENT_ENGINE, defect });+ return defect;+ });+}diff --git a/src/private-check-worker.js b/src/private-check-worker.jsindex bddbb006..7c32feeb 100644--- a/src/private-check-worker.js+++ b/src/private-check-worker.js@@ -1,5 +1,6 @@/** Collect private command output through pipes; dependency files are never size-limited [V18,V2]. */import { spawn } from 'node:child_process';+import { executionEnvironment } from './execution-environment.js';import {createWriteStream,readFileSync,@@ -62,7 +63,8 @@ child.once('close', (status, signal) => {sent = true;const marker = bytes > LIMIT ? '\n[output capped at 8 MiB; middle omitted]\n' : '';const output = head.toString('utf8') + marker + tail.toString('utf8');- process.stdout.write(JSON.stringify({ status, signal, error: timedOut ? { code: 'ETIMEDOUT' } : error, logError, output }));+ process.stdout.write(JSON.stringify({ status, signal, error: timedOut ? { code: 'ETIMEDOUT' } : error, logError, output,+ environment: executionEnvironment() }));};log.once('close', finish);if (log.closed) finish();diff --git a/src/quarantine.js b/src/quarantine.jsindex 0132bfd8..4381cb85 100644--- a/src/quarantine.js+++ b/src/quarantine.js@@ -13,6 +13,7 @@ import {logEvent,} from './board.js';import { GATE_RUN_ENGINE } from './gate-run-engine.js';+import { LANDING_ENVIRONMENT_ENGINE } from './landing-environment-engine.js';import {boardReceiptStore,receiptBinds,@@ -108,6 +109,7 @@ export function requireBound(board, receipt) {* @returns {{ run: object, duplicate?: boolean, quarantined: {file: string, name: string, item: number}[] }}*/export function recordGateRun(board, { agentId, receipt, lane }) {+ if (Object.hasOwn(receipt ?? {}, 'environment') && (board.executionEngineVersion ?? ENGINE_VERSION) < LANDING_ENVIRONMENT_ENGINE) throw new Refused('ENGINE_VERSION', `gate environments require engine ${LANDING_ENVIRONMENT_ENGINE}`);if ((board.executionEngineVersion ?? ENGINE_VERSION) < GATE_RUN_ENGINE) throw new Refused('ENGINE_VERSION', `gate runs require engine ${GATE_RUN_ENGINE}; upgrade Pullboard`);if (!listAgents(board).some(agent => agent.agent_id === agentId)) throw new Refused('NOT_JOINED', 'join this board before recording a gate run');const value = runReceipt(receipt);@@ -121,7 +123,7 @@ export function recordGateRun(board, { agentId, receipt, lane }) {if (JSON.stringify(stored) !== JSON.stringify(value)) throw new Refused('GATE_RUN_CHANGED', 'a run id already binds different evidence; keep the original and use a new id');return { run: stored, duplicate: true, quarantined: [] };}- logEvent(board, agentId, 'gate-run', null, { engine: GATE_RUN_ENGINE, run: value });+ logEvent(board, agentId, 'gate-run', null, { engine: Object.hasOwn(value, 'environment') ? LANDING_ENVIRONMENT_ENGINE : GATE_RUN_ENGINE, run: value });// Only the coordinator's runs prove a flake: its landing and main-checkout gates run accepted work, and no seat can// send a move as the coordinator. A seat's runs stay on the board as evidence of what it saw [C7,D1].const sameTree = gateRuns(board).filter(entry => entry.tree === value.tree && entry.by === COORDINATOR);diff --git a/src/relay-outbox.js b/src/relay-outbox.jsindex 1f6e5df0..2c8a8655 100644--- a/src/relay-outbox.js+++ b/src/relay-outbox.js@@ -161,7 +161,7 @@ export const ITEM_SLOTS = Object.freeze({register: [], ensureCoordinator: [], shout: [], passDecision: [], holdLane: [], releaseLane: [],moveMilestone: [], editMilestone: [], removeMilestone: [], shipMilestone: [],recordRowDecisions: [], applyRowDecisions: [], draftSpecRow: [], recordSpecApprovalBaseline: [],- recordLandingBatch: [], recordLandingWaiver: [], recordLandingFlake: [], finishLandingBatch: [],+ recordLandingBatch: [], recordLandingWaiver: [], recordLandingFlake: [], recordLandingTestDefect: [], finishLandingBatch: [],recordHealthFindings: [], decideSentinel: [], beginSentinelRun: [], finishSentinelRun: [],recordFlakeObservation: [], recordGateRun: [], declareJob: [], recordJobRun: [], takeCoordinator: [],...Object.fromEntries(FIRST_ITEM.map((operation) => [operation, [[0]]])),diff --git a/src/relay-sender.js b/src/relay-sender.jsindex c0f3c499..8af44175 100644--- a/src/relay-sender.js+++ b/src/relay-sender.js@@ -13,7 +13,7 @@ export function relayMoveActor(move) {if (['recordHealthFindings', 'recordFlakeObservation', 'recordGateRun', 'declareJob', 'recordJobRun', 'takeCoordinator'].includes(move.operation)) return args[0]?.agentId ?? null;if (['holdLane', 'releaseLane'].includes(move.operation) && args[1]?.asPerson) return 'person';if (move.operation === 'release') return args[1] ?? null;- if (['reserveNextReview', 'addMilestone', 'recordRowDecisions', 'applyRowDecisions', 'draftSpecRow', 'recordSpecApprovalBaseline', 'recordLandingBatch', 'recordLandingWaiver', 'recordLandingFlake', 'finishLandingBatch'].includes(move.operation)) return args[0]?.agentId ?? null;+ if (['reserveNextReview', 'addMilestone', 'recordRowDecisions', 'applyRowDecisions', 'draftSpecRow', 'recordSpecApprovalBaseline', 'recordLandingBatch', 'recordLandingWaiver', 'recordLandingFlake', 'recordLandingTestDefect', 'finishLandingBatch'].includes(move.operation)) return args[0]?.agentId ?? null;if (['acceptCheck', 'completeCheckBaseline', 'appendFact', 'editItem', 'escalate', 'recordAttempt', 'claim', 'submit', 'reserveReview', 'verify', 'merged', 'withdraw', 'refreeze','passDecision', 'answerDecision', 'holdLane', 'releaseLane', 'holdItem', 'releaseItemHold', 'reopen', 'editMilestoneItems', 'orderMilestoneItems', 'moveMilestone', 'editMilestone', 'removeMilestone', 'shipMilestone'].includes(move.operation)) return args[1]?.agentId ?? null;return null;diff --git a/src/runner-worker.js b/src/runner-worker.jsindex 99fd5ef2..ff64a328 100644--- a/src/runner-worker.js+++ b/src/runner-worker.js@@ -23,6 +23,7 @@ import {writeFileSync,} from 'node:fs';import { availableParallelism } from 'node:os';+import { executionEnvironment } from './execution-environment.js';import { freemem } from 'node:os';import { loadavg } from 'node:os';import { userInfo } from 'node:os';@@ -205,7 +206,7 @@ async function readSpec() {tagNames.add(tag.name);if (tag.chain.length ? tag.chain[0] !== tag.object : tag.object !== tag.peeledCommit) throw new Error('invalid tag manifest');}- const runtimeNames = ['resources.js', 'git.js', 'machine-home.js', 'refused.js', 'process-census.js', 'queue-settings.js', 'queue-order.js', 'sandbox-denial.js', 'gate-stages.js', 'child-journal-preload.js'];+ const runtimeNames = ['resources.js', 'git.js', 'machine-home.js', 'refused.js', 'process-census.js', 'queue-settings.js', 'queue-order.js', 'sandbox-denial.js', 'gate-stages.js', 'child-journal-preload.js', 'execution-environment.js'];if (Object.keys(value.runtime.files).length !== runtimeNames.length|| runtimeNames.some(name => typeof value.runtime.files[name] !== 'string')) throw new Error('invalid work specification');if (createHash('sha256').update(JSON.stringify(value.runtime.files)).digest('hex') !== value.runtime.sha256) throw new Error('invalid trusted runtime');@@ -1182,6 +1183,7 @@ async function runCommand(spec, root, env, sink, tracker) {async function receipt(spec, fields, sink) {await flushStdout();const body = { id: spec.id, commit: spec.commit, tree: spec.tree, code: fields.code, signal: fields.signal,+ environment: executionEnvironment(),runtimeSha256: spec.runtime.sha256, toolingSha256: spec.tooling.sha256, root: fields.root ?? '', outputSha256: sink.hash.digest('hex'), wallMs: Math.max(0, Date.now() - sink.wallStart),// The execution host's load and the pinned main this run used, so a paired rerun here can be judged (#925).main: typeof spec.main === 'string' ? spec.main : null, load: { average: loadavg(), cpus: availableParallelism(), freeMB: Math.floor(freemem() / 1048576) },diff --git a/src/runners.js b/src/runners.jsindex 87fe2b32..1df9ef0c 100644--- a/src/runners.js+++ b/src/runners.js@@ -30,6 +30,7 @@ import {} from 'node:path';import { fileURLToPath } from 'node:url';import { pipeline } from 'node:stream/promises';+import { environmentProblem } from './execution-environment.js';import {gunzipSync,gzipSync,@@ -67,7 +68,7 @@ const MAX_BLOB_BYTES = 8 * 1024 ** 2;const MAX_HISTORY_TAGS = 1_024;const MAX_TAG_CHAIN = 8;const TOOL_ROOT = fileURLToPath(new URL('../', import.meta.url));-const RUNTIME_NAMES = ['resources.js', 'git.js', 'machine-home.js', 'refused.js', 'process-census.js', 'queue-settings.js', 'queue-order.js', 'sandbox-denial.js', 'gate-stages.js', 'child-journal-preload.js'];+const RUNTIME_NAMES = ['resources.js', 'git.js', 'machine-home.js', 'refused.js', 'process-census.js', 'queue-settings.js', 'queue-order.js', 'sandbox-denial.js', 'gate-stages.js', 'child-journal-preload.js', 'execution-environment.js'];/** Validate an SSH destination as one argument, never a command or an SSH option. */export function validateRunner(value) {@@ -548,6 +549,7 @@ function resultFrom(request, result) {}}const text = staged?.output ?? output.toString('utf8');+ if (receipt.environment !== undefined && environmentProblem(receipt.environment)) throw new RunnerDropped(request.runner.host);if (receipt.browserRefused !== undefined && (receipt.browserRefused !== true || receipt.code === 0 || request.spec.browserRequired)) throw new RunnerDropped(request.runner.host);// Only the lease guard's own receipt counts; text a test prints is never a refusal (#1043).if (receipt.browserRefused === true) {@@ -556,6 +558,7 @@ function resultFrom(request, result) {throw refused;}return { isGreen: receipt.code === 0 && !receipt.signal, output: text, sandboxBlocked,+ environment: receipt.environment ?? null,...(request.spec.stageMarker ? { stages: staged?.stages ?? null } : {}),seconds: Math.round(receipt.wallMs / 1000), exitCode: receipt.code,executionRunner: request.runner.host, executionRoot: receipt.root, remoteWallMs: receipt.wallMs,diff --git a/src/settings-inventory.js b/src/settings-inventory.jsindex 35e888a1..c0280e7d 100644--- a/src/settings-inventory.js+++ b/src/settings-inventory.js@@ -23,17 +23,18 @@ import {DEFAULT_VIEW_PORT,} from './view-port.js';import { Refused } from './refused.js';+import { environmentProblem } from './execution-environment.js';const MACHINE_DEFAULTS = {gateSlots: 2, browserSlots: 1, 'gate.shortSlots': 0,'gate.queue.reviewsFirst': false, 'gate.queue.currentReleaseFirst': false, 'gate.queue.agingMinutes': 30,'gate.memoryFloorMB': null, 'gate.browserFreeChecks': false, 'gate.browserByLaunch': false,- 'health.sentinel': true, 'view.background': true, 'relay.offerAtInit': true, runners: [],+ 'health.sentinel': true, 'view.background': true, 'relay.offerAtInit': true, runners: [], 'landing.pools': [],};const OPTIONAL_REPO_DEFAULTS = {project: null, name: null, 'checks.provesNothing': 'warn', 'verify.unrelatedTrunkMoves': false, 'verify.composeAtAdmission': false,'flakes.rerun': false, 'flakes.quarantine': false, 'rigor.budget': 400, 'relay.outbox': false,- submitGate: null, submitDeferAbove: null, landingShards: 1, 'landing.publish': null, positiveControl: null, affectedTests: null,+ submitGate: null, submitDeferAbove: null, landingShards: 1, 'landing.publish': null, 'landing.environment': null, positiveControl: null, affectedTests: null,'health.sentinel': true, 'testConcurrency.browser': 2, approvers: null,};@@ -59,6 +60,8 @@ function fields(value, names) {/** Project structured settings without returning unknown nested metadata or credential fields. */function safeValue(key, value) {+ if (key === 'landing.environment' && value !== null && environmentProblem(value)) throw new Refused('BAD_SETTINGS', 'landing.environment needs exact platform, arch and Node version');+ if (key === 'landing.pools' && (!Array.isArray(value) || value.some(id => typeof id !== 'string' || !/^[a-f0-9]{32}$/u.test(id)))) throw new Refused('BAD_SETTINGS', 'landing.pools lists board identifiers');const strings = entries => Array.isArray(entries) && entries.every(entry => typeof entry === 'string');if (key === 'products' && !Object.values(value).every(strings)) throw new Refused('BAD_SETTINGS', 'products must map names to spec-id lists');if (key === 'runners') return value.map(runner => fields(runner, ['host', 'slots', 'browser', 'node', 'root']));@@ -78,7 +81,7 @@ function leaves(value, prefix = '') {/** Refuse malformed supported scalar settings without echoing credential-bearing input. */function checkedValue(key, value, fallback) {- const expected = fallback === null ? (key === 'gate.memoryFloorMB' || key.startsWith('resources.') ? 'number' : 'string') : typeof fallback;+ const expected = key === 'landing.environment' ? 'object' : fallback === null ? (key === 'gate.memoryFloorMB' || key.startsWith('resources.') ? 'number' : 'string') : typeof fallback;if (value !== null && expected !== 'object' && typeof value !== expected) {throw new Refused('BAD_SETTINGS', `setting ${key} has an unsupported type; restore its documented value`);}diff --git a/src/settings.js b/src/settings.jsindex 8e72d632..b0c23959 100644--- a/src/settings.js+++ b/src/settings.js@@ -33,6 +33,11 @@ export function loadMachineSettings() {const file = machineSettingsFile();const value = readMachineSettingsFile(file);if (!value) return { gateSlots: DEFAULT_GATE_SLOTS, browserSlots: DEFAULT_BROWSER_SLOTS };+ if (value.landing !== undefined && (!value.landing || typeof value.landing !== 'object' || Array.isArray(value.landing)+ || Object.keys(value.landing).some(key => key !== 'pools') || !Array.isArray(value.landing.pools)+ || value.landing.pools.some(id => typeof id !== 'string' || !/^[a-f0-9]{32}$/u.test(id)))) {+ throw new Refused('BAD_MACHINE_SETTINGS', `landing.pools in ${file} lists the board identifiers this machine may land`);+ }if (value.health?.sentinel !== undefined && typeof value.health.sentinel !== 'boolean') {throw new Refused('BAD_MACHINE_SETTINGS', `health.sentinel in ${file} must be true or false`);}@@ -136,6 +141,17 @@ function writeMachineSettings(settings) {} finally { rmSync(temporary, { force: true }); }}+/** Opt this machine into one board's landing pool without cancelling any admitted work. */+export function setLandingPool(board, enabled) {+ if (!/^[a-f0-9]{32}$/u.test(board) || typeof enabled !== 'boolean') throw new Refused('BAD_MACHINE_SETTINGS', 'a landing pool needs this board identifier and on or off');+ const settings = loadMachineSettings();+ const pools = new Set(settings.landing?.pools ?? []);+ if (enabled) pools.add(board); else pools.delete(board);+ const next = { ...settings, landing: { pools: [...pools].sort() } };+ writeMachineSettings(next);+ return next;+}+/** Raise machine gate capacity immediately; decreases require an empty durable queue. */export function setGateSlots(capacity) {if (!Number.isSafeInteger(capacity) || capacity < 1) throw new Refused('BAD_GATE_SLOTS', 'gateSlots must be a positive integer; run pullboard settings gateSlots <n>');diff --git a/src/submit-invariants.js b/src/submit-invariants.jsindex fa72dcf0..3f6a004e 100644--- a/src/submit-invariants.js+++ b/src/submit-invariants.js@@ -127,7 +127,7 @@ export function submitInvariantLine(proposal) {/** Validate the existing canonical batch identity before its append-only snapshot is recorded. */export function validateLandingBatch(batch, revision) {if (!batch || batch.version !== 1 || typeof batch.id !== 'string' || !/^[a-zA-Z0-9_-]{1,80}$/u.test(batch.id)- || !['merging', 'gating', 'bisecting', 'flaky', 'blocked', 'ready', 'pushed', 'trunk', 'landed'].includes(batch.state)+ || !['merging', 'gating', 'bisecting', 'flaky', 'test-defect', 'blocked', 'ready', 'pushed', 'trunk', 'landed'].includes(batch.state)|| !/^[a-f0-9]{40,64}$/u.test(batch.base ?? '') || !/^[a-f0-9]{40,64}$/u.test(batch.tip ?? '')|| typeof batch.root !== 'string' || !batch.root || typeof batch.branch !== 'string' || !batch.branch.startsWith('refs/heads/')|| !Array.isArray(batch.items) || batch.items.some((entry) => !Number.isSafeInteger(entry?.id) || entry.id < 1 || !/^[a-f0-9]{40,64}$/u.test(entry.commit ?? ''))diff --git a/src/trusted-policy.js b/src/trusted-policy.jsindex 5fc1da6c..0492106e 100644--- a/src/trusted-policy.js+++ b/src/trusted-policy.js@@ -1,5 +1,6 @@/** Coordinator policy and immutable submission checks cannot come from a builder's candidate [V4,V16,L3,M3]. */import { randomUUID } from 'node:crypto';+import { environmentProblem } from './execution-environment.js';import { spawnSync } from 'node:child_process';import {digestOf,@@ -210,6 +211,7 @@ export function checkAtCommit(root, item, { waitMs = 0, gateSlotHeld = false, gadelete env.PULLBOARD_RELAY_TOKEN;let installOutput = '';let checkOutput = '';+ let environment = null;const checkStartedAt = Date.now();let installLogPath = '';let checkLogPath = '';@@ -219,9 +221,9 @@ export function checkAtCommit(root, item, { waitMs = 0, gateSlotHeld = false, gaconst finish = (state, stage) => {const runner = timingRunner(command);const events = checkLogPath && existsSync(checkLogPath) ? timingFromLog(checkLogPath, runner) : timingFromOutput(checkOutput, runner);- timingProfile = { ...events, wallMs: Math.max(0, Date.now() - checkStartedAt) };+ timingProfile = { ...events, wallMs: Math.max(0, Date.now() - checkStartedAt), environment };return checkResult(state, stage, installOutput, checkOutput, { root, item, commandRoot: copy, installLogPath, checkLogPath, timingProfile, waitMs,- executionSourceUnchanged: checkedSourceReady && privateSourceUnchanged(copy, item.item_commit, env) });+ environment, executionSourceUnchanged: checkedSourceReady && privateSourceUnchanged(copy, item.item_commit, env) });};try {const common = policyGit(root, ['rev-parse', '--path-format=absolute', '--git-common-dir']).trim();@@ -266,6 +268,7 @@ export function checkAtCommit(root, item, { waitMs = 0, gateSlotHeld = false, gaif (remaining <= 0) return finish('unverified', 'check timed out');checkLogPath = join(scratch, 'check.log');const run = runPrivateCommand(copy, env, command, remaining, checkLogPath);+ environment = environmentProblem(run.environment) ? null : run.environment;checkOutput = run.output;if (run.error?.code === 'ETIMEDOUT') return finish('unverified', 'check timed out');if (run.error) return finish('unverified', `check could not start (${run.error.code})`);@@ -423,7 +426,7 @@ function privateSourceUnchanged(root, commit, env) {}/** Persist a sanitized full diagnostic outside the temporary checkout so a refusal can name it. */-function checkResult(state, stage, installCapture, checkCapture, { root = '', item = {}, commandRoot = root, installLogPath = '', checkLogPath = '', timingProfile = null, waitMs = 0, executionSourceUnchanged } = {}) {+function checkResult(state, stage, installCapture, checkCapture, { root = '', item = {}, commandRoot = root, installLogPath = '', checkLogPath = '', timingProfile = null, waitMs = 0, environment = null, executionSourceUnchanged } = {}) {const boundedInstall = secretScanned(installCapture, 'check install capture');const boundedCheck = secretScanned(checkCapture, 'frozen check capture');const install = digestOf(boundedInstall) || '(no output)';@@ -499,6 +502,6 @@ function checkResult(state, stage, installCapture, checkCapture, { root = '', it: /could not start/u.test(stage) ? "couldn't start" : state === 'unverified' ? 'could not be verified' : 'passed';const output = `install output:\n${boundedInstall || '(no output)'}\ncheck output:\n${boundedCheck || '(not run or no output)'}`;return { sandboxBlocked, state, green: state === 'pass', checked: true, stage, failure, report, output, outputTail, outputPath, outputError, profilePath,- executionRoot: commandRoot, ...(executionSourceUnchanged === undefined ? {} : { executionSourceUnchanged }),+ executionRoot: commandRoot, environment, ...(executionSourceUnchanged === undefined ? {} : { executionSourceUnchanged }),profile: timingProfile ? { ...timingProfile, profilePath } : null };}diff --git a/src/verdict-reviews.js b/src/verdict-reviews.jsindex f1fb7594..b8eaed8b 100644--- a/src/verdict-reviews.js+++ b/src/verdict-reviews.js@@ -28,7 +28,8 @@ export function verdictsFor(board, id) {return verdicts.map((verdict, index) => {let detail = {};try { detail = JSON.parse(receipts[index]?.event_detail ?? '{}'); } catch { /* Malformed legacy details remain unknown. */ }- return { ...verdict, check: detail.check ?? 'unknown', ...(detail.review ? { review: detail.review } : {}) };+ return { ...verdict, check: detail.check ?? 'unknown', ...(detail.review ? { review: detail.review } : {}),+ ...(Object.hasOwn(detail, 'environment') ? { environment: detail.environment } : {}) };});}diff --git a/test/landing-environment-fixture.js b/test/landing-environment-fixture.jsnew file mode 100644index 00000000..37e6a368--- /dev/null+++ b/test/landing-environment-fixture.js@@ -0,0 +1,209 @@+/** Public Git/CLI cells for landing hosts and a trunk held by a test defect [E27,E28,E29]. */+import assert from 'node:assert/strict';+import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';+import { join } from 'node:path';+import * as store from '../src/board.js';+import { applyEngineMove, prepareEngineMove } from '../src/engine.js';+import { receiptBinds, receiptBody, receiptFields, receiptStore } from '../src/gate-run-receipt.js';++/** Read the private board through its public store without rewriting historical receipts. */+function boardRead(box, action, clock) {+ const board = store.openBoard(join(box.repo, '.git/pullboard/board.sqlite'), clock);+ try { return action(board); } finally { store.closeBoard(board); }+}++/** Keep each actual public command result attached to a failed assertion. */+function command(box, cwd, ...args) {+ const ran = box.run(cwd, ...args, '--json');+ let document;+ try { document = JSON.parse(ran.out); } catch { document = null; }+ return { ...ran, document };+}++/** Require success before using a public command's document. */+function success(box, cwd, ...args) {+ const ran = command(box, cwd, ...args);+ assert.equal(ran.code, 0, `${args.join(' ')}: ${ran.err}${ran.out}`);+ return ran.document;+}++/** Commit fixture inputs through the normal installed hooks. */+function commit(box, root, message) {+ box.git(root, 'add', '-A');+ box.git(root, 'commit', '-q', '-m', message);+ return box.git(root, 'rev-parse', 'HEAD');+}++/** A real Node test passes for either item alone and fails when their changes meet. */+function fixture(helpers) {+ const box = helpers.project('node --test web/landing.test.js');+ mkdirSync(join(box.repo, 'web'), { recursive: true });+ writeFileSync(join(box.repo, 'web/landing.test.js'), [+ "import { test } from 'node:test';",+ "import assert from 'node:assert/strict';",+ "import { existsSync } from 'node:fs';",+ "test('the two changes coexist [E27,E29]', () => assert.equal(existsSync('web/a.txt') && existsSync('web/b.txt'), false));",+ ].join('\n') + '\n');+ const config = JSON.parse(readFileSync(join(box.repo, 'pullboard.json'), 'utf8'));+ config.affectedTests = 'node --test';+ writeFileSync(join(box.repo, 'pullboard.json'), JSON.stringify(config, null, 2) + '\n');+ commit(box, box.repo, 'chore: prepare the landing host fixture');+ const remote = join(box.dir, 'origin.git');+ box.git(box.dir, 'init', '-q', '--bare', remote);+ box.git(box.repo, 'remote', 'add', 'origin', remote);+ box.git(box.repo, 'push', '-q', '-u', 'origin', 'main');+ return { ...box, remote };+}++/** Build and independently verify a fixture item at its actual committed head. */+function verified(box, name, { touchTest = false } = {}) {+ const path = join(box.dir, name);+ box.git(box.repo, 'worktree', 'add', '-q', '--detach', path, 'main');+ success(box, path, 'join', 'web');+ const file = `web/${name}.txt`;+ const added = success(box, box.repo, 'add', 'web', `Landing change ${name}`, '--specs', 'G1',+ '--criterion', `the ${name} change exists`, '--check', `test -f ${file}`);+ const id = added.item.item_id;+ success(box, path, 'claim', String(id));+ writeFileSync(join(path, file), `${name}\n`);+ if (touchTest) writeFileSync(join(path, 'web/landing.test.js'), readFileSync(join(path, 'web/landing.test.js'), 'utf8') + '// Candidate-only test edit.\n');+ const head = commit(box, path, 'feat(web): build the landing fixture [G1]');+ success(box, path, 'submit', String(id));+ box.git(box.repo, 'switch', '-q', '--detach', head);+ try {+ success(box, box.repo, 'verify', String(id), 'accept', '--as', 'coordinator',+ '--note', 'The real frozen file-existence check passed at this submitted head.');+ } finally { box.git(box.repo, 'switch', '-q', 'main'); }+ return { id, path, head, file };+}++/** Save a project policy normally, without changing another machine's settings. */+function policy(box, landing) {+ const file = join(box.repo, 'pullboard.json');+ const config = JSON.parse(readFileSync(file, 'utf8'));+ config.landing = landing;+ writeFileSync(file, JSON.stringify(config, null, 2) + '\n');+ commit(box, box.repo, 'chore: declare the landing host policy');+}++/** S7d: a real check records its host; only an opted-in matching host may land. */+export function assertMatchingLandingHost(helpers) {+ const box = fixture(helpers);+ const entry = verified(box, 'a');+ const environment = { platform: process.platform, arch: process.arch, node: process.versions.node };+ const accepted = boardRead(box, board => store.events(board, { itemId: entry.id }).findLast(event => event.event_kind === 'accept'));+ assert.deepEqual(JSON.parse(accepted.event_detail).environment, environment,+ 'a machine-run verdict records the environment that actually ran its frozen check');+ success(box, box.repo, 'gate');+ const run = boardRead(box, board => store.events(board).findLast(event => event.event_kind === 'gate-run'));+ assert.deepEqual(JSON.parse(run.event_detail).run.environment, environment,+ 'a real gate receipt records its executor environment');+ const receipt = JSON.parse(run.event_detail).run;+ assert.equal(receiptBinds(receiptStore(box.repo), receipt), true);+ assert.equal(receiptBinds(receiptStore(box.repo), { ...receipt, environment: { ...environment, node: '0.0.1' } }), false,+ 'changing an executor identity breaks the real gate receipt binding');+ const { environment: ignored, ...legacyReceipt } = receipt;+ assert.equal(Object.hasOwn(receiptFields(legacyReceipt), 'environment'), false);+ assert.equal(receiptBody(legacyReceipt), JSON.stringify(legacyReceipt) + '\n',+ 'historical receipts keep the exact canonical bytes without a fabricated executor');++ boardRead(box, board => {+ const item = store.getItem(board, entry.id);+ const options = { agentId: 'coordinator', decision: 'ACCEPT', note: 'Replay compatibility fixture.', head: entry.head,+ digest: item.item_frozen_digest, policy: 'any', check: 'green', review: JSON.parse(accepted.event_detail).review };+ const modern = prepareEngineMove(board, 'verify', [entry.id, { ...options, environment }]);+ const count = store.events(board).length;+ assert.throws(() => applyEngineMove(board, { ...modern, engine: 78 }, { sequence: 1, at: new Date().toISOString() }), { code: 'RELAY_MOVE' });+ assert.equal(store.events(board).length, count, 'an old engine cannot silently discard the new environment semantics');+ const historical = prepareEngineMove(board, 'verify', [entry.id, options]);+ assert.equal(applyEngineMove(board, { ...historical, engine: 73 }, { sequence: 1, at: new Date().toISOString() }).error, undefined);+ assert.equal(Object.hasOwn(JSON.parse(store.events(board).findLast(event => event.event_kind === 'accept').event_detail), 'environment'), false,+ 'recorded legacy verdict moves replay without acquiring new metadata');+ });++ // Model a sealed peer verdict reporting a different host; this is fixture data, not a measured second runtime.+ const peerEnvironment = { ...environment, node: '0.0.1' };+ boardRead(box, board => {+ const item = store.getItem(board, entry.id);+ store.verify(board, entry.id, { agentId: 'coordinator', decision: 'ACCEPT',+ note: 'Stand-in peer records its different execution environment.', head: entry.head,+ digest: item.item_frozen_digest, policy: 'any', check: 'green',+ review: JSON.parse(accepted.event_detail).review, environment: peerEnvironment });+ });++ const mismatch = { ...environment, platform: process.platform === 'linux' ? 'darwin' : 'linux' };+ policy(box, { environment: mismatch });+ const base = box.git(box.repo, 'rev-parse', 'HEAD');+ success(box, box.repo, 'settings', 'landing.pool', 'on');+ const refused = command(box, box.repo, 'land');+ assert.equal(refused.document?.error?.code, 'LAND_ENVIRONMENT', JSON.stringify(refused));+ assert.equal(box.git(box.repo, 'rev-parse', 'HEAD'), base, 'a mismatched host never moves the trunk');+ assert.equal(boardRead(box, board => store.landingBatches(board).length), 0,+ 'host mismatch is refused before a batch or its gate starts');++ policy(box, { environment });+ success(box, box.repo, 'settings', 'landing.pool', 'off');+ assert.equal(command(box, box.repo, 'land').document?.error?.code, 'LAND_HOST_NOT_JOINED');+ success(box, box.repo, 'settings', 'landing.pool', 'on');+ const landed = success(box, box.repo, 'land');+ assert.deepEqual(landed.landed, [entry.id]);+ assert.deepEqual(landed.batch.environment, environment);+ assert.ok(landed.batch.environmentWarnings.some(warning => warning.item === entry.id+ && warning.recorded.node === peerEnvironment.node && warning.landing.node === environment.node),+ 'landing flags the stand-in verdict from another environment');+}++/** S7e: an interaction with no item culprit files a test defect and holds every new batch. */+export function assertNoCulpritTrunkHold(helpers) {+ const box = fixture(helpers);+ const entries = [verified(box, 'a', { touchTest: true }), verified(box, 'b')];+ const base = box.git(box.repo, 'rev-parse', 'HEAD');+ const held = success(box, box.repo, 'land');+ assert.deepEqual(held.landed, []);+ assert.deepEqual(held.culprits, [], 'both bisection halves pass; neither item is a proved culprit');+ assert.equal(box.git(box.repo, 'rev-parse', 'HEAD'), base);+ assert.equal(box.git(box.remote, 'rev-parse', 'main'), base);+ const defects = boardRead(box, board => store.events(board).filter(event => event.event_kind === 'landing-test-defect'));+ assert.equal(defects.length, 1, 'the no-culprit red files one durable test defect');+ const defect = JSON.parse(defects[0].event_detail).defect;+ assert.equal(defect.test, 'web/landing.test.js');+ assert.equal(defect.batchId, held.batch.id);+ assert.ok(boardRead(box, board => store.getItem(board, defect.item)));+ const callsBefore = boardRead(box, board => store.events(board).filter(event => event.event_kind === 'gate-run').length);+ const again = command(box, box.repo, 'land');+ assert.equal(again.document?.error?.code, 'LAND_TEST_DEFECT',+ 'a candidate-only test edit does not look like a committed trunk correction');+ assert.equal(boardRead(box, board => store.events(board).filter(event => event.event_kind === 'gate-run').length), callsBefore,+ 'the held trunk does not retry the unchanged gate');+ boardRead(box, board => store.recordLandingWaiver(board, { agentId: 'person', channel: 'terminal',+ id: 'expired-host-fixture', test: defect.test, until: '2000-01-02', reason: 'Expired private fixture waiver.' }),+ { now: () => new Date('2000-01-01T00:00:00Z') });+ assert.equal(command(box, box.repo, 'land').document?.error?.code, 'LAND_TEST_DEFECT',+ 'an expired person waiver cannot release the trunk');+ success(box, box.repo, 'land', '--waive', defect.test, '--until', '2099-01-01', '--reason', 'Private fixture interaction is tracked by its defect.');+ const waived = success(box, box.repo, 'land');+ assert.deepEqual(waived.landed, entries.map(entry => entry.id));+ assert.equal(waived.batch.proof.tree, box.git(waived.batch.root, 'rev-parse', 'HEAD^{tree}'));+ assert.ok(waived.batch.proof.failures.every(failure => failure.waiver), 'the red tree stays explicitly waived');++ const fixed = fixture(helpers);+ const fixedEntries = [verified(fixed, 'a'), verified(fixed, 'b')];+ assert.deepEqual(success(fixed, fixed.repo, 'land').landed, []);+ const heldTest = readFileSync(join(fixed.repo, 'web/landing.test.js'), 'utf8');+ writeFileSync(join(fixed.repo, 'web/landing.test.js'), heldTest + '// An uncommitted edit is not a correction.\n');+ assert.equal(command(fixed, fixed.repo, 'land').document?.error?.code, 'LAND_TEST_DEFECT',+ 'an uncommitted test edit does not release the trunk hold');+ writeFileSync(join(fixed.repo, 'web/landing.test.js'), [+ "import { test } from 'node:test';",+ "import assert from 'node:assert/strict';",+ "import { existsSync, readFileSync } from 'node:fs';",+ "test('the two changes coexist [E27,E29]', () => {",+ " if (existsSync('web/a.txt') && existsSync('web/b.txt')) {",+ " assert.equal(readFileSync('web/a.txt', 'utf8') + readFileSync('web/b.txt', 'utf8'), 'a\\nb\\n');",+ ' }',+ '});',+ ].join('\n') + '\n');+ commit(fixed, fixed.repo, 'fix(web): correct the interaction expectation [G1]');+ assert.deepEqual(success(fixed, fixed.repo, 'land').landed, fixedEntries.map(entry => entry.id),+ 'a correction to the held test releases the trunk without a waiver');+}diff --git a/test/runners.test.js b/test/runners.test.jsindex 38f35782..2de12f7f 100644--- a/test/runners.test.js+++ b/test/runners.test.js@@ -409,6 +409,8 @@ test('a queued run executes on a registered runner and its result comes back (hoconst result = gateResult(run.stdout);assert.equal(result.isGreen, true);assert.equal(result.runner, HOST);+ assert.deepEqual(result.profile.receipt.environment, { platform: process.platform, arch: process.arch, node: process.versions.node },+ 'the real SSH stand-in worker reports its own executor, without inferring a second physical host');assert.equal(result.profile.executionRunner, HOST);assert.equal(result.profile.executionSource.tooling.name, 'pullboard');assert.equal(result.profile.executionSource.tooling.kind, 'git-checkout');diff --git a/test/team.test.js b/test/team.test.jsindex f7c9d04b..f0a98c71 100644--- a/test/team.test.js+++ b/test/team.test.js@@ -24,12 +24,18 @@ import { decodeBoardKey, seal } from '../src/seal.js';import { ENGINE_VERSION as PEOPLE_VERSION } from '../src/machine.js';import { relayWorkBudgetMs } from './relay-budget.js';import { hostname } from 'node:os';+import { assertMatchingLandingHost, assertNoCulpritTrunkHold } from './landing-environment-fixture.js';const CLI = join(import.meta.dirname, '..', 'bin', 'pullboard.js');const helpers = createE2eHelpers();after(helpers.cleanup);+test('land runs on a matching host [E27,E28,E29]', { timeout: 180_000 }, () => { // budget: hang ceiling for real Git/CLI host checks, bisection and waiver controls; no speed target.+ assertMatchingLandingHost(helpers);+ assertNoCulpritTrunkHold(helpers);+});+/** Open a fixture's independent board and always close it after its observation or public move. */function withBoard(root, action) {const board = store.openBoard(join(root, '.git', 'pullboard', 'board.sqlite'));