FORGE-5: forge_calls reads the merge calls; forge_call_say_again says one again
forge_calls answers the kept calls newest first with each member's base, head and state; forge_call_say_again, with call and why, says a call's merge-called again once the hand-act log took it. Builds: design 47 H §766 (its tools); H-A-18 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
@@ -92,3 +92,28 @@ test("a call says one merge-called of what landed; none for a call that landed n
|
||||
assert.equal(said[0].body.refused, undefined, "a member not merged after a stop is no refused member");
|
||||
assert.deepEqual(await sayUnsaid(calls, say), [], "said once");
|
||||
});
|
||||
|
||||
// The merge calls' tools (design 47 H §766): forge_calls answers the calls newest first with each member's state, and
|
||||
// forge_call_say_again says a call's merge-called again once the hand-act log took it.
|
||||
test("forge_calls reads the calls newest first; forge_call_say_again says one again after the hand-act log", async () => {
|
||||
const { Calls } = await import("../dist/calls.js");
|
||||
const { Partials } = await import("../dist/partials.js");
|
||||
const { callTools } = await import("../dist/tools/calls.js");
|
||||
const { st } = memory();
|
||||
const calls = new Calls(st as any);
|
||||
const m = (n: number, state: string) => ({ repository: "novox/app", number: n, branch: "main", head: A, state, ...(state === "merged" ? { commit: String(n).repeat(40) } : {}) });
|
||||
await calls.put("00000000000000aa", { by: "a@b", account: "x", at: "2026-11-20T01:00:00Z", members: [m(1, "merged")], said: true } as any);
|
||||
await calls.put("00000000000000bb", { by: "a@b", account: "x", at: "2026-11-20T02:00:00Z", members: [m(2, "refused")], said: true } as any);
|
||||
const said: any[] = [], acts: any[] = [];
|
||||
const tools = callTools(calls, new Partials(memory().st as any, calls), async (subject: string, body: unknown) => { said.push([subject, body]); },
|
||||
async (a) => { acts.push(a); });
|
||||
const tool = (name: string) => tools.find((t) => t.name === name)!;
|
||||
const read: any = await tool("forge_calls").run({});
|
||||
assert.deepEqual(read.calls.map((c: any) => [c.call, c.members[0].state]), [["00000000000000bb", "refused"], ["00000000000000aa", "merged"]]);
|
||||
await assert.rejects(tool("forge_call_say_again").run({ call: "00000000000000aa" }), /names the call .* and why/);
|
||||
await assert.rejects(tool("forge_call_say_again").run({ call: "00000000000000ff", why: "x" }), /keeps no merge call/);
|
||||
const again: any = await tool("forge_call_say_again").run({ call: "00000000000000aa", why: "the gate missed it" });
|
||||
assert.deepEqual([again.said, acts[0].verb, said[0][0]], [true, "forge_call_say_again", "mesh.seat.git.event.merge-called.00000000000000aa"]);
|
||||
const none: any = await tool("forge_call_say_again").run({ call: "00000000000000bb", why: "x" });
|
||||
assert.equal(none.said, false, "a call that landed none says none");
|
||||
});
|
||||
|
||||
@@ -57,9 +57,9 @@ test("the forge refusing the second merge says what landed, raises merge-partial
|
||||
await run("00000000000000cc", [5, 9]);
|
||||
assert.equal(findings.kv.has(partialKey("00000000000000cc")), true);
|
||||
const acts: any[] = [];
|
||||
const tool = callTools(partials, async (a) => { acts.push(a); }).find((t) => t.name === "forge_partial_clear")!;
|
||||
const tool = callTools(calls, partials, async () => {}, async (a) => { acts.push(a); }).find((t) => t.name === "forge_partial_clear")!;
|
||||
await assert.rejects(tool.run({ call: "00000000000000cc" }), /names the call .* and why/);
|
||||
const failing = callTools(partials, async () => { throw new Error("down"); }).find((t) => t.name === "forge_partial_clear")!;
|
||||
const failing = callTools(calls, partials, async () => {}, async () => { throw new Error("down"); }).find((t) => t.name === "forge_partial_clear")!;
|
||||
await assert.rejects(failing.run({ call: "00000000000000cc", why: "dropped" }), /not recorded, so nothing was cleared/);
|
||||
assert.equal(findings.kv.has(partialKey("00000000000000cc")), true);
|
||||
const done: any = await runAs({ "mesh/caller": "person.jochen" }, {}, () => tool.run({ call: "00000000000000cc", why: "the lib change is dropped" }));
|
||||
|
||||
Reference in New Issue
Block a user