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): send engine from deployment smoke [H16,H3]

Corey Olson894e7090f788
diff --git a/relay/smoke.mjs b/relay/smoke.mjs
index c6090a7b..47a7cb2f 100644
--- a/relay/smoke.mjs
+++ b/relay/smoke.mjs
@@ -3,6 +3,7 @@ import { spawn } from 'node:child_process';
import { existsSync, readFileSync, statSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
+import { ENGINE_VERSION } from '../src/machine.js';
import { readBoardKey } from '../src/relay-key.js';
import { unseal } from '../src/seal.js';
@@ -48,7 +49,7 @@ function cliGit(root, args) {
/** Read one authenticated event and prove that the smoke-created item reached the relay. */
async function readMirroredMove({ address, board, token, key, after, item, title }) {
const path = `/api/v1/boards/${board}/events?after=${after}`;
- const response = await fetch(new URL(path, address), { headers: { authorization: `Bearer ${token}` } });
+ const response = await fetch(new URL(path, address), { headers: { authorization: `Bearer ${token}`, 'x-pullboard-engine': String(ENGINE_VERSION) } });
if (!response.ok) {
const refusal = await response.json().catch(() => ({}));
if (refusal.error?.code === 'SNAPSHOT_REQUIRED') {
@@ -63,7 +64,7 @@ async function readMirroredMove({ address, board, token, key, after, item, title
const move = JSON.parse(new TextDecoder().decode(bytes));
if (move.operation === 'addItem') {
if (move.args?.[0]?.title !== title) throw new Error('the decrypted relay operation is not the smoke item');
- const stateResponse = await fetch(new URL(`/api/v1/boards/${board}/state`, address), { headers: { authorization: `Bearer ${token}` } });
+ const stateResponse = await fetch(new URL(`/api/v1/boards/${board}/state`, address), { headers: { authorization: `Bearer ${token}`, 'x-pullboard-engine': String(ENGINE_VERSION) } });
if (!stateResponse.ok) throw new Error('the relay did not return its native checkpoint');
const saved = await stateResponse.json();
const checkpointBytes = await unseal(key, Buffer.from(saved.state.sealed, 'base64url'), {
@@ -83,7 +84,7 @@ async function readMirroredMove({ address, board, token, key, after, item, title
/** Read a compacted move from its authenticated native checkpoint when the event tail is gone. */
async function readMirroredCheckpoint({ address, board, token, key, after, item, title }) {
- const response = await fetch(new URL(`/api/v1/boards/${board}/state`, address), { headers: { authorization: `Bearer ${token}` } });
+ const response = await fetch(new URL(`/api/v1/boards/${board}/state`, address), { headers: { authorization: `Bearer ${token}`, 'x-pullboard-engine': String(ENGINE_VERSION) } });
if (!response.ok) throw new Error('the relay did not return the mirrored checkpoint');
const saved = await response.json();
const sequence = saved.state?.sequence;
diff --git a/test/relay-client-fixture.js b/test/relay-client-fixture.js
index 6f4f8a0c..f6aaa548 100644
--- a/test/relay-client-fixture.js
+++ b/test/relay-client-fixture.js
@@ -153,6 +153,12 @@ export async function relayClientFixture(t) {
assert.equal((await cli('relay', 'on', '--url', origin)).code, 0, 'real device sign-in links the board');
privateKeys.add(readFileSync(keyFile, 'utf8').trim());
}
+ /** Raise this fixture board's durable minimum to the current engine before compatibility checks. */
+ async function requireEngineThree() {
+ const state = JSON.parse(readFileSync(linkFile, 'utf8'));
+ await auth.issueToken(state.token, { board: state.board, agent: 'fixture-engine-minimum' });
+ return auth.minimumEngineVersion(state.board);
+ }
/** Pair and unlink from a second real repository with its own private device home and key. */
async function otherDeviceOff() {
const otherRoot = join(scratch, 'other-device');
@@ -195,7 +201,7 @@ export async function relayClientFixture(t) {
return childResult(root, env, ['--input-type=module', '-e', source]);
}
return {
- root, env, origin, lane, before, linkFile, keyFile, calls, moveAcks, cli, link, otherDeviceOff, additionalBoard, script, stopRelay, restartRelay,
+ root, env, origin, lane, before, linkFile, keyFile, calls, moveAcks, cli, link, requireEngineThree, otherDeviceOff, additionalBoard, script, stopRelay, restartRelay,
advance(days) { time = Date.now() + days * 86400000; },
overrideDelete(value) { override = value; },
refuseSnapshotWrites(value) { refuseSnapshotWrites = value; },
diff --git a/test/relay-deploy.test.js b/test/relay-deploy.test.js
index 7ce954aa..fc641b81 100644
--- a/test/relay-deploy.test.js
+++ b/test/relay-deploy.test.js
@@ -6,6 +6,7 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync,
import { join, resolve } from 'node:path';
import { tmpdir } from 'node:os';
import { test } from 'node:test';
+import { ENGINE_VERSION } from '../src/machine.js';
import { relayClientFixture } from './relay-client-fixture.js';
import { githubFixture } from './relay-fixture.js';
@@ -209,6 +210,7 @@ test('[H5,H18] the Railway checklist matches the container and relay runtime set
test('[H5,H18] the Railway smoke links, reads one unsealed move and unlinks locally', async (t) => {
const box = await relayClientFixture(t);
await box.link();
+ assert.equal(await box.requireEngineThree(), ENGINE_VERSION, 'the real relay fixture now refuses legacy declarations for this board');
const previous = JSON.parse(readFileSync(box.linkFile, 'utf8'));
assert.equal((await box.cli('relay', 'off')).code, 0);
const beforeSmoke = box.calls.length;
@@ -223,6 +225,10 @@ test('[H5,H18] the Railway smoke links, reads one unsealed move and unlinks loca
assert.equal(existsSync(box.keyFile), false, 'relay off forgets the device-only board key');
assert.ok(box.calls.slice(beforeSmoke).some((call) => call.method === 'DELETE' && call.path === `/api/v1/boards/${previous.board}`),
'the smoke sends relay off to the supplied local relay');
+ const smokeReads = box.calls.slice(beforeSmoke).filter((call) => call.method === 'GET'
+ && new RegExp(`^/api/v1/boards/${previous.board}/(?:events|state)(?:\\?|$)`, 'u').test(call.path));
+ assert.ok(smokeReads.length >= 2, 'the smoke reads the mirrored event and its native checkpoint over the real HTTP API');
+ assert.ok(smokeReads.every((call) => call.engine === String(ENGINE_VERSION)), 'every smoke board-content read declares the current engine after the relay minimum is raised');
const local = (await box.cli('export')).document;
assert.ok(local.tables.item.some((item) => item.item_id === result.item && item.item_title.startsWith('Pullboard relay smoke ')),
'the real CLI move remains in the local board after relay off');