--- id: IHUB-WP-0017 type: workplan title: "Autonomous Error-Fix Loop: Reach Clean Build" domain: inter_hub repo: inter-hub status: done owner: custodian created: "2026-04-10" updated: "2026-04-10" depends_on: [IHUB-WP-0016] state_hub_workstream_id: "4636eb67-f7fb-409c-8d13-7fb461ef5db2" --- # IHUB-WP-0017 — Autonomous Error-Fix Loop: Reach Clean Build ## Goal Drive the inter-hub codebase to a clean `ghcid` build ("All good, N modules loaded") by fixing compilation errors bottom-up, one module at a time. ## Pre-conditions - Must be run inside `devenv shell` (IHP_LIB must be set, ghcid in PATH) - WP-0016 complete (compile-check scripts and ghci flags in place) ## How to start ```bash # Enter devenv shell first: devenv shell # Then start this loop: /ralph-workplan workplans/IHUB-WP-0017-error-fix-loop.md ``` ## Error-Fix SOP (Standard Operating Procedure) ``` 1. Run: scripts/compile-check --bg 2. Tail /tmp/ihub-compile-errors.txt 3. Parse errors: group by module, order by Layer (1 → 4) 4. Fix Layer 1 errors first (rare; usually type/import issues in Web/Types.hs) 5. For each failing module in Layer 2–3: a. Read current module state b. Apply targeted fix (one module at a time) c. Wait for ghcid "Reloading..." + result d. If still failing: re-read error, apply next fix e. If 3 attempts fail: escalate — flag_for_human with module name and error 6. After Layer 3 clean: fix Layer 4 (FrontController/Routes) 7. "All good (N modules)" in log = build clean ``` **Layer discipline** (never violate): - Never modify Layer 1 (`Web/Types.hs`, `build/Generated/*.hs`) during error-fix loops - Layer 1 changes invalidate ALL 59 controllers and 120 views simultaneously - Fix within the layer where the error is reported; escalate if the fix requires Layer 1 ## Tasks ### E1 — Start compile-check and capture initial error set ```task id: E1 status: done priority: high state_hub_task_id: "0ddc0559-55a4-405d-b568-afabcf9d2242" ``` Run `scripts/compile-check --bg` and read `/tmp/ihub-compile-errors.txt`. List all failing modules and their layers. ### E2 — Fix Layer 2 errors (Application/Helper/*.hs) ```task id: E2 status: done priority: high state_hub_task_id: "2cd3dbb3-32d6-4348-8c04-e820feff96c0" ``` Fix all errors in `Application/Helper/*.hs`. Verify via ghcid reload. Mark done when Layer 2 shows no errors. ### E3 — Fix Layer 3 errors (Web/Controller/*.hs and Web/View/**/*.hs) ```task id: E3 status: done priority: high state_hub_task_id: "99c4345c-57fa-4e00-afa3-3d10d948ba02" ``` Fix errors in controllers and views. Work module-by-module, bottom-up. Mark done when Layer 3 shows no errors. ### E4 — Fix Layer 4 errors (Web/FrontController.hs, Web/Routes.hs) ```task id: E4 status: done priority: medium state_hub_task_id: "c5dda487-b091-4ce8-b7ad-782d2c462298" ``` Fix wiring errors last. Mark done when `ghcid` reports "All good, N modules loaded". ### E5 — Commit clean build and close WP-0014/A1 ```task id: E5 status: done priority: medium state_hub_task_id: "e20d48ea-6819-4222-a614-7dce74951e7c" ``` After "All good" state: 1. Commit all fixes with `fix(WP-0017): reach clean build` 2. Update `workplans/IHUB-WP-0014-pre-flight-deployment-gaps.md` A1 status to done 3. Mark this workplan done ## Exit Criteria - `ghcid` reports "All good, N modules loaded" with no errors - All fixes committed - WP-0014/A1 closed