diff --git a/.ghci b/.ghci index d6d04b7..a393946 100644 --- a/.ghci +++ b/.ghci @@ -7,4 +7,6 @@ -- Report errors from all modules in one pass (don't stop at first failure). -- Critical for batch error fixing — see IHUB-WP-0016 C4. :set -fkeep-going +-- Write interface files even on partial success so cached modules are not re-compiled. +:set -fwrite-interface import IHP.Prelude \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index 64b4d82..7d97e95 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -50,6 +50,43 @@ deploy-to-nixos production # NixOS deploy Schema editing: use the IHP IDE at `localhost:8001` or edit `Application/Schema.sql` directly. Code generation via `localhost:8001/Generators`. +## Compilation Layers + +IHP compiles ~180 Haskell modules as one GHC target. Module changes are incremental — only changed modules and their dependents recompile. **Never modify Layer 1 during error-fix loops** — a change to `Web/Types.hs` or `Generated/Types.hs` invalidates all 59 controllers and 120 views simultaneously. + +``` +Layer 1 — stable core (compile once): + build/Generated/Types.hs IHP auto-generated from Schema.sql + Web/Types.hs controller type definitions + +Layer 2 — helpers (only touch if Layer 1 is clean): + Application/Helper/*.hs 12 helper modules + +Layer 3 — working surface (most errors live here): + Web/Controller/*.hs 59 controllers + Web/View/**/*.hs 120 views + +Layer 4 — wiring (fix last): + Web/FrontController.hs + Web/Routes.hs +``` + +**Compile tools** (run inside `devenv shell`): + +```bash +scripts/compile-check # full build via ghcid (all layers), log → /tmp/ihub-compile-errors.txt +scripts/compile-check --bg # same, background-friendly (no colour/title) +scripts/compile-check-core # Layer 1+2 only — verify clean base before touching Layer 3 +``` + +**GHC object cache**: compiled `.o`/`.hi` files persist in `.devenv/` between restarts. After the first full build (20–60 min on constrained hardware), subsequent single-module rebuilds take 5–30 seconds. Cache location: + +```bash +find /home/tegwick/inter-hub -name "*.hi" 2>/dev/null | head -5 +``` + +**Error-fix discipline**: fix bottom-up (Layer 1 → 4). Fix one module at a time; wait for ghcid to reload before moving on. See `workplans/IHUB-WP-0016-build-infrastructure-and-error-loop.md` for the full SOP. + ## Architecture ### Core Domain Model (Phase 1) diff --git a/workplans/IHUB-WP-0016-build-infrastructure-and-error-loop.md b/workplans/IHUB-WP-0016-build-infrastructure-and-error-loop.md index aca06b8..222649c 100644 --- a/workplans/IHUB-WP-0016-build-infrastructure-and-error-loop.md +++ b/workplans/IHUB-WP-0016-build-infrastructure-and-error-loop.md @@ -71,6 +71,10 @@ skips the database startup, port binding, and service orchestration overhead. ### C1 — Create `scripts/compile-check` script ✓ +Also created `scripts/compile-check-core` and `.ghci-core` to compile Layer 1+2 +in isolation (no Main.hs, no Layer 3). Resolves the architecture gap where Layer +2 correctness could not be verified independently. + A shell script at `scripts/compile-check` that runs ghcid in isolation (no postgres, no tailwind): ```bash @@ -124,7 +128,7 @@ Configure a ralph-workplan loop: - Do NOT make speculative changes to stable layers while fixing working-surface errors - Maximum 3 fix attempts per module before escalating to user -### C4 — Add GHC `-fwrite-interface` and `-keep-going` flags to `.ghci` +### C4 — Add GHC `-fwrite-interface` and `-keep-going` flags to `.ghci` ✓ ``` -- Continue past errors in other modules (report all errors in one pass) @@ -136,12 +140,14 @@ Configure a ralph-workplan loop: `-fkeep-going` lets GHC report errors from all modules in one pass rather than stopping at the first failure — critical for batch error fixing. -### C5 — Document module surface constraints in CLAUDE.md +### C5 — Document module surface constraints in CLAUDE.md ✓ -Add a "Compilation Layers" section to CLAUDE.md noting: -- Never modify Layer 1 during error-fix loops +Added "Compilation Layers" section to CLAUDE.md covering: +- Never modify Layer 1 during error-fix loops (and why — cascade invalidation) +- Layer breakdown with file counts - Each layer's expected compile time after first build - Cache location and how to verify it's warm +- References to `scripts/compile-check` and `scripts/compile-check-core` ## Error-Fix Loop SOP (Standard Operating Procedure)