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
fix(core): preserve bar grandfathering and authorship [B4,V2,V1]
Corey Olsond40f62c6f2b4
diff --git a/docs/lifecycle.md b/docs/lifecycle.mdindex 9b2213fc..a2f21994 100644--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@ -54,10 +54,10 @@ Each move checks its guards in this order and refuses with the first one that do| Move | From | To | Who | Guards, in order; result refusals || --- | --- | --- | --- | --- |-| claim | open, claimed | claimed | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_CLAIMABLE), checkProvesSomething (CRITERION_PROVES_NOTHING), 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) |+| 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), 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), 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) |@@ -136,6 +136,7 @@ Each move checks its guards in this order and refuses with the first one that do| 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 || GUARD_CANNOT_FAIL | the frozen item check passes at the submitted commit, or its clean reviewed composition for a stale acceptance | reject: the check stays green with the named guard reverted || GUARD_NOT_FOUND | the frozen item check passes at the submitted commit, or its clean reviewed composition for a stale acceptance | the named guard is not in the submitted commit; ask the coordinator to fix it |+| BAR_NOT_READY | an opted-in new bar has a named red baseline, measurement notes, reviewer edges and a revision-bound signature from another parent session, bar ready is on and this bar was frozen or edited after activation | the author completes the brief, then another parent runs pullboard bar sign <id> || CRITERION_PROVES_NOTHING | the item's check does not already pass on main, or the person accepted that exact check, only when accepted main sets checks.provesNothing to "hold" | set a check that fails before the work, or the person runs pullboard check accept <id> || GATE_RED | the gate, which submit runs itself every time, is green at HEAD | fix what the digest names, commit, submit again || LAND_TIMEOUT_CUSTODY | the gate, which submit runs itself every time, is green at HEAD | inspect the saved timed gate cleanup state and stop only its proven owned processes before starting another landing |diff --git a/src/bar-readiness.js b/src/bar-readiness.jsindex ddd13db8..c4744050 100644--- a/src/bar-readiness.js+++ b/src/bar-readiness.js@@ -34,19 +34,32 @@ export function setBarReady(board, { agentId, enabled }) {return atomic(board, () => {const prior = barReadySetting(board);if (prior.enabled === enabled) return prior;- logEvent(board, agentId, 'bar-ready', null, { enabled });+ const grandfathered = enabled ? board.db.prepare('SELECT * FROM item WHERE item_frozen_digest IS NOT NULL').all().map(item => ({ id: item.item_id, digest: barDigest(item), frozen: item.item_frozen_digest, revision: read(board, `bar_revision:${item.item_id}`)?.revision ?? 0 })) : [];+ logEvent(board, agentId, 'bar-ready', null, { enabled, grandfathered });const setting = { enabled, since: board.lastEvent.event_id };+ for (const bar of grandfathered) save(board, `bar_grandfather:${bar.id}`, { ...bar, since: setting.since });save(board, 'bar_ready_setting', setting);return setting;});}+/** Retain every field's prior author when readiness is enabled on an existing open item. */+function historicalAuthors(board, item) {+ const fields = Object.fromEntries(FIELDS.map(field => [field, item.item_created_by]));+ for (const event of board.db.prepare("SELECT event_by,event_detail FROM event WHERE item_id=? AND event_kind='edit' ORDER BY event_id").all(item.item_id)) {+ const detail = JSON.parse(event.event_detail);+ for (const [key, field] of Object.entries({ brief: 'item_brief', criterion: 'item_criterion', check: 'item_check', after: 'item_after', route: 'item_route' })) {+ if (Object.hasOwn(detail, key)) fields[field] = event.event_by;+ }+ }+ return Object.fromEntries(Object.entries(fields).map(([field, agent]) => [field, { agent, parent: parent(board, agent) }]));+}/** Snapshot authors on semantic edits, never retroactively upgrading an unknown historical parent. */export function recordBarRevision(board, item, by, before = null) {if ((board.executionEngineVersion ?? ENGINE_VERSION) < BAR_READY_ENGINE || !barReadySetting(board).enabled) return;const previous = read(board, `bar_revision:${item.item_id}`);- const changed = FIELDS.filter(key => !previous || !before || before[key] !== item[key]);- if (!changed.length) return;- const authors = { ...(previous?.authors ?? {}) };+ const changed = FIELDS.filter(key => !before || before[key] !== item[key]);+ if (!changed.length && previous) return;+ const authors = previous?.authors ?? historicalAuthors(board, item);for (const field of FIELDS) {if (changed.includes(field)) authors[field] = { agent: by, parent: parent(board, by) };else if (!authors[field]) authors[field] = { agent: item.item_created_by, parent: parent(board, item.item_created_by) };@@ -72,9 +85,10 @@ export function barReadinessRequired(board, item) {const setting = barReadySetting(board);if (!setting.enabled) return false;if (!item.item_frozen_digest) return true;- const edited = read(board, `bar_revision:${item.item_id}`)?.revision ?? 0;- const frozen = board.db.prepare("SELECT MAX(event_id) AS id FROM event WHERE item_id=? AND event_kind IN ('claim','refreeze')").get(item.item_id).id ?? 0;- return Math.max(edited, frozen) > setting.since;+ const old = read(board, `bar_grandfather:${item.item_id}`);+ const revision = read(board, `bar_revision:${item.item_id}`)?.revision ?? 0;+ return !old || old.since !== setting.since || old.digest !== barDigest(item)+ || old.frozen !== item.item_frozen_digest || old.revision !== revision;}/** Mechanical omissions are aggregated, so the coordinator can repair the bar in one pass. */export function barReadiness(board, item, { signature = true } = {}) {diff --git a/test/claim-reopen.test.js b/test/claim-reopen.test.jsindex 25f252fa..8bdebd7b 100644--- a/test/claim-reopen.test.js+++ b/test/claim-reopen.test.js@@ -118,7 +118,7 @@ test('[B13,B5] first refusal does not bypass the existing one-live-claim rule',const f = fixture(t);const id = returned(f, 'landing', 30);const second = store.addItem(f.board, { by: 'coordinator', lane: 'core', title: 'another', route: 'mid',- criterion: 'prove', check: 'true', brief: 'Files: src/a.js\nTest: proves another fix' });+ criterion: 'prove', check: 'true', brief: 'Files: src/unrelated.js\nTest: proves another fix' });claim(f, second, f.builder);assert.throws(() => claim(f, id, f.builder), error => error.code === 'ONE_CLAIM');store.release(f.board, second, f.builder);@@ -130,7 +130,7 @@ test('[B13,B5] releasing another review cannot cancel the builder reservation',const f = fixture(t);const id = returned(f, 'reject', 30);const another = store.addItem(f.board, { by: 'coordinator', lane: 'core', title: 'review another', route: 'mid',- criterion: 'prove', check: 'true', brief: 'Files: src/a.js\nTest: proves another fix' });+ criterion: 'prove', check: 'true', brief: 'Files: src/unrelated.js\nTest: proves another fix' });claim(f, another, f.other);submitFixture(f.board, another, { agentId: f.other, commit: COMMIT, tree: COMMIT });store.reserveReview(f.board, another, { agentId: f.builder, leaseMs: 1_800_000, policy: 'any' });@@ -207,7 +207,7 @@ function signReady(f, id, agentId = f.other) {note: 'The builder can meet this bar; two reviewers can use the named witness and listed edges to grade it alike.' });}-test('[U113,V1,H16] a claim waits for a bar signed by another session', (t) => {+test('[B4,V2,V1,H16] a claim waits for a bar signed by another session', (t) => {const f = fixture(t);readyAuthors(f);setBarReady(f.board, { agentId: 'coordinator', enabled: true });@@ -230,7 +230,7 @@ test('[U113,V1,H16] a claim waits for a bar signed by another session', (t) => {assert.equal(barReadiness(replica, store.getItem(replica, id)).missing.length, 0);});-test('[U113,H16] readiness is default off and activation preserves old frozen work', (t) => {+test('[B4,V2,H16] readiness is default off and activation preserves old frozen work', (t) => {const f = fixture(t);assert.equal(barReadySetting(f.board).enabled, false);const old = readyItem(f, 'green');@@ -239,7 +239,8 @@ test('[U113,H16] readiness is default off and activation preserves old frozen woconst activation = setBarReady(f.board, { agentId: 'coordinator', enabled: true });assert.deepEqual(setBarReady(f.board, { agentId: 'coordinator', enabled: true }), activation, 'repeating on cannot grandfather new obligations');claim(f, old, f.builder);- store.release(f.board, old, f.builder);+ claim(f, old, f.builder);+ submitFixture(f.board, old, { agentId: f.builder, commit: COMMIT, tree: COMMIT });const fresh = readyItem(f, 'green');assert.throws(() => claim(f, fresh, f.builder), error => error.code === 'BAR_NOT_READY' && error.message.includes('red check baseline'));setBarReady(f.board, { agentId: 'coordinator', enabled: false });@@ -250,7 +251,7 @@ test('[U113,H16] readiness is default off and activation preserves old frozen woassert.throws(() => setBarReady(f.board, { agentId: f.other, enabled: false }), error => error.code === 'COORDINATOR_ONLY');});-test('[U113,V2] all missing bar parts are named and content reversal cannot revive a signature', (t) => {+test('[B4,V2] all missing bar parts are named and content reversal cannot revive a signature', (t) => {const f = fixture(t);readyAuthors(f);setBarReady(f.board, { agentId: 'coordinator', enabled: true });@@ -267,7 +268,7 @@ test('[U113,V2] all missing bar parts are named and content reversal cannot reviclaim(f, id, f.builder);});-test('[U113,V1] unknown lineage and a changed baseline cannot masquerade as peer approval', (t) => {+test('[B4,V1] unknown lineage and a changed baseline cannot masquerade as peer approval', (t) => {const f = fixture(t);setBarReady(f.board, { agentId: 'coordinator', enabled: true });const id = readyItem(f);diff --git a/test/machine.test.js b/test/machine.test.jsindex 28c1976a..f5bf3df6 100644--- a/test/machine.test.js+++ b/test/machine.test.js@@ -951,7 +951,12 @@ test('claim refuses in the declared order, one failure peeled at a time, on a resubmitFixture(board, dependency, { agentId: 'web-1', commit: SHA_A, tree: 'tree' });store.holdLane(board, 'web', { agentId: 'coordinator', reason: 'pause' });store.holdItem(board, target, { agentId: 'coordinator', reason: 'item pause' });- const fired = [claimAs(999, light, 'api'), claimAs(done, light, 'api'), claimAs(target, light, 'api')];+ const fired = [claimAs(999, light, 'api'), claimAs(done, light, 'api')];+ store.setBarReady(board, { agentId: 'coordinator', enabled: true });+ store.editItem(board, target, { agentId: 'coordinator', brief: 'Unsigned bar edge' });+ fired.push(claimAs(target, light, 'api'));+ store.setBarReady(board, { agentId: 'coordinator', enabled: false });+ fired.push(claimAs(target, light, 'api'));store.releaseItemHold(board, target, { agentId: 'coordinator' });fired.push(claimAs(target, light, 'api'), claimAs(target, light, 'web'), claimAs(target, strong, 'web'));verdictOn(board, dependency, 'web-2', 'ACCEPT');@@ -967,7 +972,7 @@ test('claim refuses in the declared order, one failure peeled at a time, on a restore.release(board, spare, strong);fired.push(claimAs(target, strong, 'web'), claimAs(target, strong, 'web', freeze));assert.deepEqual(fired, [...declaredBoardOrder('claim'), 'ok']);- assert.deepEqual(fired, ['NO_ITEM', 'NOT_CLAIMABLE', 'ITEM_HELD', 'WRONG_LANE', 'ROUTE', 'BLOCKED', 'HELD', 'REOPEN_HELD_FOR_BUILDER', 'PENDING_REFREEZE', 'LANE_HELD', 'ONE_CLAIM', 'UNKNOWN_SPEC', 'ok']);+ assert.deepEqual(fired, ['NO_ITEM', 'NOT_CLAIMABLE', 'BAR_NOT_READY', 'ITEM_HELD', 'WRONG_LANE', 'ROUTE', 'BLOCKED', 'HELD', 'REOPEN_HELD_FOR_BUILDER', 'PENDING_REFREEZE', 'LANE_HELD', 'ONE_CLAIM', 'UNKNOWN_SPEC', 'ok']);} finally {lab.done();}@@ -987,6 +992,10 @@ test('submit, accept and reject refuse in the declared order, one failure peeledsubmits.push(submitAs(piece, 'web-1', SHA_A));assert.equal(submits.at(-1), 'PENDING_REFREEZE', 'a pending correction stops the board submission before later guards');store.refreeze(board, piece, { agentId: 'web-1', freeze });+ store.setBarReady(board, { agentId: 'coordinator', enabled: true });+ store.editItem(board, piece, { agentId: 'coordinator', brief: 'Unsigned corrected bar' });+ submits.push(submitAs(piece, 'web-1', SHA_A));+ store.setBarReady(board, { agentId: 'coordinator', enabled: false });submits.push(outcome(() => submitFixture(board, piece, { agentId: 'web-1', commit: SHA_A, tree: 'tree',submissionProof: { version: 99, files: [], full: false, deferred: true, reason: '' } })));submitFixture(board, piece, { agentId: 'web-1', commit: SHA_A, tree: 'tree' });