Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

fix(harness): resolve review-verdict flag dir on a managed launcher

Jerome98fec10ad9bc
diff --git a/.claude/hooks/lib/reviews.mjs b/.claude/hooks/lib/reviews.mjs
index d37b4a9e..35405198 100644
--- a/.claude/hooks/lib/reviews.mjs
+++ b/.claude/hooks/lib/reviews.mjs
@@ -8,12 +8,24 @@
// (PreToolUse/Agent), cleared on REJECTED and when a developer is (re)dispatched
// (setup-worktree.mjs) so a changed diff invalidates stale approvals. Session-scoped
// under <sessionDir>/reviews, mirroring the <sessionDir>/flags convention.
+//
+// Path source: the quality-reviewer agent (PRIMARY writer) derives the flag dir
+// from its ticket file — `$(dirname TICKET_FILE)/reviews` — i.e. under the
+// `<session_dir>` it was handed (TICKETS_DIR == <session_dir>, see orchestrator.md).
+// On a managed launcher (CRM Builder's chat-service) that `<session_dir>` is
+// `CHAT_SESSION_DIR`, which is NOT the `/tmp/<repo>/<id>` path ctx.sessionDir
+// recomputes — so the reader/clearer/fallback below must key off CHAT_SESSION_DIR
+// when present, or they look in the wrong dir and the synchronous verdict is lost
+// (block-merger then blocks on a phantom "no APPROVED"). With no managed launcher,
+// CHAT_SESSION_DIR is unset and ctx.sessionDir already equals <session_dir> (the
+// session-bootstrap hook injects exactly that), so this is a no-op there.
import { join } from "node:path";
export const REVIEW_ROLES = ["quality-reviewer"];
-export const reviewsDir = (ctx) => join(ctx.sessionDir, "reviews");
+export const reviewsDir = (ctx) =>
+ join(process.env.CHAT_SESSION_DIR || ctx.sessionDir, "reviews");
export const reviewFlag = (ctx, taskId, role) =>
join(reviewsDir(ctx), `${taskId}-${role}`);