feat(WP-0016/C2-C3): close build infrastructure workplan

C2: document actual GHC cache behavior (-fbyte-code, no .o files, .hi
caching via -fwrite-interface) and correct CLAUDE.md cache claim.
C3: create IHUB-WP-0017 error-fix loop workplan (ralph-compatible,
5 tasks E1-E5, runs inside devenv shell).
WP-0016 status → done.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-10 23:36:06 +00:00
parent 469ed6c758
commit 34be62de04
3 changed files with 169 additions and 14 deletions

View File

@@ -4,7 +4,7 @@ type: workplan
title: "Build Infrastructure: Incremental Compilation and Autonomous Error-Fix Loop"
domain: inter_hub
repo: inter-hub
status: open
status: done
owner: custodian
topic_slug: inter_hub
created: "2026-04-10"
@@ -71,6 +71,12 @@ skips the database startup, port binding, and service orchestration overhead.
### C1 — Create `scripts/compile-check` script ✓
```task
id: C1
status: done
priority: high
```
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.
@@ -103,19 +109,40 @@ This relies on `.ghci` (already present) which sets up `-j1` and loads the IHP c
### C2 — Verify GHC object cache persistence
GHC stores compiled objects in IHP's `.devenv` or a project-local `dist-newstyle/`
equivalent. Verify the cache survives between `devenv up` restarts:
```bash
# After first successful build, check cache location:
find /home/tegwick/inter-hub -name "*.o" -newer Main.hs 2>/dev/null | head -5
```task
id: C2
status: done
priority: medium
```
If the cache is cleared on each `devenv up` restart, add `IHP_BUILD_CACHE` or
configure the Nix build dir to persist. Document the location here.
**Finding (2026-04-10):** IHP's `applicationGhciConfig` sets `-fbyte-code`. GHCi compiles
modules to bytecode in memory — there are **no persistent `.o` object files**. Each ghcid
session recompiles all bytecode from source.
Our `-fwrite-interface` flag (C4) writes `.hi` interface files alongside source modules.
These survive session restarts and allow GHCi to skip re-type-checking unchanged modules.
This saves some time on restarts but does NOT eliminate full bytecode recompilation.
**Net result:** No persistent `.o` cache. `.hi` files provide partial speedup (skip
type-checking). A single-module change still triggers full bytecode regeneration of that
module and its dependents. For true persistent incremental builds, `-fobject-code` would
be needed — not worth adding given IHP's design tradeoffs.
**Action:** No configuration change needed. Expectation documented here and in CLAUDE.md.
### C3 — Autonomous error-fix loop (ralph-workplan)
```task
id: C3
status: done
priority: high
```
Delivered as `workplans/IHUB-WP-0017-error-fix-loop.md`. Run inside `devenv shell`:
```bash
/ralph-workplan workplans/IHUB-WP-0017-error-fix-loop.md
```
Configure a ralph-workplan loop:
1. `scripts/compile-check --bg` runs ghcid in background, writing to `/tmp/ihub-compile-errors.txt`
2. Monitor tool watches the log file for new error output
@@ -130,6 +157,12 @@ Configure a ralph-workplan loop:
### C4 — Add GHC `-fwrite-interface` and `-keep-going` flags to `.ghci` ✓
```task
id: C4
status: done
priority: high
```
```
-- Continue past errors in other modules (report all errors in one pass)
:set -fkeep-going
@@ -142,6 +175,12 @@ stopping at the first failure — critical for batch error fixing.
### C5 — Document module surface constraints in CLAUDE.md ✓
```task
id: C5
status: done
priority: medium
```
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