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.

refactor(relay): keep exclusion provenance in its helper [H5,H17]

Corey Olson3f1574b81415
diff --git a/src/relay-exclusion-state.js b/src/relay-exclusion-state.js
index 55322076..ec7fede2 100644
--- a/src/relay-exclusion-state.js
+++ b/src/relay-exclusion-state.js
@@ -16,13 +16,16 @@ export function relayExclusion(root) {
}
/** Successful local unlink remains available to agents; only a person can persist an opt-out. */
-export function excludeRelayByPerson(root, io, record) {
+export function excludeRelayByPerson(root, io, { localRecords, store }) {
let channel;
try { channel = requirePersonChannel(io.personChannel); }
catch (error) { if (error.code === 'B26_PERSON_CHANNEL') return false; throw error; }
const project = repoInfo(root).root;
// Record the intent first: a storage failure can leave a truthful request, never an unattributed exclusion.
- const receipt = record({ path: 'relayOff', reason: 'person relay off', channel, action: 'exclude' });
+ const receipt = localRecords(root, board => {
+ store.logEvent(board, store.PERSON, 'relay_exclusion', null, { path: 'relayOff', reason: 'person relay off', channel, action: 'exclude' });
+ return { by: board.lastEvent.event_by, at: board.lastEvent.event_at, eventId: board.lastEvent.event_id };
+ });
updateRelayMachine(state => {
if (!state.excluded.includes(project)) state.excluded.push(project);
state.exclusionDetails ??= {};
@@ -42,3 +45,10 @@ export function clearRelayExclusion(root) {
return existed;
});
}
+
+/** Explain a completed opt-in without hiding a separate fresh-board notice. */
+export function reportClearedExclusion(result, io) {
+ const notice = 'The exclusion was cleared; this board is linked again.';
+ result.notice = [result.notice, notice].filter(Boolean).join(' ');
+ io.err(notice);
+}
diff --git a/src/relay.js b/src/relay.js
index 55bb0d49..b54b7822 100644
--- a/src/relay.js
+++ b/src/relay.js
@@ -1,6 +1,7 @@
import { relayExclusion } from './relay-exclusion-state.js';
import { excludeRelayByPerson } from './relay-exclusion-state.js';
import { clearRelayExclusion } from './relay-exclusion-state.js';
+import { reportClearedExclusion } from './relay-exclusion-state.js';
import {
cancellationOutcome,
waitForDevicePoll,
@@ -1666,20 +1667,14 @@ export async function relayOn(root, address, io, { session, credential, quiet =
delete state.previousBoardNotice;
saveLink(file, state);
}
- if (clearedExclusion) {
- result.notice = [result.notice, 'The exclusion was cleared; this board is linked again.'].filter(Boolean).join(' ');
- io.err('The exclusion was cleared; this board is linked again.');
- }
+ if (clearedExclusion) reportClearedExclusion(result, io);
return result;
});
}
/** Unlink locally without approval, then request a separate phone-approved remote deletion if possible. */
export async function relayOff(root, io) {
- excludeRelayByPerson(root, io, detail => localRecords(root, board => {
- store.logEvent(board, store.PERSON, 'relay_exclusion', null, detail);
- return { by: board.lastEvent.event_by, at: board.lastEvent.event_at, eventId: board.lastEvent.event_id };
- }));
+ excludeRelayByPerson(root, io, { localRecords, store });
const file = linkFile(root);
return locked(file, async () => {
const state = loadLink(file);