Skip to content

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.

fix(core): preserve publication repair invariants [B2,R3,M1]

Corey Olsonde8a74593548
diff --git a/src/board.js b/src/board.js
index 0f564ae1..6a6233b8 100644
--- a/src/board.js
+++ b/src/board.js
@@ -563,6 +563,18 @@ function setItem(board, id, fields) {
.run(...keys.map((key) => fields[key]), now(board), id);
}
+/** Link a fresh neutral CI repair to its merged original without changing either status [B2,R3]. */
+export function linkPublishRepair(board, { agentId, item, repair }) {
+ if (agentId !== COORDINATOR) throw new Refused('COORDINATOR_ONLY', 'only the coordinator links publication CI repairs');
+ const original = getItem(board, item);
+ const child = getItem(board, repair);
+ if (!original.item_merged_commit || original.item_status !== 'verified' || child.item_status !== 'open' ||
+ child.item_created_by !== COORDINATOR || child.item_parent_id !== null || child.item_lane !== original.item_lane || item === repair) {
+ throw new Refused('PUBLISH_FINDING', 'link only a new neutral coordinator repair to its merged original');
+ }
+ setItem(board, repair, { item_parent_id: item });
+}
+
/**
* True while someone holds the item under a lease that has not lapsed.
*
diff --git a/src/pr-findings.js b/src/pr-findings.js
index 615a9b87..95801a41 100644
--- a/src/pr-findings.js
+++ b/src/pr-findings.js
@@ -1,6 +1,6 @@
/** Preserve merged history while recording one linked neutral CI repair [B2,R3]. */
import { createHash } from 'node:crypto';
-import { addItem, appendFact, atomic, getItem, logEvent } from './board.js';
+import { addItem, appendFact, atomic, getItem, linkPublishRepair, logEvent } from './board.js';
import { COORDINATOR } from './config.js';
import { Refused } from './refused.js';
@@ -31,7 +31,7 @@ export function recordPublishFinding(board, { agentId, item, repository, pull, h
brief: `Linked repair of merged item #${item}; GitHub ${repository} PR #${pull}, head ${head}. Keep the original merge and acceptance history. Jobs: ${failures.map(f => `${f.name}: ${f.url}`).join('; ')}` });
// This new coordinator-only move is the explicit exception for a repair OF a closed item.
// The ordinary addItem(parentId) guard still refuses a child of any closed parent.
- if (!old) board.db.prepare('UPDATE item SET item_parent_id=? WHERE item_id=?').run(item, repair);
+ if (!old) linkPublishRepair(board, { agentId, item, repair });
const detail = { key, repository, pull, head, item, repair, failures: observed };
const factId = 'pr-ci-' + createHash('sha256').update(JSON.stringify(detail)).digest('hex');
appendFact(board, item, { agentId, kind: 'capture', factId, text: 'CI finding: ' + JSON.stringify(detail) });
diff --git a/test/engine.test.js b/test/engine.test.js
index 09720b2f..223b5ed4 100644
--- a/test/engine.test.js
+++ b/test/engine.test.js
@@ -14,6 +14,7 @@ import { applyEngineMove, applyRelayMove, prepareEngineMove, appliedSequence, en
import { COMMAND_CANDIDATE, COMMAND_FILE, discovered } from '../src/discovery.js';
import { ENGINE_REGISTRY, ENGINE_VERSION, discoverEngines } from '../src/machine.js';
import { Refused } from '../src/refused.js';
+import { ENGINE_LINE } from '../src/engine-numbers.js';
import { unpackRelease } from './release-archive.js';
const HOUR = 3_600_000;
@@ -664,7 +665,7 @@ test('the engine version is the highest feature engine [C7,V4]', () => {
const source = new URL('../src/', import.meta.url);
const files = readdirSync(source).filter((file) => /-engine\.js$/u.test(file));
assert.deepEqual(Object.keys(ENGINE_REGISTRY), files.map((file) => file.slice(0, -'-engine.js'.length)).sort(), 'every src/*-engine.js leaf is a feature engine, discovered by its file name');
- for (const file of files) assert.match(readFileSync(new URL(file, source), 'utf8'), /^export const [A-Z][A-Z0-9_]*_ENGINE = \d+;$/mu, `${file} declares its one engine constant`);
+ for (const file of files) assert.equal(readFileSync(new URL(file, source), 'utf8').split('\n').filter(line => ENGINE_LINE.test(line)).length, 1, `${file} declares its one supported engine constant`);
assert.doesNotMatch(readFileSync(new URL('machine.js', source), 'utf8'), /Math\.max\([A-Z_]+ENGINE,/u, 'src/machine.js lists no engine by name');
});
diff --git a/test/pr-bridge-fixture.js b/test/pr-bridge-fixture.js
index fb645449..f854239b 100644
--- a/test/pr-bridge-fixture.js
+++ b/test/pr-bridge-fixture.js
@@ -149,7 +149,7 @@ export function landBridgeRepair(box, id, file) {
'--check', 'test ! -f RED', '--brief', 'Change the named private web fixture and retain the linked finding.');
assert.equal(edited.code, 0, edited.err);
assert.equal(box.run(path, 'claim', String(id)).code, 0);
- assert.equal(box.commitFile(box, path, file, 'PASS REPAIRED\n', 'fix(web): repair private CI finding [G1]').status, 0);
+ assert.equal(box.commitFile(box, path, file, 'PASS FIXED\n', 'fix(web): repair private CI finding [G1]').status, 0);
const commit = box.git(path, 'rev-parse', 'HEAD');
const submitted = box.run(path, 'submit', String(id));
assert.equal(submitted.code, 0, submitted.err);
diff --git a/test/pr-bridge.test.js b/test/pr-bridge.test.js
index 81548c6c..fc3c5a83 100644
--- a/test/pr-bridge.test.js
+++ b/test/pr-bridge.test.js
@@ -55,6 +55,8 @@ test("publish opens one pull request with each item's receipt and records the pe
pull.merged_by = { login: 'fixture-person', type: 'User', id: 42 };
const observed = await runBridgeCLI(box, 'publish', '--json');
assert.equal(observed.code, 0, observed.err);
+ assert.equal(JSON.parse(observed.out).releases[0].recognizedPerson, true);
+ assert.equal(JSON.parse(observed.out).releases[0].personApproval, false);
const facts = onBoard(box, board => entries.flatMap(entry => store.itemThread(board, entry.id)
.filter(fact => fact.type === 'fact').map(fact => fact.text)));
for (const entry of entries) assert.ok(facts.some(text => text.includes(pull.html_url) && text.includes(pull.merge_commit_sha)),
@@ -174,4 +176,5 @@ test('publication findings replay deterministically and ordinary closed-parent g
assert.throws(() => store.addItem(source, { by: 'coordinator', lane: 'web', title: 'ordinary child',
criterion: 'ordinary closed parent remains refused', parentId: entries[0].id, route: 'strong' }), { code: 'PARENT_CLOSED' });
assert.throws(() => store.recordPublishFinding(source, { ...request, agentId: 'web-1' }), { code: 'COORDINATOR_ONLY' });
+ assert.throws(() => store.linkPublishRepair(source, { agentId: 'web-1', item: entries[0].id, repair: entries[1].id }), { code: 'COORDINATOR_ONLY' });
});