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:
2026-11-20 03:47:41 +01:00
parent 3ba309c5e4
commit 0400d7bbe7
4 changed files with 70 additions and 6 deletions
+42 -3
View File
@@ -1,15 +1,54 @@
// The tools of the forge module's merge calls (novox/hq design 47 H §766, §767): forge_partial_clear clears a call's
// merge-partial by hand, written in the hand-act log before it is done.
// The tools of the forge module's merge calls (novox/hq design 47 H §766, §767): forge_calls reads the calls, newest first,
// with each member's state; forge_call_say_again says a call's merge-called again; forge_partial_clear clears a call's
// merge-partial by hand. Each act is written in the hand-act log before it is done.
import type { ToolDefinition } from "@novox/mesh-sdk/tools";
import { callerOf } from "@novox/mesh-sdk/callers";
import type { HandAct } from "@novox/mesh-sdk/views";
import type { Partials } from "../partials.js";
import { sayCall, type Calls, type Say } from "../calls.js";
const word = (v: unknown): string => (typeof v === "string" ? v.trim() : "");
export function callTools(partials: Partials, acts: (act: HandAct) => Promise<void>): ToolDefinition[] {
export function callTools(calls: Calls, partials: Partials, say: Say, acts: (act: HandAct) => Promise<void>): ToolDefinition[] {
return [
{
name: "forge_calls",
description: "The merge calls the forge module keeps (its state calls), newest first: each call's by, account, when, whether its merge-called " +
"was said, and each member with its base, head and state (judged, merged with its commit, or refused with why) (design 47 H §766).",
input: { type: "object", properties: { call: { type: "string", description: "only this merge call" } } },
run: async (args: Record<string, unknown>) => {
const only = word(args.call);
const all = await calls.all();
return { calls: only ? all.filter((c) => c.call === only) : all };
},
},
{
name: "forge_call_say_again",
description: "Says one merge call's merge-called again, for what it landed, with why: a gate that missed it takes the call in. " +
"Written in the hand-act log first (design 47 H §766).",
input: { type: "object", required: ["call", "why"], properties: {
call: { type: "string", description: "the merge call, 16 lowercase hex characters" },
why: { type: "string", description: "why it is said again, in plain words" } } },
run: async (args: Record<string, unknown>) => {
const call = word(args.call), why = word(args.why);
if (!/^[0-9a-f]{16}$/.test(call) || !why) throw new Error("forge_call_say_again names the call (16 lowercase hex characters) and why");
const kept = await calls.get(call);
if (!kept) throw new Error(`the forge module keeps no merge call ${call}`);
const by = callerOf(args);
try {
await acts({ what: `said the merge-called of the merge call ${call} again`, why: `${why} (${by})`, cause: "merge-called-said-again", verb: "forge_call_say_again" });
} catch (err) {
throw new Error(`the hand act was not recorded, so nothing was said: ${err instanceof Error ? err.message : String(err)}`);
}
const said = await sayCall(kept, say);
if (said && !kept.said) {
const { call: _c, ...value } = kept;
await calls.put(call, { ...value, said: true });
}
return { call, said, why, by, ...(said ? {} : { "said-none": "the call landed no member, so it says no merge-called" }) };
},
},
{
name: "forge_partial_clear",
description: "Clears the finding merge-partial of one merge call (a call the forge refused a member of after every member was judged), " +