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(cli): submit promises only the gate's start and end tree [V16]

Corey Olson8d5482e5f92d
diff --git a/docs/lifecycle.md b/docs/lifecycle.md
index b28fe983..9a413ee0 100644
--- a/docs/lifecycle.md
+++ b/docs/lifecycle.md
@@ -93,7 +93,7 @@ Each move checks its guards in this order and refuses with the first one that do
| NO_COMMIT | there is a commit to submit | commit your work, then submit |
| NO_GATE | the repo names a gate command | set "gate" in pullboard.json, e.g. "npm test" |
| GATE_RED | the gate, which submit runs itself every time, is green at HEAD | fix what the digest names, commit, submit again |
-| MOVED_DURING_GATE | HEAD and every tracked file stayed as they were while the gate ran | leave the worktree alone until the gate finishes, then submit again |
+| MOVED_DURING_GATE | when the gate ends, HEAD and every tracked file are as they were when it started | leave the worktree alone until the gate finishes, then submit again |
| CHILDREN_OPEN | every child item is verified or withdrawn | finish the child items, or the coordinator withdraws them |
| HEAD_NOT_NEW | a verifier has not already rejected this commit | commit the rework, then submit |
| NOT_AT_COMMIT | the caller's checkout contains the submitted commit | git switch --detach <commit> |
diff --git a/docs/proof/verification-mutants.mjs b/docs/proof/verification-mutants.mjs
index e2524c32..f46a3f85 100644
--- a/docs/proof/verification-mutants.mjs
+++ b/docs/proof/verification-mutants.mjs
@@ -23,7 +23,7 @@ const VERDICT_ROW = '.run(id, agentId, decision, code, note.trim(), found.item_c
const SUBMIT_RUN = 'const gate = runGate(root, ctx.config, { trustStamp: false });';
const MOVED = 'if (headCommit(root) !== commit || !isClean(root)) {';
const HAND_STAMP = ['test/gate.test.js', 'a stamp written by hand never stands in'];
-const MOVED_TREE = ['test/gate.test.js', 'submit refuses a tree that moved while its gate ran'];
+const MOVED_TREE = ['test/gate.test.js', 'submit refuses a tree its gate left changed'];
/** Row, the change, its edits as [file, from, to], the test that judges it, and the outcome expected. */
const MUTANTS = [
diff --git a/docs/proof/verification.md b/docs/proof/verification.md
index 7b3dea0f..ea175e87 100644
--- a/docs/proof/verification.md
+++ b/docs/proof/verification.md
@@ -24,7 +24,7 @@ Re-run it with `node docs/proof/verification-mutants.mjs`. It copies the repo to
| V16 | Submit runs the gate itself on the exact tree it submits; no stamp from an earlier run stands in. | submit trusts a stamp written by hand | submit runs the gate itself: a stamp written by hand never stands in for a red gate | red |
| V16 | | submit trusts an earlier run's stamp | submit runs the gate even on a tree an earlier run passed, which a plain gate run may skip | red |
| V16 | | the gate trusts the stamp whatever submit asks | submit runs the gate itself: a stamp written by hand never stands in for a red gate | red |
-| V16 | | submit does not look whether the tree moved; it misses a new commit; it misses an edited tracked file (three changes) | submit refuses a tree that moved while its gate ran: a new commit, or an edited tracked file | red, all three |
+| V16 | | submit does not look whether the tree moved; it misses a new commit; it misses an edited tracked file (three changes) | submit refuses a tree its gate left changed: a new commit, or an edited tracked file | red, all three |
## What the audit changed
@@ -42,4 +42,6 @@ git rev-parse 'HEAD^{tree}' > "$(git rev-parse --git-path pullboard-gate-green)"
pullboard submit 1 -> submitted #1 at 8c6b3057c8d7; gate green (this tree already passed)
```
-On one machine, any file pullboard writes an agent can write too, so no stamp can be made safe to trust. Since #51, submit runs the gate itself every time and refuses MOVED_DURING_GATE if HEAD or a tracked file changes while it runs. The stamp now only saves a run where nothing is proven by it: pre-push and `pullboard gate` (C3). Gitignored files that a gate may read are still out of scope; a fresh checkout per submit would be the next step.
+On one machine, any file pullboard writes an agent can write too, so no stamp can be made safe to trust. Since #51, submit runs the gate itself every time. The gate starts on exactly the commit submitted, and submit refuses MOVED_DURING_GATE if HEAD or a tracked file differs from it when the gate ends. The stamp now only saves a run where nothing is proven by it: pre-push and `pullboard gate` (C3). Gitignored files that a gate may read are still out of scope; a fresh checkout per submit would be the next step.
+
+**What submit does not claim.** The gate is code in the submitted tree. A gate that edits a tracked file and puts it back before it exits, or commits and resets, ends on the submitted commit and passes. tests-1 showed both on fresh repos while reviewing #51. Submit cannot tell such a run from an honest one: a gate could as well copy the tree elsewhere and test the copy. So submit promises only what it can see: no stamp stands in, and the gate starts and ends on the submitted commit. What the gate's code does in between is part of the submitted tree. Its verifier reads it and reruns the gate at that commit.
diff --git a/src/cli.js b/src/cli.js
index 7cf3bb80..60161b2c 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -810,13 +810,14 @@ function submitHere(ctx, id) {
const commit = headCommit(root);
if (!commit) throw new Refused('NO_COMMIT', 'nothing committed yet');
// Submit runs the gate itself, every time: a stamp from an earlier run is a file any agent can
- // write, so it never stands in for this run (V16). The run must also see the tree as submitted.
+ // write, so it never stands in for this run (V16). It starts on the commit submitted, and must end
+ // on it too. What the gate's own code does in between is the submitted tree's, under review.
const gate = runGate(root, ctx.config, { trustStamp: false });
if (!gate.isGreen) throw new Refused('GATE_RED', `the gate is red at ${commit.slice(0, 12)}; fix it, commit, submit again. ${gateReport(gate)}`);
if (headCommit(root) !== commit || !isClean(root)) {
throw new Refused(
'MOVED_DURING_GATE',
- `HEAD or a tracked file changed while the gate ran, so it did not check ${commit.slice(0, 12)} as you would submit it; leave the worktree alone until the gate finishes, then submit again`,
+ `when the gate ended, HEAD or a tracked file differed from ${commit.slice(0, 12)}, the commit it started on, so the gate did not end on what you would submit; leave the worktree alone until the gate finishes, then submit again`,
);
}
withBoard(ctx, (board) => store.submit(board, id, { agentId: me.id, commit, tree: headTree(root) ?? '', files: filesSince(root, id, claimHead, commit) }));
diff --git a/src/machine.js b/src/machine.js
index 62b7ed6e..85d0116d 100644
--- a/src/machine.js
+++ b/src/machine.js
@@ -111,7 +111,7 @@ export const GUARDS = [
{ id: 'hasCommit', refuse: 'NO_COMMIT', rule: 'there is a commit to submit', next: 'commit your work, then submit', source: 'cli' },
{ id: 'gateConfigured', refuse: 'NO_GATE', rule: 'the repo names a gate command', next: 'set "gate" in pullboard.json, e.g. "npm test"', source: 'cli' },
{ id: 'gateGreen', refuse: 'GATE_RED', rule: 'the gate, which submit runs itself every time, is green at HEAD', next: 'fix what the digest names, commit, submit again', source: 'cli' },
- { id: 'treeStillDuringGate', refuse: 'MOVED_DURING_GATE', rule: 'HEAD and every tracked file stayed as they were while the gate ran', next: 'leave the worktree alone until the gate finishes, then submit again', source: 'cli' },
+ { id: 'treeStillDuringGate', refuse: 'MOVED_DURING_GATE', rule: 'when the gate ends, HEAD and every tracked file are as they were when it started', next: 'leave the worktree alone until the gate finishes, then submit again', source: 'cli' },
{ id: 'childrenDone', refuse: 'CHILDREN_OPEN', rule: 'every child item is verified or withdrawn', next: 'finish the child items, or the coordinator withdraws them', source: 'board' },
{ id: 'headIsNew', refuse: 'HEAD_NOT_NEW', rule: 'a verifier has not already rejected this commit', next: 'commit the rework, then submit', source: 'board' },
{ id: 'atSubmittedCommit', refuse: 'NOT_AT_COMMIT', rule: "the caller's checkout contains the submitted commit", next: 'git switch --detach <commit>', source: 'cli' },
diff --git a/test/gate.test.js b/test/gate.test.js
index 4d7da957..0b6d76c8 100644
--- a/test/gate.test.js
+++ b/test/gate.test.js
@@ -125,7 +125,7 @@ test('submit runs the gate even on a tree an earlier run passed, which a plain g
assert.equal(box.runs(), 2, 'submit ran the gate itself, stamp or no stamp');
});
-test('submit refuses a tree that moved while its gate ran: a new commit, or an edited tracked file [V16]', () => {
+test('submit refuses a tree its gate left changed: a new commit, or an edited tracked file [V16]', () => {
for (const [moves, gate] of [
['a commit made during the gate', 'git commit -q --allow-empty -m "chore: moved under the gate"'],
['a tracked file edited during the gate', 'echo more >> SPEC.md'],