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
chore(merge): integrate stale verdicts with main [E8,H16]
Corey Olson5aef125533d2
diff --cc docs/lifecycle.mdindex c48d8443,4d6325e6..e391ddb7--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@@ -56,10 -54,10 +56,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), 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), 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 | 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), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), 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) |- | reject | submitted, verified | 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), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED) |-| 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 | 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), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), 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, verified | 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), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), 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) || 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) |@@@ -122,8 -120,10 +122,10 @@@| NO_POLICY | the candidate merges cleanly into the current primary branch without changing an index or worktree | restore the primary repository metadata || NO_TRUNK | the candidate merges cleanly into the current primary branch without changing an index or worktree | check out the trunk branch in the main checkout once and run pullboard inbox || STACKED_ON_UNVERIFIED | the candidate range contains no other item's unverified submitted commit | wait for that item to be accepted, or rebuild without its commits |+ | RATCHET_ROSE | every touched doctrine check counts (exit 0 or 1), none rises above its committed count and no changed file gains a problem; watch-mode rules only count, only when accepted main has an approved doctrine rule with gate: check | fix the new problems, commit, submit again; only the person's signature raises count: |+ | RATCHET_UNCOUNTED | every touched doctrine check counts (exit 0 or 1), none rises above its committed count and no changed file gains a problem; watch-mode rules only count, only when accepted main has an approved doctrine rule with gate: check | fix the check so it exits 0 or 1 within its timeout, then submit again |-| CHECK_RED | the frozen item check passes at the exact submitted commit | reject the failing behavior; the builder fixes and resubmits |-| CHECK_UNVERIFIED | the frozen item check passes at the exact submitted commit | restore the frozen install or check environment and retry |+| CHECK_RED | the frozen item check passes at the submitted commit, or its clean reviewed composition for a stale acceptance | reject the failing behavior; the builder fixes and resubmits |+| CHECK_UNVERIFIED | the frozen item check passes at the submitted commit, or its clean reviewed composition for a stale acceptance | restore the frozen install or check environment and retry || GATE_RED | the gate, which submit runs itself every time, is green at HEAD | fix what the digest names, commit, submit again || PIPEFAIL_UNAVAILABLE | the gate, which submit runs itself every time, is green at HEAD | rewrite the gate without a pipe || MOVED_DURING_GATE | when the gate ends, HEAD and every tracked file are as they were when it started | leave the worktree alone until the gate finishes, then submit again |diff --cc src/cli.jsindex 0bd7568a,7c289e1f..f0a8ea78--- a/src/cli.js+++ b/src/cli.js@@@ -2402,7 -2425,9 +2437,10 @@@ async function verifyHere(ctx, id, { seif (!decision) throw new Refused('USAGE', 'pullboard verify <id> accept, or reject --reason CODE --note "..."');const { root } = ctx.info;let verificationProfile = null;- const result = await withBoard(ctx, async (board) => {+ let accepted = null;++ let acceptedLandingCommit = null;+ /** Record one verdict on the open board. */+ const decide = async (board) => {checkMainVerifier(ctx, board, values);const me = whoAmI(ctx, board);const recovered = relayRecovered(root);@@@ -2442,20 -2464,11 +2480,21 @@@}if (decision === 'ACCEPT') {if (digest !== item.item_frozen_digest) throw new Refused('CRITERIA_CHANGED', 'the criterion changed; ask the coordinator to refreeze this item before checking it');- const trunk = requireTrunkMerge(root, commit);- refuseUnverifiedStack(root, board, item, commit, trunk);- const browser = !browserFreeChecksEnabled() || await checkNeedsBrowser(root, frozenCheck(item), { commit, onFallback: browserAdmissionReporter(ctx.io, ctx.io.relayJson) });- check = await withGateSlot(root, (lease) => checkAtCommit(root, item, { waitMs: lease.waitMs, gateLease: lease }), { browser, agent: me.id, item: String(id), kind: 'review', itemCheck: true, onWait: gateWaitReporter(ctx.io) });+ const checkedCommit = reReview ? head : commit;+ const checkedLabel = reReview ? 'reviewed composition' : 'submitted commit';+ const trunk = requireTrunkMerge(root, checkedCommit);+ if (reReview) {+ if (!isClean(root)) throw new Refused('DIRTY', 'commit the reviewed composition before re-reviewing the stale verdict');+ if (untracked(root).length) throw new Refused('UNTRACKED', 'commit or ignore untracked files before re-reviewing the stale verdict');+ if (!contains(root, trunk.commit, head)) throw staleVerdictRefusal(item, stale);+ }+ review = captureVerdictReview(root, board, item, trunk.commit, checkedCommit);+ refuseUnverifiedStack(root, board, item, checkedCommit, trunk);+ const checkedItem = reReview ? { ...item, item_commit: checkedCommit } : item;+ const browser = !browserFreeChecksEnabled() || await checkNeedsBrowser(root, frozenCheck(item), { commit: checkedCommit, onFallback: browserAdmissionReporter(ctx.io, ctx.io.relayJson) });+ check = await withGateSlot(root, (lease) => checkAtCommit(root, checkedItem, { waitMs: lease.waitMs, gateLease: lease }), { browser, agent: me.id, item: String(id), kind: 'review', itemCheck: true, onWait: gateWaitReporter(ctx.io) });+ invalidateGitFacts(); // A private check can outlive changes in the reviewer's live checkout.+ refuseSandboxBlocked(check);verificationProfile = check.profile ?? null;const evidence = check.checked? `\nlast output lines (up to 40):\n${(check.outputTail ?? '(no output)').split('\n').map((line) => ` ${line}`).join('\n')}\nfull output file: ${check.outputPath ?? `(unavailable${check.outputError ? `: ${check.outputError}` : ''})`}`@@@ -2484,9 -2491,13 +2523,17 @@@digest,policy: ctx.config.verify.policy,familyPolicy: ctx.config.verify.family,+ review,...(decision === 'ACCEPT' ? { check: check.checked ? 'green' : 'none' } : {}),}]);+ };+ const result = await withBoard(ctx, async (board) => {+ const verdict = await decide(board);- if (verdict.decision === 'ACCEPT') accepted = store.getItem(board, id);++ if (verdict.decision === 'ACCEPT') {++ accepted = store.getItem(board, id);++ acceptedLandingCommit = store.checkedLandingCommit(board, accepted);++ }+ return verdict;});ctx.io.result?.({ id, ...result });const verifiedSummary = timingDigest(verificationProfile);@@@ -2494,9 -2505,73 +2541,74 @@@ctx.io.say(result.decision === 'ACCEPT'? `verified #${id}: ${result.reason}${result.check === 'none' ? '; no frozen check ran' : ''}${verifiedTiming}`: `rejected #${id}: ${result.reason}; it is open again for rework`);- if (accepted) ctx.io.say(landNext(ctx.info, accepted));++ if (accepted) ctx.io.say(landNext(ctx.info, accepted, acceptedLandingCommit));return 0;}+ /**+ * Say the exact command that lands an accepted item in this repo [B3].+ * A repo with a push remote lands through pullboard land; one without merges by hand,+ * because pullboard land would refuse LAND_PUSH there.+ *+ * @param {any} info+ * @param {any} item++ * @param {string} [commit] - The exact checked composition the acceptance authorizes.+ * @returns {string}+ */-function landNext(info, item) {++function landNext(info, item, commit = item.item_commit) {+ const mainRoot = primaryCheckoutRoot(info);+ const branch = mainCheckout(info.root)?.branch ?? '';+ const remote = landingRemote(info.root, branch);+ const command = remote+ ? 'pullboard land'- : `git merge --no-ff ${item.item_commit} -m ${shellWord(landingSubject(item))} && pullboard merged ${item.item_id} HEAD`;++ : `git merge --no-ff ${commit} -m ${shellWord(landingSubject(item))} && pullboard merged ${item.item_id} HEAD`;+ if (!mainRoot) return `next: could not safely locate the primary checkout; run from the main checkout: ${command}`;+ if (remote) return `next: the coordinator lands it: ${cdTo(mainRoot)} ${command}`;+ return `next: this repo has no remote for pullboard land to push to, so the coordinator merges it on ${branch.replace(/^refs\/heads\//u, '') || 'the trunk'}: ${cdTo(mainRoot)} ${command}`;+ }++ /** Resolve a usable primary checkout without trusting the Git metadata directory as a path. */+ function primaryCheckoutRoot(info) {+ if (info.isMain) return info.root;+ let commonDir;+ try { commonDir = realpathSync.native(info.commonDir); }+ catch { return null; }+ /** Return unique validated primary checkouts among candidate repository paths.+ *+ * @param {string[]} candidates+ * @returns {string[]}+ */+ const matches = (candidates) => {+ const roots = new Map();+ for (const candidate of candidates) {+ if (typeof candidate !== 'string' || !isAbsolute(candidate)) continue;+ try {+ const result = tryGit(candidate, ['rev-parse', '--path-format=absolute', '--show-toplevel', '--git-dir', '--git-common-dir']);+ const fields = result.stdout.split('\n');+ if (result.status !== 0 || fields.length !== 3 || fields.some((field) => !field)) continue;+ const [root, gitDir, candidateCommonDir] = fields;+ if (!existsSync(join(root, '.git'))+ || realpathSync.native(candidateCommonDir) !== commonDir+ || realpathSync.native(gitDir) !== realpathSync.native(candidateCommonDir)) continue;+ roots.set(realpathSync.native(root), root);+ } catch { /* A stale registry entry or Git metadata directory is not a usable checkout. */ }+ }+ return [...roots.values()];+ };+ const worktrees = tryGit(info.root, ['worktree', 'list', '--porcelain', '-z']);+ if (worktrees.status === 0) {+ const candidates = worktrees.stdout.split('\0')+ .filter((field) => field.startsWith('worktree '))+ .map((field) => field.slice('worktree '.length));+ const found = matches(candidates);+ if (found.length === 1) return found[0];+ }+ const registered = registeredProjectRootsSnapshot();+ if (registered === null) return null;+ const found = matches(registered);+ return found.length === 1 ? found[0] : null;+ }+/*** One loop of `next`: claim the next free item, or reserve the next review (V15). A claim that loses* a race to another agent is not an error; the caller looks again. A review is looked for anddiff --cc src/land.jsindex 8b39453a,e5e12876..5778ba89--- a/src/land.js+++ b/src/land.js@@@ -241,14 -328,7 +345,14 @@@ function requirePushTarget(root, branch/** Push the exact gated tip before recording receipts, then fast-forward only a clean unchanged main. */async function publish(state) {let batch = state.batch;+ for (const entry of batch.items) {+ const item = store.getItem(state.board, entry.id);+ if (item.item_status !== 'verified' || item.item_commit !== entry.commit+ || store.checkedLandingCommit(state.board, item) !== (entry.reviewedCommit ?? entry.commit)) {+ throw new Refused('LAND_ITEM_MOVED', `item #${entry.id} changed its checked composition; rebuild the landing before publishing`);+ }+ }- const remote = tryGit(state.root, ['config', '--get', `branch.${batch.branch.replace(/^refs\/heads\//u, '')}.remote`]).stdout || 'origin';+ const remote = requirePushTarget(state.root, batch.branch);if (batch.proof?.failures?.length && batch.state !== 'pushed') {const failures = batch.proof.failures.map((failure) => ({ ...failure, waiver: store.landingWaiverFor(state.board, failure)?.id }));if (!failures.every((failure) => failure.waiver)) throw new Refused('LAND_WAIVER', 'the landing proof has an expired or missing person waiver; ask the person for a new expiring waiver, then adopt the batch');@@@ -286,12 -366,11 +390,13 @@@ export async function land({ root, boarif (!trunk?.commit) throw new Refused('LAND_TRUNK', 'landing needs the coordinator’s primary branch; return its checkout to the trunk');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');+ if (!selected.ready.length && stale) throw staleVerdictRefusal({ item_id: stale.id }, stale);if (dryRun) {+ if (selected.ready.length) requirePushTarget(root, trunk.branch);const conflicts = [];for (const item of selected.ready) {- const merge = tryGit(root, ['merge-tree', '--write-tree', '--name-only', '-z', trunk.commit, item.item_commit]);+ const merge = tryGit(root, ['merge-tree', '--write-tree', '--name-only', '-z', trunk.commit, item.item_landing_commit]);if (merge.status === 1) {const parts = merge.stdout.split('\0').slice(1);const end = parts.indexOf('');diff --cc src/machine.jsindex 0134846f,71b60afe..21e84bd1--- a/src/machine.js+++ b/src/machine.js@@@ -124,7 -121,8 +125,8 @@@ export const GUARDS ={ id: 'withinLane', refuse: 'OUTSIDE_LANE', alsoRefuses: [{ code: 'NO_POLICY', next: 'restore the claim base or ask the coordinator to refreeze' }, { code: 'BAD_CONFIG', next: 'restore the committed coordinator configuration' }, { code: 'GIT_GRAFTS', next: 'ask the coordinator to remove the Git graft file before retrying' }], rule: 'the full claimed diff respects committed coordinator ownership', next: 'restore foreign paths or shout their owner', source: 'cli' },{ id: 'trunkMergeClean', refuse: 'MERGE_CONFLICT', alsoRefuses: [{ code: 'MERGE_CHECK_FAILED', next: 'use Git 2.38 or newer, restore its objects and retry' }, { code: 'NO_POLICY', next: 'restore the primary repository metadata' }, { code: 'NO_TRUNK', next: 'check out the trunk branch in the main checkout once and run pullboard inbox' }], rule: 'the candidate merges cleanly into the current primary branch without changing an index or worktree', next: 'merge the trunk into your branch, resolve conflicts, commit and resubmit', source: 'cli' },{ id: 'noUnverifiedStack', refuse: 'STACKED_ON_UNVERIFIED', rule: "the candidate range contains no other item's unverified submitted commit", next: 'wait for that item to be accepted, or rebuild without its commits', source: 'cli' },+ { id: 'doctrineHolds', refuse: 'RATCHET_ROSE', alsoRefuses: [{ code: 'RATCHET_UNCOUNTED', next: 'fix the check so it exits 0 or 1 within its timeout, then submit again' }], rule: "every touched doctrine check counts (exit 0 or 1), none rises above its committed count and no changed file gains a problem; watch-mode rules only count", next: "fix the new problems, commit, submit again; only the person's signature raises count:", source: 'cli', when: 'only when accepted main has an approved doctrine rule with gate: check' },- { id: 'itemCheckGreen', refuse: 'CHECK_RED', alsoRefuses: [{ code: 'CHECK_UNVERIFIED', next: 'restore the frozen install or check environment and retry' }], rule: 'the frozen item check passes at the exact submitted commit', next: 'reject the failing behavior; the builder fixes and resubmits', source: 'cli' },+ { id: 'itemCheckGreen', refuse: 'CHECK_RED', alsoRefuses: [{ code: 'CHECK_UNVERIFIED', next: 'restore the frozen install or check environment and retry' }], rule: 'the frozen item check passes at the submitted commit, or its clean reviewed composition for a stale acceptance', next: 'reject the failing behavior; the builder fixes and resubmits', source: 'cli' },{ id: 'gateGreen', refuse: 'GATE_RED', alsoRefuses: [{ code: 'PIPEFAIL_UNAVAILABLE', next: 'rewrite the gate without a pipe' }], rule: 'the gate, which submit runs itself every time, is green at HEAD', next: 'fix what the digest names, commit, submit again', source: 'cli' },{ id: 'treeStillDuringGate', refuse: 'MOVED_DURING_GATE', rule: 'when the gate ends, HEAD and every tracked file are as they were when it started', next: 'leave the worktree alone until the gate finishes, then submit again', source: 'cli' },@@@ -170,13 -166,15 +172,15 @@@ export const MOVES =sets: ['item_review_by', 'item_review_until'], command: 'pullboard next --verify',},{- verb: 'accept', from: ['submitted'], to: 'verified', by: ['agent', 'coordinator'], refuse: 'NOT_SUBMITTED',- guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonIsMet', 'trunkMergeClean', 'noUnverifiedStack', 'itemCheckGreen', 'proofNoted'],+ verb: 'accept', from: ['submitted', 'verified'], to: 'verified', by: ['agent', 'coordinator'], refuse: 'NOT_SUBMITTED',+ guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notMerged', 'verdictReviewRecorded', 'reviewTreeCurrent', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonIsMet', 'trunkMergeClean', 'noUnverifiedStack', 'itemCheckGreen', 'proofNoted'],+ alsoRefuses: [{ code: 'LAND_HEADER', rule: 'a displayed merge command fits the commit-header limit', next: 'shorten the item title or cited rows so the merge header fits' }],sets: ['item_verified_by'], command: 'pullboard verify <id> accept --note "..."',},{- verb: 'reject', from: ['submitted'], to: 'open', by: ['agent', 'coordinator'], refuse: 'NOT_SUBMITTED',- guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonCoded', 'noteGiven'],+ verb: 'reject', from: ['submitted', 'verified'], to: 'open', by: ['agent', 'coordinator'], refuse: 'NOT_SUBMITTED',+ guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notMerged', 'verdictReviewRecorded', 'reviewTreeCurrent', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonCoded', 'noteGiven'],+ alsoRefuses: [{ code: 'LAND_HEADER', rule: 'a displayed merge command fits the commit-header limit', next: 'shorten the item title or cited rows so the merge header fits' }],command: 'pullboard verify <id> reject --reason CODE --note "..."',},{diff --cc test/machine.test.jsindex 8388ece4,fc0aada7..e560fe07--- a/test/machine.test.js+++ b/test/machine.test.js@@@ -836,10 -838,10 +838,10 @@@ test('pullboard help lists each role\'/** Guards checked before the explicit transition: CLI facts and optional roadmap selection. */const PRECHECKED = {claim: ['joined'],- submit: ['joined', 'criterionUnchanged', 'treeClean', 'nothingUntracked', 'hasCommit', 'withinLane', 'trunkMergeClean', 'gateConfigured', 'gateGreen', 'treeStillDuringGate', 'noUnverifiedStack'],+ submit: ['joined', 'criterionUnchanged', 'treeClean', 'nothingUntracked', 'hasCommit', 'withinLane', 'trunkMergeClean', 'doctrineHolds', 'gateConfigured', 'gateGreen', 'treeStillDuringGate', 'noUnverifiedStack'],reserve: ['coordinatorSaysAs', 'joined', 'roadmapReadable'],- accept: ['coordinatorSaysAs', 'joined', 'atSubmittedCommit', 'trunkMergeClean', 'itemCheckGreen', 'noUnverifiedStack'],- reject: ['coordinatorSaysAs', 'joined', 'atSubmittedCommit'],+ accept: ['coordinatorSaysAs', 'joined', 'atSubmittedCommit', 'reviewTreeCurrent', 'trunkMergeClean', 'itemCheckGreen', 'noUnverifiedStack'],+ reject: ['coordinatorSaysAs', 'joined', 'atSubmittedCommit', 'reviewTreeCurrent'],};/**diff --cc test/team.test.jsindex afc99b5e,00000000..e1f53a7cmode 100644,000000..100644--- a/test/team.test.js+++ b/test/team.test.js@@@ -1,324 -1,0 +1,325 @@@+/** Two independent Git/SQLite replicas derive verdict freshness without rewriting proof [E8]. */+import assert from 'node:assert/strict';+import childProcess from 'node:child_process';+import { syncBuiltinESMExports } from 'node:module';+import { existsSync, readFileSync, writeFileSync, rmSync } from 'node:fs';+import { join } from 'node:path';+import { after, test } from 'node:test';+import * as store from '../src/board.js';+import { exportBoard, importBoard } from '../src/exchange.js';+import { applyEngineMove, prepareEngineMove } from '../src/engine.js';+import { createE2eHelpers } from './e2e-helpers.js';+import { serveApi } from '../src/api.js';+import { main } from '../src/cli.js';+import { fetchFresh } from './http-fixture.js';+import { relaySnapshot, presentationDigest } from '../src/relay-presentation.js';+import { snapshotState } from '../relay/browser-model.js';++const helpers = createE2eHelpers();+after(helpers.cleanup);++/** 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'));+ try { return action(board); }+ finally { store.closeBoard(board); }+}++/** Run a real fixture CLI command, retaining the refusal or successful document verbatim. */+function run(box, root, ...args) {+ const result = box.run(root, ...args);+ assert.equal(result.code, 0, `${args.join(' ')}: ${result.err}${result.out}`);+ return result.out;+}++test('a verdict reads stale when main moves under its files [E8]', { timeout: 120_000 }, async t => { // budget: hang ceiling for two real replicas, CLI checks and Git history; not a speed target.+ const box = helpers.project();+ assert.equal(helpers.commitFile(box, box.repo, 'web/feature.js', 'feature = 0\nmain = 0\n', 'feat(web): baseline [G1]').status, 0);+ box.git(box.web, 'merge', '-q', '--ff-only', 'main');+ const checkedHeads = join(box.dir, 'checked-heads');+ const check = `grep -q '^feature = 1$' web/feature.js && git rev-parse HEAD >> '${checkedHeads}'`;+ run(box, box.repo, 'add', 'web', 'Feature', '--specs', 'G1', '--check', check, '--wait');+ run(box, box.web, 'claim', '1');+ assert.equal(helpers.commitFile(box, box.web, 'web/feature.js', 'feature = 1\nmain = 0\n', 'feat(web): feature [G1]').status, 0);+ const submitted = box.git(box.web, 'rev-parse', 'HEAD');+ run(box, box.web, 'submit', '1');+ const reviewer = join(box.dir, 'web-2');+ box.git(box.repo, 'worktree', 'add', '-q', '--detach', reviewer, submitted);+ run(box, reviewer, 'join', 'web');+ run(box, reviewer, 'verify', '1', 'accept', '--note', 'The feature changes its first line and the frozen check observes it.');+ const original = withBoard(box.repo, board => store.verdictsFor(board, 1));+ const mainEditor = join(box.dir, 'main-caller-editor');+ box.git(box.repo, 'worktree', 'add', '-q', '--detach', mainEditor, 'main');+ run(box, mainEditor, 'join', 'web');+ const peer = join(box.dir, 'replica');+ box.git(box.dir, 'clone', '-q', box.repo, peer);+ withBoard(peer, board => importBoard(board, withBoard(box.repo, exportBoard)));++ /** Move only the peer's Git trunk; its independently stored acceptance stays unchanged. */+ const syncTrunk = () => {+ box.git(peer, 'fetch', '-q', 'origin', 'main');+ box.git(peer, 'merge', '-q', '--ff-only', 'origin/main');+ };+ /** Read each replica through its actual public CLI, rather than a test-only freshness helper. */+ const items = () => [box.repo, peer].map(root => JSON.parse(run(box, root, 'show', '1', '--json')));+ let streamController;+ let streamReader;+ let builds = 0;+ const api = await serveApi({ runCommand: main, projects: () => [{ root: reviewer, name: 'Verdict fixture' }], onStateBuild: () => { builds += 1; } });+ t.after(async () => {+ streamController?.abort();+ await streamReader?.cancel().catch(() => {});+ await api.close();+ });+ const address = new URL(api.url);+ const headers = { 'x-pullboard-key': address.searchParams.get('k') };+ const apiPath = '/api/v1/boards/' + withBoard(box.repo, store.boardId);+ /** Read one authenticated public HTTP endpoint on the persistent worktree-backed server. */+ const http = async suffix => {+ const response = await fetchFresh(address.origin + apiPath + suffix, { headers });+ const document = await response.json();+ assert.equal(response.status, 200, JSON.stringify(document));+ return document;+ };+ const initialState = (await http('/state')).state;+ const phoneBefore = relaySnapshot(reviewer);+ await http('/state');+ assert.equal(builds, 1, 'unchanged HTTP reads reuse the state cache');+ await http('/items/1'); // Warm the independent detail freshness projection for a verified item.+ const processMethods = ['spawn', 'spawnSync', 'exec', 'execSync', 'execFile', 'execFileSync'];+ const originals = new Map(processMethods.map(method => [method, childProcess[method]]));+ const processCalls = [];+ try {+ for (const method of processMethods) childProcess[method] = function (...args) {+ processCalls.push({ method, command: args[0] });+ return Reflect.apply(originals.get(method), this, args);+ };+ syncBuiltinESMExports();+ await http('/items/1');+ await http('/state');+ await http('/items/1');+ relaySnapshot(reviewer);+ relaySnapshot(reviewer);+ assert.deepEqual(processCalls, [], 'unchanged accepted-item detail, state and sealed phone snapshot reads spawn no process');+ } finally {+ for (const [method, original] of originals) childProcess[method] = original;+ syncBuiltinESMExports();+ }++ assert.ok(items().every(item => !item.item_verdict_state));+ assert.equal(helpers.commitFile(box, mainEditor, 'web/unrelated.js', 'unrelated = 1\n', 'feat(web): unrelated [G1]').status, 0);+ box.git(box.repo, 'merge', '-q', '--no-ff', box.git(mainEditor, 'rev-parse', 'HEAD'), '-m', 'chore(merge): unrelated main change [G1]');+ syncTrunk();+ assert.ok(items().every(item => !item.item_verdict_state), 'unrelated main files do not stale acceptance');+ assert.equal((await http('/state')).state.items[0].verdictState, undefined);+ const beforeMoveHead = box.git(reviewer, 'rev-parse', 'HEAD');+ streamController = new AbortController();+ const stream = await fetchFresh(address.origin + apiPath + '/events?after=' + initialState.sequence, {+ headers: { ...headers, accept: 'text/event-stream' }, signal: streamController.signal,+ });+ assert.equal(stream.status, 200);+ streamReader = stream.body.getReader();+ box.git(mainEditor, 'merge', '-q', '--ff-only', 'main');+ assert.equal(helpers.commitFile(box, mainEditor, 'web/feature.js', 'feature = 0\nmain = 1\n', 'feat(web): change main caller [G1]').status, 0);+ box.git(box.repo, 'merge', '-q', '--no-ff', box.git(mainEditor, 'rev-parse', 'HEAD'), '-m', 'chore(merge): change main caller [G1]');+ const movingCommit = box.git(box.repo, 'rev-parse', 'HEAD');+ syncTrunk();+ for (const item of items()) {+ assert.equal(item.item_verdict_state?.code, 'STALE_VERDICT');+ assert.equal(item.item_verdict_state.file, 'web/feature.js');+ assert.equal(item.item_verdict_state.commit, movingCommit);+ assert.equal(item.item_verdict, 'ACCEPT', 'the historical acceptance remains a fact');+ }+ assert.equal(box.git(reviewer, 'rev-parse', 'HEAD'), beforeMoveHead, 'the served worktree HEAD stayed fixed while main moved');+ const apiStale = (await http('/state')).state;+ assert.equal(apiStale.sequence, initialState.sequence, 'Git movement needs no board event to invalidate the state cache');+ assert.equal(apiStale.items[0].verdictState?.code, 'STALE_VERDICT');+ assert.equal(apiStale.items[0].verdictState.commit, movingCommit);+ const coldGit = [];+ const originalSpawn = childProcess.spawnSync;+ let phoneStale;+ try {+ childProcess.spawnSync = function (...args) {+ if (args[0] === 'git') coldGit.push(args[1]);+ return Reflect.apply(originalSpawn, this, args);+ };+ syncBuiltinESMExports();+ phoneStale = relaySnapshot(reviewer);+ } finally { childProcess.spawnSync = originalSpawn; syncBuiltinESMExports(); }+ assert.ok(coldGit.filter(args => args.includes('diff')).length <= 1,+ 'unrelated main history must not start one file-diff process per commit: ' + JSON.stringify(coldGit));+ const phoneState = snapshotState(phoneStale, withBoard(box.repo, store.boardId));+ assert.equal(phoneState.items[0].verdictState?.commit, movingCommit, 'the sealed phone snapshot carries the same stale verdict at fixed served HEAD');+ assert.notEqual(presentationDigest(phoneBefore.presentation), presentationDigest(phoneStale.presentation), 'Git-only freshness changes cause a new sealed presentation');++ assert.equal((await http('/items/1')).item.verdictState?.commit, movingCommit);+ const streamDeadline = setTimeout(() => streamController.abort(new Error('trunk movement produced no live changed event')), 5_000); // budget: hang ceiling for a fixture-local change notification; no throughput claim.+ try {+ let buffered = '';+ while (!/event: changed\n/u.test(buffered)) {+ const { value, done } = await streamReader.read();+ assert.equal(done, false, 'the live stream stays open through the trunk change');+ buffered += new TextDecoder().decode(value);+ }+ } finally { clearTimeout(streamDeadline); }+ streamController.abort();+ await streamReader.cancel().catch(() => {});+ for (const root of [box.repo, peer]) {+ assert.match(run(box, root, 'show', '1'), /STALE_VERDICT/u);+ assert.equal(JSON.parse(run(box, root, 'list', '--all', '--json')).items[0].item_verdict_state?.commit, movingCommit);+ const resume = JSON.parse(run(box, root, 'resume', '--json'));+ assert.equal(resume.all[0].item_verdict_state?.commit, movingCommit);+ assert.deepEqual(resume.toMerge, [], 'resume never suggests landing a stale acceptance');+ assert.equal(resume.staleVerdicts[0].item_id, 1);+ assert.deepEqual(withBoard(root, board => store.verdictsFor(board, 1)), original, 'read projection cannot rewrite original proof');+ const refused = box.run(root, 'land', '--dry-run', '--json');+ assert.equal(refused.code, 1, refused.out + refused.err);+ const error = JSON.parse(refused.out).error;+ assert.equal(error.code, 'STALE_VERDICT');+ assert.ok(error.message.includes('web/feature.js') && error.message.includes(movingCommit), error.message);+ }+ box.git(box.repo, 'revert', '-m', '1', '--no-edit', movingCommit);+ syncTrunk();+ assert.ok(items().every(item => item.item_verdict_state?.commit === movingCommit), 'a revert cannot turn an old review into a new review');+ const priorChecks = readFileSync(checkedHeads, 'utf8');+ const oldHead = box.run(reviewer, 'verify', '1', 'accept', '--note', 'Trying the old candidate is insufficient.');+ assert.equal(oldHead.code, 1);+ assert.equal(readFileSync(checkedHeads, 'utf8'), priorChecks, 'old candidate is refused before running its check');+ box.git(reviewer, 'merge', '-q', '--no-edit', 'main');+ const composed = box.git(reviewer, 'rev-parse', 'HEAD');+ assert.notEqual(composed, submitted);- run(box, reviewer, 'verify', '1', 'accept', '--note', 'Re-reviewed the feature with the latest main caller and its reverted history.');++ const landingGuidance = run(box, reviewer, 'verify', '1', 'accept', '--note', 'Re-reviewed the feature with the latest main caller and its reverted history.');++ assert.ok(landingGuidance.includes('git merge --no-ff ' + composed), 'the new-main manual landing hint names the checked composition, not the original submission');+ assert.equal(readFileSync(checkedHeads, 'utf8').trim().split('\n').at(-1), composed, 'the frozen check ran on the reviewed composition');+ const reviewed = withBoard(box.repo, board => store.verdictsFor(board, 1));+ assert.deepEqual(reviewed.slice(0, original.length), original);+ assert.equal(reviewed.length, original.length + 1, 're-review appends independent proof');+ const verdict = reviewed.at(-1);+ const outcome = withBoard(peer, board => {+ const move = prepareEngineMove(board, 'verify', [1, {+ agentId: verdict.verdict_by, decision: 'ACCEPT', note: verdict.verdict_note,+ head: verdict.verdict_head, digest: verdict.verdict_digest, policy: 'any',+ check: verdict.check, review: verdict.review,+ }]);+ return applyEngineMove(board, move, { sequence: 1, at: verdict.verdict_at });+ });+ assert.equal(outcome.error, undefined, JSON.stringify(outcome));+ const reviewPin = `refs/pullboard/items/1/${composed.slice(0, 12)}`;+ assert.equal(box.git(box.repo, 'rev-parse', reviewPin), composed, 'the checked commit is pinned durably for other replicas to fetch');+ assert.equal(items()[1].item_verdict_state?.code, 'STALE_VERDICT', 'a replica without the checked Git objects fails closed');+ const peerBoardId = withBoard(peer, store.boardId);+ assert.equal(snapshotState(relaySnapshot(peer), peerBoardId).items[0].verdictState?.code, 'STALE_VERDICT',+ 'a sealed phone presentation also fails closed until the reviewed objects arrive');+ const peerApi = await serveApi({ runCommand: main, projects: () => [{ root: peer, name: 'Peer verdict fixture' }] });+ t.after(() => peerApi.close());+ const peerAddress = new URL(peerApi.url);+ /** Keep this peer's server alive across an object-only fetch without a board write. */+ const peerHttp = async suffix => {+ const response = await fetchFresh(peerAddress.origin + apiPath + suffix,+ { headers: { 'x-pullboard-key': peerAddress.searchParams.get('k') } });+ assert.equal(response.status, 200);+ return response.json();+ };+ assert.equal((await peerHttp('/state')).state.items[0].verdictState?.code, 'STALE_VERDICT');+ assert.equal((await peerHttp('/items/1')).item.verdictState?.code, 'STALE_VERDICT');+ box.git(peer, 'fetch', '-q', 'origin', reviewPin);+ assert.equal((await peerHttp('/items/1')).item.verdictState, undefined,+ 'an object-only fetch clears a cached unavailable HTTP detail');+ assert.equal((await peerHttp('/state')).state.items[0].verdictState, undefined,+ 'an object-only fetch clears a cached unavailable HTTP state');+ assert.equal(snapshotState(relaySnapshot(peer), peerBoardId).items[0].verdictState, undefined,+ 'fetching the exact reviewed objects clears the sealed phone presentation without another board event or main move');+ assert.ok(items().every(item => !item.item_verdict_state), 'the same sealed re-review clears both replicas');+ assert.equal((await http('/state')).state.items[0].verdictState, undefined, 'a newer acceptance invalidates stale cached state');+ assert.equal((await http('/items/1')).item.verdictState, undefined);+ assert.equal(snapshotState(relaySnapshot(reviewer), withBoard(box.repo, store.boardId)).items[0].verdictState, undefined, 'the sealed phone presentation clears after the checked re-review');+ assert.deepEqual(withBoard(peer, board => store.verdictsFor(board, 1)), reviewed);+ box.git(box.repo, 'merge', '-q', '--no-edit', composed);+ syncTrunk();+ const landed = box.git(box.repo, 'rev-parse', 'HEAD');+ for (const root of [box.repo, peer]) withBoard(root, board => store.merged(board, 1, { agentId: 'coordinator', commit: landed }));+ assert.equal(helpers.commitFile(box, box.repo, 'web/feature.js', 'feature = 1\nmain = 2\n', 'feat(web): after landing [G1]').status, 0);+ syncTrunk();+ assert.ok(items().every(item => !item.item_verdict_state), 'landed items are not waiting for re-review');+ assert.ok(existsSync(join(peer, '.git', 'pullboard', 'board.sqlite')));+});+++test('a checkout or trunk moving during verification cannot acquire proof [E8]', () => {+ const box = helpers.project();+ const reviewer = join(box.dir, 'moving-reviewer');+ const moveHead = join(box.dir, 'move-review-head');+ const moveMain = join(box.dir, 'move-review-main');+ const baseline = box.git(box.repo, 'rev-parse', 'main');+ const check = `grep -q '^feature = 1$' web/feature.js && if test -f '${moveHead}'; then git -C '${reviewer}' checkout -q --detach '${baseline}'; fi && if test -f '${moveMain}'; then git -C '${box.repo}' commit -q --allow-empty -m 'chore: move review trunk [G1]'; fi`;+ run(box, box.repo, 'add', 'web', 'Moving review', '--specs', 'G1', '--check', check, '--wait');+ run(box, box.web, 'claim', '1');+ assert.equal(helpers.commitFile(box, box.web, 'web/feature.js', 'feature = 1\n', 'feat(web): moving review feature [G1]').status, 0);+ const submitted = box.git(box.web, 'rev-parse', 'HEAD');+ run(box, box.web, 'submit', '1');+ box.git(box.repo, 'worktree', 'add', '-q', '--detach', reviewer, submitted);+ run(box, reviewer, 'join', 'web');+ writeFileSync(moveHead, 'armed');+ const moved = box.run(reviewer, 'verify', '1', 'accept', '--note', 'The check moved the live reviewer checkout.');+ assert.equal(moved.code, 1, moved.out + moved.err);+ assert.match(moved.err, /NOT_AT_COMMIT/u);+ assert.equal(box.git(reviewer, 'rev-parse', 'HEAD'), baseline, 'the actual checkout moved while its private check was running');+ assert.deepEqual(withBoard(box.repo, board => store.verdictsFor(board, 1)), []);+ rmSync(moveHead);+ box.git(reviewer, 'checkout', '-q', '--detach', submitted);+ writeFileSync(moveMain, 'armed');+ const mainMoved = box.run(reviewer, 'verify', '1', 'accept', '--note', 'The check moved the known main.');+ assert.equal(mainMoved.code, 1, mainMoved.out + mainMoved.err);+ assert.match(mainMoved.err, /VERDICT_TRUNK_MOVED/u);+ assert.notEqual(box.git(box.repo, 'rev-parse', 'main'), baseline);+ assert.deepEqual(withBoard(box.repo, board => store.verdictsFor(board, 1)), []);+ rmSync(moveMain);+ run(box, reviewer, 'verify', '1', 'accept', '--note', 'The candidate and known trunk stayed fixed through the complete frozen check.');+ assert.equal(withBoard(box.repo, board => store.verdictsFor(board, 1)).length, 1);+});+++test('landing retains the exact repair that passed stale re-review [E8,V8,R3]', () => {+ const box = helpers.project();+ const source = (feature, expected) => `feature = ${feature}\n${'// independent caller line\n'.repeat(12)}expected = ${expected}\n`;+ assert.equal(helpers.commitFile(box, box.repo, 'web/feature.txt', source(0, 1), 'feat(web): baseline caller [G1]').status, 0);+ box.git(box.web, 'merge', '-q', '--ff-only', 'main');+ const check = `test "$(sed -n 's/^feature = //p' web/feature.txt)" = "$(sed -n 's/^expected = //p' web/feature.txt)"`;+ run(box, box.repo, 'add', 'web', 'Repair follows its review', '--specs', 'G1', '--check', check, '--wait');+ run(box, box.web, 'claim', '1');+ assert.equal(helpers.commitFile(box, box.web, 'web/feature.txt', source(1, 1), 'feat(web): original feature [G1]').status, 0);+ const submitted = box.git(box.web, 'rev-parse', 'HEAD');+ run(box, box.web, 'submit', '1');+ const reviewer = join(box.dir, 'repair-reviewer');+ box.git(box.repo, 'worktree', 'add', '-q', '--detach', reviewer, submitted);+ run(box, reviewer, 'join', 'web');+ run(box, reviewer, 'verify', '1', 'accept', '--note', 'The original feature matches the original caller.');+ const original = withBoard(box.repo, board => store.verdictsFor(board, 1));+ assert.equal(helpers.commitFile(box, box.repo, 'web/feature.txt', source(0, 2), 'feat(web): caller now requires two [G1]').status, 0);+ assert.equal(JSON.parse(run(box, box.repo, 'show', '1', '--json')).item_verdict_state?.code, 'STALE_VERDICT');+ box.git(reviewer, 'merge', '-q', '--no-edit', 'main');+ assert.equal(helpers.commitFile(box, reviewer, 'web/feature.txt', source(2, 2), 'feat(web): repair against the new caller [G1]').status, 0);+ assert.equal(helpers.commitFile(box, reviewer, 'web/repair.txt', 'ready\n', 'feat(web): add the repair companion [G1]').status, 0);+ const checked = box.git(reviewer, 'rev-parse', 'HEAD');+ run(box, reviewer, 'verify', '1', 'accept', '--note', 'The repaired composition matches the new caller; the original feature does not.');+ const reviewed = withBoard(box.repo, board => store.verdictsFor(board, 1));+ assert.deepEqual(reviewed.slice(0, original.length), original);+ assert.equal(reviewed.at(-1).verdict_head, checked);+ const probe = join(box.dir, 'repair-path-replica');+ box.git(box.dir, 'clone', '-q', box.repo, probe);+ withBoard(probe, board => importBoard(board, withBoard(box.repo, exportBoard)));+ box.git(probe, 'fetch', '-q', 'origin', `refs/pullboard/items/1/${checked.slice(0, 12)}`);+ assert.equal(helpers.commitFile(box, probe, 'web/repair.txt', 'main changed the repair\n', 'feat(web): main changes a repair file [G1]').status, 0);+ const changedRepair = JSON.parse(run(box, probe, 'show', '1', '--json'));+ assert.equal(changedRepair.item_verdict_state?.file, 'web/repair.txt', 'a file introduced by the checked repair must participate in later freshness');++ const remote = join(box.dir, 'landing-remote.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');+ const landed = JSON.parse(run(box, box.repo, 'land', '--json'));+ assert.deepEqual(landed.landed, [1], JSON.stringify(landed));+ assert.equal(box.git(box.repo, 'show', landed.batch.tip + ':web/feature.txt'), source(2, 2).trim(), 'landing must retain the exact repaired file that passed the frozen check');+ assert.equal(box.git(box.remote ?? remote, 'rev-parse', 'main'), landed.batch.tip);+ assert.equal(withBoard(box.repo, board => store.getItem(board, 1)).item_commit, submitted, 'the original submission remains the immutable item identity');+});