Skip to content

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.

fix(activity): retain inbox reads during recovery [H16,N26]

Corey Olsonf3c97efa2ec7
diff --git a/src/activity-delivery-cli.js b/src/activity-delivery-cli.js
index 044132db..003f01b3 100644
--- a/src/activity-delivery-cli.js
+++ b/src/activity-delivery-cli.js
@@ -2,6 +2,7 @@
import * as store from './board.js';
import { readActivityDelivery } from './activity-delivery-read.js';
import { handoffMoveProblem } from './handoff-state.js';
+import { Refused } from './refused.js';
import {
activityMainFiles,
activityWorkingFiles,
@@ -64,7 +65,14 @@ export async function deliverActivity(ctx, { actedIds = [], afterSubmit = false,
// Pending obligations survive an output failure: delivery is not acknowledgement.
const retired = handoffMoveProblem(board, me.id, 'recordActivityDelivery', [{ agentId: me.id }]);
if (retired) activity.receipt = { recorded: false, code: retired.code, message: retired.message };
- else await recordIncluded(ctx, board, me.id, observation);
+ else {
+ try { await recordIncluded(ctx, board, me.id, observation); }
+ catch (error) {
+ if (!(error instanceof Refused) || error.code !== 'RELAY_RECOVERY_PENDING') throw error;
+ // Recovery keeps canonical writes fenced; unread obligations replay until their delivery is recorded.
+ activity.receipt = { recorded: false, code: error.code, message: error.message };
+ }
+ }
return { shouts, agents: store.listAgents(board), activity, local };
});
if (!saveActivityCursor(delivered.local, delivered.activity.cursor)) {
diff --git a/test/relay-sealed.test.js b/test/relay-sealed.test.js
index 7b9559d6..ea50a6e6 100644
--- a/test/relay-sealed.test.js
+++ b/test/relay-sealed.test.js
@@ -778,6 +778,8 @@ test('person recovery explicitly skips one future-engine blocker and publishes a
{ cwd: box.root, env: { ...box.env, PULLBOARD_HOME: box.home }, encoding: 'utf8' });
assert.equal(inboxCommand.status, 0, inboxCommand.stderr);
assert.match(inboxCommand.stdout, /read cursor recovery probe/);
+ assert.match(inboxCommand.stdout, /activity delivery was not recorded: .*RELAY_RECOVERY_PENDING/u,
+ 'the local read reports its deferred canonical delivery without claiming acknowledgement');
const afterInbox = store.openBoard(join(box.root, '.git/pullboard/board.sqlite'));
let cursorAfterInbox;
try { cursorAfterInbox = afterInbox.db.prepare("SELECT agent_last_shout_id FROM agent WHERE agent_id='coordinator'").get().agent_last_shout_id; }
@@ -1049,7 +1051,7 @@ test('recovery collision status preserves the retry while the winner catches an
const winningNative = await openCheckpoint(box, winningCheckpoint);
process.env.PULLBOARD_HOME = secondHome;
const futureNative = structuredClone(winningNative);
- futureNative.tables.board_meta.find((row) => row.meta_key === 'relay_engine_version').meta_value = '99';
+ futureNative.tables.board_meta.find((row) => row.meta_key === 'relay_engine_version').meta_value = String(ENGINE_VERSION + 1);
const futureSeal = Buffer.from(await sealMove(box.key, new TextEncoder().encode(JSON.stringify(futureNative)),
{ boardId: box.id, kind: 'snapshot', sequence: 1 })).toString('base64url');
assert.equal((await box.call(box.path + '/state', { method: 'PUT', token: box.person.token, body: { sequence: 1, sealed: futureSeal } })).status, 200);