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
Merge remote-tracking branch 'origin/main' into core/696-claude-merge
Corey Olsone99fffef82ef
diff --cc docs/formats.mdindex c3797a6c,425167f8..0d81e606--- a/docs/formats.md+++ b/docs/formats.md@@@ -102,7 -113,7 +113,7 @@@ The board file is in the repository's G| `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` | `12` | `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` | `20` | `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` | `22` | `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 -->Pullboard 0.6.1 released engine 1. Engine 2 records a fresh explicit-build claim's skipped-review snapshot. Pullboard 0.8.1 released engine 3, including lane-sensitive graft refusals and authenticated relay senders. Engine 4 adds captured background-baseline completions through `completeCheckBaseline`; released engine-3 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Engine 5 requires a one-line reason when releasing a review and gives that reviewer a one-hour cooldown for the current submission. Each sealed move replays under its recorded engine version: engines 1 through 4 retain the original release event and review-reservation behavior. Engine 5 retains support for older moves, including engine-4 baseline completions. Pullboard 0.8.3 released engine 6, adding board-scoped machine credentials and permitting machine execution only for one exact, earlier authenticated phone request, including its payload digest. Engine 7 adds ordered item holds through `holdItem` and `releaseItemHold`; engine-6 clients stop with `ENGINE_VERSION` before interpreting either operation or advancing their replay cursor. Engine 8, shared by the 0.8.5 move changes, retains merged-item exception notes, selects the next review in roadmap order, and adds coordinator-only `reopen` for a submission returned without a verdict; engine-7 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Recorded engines 1 through 7 retain their original tier-first review selection. Engine 8 also adds durable refusal recovery for blocked relay positions; each explicit skip publishes the readable prefix even when another unsupported record follows. Engine 8 also permits coordinator criterion/check edits on a live claim as pending corrections; the holder cannot renew or submit until a refreeze adopts the correction while preserving the claim. Older request receipts retain their recorded engine semantics. Upgrade every linked device before using the new moves. Each release shares one engine bump across its changed moves. Engine 8 also retains declared model labels on registration and records each registered agent move's model snapshot; engines 1 through 7 retain their original registration and event details without these model fields. Pullboard 0.8.8 released engine 9, which allows resubmitting the same rejected commit after a corrected criterion is refrozen, but only when the rejection names a different frozen digest. Engine 8 retains its HEAD_NOT_NEW refusal and prior submit-event detail. Engine-9 submit events add `criterionDigest`, and engine-8 boards replay with the original refusal and event history.@@@ -113,6 -124,10 +124,12 @@@ Engine 11 permits resubmitting the samEngine 12 records declined person row decisions without replacing the exact source text: the row becomes `wont` and the reason stays in the decision record. Engine-11 decline receipts retain their original reason-as-row-text validation and replay outcome. Engine-11 clients refuse engine-12 moves before interpreting them; upgrade linked clients before recording new decline decisions.+ Engine 19 makes a corrected bar record why the old one was wrong. Once an item has ever been claimed, an `editItem` that changes its criterion or check must carry `reason`, the text of what the old bar got wrong; without one it is refused with `BAR_REASON`, naming `--reason`. The edit event then records `reason` and `barCorrection: {fields, reject}`: `fields` lists `criterion` and/or `check`, and `reject` is `{verdict, by, reason, at}` when the item's newest verdict is a reject no earlier correction already explained, or `null`. That reject is counted as caused by the bar. The board derives `barCorrection` from its own rows; a move supplies only `reason`. An edit before any claim needs no reason and records one only if given. `pullboard stats` JSON adds `bars`, keyed by agent: `{corrections, barRejects, buildRejects}`. Corrections and the rejects they explain count to the agent who corrected the bar; any other reject counts as the build's, to the agent who added the item. An `editItem` move carrying `reason` requires engine 19, and older engines refuse it with `RELAY_MOVE` before changing their board or cursor. Moves recorded under engines 18 and earlier replay without the reason rule. Engine numbers 13 to 18 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.++ Engine 20 lets a decision name the items it changes. An `appendFact`, `answerDecision` or `verify` move may carry `implies`, a list of existing item ids, and an `answerDecision` move may carry `supersedes`, the shout id of an earlier answer. Either makes the move an engine-20 move: an older engine refuses it with `RELAY_MOVE` before changing its board or cursor, and a board replaying an older engine refuses `implies` with `ENGINE_VERSION`. Engine 20 also tells implied items when a decision is superseded: by a fact's `supersedes`, by an answer's `supersedes`, or by the next verdict on the same item. Moves recorded under engines 19 and earlier replay without these notices. Engine numbers 13 to 18 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.+++Engine 22 records submission test selections and normalized landing evidence. A `submit` carrying `submissionProof` or a `recordLandingBatch` carrying `invariantEvidence` requires engine 22; earlier engines refuse these envelopes before applying them, and a malformed proof is refused with `SUBMISSION_PROOF`. Moves recorded under engines 21 and earlier replay without inferred coverage. Recorded invariant evidence is append-only when a landing batch is adopted. Engine numbers 13 to 18 and 21 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.++The CLI declares its engine in every relay request's `X-Pullboard-Engine` header.A linked board requires at least engine 3 after issuing any agent token, includingrevoked or expired tokens. Issuing any machine credential raises that board’s minimum to engine 6, including after revocation or expiry. The minimum survives reopening the auth database;diff --cc docs/lifecycle.mdindex f60d3736,d0672d72..07abe5f6--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@@ -54,10 -54,10 +54,10 @@@ Each move checks its guards in this ord| claim | open, claimed | claimed | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_CLAIMABLE), itemNotHeld (ITEM_HELD), inLane (WRONG_LANE), routeAllows (ROUTE), dependenciesVerified (BLOCKED), notHeldByAnother (HELD), correctionRefrozen (PENDING_REFREEZE), laneOpen (LANE_HELD), oneLiveClaim (ONE_CLAIM), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) || release | claimed | open | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), reviewReleaseExplained (NOTE_REQUIRED) || lapse | claimed | open | clock, when its lease runs out | none |-| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), correctionRefrozen (PENDING_REFREEZE), criterionUnchanged (CRITERIA_CHANGED), treeClean (DIRTY), nothingUntracked (UNTRACKED), hasCommit (NO_COMMIT), withinLane (OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), doctrineHolds (RATCHET_ROSE or RATCHET_UNCOUNTED), gateConfigured (NO_GATE), gateGreen (GATE_RED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) |+| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), correctionRefrozen (PENDING_REFREEZE), criterionUnchanged (CRITERIA_CHANGED), treeClean (DIRTY), nothingUntracked (UNTRACKED), hasCommit (NO_COMMIT), withinLane (OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), doctrineHolds (RATCHET_ROSE or RATCHET_UNCOUNTED), gateConfigured (NO_GATE), gateGreen (GATE_RED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), submissionProofValid (SUBMISSION_PROOF), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) || reserve | submitted | submitted | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), roadmapReadable (MILESTONES_CORRUPT), itemExists (NO_ITEM), inState (NOT_SUBMITTED), reviewCooldownElapsed (REVIEW_COOLDOWN), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD) |- | accept | submitted | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonIsMet (BAD_REASON), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), itemCheckGreen (CHECK_RED or CHECK_UNVERIFIED), proofNoted (PROOF_REQUIRED), result (LAND_HEADER) |- | reject | submitted | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED), result (LAND_HEADER) |+ | accept | submitted | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonIsMet (BAD_REASON), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), itemCheckGreen (CHECK_RED or CHECK_UNVERIFIED), proofNoted (PROOF_REQUIRED), result (LAND_HEADER), result (ENGINE_VERSION) |+ | reject | submitted | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED), result (LAND_HEADER), result (ENGINE_VERSION) || reopen | submitted, verified | open | coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), notMerged (ALREADY_MERGED), landingFailureRecorded (LANDING_FAILURE_REQUIRED) || escalate | open, claimed | open | agent, coordinator | joined (NOT_JOINED), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED) || refreeze | open, claimed, submitted | open | coordinator, when there is no live claim awaiting a coordinator correction | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), itemExists (NO_ITEM), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) |@@@ -145,10 -145,11 +145,12 @@@| REVIEW_COOLDOWN | the reviewer has not released this submission within the past hour, engine 5 or newer, only for the same reviewer and current submission | let another reviewer take it, or wait an hour or for a new submission || NOTE_REQUIRED | the move carries a note: what failed, what was tried, or why | --note "..." or --note-file <file> || ALREADY_MERGED | the item has no recorded merge receipt | a merged item cannot be reopened |- | SUBMISSION_PROOF | recorded test selection names literal project files and its full-fallback policy, engine 17 or later; absent legacy selection remains unknown | rerun submit with the current CLI |++| SUBMISSION_PROOF | recorded test selection names literal project files and its full-fallback policy, engine 22 or later; absent legacy selection remains unknown | rerun submit with the current CLI || LANDING_FAILURE_REQUIRED | a verified item note names the failing test and landing merge commit | cite the recorded batch, or name the test and merge commit in a manual note || LAND_HEADER | a displayed merge command fits the commit-header limit (accept result) | shorten the item title or cited rows so the merge header fits |+ | ENGINE_VERSION | a verdict that implies items replays only under engine 20 or later (accept result) | upgrade Pullboard on every linked device before using --implies || LAND_HEADER | a displayed merge command fits the commit-header limit (reject result) | shorten the item title or cited rows so the merge header fits |+ | ENGINE_VERSION | a verdict that implies items replays only under engine 20 or later (reject result) | upgrade Pullboard on every linked device before using --implies || BAD_DECISION | a verdict is accept or reject | pullboard verify <id> accept, or reject --reason CODE --note "..." |For check diagnostics, a refusal from a failed or unverifiable check includes an output digest, sanitized tail, and a private full-output path in the CLI message (also `error.message` in JSON). The artifact is owner-readable only. If it cannot be saved, the tail remains available and the message names the storage error instead of claiming a path.diff --cc src/board.jsindex fa2b4cab,004f398a..a388918e--- a/src/board.js+++ b/src/board.js@@@ -14,13 -15,9 +15,15 @@@ import { briefFiles, briefSections } frimport { COORDINATOR } from './config.js';import { ENGINE_VERSION, GUARDS, IN_STATE, MOVES, STATES, UNKNOWN_MOVE, effectiveGuards, storeTriggers } from './machine.js';import { Refused } from './refused.js';+ import { barCorrectionFields } from './bar-corrections.js';+ import { factFromEvent, requestAnswerRefusal, tellAnswerImplications, tellFactImplications, tellVerdictImplications } from './implies.js';import { parseSpec } from './spec.js';+import { invariantEvidence } from './submit-invariants.js';+import { preserveInvariantEvidence } from './submit-invariants.js';+import { validateLandingBatch } from './submit-invariants.js';+import { validateLandingRevision } from './submit-invariants.js';+import { submissionProof } from './submit-invariants.js';+import { SUBMISSION_PROOF_ENGINE } from './submit-invariants.js';export const ACCEPT_REASON = 'CRITERION_MET';export const PERSON = 'person';diff --cc src/cli.jsindex edcd60d2,be1e8c61..b6b98e3c--- a/src/cli.js+++ b/src/cli.js@@@ -17,11 -18,9 +18,11 @@@ import { agentDoctrine, proposeDoctrineimport { checkRulesAt, doctrineReport, hasSubmitRules, holdDoctrine, ruleLine } from './doctrine-checks.js';import { agentSessionDigest, requirePersonChannel } from './person.js';import { bindLocalSession, localSessionMatches } from './agent-session.js';- import { decisionProjection, planRowApply, prepareRowDecisions, restoreRowApply, writeRowApply } from './row-decisions.js';+ import { decisionAnswer, decisionProjection, handAnsweredQuestions, pendingAnswers, planRowApply, prepareRowDecisions, restoreRowApply, writeRowApply } from './row-decisions.js';import { digestOf, gateReport, refuseSandboxBlocked, runGate, runProfiledShell, runSubmitGate, submitGateReport, timingDigest, withGateSlot } from './gate.js';import { checkNeedsBrowser } from './browser-admission.js';+import { submitInvariantLine } from './submit-invariants.js';+import { submitInvariantProposals } from './submit-invariants.js';import { bareWorktreeFinding, codeIsFromMain, contains, differFromHead, git, gitChildEnv, headCommit, headTree, invalidateGitFacts, isClean, mainCheckout, patchId, repoInfo, resolveCommit, tryGit, untracked, withGitFacts } from './git.js';import {FIX_NOTE,diff --cc src/engine.jsindex a3dbdb31,8be6dc97..39ee279e--- a/src/engine.js+++ b/src/engine.js@@@ -23,11 -24,11 +25,13 @@@ export const ENGINE_OPERATIONS = Object/** Engine version at which each ordered operation first has stable replay semantics. */const OPERATION_ENGINE = Object.freeze({ reopen: 8, recordLandingBatch: 8, recordLandingWaiver: 8, recordLandingFlake: 8, finishLandingBatch: 8 });- /** Dependency edits add engine-10 meaning without changing ordinary historical edit envelopes. */-/** Dependency edits add engine-10 meaning, edit reasons engine-19 and implied items engine-20, without changing ordinary historical envelopes. */++/** Dependency edits add engine-10 meaning, edit reasons engine-19, implied items engine-20 and submission proofs engine-22, without changing ordinary historical envelopes. */function minimumOperationEngine(operation, args) {const options = args[1];+ if (operation === 'submit' && options?.submissionProof !== undefined+ || operation === 'recordLandingBatch' && args[0]?.batch?.invariantEvidence !== undefined) return SUBMISSION_PROOF_ENGINE;+ if (carriesImplies(operation, args)) return IMPLIES_ENGINE;+ if (carriesBarReason(operation, args)) return BAR_ENGINE;return operation === 'editItem' && options && Object.hasOwn(options, 'after') && options.after !== undefined? 10 : OPERATION_ENGINE[operation] ?? 1;}diff --cc src/machine.jsindex 54ff8c05,227bc125..b7214766--- a/src/machine.js+++ b/src/machine.js@@@ -10,7 -10,7 +10,7 @@@*//** Executable move semantics, carried by every sealed move and retained during replay [H16]. */- export const ENGINE_VERSION = 17;-export const ENGINE_VERSION = 20;++export const ENGINE_VERSION = 22;/** @typedef {'agent' | 'coordinator' | 'clock'} Role */@@@ -140,7 -140,6 +140,7 @@@ export const GUARDS ={ id: 'reviewCooldownElapsed', refuse: 'REVIEW_COOLDOWN', rule: 'the reviewer has not released this submission within the past hour', next: 'let another reviewer take it, or wait an hour or for a new submission', source: 'board', when: 'engine 5 or newer, only for the same reviewer and current submission' },{ id: 'noteGiven', refuse: 'NOTE_REQUIRED', rule: 'the move carries a note: what failed, what was tried, or why', next: '--note "..." or --note-file <file>', source: 'board' },{ id: 'notMerged', refuse: 'ALREADY_MERGED', rule: 'the item has no recorded merge receipt', next: 'a merged item cannot be reopened', source: 'board' },- { id: 'submissionProofValid', refuse: 'SUBMISSION_PROOF', rule: 'recorded test selection names literal project files and its full-fallback policy', next: 'rerun submit with the current CLI', source: 'board', when: 'engine 17 or later; absent legacy selection remains unknown' },++ { id: 'submissionProofValid', refuse: 'SUBMISSION_PROOF', rule: 'recorded test selection names literal project files and its full-fallback policy', next: 'rerun submit with the current CLI', source: 'board', when: 'engine 22 or later; absent legacy selection remains unknown' },{ id: 'landingFailureRecorded', refuse: 'LANDING_FAILURE_REQUIRED', rule: 'a verified item note names the failing test and landing merge commit', next: 'cite the recorded batch, or name the test and merge commit in a manual note', source: 'board' },];diff --cc src/submit-invariants.jsindex aad32b8c,00000000..42457f83mode 100644,000000..100644--- a/src/submit-invariants.js+++ b/src/submit-invariants.js@@@ -1,159 -1,0 +1,159 @@@+/** Read-only submit-invariant proposals from recorded selection and exact-commit evidence [C7,V4]. */+import { Refused } from './refused.js';+import { isAbsolute } from 'node:path';+import { relative } from 'node:path';+- export const SUBMISSION_PROOF_ENGINE = 17;++export const SUBMISSION_PROOF_ENGINE = 22;+const BUDGET_MS = 60_000;+const COMMIT = /^[a-f0-9]{40,64}$/u;++/** Accept only literal project-relative paths that can be displayed and configured safely. */+function projectFile(value) {+ return typeof value === 'string' && value.length > 0 && value.length <= 4096+ && !/[:\\\p{Cc}\p{Zl}\p{Zp}]/u.test(value)+ && value.split('/').every(part => part && part !== '.' && part !== '..');+}++/** Normalize a versioned selection receipt; absent legacy receipts remain unknown. */+export function submissionProof(value) {+ if (value === undefined) return undefined;+ if (!value || value.version !== 1 || typeof value.full !== 'boolean'+ || typeof value.deferred !== 'boolean' || typeof value.reason !== 'string'+ || value.reason.length > 8192 || !Array.isArray(value.files) || value.files.some(file => !projectFile(file))) {+ throw new Refused('SUBMISSION_PROOF', 'a submission proof needs its version, selected project files, full-fallback reason and deferred flag; rerun submit with the current CLI');+ }+ return { version: 1, files: [...new Set(value.files)].sort(), full: value.full,+ deferred: value.deferred, reason: value.reason };+}++/** Accept only measured finite nonnegative durations; unavailable is always null. */+function duration(value) { return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : null; }++/** Retain printed whole-file timings only; never sum case bodies into a file runtime. */+export function landingFileTimes(root, profile) {+ return (profile?.files ?? []).flatMap(file => {+ if (typeof file?.path !== 'string') return [];+ const path = (isAbsolute(file.path) ? relative(root, file.path) : file.path).replace(/^\.\//u, '');+ return projectFile(path) && duration(file.durationMs) !== null ? [{ path, durationMs: file.durationMs }] : [];+ });+}++/** Validate canonical landing evidence before a move can change the board. */+export function invariantEvidence(value) {+ if (value === undefined) return undefined;+ /** Raise a typed refusal before malformed evidence can reach the canonical event log. */+ const bad = () => { throw new Refused('LAND_EVIDENCE', 'landing invariant evidence needs exact commits, participating submissions and literal test files; rerun land with the current CLI'); };+ if (!value || value.version !== 1 || !Array.isArray(value.gates) || !Array.isArray(value.diagnostics)) bad();+ const gates = value.gates.map(gate => {+ if (!gate || !COMMIT.test(gate.commit ?? '') || typeof gate.isGreen !== 'boolean'+ || !Array.isArray(gate.submissions) || !Array.isArray(gate.failures) || !Array.isArray(gate.fileTimes)) bad();+ if (gate.submissions.some(row => !Number.isSafeInteger(row?.id) || row.id < 1 || !COMMIT.test(row.commit ?? ''))+ || gate.failures.some(file => !projectFile(file))+ || gate.fileTimes.some(row => !projectFile(row?.path) || row.durationMs !== null && duration(row.durationMs) === null)) bad();+ return { commit: gate.commit, isGreen: gate.isGreen,+ submissions: gate.submissions.map(row => ({ id: row.id, commit: row.commit })),+ failures: [...new Set(gate.failures)].sort(),+ fileTimes: gate.fileTimes.map(row => ({ path: row.path, durationMs: row.durationMs })) };+ });+ const diagnostics = value.diagnostics.map(row => {+ if (!row || !COMMIT.test(row.commit ?? '') || !projectFile(row.test) || typeof row.isGreen !== 'boolean'+ || row.wallMs !== null && duration(row.wallMs) === null) bad();+ return { commit: row.commit, test: row.test, isGreen: row.isGreen, wallMs: row.wallMs };+ });+ return { version: 1, gates, diagnostics };+}++/** Propose escaped files without inspecting mutable logs, inferring legacy coverage or editing config. */+export function submitInvariantProposals(events, config) {+ if (config.submitGate !== 'landing') return [];+ const selections = new Map();+ for (const event of events) {+ if (event.event_kind !== 'submit') continue;+ const detail = JSON.parse(event.event_detail);+ if (detail.submissionProof) selections.set(`${event.item_id}:${detail.commit}`, detail.submissionProof);+ }+ const gates = [];+ const diagnostics = [];+ const seen = new Set();+ for (const event of events) {+ if (event.event_kind !== 'landing_batch') continue;+ const { batch } = JSON.parse(event.event_detail);+ if (!batch?.invariantEvidence) continue;+ for (const [kind, target] of [['gates', gates], ['diagnostics', diagnostics]]) {+ batch.invariantEvidence[kind].forEach((row, index) => {+ const identity = `${batch.id}:${kind}:${index}`;+ if (seen.has(identity)) return;+ seen.add(identity);+ target.push({ ...row, order: event.event_id });+ });+ }+ }+ const proposals = new Map();+ for (const gate of gates) {+ if (gate.isGreen) continue;+ for (const file of gate.failures) {+ if ((config.submitInvariants ?? []).includes(file)) continue;+ if (gates.some(other => other.commit === gate.commit && other.isGreen && other.order >= gate.order)+ || diagnostics.some(row => row.commit === gate.commit && row.test === file && row.isGreen && row.order >= gate.order)) continue;+ const outside = gate.submissions.filter(row => {+ const proof = selections.get(`${row.id}:${row.commit}`);+ return proof && !(proof.full && !proof.deferred) && !proof.files.includes(file);+ });+ if (!outside.length) continue;+ const entry = proposals.get(file) ?? { file, merges: new Set(), runtimes: [], submissions: new Map() };+ entry.merges.add(gate.commit);+ for (const row of outside) entry.submissions.set(`${row.id}:${row.commit}`, row);+ for (const row of gate.fileTimes) if (row.path === file && duration(row.durationMs) !== null) entry.runtimes.push(row.durationMs);+ for (const row of diagnostics) if (row.commit === gate.commit && row.test === file && duration(row.wallMs) !== null) entry.runtimes.push(row.wallMs);+ proposals.set(file, entry);+ }+ }+ return [...proposals.values()].map(entry => {+ const runtimeMs = entry.runtimes.length ? Math.max(...entry.runtimes) : null;+ return { file: entry.file, escapes: entry.merges.size, runtimeMs, budgetMs: BUDGET_MS,+ withinBudget: runtimeMs === null ? null : runtimeMs < BUDGET_MS,+ commits: [...entry.merges].sort(), submissions: [...entry.submissions.values()].sort((a, b) => a.id - b.id || a.commit.localeCompare(b.commit)) };+ }).sort((a, b) => Number(b.escapes >= 2 && b.withinBudget === true) - Number(a.escapes >= 2 && a.withinBudget === true)+ || Number(b.withinBudget === true) - Number(a.withinBudget === true) || b.escapes - a.escapes || a.file.localeCompare(b.file));+}++/** Render a proposal with its measured budget and the explicit human-controlled next step. */+export function submitInvariantLine(proposal) {+ const runtime = proposal.runtimeMs === null ? 'unmeasured' : `${(proposal.runtimeMs / 1000).toFixed(2)} s`;+ const budget = proposal.withinBudget === null ? '' : proposal.withinBudget ? ' (within budget)' : ' (over budget)';+ return `submit invariant proposal: ${proposal.file}; ${proposal.escapes} escaped merge(s); runtime ${runtime} / 60 s${budget}; edit submitInvariants on main to accept`;+}++/** 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', '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 ?? ''))+ || typeof batch.owner !== 'string' || !batch.owner || typeof batch.logPath !== 'string' || !batch.logPath+ || !Number.isSafeInteger(revision) || revision < 0) {+ throw new Refused('LAND_BATCH', 'a landing batch needs its exact base, tip, items, state, owner and log path; run pullboard land');+ }+}+- /** Preserve earlier normalized gate and diagnostic receipts when an engine-17 batch is adopted. */++/** Preserve earlier normalized gate and diagnostic receipts when an engine-22 batch is adopted. */+export function preserveInvariantEvidence(previous, evidence, engine) {+ if (previous?.invariantEvidence && engine >= SUBMISSION_PROOF_ENGINE) {+ for (const kind of ['gates', 'diagnostics']) {+ if (!evidence || JSON.stringify(evidence[kind].slice(0, previous.invariantEvidence[kind].length)) !== JSON.stringify(previous.invariantEvidence[kind])) {+ throw new Refused('LAND_EVIDENCE', 'recorded landing evidence is append-only; preserve earlier gate and diagnostic receipts when adopting');+ }+ }+ }+}++/** Keep the original revision, terminal-state and immutable batch-identity guards together. */+export function validateLandingRevision(previous, batch, revision) {+ if ((previous?.revision ?? 0) !== revision || previous?.state === 'landed') {+ throw new Refused('LAND_MOVED', 'the landing batch changed; read pullboard resume and adopt its current revision');+ }+ if (previous && (previous.base !== batch.base || previous.root !== batch.root || previous.branch !== batch.branch)) {+ throw new Refused('LAND_BATCH', 'a batch keeps its original base and landing worktree; adopt it with pullboard land --adopt');+ }+}diff --cc test/agent-model-engine.test.jsindex e85e2e8d,c45f64d4..6b4785a4--- a/test/agent-model-engine.test.js+++ b/test/agent-model-engine.test.js@@@ -11,7 -11,7 +11,7 @@@ import { tmpdir } from 'node:os'import { join } from 'node:path';test('model declarations and event snapshots retain engines 1 through 11 semantics [O8,O3,H16]', (t) => {- assert.equal(ENGINE_VERSION, 12, 'engine 12 preserves the released engine-8 through engine-11 model behavior');- assert.equal(ENGINE_VERSION, 20, 'engine 20 preserves the released engine-8 through engine-11 model behavior');++ assert.equal(ENGINE_VERSION, 22, 'engine 22 preserves the released engine-8 through engine-11 model behavior');for (const version of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ENGINE_VERSION]) {const board = store.openBoard(':memory:');t.after(() => store.closeBoard(board));diff --cc test/pending-refreeze.test.jsindex 15ad01aa,d5297661..07465ae2--- a/test/pending-refreeze.test.js+++ b/test/pending-refreeze.test.js@@@ -261,7 -261,7 +261,7 @@@ async function checkDependencyLegacyCli}test('dependency edits replay the same on every engine [B3,V2,H16]', async (t) => {- assert.equal(ENGINE_VERSION, 12);- assert.equal(ENGINE_VERSION, 20);++ assert.equal(ENGINE_VERSION, 22);const directory = mkdtempSync(join(tmpdir(), 'pullboard-dependency-engines-'));const cleanup = [];t.after(() => {