FORGE-4: a member the forge refuses after judging raises merge-partial

The call stops merging, says merge-called with what landed and refused,
and raises merge-partial (scope delivery, id the call, urgent, resolver
operator) in the module's findings; a later call landing every refused
member clears it, and forge_partial_clear clears one by hand after the
hand-act log took it.

Builds: design 47 H §767; H-A-1, H-A-18, H-A-81

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
2026-11-20 03:46:59 +01:00
parent 7f5f285b60
commit 3ba309c5e4
8 changed files with 207 additions and 12 deletions
+1 -11
View File
@@ -1,5 +1,6 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { memory } from "./memstate.ts";
// **The call is written before its first merge** (novox/hq design 47 H §766; H-A-18, H-A-47, H-A-71): the key
// call.<call> of the state calls holds by, the proved account, at, each member with its base and its state (judged before
@@ -8,17 +9,6 @@ import { test } from "node:test";
const A = "a".repeat(40), B = "b".repeat(40);
export function memory() {
const kv = new Map<string, unknown>();
return { kv, st: {
get: async (k: string) => (kv.has(k) ? { key: k, value: structuredClone(kv.get(k)), revision: 1 } : null),
put: async (k: string, v: unknown) => { kv.set(k, structuredClone(v)); return 1; },
delete: async (k: string) => { kv.delete(k); },
keys: async () => [...kv.keys()].sort(),
watch: async () => {},
} };
}
test("a merge call is kept before its first merge, each member judged, then merged with its commit", async () => {
const { mergeCall } = await import("../dist/mergecall.js");
const { Calls } = await import("../dist/calls.js");
+11
View File
@@ -0,0 +1,11 @@
// A state of the runtime in memory, for the tests of the merge calls (calls.ts, partials.ts).
export function memory() {
const kv = new Map<string, unknown>();
return { kv, st: {
get: async (k: string) => (kv.has(k) ? { key: k, value: structuredClone(kv.get(k)), revision: 1 } : null),
put: async (k: string, v: unknown) => { kv.set(k, structuredClone(v)); return 1; },
delete: async (k: string) => { kv.delete(k); },
keys: async () => [...kv.keys()].sort(),
watch: async () => {},
} };
}
+67
View File
@@ -0,0 +1,67 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { memory } from "./memstate.ts";
// **A member refused after every member was judged is said and raised** (novox/hq design 47 H §767; acceptance test 115;
// H-A-81): a forge that refuses the second merge gives one merge-called with the first member and `refused`, and
// merge-partial (scope delivery, id the call, urgent, resolver operator) raised; a later call landing the refused member
// clears it, and forge_partial_clear clears one by hand after the hand-act log took it.
const A = "a".repeat(40), B = "b".repeat(40);
test("the forge refusing the second merge says what landed, raises merge-partial, and a later call landing it clears it", async () => {
const { mergeCall } = await import("../dist/mergecall.js");
const { Calls } = await import("../dist/calls.js");
const { Partials, partialKey } = await import("../dist/partials.js");
const { callTools } = await import("../dist/tools/calls.js");
const { runAs } = await import("@novox/mesh-sdk/callers");
const { st } = memory();
const findings = memory();
const calls = new Calls(st as any);
const partials = new Partials(findings.st as any, calls);
const said: any[] = [];
const pulls: Record<number, any> = { 5: { head: A, merged: false, refuse: false }, 9: { head: B, merged: false, refuse: true } };
const forge = {
getPullRequest: async (_o: string, _r: string, n: number) => ({ number: n, state: "open", merged: pulls[n].merged, base: "main",
head_sha: pulls[n].head, ...(pulls[n].merged ? { merge_commit_sha: String(n).repeat(40) } : {}) }),
mergePullRequest: async (_o: string, r: string, n: number) => {
if (pulls[n].refuse) throw new Error(`Gitea API POST /repos/novox/${r}/pulls/${n}/merge: 409 merge conflict`);
pulls[n].merged = true;
},
commitParents: async () => [],
};
let clock = Date.parse("2026-11-20T03:00:00Z");
const run = (call: string, numbers: number[]) => {
const args = { by: "lead@shanks", pulls: numbers.map((n) => ({ repository: n === 5 ? "novox/app" : "novox/lib", number: n, head: pulls[n].head })) };
return runAs({ "mesh/caller": "shanks.claude-code" }, args, () => mergeCall(forge as any, args, { registered: () => true,
watched: () => new Map([["novox/app", new Set(["main"])], ["novox/lib", new Set(["main"])]]), judge: async () => null,
newCall: () => call, calls, partials, say: async (_s: string, body: unknown) => { said.push(body); },
now: () => new Date((clock += 1000)) } as any)) as Promise<any>;
};
const got = await run("00000000000000aa", [5, 9]);
assert.deepEqual(got.members.map((m: any) => m.state), ["merged", "refused"]);
assert.equal(said.length, 1);
assert.deepEqual(said[0].members.map((m: any) => m.number), [5]);
assert.deepEqual(said[0].refused.map((m: any) => [m.repository, m.number]), [["novox/lib", 9]]);
assert.match(said[0].refused[0].why, /merge conflict/);
const raised: any = findings.kv.get(partialKey("00000000000000aa"));
assert.deepEqual([raised?.kind, raised?.subject, raised?.severity, raised?.resolver], ["merge-partial", { scope: "delivery", id: "00000000000000aa" }, "urgent", "operator"]);
assert.match(raised.summary, /landed novox\/app#5 and not novox\/lib#9/);
// A later call landing the refused member clears it.
pulls[9].refuse = false;
await run("00000000000000bb", [9]);
assert.equal(findings.kv.has(partialKey("00000000000000aa")), false, "cleared by the later call");
// By hand: written in the hand-act log first, then cleared.
pulls[9] = { head: B, merged: false, refuse: true };
pulls[5] = { head: A, merged: false, refuse: false };
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")!;
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")!;
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" }));
assert.deepEqual([done.cleared, acts[0].verb, findings.kv.has(partialKey("00000000000000cc"))], [true, "forge_partial_clear", false]);
});