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
test: trace deferred relay flush operations [H16]
Corey Olsonafd9af0cdaf1
diff --git a/test/relay-client-replica-fixture.js b/test/relay-client-replica-fixture.jsindex 3713114c..576e0bc6 100644--- a/test/relay-client-replica-fixture.js+++ b/test/relay-client-replica-fixture.js@@ -1,5 +1,6 @@/** Read and replay fixture replica state without changing its durable history [H16,V1,V17]. */import { DatabaseSync } from 'node:sqlite';+import { unseal } from '../src/seal.js';import { syncRelay } from '../src/relay.js';/** Read local events directly so inspection itself cannot drain the durable retry queue. */@@ -18,6 +19,16 @@ export function receipts(file) {} finally { db.close(); }}+/** Decode only stable operation identity fields from captured fixture relay posts. */+export async function relayUploadSummary(uploads, key, boardId) {+ return Promise.all(uploads.map(async ({ sequence, sealed }) => {+ const plain = await unseal(key, Buffer.from(sealed, 'base64url'), { boardId, kind: 'move', sequence });+ const move = JSON.parse(new TextDecoder().decode(plain));+ return { sequence, operation: move.operation, moveId: move.id,+ item: Number.isSafeInteger(move.args?.[0]) ? move.args[0] : null };+ }));+}+/** Replay a fixture clone's real outbox through the production sync path without another CLI process. */export async function syncReplica(root, env) {const keys = ['HOME', 'USERPROFILE', 'PULLBOARD_HOME', 'PULLBOARD_RELAY_TOKEN', 'PULLBOARD_RELAY_SENDER_BACKGROUND',diff --git a/test/relay-client.test.js b/test/relay-client.test.jsindex fe9c6c62..7032824b 100644--- a/test/relay-client.test.js+++ b/test/relay-client.test.js@@ -31,7 +31,7 @@ import { captureSpecApprovalBaseline } from '../src/spec-approval.js';import { AGENT_SHELL_MARKERS, SSH_SHELL_MARKERS } from '../src/person.js';import { legacyMirrorQueueFragment } from './relay-client-legacy-case.js';import { assertBaselineResumeEvidence, assertOriginalBaselineEvidence } from './relay-client-baseline-case.js';-import { localEvents, receipts, syncReplica } from './relay-client-replica-fixture.js';+import { localEvents, receipts, relayUploadSummary, syncReplica } from './relay-client-replica-fixture.js';import { assertDroppedReplyConsumed, commitInitializedRepoFiles, enterLegacyAckPolicy } from './relay-client-policy-fixture.js';import { threeReplicaPhaseCapture } from './relay-client-timing.js';@@ -1236,14 +1236,17 @@ async function recoverReplicaReplies(fixture, timing) {const beforeRecoveredStack = relay.uploads.length;relay.dropNextReply({ offline: true, operation: 'submit', item: stackedB, key, boardId });const lostStackSubmit = await timing.wait('submit recovered-stack item B with its reply dropped', () => cliResult(worktrees[0], envs[0], 'submit', String(stackedB)));+ const afterLostStackSubmit = relay.uploads.length;assertDroppedReplyConsumed(relay, 'the recovered-stack submission reply');assert.equal(lostStackSubmit.status, 1);assert.equal(lostStackSubmit.document.error.code, 'RELAY_UNAVAILABLE');relay.failReads(false);const laterA = await timing.wait('submit stack item A after B has a lost reply', () => cliResult(worktrees[1], envs[1], 'submit', String(stackedA)));+ const afterLaterA = relay.uploads.length;assert.equal(laterA.status, 0, laterA.stderr);assert.equal(laterA.document.commit, firstRecoveryCommit);await timing.wait('sync clone A to recover stacked submission B', () => cli(clones[0], envs[0], 'status'));+ const afterStackRecovery = relay.uploads.length;const recoveredLink = join(commonDir(clones[0], envs[0]), 'pullboard', 'relay.json');const pendingOutcome = JSON.parse(readFileSync(recoveredLink, 'utf8')).recovered;@@ -1253,6 +1256,12 @@ async function recoverReplicaReplies(fixture, timing) {const recoveredReceipt = receipts(replicaFiles[0]).find((receipt) => JSON.parse(receipt.move).id === pendingOutcome.move.id);assert.deepEqual(JSON.parse(recoveredReceipt.move), pendingOutcome.move, 'the pending reply has the exact durable engine receipt');const beforeOutcomeRetry = relay.uploads.length;+ console.log('stacked submit upload diagnostic', JSON.stringify({+ lostB: await relayUploadSummary(relay.uploads.slice(beforeRecoveredStack, afterLostStackSubmit), key, boardId),+ submitA: await relayUploadSummary(relay.uploads.slice(afterLostStackSubmit, afterLaterA), key, boardId),+ syncA: await relayUploadSummary(relay.uploads.slice(afterLaterA, afterStackRecovery), key, boardId),+ pendingReceiptRead: await relayUploadSummary(relay.uploads.slice(afterStackRecovery, beforeOutcomeRetry), key, boardId),+ }));assert.equal(beforeOutcomeRetry, beforeRecoveredStack + 2, 'the relay applied B and then A once each');const originalOutcome = await timing.wait('read the durable original submission outcome for B', () => cli(worktrees[0], envs[0], 'submit', String(stackedB)));assert.equal(originalOutcome.commit, recoveredStackCommit);