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(grant): keep attributed findings available across claims [E21,H16]
Corey Olsonade9de1ce454
diff --git a/src/agent-grant.js b/src/agent-grant.jsindex 7479356e..9387273b 100644--- a/src/agent-grant.js+++ b/src/agent-grant.js@@ -3,7 +3,8 @@ import { AGENT_GRANT_ENGINE } from './agent-grant-engine.js';import { MOVE_REGISTRY } from './move-registry.js';import { Refused } from './refused.js';-const ADMINISTRATIVE = new Set(['shout', 'claim', 'release', 'reserveReview']);+// Attributed append-only findings never confer authority over item state.+const ADMINISTRATIVE = new Set(['shout', 'claim', 'release', 'reserveReview', 'appendFact']);/** Bind only item mutations declared by the public operation, including item creation. */function target(move) {@@ -46,14 +47,9 @@ export function requireAgentGrant(board, move, at = board.clock.now()) {if (!scope) return;const item = existingItem(board, scope.item);if (!scope.creating && !item) return; // Preserve the operation's own malformed/missing-item refusal.- // The seat's immutable handoff-open event grants only its own channel facts, not other item work.- // Replacement fencing runs before this guard, so a taken-over seat keeps only its existing shout path.- if (move.operation === 'appendFact' && board.db.prepare(- "SELECT event_id FROM event WHERE item_id=? AND event_by=? AND event_kind='handoff-open' LIMIT 1")- .get(item.item_id, actor)) return;const now = at.toISOString();if (item?.item_review_by === actor && item.item_status === 'submitted' && item.item_review_until > now- && ['verify', 'appendFact'].includes(move.operation)) return;+ && move.operation === 'verify') return;const claims = board.db.prepare("SELECT item_id,item_lease_until FROM item WHERE item_owner=? AND item_status='claimed'").all(actor);const own = claims.find(claim => claim.item_id === item?.item_id);const live = claims.filter(claim => claim.item_lease_until > now);diff --git a/test/team.test.js b/test/team.test.jsindex 4512b988..78ad6ed5 100644--- a/test/team.test.js+++ b/test/team.test.js@@ -905,23 +905,25 @@ test('an agent grant narrows at claim and expires identically on independent repassert.deepEqual(outcomes[0], outcomes[1], 'the same move has the same public result on both replicas');return outcomes[0];};- /** Facts are ordinary item mutations, not a claim-only or CLI-only permission check. */+ /** Facts remain communication; escalation supplies the state-change grant witness. */const fact = (item, text, at, by = actor) => replay('appendFact', [item, { agentId: by, kind: 'note', text }], at);- assert.equal(fact(1, 'Own claimed item remains writable').error, undefined, 'positive own-item mutation reached the engine');- const before = roots.map(root => withBoard(root, board => store.itemThread(board, 2).filter(entry => entry.type === 'fact')));- const outside = fact(2, 'This must not reach another item');+ /** Escalation changes item state and must stay inside the computed grant. */+ const change = (item, note, at, by = actor) => replay('escalate', [item, { agentId: by, note }], at);+ assert.equal(fact(1, 'Own claimed item remains writable').error, undefined, 'positive own-item communication reached the engine');+ const before = roots.map(root => withBoard(root, board => store.getItem(board, 2)));+ const outside = change(2, 'This must not change another item');assert.equal(outside.error?.code, 'AGENT_GRANT_ITEM', 'claim narrows item mutations even inside the same lane');- assert.deepEqual(roots.map(root => withBoard(root, board => store.itemThread(board, 2).filter(entry => entry.type === 'fact'))), before,- 'a refused move cannot leave a fact on either replica');- assert.equal(fact(1, 'The expired lease no longer authorizes a move', expired).error?.code,+ assert.deepEqual(roots.map(root => withBoard(root, board => store.getItem(board, 2))), before,+ 'a refused state change cannot modify either replica');+ assert.equal(change(1, 'The expired lease no longer authorizes a move', expired).error?.code,'AGENT_GRANT_EXPIRED', 'ordered receipt time, not the receiving machine clock, ends the grant');// Administrative communication and release cannot be trapped behind the grant being reported.assert.equal(replay('shout', [{ from: actor, to: 'coordinator', text: 'My claim expired; arranging the next work.', lanes: ['web', 'api'] }], expired).error,undefined, 'ordinary coordination remains available after expiry');assert.equal(replay('release', [1, actor, 'Done with this claim.'], expired).error, undefined);- assert.equal(fact(1, 'Release does not revive an expired grant', expired).error?.code, 'AGENT_GRANT_EXPIRED',+ assert.equal(change(1, 'Release does not revive an expired grant', expired).error?.code, 'AGENT_GRANT_EXPIRED','a fresh claim is required after expiry even after administrative release');- assert.equal(fact(3, 'An agent cannot mutate another lane', expired, freshActor).error?.code, 'AGENT_GRANT_LANE',+ assert.equal(change(3, 'An agent cannot mutate another lane', expired, freshActor).error?.code, 'AGENT_GRANT_LANE','a fresh unclaimed seat still has only its registered lane');});@@ -957,11 +959,11 @@ test('an agent grant narrows at claim without changing old receipts or permittinconst options = { agentId: actor, lane: 'web', leaseMs: 60_000, freeze };apply('claim', [1, options]);const prior = apply('appendFact', [2, { agentId: actor, kind: 'note', text: 'Legacy behavior stays recorded.' }]);- const forged = prepareEngineMove(boards[0], 'appendFact', [2, { agentId: actor, kind: 'note', text: 'Old engine cannot bypass the new claim.' }]);+ const forged = prepareEngineMove(boards[0], 'escalate', [2, { agentId: actor, note: 'Old engine cannot bypass the new claim.' }]);forged.engine = legacy;- const oldPeer = prepareEngineMove(boards[0], 'appendFact', [1, { agentId: other, kind: 'note', text: 'Another old seat must understand the new item grant.' }]);+ const oldPeer = prepareEngineMove(boards[0], 'escalate', [1, { agentId: other, note: 'Another old seat must understand the new item grant.' }]);oldPeer.engine = legacy;- const oldTextPeer = prepareEngineMove(boards[0], 'appendFact', ['1', { agentId: other, kind: 'note', text: 'Numeric text cannot hide the newly claimed target from an old engine.' }]);+ const oldTextPeer = prepareEngineMove(boards[0], 'escalate', ['1', { agentId: other, note: 'Numeric text cannot hide the newly claimed target from an old engine.' }]);oldTextPeer.engine = legacy;apply('claim', [1, options], AGENT_GRANT_ENGINE);for (const board of boards) {@@ -1009,13 +1011,13 @@ test('an agent grant narrows at claim without trapping its own handoff facts [E2const channels = roots.map(root => withBoard(root, board => board.db.prepare("SELECT item_id FROM event WHERE event_by=? AND event_kind='handoff-open' ORDER BY event_id DESC LIMIT 1").get(actor).item_id));assert.equal(channels[0], channels[1]);- /** A channel fact remains an ordinary fact move, scoped by its canonical handoff-open event. */+ /** Handoff and ordinary item facts both remain available without state-change authority. */const fact = (item, text, at) => replay('appendFact', [item, { agentId: actor, kind: 'note', text }], at);assert.equal(fact(channels[0], 'Context for the incoming seat').error, undefined,'the live build claim cannot block facts on its own handoff channel');- assert.equal(fact(2, 'Not a handoff channel').error?.code, 'AGENT_GRANT_ITEM');+ assert.equal(fact(2, 'Findings also belong on ordinary items').error, undefined);assert.equal(fact(channels[0], 'More context after the build lease ended', expired).error, undefined);- assert.equal(fact(2, 'Expiry is not general authority', expired).error?.code, 'AGENT_GRANT_EXPIRED');+ assert.equal(fact(2, 'Expiry does not block findings', expired).error, undefined);});@@ -1035,25 +1037,25 @@ test('an agent grant narrows at claim for accepted numeric-text item ids [E21,H1const during = new Date(Date.parse(held.item_lease_until) - 1000).toISOString();const expired = new Date(Date.parse(held.item_lease_until) + 1).toISOString();/** Keep the public engine argument bytes while both replicas resolve the same native row. */- const fact = (item, text, at = during) => {- const move = withBoard(box.repo, board => prepareEngineMove(board, 'appendFact', [item, { agentId: actor, kind: 'note', text }]));+ const change = (item, note, at = during) => {+ const move = withBoard(box.repo, board => prepareEngineMove(board, 'escalate', [item, { agentId: actor, note }]));const outcomes = roots.map(root => withBoard(root, board => applyEngineMove(board, move,{ sequence: appliedSequence(board) + 1, at })));assert.deepEqual(outcomes[0], outcomes[1]);return outcomes[0];};- assert.equal(fact('1', 'Accepted numeric text still names the own item').error, undefined,- 'a guard must preserve the existing accepted item-id form');const before = roots.map(root => withBoard(root, board => store.itemThread(board, 2)));for (const item of ['2', '02', '2.0', ' 2 ']) {- assert.equal(fact(item, 'An alternate spelling does not enlarge authority').error?.code, 'AGENT_GRANT_ITEM',+ assert.equal(change(item, 'An alternate spelling does not enlarge authority').error?.code, 'AGENT_GRANT_ITEM',`the existing target ${JSON.stringify(item)} is still outside the claim`);}assert.deepEqual(roots.map(root => withBoard(root, board => store.itemThread(board, 2))), before,'numeric-text refusals add no item facts on either replica');- assert.equal(fact('1', 'Text cannot extend an expired lease', expired).error?.code, 'AGENT_GRANT_EXPIRED');- assert.equal(fact('999999', 'A missing target stays missing', expired).error?.code, 'NO_ITEM');- assert.equal(fact('not-an-id', 'Malformed text keeps its existing refusal', expired).error?.code, 'NO_ITEM');+ assert.equal(change('1', 'Text cannot extend an expired lease', expired).error?.code, 'AGENT_GRANT_EXPIRED');+ assert.equal(change('999999', 'A missing target stays missing', expired).error?.code, 'NO_ITEM');+ assert.equal(change('not-an-id', 'Malformed text keeps its existing refusal', expired).error?.code, 'NO_ITEM');+ assert.equal(change('1', 'Accepted numeric text still names the own item').error, undefined,+ 'a state change must preserve the existing accepted item-id form');});/** Real Git and two private SQLite replicas; seeded acceptances are lifecycle fixtures, not executed gates. */