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): claim catches spec rows behind main [B6,V1,M1]

Corey Olsondb7bdef2ff4b
diff --git a/docs/lifecycle.md b/docs/lifecycle.md
index bc61a65d..f9731d2d 100644
--- a/docs/lifecycle.md
+++ b/docs/lifecycle.md
@@ -51,7 +51,7 @@ Each move checks its guards in this order and refuses with the first one that do
| Move | From | To | Who | Guards, in order |
| --- | --- | --- | --- | --- |
-| claim | open, claimed | claimed | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_CLAIMABLE), itemNotHeld (ITEM_HELD), inLane (WRONG_LANE), routeAllows (ROUTE), dependenciesVerified (BLOCKED), notHeldByAnother (HELD), correctionRefrozen (PENDING_REFREEZE), laneOpen (LANE_HELD), oneLiveClaim (ONE_CLAIM), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG) |
+| claim | open, claimed | claimed | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_CLAIMABLE), itemNotHeld (ITEM_HELD), inLane (WRONG_LANE), routeAllows (ROUTE), dependenciesVerified (BLOCKED), notHeldByAnother (HELD), correctionRefrozen (PENDING_REFREEZE), laneOpen (LANE_HELD), oneLiveClaim (ONE_CLAIM), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) |
| release | claimed | open | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), reviewReleaseExplained (NOTE_REQUIRED) |
| lapse | claimed | open | clock, when its lease runs out | none |
| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), correctionRefrozen (PENDING_REFREEZE), criterionUnchanged (CRITERIA_CHANGED), treeClean (DIRTY), nothingUntracked (UNTRACKED), hasCommit (NO_COMMIT), withinLane (OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), gateConfigured (NO_GATE), gateGreen (GATE_RED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) |
@@ -60,8 +60,8 @@ Each move checks its guards in this order and refuses with the first one that do
| reject | submitted | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED) |
| reopen | submitted | open | coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED) |
| escalate | open, claimed | open | agent, coordinator | joined (NOT_JOINED), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED) |
-| refreeze | open, claimed, submitted | open | coordinator, when there is no live claim awaiting a coordinator correction | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), itemExists (NO_ITEM), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG) |
-| refreeze | claimed | claimed | agent, coordinator, when a live claim has a pending coordinator correction | joined (NOT_JOINED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG) |
+| refreeze | open, claimed, submitted | open | coordinator, when there is no live claim awaiting a coordinator correction | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), itemExists (NO_ITEM), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) |
+| refreeze | claimed | claimed | agent, coordinator, when a live claim has a pending coordinator correction | joined (NOT_JOINED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) |
| withdraw | open, claimed, submitted | withdrawn | coordinator | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), inState (CLOSED) |
## Exit guards
@@ -105,6 +105,7 @@ Each move checks its guards in this order and refuses with the first one that do
| A5_GRAMMAR_VERSION | every row the item cites exists and is in force, only where the criterion freezes: claiming an item with no frozen criterion, and refreeze | upgrade Pullboard or use a file written for grammar 1 |
| NO_POLICY | every row the item cites exists and is in force, only where the criterion freezes: claiming an item with no frozen criterion, and refreeze | restore the committed coordinator policy |
| BAD_CONFIG | every row the item cites exists and is in force, only where the criterion freezes: claiming an item with no frozen criterion, and refreeze | repair and commit the coordinator configuration |
+| SPEC_BEHIND_MAIN | every row the item cites exists and is in force, only where the criterion freezes: claiming an item with no frozen criterion, and refreeze | merge main from this worktree, then retry the claim |
| CRITERIA_CHANGED | the criterion and the rows it cites read as they did at claim | the coordinator runs pullboard refreeze <id> |
| DIRTY | the worktree has no uncommitted changes | commit your changes, then submit |
| UNTRACKED | the worktree has no untracked files | commit or ignore them, then submit |
diff --git a/src/cli.js b/src/cli.js
index 558665ee..0d086584 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -597,6 +597,75 @@ function freezer(ctx, { captureVerifyPolicy = false } = {}) {
};
}
+/** Merge a safe main fast-forward before freezing rows that only main has [V1].
+ *
+ * @param {any} ctx
+ * @param {any} item
+ * @returns {string[]|null} Missing rows merged from main, or null when no merge was needed.
+ */
+function prepareClaimSpec(ctx, item) {
+ if (item.item_frozen) return null;
+ const ids = (item.item_spec_ids ?? '').split(',').map((id) => id.trim()).filter((id) => id && !id.startsWith('doctrine:'));
+ if (!ids.length) return null;
+ const root = ctx.info.root;
+ const main = mainCheckout(root);
+ if (!main?.commit) return null;
+ const policy = policyAt(root, main.commit);
+ const mainSource = tryGit(root, ['show', `${main.commit}:${policy.config.spec}`]);
+ if (mainSource.status !== 0) return null;
+ const mainRows = new Set(parseSpec(mainSource.stdout).rows.map((row) => row.id));
+ const localRows = new Set(loadSpec(root, ctx.config).rows.map((row) => row.id));
+ const missing = [...new Set(ids)].filter((id) => mainRows.has(id) && !localRows.has(id));
+ if (!missing.length) return null;
+
+ const head = headCommit(root);
+ const symbolic = tryGit(root, ['symbolic-ref', '--quiet', 'HEAD']);
+ const canFastForward = Boolean(head && symbolic.status === 0 && isClean(root) && untracked(root).length === 0 && contains(root, head, main.commit));
+ if (!canFastForward) throw specBehindMain(policy.config.spec, missing);
+ try {
+ git(root, ['merge', '--ff-only', main.commit]);
+ if (headCommit(root) !== main.commit) throw new Error('main moved during the fast-forward');
+ } catch {
+ throw specBehindMain(policy.config.spec, missing);
+ }
+ Object.assign(ctx, context(ctx.io));
+ return missing;
+}
+
+/** Carry a safe main fast-forward out of the board transaction so claim can retry at the new HEAD. */
+class MainSpecMerged extends Error {
+ /** Preserve the rows needed for the caller's one-line merge notice.
+ * @param {string[]} rows
+ */
+ constructor(rows) {
+ super('main advanced to include the claimed spec rows');
+ this.rows = rows;
+ }
+}
+
+/** Prepare the criterion after the board's other claim guards have passed.
+ *
+ * @param {any} ctx
+ * @returns {(item: any) => { text: string, digest: string }}
+ */
+function claimFreezer(ctx) {
+ return (item) => {
+ const rows = prepareClaimSpec(ctx, item);
+ if (rows) throw new MainSpecMerged(rows);
+ return freezer(ctx)(item);
+ };
+}
+
+/** Explain why an out-of-date spec cannot be merged automatically.
+ *
+ * @param {string} specName
+ * @param {string[]} rows
+ * @returns {Refused}
+ */
+function specBehindMain(specName, rows) {
+ return new Refused('SPEC_BEHIND_MAIN', `${specName} is missing rows ${rows.join(', ')} that exist on main; commit or resolve local work, then merge main and retry`);
+}
+
/**
* The evidence a shout carries, from its flags (B22). The commit is resolved here, in this repo,
* so the board only ever stores a full SHA that names a real commit.
@@ -1784,8 +1853,9 @@ async function nextOnce(ctx, values) {
const reviewSkipped = values.build && !held
? { offeredItem: offer?.item.item_id ?? null, ratio: ctx.config.verify.reviewRatio, ...store.reviewQueue(board) } : null;
try {
- await ordered(ctx, board, 'claim', [item.item_id, { agentId: me.id, lane: me.lane, leaseMs: ctx.config.leaseMs, freeze: freezer(ctx), head: headCommit(ctx.info.root), reviewSkipped }]);
+ await ordered(ctx, board, 'claim', [item.item_id, { agentId: me.id, lane: me.lane, leaseMs: ctx.config.leaseMs, freeze: claimFreezer(ctx), head: headCommit(ctx.info.root), reviewSkipped }]);
} catch (error) {
+ if (error instanceof MainSpecMerged) return { retry: true, specMerged: { item: item.item_id, rows: error.rows } };
if (error instanceof Refused && ['HELD', 'ITEM_HELD', 'BLOCKED', 'ONE_CLAIM'].includes(error.code)) return { retry: true };
throw error;
}
@@ -1824,7 +1894,7 @@ function sayReviewOffer(ctx, found) {
* @returns {Promise<number>}
*/
async function nextHere(io, values) {
- const ctx = context(io);
+ let ctx = context(io);
if (values.build && values.verify) throw new Refused('USAGE', 'choose a build or a review: pullboard next --build or pullboard next --verify');
if (values.verifyId !== undefined && !values.verify) {
throw new Refused('USAGE', 'give an item id only with --verify: pullboard next --verify <id>');
@@ -1837,6 +1907,11 @@ async function nextHere(io, values) {
const deadline = Date.now() + minutes * 60_000;
for (;;) {
const found = await nextOnce(ctx, values);
+ if (found.specMerged) {
+ io.say(`merged main before claiming #${found.specMerged.item}: added spec rows ${found.specMerged.rows.join(', ')}`);
+ ctx = context(io);
+ continue;
+ }
if (found.item) {
if (found.offer) { sayReviewOffer(ctx, found); return 0; }
const item = found.item;
@@ -2128,7 +2203,18 @@ function workCommands(io, args) {
return run.isGreen ? 0 : 1;
},
claim: () => act(async (ctx, board, me) => {
- const result = await ordered(ctx, board, 'claim', [idArg(first), { agentId: me.id, lane: me.lane, leaseMs: ctx.config.leaseMs, freeze: freezer(ctx), head: headCommit(ctx.info.root) }]);
+ const id = idArg(first);
+ let result;
+ for (;;) {
+ try {
+ result = await ordered(ctx, board, 'claim', [id, { agentId: me.id, lane: me.lane, leaseMs: ctx.config.leaseMs, freeze: claimFreezer(ctx), head: headCommit(ctx.info.root) }]);
+ break;
+ } catch (error) {
+ if (!(error instanceof MainSpecMerged)) throw error;
+ io.say(`merged main before claiming #${id}: added spec rows ${error.rows.join(', ')}`);
+ me = whoAmI(ctx, board);
+ }
+ }
io.result?.({ id: idArg(first), ...result });
io.say(`${result.renewed ? 'renewed' : 'claimed'} #${first} until ${result.leaseUntil}; criterion frozen as ${result.digest.slice(0, 12)}`);
return 0;
diff --git a/src/json.js b/src/json.js
index f67bfb1c..da404bbf 100644
--- a/src/json.js
+++ b/src/json.js
@@ -107,7 +107,7 @@ function nextStep(message) {
/** A refusal shared by the CLI and API, retaining its rule and repair guidance (A1, A2). */
export function refusalDocument(error) {
const message = String(error.message).replace(/^\[[A-Z][A-Z0-9_]*\] /, '');
- return { version: JSON_SHAPES.version, error: { code: error.code ?? 'INTERNAL', message, next: nextStep(message) } };
+ return { version: JSON_SHAPES.version, error: { code: error.code ?? 'INTERNAL', message, next: error.code === 'SPEC_BEHIND_MAIN' ? 'git merge main' : nextStep(message) } };
}
/**
diff --git a/src/machine.js b/src/machine.js
index 0fa01be3..87cd61b8 100644
--- a/src/machine.js
+++ b/src/machine.js
@@ -111,7 +111,7 @@ export const GUARDS = [
{ id: 'itemNotHeld', refuse: 'ITEM_HELD', rule: 'the coordinator has not put this item on hold', next: 'the coordinator lifts it with pullboard hold <id> --off', source: 'board', when: 'unless the caller is renewing its own live claim' },
{ id: 'correctionRefrozen', refuse: 'PENDING_REFREEZE', rule: 'no coordinator correction to a claimed criterion or check is waiting to be frozen', next: 'pullboard refreeze <id>', source: 'board' },
{ id: 'oneLiveClaim', refuse: 'ONE_CLAIM', rule: 'the caller holds no other live top-level claim, reworks of its own rejected items aside', next: 'submit or release the other item first; child items are free', source: 'board' },
- { id: 'rowsInForce', refuse: 'UNKNOWN_SPEC', alsoRefuses: [{ code: 'A5_GRAMMAR_VERSION', next: 'upgrade Pullboard or use a file written for grammar 1' }, { code: 'NO_POLICY', next: 'restore the committed coordinator policy' }, { code: 'BAD_CONFIG', next: 'repair and commit the coordinator configuration' }], rule: 'every row the item cites exists and is in force', next: 'fix the spec, or the coordinator withdraws the item', source: 'board', when: 'only where the criterion freezes: claiming an item with no frozen criterion, and refreeze' },
+ { id: 'rowsInForce', refuse: 'UNKNOWN_SPEC', alsoRefuses: [{ code: 'A5_GRAMMAR_VERSION', next: 'upgrade Pullboard or use a file written for grammar 1' }, { code: 'NO_POLICY', next: 'restore the committed coordinator policy' }, { code: 'BAD_CONFIG', next: 'repair and commit the coordinator configuration' }, { code: 'SPEC_BEHIND_MAIN', next: 'merge main from this worktree, then retry the claim' }], rule: 'every row the item cites exists and is in force', next: 'fix the spec, or the coordinator withdraws the item', source: 'board', when: 'only where the criterion freezes: claiming an item with no frozen criterion, and refreeze' },
{ id: 'criterionUnchanged', refuse: 'CRITERIA_CHANGED', rule: 'the criterion and the rows it cites read as they did at claim', next: 'the coordinator runs pullboard refreeze <id>', source: 'cli' },
{ id: 'treeClean', refuse: 'DIRTY', rule: 'the worktree has no uncommitted changes', next: 'commit your changes, then submit', source: 'cli' },
{ id: 'nothingUntracked', refuse: 'UNTRACKED', rule: 'the worktree has no untracked files', next: 'commit or ignore them, then submit', source: 'cli' },
diff --git a/test/spec-behind-main.test.js b/test/spec-behind-main.test.js
new file mode 100644
index 00000000..df115098
--- /dev/null
+++ b/test/spec-behind-main.test.js
@@ -0,0 +1,132 @@
+/** Claim-time spec freshness on real linked Git worktrees [B6,V1]. */
+import assert from 'node:assert/strict';
+import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { test } from 'node:test';
+import { createE2eHelpers } from './e2e-helpers.js';
+
+const e2e = createE2eHelpers();
+const { project } = e2e;
+
+/** Add and commit rows on the coordinator branch. */
+function addMainRows(box, ids = ['G3']) {
+ const spec = join(box.repo, 'SPEC.md');
+ const additions = ids.map((id) => `- ${id} [approved, must] The new row is in force. | gate: test`).join('\n');
+ writeFileSync(spec, `${readSpec(box)}\n${additions}\n`);
+ box.git(box.repo, 'add', 'SPEC.md');
+ box.git(box.repo, 'commit', '-q', '-m', 'docs: add a spec row [G1]');
+}
+
+/** Read the fixture's spec file from its coordinator checkout. */
+function readSpec(box) {
+ return box.git(box.repo, 'show', 'HEAD:SPEC.md');
+}
+
+/** Create a board item whose row is already committed on main. */
+function addRowItem(box, ids = 'G3', lane = 'web') {
+ const added = box.run(box.repo, 'add', lane, 'Main-only row', '--specs', ids, '--json');
+ assert.equal(added.code, 0, added.err || added.out);
+ return String(JSON.parse(added.out).item.item_id);
+}
+
+/** Commit a local file through the lane's normal hooks. */
+function commitLocalWork(box) {
+ const file = join(box.web, 'web', 'local.txt');
+ mkdirSync(join(box.web, 'web'), { recursive: true });
+ writeFileSync(file, 'local work\n');
+ box.git(box.web, 'add', 'web/local.txt');
+ box.git(box.web, 'commit', '-q', '-m', 'docs: local work [G1]');
+}
+
+test('a worktree behind main on the spec is caught before UNKNOWN_SPEC [B6, V1]', () => {
+ const fastForward = project();
+ addMainRows(fastForward);
+ const fastForwardItem = addRowItem(fastForward);
+ const beforeFastForward = fastForward.git(fastForward.web, 'rev-parse', 'HEAD');
+ const built = fastForward.run(fastForward.web, 'next', '--build');
+ assert.equal(built.code, 0, built.err || built.out);
+ assert.match(built.out, new RegExp(`merged main before claiming #${fastForwardItem}: added spec rows G3`));
+ assert.match(built.out, new RegExp(`claimed #${fastForwardItem}`));
+ assert.notEqual(beforeFastForward, fastForward.git(fastForward.web, 'rev-parse', 'HEAD'));
+ const fastForwardHead = fastForward.git(fastForward.web, 'rev-parse', 'HEAD');
+ assert.equal(fastForwardHead, fastForward.git(fastForward.repo, 'rev-parse', 'HEAD'));
+ assert.equal(JSON.parse(fastForward.run(fastForward.web, 'show', fastForwardItem, '--json').out).item_claim_head, fastForwardHead);
+
+ const directClaim = project();
+ addMainRows(directClaim);
+ const directItem = addRowItem(directClaim);
+ const direct = directClaim.run(directClaim.web, 'claim', directItem);
+ assert.equal(direct.code, 0, direct.err || direct.out);
+ assert.match(direct.out, new RegExp(`merged main before claiming #${directItem}: added spec rows G3`));
+ assert.match(direct.out, new RegExp(`claimed #${directItem}`));
+ const directHead = directClaim.git(directClaim.web, 'rev-parse', 'HEAD');
+ assert.equal(directHead, directClaim.git(directClaim.repo, 'rev-parse', 'HEAD'));
+ assert.equal(JSON.parse(directClaim.run(directClaim.web, 'show', directItem, '--json').out).item_claim_head, directHead);
+
+ const localCommit = project();
+ addMainRows(localCommit, ['G3', 'G4']);
+ const localItem = addRowItem(localCommit, 'G3,G4');
+ commitLocalWork(localCommit);
+ const localHead = localCommit.git(localCommit.web, 'rev-parse', 'HEAD');
+ const refused = localCommit.run(localCommit.web, 'claim', localItem);
+ assert.equal(refused.code, 1);
+ assert.match(refused.err, /^(?:stderr: )?pullboard: \[SPEC_BEHIND_MAIN\]/mu);
+ assert.match(refused.err, /G3, G4/u);
+ assert.ok(refused.err.trimEnd().endsWith('next: git merge main'));
+ const refusalJson = JSON.parse(localCommit.run(localCommit.web, 'claim', localItem, '--json').out);
+ assert.equal(refusalJson.error.code, 'SPEC_BEHIND_MAIN');
+ assert.equal(refusalJson.error.next, 'git merge main');
+ assert.equal(localCommit.git(localCommit.web, 'rev-parse', 'HEAD'), localHead);
+ assert.match(localCommit.run(localCommit.repo, 'list', '--all').out, new RegExp(`#${localItem} open`));
+
+ const untracked = project();
+ addMainRows(untracked);
+ const untrackedItem = addRowItem(untracked);
+ mkdirSync(join(untracked.web, 'web'), { recursive: true });
+ writeFileSync(join(untracked.web, 'web', 'untracked.txt'), 'uncommitted work\n');
+ const untrackedHead = untracked.git(untracked.web, 'rev-parse', 'HEAD');
+ const untrackedRefusal = untracked.run(untracked.web, 'claim', untrackedItem);
+ assert.equal(untrackedRefusal.code, 1);
+ assert.match(untrackedRefusal.err, /^(?:stderr: )?pullboard: \[SPEC_BEHIND_MAIN\]/mu);
+ assert.match(untrackedRefusal.err, /G3/u);
+ assert.ok(untrackedRefusal.err.trimEnd().endsWith('next: git merge main'));
+ assert.equal(untracked.git(untracked.web, 'rev-parse', 'HEAD'), untrackedHead);
+
+ const dirty = project();
+ addMainRows(dirty);
+ const dirtyItem = addRowItem(dirty);
+ const dirtyPath = join(dirty.web, 'AGENTS.md');
+ const dirtyText = readFileSync(dirtyPath, 'utf8') + '\nLocal unfinished instructions.\n';
+ writeFileSync(dirtyPath, dirtyText);
+ const dirtyHead = dirty.git(dirty.web, 'rev-parse', 'HEAD');
+ const dirtyRefusal = dirty.run(dirty.web, 'next', '--build');
+ assert.equal(dirtyRefusal.code, 1);
+ assert.match(dirtyRefusal.err, /^(?:stderr: )?pullboard: \[SPEC_BEHIND_MAIN\]/mu);
+ assert.ok(dirtyRefusal.err.trimEnd().endsWith('next: git merge main'));
+ assert.equal(dirty.git(dirty.web, 'rev-parse', 'HEAD'), dirtyHead);
+ assert.equal(readFileSync(dirtyPath, 'utf8'), dirtyText);
+ assert.equal(JSON.parse(dirty.run(dirty.repo, 'show', dirtyItem, '--json').out).item_status, 'open');
+
+ // Earlier claim guards keep their refusal and cannot advance a caller in the wrong lane.
+ const wrongLane = project();
+ addMainRows(wrongLane);
+ const wrongItem = addRowItem(wrongLane, 'G3', 'api');
+ const wrongHead = wrongLane.git(wrongLane.web, 'rev-parse', 'HEAD');
+ const wrong = wrongLane.run(wrongLane.web, 'claim', wrongItem);
+ assert.equal(wrong.code, 1);
+ assert.match(wrong.err, /^(?:stderr: )?pullboard: \[WRONG_LANE\]/mu);
+ assert.equal(wrongLane.git(wrongLane.web, 'rev-parse', 'HEAD'), wrongHead);
+
+ const alreadyCurrent = project();
+ addMainRows(alreadyCurrent);
+ const currentItem = addRowItem(alreadyCurrent);
+ alreadyCurrent.git(alreadyCurrent.web, 'merge', '--ff-only', 'main');
+ const currentHead = alreadyCurrent.git(alreadyCurrent.web, 'rev-parse', 'HEAD');
+ const claimed = alreadyCurrent.run(alreadyCurrent.web, 'claim', currentItem);
+ assert.equal(claimed.code, 0, claimed.err || claimed.out);
+ assert.match(claimed.out, new RegExp(`claimed #${currentItem}`));
+ assert.doesNotMatch(claimed.out, /merged main/u);
+ assert.equal(alreadyCurrent.git(alreadyCurrent.web, 'rev-parse', 'HEAD'), currentHead);
+});
+
+test.after(e2e.cleanup);