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.

feat(reopen): a trunk conflict records the merge-conflict cause [D1,B3]

Corey Olsonf679f4399bae
diff --git a/docs/formats.md b/docs/formats.md
index ed647255..9c3dd6d9 100644
--- a/docs/formats.md
+++ b/docs/formats.md
@@ -117,7 +117,7 @@ Engine 19 makes a corrected bar record why the old one was wrong. Once an item h
Engine 20 lets a decision name the items it changes. An `appendFact`, `answerDecision` or `verify` move may carry `implies`, a list of existing item ids, and an `answerDecision` move may carry `supersedes`, the shout id of an earlier answer. Either makes the move an engine-20 move: an older engine refuses it with `RELAY_MOVE` before changing its board or cursor, and a board replaying an older engine refuses `implies` with `ENGINE_VERSION`. Engine 20 also tells implied items when a decision is superseded: by a fact's `supersedes`, by an answer's `supersedes`, or by the next verdict on the same item. Moves recorded under engines 19 and earlier replay without these notices. Engine numbers 13 to 18 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.
-Engine 28 reopens an accepted item that conflicts with the trunk for a main merge. A `reopen` move may carry `conflict: {files, trunk}`: the files that conflict, and the full trunk commit they conflict with. The CLI fills `trunk` from Git and refuses `NOT_CONFLICTING` when the accepted commit merges cleanly, or `CONFLICT_FILES` when a named file is not one Git reports as conflicting. The board refuses `NOT_ACCEPTED` unless the item is verified with an accept at its commit, and `BAD_CONFLICT` for a malformed conflict. A conflict needs no note and no landing failure; the event records `supersedes`, the accept it sets aside, and `conflict`, never `landingFailure`. The item reads `needs main merge` until its next verdict, and the re-review checks the frozen check at the new head. A `reopen` move carrying `conflict` requires engine 28, and older engines refuse it with `RELAY_MOVE` before changing their board or cursor; a board replaying an older engine refuses it with `ENGINE_VERSION`. Moves recorded under engines 27 and earlier replay unchanged. Engine numbers 21 to 27 are allocated to other changes; a gap is fine, a reused number is not.
+Engine 28 reopens an accepted item that conflicts with the trunk for a main merge. A `reopen` move may carry `conflict: {files, trunk}`: the files that conflict, and the full trunk commit they conflict with. The CLI fills `trunk` from Git and refuses `NOT_CONFLICTING` when the accepted commit merges cleanly, or `CONFLICT_FILES` when a named file is not one Git reports as conflicting. The board refuses `NOT_ACCEPTED` unless the item is verified with an accept at its commit, and `BAD_CONFLICT` for a malformed conflict. A conflict needs no note and no landing failure; the event records `supersedes`, the accept it sets aside, `conflict`, and `cause: "refusal:MERGE_CONFLICT"`, never `landingFailure`, so rigor counts it as a merge conflict and never as a failing test. The item reads `needs main merge` until its next verdict, and the re-review checks the frozen check at the new head. A `reopen` move carrying `conflict` requires engine 28, and older engines refuse it with `RELAY_MOVE` before changing their board or cursor; a board replaying an older engine refuses it with `ENGINE_VERSION`. Moves recorded under engines 27 and earlier replay unchanged. Engine numbers 21 to 27 are allocated to other changes; a gap is fine, a reused number is not.
The CLI declares its engine in every relay request's `X-Pullboard-Engine` header.
A linked board requires at least engine 3 after issuing any agent token, including
@@ -319,7 +319,7 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap
| `reserve` | reviewer | `until` |
| `accept` | reviewer | `reason`, `commit`, engine-20 `implies` |
| `reject` | reviewer | `reason`, `commit`, engine-20 `implies` |
-| `reopen` | coordinator | `commit`, `note`, `judgment`, engine-10 `supersedes`, `landingFailure`, engine-28 `conflict` |
+| `reopen` | coordinator | `commit`, `note`, `judgment`, engine-10 `supersedes`, `landingFailure`, engine-28 `conflict`, `cause` |
| `merged` | coordinator | `commit` |
| `landing_batch` | coordinator | `batch` |
| `landing_waiver` | person | `waiver` |
diff --git a/src/board.js b/src/board.js
index 884c3ba8..134dbe28 100644
--- a/src/board.js
+++ b/src/board.js
@@ -16,7 +16,7 @@ import { COORDINATOR } from './config.js';
import { ENGINE_VERSION, GUARDS, IN_STATE, MOVES, STATES, UNKNOWN_MOVE, effectiveGuards, storeTriggers } from './machine.js';
import { Refused } from './refused.js';
import { barCorrectionFields } from './bar-corrections.js';
-import { conflictNote, conflictProblem } from './trunk-conflict.js';
+import { conflictDetail, conflictNote, conflictProblem } from './trunk-conflict.js';
import { factFromEvent, requestAnswerRefusal, tellAnswerImplications, tellFactImplications, tellVerdictImplications } from './implies.js';
import { parseSpec } from './spec.js';
@@ -1596,7 +1596,7 @@ export function reopen(board, id, { agentId, note = '', conflict }) {
};
},
});
- const returned = forMerge ? { supersedes, conflict: { files: conflict.files, trunk: conflict.trunk } } : supersedes ? { supersedes, landingFailure } : {};
+ const returned = forMerge ? { supersedes, ...conflictDetail(conflict) } : supersedes ? { supersedes, landingFailure } : {};
logEvent(board, agentId, 'reopen', id, { commit: submittedCommit, note: note.trim() || conflictNote(conflict), judgment: null, ...returned });
return { id: item.item_id, commit: submittedCommit, ...returned };
});
diff --git a/src/trunk-conflict.js b/src/trunk-conflict.js
index ad5b23cc..037f737f 100644
--- a/src/trunk-conflict.js
+++ b/src/trunk-conflict.js
@@ -98,6 +98,23 @@ export function conflictProblem(board, item, conflict, found) {
return null;
}
+/**
+ * The cause key a trunk conflict records: the refusal Pullboard gives work that no longer merges.
+ * Rigor (#713) reads cause keys and never counts a merge conflict, so a conflict reopen is never a
+ * failing test, nor an uncaused reopen; two branches touching the same lines is no rule to learn.
+ */
+export const TRUNK_CONFLICT_CAUSE = 'refusal:MERGE_CONFLICT';
+
+/**
+ * The event fields a conflict reopen records: the conflict itself and its cause key.
+ *
+ * @param {{ files: string[], trunk: string }} conflict
+ * @returns {{ conflict: { files: string[], trunk: string }, cause: string }}
+ */
+export function conflictDetail({ files, trunk }) {
+ return { conflict: { files, trunk }, cause: TRUNK_CONFLICT_CAUSE };
+}
+
/** The note a conflict reopen records when the coordinator gives none. */
export function conflictNote({ files, trunk }) {
return `conflicts with the trunk at ${trunk.slice(0, 12)} in ${files.join(', ')}; merge main and resubmit`;
diff --git a/test/reopen-conflict.test.js b/test/reopen-conflict.test.js
index aca3d43f..40ff63b3 100644
--- a/test/reopen-conflict.test.js
+++ b/test/reopen-conflict.test.js
@@ -127,6 +127,31 @@ test('a conflicting accepted item reopens for a main merge [B3,D1]', () => {
assert.doesNotMatch(box.run(box.repo, 'show', String(item.id)).out, /needs main merge/u, 'the new accept clears the label');
});
+test('a trunk conflict is not counted as a test cause [D1,B3]', () => {
+ const box = project();
+ const red = submitItem(box, 'Red landing item', 'export const status = "RED";\n');
+ accept(box, red.id, red.commit);
+ const landing = box.run(box.repo, 'reopen', String(red.id), '--note', `web/landing.test.js: keeps the landed behavior; merge commit ${'c'.repeat(40)}`, '--json');
+ assert.equal(landing.code, 0, landing.out);
+ box.git(box.web, 'reset', '-q', '--hard', 'main');
+ const item = submitItem(box, 'Conflict item', 'export const status = "ITEM";\n');
+ accept(box, item.id, item.commit);
+ const trunk = moveTrunk(box);
+ const reopened = box.run(box.repo, 'reopen', String(item.id), '--conflict', 'web/feature.js', '--note', 'two accepted items changed web/feature.js', '--json');
+ assert.equal(reopened.code, 0, reopened.out);
+
+ const reopenOf = (id) => readItem(box, id).thread.findLast((entry) => entry.type === 'move' && entry.kind === 'reopen').detail;
+ assert.deepEqual(reopenOf(red.id).landingFailure.tests, [{ file: 'web/landing.test.js', name: 'keeps the landed behavior' }], 'a red landing names its failing test');
+ assert.equal(reopenOf(red.id).cause, undefined);
+ const conflict = reopenOf(item.id);
+ assert.equal(conflict.landingFailure, undefined, 'a trunk conflict names no failing test');
+ assert.equal(conflict.cause, 'refusal:MERGE_CONFLICT', 'its cause key is the merge-conflict refusal, which rigor never counts');
+ assert.deepEqual(conflict.conflict, { files: ['web/feature.js'], trunk });
+ assert.equal(conflict.note, 'two accepted items changed web/feature.js', 'a note the coordinator gives is kept');
+ assert.ok(!Object.keys(conflict).some((key) => /test/iu.test(key)), 'no field records a test');
+ assert.deepEqual(readItem(box, item.id).verdicts.map((verdict) => verdict.verdict_reason), ['CRITERION_MET'], 'no TEST_FAILURE verdict is recorded');
+});
+
test('an older engine refuses a trunk conflict reopen before changing anything [B3,H16]', (t) => {
const box = project();
const item = submitItem(box, 'Engine item', 'export const status = "ITEM";\n');