Three-reviewer architecture audit (DEV-A: core, DEV-B: cli/server/wasm, DEV-C: extension/relay) plus PM synthesis. Lens: make the codebase readable for a smart developer who doesn't know Rust but wants to learn by tinkering. Top synthesis findings (P1): - SessionHandle has no impl Drop; .free() is a cleanup no-op (cross-cutting Rust+JS) - cli/main.rs is a 2641-line monolith with no submodule boundaries - setup.ts (1220 LOC) bypasses the SW and orchestrates WASM directly - vault.ts (1027 LOC) owns shell + sidebar + list + drawer + routing - shared/state.ts is fully any-typed - recovery_qr.rs is undocumented vs. rest of crypto-adjacent core - duplicated SW router helpers (storage + itemToManifestEntry) - pure parsers (parse_month_year, base32_decode_lenient) belong in core - 16x duplicated git invocation boilerplate with one-line errors CLI/extension parity: 22/23 capabilities ✓; only true gap is `relicario status` (no get_vault_status); `detach` is partial via update_item. Also fixes tools/relay/queue.test.ts:54 to match the dev-c role expansion already in queue.ts (was failing 1/4; now 5/5 pass). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { describe, it, beforeEach } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { RelayQueue, isRole } from "./queue.ts";
|
|
|
|
describe("RelayQueue", () => {
|
|
let q: RelayQueue;
|
|
|
|
beforeEach(() => {
|
|
q = new RelayQueue();
|
|
});
|
|
|
|
it("post + read roundtrip returns the message with correct fields", () => {
|
|
q.post("dev-b", "pm", "status", "Task P4 DONE");
|
|
const msgs = q.read("pm");
|
|
assert.equal(msgs.length, 1);
|
|
assert.equal(msgs[0].from, "dev-b");
|
|
assert.equal(msgs[0].to, "pm");
|
|
assert.equal(msgs[0].kind, "status");
|
|
assert.equal(msgs[0].body, "Task P4 DONE");
|
|
assert.ok(typeof msgs[0].id === "string" && msgs[0].id.length > 0);
|
|
assert.ok(typeof msgs[0].ts === "string");
|
|
});
|
|
|
|
it("consume-once: second read returns empty", () => {
|
|
q.post("dev-a", "pm", "question", "Should I use approach A?");
|
|
q.read("pm");
|
|
const second = q.read("pm");
|
|
assert.deepEqual(second, []);
|
|
});
|
|
|
|
it("list_pending does not drain inbox", () => {
|
|
q.post("dev-b", "pm", "directive", "PROCEED");
|
|
const before = q.pending("pm");
|
|
assert.equal(before.count, 1);
|
|
const after = q.read("pm");
|
|
assert.equal(after.length, 1);
|
|
});
|
|
|
|
it("FIFO ordering across multiple senders", () => {
|
|
q.post("dev-a", "pm", "status", "first");
|
|
q.post("dev-b", "pm", "status", "second");
|
|
q.post("dev-a", "pm", "question", "third");
|
|
const msgs = q.read("pm");
|
|
assert.equal(msgs.length, 3);
|
|
assert.equal(msgs[0].body, "first");
|
|
assert.equal(msgs[1].body, "second");
|
|
assert.equal(msgs[2].body, "third");
|
|
});
|
|
|
|
it("isRole rejects unknown strings", () => {
|
|
assert.ok(isRole("pm"));
|
|
assert.ok(isRole("dev-a"));
|
|
assert.ok(isRole("dev-b"));
|
|
assert.ok(isRole("dev-c"));
|
|
assert.ok(!isRole("dev-d"));
|
|
assert.ok(!isRole(""));
|
|
assert.ok(!isRole("PM"));
|
|
});
|
|
});
|