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(relay): return original events on API retries [H3,H16]
Corey Olson4e718fdc2a4b
diff --git a/src/cli.js b/src/cli.jsindex 4f3e351f..83e8a702 100644--- a/src/cli.js+++ b/src/cli.js@@ -1791,6 +1791,7 @@ function workCommands(io, args) {add: () => act(async (ctx, board, me) => {const recovered = await relayCommandReceipt(ctx.info.root, io.relayCommand);if (recovered) {+ for (const event of recovered.events) io.onEvent?.(event);const id = recovered.result;io.result?.({ item: store.getItem(board, id) });io.say(`#${id}`);@@ -1829,6 +1830,7 @@ function workCommands(io, args) {const id = idArg(first);const recovered = await relayCommandReceipt(ctx.info.root, io.relayCommand);if (recovered) {+ for (const event of recovered.events) io.onEvent?.(event);io.result?.({ item: store.getItem(board, id) });io.say(`edited #${id}`);sayCheckBaseline(io, store.getItem(board, id));@@ -1926,6 +1928,7 @@ function workCommands(io, args) {merged: () => act(async (ctx, board, me) => {const recovered = await relayCommandReceipt(ctx.info.root, io.relayCommand);if (recovered) {+ for (const event of recovered.events) io.onEvent?.(event);const commit = recovered.move.args[1].commit;io.result?.({ id: idArg(first), commit });io.say(`#${first} merged as ${commit.slice(0, 12)}`);diff --git a/src/relay.js b/src/relay.jsindex 913acbcb..f1d71b0d 100644--- a/src/relay.js+++ b/src/relay.js@@ -518,7 +518,7 @@ export async function relayCommandReceipt(root, command) {saveLink(file, state);throw new Refused(receipt.outcome.error.code, receipt.outcome.error.message);}- return { result: receipt.outcome.result, move };+ return { result: receipt.outcome.result, events: receipt.outcome.events ?? [], move };});}diff --git a/test/relay-client.test.js b/test/relay-client.test.jsindex e32b2653..f26b72f2 100644--- a/test/relay-client.test.js+++ b/test/relay-client.test.js@@ -563,6 +563,29 @@ test('[H3,H16] three cloned linked replicas order competing claims and recover lassert.equal(result.event.event_kind, 'add');assert.equal(result.event.item_id, result.result.item.item_id, 'the API returns its own event despite catching up an earlier add');assert.equal(result.result.item.item_title, 'This API item');++ const apiLostTitle = 'Lost API reply';+ const apiLostBody = JSON.stringify({ verb: 'add', args: { lane: 'web', title: apiLostTitle } });+ const apiLostHeaders = { 'x-pullboard-key': address.searchParams.get('k'), 'content-type': 'application/json' };+ const beforeLostApi = relay.uploads.length;+ relay.dropNextReply({ offline: true });+ const lostApi = await fetch(`${address.origin}/api/v1/boards/${boardId}/moves`, {+ method: 'POST', headers: apiLostHeaders, body: apiLostBody,+ });+ const lostApiResult = await lostApi.json();+ assert.equal(lostApi.status, 409, JSON.stringify(lostApiResult));+ assert.equal(lostApiResult.error.code, 'RELAY_UNAVAILABLE');+ relay.failReads(false);+ await cli(clones[0], envs[0], 'status');+ const apiRetry = await fetch(`${address.origin}/api/v1/boards/${boardId}/moves`, {+ method: 'POST', headers: apiLostHeaders, body: apiLostBody,+ });+ const apiRetryResult = await apiRetry.json();+ assert.equal(apiRetry.status, 200, JSON.stringify(apiRetryResult));+ assert.equal(apiRetryResult.event.event_kind, 'add');+ assert.equal(apiRetryResult.event.item_id, apiRetryResult.result.item.item_id);+ assert.equal(apiRetryResult.result.item.item_title, apiLostTitle);+ assert.equal(relay.uploads.length, beforeLostApi + 1, 'local API retry returns its original emitted event without posting again');} finally { await localApi.close(); }const beforeDropped = relay.uploads.length;