A full-featured CRM built with React, shadcn/ui, and Supabase.
Fix force-foreground x duplicate-dispatch interaction that wedged planning
Jerome61de8257257a
diff --git a/.claude/hooks/block-duplicate-dispatch.mjs b/.claude/hooks/block-duplicate-dispatch.mjsindex 89f6c392..f0830c83 100755--- a/.claude/hooks/block-duplicate-dispatch.mjs+++ b/.claude/hooks/block-duplicate-dispatch.mjs@@ -49,6 +49,26 @@ try {const sha = (s) => createHash("sha1").update(s).digest("hex").slice(0, 16);+// A pipeline dispatch WITHOUT an explicit run_in_background:false will be DENIED by+// force-foreground-orchestrator-dispatch and re-issued with false. Do NOT record or+// check a marker for it here: otherwise the denied attempt's marker would reject the+// corrective retry as a "duplicate" (a regression from force-foreground's deny-and-retry,+// caught by fresh-session run 8468cc06 - the planner never ran yet its marker blocked the+// retry for 60 min). Only debounce dispatches that will actually proceed (rib === false).+const PIPELINE_ROLES = new Set([+ "developer",+ "quality-reviewer",+ "merger",+ "planner",+ "simple-developer",+]);+const childRole = PIPELINE_ROLES.has(d.subagentType)+ ? d.subagentType+ : PIPELINE_ROLES.has(d.role)+ ? d.role+ : "";+if (childRole && input.tool_input?.run_in_background !== false) process.exit(0);+// ---- Concern 1: at most one planner per request -------------------------------if (d.subagentType === "planner") {// The STATE A planner template writes `TICKETS_DIR=<path>` (equals);diff --git a/.claude/hooks/test/block-duplicate-dispatch.test.mjs b/.claude/hooks/test/block-duplicate-dispatch.test.mjsindex 6bf4013f..1ce9c510 100644--- a/.claude/hooks/test/block-duplicate-dispatch.test.mjs+++ b/.claude/hooks/test/block-duplicate-dispatch.test.mjs@@ -31,12 +31,27 @@ let breakerDir;let env;// Returns { blocked: boolean } — blocked when the decisionBlock JSON is printed.-const run = (prompt, subagentType, agentId = CALLER) => {+// runInBackground defaults to false: in the real harness (post force-foreground)+// every pipeline dispatch carries run_in_background:false, and block-duplicate only+// debounces those. Pass `undefined` to simulate the malformed (absent) dispatch that+// force-foreground denies — block-duplicate must skip it (no marker).+const run = (+ prompt,+ subagentType,+ agentId = CALLER,+ runInBackground = false,+) => {+ const tool_input = { subagent_type: subagentType, prompt };+ // Pass the sentinel "absent" to OMIT the field (a default param can't express this:+ // passing `undefined` still triggers the default). "absent" simulates the malformed+ // dispatch force-foreground denies.+ if (runInBackground !== "absent")+ tool_input.run_in_background = runInBackground;const r = spawnSync("node", [HOOK], {input: JSON.stringify({session_id: SESSION_ID,agent_id: agentId,- tool_input: { subagent_type: subagentType, prompt },+ tool_input,}),env,encoding: "utf8",@@ -149,3 +164,17 @@ describe("block-duplicate-dispatch — pass-through", () => {expect(r.blocked).toBe(false);});});++describe("block-duplicate-dispatch — force-foreground retry (regression 8468cc06)", () => {+ // A pipeline dispatch without run_in_background:false is DENIED by+ // force-foreground-orchestrator-dispatch and re-issued. block-duplicate must NOT+ // record a marker for the denied attempt, or the corrective retry would be wrongly+ // rejected as a duplicate (this wedged planning for 60 min in a real run).+ test("a rib-absent pipeline dispatch is skipped, so the rib:false retry is not a duplicate", () => {+ const p = `TICKETS_DIR=${join(TMP, "tickets-ff")}`;+ const FF = "ff-orch"; // unique caller: no marker collision with earlier tests+ expect(run(p, "planner", FF, "absent").blocked).toBe(false); // denied form -> skipped, no marker+ expect(run(p, "planner", FF, false).blocked).toBe(false); // the retry proceeds+ expect(run(p, "planner", FF, false).blocked).toBe(true); // a genuine 2nd planner is still blocked+ });+});