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.

test(relay): preserve lifecycle and unlink checks [H16,M1,H7]

Corey Olson452019924794
diff --git a/test/machine.test.js b/test/machine.test.js
index ef8534dc..d1670693 100644
--- a/test/machine.test.js
+++ b/test/machine.test.js
@@ -28,6 +28,7 @@ const NOT_MOVES = {
ONE_COORDINATOR: 'registering who is asking, before any move',
BAD_MACHINE_SETTINGS: 'machine-wide settings checked before a command runs',
BAD_GATE_SLOTS: 'machine-wide gate capacity checked before a command runs',
+ NO_AGENT: 'a linked coordinator must already be registered before an item move',
EVENT_LOG_VERSION: 'the local board format is checked before opening it for an item move',
};
@@ -55,6 +56,12 @@ const CALLBACKS = { 'board.js': { freeze: 'cli.js#freezer' } };
*/
const CAUGHT = { 'cli.js#submitHere': ['cli.js#freezer'], 'cli.js#verifyHere': ['cli.js#freezer'] };
+/**
+ * Encrypted transport authenticates/orders a move; its board operation is walked separately above.
+ * Keep walking the CLI dispatcher itself so a new item rule there cannot hide behind this boundary.
+ */
+const TRANSPORT_BOUNDARIES = new Set(['relay.js#relayLinked', 'relay.js#relayOperation']);
+
/** A top-level function, or a top-level arrow function bound to a const. */
const START = /^(?:export )?(?:(?:async )?function (\w+)\(|const (\w+) = (?:async )?(?:\([^)]*\)|\w+) =>)/;
@@ -113,7 +120,7 @@ function codeWalk(read) {
return files.get(file);
};
const refusalsOf = (key, skip = new Set(), seen = new Set()) => {
- if (seen.has(key) || skip.has(key)) return new Set();
+ if (seen.has(key) || skip.has(key) || TRANSPORT_BOUNDARIES.has(key)) return new Set();
seen.add(key);
const [file, name] = key.split('#');
const { bodies, named, spaces } = load(file);
@@ -1245,3 +1252,13 @@ test('a helper added to the board that changes a status outside moveItem is refu
rmSync(dir, { recursive: true, force: true });
}
});
+
+
+test('transport boundaries keep a new item refusal in ordered dispatch visible [M1,M4,H16]', () => {
+ const inDispatch = editedSource('cli.js', /^async function ordered\(ctx, board, operation, args\) \{$/m,
+ "$&\n if (args[0] === 999) throw new Refused('MOON_PHASE', 'wait for the full moon');");
+ assert.deepEqual(codeProblems(MACHINE, inDispatch).sort(), [
+ 'MOON_PHASE is raised by accept and reject but not declared there',
+ 'MOON_PHASE is raised by submit but not declared there',
+ ], 'transport authentication is separate but a dispatcher item guard still belongs to the lifecycle');
+});
diff --git a/test/relay.test.js b/test/relay.test.js
index bebba1da..476d0a7a 100644
--- a/test/relay.test.js
+++ b/test/relay.test.js
@@ -352,6 +352,7 @@ test('relay off forgets expired and independently unlinked boards while preservi
for (const cause of ['expired', 'other-client']) await t.test(cause, async (t) => {
const box = await relayClientFixture(t);
await box.link();
+ const localBeforeDeletion = (await box.cli('export')).document.tables;
if (cause === 'expired') box.advance(90);
else assert.equal(await box.otherDeviceOff(), 0, 'a second real CLI device unlinks the shared board');
const off = await box.cli('relay', 'off');
@@ -361,7 +362,7 @@ test('relay off forgets expired and independently unlinked boards while preservi
assert.match(off.document.notice, /already deleted/);
assert.equal(existsSync(box.linkFile), false, 'local link metadata is forgotten');
assert.equal(existsSync(box.keyFile), false, 'device-only fallback key is forgotten');
- assert.deepEqual((await box.cli('export')).document.tables, box.before.tables, 'local board is complete after remote deletion');
+ assert.deepEqual((await box.cli('export')).document.tables, localBeforeDeletion, 'local board is complete after remote deletion');
const count = box.calls.length;
assert.equal((await box.cli('relay', 'off')).code, 0);
assert.equal((await box.cli('status')).code, 0);