feat(WP-0016/C5): compilation layers docs and -fwrite-interface flag

- CLAUDE.md: add "Compilation Layers" section (C5) — layer map,
  compile-check tool usage, cache location, error-fix discipline
- .ghci: add -fwrite-interface so interface files are cached even
  on partial-success builds (completes C4 spec)
- WP-0016: mark C5 done; annotate C4 ✓ note in workplan

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-10 20:03:54 +00:00
parent 64a9d4eeb4
commit 563983fa7f
3 changed files with 49 additions and 4 deletions

View File

@@ -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 (2060 min on constrained hardware), subsequent single-module rebuilds take 530 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)