A full-featured CRM built with React, shadcn/ui, and Supabase.
Chore: improve agents and efforts
erwanMarmelabef01e750b81f
diff --git a/.claude/agents/chat-orchestrator.md b/.claude/agents/chat-orchestrator.mdindex f7809965..fb42cb20 100644--- a/.claude/agents/chat-orchestrator.md+++ b/.claude/agents/chat-orchestrator.md@@ -598,25 +598,22 @@ If an `Agent` dispatch *call itself* errors (rather than the agent running), mar#### Stage 2 — REVIEW + bounded retry (concurrent reviews, looped)-For every ticket now in `REVIEW`, dispatch BOTH reviewers in the foreground. Batch-all reviewers for all review-ready tickets into ONE message so they run-concurrently (reviewers are read-only on separate worktrees). Substitute the real-ticket id `T` in the prompt — plus the concrete+For every ticket now in `REVIEW`, dispatch the single quality-reviewer in the+foreground. Batch the reviewer for all review-ready tickets into ONE message so+they run concurrently (reviewers are read-only on separate worktrees). Substitute+the real ticket id `T` in the prompt — plus the concrete`<TICKETS_DIR>` / `<WORKTREE_BASE>` values:```Agent({ subagent_type: "quality-reviewer",- description: "Quality review T",+ description: "Review T",prompt: "ROLE: quality-reviewer\nTASK_ID: T\nTICKET_FILE: <TICKETS_DIR>/T.json\nWORKTREE_PATH: <WORKTREE_BASE>/T" })-Agent({ subagent_type: "test-validator",- description: "Test validation T",- prompt: "ROLE: test-validator\nTASK_ID: T\nTICKET_FILE: <TICKETS_DIR>/T.json\nWORKTREE_PATH: <WORKTREE_BASE>/T" })```-When they return, store each verdict in `reviews.{quality|test}` and resolve every+When it returns, store the verdict in `reviews.quality` and resolve everyreviewed ticket:-- both `APPROVED` → `stage = MERGE`.-- at least one `REJECTED` (malformed reviewer output → treat as `REJECTED`) →+- `APPROVED` → `stage = MERGE`.+- `REJECTED` (malformed reviewer output → treat as `REJECTED`) →increment `retries`. If `retries ≤ MAX_RETRIES` (2): `stage = DEV`, clear`reviews`, and **re-develop** (below). If `retries > MAX_RETRIES`: `stage = FAILED`.@@ -626,7 +623,7 @@ reviewed ticket:fresh PreToolUse/Agent event; `setup-worktree` re-reads them and SKIPs harmlesslybecause the worktree already exists — dropping them yields `setup-worktree SKIPmissing identity`), PLUS a trailing line:-`RETRY_FEEDBACK=<for each REJECTED reviewer, prefix its verdict body with 'quality:' or 'test:' and include it verbatim; omit APPROVED reviewers; separate the two prefixed blocks with a blank line when both are present>`+`RETRY_FEEDBACK=<the reviewer's REJECTED verdict body, verbatim>`After re-developing a ticket, **re-review it** (run this stage again for thatticket). **Loop Stage 2 until every still-live ticket is `MERGE` or `FAILED`** —@@ -649,8 +646,8 @@ Agent({ subagent_type: "merger",Per result: `DONE: T commit=…` → `stage = DONE`; `FAILED: …` or malformed →`stage = FAILED`. (The `block-merger-without-review` hook still gates each merger-dispatch on both recorded `APPROVED` verdicts — the SubagentStop-`record-review-verdict` hook recorded them when the reviewers returned, exactly as+dispatch on the recorded quality-reviewer `APPROVED` verdict — the SubagentStop+`record-review-verdict` hook recorded it when the reviewer returned, exactly asbefore.)Emit a short status line only when crossing a milestone the user cares about (adiff --git a/.claude/agents/developer.md b/.claude/agents/developer.mdindex d37a04d5..8bfcf7b1 100644--- a/.claude/agents/developer.md+++ b/.claude/agents/developer.md@@ -64,7 +64,7 @@ The orchestrator parses this line by regex. Any other format is treated as `FAILIf your spawn prompt contains a `RETRY_FEEDBACK=...` block, you are on a retry attempt. The worktree already exists with your previous commits on the branch — do NOT re-create it, do NOT re-init the branch.-1. Read the bullets in `RETRY_FEEDBACK` carefully. They come from `quality-reviewer` and/or `test-validator` and describe issues with your previous attempt.+1. Read the bullets in `RETRY_FEEDBACK` carefully. They come from the `quality-reviewer` and describe issues with your previous attempt.2. Apply targeted fixes only for the listed issues. Do not refactor unrelated code.3. Commit your fixes. The SubagentStop validation chain (typecheck + prettier + unit + e2e) runs automatically when you stop — failures come back to you as stderr and you fix and re-stop until it passes, exactly as for a fresh attempt.4. Emit the OUTPUT CONTRACT line with the new HEAD commit sha.diff --git a/.claude/agents/documentator.md b/.claude/agents/documentator.mdindex 175708cd..ffe37d68 100644--- a/.claude/agents/documentator.md+++ b/.claude/agents/documentator.md@@ -1,7 +1,7 @@---name: documentatordescription: Two modes. Mode 1 — captures recurring patterns into runtime artifacts under /home/developer/.claude/local/, indexed in the patterns ledger. Mode 2 — at COMPLEX session end, appends business-knowledge bullets to $CLAUDE_PROJECT_DIR/MEMORY.md. Always orchestrator-triggered.-model: sonnet+model: haikutools: [Read, Write, Edit, Glob, Grep, Bash]skills: []---diff --git a/.claude/agents/planner.md b/.claude/agents/planner.mdindex e09d2626..b85f62a7 100644--- a/.claude/agents/planner.md+++ b/.claude/agents/planner.md@@ -2,6 +2,7 @@name: plannerdescription: Product task planner. Use at the start of any new feature or project need (COMPLEX path) and at the end of FULL_SETUP (SETUP_MODE=true). Decomposes natural-language product needs into atomic, ordered, actionable tickets with best-guess file paths.model: sonnet+effort: xhightools:- Write- Edit@@ -224,6 +225,23 @@ The correct phrasing for the same intent is *schema-file* based:If you catch yourself writing "migration" anywhere in an AC, delete the line andrewrite it against `supabase/schemas/`.+### Mandatory acceptance criteria — convention-implied, ALWAYS WRITE THESE++Some conventions are reviewer-blocking but easy to leave implicit. Write these+standard ACs in every relevant ticket so the developer ships them in the first+pass and reviewers check the same line:++- Ticket touches UI / filter / form / interaction → add:+ *"An e2e spec in `e2e/` covers <the main user-visible behavior>"*+- Ticket introduces new user-facing labels/strings → add:+ *"New labels have i18n keys in both `englishCrmMessages.ts` and `frenchCrmMessages.ts`"*+- Ticket touches `supabase/schemas/01_tables.sql` → add:+ *"The new column is exposed in the matching `03_views.sql` view"*++Make each criterion specific and testable — one line the developer marks `[PASS]`+against the diff and a reviewer checks independently. These are implied by project+conventions, not invented criteria.+---## Constraintsdiff --git a/.claude/agents/quality-reviewer.md b/.claude/agents/quality-reviewer.mdindex ca475daf..7b628381 100644--- a/.claude/agents/quality-reviewer.md+++ b/.claude/agents/quality-reviewer.md@@ -1,6 +1,6 @@---name: quality-reviewer-description: Combined code quality and security review agent. Used in two contexts — (1) shared in a COMPLEX wave alongside test-validator, (2) single-shot in the SIMPLE flow when the diff touched `supabase/` (schema/view/RLS gating before merge).+description: Combined code quality, security, and QA review agent — the sole reviewer in a COMPLEX wave (code + security review AND runtime/integration validation), and single-shot in the SIMPLE flow when the diff touched `supabase/` (schema/view/RLS gating before merge).model: sonnettools:- Read@@ -14,7 +14,7 @@ tools:## Role-Verify the implementation is correct, spec-compliant, follows project conventions, and introduces no exploitable vulnerability. Run in parallel with test-validator.+Verify the implementation is correct, spec-compliant, follows project conventions, introduces no exploitable vulnerability, and actually works to the extent the local environment allows. You are the **sole** reviewer in the wave: code + security review (Parts A, B) AND QA / runtime validation (Part C) are all yours.- Read ticket: `${TICKET_FILE}` (absolute path passed in spawn prompt).- Output format: `.claude/rules/agent-output-format.md`.@@ -77,7 +77,8 @@ Read the ticket spec at `TICKET_FILE`, read the diff in `WORKTREE_PATH`. Apply y````origin/main` is the canonical session base — the `fetch` keeps it current in case other tickets merged while you were waiting for the dev's message.2. **Apply the rubric** below (Parts A and B). Also apply `coding-style.md` and `security-triggers.md` rules.-3. **Emit verdict** as the final line of output using the OUTPUT CONTRACT format above.+3. **Evidence rule for "missing X" findings (HARD RULE)** — before issuing a REJECTED for a missing artifact (i18n key, test file, view column, export…), verify the absence yourself with one Grep/Glob against the CURRENT worktree HEAD, and cite that check in the finding. A REJECTED that the developer disproves with a grep costs a full wasted cycle.+4. **Emit verdict** as the final line of output using the OUTPUT CONTRACT format above.**DO NOT:**- Run validations (typecheck, prettier, unit, e2e) — hooks do this.@@ -136,8 +137,8 @@ Run `npm audit --audit-level=high` ONLY if `package.json` / `package-lock.json`### A.1 Spec compliance (BLOCKING)Read every item in `acceptance_criteria` from the ticket JSON. For each one:-- **Code-verifiable** (source confirms it — prop present, file deleted, type defined, variable set): verify now, mark `[PASS]` or `[FAIL]`.-- **Behavior-verifiable** (requires runtime rendering to confirm): mark `[→ tv]` and skip — this is test-validator's responsibility.+- **Code-verifiable** (source confirms it — prop present, file deleted, type defined, variable set): verify here, mark `[PASS]` or `[FAIL]`.+- **Behavior-verifiable** (requires runtime rendering to confirm): verify in **Part C** (integration check + screenshots) and mark `[PASS]` or `[FAIL]` there.Any `[FAIL]` → REJECTED. Omitting a criterion from the list is itself a bug.@@ -285,6 +286,65 @@ Supabase-specific:---+## Part C — QA / runtime validation++Verify the implementation works to the extent the local environment allows.+Authoritative validation runs in CI on the PR (`make start-supabase-e2e`); this+is the local pre-filter. Behavior-verifiable acceptance criteria, integration+wiring, and e2e presence are yours to check here — no second reviewer covers them.++### Sandbox awareness++Typically unavailable in the dev sandbox: a running Supabase stack on 54341; a+display for vitest browser mode; auth against a real backend (sign-in/sign-up+taps the Supabase Auth API even with `VITE_DATA_PROVIDER=fakerest`). If you hit+these, **don't retry** — note the limitation and let CI cover the screenshot+step (C.3). A sandbox limitation alone is never a REJECTED.++### C.1 Acceptance criteria — behavior-verifiable (BLOCKING)++For every item flagged behavior-verifiable in A.1 (runtime rendering — visual+output, reachability, state transitions): verify it via C.2/C.3 and mark+`[PASS]` or `[FAIL]`. Any `[FAIL]` → REJECTED. Omitting a criterion is itself a+bug.++### C.2 Integration check (read-only, BLOCKING)++Router / App registration:+- New resource registered in `src/components/atomic-crm/root/CRM.tsx`?+- New route in the router?+- Nav menu entry in `Header.tsx`?++Component exports:+- `src/components/atomic-crm/[entity]/index.ts` exports the resource config?+- All referenced components actually created?++Renaming sanity:+- If a table was renamed: no lingering `.from("<old_name>")` in `src/` or `e2e/`?++Any failure → REJECTED. (Migrations are NOT checked here — SQL is generated at+deploy time from the session-branch diff, not in a feature TASK.)++### C.3 Playwright screenshots (when reachable)++**Skip entirely** if no acceptance criterion is behavior-verifiable, or the route+needs auth / no display is available — note that CI will cover it. Do NOT run+`npx playwright install --with-deps`.++**Run when** at least one behavior-verifiable criterion exists and the route is+reachable without auth. Capture only what the criterion requires, then `Read`+each screenshot. Legibility failure (text invisible on its background in any+theme or interaction state) → REJECTED.++### C.4 e2e spec sanity (read-only)++Execution is the SubagentStop validation chain's job (`validate-on-stop.mjs`).+Here you only verify the spec file exists when acceptance criteria require it and+that it targets the right route/component. (Presence of a test for every new+behavior is also enforced by A.7.)++---+## Common false positives — do NOT flag- Env vars in `.env.example` (not actual secrets)diff --git a/.claude/agents/simple-developer.md b/.claude/agents/simple-developer.mdindex 8dfed980..87e73e1c 100644--- a/.claude/agents/simple-developer.md+++ b/.claude/agents/simple-developer.md@@ -119,13 +119,20 @@ Then `Read("$CLAUDE_PROJECT_DIR/MEMORY.md")` — domain vocabulary. Even a label- File modifications MUST go through Edit or Write — NEVER use Bash to write files (`sed -i`, `cat > file`, `echo > file`, in-place edits). Renames via `git mv` are allowed.- Stay strictly within the scope above — cosmetic, single-field (optionally with i18n labels for that field), or a list filter reusing existing components. Anything broader (multiple fields, import, new entity, new custom component) → refuse with `FAILED: out of scope — needs COMPLEX flow`.-### 4. Commit+### 4. Self-check++If the change touched `supabase/schemas/`, verify before committing (these are exactly what the post-commit DB review blocks on — each miss costs a silent fix round-trip):+- new column appended at the **end** of the view's SELECT in `03_views.sql` (no reordering),+- no file under `supabase/migrations/` in your diff,+- i18n keys for the new field present in BOTH `englishCrmMessages.ts` and `frenchCrmMessages.ts` if the field has user-facing labels.++### 5. Commit```bashcd <WORKTREE_PATH> && git add -A && git commit -m "simple: <one-line summary>"```-### 5. Stop+### 6. StopAfter the commit, **stop and report DONE**. The `validate-on-stop` SubagentStop hook (prettier auto-fix, typecheck, unit tests, e2e) runs automatically:- All pass → your stop is final, output below is returned to the orchestrator.diff --git a/.claude/agents/test-validator.md b/.claude/agents/test-validator.mddeleted file mode 100644index 2ffdb068..00000000--- a/.claude/agents/test-validator.md+++ /dev/null@@ -1,158 +0,0 @@-----name: test-validator-description: QA agent. Use after DEVELOPER implementation, in parallel with quality-reviewer. Verifies the feature is reachable in the app and that acceptance criteria are met locally.-model: sonnet-tools:- - Read- - Bash- - Glob- - Grep- - Skill------# TEST-VALIDATOR — QA Agent--## Role--Verify the implementation works to the extent the local environment allows. Authoritative validation runs in CI on the PR (`make start-supabase-e2e`); your job is the local pre-filter. Run in parallel with quality-reviewer.--- Read ticket: `${TICKET_FILE}` (absolute path passed in spawn prompt).-- Output format: `.claude/rules/agent-output-format.md`.-- Worktree scope: code lives in `<WORKTREE_BASE>/TASK-XXX/`, NOT `$CLAUDE_PROJECT_DIR/src/`. Read `.claude/rules/worktree-scope.md` first. Reading `$CLAUDE_PROJECT_DIR/src/...` shows pre-ticket state → false REJECTED.-- Available skills — call `Skill({skill: "e2e-conventions"})` when checking e2e test presence and shape.--## OUTPUT CONTRACT (required)--Your very last line of output MUST be exactly one of:--- `APPROVED`-- `REJECTED: <feedback>`--For `REJECTED:`, `<feedback>` is a bulleted list (one bullet per issue) the developer must address on retry. Be specific: file path + symptom + what to change. The developer's next attempt receives this verbatim as `RETRY_FEEDBACK`.--Nothing else after the contract line — no pleasantries, no markdown trailer.--The orchestrator parses this line by regex. Any other format is treated as `REJECTED: <malformed reviewer output>`.-------## Workflow--Your spawn prompt provides `TASK_ID`, `WORKTREE_PATH`, and `TICKET_FILE`.--Read the ticket spec at `TICKET_FILE`, read the test artifacts in `WORKTREE_PATH`. Apply your validation checklist. Emit the contract line.--1. **Read** ticket spec at `TICKET_FILE` and the worktree (including new test files).-2. **PRESENCE** — every new behavior in the diff has at least one test (unit or e2e).-3. **PERTINENCE** — assertions actually cover the failure modes that matter (a test that always passes is not pertinent).-4. **Apply** Steps 0 (acceptance criteria), 1 (integration), 2 (screenshots if reachable), 3 (e2e spec sanity) — see detail sections below.-5. **Emit verdict** as the final line of output using the OUTPUT CONTRACT format above.--**DO NOT:**-- Run tests (`npx vitest`, `npx playwright test`) — the SubagentStop validation chain does this.-- Run `npx playwright install --with-deps`.-- Re-spawn agents or call `TeamCreate` / `TeamDelete`.-------## Sandbox awareness--Typically unavailable in the dev sandbox:-- A running Supabase stack on 54341-- A display for vitest browser mode-- Auth against a real backend (sign-in/sign-up taps Supabase Auth API even with `VITE_DATA_PROVIDER=fakerest`)--If you hit these: **don't retry**. Report the limitation, emit `APPROVED` if everything else is clean and Steps 0 + 1 + 3 pass, noting CI will cover Step 2. If any other step has blocking issues, use `REJECTED:`.-------## Validation commands — DO NOT RUN--See `.claude/rules/validation-commands.md`. Focus on what hooks can't check:-- Integration wiring (Step 1) — Read/Grep only-- UI reachability (Step 2) — screenshots if unauth-accessible, else skip-- e2e spec presence (Step 3) — verify file + route, do NOT run-------## Step 0 — Acceptance criteria checklist (required)--Read every item in `acceptance_criteria` from the ticket JSON. For each one:-- **Behavior-verifiable** (requires runtime rendering — visual output, reachability, state transitions): verify in Steps 1–2, mark `[PASS]` or `[FAIL]`.-- **Code-verifiable** (source structure — types, routes, props, file presence): mark `[→ qr]`, skip.--Any `[FAIL]` → REJECTED. Omitting a criterion from the list is itself a bug.-------## Step 1 — Integration check (read-only, required)--Router / App registration:-- New resource registered in `src/components/atomic-crm/root/CRM.tsx`?-- New route in the router?-- Nav menu entry in `Header.tsx`?--Component exports:-- `src/components/atomic-crm/[entity]/index.ts` exports the resource config?-- All referenced components actually created?--Renaming sanity:-- If a table was renamed: no lingering `.from("<old_name>")` in `src/` or `e2e/`?--Migrations are NOT a developer concern: SQL is generated at deploy time from-`git diff session-base/<SESSION_SHORT_ID>..session/<SESSION_SHORT_ID>` by a-dedicated migration round. Do not look for migration files in this worktree.--Any failure → REJECTED.-------## Step 2 — Playwright screenshots--**Skip entirely** if no acceptance criterion is behavior-verifiable. Takes 5–10s — don't run it for purely structural tickets.--**Run when** at least one behavior-verifiable criterion exists and the route is reachable without auth. Do NOT run `npx playwright install --with-deps`.--Capture what the criterion requires — no more. Examples of minimal targeted shots:-- A criterion about a label or title: screenshot the relevant page, read the text in the image.-- A criterion about visual appearance in dark mode: force dark class, screenshot the relevant component, check legibility of text on its background and at hover state.-- A criterion about a feature being present: navigate to its route, screenshot to confirm it renders.--Read each screenshot you take. Legibility failure (text invisible on its background in any theme or interaction state) → REJECTED.-------## Step 3 — e2e spec sanity check--Execution is the SubagentStop validation chain's job (`validate-on-stop.mjs`, full mode only). You only verify:-- Spec file exists if acceptance criteria require it-- Spec targets the right route/component (read-only)-------## Verdict matrix--| Condition | Verdict |-|---|---|-| Any `[FAIL]` in acceptance criteria checklist (Step 0) | REJECTED |-| Integration missing (Step 1) | REJECTED |-| Contrast / legibility failure in screenshots (Step 2) | REJECTED |-| All steps clean | APPROVED |-| Steps 0 + 1 + 3 clean, Step 2 skipped (auth/no display) | APPROVED |--Step 2 being skipped due to sandbox limitations is normal — emit `APPROVED` with a note in your output (before the contract line) that CI will cover Step 2. Do NOT use this path when the ticket has visual acceptance criteria that require screenshot verification and the route is reachable.--Typecheck/unit/e2e failures are caught by hooks before you run. If DEVELOPER reached you, those passed. Don't include them in your verdict.-------## Severity--| Severity | Definition | Verdict |-|---|---|---|-| blocking | Unit tests fail, feature unreachable, integration missing, typecheck error | REJECTED |-| warning | Console warnings, pre-existing flaky tests, missing non-required assertion | APPROVED with note |-------The contract line is your entire output as far as the orchestrator is concerned. Informational analysis above it is not parsed.diff --git a/.claude/hooks/bash-guard.mjs b/.claude/hooks/bash-guard.mjsindex f9c868d5..805a1865 100755--- a/.claude/hooks/bash-guard.mjs+++ b/.claude/hooks/bash-guard.mjs@@ -41,12 +41,7 @@ if (browserViolation) {// Validation rules — gated subagents only: the validation hooks already run// these; manual runs burn budget and can hang (vitest headed without CI=true).-const GATED_AGENTS = [- "developer",- "quality-reviewer",- "test-validator",- "simple-developer",-];+const GATED_AGENTS = ["developer", "quality-reviewer", "simple-developer"];if (!GATED_AGENTS.includes(agent)) process.exit(0);const runsTypecheck = (c) =>diff --git a/.claude/hooks/block-merger-without-review.mjs b/.claude/hooks/block-merger-without-review.mjsindex 9f18c640..5724dcef 100755--- a/.claude/hooks/block-merger-without-review.mjs+++ b/.claude/hooks/block-merger-without-review.mjs@@ -1,9 +1,9 @@#!/usr/bin/env node-// PreToolUse(Agent) — block dispatching a per-ticket merger until BOTH reviewers-// (quality-reviewer + test-validator) have recorded APPROVED for that ticket.-// With no SendMessage handshake, nothing else stops the orchestrator from going-// developer -> merger directly and skipping review; this gate enforces the-// dev -> reviewers -> (both APPROVED) -> merger ordering structurally.+// PreToolUse(Agent) — block dispatching a per-ticket merger until the+// quality-reviewer has recorded APPROVED for that ticket. With no SendMessage+// handshake, nothing else stops the orchestrator from going developer -> merger+// directly and skipping review; this gate enforces the+// dev -> reviewer -> (APPROVED) -> merger ordering structurally.//// Verdicts are recorded by record-review-verdict.mjs (SubagentStop) as flags// under <sessionDir>/reviews/<TASK>-<role>. Skipped for the SIMPLE flow,@@ -27,11 +27,11 @@ if (!/^TASK-\d+$/.test(d.taskId)) process.exit(0); // can't identify a ticketconst missing = REVIEW_ROLES.filter((role) => !existsSync(reviewFlag(ctx, d.taskId, role)),);-if (missing.length === 0) process.exit(0); // both APPROVED → allow the merge+if (missing.length === 0) process.exit(0); // APPROVED → allow the mergectx.fail(`Refusing to dispatch the merger for ${d.taskId}: no APPROVED verdict from ${missing.join(" and ")} yet.\n` +- "The flow is: developer -> quality-reviewer + test-validator -> (BOTH return APPROVED) -> merger.\n" +- `Dispatch quality-reviewer-${d.taskId} and test-validator-${d.taskId} first (STATE B transitions), then dispatch the merger only after both APPROVED.`,+ "The flow is: developer -> quality-reviewer -> (APPROVED) -> merger.\n" ++ `Dispatch quality-reviewer-${d.taskId} first (STATE B transition), then dispatch the merger only after it returns APPROVED.`,{ log: `BLOCK ${d.taskId} missing=${missing.join(",")}` },);diff --git a/.claude/hooks/block-promote-unmerged.mjs b/.claude/hooks/block-promote-unmerged.mjsindex 531cbe2c..b718cc3c 100755--- a/.claude/hooks/block-promote-unmerged.mjs+++ b/.claude/hooks/block-promote-unmerged.mjs@@ -49,6 +49,6 @@ ctx.fail(`Refusing to promote ${session} to main — these task branches have commits NOT yet merged into the session branch:\n` +unmerged.map(describe).join("\n") +"\n" +- "A ticket was developed but never merged (its reviewers/merger were likely never dispatched). For EACH branch above, drive its ticket through REVIEW -> MERGE (dispatch its quality-reviewer + test-validator if needed, then its per-ticket merger) so its work lands on the session branch. Re-dispatch the promotion merger only once this list is empty.",+ "A ticket was developed but never merged (its reviewer/merger were likely never dispatched). For EACH branch above, drive its ticket through REVIEW -> MERGE (dispatch its quality-reviewer if needed, then its per-ticket merger) so its work lands on the session branch. Re-dispatch the promotion merger only once this list is empty.",{ log: `BLOCK unmerged=${unmerged.length}` },);diff --git a/.claude/hooks/lib/reviews.mjs b/.claude/hooks/lib/reviews.mjsindex 05e98ba8..515c4089 100644--- a/.claude/hooks/lib/reviews.mjs+++ b/.claude/hooks/lib/reviews.mjs@@ -7,7 +7,7 @@import { join } from "node:path";-export const REVIEW_ROLES = ["quality-reviewer", "test-validator"];+export const REVIEW_ROLES = ["quality-reviewer"];export const reviewsDir = (ctx) => join(ctx.sessionDir, "reviews");diff --git a/.claude/hooks/lib/teams.mjs b/.claude/hooks/lib/teams.mjsindex e5443c77..5694bb92 100644--- a/.claude/hooks/lib/teams.mjs+++ b/.claude/hooks/lib/teams.mjs@@ -6,5 +6,4 @@ export const getFirstTaskId = (text) => (String(text ?? "").match(/TASK-[0-9]+/)// Agent-name role predicates. Match the bare role, a suffixed name// (merger-TASK-003), or an @-qualified address.export const isQualityReviewer = (name) => /^quality-reviewer([-@]|$)/.test(name || "");-export const isTestValidator = (name) => /^test-validator([-@]|$)/.test(name || "");export const isMerger = (name) => /^merger([-@]|$)/.test(name || "");diff --git a/.claude/hooks/record-review-verdict.mjs b/.claude/hooks/record-review-verdict.mjsindex 1ee8c825..8f68b422 100755--- a/.claude/hooks/record-review-verdict.mjs+++ b/.claude/hooks/record-review-verdict.mjs@@ -1,7 +1,7 @@#!/usr/bin/env node-// SubagentStop(quality-reviewer|test-validator) — record each reviewer's verdict+// SubagentStop(quality-reviewer) — record the reviewer's verdict// as a per-ticket flag so block-merger-without-review.mjs can enforce-// dev -> reviewers -> merger. SubagentStop cannot block — it only records.+// dev -> reviewer -> merger. SubagentStop cannot block — it only records.//// Flag (presence == APPROVED): <sessionDir>/reviews/<TASK>-<role>. Cleared on// REJECTED here; cleared on a developer (re)dispatch by setup-worktree.mjs so a@@ -21,11 +21,7 @@ import {writeFileSync,} from "node:fs";import { createHookContext } from "./lib/context.mjs";-import {- getFirstTaskId,- isQualityReviewer,- isTestValidator,-} from "./lib/teams.mjs";+import { getFirstTaskId, isQualityReviewer } from "./lib/teams.mjs";import { reviewFlag, reviewsDir } from "./lib/reviews.mjs";const input = JSON.parse(readFileSync(0, "utf8"));@@ -33,11 +29,7 @@ const ctx = createHookContext(input, "record-review-verdict");// Role + task from the (suffixed) agent identity, e.g. quality-reviewer-TASK-001.const ids = [ctx.agentName, ctx.agentType].filter(Boolean);-let role = ids.some(isQualityReviewer)- ? "quality-reviewer"- : ids.some(isTestValidator)- ? "test-validator"- : "";+let role = ids.some(isQualityReviewer) ? "quality-reviewer" : "";let task = "";for (const n of ids) {const m = getFirstTaskId(n);@@ -61,9 +53,7 @@ if (!role || !task) {}for (const line of body.split("\n")) {if (!role) {- const m = line.match(- /(?:^|\\n|")ROLE:\s*(quality-reviewer|test-validator)/,- );+ const m = line.match(/(?:^|\\n|")ROLE:\s*(quality-reviewer)/);if (m) role = m[1];}if (!task) {@@ -122,11 +112,9 @@ const lastAssistantText = () => {if (!role) {// Anchor to a dispatch-line boundary — start of the JSONL record, an// escaped newline (\n inside the JSON string), or the prompt field's- // opening quote — so an inline prose mention ("...the ROLE: test-validator+ // opening quote — so an inline prose mention ("...the ROLE: quality-reviewer// agent...") cannot mis-assign the role.- const m = line.match(- /(?:^|\\n|")ROLE:\s*(quality-reviewer|test-validator)/,- );+ const m = line.match(/(?:^|\\n|")ROLE:\s*(quality-reviewer)/);if (m) role = m[1];}if (!task) {diff --git a/.claude/hooks/test/bash-guard.test.mjs b/.claude/hooks/test/bash-guard.test.mjsindex 652b98c0..87c069cc 100644--- a/.claude/hooks/test/bash-guard.test.mjs+++ b/.claude/hooks/test/bash-guard.test.mjs@@ -40,12 +40,18 @@ describe("bash-guard hook", () => {});test("headed playwright screenshot from merger → blocked", () => {- const r = runHook("merger", "npx playwright screenshot http://localhost:5173 out.png");+ const r = runHook(+ "merger",+ "npx playwright screenshot http://localhost:5173 out.png",+ );expect(isBlocked(r)).toBe(true);});test("playwright with --headless from main session → allowed", () => {- const r = runHook("", "npx playwright screenshot --headless http://localhost:5173 out.png");+ const r = runHook(+ "",+ "npx playwright screenshot --headless http://localhost:5173 out.png",+ );expect(r.status).toBe(0);expect(isBlocked(r)).toBe(false);});@@ -68,7 +74,7 @@ describe("bash-guard hook", () => {["simple-developer", "npx vitest run"],["simple-developer", "npm run prettier:apply"],["quality-reviewer", "npx playwright test --headless"],- ["test-validator", "make lint"],+ ["quality-reviewer", "make lint"],["developer", "npm run build"],];diff --git a/.claude/hooks/test/block-merger-without-review.test.mjs b/.claude/hooks/test/block-merger-without-review.test.mjsindex 837023b4..f0d35e79 100644--- a/.claude/hooks/test/block-merger-without-review.test.mjs+++ b/.claude/hooks/test/block-merger-without-review.test.mjs@@ -1,6 +1,6 @@// Tests for block-merger-without-review.mjs — the PreToolUse(Agent) gate that-// blocks a per-ticket merger until BOTH reviewers recorded APPROVED (flags under-// <sessionDir>/reviews/<TASK>-<role>, written by record-review-verdict.mjs). The+// blocks a per-ticket merger until the quality-reviewer recorded APPROVED (flags+// under <sessionDir>/reviews/<TASK>-<role>, written by record-review-verdict.mjs). The// gate exits 2 to block and 0 to allow. Skipped for promotion-only / SIMPLE /// ROLLBACK dispatches and when the ticket id can't be parsed (fail open).@@ -53,16 +53,8 @@ describe("block-merger-without-review", () => {).toBe(2);});- test("blocks when only one reviewer has approved", () => {- approve("TASK-002", "quality-reviewer");- expect(- run(`ROLE: merger\nTASK_ID: TASK-002\nBRANCH_NAME: ${SS}/TASK-002`),- ).toBe(2);- });-- test("allows the merger once BOTH reviewers approved", () => {+ test("allows the merger once the reviewer approved", () => {approve("TASK-003", "quality-reviewer");- approve("TASK-003", "test-validator");expect(run(`ROLE: merger\nTASK_ID: TASK-003\nBRANCH_NAME: ${SS}/TASK-003`),).toBe(0);diff --git a/.claude/hooks/test/record-review-verdict.test.mjs b/.claude/hooks/test/record-review-verdict.test.mjsindex e874483c..d1472f15 100644--- a/.claude/hooks/test/record-review-verdict.test.mjs+++ b/.claude/hooks/test/record-review-verdict.test.mjs@@ -56,12 +56,12 @@ describe("record-review-verdict", () => {expect(existsSync(flag("TASK-007-quality-reviewer"))).toBe(false);});- test("test-validator records its own flag from the final line", () => {+ test("records the flag from a final APPROVED after preamble prose", () => {run({- agent_type: "test-validator-TASK-007",- last_assistant_message: "Step 1 — integration: present\nAPPROVED",+ agent_type: "quality-reviewer-TASK-011",+ last_assistant_message: "Part C — integration: present\nAPPROVED",});- expect(existsSync(flag("TASK-007-test-validator"))).toBe(true);+ expect(existsSync(flag("TASK-011-quality-reviewer"))).toBe(true);});test("multi-line REJECTED (bulleted feedback) clears a prior flag", () => {@@ -97,10 +97,10 @@ describe("record-review-verdict", () => {test("standalone APPROVED with a trailing note still approves", () => {run({- agent_type: "test-validator-TASK-010",+ agent_type: "quality-reviewer-TASK-012",last_assistant_message: "APPROVED\nNice work — all e2e specs present.",});- expect(existsSync(flag("TASK-010-test-validator"))).toBe(true);+ expect(existsSync(flag("TASK-012-quality-reviewer"))).toBe(true);});test("unknown verdict leaves state untouched (no flag written)", () => {diff --git a/.claude/rules/agent-output-format.md b/.claude/rules/agent-output-format.mdindex f1ebcec3..1f3614ef 100644--- a/.claude/rules/agent-output-format.md+++ b/.claude/rules/agent-output-format.md@@ -6,9 +6,9 @@ paths: []All ticket agents are spawned one-shot (in the background) by the chat orchestrator. Each agent's last line of output is parsed by regex against an output contract. Anything else in the body is informational and ignored by the orchestrator's parser.-The developer, quality-reviewer, and test-validator read their ticket from `${TICKET_FILE}` (an absolute path passed in the spawn prompt). The merger additionally receives `${TICKETS_DIR}` (the per-session directory holding all ticket JSON files) so it can update the ticket's `status` field after a successful merge.+The developer and quality-reviewer read their ticket from `${TICKET_FILE}` (an absolute path passed in the spawn prompt). The merger additionally receives `${TICKETS_DIR}` (the per-session directory holding all ticket JSON files) so it can update the ticket's `status` field after a successful merge.-## Reviewer agents (quality-reviewer, test-validator)+## Reviewer agent (quality-reviewer)Last line of output MUST be exactly one of:diff --git a/.claude/rules/validation-commands.md b/.claude/rules/validation-commands.mdindex b4d71822..df3a2312 100644--- a/.claude/rules/validation-commands.md+++ b/.claude/rules/validation-commands.md@@ -6,10 +6,10 @@ paths: []Validation is automated:- The `validate-on-stop.mjs` SubagentStop hook runs the full chain (prettier auto-fix, typecheck, unit, e2e) after every developer (and simple-developer) stops. A failed validation rejects the stop, the developer's internal loop fixes the issue, and only a green stop returns control to the orchestrator.-- The `bash-guard.mjs` PreToolUse hook blocks `developer`, `simple-developer`, `quality-reviewer`, `test-validator` from running them manually.+- The `bash-guard.mjs` PreToolUse hook blocks `developer`, `simple-developer`, `quality-reviewer` from running them manually.- Prettier is auto-applied and committed by the validation chain — formatting never needs manual action unless a file has a syntax error.-## Forbidden commands (developer / quality-reviewer / test-validator)+## Forbidden commands (developer / quality-reviewer)| Category | Commands ||---|---|diff --git a/.claude/rules/worktree-scope.md b/.claude/rules/worktree-scope.mdindex 8bc4e7f2..a884ba9d 100644--- a/.claude/rules/worktree-scope.md+++ b/.claude/rules/worktree-scope.md@@ -1,6 +1,6 @@# Worktree scope — strict file access for ticket work-Applies to: developer, quality-reviewer, test-validator. Any agent dispatched by the orchestrator (background, single-shot) to work on a specific ticket, with a suffixed name (e.g. `developer-TASK-006`).+Applies to: developer, quality-reviewer. Any agent dispatched by the orchestrator (background, single-shot) to work on a specific ticket, with a suffixed name (e.g. `developer-TASK-006`).Throughout this rule, `$REPO` is the project root (`$CLAUDE_PROJECT_DIR` — wherever the repo is checked out). `<WORKTREE_PATH>` is the absolute worktree path handed to you in your spawn prompt.diff --git a/.claude/settings.json b/.claude/settings.jsonindex 7338f9b7..b20e7a74 100644--- a/.claude/settings.json+++ b/.claude/settings.json@@ -105,7 +105,7 @@]},{- "matcher": "quality-reviewer|test-validator",+ "matcher": "quality-reviewer","hooks": [{"type": "command",diff --git a/CLAUDE.md b/CLAUDE.mdindex bf8df867..e6d054e5 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -15,7 +15,7 @@ The **chat-orchestrator** is the user-facing entry point. It routes, narrates pr1. **planner** — decompose the approved plan into atomic, ordered tickets (JSON) with best-guess file paths and dependency waves. Skip only when the plan is already a single atomic deliverable (one file, one fix, one migration).2. **developer** (one per ticket) — implement + commit inside the ticket's git worktree. Tickets in the same wave (`parallel_safe: true`, no mutual dependency) are spawned concurrently as **foreground** subagents — a single message with multiple `Agent(...)` tool uses (no `run_in_background`); the orchestrator's turn resumes once they all return. Developers also write an ADR under `adr/` when a change introduces a structural decision, and never write SQL migrations (those are generated at deploy time).-3. **quality-reviewer** + **test-validator** (per ticket, in parallel) — quality-reviewer does combined semantic code + security review; test-validator checks integration wiring and e2e presence. Neither re-runs validation (hooks already do).+3. **quality-reviewer** — the single reviewer: combined semantic code + security review (Parts A, B) plus QA / runtime validation — integration wiring, behavior-verifiable acceptance criteria, e2e presence (Part C). Never re-runs validation (hooks already do).4. **merger** — `git merge --no-ff` only; never `git add` / `git commit`. One merger is dispatched per ticket (Stage A: feature branch → session branch); a final promotion merger (`MODE: promote`) moves the session branch onto `main` once the wave is done, serialised across sessions by a `flock` on the shared `.git`.5. **documentator** — auto-runs at the end of every COMPLEX session, appending business knowledge to `MEMORY.md` from the session diff. (Mode 1 also captures reusable rules/skills on explicit user request.)@@ -29,8 +29,7 @@ There is no cross-agent messaging: the orchestrator dispatches every agent as a| planner | sonnet | Decomposes the plan into tickets JSON with waves + file hints. || developer | opus | Implements + commits in a worktree. Applies the **Ponytail** minimization ladder (full mode) automatically on every ticket, via an inline prompt directive. Writes ADRs for structural decisions. Never writes SQL migrations (deploy-time only). || simple-developer | sonnet | One cosmetic edit, one single-field entity change, or one filter reusing existing components. Applies the **Ponytail** ladder (full mode) automatically, via an inline prompt directive. No team, no review. |-| quality-reviewer | sonnet | Combined semantic code + security review only. Never re-runs validation. |-| test-validator | haiku | Integration wiring + e2e presence. |+| quality-reviewer | sonnet | Sole reviewer: combined semantic code + security review AND QA/runtime validation (integration wiring, behavior criteria, e2e presence). Never re-runs validation. || merger | haiku | `git merge --no-ff` only. Never `git add` / `git commit`. || documentator | sonnet | Mode 1 — captures rules/skills on request. Mode 2 — appends business knowledge to `MEMORY.md` at COMPLEX session end. |