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(submit): preserve retry intent with derived carry [H16,V4]
Corey Olson05af4cb78846
diff --git a/src/engine.js b/src/engine.jsindex 4e23e7cc..48bd7b4a 100644--- a/src/engine.js+++ b/src/engine.js@@ -95,7 +95,9 @@ export function prepareEngineMove(board, operation, args, { id = randomUUID(), aif (operation === 'submit' && ENGINE_VERSION >= SUBMISSION_PROOF_ENGINE) submissionProof(values[1]?.submissionProof);// Derive once before sealing; replicas never re-decide a recorded carry from their local objects.if (operation === 'submit' && ENGINE_VERSION >= MERGE_ONLY_VERDICT_ENGINE && values[1]) {- values[1].mergeOnly = store.prepareMergeOnlySubmit(board, values[0], values[1]);+ const carry = store.prepareMergeOnlySubmit(board, values[0], values[1]);+ delete values[1].mergeOnly;+ if (carry) values[1].mergeOnly = carry;}if (operation === 'claim' && ['wipPerReviewer', 'takeoverMinutes'].some(key => typeof lineSettings(board)[key] === 'number')) {values[1] = { ...values[1], lineCapacity: true };diff --git a/src/relay-sender.js b/src/relay-sender.jsindex 2f69d18c..19bdb1c2 100644--- a/src/relay-sender.js+++ b/src/relay-sender.js@@ -101,8 +101,13 @@ export function credentialActor(move) {/** Compare caller intent without executing frozen callbacks or allocating another operation id. */export function operationIntent(operation, args) {const values = Array.isArray(args) ? args.map((value, index) => {- if (!['claim', 'refreeze'].includes(operation) || index !== 1 || !value || typeof value !== 'object') return value;+ if (!['claim', 'refreeze', 'submit'].includes(operation) || index !== 1 || !value || typeof value !== 'object') return value;const options = { ...value };+ if (operation === 'submit') {+ // Native proof is derived after caller intent is saved, and is not a different retry.+ delete options.mergeOnly;+ return options;+ }delete options.freeze;delete options.frozen;delete options.freezeError;diff --git a/test/merge-only-verdict.test.js b/test/merge-only-verdict.test.jsindex a3ee063b..a3f261ef 100644--- a/test/merge-only-verdict.test.js+++ b/test/merge-only-verdict.test.js@@ -1,7 +1,7 @@/** Real public submission, Git conflict resolution and immutable verdict coverage [V1,V4,H16]. */import assert from 'node:assert/strict';import { createHash } from 'node:crypto';-import { land } from '../src/land.js';+import { land, runLandingBatch } from '../src/land.js';import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';@@ -14,6 +14,7 @@ import { runFixtureGit, runFixtureChild } from './fixture-child.js';import { exportBoard, importBoard } from '../src/exchange.js';import { prepareEngineMove, applyEngineMove, applyRelayMove } from '../src/engine.js';import { MERGE_ONLY_VERDICT_ENGINE } from '../src/merge-only-verdict-engine.js';+import { operationIntent } from '../src/relay-sender.js';const e2e = createE2eHelpers();after(e2e.cleanup);@@ -100,6 +101,15 @@ test('a merge-only resubmission keeps its accept and records the resolution diffimportBoard(origin, pending.snapshot);importBoard(objectless, pending.snapshot);const canonical = prepareEngineMove(origin, 'submit', [id, options]);+ const { mergeOnly: suppliedCarry, ...callerOptions } = options;+ assert.ok(suppliedCarry);+ assert.equal(operationIntent('submit', canonical.args), operationIntent('submit', [id, callerOptions]),+ 'the derived canonical carry preserves the interrupted caller intent');+ for (const key of ['commit', 'tree', 'policyCommit', 'gateGreen']) {+ const changed = { ...callerOptions, [key]: key === 'gateGreen' ? false : '0'.repeat(40) };+ assert.notEqual(operationIntent('submit', canonical.args), operationIntent('submit', [id, changed]),+ `${key}: an actual changed submission is not an exact retry`);+ }const at = '2026-01-01T00:00:00.000Z';const sender = { kind: 'agent', agent: options.agentId, userId: 'private-builder',policy: MERGE_ONLY_VERDICT_ENGINE };@@ -190,6 +200,36 @@ test('a merge-only resubmission keeps its accept and records the resolution diffassert.equal(box.git(box.repo, 'rev-parse', 'HEAD'), beforeLanding);assert.deepEqual(store.verdictsFor(forged, id), original.verdicts);assert.deepEqual(store.landingBatches(forged), []);+ // Adopt an already-gated trunk batch while an independent valid item remains ready.+ // That bypasses the earlier all-stale selection refusal and reaches the final publication guard.+ const adoption = store.openBoard(':memory:', undefined, { gitRoot: box.web });+ try {+ importBoard(adoption, exportBoard(forged));+ const readyCommit = box.git(box.repo, 'commit-tree', box.git(box.repo, 'rev-parse', `${trunk}^{tree}`),+ '-p', trunk, '-m', 'private independent ready candidate');+ const ready = store.addItem(adoption, { by: 'coordinator', lane: 'web', title: 'Independent ready candidate' });+ store.claim(adoption, ready, { agentId: options.agentId, lane: 'web', leaseMs: 7_200_000,+ freeze: () => ({ text: pending.item.item_frozen, digest: pending.item.item_frozen_digest }) });+ store.submit(adoption, ready, { agentId: options.agentId, commit: readyCommit,+ tree: box.git(box.repo, 'rev-parse', `${readyCommit}^{tree}`), policyCommit: trunk,+ submissionProof: options.submissionProof });+ store.verify(adoption, ready, { agentId: original.verdicts.at(-1).verdict_by, decision: 'ACCEPT',+ note: 'Private independent candidate keeps adoption selection nonempty', head: readyCommit,+ digest: pending.item.item_frozen_digest, check: 'green',+ review: { commit: readyCommit, head: readyCommit, trunk, paths: [] } });+ const batch = { version: 1, id: 'private-gated-forged-carry', state: 'trunk', base: trunk, tip: extraHead,+ root: box.web, branch: 'refs/heads/main', owner: 'private-adopter', logPath: join(box.repo, '.git', 'private-adoption.log'),+ items: [{ id, commit: extraHead, merge: extraHead }] };+ store.recordLandingBatch(adoption, { agentId: 'coordinator', batch });+ await assert.rejects(runLandingBatch({ root: box.repo, board: adoption, adopt: true,+ config: { landing: { publish: 'separate' } }, owner: 'private-adopter', say: () => {},+ write: async (operation, args) => store[operation](adoption, ...args), checkLease: async () => {} }),+ error => error.code === 'STALE_VERDICT' && /recorded merge-only acceptance/u.test(error.message),+ 'adoption must re-prove an already-gated canonical carry before finishing its trunk receipt');+ assert.equal(store.landingBatches(adoption).at(-1).state, 'trunk');+ assert.equal(store.getItem(adoption, id).item_merged_commit, null);+ assert.equal(box.git(box.repo, 'rev-parse', 'HEAD'), beforeLanding);+ } finally { store.closeBoard(adoption); }store.reopen(forged, id, { agentId: 'coordinator',note: `test/example.test.js: recorded failure; merge commit ${extraHead}` });store.claim(forged, id, { agentId: options.agentId, lane: 'web', leaseMs: 7_200_000,@@ -218,6 +258,8 @@ test('a merge-only resubmission keeps its accept and records the resolution difftry {importBoard(absent, pending.snapshot);const move = prepareEngineMove(absent, 'submit', [id, { ...options, gitRoot: box.web }]);+ assert.equal(Object.hasOwn(move.args[1], 'mergeOnly'), false,+ 'ordinary submit omits a derived null field and discards caller-provided carry');applyEngineMove(absent, move,{ sequence: 1, at: '2026-01-01T00:00:00.000Z' });assert.equal(store.getItem(absent, id).item_status, 'submitted', 'an objectless origin cannot derive carry from caller fields or a serialized gitRoot');