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): route roster reads through bounded transport [H17,P5]

Corey Olson8d7324cc0239
diff --git a/src/relay-roster.js b/src/relay-roster.js
index 704faf6f..4af22951 100644
--- a/src/relay-roster.js
+++ b/src/relay-roster.js
@@ -1,8 +1,10 @@
/** Who reads this computer's linked boards: paired phones and joined computers, by name [H17]. */
-import { ENGINE_VERSION } from './machine.js';
import { listApiProjects } from './projects.js';
import { readRelayMachine } from './relay-machine.js';
-import { relayMachineContext, relayOrigin } from './relay.js';
+import {
+ relayMachineContext,
+ relayRosterRead,
+} from './relay.js';
const MACHINE = /^[A-Za-z0-9_.-]{1,128}$/u;
const DEVICE = /^device-[0-9a-f]{32}$/u;
@@ -10,9 +12,7 @@ const DEVICE = /^device-[0-9a-f]{32}$/u;
/** Read one roster document with a board's machine credential; an older or unreachable relay gives null. */
async function rosterRead(state, path) {
try {
- const response = await fetch(relayOrigin(state.url) + path, { redirect: 'error', signal: AbortSignal.timeout(5000),
- headers: { authorization: 'Bearer ' + state.token, 'x-pullboard-engine': String(ENGINE_VERSION) } });
- return response.ok ? await response.json() : null;
+ return await relayRosterRead(state, path);
} catch {
// The roster is a courtesy: local names and dates still print when the relay cannot answer.
return null;
diff --git a/src/relay.js b/src/relay.js
index ffb091f7..9d24160e 100644
--- a/src/relay.js
+++ b/src/relay.js
@@ -1627,6 +1627,20 @@ export async function deliverDeviceWraps(root, io) {
/** Expose board-scoped machine context only to the native setup/approval adapter. */
export function relayMachineContext(root) { return loadLink(linkFile(root)); }
+/** Ignore notices from courtesy roster reads; disconnected boards keep their local labels and dates. */
+function ignoreRosterNotice() {}
+
+const ROSTER_READ_IO = Object.freeze({ ignoreRelayEnvironmentToken: true, err: ignoreRosterNotice });
+
+/** Read only the fixed, board-scoped roster resources through the CLI's existing outbound transport. */
+export async function relayRosterRead(state, path) {
+ const board = typeof state?.board === 'string' && /^[0-9a-f]{32}$/u.test(state.board);
+ const allowed = typeof path === 'string' && (path === '/api/v1/devices' || /^\/api\/v1\/devices\/device-[0-9a-f]{32}$/u.test(path) ||
+ (board && path === `/auth/machines?board=${state.board}`));
+ if (!allowed) throw new Refused('RELAY_ROSTER_PATH', 'the roster requested an unsupported relay resource');
+ return request(state, path, { method: 'GET', signal: AbortSignal.timeout(5000) }, ROSTER_READ_IO);
+}
+
/** Require one exact phone approval before revoking and removing a device from the trusted roster. */
export async function relayRevokeDevice(root, deviceId, io) {
requirePersonChannel(io.personChannel);