Row 141 round 1, Darkwing's candidate (agents/darkwing/work/queue-141/, build.patch bb036c6d, manifest d474b330, 26 paths, base18aee8fa1), rebased without change by Sage onto7e40fb83bas round 2 (agents/sage/work/queue-141-r2/, build.patch 72b890d9, manifest cae29087). Row 148 moved two of the paths, packages/bus/README.md and packages/bus/src/broker.mjs; the interdiff touches only index and @@ lines. Filbert approved round 1 (comment 28841). Schema 3f->3g adds instance_names, an append-only log whose latest row per instance is its current name. message.send resolves a to that is not an instance key or a role through the names table, and records to_name. The new bus writer name.set and read names back the CLI verbs mosaic name INSTANCE NAME (human-only) and mosaic names [--json]. `instance.name` is routed under REQ-MSG-2 (1.5). It joins ACTIONS and ROUTED in the vocabulary and the broker, and roles/chief-of-staff.json grants it within-role, as row 139's brief asks of whichever of 139 and 141 lands second. The chief has no tool for it until row 155, so the chief's untypedActions and bundle untyped list are ["instance.name"] (harness tools.test.mjs:43, bundle.test.mjs:94). Follow-ups: Vikunja P19 tasks for TOOLS.md and acceptance 314 step 10 (Filbert, doc-only) and for refusing a new key or definition equal to a current name. Row 155's brief carries the return of untyped to []. Sage's landing gate ran on7e40fb83bplus the candidate: 25 steps, all rc 0 (15 packages, 10 script suites), 22:30:48Z to 22:35:15Z, network sage-r141_default removed. The commit sits on2a85b41da, which adds one docs/SESSIONS.md line that no test reads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
60 lines
3.5 KiB
JavaScript
60 lines
3.5 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { startBroker } from '../src/runtime.mjs';
|
|
import { Client } from '../src/client.mjs';
|
|
import { startTimeOf } from '../../seat/src/proc.mjs';
|
|
import { initProject } from '../../project/src/index.mjs';
|
|
import { fixture } from './spec-fixtures.mjs';
|
|
|
|
test('Broker keeps the existing sandbox client import closure: no new imports or lazy project import', () => {
|
|
const source = readFileSync(new URL('../src/broker.mjs', import.meta.url), 'utf8');
|
|
assert.deepEqual([...source.matchAll(/^import .*;$/gm)].map(m => m[0]), [
|
|
"import { randomUUID, randomBytes } from 'node:crypto';",
|
|
"import { loadRequirements } from '../../tasks/src/requirements.mjs';",
|
|
// Row 137 (#1631): land-work's checks, in RUNNER_FILES beside the broker. They import nothing.
|
|
"import { MERGE, LandingRefusal, readLanding } from './landing.mjs';",
|
|
// Row 141 (#1635): the business ID_PATTERN for instance names. The vocabulary is already in
|
|
// RUNNER_FILES and imports nothing.
|
|
"import { ID_PATTERN } from '../../business/src/vocabulary.mjs';",
|
|
]);
|
|
assert.doesNotMatch(source, /\bimport\s*\(/);
|
|
assert.doesNotMatch(readFileSync(new URL('../src/landing.mjs', import.meta.url), 'utf8'), /\bimport\b/);
|
|
assert.doesNotMatch(readFileSync(new URL('../../business/src/vocabulary.mjs', import.meta.url), 'utf8'), /\bimport\b/);
|
|
});
|
|
|
|
test('without a trusted project adapter all three async paths refuse project-not-configured', async t => {
|
|
const f = await fixture(t, { adapter: false });
|
|
for (const [verb, args] of [
|
|
['spec.read', { project: 'stack' }],
|
|
['record.write', { project: 'stack', path: 'docs/a.md', record: '# A' }],
|
|
['decision.raise', { project: 'stack', spec_path: 'spec/north-star.md', spec_commit: f.commit }],
|
|
]) await assert.rejects(f.call(f.coder, verb, args), { code: 'project-not-configured' });
|
|
assert.equal(f.store.get('SELECT count(*) n FROM decisions').n, 0);
|
|
});
|
|
|
|
test('real startBroker injects the project adapter for socket reads and bound-author record writes', async t => {
|
|
const root = mkdtempSync(join(tmpdir(), 'project-runtime-'));
|
|
let runtime;
|
|
t.after(async () => { await runtime?.close(); rmSync(root, { recursive: true, force: true }); });
|
|
const business = { id: 'demo', human: 'jason', projects: { stack: { root: join(root, 'code') } },
|
|
arbiters: { technical: 'coder', delivery: 'coder' }, roles: { coder: {
|
|
definition: 'coder', authority: { withinRole: ['record.write'], crossRole: [] },
|
|
} } };
|
|
const initialized = await initProject({ business, project: 'stack', dataRoot: root });
|
|
runtime = await startBroker({ dataRoot: root, businesses: { demo: business }, launches: [{
|
|
business: 'demo', role: 'coder', run: 'runtime-run', harness: 'pi',
|
|
pid: process.pid, startTime: startTimeOf(process.pid),
|
|
}] });
|
|
const client = new Client({ path: runtime.path, cap: runtime.launches[0].cap });
|
|
await client.call('role.claim');
|
|
const spec = await client.call('spec.read', { project: 'stack' });
|
|
assert.equal(spec.commit, initialized.commit);
|
|
assert.equal(spec.confirmed, true);
|
|
const record = await client.call('record.write', { project: 'stack', path: 'docs/runtime.md', record: '# Runtime\n' });
|
|
assert.match(record.commit, /^[0-9a-f]{40}$/);
|
|
assert.equal(readFileSync(join(initialized.repo, record.path), 'utf8'), '# Runtime\n');
|
|
});
|