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): freeze signed test coverage and main proof [V2,V4,M1]
Corey Olsond67e14200ae3
diff --git a/docs/lifecycle.md b/docs/lifecycle.mdindex a2f21994..4ab8c1de 100644--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@ -57,14 +57,14 @@ Each move checks its guards in this order and refuses with the first one that do| claim | open, claimed | claimed | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_CLAIMABLE), checkProvesSomething (CRITERION_PROVES_NOTHING), barReady (BAR_NOT_READY), itemNotHeld (ITEM_HELD), inLane (WRONG_LANE), routeAllows (ROUTE), dependenciesVerified (BLOCKED), notHeldByAnother (HELD), builderFirstRefusal (REOPEN_HELD_FOR_BUILDER), 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 or AGENT_APPROVAL_REQUIRED) || release | open, claimed | open | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_YOURS), releaseOwnsWork (NOT_YOURS), reviewReleaseExplained (NOTE_REQUIRED) || lapse | claimed | open | clock, when its lease runs out | none |-| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), correctionRefrozen (PENDING_REFREEZE), checkProvesSomething (CRITERION_PROVES_NOTHING), barReady (BAR_NOT_READY), criterionUnchanged (CRITERIA_CHANGED), treeClean (DIRTY), nothingUntracked (UNTRACKED), hasCommit (NO_COMMIT or HOST_NAME), 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), infraExplained (INFRA_NOTE_REQUIRED), doctrineHolds (RATCHET_ROSE or RATCHET_UNCOUNTED), gateConfigured (NO_GATE), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), gateGreen (GATE_RED or LAND_TIMEOUT_CUSTODY or LAND_GATE_OUTPUT or SLOT_DB_LOCKED or RUNNER_BROWSER_SLOT_REQUIRED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), submissionProofValid (SUBMISSION_PROOF), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) |+| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), correctionRefrozen (PENDING_REFREEZE), checkProvesSomething (CRITERION_PROVES_NOTHING), barReady (BAR_NOT_READY), criterionUnchanged (CRITERIA_CHANGED), treeClean (DIRTY), nothingUntracked (UNTRACKED), hasCommit (NO_COMMIT or HOST_NAME), 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), trunkInCandidate (MAIN_NOT_COMPOSED), noUnverifiedStack (STACKED_ON_UNVERIFIED), infraExplained (INFRA_NOTE_REQUIRED), doctrineHolds (RATCHET_ROSE or RATCHET_UNCOUNTED), gateConfigured (NO_GATE), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), gateGreen (GATE_RED or LAND_TIMEOUT_CUSTODY or LAND_GATE_OUTPUT or SLOT_DB_LOCKED or RUNNER_BROWSER_SLOT_REQUIRED 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 or SESSION_LEDGER), roadmapReadable (MILESTONES_CORRUPT), itemExists (NO_ITEM), inState (NOT_SUBMITTED), reviewCooldownElapsed (REVIEW_COOLDOWN), notBuilder (SELF_VERIFY or VERIFIER_STANDING or SELF_SESSION_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 or SESSION_LEDGER), 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 or VERIFIER_STANDING or SELF_SESSION_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), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), itemCheckGreen (CHECK_RED or SLOT_DB_LOCKED or CHECK_UNVERIFIED or GUARD_CANNOT_FAIL or GUARD_NOT_FOUND), proofNoted (PROOF_REQUIRED), result (VERDICT_ENVIRONMENT), result (LAND_HEADER), result (ENGINE_VERSION) || reject | submitted, verified | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED or SESSION_LEDGER), 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 or VERIFIER_STANDING or SELF_SESSION_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), result (VERDICT_ENVIRONMENT), result (LAND_HEADER), result (ENGINE_VERSION), result (NOT_YOURS), result (CLOSED) || reopen | submitted, verified | open | coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_SUBMITTED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), notMerged (ALREADY_MERGED), landingFailureRecorded (LANDING_FAILURE_REQUIRED), trunkConflicts (NOT_CONFLICTING or CONFLICT_FILES or NO_TRUNK or MERGE_CHECK_FAILED), conflictAccepted (NOT_ACCEPTED or BAD_CONFLICT or ENGINE_VERSION), result (BAD_CONFIG) || escalate | open, claimed | open | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), 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 or SESSION_LEDGER), 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 or AGENT_APPROVAL_REQUIRED) |-| refreeze | claimed | claimed | agent, coordinator, when a live claim has a pending coordinator correction | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN or AGENT_APPROVAL_REQUIRED) |+| refreeze | open, claimed, submitted | open | coordinator, when there is no live claim awaiting a coordinator correction | joined (NOT_JOINED or SESSION_LEDGER), coordinatorOnly (COORDINATOR_ONLY), itemExists (NO_ITEM), inState (CLOSED), barReady (BAR_NOT_READY), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN or AGENT_APPROVAL_REQUIRED) |+| refreeze | claimed | claimed | agent, coordinator, when a live claim has a pending coordinator correction | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED), barReady (BAR_NOT_READY), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN or AGENT_APPROVAL_REQUIRED) || withdraw | open, claimed, submitted | withdrawn | coordinator | joined (NOT_JOINED or SESSION_LEDGER), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), inState (CLOSED) |## Required transition guards@@ -127,6 +127,7 @@ Each move checks its guards in this order and refuses with the first one that do| MERGE_CHECK_FAILED | the candidate merges cleanly into the current primary branch without changing an index or worktree | use Git 2.38 or newer, restore its objects and retry || 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 |+| MAIN_NOT_COMPOSED | the candidate contains the current main used for its submission proof, and that main stays fixed through execution, bar ready is enabled for this board | merge main, commit the composition, then submit again || 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 || INFRA_NOTE_REQUIRED | edits to tests or gate files that existed at claim carry an explanation | pullboard submit <id> --infra "<why>" || 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: |diff --git a/src/bar-coverage.js b/src/bar-coverage.jsnew file mode 100644index 00000000..811f3794--- /dev/null+++ b/src/bar-coverage.js@@ -0,0 +1,77 @@+/** Captured whole-file obligations share one signed, frozen project command [V2,V4]. */+import { createHash } from 'node:crypto';+import { readFileSync, statSync } from 'node:fs';+import { resolve } from 'node:path';+import { briefFiles } from './brief.js';+import { git } from './git.js';+import { Refused } from './refused.js';++const HASH = /^[a-f0-9]{64}$/u;+const COMMIT = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;+/** Match the coordinator's literal test-path glob, without evaluating shell syntax. */+export function barTestPath(path, patterns) {+ return patterns.some(pattern => {+ const source = pattern.split(/(\*\*\/|\*\*|\*|\?)/u).map(part => part === '**/' ? '(?:.*/)?' : part === '**' ? '.*'+ : part === '*' ? '[^/]*' : part === '?' ? '[^/]' : part.replace(/[.+^$()|[\]{}\\]/gu, '\\$&')).join('');+ return new RegExp(`^${source}$`, 'u').test(path);+ });+}+/** Only literal project-relative paths become arguments to the accepted project runner. */+function projectPath(path) { return typeof path === 'string' && path.length > 0 && !/[:\\\p{Cc}]/u.test(path) && path.split('/').every(part => part && part !== '.' && part !== '..'); }+/** Measurements retain their source, runtime and whole-file provenance; the peer judges adequacy. */+function observation(value, selection) {+ return value && Number.isFinite(value.durationMs) && value.durationMs >= 0 && value.selection === selection+ && typeof value.ref === 'string' && value.ref.trim() && value.ref.length <= 4096 && HASH.test(value.sha256)+ && COMMIT.test(value.source) && typeof value.runtime === 'string' && value.runtime.trim()+ && ['pass', 'timeout', 'fail'].includes(value.outcome);+}+/** Validate captured evidence without opening a replica's files or running a command during replay. */+export function normalizeBarCoverage(value, item) {+ const bad = detail => { throw new Refused('BAR_COVERAGE', `${detail}; supply --coverage-file with recorded whole-file evidence before pullboard bar sign ${item.item_id}`); };+ if (!value || value.version !== 1 || !COMMIT.test(value.sourceMain) || value.sourceCheck !== item.item_check+ || !Number.isSafeInteger(value.timeoutMs) || value.timeoutMs <= 0 || typeof value.runner !== 'string'+ || !Array.isArray(value.required) || value.required.some(path => !projectPath(path)) || !Array.isArray(value.files)) bad('the coverage plan must bind accepted main, its timeout, test paths and the original named check');+ const required = [...new Set(value.required)].sort();+ const files = value.files.map(file => {+ if (!file || !required.includes(file.path) || !['whole','landing'].includes(file.mode) || !observation(file.evidence, 'whole-file')) bad('each existing brief test needs a whole-file observation and whole/landing mode');+ if (file.mode === 'whole' && file.evidence.outcome !== 'pass') bad(`${file.path} has no completed green whole-file duration`);+ if (file.mode === 'landing' && (!Array.isArray(file.namedCases) || !file.namedCases.length || file.namedCases.some(name => typeof name !== 'string' || !name.trim())+ || !item.item_check.includes(file.path) || !String(item.item_brief).includes(file.path) || !/landing/iu.test(item.item_brief))) bad(`${file.path} needs explicit landing coverage and named cases retained in its original check`);+ return { path: file.path, mode: file.mode, evidence: { ...file.evidence }, ...(file.mode === 'landing' ? { namedCases: [...file.namedCases] } : {}) };+ }).sort((a,b) => a.path.localeCompare(b.path));+ if (files.length !== required.length || new Set(files.map(file => file.path)).size !== required.length) bad('the coverage rows must name each required file exactly once');+ if (files.length && (!observation(value.named, 'named-check') || value.named.outcome !== 'pass' && value.named.outcome !== 'fail')) bad('the original named command needs a recorded duration');+ if (files.length && (!Number.isFinite(value.installMs) || value.installMs < 0 || value.installMs && !observation(value.install, 'install'))) bad('the plan needs the accepted install duration (zero only when no install is configured)');+ const fixed = files.length ? value.named.durationMs + value.installMs : 0;+ if (files.some(file => file.mode === 'landing' && file.evidence.durationMs + fixed <= value.timeoutMs)) bad('a landing exception needs a recorded whole-file duration exceeding the available review budget');+ const totalMs = fixed + files.filter(file => file.mode === 'whole').reduce((sum,file) => sum + file.evidence.durationMs, 0);+ if (totalMs > value.timeoutMs) bad('the recorded named, install and whole-file durations together exceed the unchanged review timeout');+ if (files.some(file => file.mode === 'whole') && !value.runner.trim()) bad('configure the project affectedTests command; Pullboard never substitutes its own test runner');+ return { version: 1, sourceMain: value.sourceMain, sourceCheck: value.sourceCheck, timeoutMs: value.timeoutMs,+ runner: value.runner, required, files, totalMs, ...(files.length ? { named: { ...value.named }, installMs: value.installMs, ...(value.install ? { install: { ...value.install } } : {}) } : {}) };+}+/** Resolve existing brief test paths at accepted main; the project explicitly configures non-Node globs. */+export function prepareBarCoverage(root, item, policy, file) {+ const committed = new Set(git(root, ['ls-tree', '-r', '--name-only', '-z', policy.commit]).split('\0').filter(Boolean));+ const required = [...new Set(briefFiles(item.item_brief).filter(path => committed.has(path) && barTestPath(path, policy.config.claim.barTestFiles)))].sort();+ let supplied = {};+ if (file) {+ const path = resolve(root, file);+ try {+ if (statSync(path).size > 262144) throw new Error('oversize');+ supplied = JSON.parse(readFileSync(path, 'utf8'));+ } catch { throw new Refused('BAR_COVERAGE', 'the coverage file must be readable JSON no larger than 256 KiB; correct --coverage-file'); }+ }+ if (required.length && !file) throw new Refused('BAR_COVERAGE', `record whole-file timing evidence for ${required.join(', ')} in --coverage-file; an unknown duration is not a slow-file exception`);+ if (policy.config.check.install && required.length && (!observation(supplied.install, 'install') || supplied.installMs !== supplied.install.durationMs)) throw new Refused('BAR_COVERAGE', 'the accepted install command needs its own recorded duration in --coverage-file');+ if (!policy.config.check.install) supplied.installMs = 0;+ return normalizeBarCoverage({ ...supplied, version: 1, sourceMain: policy.commit, sourceCheck: item.item_check,+ timeoutMs: policy.config.check.timeoutMs, runner: policy.config.affectedTests ?? '', required, files: supplied.files ?? [] }, item);+}+/** Digest every captured input so a signature cannot be transplanted to another coverage plan. */+export function barCoverageDigest(plan) { return createHash('sha256').update(JSON.stringify(plan)).digest('hex'); }+/** Group the original shell check intact, then use only the accepted project's own runner for whole files. */+export function barCoverageCommand(sourceCheck, plan) {+ const paths = plan.files.filter(file => file.mode === 'whole').map(file => `'./${file.path.replaceAll("'", "'\\''")}'`);+ return paths.length ? `(\n${sourceCheck}\n) && (\n${plan.runner} ${paths.join(' ')}\n)` : sourceCheck;+}diff --git a/src/bar-readiness.js b/src/bar-readiness.jsindex c4744050..0c488669 100644--- a/src/bar-readiness.js+++ b/src/bar-readiness.js@@ -1,3 +1,4 @@+import { normalizeBarCoverage, barCoverageDigest } from './bar-coverage.js';/** Readiness is a revision-bound peer judgement, with mechanical prerequisites [U113]. */import { createHash } from 'node:crypto';import { atomic, itemById, logEvent } from './board.js';@@ -97,13 +98,17 @@ export function barReadiness(board, item, { signature = true } = {}) {const baseline = itemCheckBaseline(board, item);const missing = [];if (!notes['named test']) missing.push('Named test: the case this check proves');- if (!baseline || baseline.result !== 'red' || baseline.command !== item.item_check || !baseline.main) missing.push('a recorded red check baseline at main (an absent named case counts)');+ const witness = notes['named test'];+ const evidence = baseline?.testEvidence;+ const namedRed = witness && evidence && !evidence.passed.some(name => name.includes(witness))+ && (evidence.failed.some(name => name.includes(witness)) || evidence.noTestsMatched && item.item_check.includes(witness));+ if (!baseline || baseline.result !== 'red' || baseline.command !== item.item_check || !baseline.main || !namedRed) missing.push('a recorded red check baseline at main for the Named test (an absent named case counts; unrelated shell failures do not)');if (!notes.measurements) missing.push('Measurements: a method beside each quantitative bound, or an explicit statement that there are none');if (!notes['reviewer edges']) missing.push('Reviewer edges: cases a reviewer should try');if (!revision || revision.digest !== barDigest(item)) missing.push('a recorded current bar revision (edit the brief)');const signed = read(board, `bar_sign:${item.item_id}`);const baselineDigest = createHash('sha256').update(JSON.stringify(baseline)).digest('hex');- if (signature && (!signed || signed.revision !== revision?.revision || signed.digest !== revision?.digest || signed.baselineDigest !== baselineDigest)) missing.push('sign-off by another parent session: pullboard bar sign '+item.item_id);+ if (signature && (!signed || signed.revision !== revision?.revision || signed.digest !== revision?.digest || signed.baselineDigest !== baselineDigest || !signed.coverage || signed.coverageDigest !== barCoverageDigest(signed.coverage))) missing.push('sign-off by another parent session: pullboard bar sign '+item.item_id);return { revision, notes, baseline, baselineDigest, signed, missing };}/** The same board guard protects explicit claim, next, run, renew and submit. */@@ -113,7 +118,7 @@ export function barReadyProblem(board, item) {return status.missing.length ? new Refused('BAR_NOT_READY', `#${item.item_id}'s bar needs ${status.missing.join('; ')}; ask its author to edit the brief, then another session runs pullboard bar sign ${item.item_id}`) : null;}/** Record the peer's judgement against exact words, author identities and baseline observation. */-export function signBar(board, id, { agentId, revision, digest, note }) {+export function signBar(board, id, { agentId, revision, digest, note, coverage }) {return atomic(board, () => {const item = itemById(board, id);if (['verified','withdrawn'].includes(item.item_status)) throw new Refused('CLOSED', `#${id} is ${item.item_status}; sign an open bar`);@@ -125,7 +130,8 @@ export function signBar(board, id, { agentId, revision, digest, note }) {if (!signerParent || authors.some(author => !author.parent)) throw new Refused('BAR_PARENT_UNKNOWN', `#${id} needs known author and signer session identities; join from the real runtime session, then author a new bar revision`);if (authors.some(author => author.agent === agentId || author.parent === signerParent)) throw new Refused('BAR_SELF_SIGN', `#${id}'s author and its helpers cannot sign their own bar; ask another parent session`);if (typeof note !== 'string' || !note.trim()) throw new Refused('NOTE_REQUIRED', 'say whether a builder can meet this bar and two reviewers would grade it the same: --note "..."');- const signed = { revision, digest, baselineDigest: status.baselineDigest, authorParents: authors, signerParent, note: note.trim() };+ const plan = normalizeBarCoverage(coverage, item);+ const signed = { revision, digest, coverage: plan, coverageDigest: barCoverageDigest(plan), baselineDigest: status.baselineDigest, authorParents: authors, signerParent, note: note.trim() };logEvent(board, agentId, 'bar-sign', id, signed);save(board, `bar_sign:${id}`, { ...signed, by: agentId, event: board.lastEvent.event_id });return { id, ...signed };diff --git a/src/board.js b/src/board.jsindex f3784491..0194ef92 100644--- a/src/board.js+++ b/src/board.js@@ -1693,6 +1693,7 @@ export function refreeze(board, id, { agentId, freeze }) {const item = moveItem(board, id, 'refreeze', {checks: {joined: null,+ barReady: found => barReadyProblem(board, found),coordinatorOnly: () => onlyCoordinator(agentId, 'refreezes a criterion'),holderOrCoordinator: (found) => {const live = current(board, found);diff --git a/src/check-baseline.js b/src/check-baseline.jsindex 6436afd4..870bf0cd 100644--- a/src/check-baseline.js+++ b/src/check-baseline.js@@ -1,3 +1,4 @@+import { timingFromOutput, timingRunner } from './timing.js';/** Observe a proposed check on an isolated copy of main before recording its move [V2,H16]. */import { spawnSync } from 'node:child_process';import { randomUUID } from 'node:crypto';@@ -36,12 +37,20 @@ export function checkBaseline(root, command, { main = undefined } = {}) {const selected = clone.status === 0 && spawnSync('git', ['-c', 'core.hooksPath=/dev/null', 'checkout', '--quiet', '--detach', base.main], { cwd: checkout, env, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });if (!selected || selected.status !== 0) return { ...base, result: 'unavailable', reason: 'temporary checkout could not be prepared' };const ran = runShell(checkout, command);- return { ...base, result: ran.isGreen ? 'green' : 'red', seconds: ran.seconds };+ return { ...base, result: ran.isGreen ? 'green' : 'red', seconds: ran.seconds, testEvidence: baselineTestEvidence(ran.output, command) };} finally {rmSync(directory, { recursive: true, force: true });}}+/** Retain observed case outcomes, distinguishing an absent named case from unrelated shell failure. */+export function baselineTestEvidence(output, command) {+ const tests = timingFromOutput(output, timingRunner(command)).tests;+ return { failed: [...new Set(tests.filter(test => !test.passed).map(test => test.name))].slice(0,512),+ passed: [...new Set(tests.filter(test => test.passed).map(test => test.name))].slice(0,512),+ noTestsMatched: /^run-tests: NO_TESTS_MATCHED:/mu.test(output) };+}+/*** Refuse a check the shell cannot parse, quoting the shell's own message. sh -n reads the command* without running it, so a stray quote is caught when the check is set instead of surfacing laterdiff --git a/src/cli.js b/src/cli.jsindex 01a9e624..054acfaf 100644--- a/src/cli.js+++ b/src/cli.js@@ -1,3 +1,5 @@+import { barReadinessRequired, barReadiness } from './bar-readiness.js';+import { barCoverageCommand } from './bar-coverage.js';/*** The pullboard command line: every command, bound to who is asking (B3, R3). The main checkout is the* coordinator; every other worktree is the agent that joined from it.@@ -519,6 +521,7 @@ const OPTIONS = {after: { type: 'string' },brief: { type: 'string' },'brief-file': { type: 'string' },+ 'coverage-file': { type: 'string' },text: { type: 'string' },gate: { type: 'string' },aim: { type: 'boolean' },@@ -1083,7 +1086,9 @@ export function freezer(ctx, { captureVerifyPolicy = false, board } = {}) {if (board) refuseAgentApprovedRows(ctx.info.root, { board, config, item });const frozen = frozenCriterion(loadSpec(ctx.info.root, config), item, doctrine);if (!policy) return frozen; // Legacy criteria retain their original digest and committed claim base.- const text = JSON.stringify({ ...JSON.parse(frozen.text), policy });+ const signed = board && barReadinessRequired(board, item) ? barReadiness(board, item).signed : null;+ const coverage = signed?.coverage;+ const text = JSON.stringify({ ...JSON.parse(frozen.text), ...(coverage ? { sourceCheck: item.item_check, check: barCoverageCommand(item.item_check, coverage), barCoverage: coverage, barRevision: signed.revision } : {}), policy });return { text, digest: createHash('sha256').update(text).digest('hex') };};}diff --git a/src/commands/bar.js b/src/commands/bar.jsindex b052f463..b5fe98c5 100644--- a/src/commands/bar.js+++ b/src/commands/bar.js@@ -1,3 +1,5 @@+import { prepareBarCoverage } from '../bar-coverage.js';+import { mainPolicy } from '../trusted-policy.js';/** Inspect, enable and independently sign acceptance bars [U113]. */import { getItem } from '../board.js';import { barReadiness, barReadySetting } from '../bar-readiness.js';@@ -25,7 +27,8 @@ export async function run(io, { first, second, rest, values }) {return 0;}io.say(`Sign-off asks: can the builder meet this bar, and would two reviewers grade it the same? Check the named baseline, every measurement method, coverage and reviewer edges in pullboard show ${id}.`);- const signed = await ordered(ctx, board, 'signBar', [id, { agentId: me.id, revision: status.revision?.revision, digest: status.revision?.digest, note: values.note }]);+ const coverage = prepareBarCoverage(ctx.info.root, item, mainPolicy(ctx.info.root), values['coverage-file']);+ const signed = await ordered(ctx, board, 'signBar', [id, { agentId: me.id, revision: status.revision?.revision, digest: status.revision?.digest, note: values.note, coverage }]);io.result?.({ signed });io.say(`signed #${id} revision ${signed.revision}; any bar edit needs a fresh signature`);return 0;diff --git a/src/commands/edit.js b/src/commands/edit.jsindex 68e88f79..b2c7188e 100644--- a/src/commands/edit.js+++ b/src/commands/edit.js@@ -1,3 +1,4 @@+import { barReadySetting } from '../bar-readiness.js';/** The pullboard edit command, in its own module so an item adding another command never edits these lines. */import * as store from '../board.js';import {@@ -48,7 +49,7 @@ export async function run(io, args) {};const { item, command } = store.validateItemEdit(board, id, change);if (command && command !== item.item_check) refuseCheckSyntax(command);- if (command && command !== item.item_check) change.checkBaseline = values.wait ? checkBaseline(ctx.info.root, command) : prepareCheckBaseline(ctx.info.root, command);+ if (command && (command !== item.item_check || barReadySetting(board).enabled)) change.checkBaseline = values.wait ? checkBaseline(ctx.info.root, command) : prepareCheckBaseline(ctx.info.root, command);await ordered(ctx, board, 'editItem', [id, change]);if (change.checkBaseline?.result === 'pending') await launchBaseline(ctx, board, id, change.checkBaseline);io.result?.({ item: store.getItem(board, id) });diff --git a/src/commands/submit.js b/src/commands/submit.jsindex 06362df2..0408457b 100644--- a/src/commands/submit.js+++ b/src/commands/submit.js@@ -1,3 +1,5 @@+import { barReadySetting, barReadyProblem } from '../bar-readiness.js';+import { requireSubmitComposition } from '../submit-composition.js';/** The pullboard submit command, in its own module so an item adding another command never edits these lines. */import * as store from '../board.js';import {@@ -109,12 +111,15 @@ export async function submitHere(ctx, id, infra) {const item = store.getItem(board, id);seatCheckout.refuseHeldElsewhere(ctx.info, store.listAgents(board), item, 'submit');if (item.item_status !== 'claimed' || item.item_owner !== me.id) throw new Refused('NOT_YOURS', 'claim this item before submitting it');+ const readiness = barReadyProblem(board, item);+ if (readiness) throw readiness;const correction = store.pendingRefreezeProblem(board, id);if (correction) throw correction;return item;});const policy = itemPolicy(root, held);const acceptedMain = mainPolicy(root);+ const requireComposition = withBoard(ctx, board => barReadySetting(board).enabled);ctx = { ...ctx, config: policy.config };withBoard(ctx, (board) => refuseProvesNothing(() => acceptedMain.config, board, store.getItem(board, id)));const dependencies = withBoard(ctx, board => dependencySnapshots(board.db, held));@@ -152,6 +157,7 @@ export async function submitHere(ctx, id, infra) {if (!commit) throw new Refused('NO_COMMIT', 'nothing committed yet');withBoard(ctx, (board) => submitPreflight(board, id, { agentId: me.id, commit, tree: headTree(root) ?? '' }));const trunk = requireTrunkMerge(root, commit);+ if (requireComposition) requireSubmitComposition(root, commit, trunk, acceptedMain.commit);withBoard(ctx, (board) => refuseUnverifiedStack(root, board, held, commit, trunk));machineNameProblems(root, `${acceptedMain.commit}..${commit}`, { refuse: acceptedMain.config.commits.noHostName === true, say: (line) => ctx.io.say(line) });const infraRecord = infraNotes.infraNote({ root, claimHead, files: filesSince(root, id, claimHead, commit), gates: [ctx.config.gate, acceptedMain.config.gate], infra, requireInfraNote: acceptedMain.config.submit.requireInfraNote });@@ -188,6 +194,7 @@ export async function submitHere(ctx, id, infra) {);}const currentTrunk = requireTrunkMerge(root, commit); // The trunk may have moved while the gate ran.+ if (requireComposition) requireSubmitComposition(root, commit, currentTrunk, acceptedMain.commit);const waivedLines = waived ? waived.map(waiverLine) : [];await withBoard(ctx, async (board) => {refuseUnverifiedStack(root, board, store.getItem(board, id), commit, currentTrunk);diff --git a/src/config.js b/src/config.jsindex cfbb7ba1..e8c86786 100644--- a/src/config.js+++ b/src/config.js@@ -54,7 +54,7 @@ export function defaults() {verify: { policy: 'any', family: 'off', reviewRatio: 3 },agents: { names: 'suffix' },check: { install: '', timeout: '5m' },- claim: { reopenFirstRefusalMinutes: 0 },+ claim: { reopenFirstRefusalMinutes: 0, barTestFiles: ['**/*.test.js', '**/*.test.mjs', '**/*.test.cjs', '**/*.spec.js', '**/*.spec.mjs', '**/*.spec.cjs'] },lanes: {},products: {},shared: [],@@ -252,6 +252,7 @@ export function configProblems(config) {|| config.claim.reopenFirstRefusalMinutes > Math.floor(8_640_000_000_000_000 / 60_000)) {problems.push('"claim.reopenFirstRefusalMinutes" is a non-negative whole number of minutes within the supported date range; 0 disables it');}+ if (!Array.isArray(config.claim?.barTestFiles) || !config.claim.barTestFiles.length || config.claim.barTestFiles.some(pattern => typeof pattern !== 'string' || !pattern || /[\[\]{}\\:\p{Cc}]/u.test(pattern) || pattern.startsWith('/') || pattern.split('/').includes('..'))) problems.push('claim.barTestFiles is a nonempty list of project test-path globs using *, ** or ?');if (typeof config.check?.install !== 'string') problems.push('"check.install" is an install command string');const timeout = typeof config.check?.timeout === 'string' ? CHECK_TIMEOUT_RE.exec(config.check.timeout) : null;const timeoutMs = timeout ? Number(timeout[1]) * CHECK_TIMEOUT_MS[timeout[2]] : NaN;diff --git a/src/help.js b/src/help.jsindex df627348..3e2721fc 100644--- a/src/help.js+++ b/src/help.js@@ -122,7 +122,9 @@ Workpullboard check accept <id> the person accepts an item's check that already passes on main, as it reads now;with checks.provesNothing "hold", claim and submit refuse that item until thenpullboard bar ready on|off coordinator: opt in to ready bars; existing frozen work needs no backfill- pullboard bar sign <id> --note "..." another parent judges buildability and repeatable grading; edits clear the signature+ pullboard bar sign <id> --note "..." [--coverage-file <json>] another parent judges buildability and repeatable grading; edits clear the signature+ claim.barTestFiles configures project test-path globs (Node test/spec files by default)+ coverage rows retain whole-file observations; slow files require named checks and explicit landing coveragepullboard bar <id> show missing prerequisites and the current revisionpullboard claim <id> take or renew a lease; the first claim freezes the criterionpullboard release <id> [--note "why"] hand it back; a review release needs a one-line reasondiff --git a/src/item-check-baseline.js b/src/item-check-baseline.jsindex 99100460..80ec46bd 100644--- a/src/item-check-baseline.js+++ b/src/item-check-baseline.js@@ -24,6 +24,8 @@ export function normalizeCheckBaseline(agentId, command, baseline) {|| (baseline.result === 'pending' && !baseline.request)|| (baseline.request !== undefined && (typeof baseline.request !== 'string' || !/^[a-f0-9-]{36}$/.test(baseline.request)))|| (baseline.reason !== undefined && typeof baseline.reason !== 'string')+ || (baseline.testEvidence !== undefined && (!baseline.testEvidence || typeof baseline.testEvidence.noTestsMatched !== 'boolean'+ || !['failed','passed'].every(key => Array.isArray(baseline.testEvidence[key]) && baseline.testEvidence[key].length <= 512 && baseline.testEvidence[key].every(name => typeof name === 'string' && name.length <= 4096))))|| (baseline.seconds !== undefined && (!Number.isSafeInteger(baseline.seconds) || baseline.seconds < 0))) {throw new Refused('BAD_CHECK_BASELINE', 'the check baseline must describe this command at a main commit; set --check again from the coordinator');}@@ -31,6 +33,7 @@ export function normalizeCheckBaseline(agentId, command, baseline) {command, main: baseline.main, result: baseline.result,...(baseline.request === undefined ? {} : { request: baseline.request }),...(baseline.reason === undefined ? {} : { reason: baseline.reason }),+ ...(baseline.testEvidence === undefined ? {} : { testEvidence: { failed: [...baseline.testEvidence.failed], passed: [...baseline.testEvidence.passed], noTestsMatched: baseline.testEvidence.noTestsMatched } }),...(baseline.seconds === undefined ? {} : { seconds: baseline.seconds }),...(baseline.result === 'green' ? { warning: 'CRITERION_PROVES_NOTHING' } : {}),};diff --git a/src/machine.js b/src/machine.jsindex 4fda76aa..c642b69b 100644--- a/src/machine.js+++ b/src/machine.js@@ -170,6 +170,7 @@ export const GUARDS = [{ id: 'gateConfigured', refuse: 'NO_GATE', rule: 'the repo names a gate command', next: 'in the main checkout, run pullboard gate set "<project test command>", then commit pullboard.json', source: 'cli' },{ 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: 'trunkInCandidate', refuse: 'MAIN_NOT_COMPOSED', rule: 'the candidate contains the current main used for its submission proof, and that main stays fixed through execution', next: 'merge main, commit the composition, then submit again', source: 'cli', when: 'bar ready is enabled for this board' },{ 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: 'infraExplained', refuse: 'INFRA_NOTE_REQUIRED', rule: 'edits to tests or gate files that existed at claim carry an explanation', next: 'pullboard submit <id> --infra "<why>"', 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' },@@ -217,7 +218,7 @@ export const MOVES = [{ verb: 'lapse', from: ['claimed'], to: 'open', by: ['clock'], guards: [], when: 'its lease runs out' },{verb: 'submit', from: ['claimed'], to: 'submitted', by: ['agent', 'coordinator'], refuse: 'NOT_YOURS',- guards: ['joined', 'itemExists', IN_STATE, 'isHolder', 'correctionRefrozen', 'checkProvesSomething', 'barReady', 'criterionUnchanged', 'treeClean', 'nothingUntracked', 'hasCommit', 'withinLane', 'trunkMergeClean', 'noUnverifiedStack', 'infraExplained', 'doctrineHolds', 'gateConfigured', 'queuedItemLease', 'gateGreen', 'treeStillDuringGate', 'submissionProofValid', 'childrenDone', 'headIsNew'],+ guards: ['joined', 'itemExists', IN_STATE, 'isHolder', 'correctionRefrozen', 'checkProvesSomething', 'barReady', 'criterionUnchanged', 'treeClean', 'nothingUntracked', 'hasCommit', 'withinLane', 'trunkMergeClean', 'trunkInCandidate', 'noUnverifiedStack', 'infraExplained', 'doctrineHolds', 'gateConfigured', 'queuedItemLease', 'gateGreen', 'treeStillDuringGate', 'submissionProofValid', 'childrenDone', 'headIsNew'],sets: ['item_built_by', 'item_commit'], command: 'pullboard submit <id>',},{@@ -250,13 +251,13 @@ export const MOVES = [},{verb: 'refreeze', from: ['open', 'claimed', 'submitted'], to: 'open', by: ['coordinator'], refuse: 'CLOSED',- guards: ['joined', 'coordinatorOnly', 'itemExists', IN_STATE, 'rowsInForce'],+ guards: ['joined', 'coordinatorOnly', 'itemExists', IN_STATE, 'barReady', 'rowsInForce'],when: 'there is no live claim awaiting a coordinator correction',sets: ['item_frozen_digest'], command: 'pullboard refreeze <id>',},{verb: 'refreeze', from: ['claimed'], to: 'claimed', by: ['agent', 'coordinator'], refuse: 'CLOSED',- guards: ['joined', 'itemExists', 'holderOrCoordinator', IN_STATE, 'rowsInForce'],+ guards: ['joined', 'itemExists', 'holderOrCoordinator', IN_STATE, 'barReady', 'rowsInForce'],when: 'a live claim has a pending coordinator correction',sets: ['item_frozen', 'item_frozen_digest'], command: 'pullboard refreeze <id>',},diff --git a/src/submit-composition.js b/src/submit-composition.jsnew file mode 100644index 00000000..b18cb1ed--- /dev/null+++ b/src/submit-composition.js@@ -0,0 +1,10 @@+/** Opted-in submission proofs run a committed composition with the pinned current trunk [M1,V4]. */+import { contains } from './git.js';+import { Refused } from './refused.js';++/** Refuse before execution, and again after it, if the exact main snapshot was not proved. */+export function requireSubmitComposition(root, candidate, trunk, expectedMain) {+ if (trunk.commit !== expectedMain || !contains(root, trunk.commit, candidate)) {+ throw new Refused('MAIN_NOT_COMPOSED', `the submission must contain current main ${trunk.commit.slice(0,12)} and prove that same snapshot; merge main into this worktree, commit the composition, then run pullboard submit <id> again`);+ }+}diff --git a/test/bar-coverage.test.js b/test/bar-coverage.test.jsnew file mode 100644index 00000000..7c573f64--- /dev/null+++ b/test/bar-coverage.test.js@@ -0,0 +1,117 @@+/** Signed test coverage preserves named checks, neighboring failures and the unchanged budget [V2,V4,M1]. */+import assert from 'node:assert/strict';+import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { test } from 'node:test';+import { barCoverageCommand, normalizeBarCoverage, prepareBarCoverage, barTestPath } from '../src/bar-coverage.js';+import { requireSubmitComposition } from '../src/submit-composition.js';+import { baselineTestEvidence } from '../src/check-baseline.js';+import { configFromSource } from '../src/config.js';+import { runFixtureChild } from './fixture-child.js';++const SHA = 'a'.repeat(40);+/** Synthetic observations test schema and arithmetic, not an actual performance claim. */+function observed(durationMs, selection = 'whole-file') {+ return { durationMs, selection, ref: 'private fixture receipt', sha256: 'b'.repeat(64), source: SHA, runtime: 'synthetic fixture runtime', outcome: 'pass' };+}+/** One bar keeps its original named command while adding a whole-file obligation. */+function example() {+ const path = 'test/adjacent.test.js';+ const item = { item_id: 1, item_check: `node --test --test-name-pattern named ${path}`, item_brief: `Files: ${path}\nTest: named proves the behavior` };+ const plan = { version: 1, sourceMain: SHA, sourceCheck: item.item_check, timeoutMs: 1000, runner: 'node --test', required: [path],+ files: [{ path, mode: 'whole', evidence: observed(400) }], named: observed(100, 'named-check'), installMs: 0 };+ return { item, plan, path };+}+/** A real private Git repository supplies accepted main and committed test inventory. */+function repository(t) {+ const root = mkdtempSync(join(tmpdir(), 'pullboard-bar-coverage-'));+ t.after(() => rmSync(root, { recursive: true, force: true }));+ const env = { ...process.env, GIT_AUTHOR_NAME: 'Fixture', GIT_AUTHOR_EMAIL: '[email protected]', GIT_COMMITTER_NAME: 'Fixture', GIT_COMMITTER_EMAIL: '[email protected]' };+ /** Keep hooks out of this synthetic project; product hooks and admission remain unchanged. */+ const git = (...args) => {+ const ran = runFixtureChild('git', ['-c','core.hooksPath=/dev/null',...args], { cwd: root, env, encoding: 'utf8' });+ assert.equal(ran.status, 0, ran.failure ?? ran.stderr);+ return ran.stdout.trim();+ };+ git('init','-q','-b','main');+ mkdirSync(join(root,'test'));+ writeFileSync(join(root,'test','adjacent.test.js'), "import { test } from 'node:test';\nimport assert from 'node:assert/strict';\ntest('named',()=>assert.ok(true));\ntest('neighbor',()=>assert.fail('neighbor still fails'));\n");+ git('add','.');git('commit','-qm','test: private bar fixture');+ return { root, git, env };+}++test('[V2,V4] a passing named check cannot hide the failing neighboring case', t => {+ const f = repository(t); const { item, plan } = example();+ const named = runFixtureChild('/bin/sh',['-c',item.item_check],{cwd:f.root,env:f.env,encoding:'utf8'});+ assert.equal(named.status,0,named.stderr);+ const whole = runFixtureChild('/bin/sh',['-c',barCoverageCommand(item.item_check,normalizeBarCoverage(plan,item))],{cwd:f.root,env:f.env,encoding:'utf8'});+ assert.notEqual(whole.status,0);+ assert.match(whole.stdout,/neighbor still fails/);+ assert.ok(barCoverageCommand(item.item_check,plan).startsWith(`(\n${item.item_check}\n)`),'original shell command remains intact');+});++test('[V2,V4] unknown, named-only or red duration cannot qualify a fast whole file', () => {+ const { item, plan } = example();+ for (const evidence of [null, observed(400,'named-check'), {...observed(400),outcome:'fail'}, {...observed(400),source:'unknown'}]) {+ assert.throws(()=>normalizeBarCoverage({...plan,files:[{...plan.files[0],evidence}]},item),e=>e.code==='BAR_COVERAGE');+ }+ assert.throws(()=>normalizeBarCoverage({...plan,files:[]},item),e=>e.code==='BAR_COVERAGE');+ assert.throws(()=>normalizeBarCoverage({...plan,files:[plan.files[0],plan.files[0]]},item),e=>e.code==='BAR_COVERAGE');+ assert.throws(()=>normalizeBarCoverage({...plan,required:['../outside.test.js']},item),e=>e.code==='BAR_COVERAGE');+});++test('[V2,V4] a slow file needs explicit landing coverage and keeps its named cases', () => {+ const { item, plan, path } = example();+ const slow = {...plan,files:[{path,mode:'landing',evidence:{...observed(1500),outcome:'timeout'},namedCases:['named']}]};+ assert.throws(()=>normalizeBarCoverage(slow,item),e=>e.code==='BAR_COVERAGE');+ item.item_brief += `\nLanding coverage: ${path} is covered by the landing gate`;+ const normalized = normalizeBarCoverage(slow,item);+ assert.equal(barCoverageCommand(item.item_check,normalized),item.item_check);+ assert.throws(()=>normalizeBarCoverage({...slow,files:[{...slow.files[0],evidence:observed(200)}]},item),e=>e.code==='BAR_COVERAGE','unknown or fast files cannot be silently deferred');+ assert.equal(normalized.timeoutMs,1000);+});++test('[V2,V4] the budget includes named, install and all whole files, without raising the timeout', () => {+ const { item, plan } = example();+ assert.throws(()=>normalizeBarCoverage({...plan,named:observed(700,'named-check')},item),e=>e.code==='BAR_COVERAGE');+ assert.throws(()=>normalizeBarCoverage({...plan,installMs:600,install:observed(600,'install')},item),e=>e.code==='BAR_COVERAGE');+ const equality = normalizeBarCoverage({...plan,named:observed(600,'named-check')},item);+ assert.equal(equality.totalMs,1000);+ assert.equal(equality.timeoutMs,1000);+});++test('[V2,V4] accepted project inventory and runner override a supplied plan without executing it', t => {+ const f = repository(t); const { item, plan } = example();+ item.item_brief = item.item_brief.replace('Files: test/adjacent.test.js', 'Files: test/adjacent.test.js, test/new.test.js');+ const sourceMain = f.git('rev-parse','HEAD');+ const config = configFromSource('{"affectedTests":"node custom-runner.js","check":{"timeout":"2s"}}');+ const file=join(f.root,'coverage.json');+ writeFileSync(file,JSON.stringify({...plan,runner:'false',timeoutMs:999999,required:[]}));+ const prepared = prepareBarCoverage(f.root,item,{commit:sourceMain,config},file);+ assert.deepEqual(prepared.required,['test/adjacent.test.js']);+ assert.equal(prepared.runner,'node custom-runner.js');+ assert.equal(prepared.timeoutMs,2000);+ assert.equal(prepared.sourceMain,sourceMain);+ assert.ok(barTestPath('tests/test_example.py',['**/test_*.py']));+ assert.equal(barTestPath('src/component.js',config.claim.barTestFiles),false);+ assert.throws(()=>prepareBarCoverage(f.root,item,{commit:sourceMain,config}),e=>e.code==='BAR_COVERAGE');+});++test('[M1,V4] a conflict-free candidate must contain the exact main used for submit proof', t => {+ const f=repository(t);const initial=f.git('rev-parse','HEAD');+ f.git('checkout','-qb','candidate');writeFileSync(join(f.root,'candidate.txt'),'candidate');f.git('add','.');f.git('commit','-qm','test: candidate');const candidate=f.git('rev-parse','HEAD');+ f.git('checkout','-q','main');writeFileSync(join(f.root,'main.txt'),'main');f.git('add','.');f.git('commit','-qm','test: main');const main=f.git('rev-parse','HEAD');+ assert.throws(()=>requireSubmitComposition(f.root,candidate,{commit:main},main),e=>e.code==='MAIN_NOT_COMPOSED');+ f.git('checkout','-q','candidate');f.git('merge','-qm','test: composition','main');const composed=f.git('rev-parse','HEAD');+ assert.doesNotThrow(()=>requireSubmitComposition(f.root,composed,{commit:main},main));+ assert.throws(()=>requireSubmitComposition(f.root,composed,{commit:main},initial),e=>e.code==='MAIN_NOT_COMPOSED','a different authority snapshot cannot inherit this proof');+});+++test('[V2,V4] baseline witness distinguishes observed failure, absent case and unrelated setup failure', () => {+ const failed = baselineTestEvidence('TAP version 13\nnot ok 1 - named witness\n ---\n duration_ms: 1\n ...\n', 'node --test');+ assert.deepEqual(failed, { failed: ['named witness'], passed: [], noTestsMatched: false });+ assert.equal(baselineTestEvidence('run-tests: NO_TESTS_MATCHED: no named case', 'node bin/run-tests.js').noTestsMatched, true);+ assert.deepEqual(baselineTestEvidence('Error: module missing', 'node --test'), { failed: [], passed: [], noTestsMatched: false });+});diff --git a/test/claim-reopen.test.js b/test/claim-reopen.test.jsindex 8bdebd7b..451290ca 100644--- a/test/claim-reopen.test.js+++ b/test/claim-reopen.test.js@@ -197,14 +197,15 @@ function readyAuthors(f) {function readyItem(f, result = 'red') {return store.addItem(f.board, { by: 'coordinator', lane: 'core', title: 'ready bar', route: 'mid',criterion: 'the named behavior works', check: 'node --test --test-name-pattern "named witness" test/a.test.js',- checkBaseline: { command: 'node --test --test-name-pattern "named witness" test/a.test.js', main: COMMIT, result },+ checkBaseline: { command: 'node --test --test-name-pattern "named witness" test/a.test.js', main: COMMIT, result, testEvidence: { failed: ['named witness'], passed: [], noTestsMatched: false } },brief: 'Files: src/a.js\nTest: named witness asserts the behavior\nNamed test: named witness\nMeasurements: no quantitative acceptance bounds\nReviewer edges: empty input and concurrent edit' });}/** Sign the currently read revision, keeping stale requests independently testable. */function signReady(f, id, agentId = f.other) {const { revision } = barReadiness(f.board, store.getItem(f.board, id));return signBar(f.board, id, { agentId, revision: revision.revision, digest: revision.digest,- note: 'The builder can meet this bar; two reviewers can use the named witness and listed edges to grade it alike.' });+ note: 'The builder can meet this bar; two reviewers can use the named witness and listed edges to grade it alike.',+ coverage: { version: 1, sourceMain: COMMIT, sourceCheck: store.getItem(f.board,id).item_check, timeoutMs: 300000, runner: 'node --test', required: [], files: [] } });}test('[B4,V2,V1,H16] a claim waits for a bar signed by another session', (t) => {@@ -281,6 +282,22 @@ test('[B4,V1] unknown lineage and a changed baseline cannot masquerade as peer aconst request = '12345678-1234-1234-1234-123456789abc';store.editItem(f.board, fresh, { agentId: 'coordinator', check: command, checkBaseline: { command, main: COMMIT, result: 'pending', request } });assert.ok(barReadiness(f.board, store.getItem(f.board, fresh)).missing.some(part => part.includes('red check baseline')));- store.completeCheckBaseline(f.board, fresh, { agentId: 'coordinator', expected: { command, main: COMMIT, request }, baseline: { command, main: COMMIT, result: 'red', request } });+ store.completeCheckBaseline(f.board, fresh, { agentId: 'coordinator', expected: { command, main: COMMIT, request }, baseline: { command, main: COMMIT, result: 'red', request, testEvidence: { failed: ['named witness'], passed: [], noTestsMatched: false } } });assert.ok(barReadiness(f.board, store.getItem(f.board, fresh)).missing.some(part => part.includes('sign-off')), 'new baseline observation needs a new sign-off');});+++test('[B4,V1] enabling readiness cannot relabel a retained criterion as the later brief editor', (t) => {+ const f = fixture(t);+ readyAuthors(f);+ const brief = 'Files: src/old.js\nTest: old witness\nNamed test: old witness\nMeasurements: no quantitative bounds\nReviewer edges: empty input';+ const id = store.addItem(f.board, { by: f.other, lane: 'core', title: 'original author', criterion: 'original judgement', brief });+ setBarReady(f.board, { agentId: 'coordinator', enabled: true });+ const check = 'node --test --test-name-pattern "old witness" test/old.test.js';+ store.editItem(f.board, id, { agentId: 'coordinator', brief: brief+'\nAn additional edge.', check,+ checkBaseline: { command: check, main: COMMIT, result: 'red', testEvidence: { failed: ['old witness'], passed: [], noTestsMatched: false } } });+ const status = barReadiness(f.board, store.getItem(f.board, id));+ assert.equal(status.revision.authors.item_criterion.agent, f.other);+ assert.equal(status.revision.authors.item_brief.agent, 'coordinator');+ assert.throws(() => signReady(f, id, f.other), error => error.code === 'BAR_SELF_SIGN');+});