Script-driven rule-major batched reviewer
Goal
Rewrite /impl-hygiene-review Phase 3 from one monolithic agent (full ruleset + full worklist) into RULE-MAJOR batches routed by the 14 seam detectors. Five batches: BATCH1 INVERTED-TDD (no detectors; plan+deliverable code), BATCH2 LEAK/SSOT (detectors scattered-knowledge, registration-drift), BATCH3 Algorithmic-DRY (clone-dry, duplicated-dispatch), BATCH4 Boundary/Flow (layering, param-sprawl, fan-in, cross-phase-gap, hot-path, exposure), BATCH5 Surface (dead-code, file-bloat, naming, comment-restatement). Each batch’s prompt is script-composed from the JSON loader (the batch’s rule records) + the detector-flagged file subset.
Implementation Sketch
Author the detector->rule-batch routing table in the runtime (consuming seam_scan.py DETECTORS keys + the loader’s detector_keys[]). Extend dispatch.py:compose_next_action to emit one next_action per batch (5 dispatches) instead of one Phase-3 dispatch. Rewrite SKILL.md Phase 3 + phase-3-analysis.md to dispatch N batch agents sequential-foreground per skill-control-contract §Caller Foreground Dispatch. verification_gate.py (drop-unless-verified) + finding_emit.py are unchanged (called per batch). Each batch prompt is script-composed (script-first.md §1: scripts generate the prompts).
Spec References
scripts/impl_hygiene_review_runtime/seam_scan.py:1162-1179 (DETECTORS registry), :255-271 (detector category keys); dispatch.py:71-99 (compose_next_action); .claude/skills/impl-hygiene-review/SKILL.md:234-244 (current monolith); phase-3-analysis.md:40-200 (5-pass structure); skill-control-contract.md §Caller Foreground Dispatch.
Work Items
- Author detector->rule-batch routing table (5 batches) in the runtime, consuming seam_scan DETECTORS + loader detector_keys[].
- Extend dispatch.py:compose_next_action to emit one next_action per batch (5 sequential dispatches); script-compose each batch prompt from the loader.
- Rewrite SKILL.md Phase 3 + phase-3-analysis.md to dispatch N batch agents sequential-foreground (verification_gate + finding_emit unchanged).
- Extend main —self-test to cover the 5-batch dispatch sequence + routing table.
Success Criteria
- [sc-759ec9aa] Phase 3 emits 5 rule-major batch next_actions routed by detectors; runtime self-test passes. (probe:
python -m scripts.impl_hygiene_review_runtime --self-test; expect: exit 0)
Fresh intel (regenerated)
{ “schema_version”: 1, “target”: { “kind”: “plan-section”, “ref”: “impl-hygiene-rules-as-data/s-e5e1f324” }, “generated_at”: “2026-06-21T05:39:30.245889+00:00”, “graph_state”: { “head_sha”: “b0bd51a8”, “last_code_import_at”: “2026-06-21T05:27:29.206Z”, “embedding_stale”: false, “insights_stale”: false, “cpg_stale”: false }, “surfaces”: {}, “summary”: “intel-package[plan-section:impl-hygiene-rules-as-data/s-e5e1f324] agent-authored dossier”, “degraded”: false, “dossier”: { “objective_symbols”: [], “tiers”: {}, “agent_authored”: true, “difficulty”: { “class”: “routine”, “research_online”: false, “research_mode”: “auto”, “signals”: [], “plan_dir”: “/home/eric/projects/ori_lang/plans/impl-hygiene-rules-as-data” } } }
(full dossier: batched-reviewer—s-e5e1f324.intel.json)