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
2.5 KiB
JavaScript
60 lines
2.5 KiB
JavaScript
// Row 141 (#1635, REQ-MSG-2): `mosaic name` and `mosaic names`, through the in-process broker from
|
|
// helpers.mjs. The broker's own checks are in packages/bus/tests/names.test.mjs.
|
|
|
|
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { main, USAGE } from "../src/cli.mjs";
|
|
import { CliError } from "../src/errors.mjs";
|
|
import { broker, io, tmp } from "./helpers.mjs";
|
|
|
|
function setup(t) {
|
|
const bus = broker(t);
|
|
const dataRoot = tmp(t);
|
|
const run = async (argv, x = io()) => {
|
|
try {
|
|
await main(argv, x, { system: { dataRoot }, transport: bus.transport });
|
|
return { code: 0, io: x };
|
|
} catch (e) {
|
|
if (!(e instanceof CliError)) throw e;
|
|
return { code: e.exitCode, error: e.message, io: x };
|
|
}
|
|
};
|
|
return { ...bus, run };
|
|
}
|
|
|
|
test("the human names an instance, lists it, and talk's message.send reaches it by that name", async (t) => {
|
|
const s = setup(t);
|
|
const named = await s.run(["name", "coder", "rex", "--business", "demo"]);
|
|
assert.equal(named.code, 0, named.error);
|
|
assert.equal(named.io.out.text, "named coder rex\n");
|
|
assert.deepEqual(s.calls.at(-1), { business: "demo", verb: "name.set", args: { instance: "coder", name: "rex" } });
|
|
|
|
const listed = await s.run(["names", "--business", "demo"]);
|
|
assert.equal(listed.code, 0, listed.error);
|
|
assert.equal(listed.io.out.text, "coder rex\n");
|
|
const json = await s.run(["names", "--json", "--business", "demo"]);
|
|
assert.deepEqual(
|
|
JSON.parse(json.io.out.text).map(({ instance, name }) => ({ instance, name })),
|
|
[{ instance: "coder", name: "rex" }],
|
|
);
|
|
|
|
const sent = await s.run(["talk", "rex", "hello", "--wait", "0", "--business", "demo"]);
|
|
assert.equal(sent.code, 0, sent.error);
|
|
assert.match(sent.io.out.text, /^sent [0-9a-f]{8} to rex\n/);
|
|
const [m] = s.b.request(s.coder, { verb: "message.receive" });
|
|
assert.equal(m.to_role, "coder");
|
|
assert.equal(m.to_name, "rex");
|
|
});
|
|
|
|
test("name and names refuse the wrong number of arguments with the usage", async (t) => {
|
|
const s = setup(t);
|
|
for (const argv of [["name", "coder"], ["name", "coder", "rex", "extra"], ["names", "coder"]]) {
|
|
const r = await s.run([...argv, "--business", "demo"]);
|
|
assert.equal(r.code, 4, argv.join(" "));
|
|
assert.ok(r.error.endsWith(USAGE), r.error);
|
|
}
|
|
assert.equal(s.calls.length, 0);
|
|
assert.match(USAGE, /^ {2}mosaic name <instance> <name> \[--business <id>\]$/m);
|
|
assert.match(USAGE, /^ {2}mosaic names \[--business <id>\] \[--json\]$/m);
|
|
});
|