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): the lost-reply decision lives beside its probe [B26,H16]
Corey Olson0868b82f139c
diff --git a/src/relay-baseline-settle.js b/src/relay-baseline-settle.jsindex 8e42bb29..51d78b50 100644--- a/src/relay-baseline-settle.js+++ b/src/relay-baseline-settle.js@@ -62,3 +62,23 @@ export async function settleUncertainBaseline(state, io, read) {}throw new Refused('RELAY_BASELINE_UNCERTAIN', `the relay may already hold this board's first upload but did not say so within ${seconds(Date.now() - startedAt)} s (${cause}); the move was not saved, so run the command again when the relay answers`);}++/**+ * Decide, under the link lock, whether the relay kept a first upload whose reply was lost: true when it holds+ * that exact snapshot, false when it holds no board; another board fences, and no answer refuses once.+ * Why: a client that only saw no reply cannot know the relay has no ordered history, so no move may commit+ * locally until this says so (#919). The link's own read, accept, fence, save and remember steps are passed in.+ */+export async function decideUncertainBaseline(state, io, link) {+ try {+ const verdict = await settleUncertainBaseline(state, io, link.read);+ if (verdict === 'other') link.fence();+ if (verdict === 'accepted') { link.accept(); return true; }+ delete state.baselineUncertain;+ link.save();+ return false;+ } catch (error) {+ link.remember(error);+ throw error;+ }+}diff --git a/src/relay.js b/src/relay.jsindex c3455d94..b707f6d2 100644--- a/src/relay.js+++ b/src/relay.js@@ -85,8 +85,8 @@ import {import { terminalQr } from './qr.js';import { locked } from './relay-lock.js';import {+ decideUncertainBaseline,remoteBoardMissing,- settleUncertainBaseline,uncertainUploadFailure,} from './relay-baseline-settle.js';import {@@ -652,24 +652,11 @@ function acceptBaseline(root, file, state) {if (resumed) clearUploadPauseNotices(state);}-/**- * Decide, under the link lock, whether the relay kept a first upload whose reply was lost: true when it holds- * that exact snapshot, false when it holds no board; another board fences, and no answer refuses once.- * Why: a client that only saw no reply cannot know the relay has no ordered history, so no move may commit- * locally until this says so (#919).- */-async function decideUncertainBaseline(root, file, state, io) {- try {- const verdict = await settleUncertainBaseline(state, io, () => request(state, '/api/v1/boards/' + state.board + '/state', {}, io));- if (verdict === 'other') fenceBaseline(file, state);- if (verdict === 'accepted') { acceptBaseline(root, file, state); return true; }- delete state.baselineUncertain;- saveLink(file, state);- return false;- } catch (error) {- rememberBaselineFailure(io, file, error);- throw error;- }+/** Decide a first upload whose reply was lost, through this link's transport and saved state (#919). */+function decideBaseline(root, file, state, io) {+ return decideUncertainBaseline(state, io, { read: () => request(state, '/api/v1/boards/' + state.board + '/state', {}, io),+ accept: () => acceptBaseline(root, file, state), fence: () => fenceBaseline(file, state),+ save: () => saveLink(file, state), remember: (error) => rememberBaselineFailure(io, file, error) });}/** Send the sequence-zero board image; only its first permanent HTTP refusal pauses relay sends. */@@ -680,22 +667,16 @@ async function uploadInitialBaseline(root, file, state, io) {await requireAbsentBaseline(file, state, io);const pending = state.snapshot;// Written ahead: from here until a definite answer, the relay may hold this snapshot (#919).- state.baselineUncertain = true;+ state.baselineUncertain = sent = true;saveLink(file, state);- sent = true;const reply = await request(state, '/api/v1/boards/' + state.board + '/state', { method: 'PUT', body: pending, initialBaseline: true }, io);if (reply.state?.sequence !== pending.sequence || reply.state.sealed !== pending.sealed) throw new Refused('RELAY_RESPONSE', 'the relay did not acknowledge the initial snapshot; retry the configured relay');acceptBaseline(root, file, state);return true;} catch (error) {- if (sent && state.baselineUncertain) {- if (uncertainUploadFailure(error)) {- if (await decideUncertainBaseline(root, file, state, io)) return true;- } else {- delete state.baselineUncertain;- saveLink(file, state);- }- }+ if (sent && state.baselineUncertain && uncertainUploadFailure(error)) {+ if (await decideBaseline(root, file, state, io)) return true;+ } else if (sent && state.baselineUncertain) { delete state.baselineUncertain; saveLink(file, state); }if (error.relayVersion === 1 && error.code === 'BASELINE_EXISTS') fenceBaseline(file, state);if (!permanentUploadRefusal(error) || state.baselineAccepted) {rememberBaselineFailure(io, file, error);@@ -932,7 +913,7 @@ async function ensureOrdered(root, file, state, io) {state.baselineAccepted = !(state.snapshot?.sequence === 0);}// An earlier command lost the reply to its first upload: decide it before re-sealing or sending anything.- if (state.baselineUncertain && !state.baselineAccepted) await decideUncertainBaseline(root, file, state, io);+ if (state.baselineUncertain && !state.baselineAccepted) await decideBaseline(root, file, state, io);if (state.baselinePause || state.baselineStale) {if (!await retryPausedBaseline(root, file, state, io)) return false;}