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(relay): keep canary helper out of command discovery [H5,H17]

Corey Olson21c4179d31b8
diff --git a/src/commands/relay.js b/src/commands/relay.js
index dd3c739d..2ad779a7 100644
--- a/src/commands/relay.js
+++ b/src/commands/relay.js
@@ -52,7 +52,7 @@ import {
/** Run `pullboard relay` and return its exit code. */
export async function run(io, { first, second, rest, values }) {
- if (first === 'canary') return (await import('./relay-canary.js')).run(io, { first: second, second: rest[0], rest: rest.slice(1), values });
+ if (first === 'canary') return (await import('../relay-canary-command.js')).run(io, { first: second, second: rest[0], rest: rest.slice(1), values });
if (['on', 'join'].includes(first) && gitSyncLinked(io.cwd)) throw new Refused('GIT_SYNC_LINKED', 'this board already shares moves through Git; it cannot start a second move order', 'keep using pullboard sync for this board');
if (values['new-browser'] && first !== 'pair') throw new Refused('USAGE', 'pullboard relay pair --new-browser');
if (first === 'members') {
diff --git a/src/commands/relay-canary.js b/src/relay-canary-command.js
similarity index 92%
rename from src/commands/relay-canary.js
rename to src/relay-canary-command.js
index 83c34d8c..88ca1c55 100644
--- a/src/commands/relay-canary.js
+++ b/src/relay-canary-command.js
@@ -1,14 +1,28 @@
/** Explicit machine-local canary commands; all messages retain the caller's ordinary authority [H5,H17]. */
import { realpathSync } from 'node:fs';
-import { context, ordered, withBoard, whoAmI } from '../cli.js';
-import { COORDINATOR } from '../config.js';
-import { PERSON } from '../board.js';
-import { Refused } from '../refused.js';
-import { relayMachineContext, relayStatus } from '../relay.js';
-import { loadMachineSettings, setRelayCanary } from '../settings.js';
-import { relayCanaryConfig } from '../relay-canary-config.js';
-import { readRelayHealth } from '../relay-canary-health.js';
-import { startRelayCanaryWatch, runRelayCanary } from '../relay-canary-watch.js';
+import {
+ context,
+ ordered,
+ withBoard,
+ whoAmI,
+} from './cli.js';
+import { COORDINATOR } from './config.js';
+import { PERSON } from './board.js';
+import { Refused } from './refused.js';
+import {
+ relayMachineContext,
+ relayStatus,
+} from './relay.js';
+import {
+ loadMachineSettings,
+ setRelayCanary,
+} from './settings.js';
+import { relayCanaryConfig } from './relay-canary-config.js';
+import { readRelayHealth } from './relay-canary-health.js';
+import {
+ startRelayCanaryWatch,
+ runRelayCanary,
+} from './relay-canary-watch.js';
/** Read telemetry without contacting the relay or creating a health observation. */
function status(root, config) {
diff --git a/test/relay-canary-notice-delivery.test.js b/test/relay-canary-notice-delivery.test.js
new file mode 100644
index 00000000..c250f956
--- /dev/null
+++ b/test/relay-canary-notice-delivery.test.js
@@ -0,0 +1,95 @@
+/** Exercise ordinary canary notification delivery through a real linked fixture, not a callback stand-in [H5,H17]. */
+import assert from 'node:assert/strict';
+import { existsSync, readFileSync, writeFileSync } from 'node:fs';
+import { delimiter, join } from 'node:path';
+import test from 'node:test';
+import { fileURLToPath } from 'node:url';
+import { relayClientFixture } from './relay-client-fixture.js';
+import { runFixtureGit } from './fixture-child.js';
+
+/** Commit the fixture configuration with its own isolated normal Pullboard commit hook entry point. */
+function commitConfiguration(box) {
+ const file = join(box.root, 'pullboard.json');
+ const config = JSON.parse(readFileSync(file, 'utf8'));
+ writeFileSync(file, JSON.stringify(config, null, 2) + '\n');
+ const cli = fileURLToPath(new URL('../bin/pullboard.js', import.meta.url));
+ const privateBin = box.env.PATH.split(delimiter)[0];
+ const pullboard = join(privateBin, 'pullboard');
+ assert.equal(existsSync(pullboard), false, 'never overwrite an existing fixture executable');
+ writeFileSync(pullboard, `#!/bin/sh\nexec node "${cli}" "$@"\n`, { mode: 0o700 });
+ runFixtureGit(['add', 'pullboard.json'], { cwd: box.root, env: box.env });
+ runFixtureGit(['commit', '-q', '-m', 'chore(config): prepare canary delivery'], { cwd: box.root, env: box.env });
+}
+
+/** Use a genuine joined worktree, with no coordinator identity or environment credential substitution. */
+async function joinedCanarySeat(box) {
+ const root = join(box.root, '..', 'notice-canary-seat');
+ runFixtureGit(['worktree', 'add', '-q', '-b', 'agent/notice-canary', root], { cwd: box.root, env: box.env });
+ const joined = await box.cliAt(root, 'join', box.lane, '--model', 'notice-canary-fixture');
+ assert.equal(joined.code, 0, joined.failure);
+ assert.equal(typeof joined.document.agent, 'string');
+ assert.notEqual(joined.document.agent, 'coordinator');
+ return { root, agentId: joined.document.agent };
+}
+
+/** Read private machine telemetry only through the normal status command. */
+async function status(box, seat) {
+ const result = await box.cliAt(seat.root, 'relay', 'canary', 'status');
+ assert.equal(result.code, 0, result.failure);
+ assert.equal(result.document.config.agentId, seat.agentId);
+ return result.document.health;
+}
+
+test('the ordinary canary command retains outage notices then records delayed alert and recovery for both native readers [H5,H17]', { timeout: 60_000 }, async t => { // budget: private linked Git fixture, four bounded probes, normal message delivery and cleanup; no timing oracle.
+ const box = await relayClientFixture(t);
+ commitConfiguration(box);
+ await box.link();
+ const seat = await joinedCanarySeat(box);
+ const enabled = await box.cliAt(seat.root, 'relay', 'canary', 'on', '--timeout', '5000');
+ assert.equal(enabled.code, 0, enabled.failure);
+ assert.equal(enabled.document.config.agentId, seat.agentId);
+ const baseline = await box.cliAt(seat.root, 'relay', 'canary', 'run');
+ assert.equal(baseline.code, 0, baseline.failure);
+ assert.equal(baseline.document.observation.ok, true);
+
+ const origin = box.origin;
+ await box.stopRelay();
+ const first = await box.cliAt(seat.root, 'relay', 'canary', 'run');
+ assert.equal(first.code, 1, 'a stopped relay cannot complete a sealed round trip');
+ const once = await status(box, seat);
+ assert.equal(once.consecutiveFailures, 1, 'the normal CLI recorded its own failed round trip');
+ assert.equal(once.pendingNotifications, 0, 'one failure has not yet raised the two-failure alert');
+ const second = await box.cliAt(seat.root, 'relay', 'canary', 'run');
+ assert.equal(second.code, 1, 'an outage cannot claim successful notification delivery');
+ const pending = await status(box, seat);
+ assert.equal(pending.consecutiveFailures, 2);
+ assert.equal(pending.status, 'degraded');
+ assert.equal(pending.pendingNotifications, 1, 'the unrecorded alert remains durable across independent CLI processes');
+ assert.equal(typeof pending.alertSince, 'string');
+
+ await box.restartRelay();
+ assert.equal(box.origin, origin, 'the fixture restarts the same listener and journal, not a replacement linked origin');
+ const recovered = await box.cliAt(seat.root, 'relay', 'canary', 'run');
+ assert.equal(recovered.code, 0, recovered.failure);
+ assert.equal(recovered.document.observation.ok, true);
+ assert.equal(recovered.document.health.pendingNotifications, 0, 'only actual recording to every native reader clears the queue');
+ const final = await status(box, seat);
+ assert.equal(final.status, 'healthy');
+ assert.equal(final.pendingNotifications, 0);
+
+ const exported = await box.cli('export');
+ assert.equal(exported.code, 0, exported.failure);
+ assert.ok(Array.isArray(exported.document.tables.shout), 'export exposes native shout rows with actual sender and recipient');
+ const notices = exported.document.tables.shout.filter(row => row.shout_from === seat.agentId && /Relay canary (?:alert|recovery) at/u.test(row.shout_text));
+ assert.equal(notices.length, 4, 'one alert and one recovery are actually recorded for each of the two native recipients');
+ for (const to of ['coordinator', 'person']) {
+ const alerts = notices.filter(row => row.shout_to === to && /Relay canary alert at/u.test(row.shout_text));
+ const recoveries = notices.filter(row => row.shout_to === to && /Relay canary recovery at/u.test(row.shout_text));
+ assert.equal(alerts.length, 1, `one actual alert reaches native ${to}`);
+ assert.match(alerts[0].shout_text, /^DELAYED:/u, 'a queued outage alert remains labelled delayed even when the current probe recovered');
+ assert.match(alerts[0].shout_text, /not a phone acknowledgement/u, 'native receipt is not phone delivery evidence');
+ assert.equal(recoveries.length, 1, `one actual recovery reaches native ${to}`);
+ }
+ const off = await box.cliAt(seat.root, 'relay', 'canary', 'off');
+ assert.equal(off.code, 0, off.failure);
+});
diff --git a/test/relay-canary-watch.test.js b/test/relay-canary-watch.test.js
index 57d6058a..25c85192 100644
--- a/test/relay-canary-watch.test.js
+++ b/test/relay-canary-watch.test.js
@@ -221,7 +221,7 @@ test('a stalled real board route is bounded by the probe deadline [H5,H17]', { t
finally { box.stallApi(false); }
assert.equal(result.ok, false, 'an unanswered board route is never a healthy round trip');
assert.ok(['push', 'pull'].includes(result.step), JSON.stringify(result));
- assert.ok(performance.now() - started < 5000, 'budget: the 250 ms probe deadline must drain below the normal five-second probe ceiling');
+ assert.ok(performance.now() - started < 5000, 'the probe drains before its normal ceiling'); // budget: the declared five-second probe ceiling bounds a stalled request.
const healthy = await withFixtureEnvironment(box.env, () => probeRelayCanary(seat.root, { agentId: seat.agentId }));
assert.equal(healthy.ok, true, JSON.stringify(healthy));
});