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): a bad stored canary is a bad machine setting [H5,H17,M1]

Corey Olsona6a7d638ae5c
diff --git a/src/relay-canary-config.js b/src/relay-canary-config.js
index a5576bcd..866358c4 100644
--- a/src/relay-canary-config.js
+++ b/src/relay-canary-config.js
@@ -4,16 +4,33 @@ import { Refused } from './refused.js';
/** Validate only execution settings; credentials remain in the existing board link and device key store. */
export function relayCanaryConfig(value) {
+ const problem = relayCanaryProblem(value);
+ if (problem) throw new Refused('RELAY_CANARY_CONFIG', problem);
+ return normalCanary(value);
+}
+
+/**
+ * Name what is wrong with a stored canary setting, or return null when it is valid or absent.
+ * Why: machine settings load on every move, so they report a bad canary as BAD_MACHINE_SETTINGS
+ * without raising the canary command's own refusal from unrelated moves.
+ */
+export function relayCanaryProblem(value) {
if (value === undefined || value === null) return null;
if (!value || typeof value !== 'object' || Array.isArray(value)
|| typeof value.enabled !== 'boolean' || typeof value.root !== 'string' || !isAbsolute(value.root)
|| typeof value.agentId !== 'string' || !value.agentId || /\s/u.test(value.agentId)
|| Object.keys(value).some(key => !['enabled', 'root', 'agentId', 'deadlineMs'].includes(key))) {
- throw new Refused('RELAY_CANARY_CONFIG', 'configure a dedicated linked seat with pullboard relay canary on; credentials are never command arguments');
+ return 'configure a dedicated linked seat with pullboard relay canary on; credentials are never command arguments';
}
const deadlineMs = value.deadlineMs ?? 5000;
if (!Number.isSafeInteger(deadlineMs) || deadlineMs < 100 || deadlineMs > 25000) {
- throw new Refused('RELAY_CANARY_CONFIG', 'set the canary timeout between 100 and 25000 milliseconds, below its one-minute cadence');
+ return 'set the canary timeout between 100 and 25000 milliseconds, below its one-minute cadence';
}
- return { enabled: value.enabled, root: value.root, agentId: value.agentId, deadlineMs };
+ return null;
+}
+
+/** Copy only the known canary fields, defaulting the deadline; the value is already validated. */
+function normalCanary(value) {
+ if (value === undefined || value === null) return null;
+ return { enabled: value.enabled, root: value.root, agentId: value.agentId, deadlineMs: value.deadlineMs ?? 5000 };
}
diff --git a/src/settings.js b/src/settings.js
index 1e03ed60..84dfcd6c 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -14,6 +14,7 @@ import {
import { validateRunner } from './runners.js';
import { Refused } from './refused.js';
import { relayCanaryConfig } from './relay-canary-config.js';
+import { relayCanaryProblem } from './relay-canary-config.js';
import {
DEFAULT_RUNNER_WAIT_MS,
validateRunnerWaitMs,
@@ -64,7 +65,8 @@ export function loadMachineSettings() {
if (value.relay?.offerAtInit !== undefined && typeof value.relay.offerAtInit !== 'boolean') {
throw new Refused('BAD_MACHINE_SETTINGS', `relay.offerAtInit in ${file} must be true or false`);
}
- relayCanaryConfig(value.relay?.canary);
+ const canaryProblem = relayCanaryProblem(value.relay?.canary);
+ if (canaryProblem) throw new Refused('BAD_MACHINE_SETTINGS', `relay.canary in ${file} is invalid: ${canaryProblem}`);
if (value.gate?.memoryFloorMB !== undefined && (!Number.isSafeInteger(value.gate.memoryFloorMB) || value.gate.memoryFloorMB < 0)) {
throw new Refused('BAD_MACHINE_SETTINGS', `gate.memoryFloorMB in ${file} must be a whole number of megabytes, 0 or more; fix it before running Pullboard`);
}