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): preserve enrolled worktrees after token failure [H2,H9]
Corey Olson5b623e052352
diff --git a/src/cli.js b/src/cli.jsindex 6f0f5c01..1a16fc07 100644--- a/src/cli.js+++ b/src/cli.js@@ -851,6 +851,11 @@ async function worktreeFor(io, lane, route, family = null) {let id;try { id = await withBoard(ctx, async (board) => await ordered(ctx, board, 'register', [{ lane, path: root, route, family }])); }catch (error) {+ const registered = withBoard(ctx, (board) => store.agentAt(board, root));+ if (registered) {+ io.err('pullboard: registration is already ordered; the worktree is preserved. Retry enrollment to obtain its credential: ' + cdTo(root) + ' pullboard join ' + lane);+ throw error;+ }// Only remove the clean worktree just created here; preserve it if another process changed it.const removed = tryGit(mainRoot, ['worktree', 'remove', root]);if (removed.status === 0) tryGit(mainRoot, ['branch', '-d', `${lane}/${n}`]);diff --git a/src/relay.js b/src/relay.jsindex 02e1df21..c74fcc4c 100644--- a/src/relay.js+++ b/src/relay.js@@ -130,7 +130,7 @@ async function request(state, path, { method = 'GET', body, allowMissing = falsenotices(document, io);// Only off can forget a link after a supported API reports that the board is gone.if (allowMissing && method === 'DELETE' && response.status === 404 && document.version === 1) return { alreadyDeleted: true };- if (!response.ok) throw new Refused(document.error?.code || 'RELAY_UNAVAILABLE', (document.error?.code === 'AUTH_REQUIRED' ? (state.agent ? 'this agent token is expired or revoked; ask the person to issue a new token for this agent, then retry with PULLBOARD_RELAY_TOKEN' : 'the relay sign-in expired or was revoked; run pullboard relay on to sign in again without changing the board key') : (document.error?.message ? `the relay ${state.url}: ${document.error.message}` : null)) || 'the relay refused this send; retry this command explicitly when reachable');+ if (!response.ok) throw new Refused(document.error?.code || 'RELAY_UNAVAILABLE', (document.error?.code === 'AUTH_REQUIRED' ? ((state.agent || token?.startsWith('pa_')) ? 'this agent token is expired or revoked; use a new token issued by the person for this agent, then retry with PULLBOARD_RELAY_TOKEN' : 'the relay sign-in expired or was revoked; run pullboard relay on to sign in again without changing the board key') : (document.error?.message ? `the relay ${state.url}: ${document.error.message}` : null)) || 'the relay refused this send; retry this command explicitly when reachable');if (document.version !== 1) throw new Refused('RELAY_VERSION', 'the relay API version is unsupported; upgrade Pullboard before syncing');return document;}@@ -482,6 +482,7 @@ export async function relayRevoke(root, id, io) {throw new Refused('TOKEN_NOT_OWNED', 'choose a token listed on this board by pullboard relay tokens');}const result = await request(state, '/auth/tokens/revoke', { method: 'POST', body: { id } }, io);+ if (result.id !== id || result.revoked !== true) throw new Refused('RELAY_RESPONSE', 'the relay did not acknowledge this token revocation; retry its opaque id');for (const credential of Object.values(state.agentTokens ?? {})) if (credential.id === id) credential.revoked = true;saveLink(file, state);return { ...tokenContext(state), id: result.id, revoked: result.revoked };