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(registry): guards and outbox slots [P3,M1,H16]

Corey Olson0f5b805a078b
diff --git a/src/relay-outbox.js b/src/relay-outbox.js
index 96eccee0..63ea3ffc 100644
--- a/src/relay-outbox.js
+++ b/src/relay-outbox.js
@@ -149,7 +149,7 @@ export function refusalLine(kept) {
}
/** The ordered operations whose first argument is an item number; a decision's answer names a shout instead. */
-const FIRST_ITEM = ['editItem', 'completeCheckBaseline', 'escalate', 'recordAttempt', 'claim', 'release', 'submit', 'reserveReview', 'verify',
+const FIRST_ITEM = ['approveOutside', 'signBar', 'editItem', 'completeCheckBaseline', 'escalate', 'recordAttempt', 'claim', 'release', 'submit', 'reserveReview', 'verify',
'merged', 'withdraw', 'refreeze', 'reopen', 'holdItem', 'releaseItemHold', 'appendFact', 'acceptCheck'];
/**
@@ -158,6 +158,8 @@ const FIRST_ITEM = ['editItem', 'completeCheckBaseline', 'escalate', 'recordAtte
* (test/relay-outbox.test.js walks them all) (#922).
*/
export const ITEM_SLOTS = Object.freeze({
+ setBarReady: [], setLineSetting: [],
+ recordPublishFinding: [[0, 'item']],
register: [], ensureCoordinator: [], shout: [], passDecision: [], holdLane: [], releaseLane: [],
moveMilestone: [], editMilestone: [], removeMilestone: [], shipMilestone: [],
recordRowDecisions: [], applyRowDecisions: [], draftSpecRow: [], recordSpecApprovalBaseline: [],
@@ -165,6 +167,7 @@ export const ITEM_SLOTS = Object.freeze({
recordHealthFindings: [], decideSentinel: [], beginSentinelRun: [], finishSentinelRun: [],
recordFlakeObservation: [], recordGateRun: [], declareJob: [], recordJobRun: [], takeCoordinator: [], landingLeaseMove: [],
...Object.fromEntries(FIRST_ITEM.map((operation) => [operation, [[0]]])),
+ intakeOutside: [[0, 'item', 'parentId'], [0, 'item', 'after', '*']],
addItem: [[0, 'parentId'], [0, 'after', '*']],
editItem: [[0], [1, 'after', '*']],
verify: [[0], [1, 'implies', '*']],
diff --git a/test/machine.test.js b/test/machine.test.js
index 11de8077..a120b4ac 100644
--- a/test/machine.test.js
+++ b/test/machine.test.js
@@ -8,7 +8,7 @@ import { submitFixture } from './board-submit-fixture.js';
import assert from 'node:assert/strict';
import { mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
-import { join } from 'node:path';
+import { dirname, join } from 'node:path';
import { pathToFileURL } from 'node:url';
import { DatabaseSync } from 'node:sqlite';
import { test } from 'node:test';
@@ -1405,8 +1405,9 @@ test('the board refuses a status written outside moveItem at run time, however i
test('a helper added to the board that changes a status outside moveItem is refused when it runs [M1]', async () => {
const dir = mkdtempSync(join(tmpdir(), 'pullboard-planted-'));
try {
- for (const file of readdirSync(new URL('../src/', import.meta.url)).filter((name) => name.endsWith('.js'))) {
+ for (const file of readdirSync(new URL('../src/', import.meta.url), { recursive: true }).filter((name) => name.endsWith('.js'))) {
const source = fromDisk(file);
+ mkdirSync(dirname(join(dir, file)), { recursive: true });
writeFileSync(join(dir, file), file === 'board.js' ? `${source}\nexport function reopenByHand(board, id) {\n board.db.prepare("update item set item_status = 'open', item_owner = null, item_lease_until = null where item_id = ?").run(id);\n}\n` : source);
}
const copy = await import(pathToFileURL(join(dir, 'board.js')).href);
diff --git a/test/package.test.js b/test/package.test.js
index 1e234ed8..dda6ce68 100644
--- a/test/package.test.js
+++ b/test/package.test.js
@@ -202,12 +202,31 @@ test('the import scan finds a package however it is imported, and nothing that i
Object.entries(forms).forEach(([source, expected], index) => assert.deepEqual(set(found[index]), set(expected), source));
});
+/**
+ * The two source-directory loaders import only a discovered file beneath their declared local URL.
+ * Normalize that exact relative discovery expression, not arbitrary computed imports; recursively
+ * scanning their leaves below keeps a package import in any discovered module visible to P3.
+ */
+function packageSource(file, source) {
+ const loaders = {
+ [join(ROOT, 'src', 'move-registry.js')]: ["import(new URL(file, directory).href)", "import('./moves/')"],
+ [join(ROOT, 'src', 'commands', 'index.js')]: ["import(new URL(file, FOLDER).href)", "import('./')"],
+ };
+ const loader = loaders[file];
+ return loader ? source.replace(loader[0], loader[1]) : source;
+}
+
+/** Parse one edited source control using exactly the package discovery policy. */
+function importsForPackageFile(file, source) { return importsIn([packageSource(file, source)])[0]; }
+
test('every import is a node: built-in or a relative file [P3]', () => {
const files = [
- ...readdirSync(join(ROOT, 'src')).filter((name) => /\.m?js$/.test(name)).map((name) => join(ROOT, 'src', name)),
+ ...readdirSync(join(ROOT, 'src'), { recursive: true }).filter((name) => /\.m?js$/.test(name)).map((name) => join(ROOT, 'src', name)),
join(ROOT, 'bin', 'pullboard.js'),
];
- const found = importsIn(files.map((file) => readFileSync(file, 'utf8')));
+ const moveFiles = readdirSync(join(ROOT, 'src', 'moves')).filter(name => name.endsWith('.js'));
+ assert.ok(moveFiles.length > 0 && moveFiles.every(name => files.includes(join(ROOT, 'src', 'moves', name))), 'all discovered move modules remain inside the no-dependencies scan');
+ const found = importsIn(files.map(file => packageSource(file, readFileSync(file, 'utf8'))));
files.forEach((file, index) => {
for (const target of found[index]) assert.ok(target.startsWith('node:') || target.startsWith('.'), `${file} imports ${target}`);
});
@@ -215,6 +234,17 @@ test('every import is a node: built-in or a relative file [P3]', () => {
assert.ok(seen > 50, `the scan found ${seen} imports in src/ and bin/; expected every file's`);
});
+test('discovery import normalization still exposes package imports and arbitrary computed targets [P3]', () => {
+ const file = join(ROOT, 'src', 'move-registry.js');
+ const source = readFileSync(file, 'utf8');
+ const site = 'import(new URL(file, directory).href)';
+ assert.ok(source.includes(site), 'the constrained discovery site is present');
+ assert.ok(importsForPackageFile(file, source.replace(site, "import('left-pad')")).includes('left-pad'));
+ assert.ok(importsForPackageFile(file, source.replace(site, 'import(otherTarget)')).includes(COMPUTED));
+ assert.ok(importsForPackageFile(file, source + '\nvoid import(otherTarget);').includes(COMPUTED), 'a second computed import has no exemption');
+ assert.ok(importsForPackageFile(join(ROOT, 'src', 'moves', 'seed.js'), 'void import(otherTarget);').includes(COMPUTED), 'move leaves have no computed-import exemption');
+});
+
test('the installable package includes the single inherited doctrine file [D1]', () => {
const packed = spawnSync('npm', ['pack', '--dry-run', '--json', '--ignore-scripts'], { cwd: ROOT, encoding: 'utf8' });
assert.equal(packed.status, 0, packed.stderr);