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: traverse verified dependency chains [B3,V4]
Corey Olsonb2bc99ba4394
diff --git a/src/trusted-policy.js b/src/trusted-policy.jsindex a11ef88f..aad545dd 100644--- a/src/trusted-policy.js+++ b/src/trusted-policy.js@@ -119,14 +119,21 @@ export function submissionPaths(root, item, commit, { config, mainCommit, dependreturn paths;}-/** Verified dependencies may contribute their own unchanged lane files before the coordinator merges them [N16]. */+/** Verified dependencies may contribute their own unchanged lane files, including through a verified chain [N16]. */export function dependencySnapshots(db, item) {- const ids = String(item.item_after ?? '').split(',').map(Number).filter(id => Number.isSafeInteger(id) && id > 0);- return ids.flatMap(id => {- const row = db.prepare("SELECT item_lane, item_claim_head, item_commit FROM item WHERE item_id=? AND item_status='verified' AND EXISTS (SELECT 1 FROM verdict WHERE item_id=? AND verdict_decision='ACCEPT' AND verdict_commit=item.item_commit)").get(id, id);- return row?.item_claim_head && /^[0-9a-f]{40,64}$/.test(row.item_commit ?? '')- ? [{ lane: row.item_lane, base: row.item_claim_head, commit: row.item_commit }] : [];- });+ const pending = String(item.item_after ?? '').split(',').map(Number).filter(id => Number.isSafeInteger(id) && id > 0);+ const visited = new Set();+ const snapshots = [];+ while (pending.length) {+ const id = pending.shift();+ if (visited.has(id)) continue;+ visited.add(id);+ const row = db.prepare("SELECT item_lane, item_claim_head, item_commit, item_after FROM item WHERE item_id=? AND item_status='verified' AND EXISTS (SELECT 1 FROM verdict WHERE item_id=? AND verdict_decision='ACCEPT' AND verdict_commit=item.item_commit)").get(id, id);+ if (!row?.item_claim_head || !/^[0-9a-f]{40,64}$/.test(row.item_commit ?? '')) continue;+ snapshots.push({ lane: row.item_lane, base: row.item_claim_head, commit: row.item_commit });+ pending.push(...String(row.item_after ?? '').split(',').map(Number).filter(dependency => Number.isSafeInteger(dependency) && dependency > 0));+ }+ return snapshots;}/** Read the command frozen with the criterion, preventing a later edit from changing its proof. */diff --git a/test/e2e-policy.test.js b/test/e2e-policy.test.jsindex 65758e93..02635538 100644--- a/test/e2e-policy.test.js+++ b/test/e2e-policy.test.js@@ -22,7 +22,7 @@ import { connect } from 'node:net';import { join, resolve } from 'node:path';import { after, test } from 'node:test';import { parseSpec } from '../src/spec.js';-import { checkAtCommit } from '../src/trusted-policy.js';+import { checkAtCommit, dependencySnapshots, submissionPaths } from '../src/trusted-policy.js';import * as store from '../src/board.js';import { createE2eHelpers } from './e2e-helpers.js';@@ -252,3 +252,111 @@ test('a detached coordinator review cannot become a new claim policy [V4,V16]',assert.equal(submitted.code, 1);assert.equal(JSON.parse(submitted.out).error.code, 'OUTSIDE_LANE');});++test("a dependency's own verified dependency admits its files [N16,V4]", () => {+ const box = project('true');+ const config = JSON.parse(readFileSync(join(box.repo, 'pullboard.json'), 'utf8'));+ config.lanes.design = { owns: ['design/'], specs: ['G1'] };+ writeFileSync(join(box.repo, 'pullboard.json'), JSON.stringify(config, null, 2));+ box.git(box.repo, 'add', 'pullboard.json');+ box.git(box.repo, 'commit', '-q', '-m', 'chore: add design fixture lane');+ box.git(box.web, 'merge', '-q', '--ff-only', 'main');++ const api = join(box.dir, 'api-1');+ const design = join(box.dir, 'design-1');+ box.git(box.repo, 'worktree', 'add', '-q', api, '-b', 'api/one');+ box.git(box.repo, 'worktree', 'add', '-q', design, '-b', 'design/one');+ assert.equal(box.run(api, 'join', 'api').code, 0);+ assert.equal(box.run(design, 'join', 'design').code, 0);++ let nextId = 1;+ /** Add a fixture item from the coordinator checkout and return its sequential id. */+ const add = (lane, title, after = null) => {+ const args = ['add', lane, title];+ if (after !== null) args.push('--after', String(after));+ const result = box.run(box.repo, ...args);+ assert.equal(result.code, 0, result.err || result.out);+ return nextId++;+ };+ /** Claim, commit, and submit one fixture item through the real CLI lifecycle. */+ const buildAndSubmit = (cwd, lane, id, path, content) => {+ assert.equal(box.run(cwd, 'claim', String(id)).code, 0, `claim #${id}`);+ const spec = lane === 'api' ? 'G2' : 'G1';+ const commit = commitFile(box, cwd, path, content, `feat(${lane}): fixture item [${spec}]`);+ assert.equal(commit.status, 0, commit.stderr || commit.failure || `commit #${id}`);+ const submitted = box.run(cwd, 'submit', String(id), '--json');+ assert.equal(submitted.code, 0, submitted.err || submitted.out);+ return box.git(cwd, 'rev-parse', 'HEAD');+ };+ /** Record a real accepted verdict from the other lane's worktree. */+ const accept = (cwd, id, note) => {+ const result = box.run(cwd, 'verify', String(id), 'accept', '--note', note, '--json');+ assert.equal(result.code, 0, result.err || result.out);+ };++ const webItem = add('web', 'verified web ancestor');+ const webCommit = buildAndSubmit(box.web, 'web', webItem, 'web/ancestor.txt', 'ancestor bytes\n');+ box.git(api, 'merge', '-q', '--ff-only', 'web/one');+ accept(api, webItem, 'the web ancestor submitted cleanly');++ const apiItem = add('api', 'verified api middle', webItem);+ const apiCommit = buildAndSubmit(api, 'api', apiItem, 'api/middle.txt', 'middle bytes\n');+ box.git(box.web, 'merge', '-q', '--ff-only', 'api/one');+ accept(box.web, apiItem, 'the api middle submitted cleanly');++ const designItem = add('design', 'transitive design target', apiItem);+ assert.equal(box.run(design, 'claim', String(designItem)).code, 0);+ box.git(design, 'merge', '-q', '--ff-only', 'api/one');+ const targetChange = commitFile(box, design, 'design/target.txt', 'target bytes\n', 'feat(design): target fixture [G1]');+ assert.equal(targetChange.status, 0, targetChange.stderr || targetChange.failure || 'target commit');+ const submitted = box.run(design, 'submit', String(designItem), '--json');+ assert.equal(submitted.code, 0, submitted.err || submitted.out);+ const targetCommit = box.git(design, 'rev-parse', 'HEAD');+ const target = JSON.parse(box.run(design, 'show', String(designItem), '--json').out);+ assert.equal(JSON.parse(box.run(box.repo, 'show', String(webItem), '--json').out).item_commit, webCommit);+ assert.equal(JSON.parse(box.run(box.repo, 'show', String(apiItem), '--json').out).item_commit, apiCommit);++ const board = store.openBoard(join(box.repo, '.git/pullboard/board.sqlite'));+ try {+ const snapshots = dependencySnapshots(board.db, target);+ assert.deepEqual(snapshots.map(snapshot => snapshot.lane), ['api', 'web']);+ assert.deepEqual(dependencySnapshots(board.db, { ...target, item_after: `${apiItem},${apiItem}` }), snapshots,+ 'a duplicate dependency is visited only once');+ assert.ok(submissionPaths(box.repo, target, targetCommit, { dependencies: snapshots }).includes('web/ancestor.txt'),+ 'the verified dependency chain admits the exact ancestor bytes');++ const unverifiedItem = add('api', 'unverified api middle', webItem);+ const unverifiedCommit = buildAndSubmit(api, 'api', unverifiedItem, 'api/unverified.txt', 'unverified bytes\n');+ assert.equal(JSON.parse(box.run(box.repo, 'show', String(unverifiedItem), '--json').out).item_status, 'submitted');+ const withUnverifiedOnly = { ...target, item_after: String(unverifiedItem) };+ assert.deepEqual(dependencySnapshots(board.db, withUnverifiedOnly), [],+ 'an unverified middle item does not expose its verified parent');++ const frozen = JSON.parse(target.item_frozen);+ const isolatedTarget = {+ ...target,+ item_claim_head: targetCommit,+ item_frozen: JSON.stringify({ ...frozen, policy: { ...frozen.policy, commit: targetCommit } }),+ };+ mkdirSync(join(design, 'api'), { recursive: true });+ writeFileSync(join(design, 'api/unverified.txt'), readFileSync(join(api, 'api/unverified.txt')));+ const unverifiedCandidate = attackCommit(box, design);+ assert.ok(unverifiedCommit);+ assert.throws(() => submissionPaths(box.repo, isolatedTarget, unverifiedCandidate, { dependencies: [] }),+ error => error.code === 'OUTSIDE_LANE');++ box.git(design, 'reset', '--hard', '-q', targetCommit);+ writeFileSync(join(design, 'web/ancestor.txt'), 'corrupted ancestor bytes\n');+ const corruptedCandidate = attackCommit(box, design);+ assert.throws(() => submissionPaths(box.repo, isolatedTarget, corruptedCandidate, { dependencies: snapshots }),+ error => error.code === 'OUTSIDE_LANE');++ box.git(design, 'reset', '--hard', '-q', targetCommit);+ writeFileSync(join(design, 'orphan.txt'), 'unrelated foreign bytes\n');+ const unrelatedCandidate = attackCommit(box, design);+ assert.throws(() => submissionPaths(box.repo, isolatedTarget, unrelatedCandidate, { dependencies: snapshots }),+ error => error.code === 'OUTSIDE_LANE');+ } finally {+ store.closeBoard(board);+ }+});