30 Commits

Author SHA1 Message Date
8aee7825c7 fix(build): simplify GHC 9.10.3 overlay — drop Generated.Types stub
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
The inter-hub-lib postUnpack that expanded `import Generated.Types` to
119 individual imports was incorrect: it deleted `module Generated.Types`
from Prelude export lists without replacing it, so consumers of the
Prelude lost all entity types (Build 32: GHC-76037 not-in-scope errors).

Fix: keep Generated.Types as a real module in inter-hub-models (remove the
empty stub). With the ActualTypes.hi fix already in place (explicit T(..)
exports), the cascade is shallow: each entity .hi is compact, so
Generated.Types.hi stays well under GHC's 274 MB limit. This makes
`import Generated.Types` work normally throughout inter-hub-lib without
any source patching.

The entire inter-hub-lib overrideAttrs block is removed; the
inter-hub-models overlay now only rewrites ActualTypes.hs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-02 17:09:00 +02:00
11ff61c1ba fix(build): route TH to ghc-iserv-dyn to bypass truncated libHSghc.a
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
Root cause: libHSghc-9.10.3-5702.a (287,768,576 bytes) has its last AR
entry (Expr.o) claiming 517,544 bytes but only 82,258 bytes remain —
the archive is truncated. GHC's internal readAr (Data.Binary.Get) panics
at position 287,686,318 when it tries to read the full claimed size.

The truncated .a is read lazily: IHP's TH splices queue a dependency on
the ghc package, which flushes to readAr after all 477 modules compile.
This explains the invariant crash at [477 of 477] WidgetVersionInclude.

ghc-iserv-dyn is not exposed in ghc-with-packages/bin/ (why
-fexternal-interpreter alone silently fell back to the internal linker).
Use -pgmi with the absolute path in the unwrapped GHC store to force
iserv-dyn, which uses dlopen on libHSghc.so (intact, 110 MB) instead
of readAr on the truncated .a. No crash.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-02 11:11:07 +02:00
ec8aa611b8 chore(build): swap -fexternal-interpreter for --disable-shared on models
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
-fexternal-interpreter had no effect: crash invariant at 287,686,318.
System ar reads libHSghc-9.10.3-5702.a (287,768,576 bytes) fine, but GHC's
internal readAr fails on the last entry — a bug in GHC's AR parser when
reading content near end-of-file. The call site is mergeObjectFiles during
.so creation, not TH evaluation.

--disable-shared skips the shared library build for inter-hub-models,
preventing GHC from ever calling readAr on libHSghc.a.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-02 00:49:14 +02:00
1050af9533 chore(build): try -fexternal-interpreter to bypass internal static linker
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
GHC crashes at byte 287,686,318 reading libHSghc-9.10.3.a (~274 MB) via
its internal static linker during TH evaluation of WidgetVersionInclude.
-fexternal-interpreter delegates TH to a separate iserv process using the
dynamic linker, bypassing readAr and the 274 MB archive entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-02 00:26:27 +02:00
e117f78ef3 chore(debug): force -j1 to serialize GHC parallel code generation
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
With -j8, GHC generates code for 8 modules in parallel. A parallel merging
step might read combined objects via Data.Binary.Get hitting 287 MB. Forcing
-j1 serializes codegen to test if parallel merging is the crash cause.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-02 00:06:31 +02:00
4c0d966d38 chore(debug): add -fno-dynamic-too to skip combined static/dynamic pass
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
DynamicToo state: DT_Dyn appears right before the crash. Force separate
static and dynamic GHC compilation passes to change the code path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-02 00:02:10 +02:00
01902040da chore(debug): try --disable-split-sections to avoid GHC crash
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
Crash invariantly at position 287,686,318 bytes happens after all 477 modules
compile. Hypothesis: split-sections expands ELF section count, triggering
GHC's internal ELF merger/linker to fail when reading the combined object.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 23:54:02 +02:00
3664af59f2 chore(debug): add -ddump-if-trace to inter-hub-models to diagnose GHC crash
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
All 477 modules compile successfully but GHC panics at position 287,686,318
during finalization. Trace will show which .hi file is being read at crash time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 23:27:21 +02:00
5382a7672a fix(build): capture type aliases in ActualTypes hub export list
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
IHP entity pattern: data Foo' params = Foo {...} (primed type, unprimed ctor)
                   type Foo = Foo' arg1 arg2    (concrete alias, kind *)

Include type instances use [Foo] — needs the concrete type alias (kind *),
not the primed data type. Previous awk only matched data/newtype, missing
the type alias. Add /^type [A-Z]/ match (no (..) suffix — type aliases are
not ADTs). type instance lines start with lowercase 'i' and don't match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 23:13:26 +02:00
1bdbce96e6 fix(build): rewrite ActualTypes hub with explicit T(..) re-exports
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
Previous attempt (stubs + direct imports) broke qualified constructor
references like Generated.ActualTypes.WidgetVersion in Include files —
removing the hub from scope invalidated all qualified names through it.

New approach: rewrite Generated.ActualTypes.hs in postUnpack to replace
the `module M` export list with explicit T(..) re-exports. Explicit
re-exports store only name references in the .hi file (compact), while
`module M` embeds the full sub-interface (~287 MB for 61 modules). Hub
stays functional — consumers still qualify via Generated.ActualTypes.

Also deduplicate with sort -u in case PrimaryKeys and entity files both
declare the same ID type.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 23:04:57 +02:00
881fef28cc fix(build): stub ActualTypes hub + patch importers to avoid 274 MB .hi crash
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
Generated.ActualTypes uses `module M` re-export syntax for 61 sub-modules;
GHC 9.10.3 embeds all 61 full sub-interfaces into ActualTypes.hi (~287 MB),
hitting the binary-deserialization limit at position 287686318.

Revert Cabal sub-library split (did not help — models-inner also crashed
with only 61 modules at the same invariant position). Apply the same fix
already working for Generated.Types in inter-hub-lib:

- inter-hub-models postUnpack: stub Generated.ActualTypes.hs + Generated.Types.hs
  to empty modules; patch every importer with direct sub-module imports (reads
  original ActualTypes.hs before stubbing to build the replacement import list)
- inter-hub-lib postUnpack: same for both hubs (each package has its own
  sourceRoot with originals intact)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 22:34:09 +02:00
ce18636038 fix(nix): cabal-version 3.0 for sublibrary dependency syntax
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
cabal-version: 2.2 does not support the pkg:sublibrary reference
syntax. Bump to 3.0 which explicitly supports it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 22:18:03 +02:00
5378eb881e fix(nix): split inter-hub-models into two Cabal library components
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
GHC 9.10.3 crashes with Data.Binary.Get.runGet at position 287686318
invariantly when compiling all 476 inter-hub-models modules in a single
--make invocation. Split into two library components to force two
separate GHC compilations:

  models-inner (~63 modules): Generated.ActualTypes.* + Generated.Enums
    Pure type definitions; zero inter-hub-models dependencies.
  main library (~413 modules): entity ops + Include instances
    Depends on models-inner.

Longer-term this is the right architecture: explicit boundaries reduce
build cost, isolate changes, and make diagnostics cheaper.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 21:51:47 +02:00
dfd8582095 fix(nix): strip module-M re-export syntax from Generated.ActualTypes
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
Generated.ActualTypes uses "module M" for 61 sub-modules, causing GHC
to embed each sub-interface verbatim into ActualTypes.hi. That file hits
the GHC 9.10.3 Data.Binary.Get 274 MB limit (position 287686318) when
WidgetVersionInclude reads it during inter-hub-models compilation.

Removing the explicit (module M, ...) export list keeps the same
re-export semantics (no explicit list = export all imports) but forces
GHC to store compact name-reference entries instead of embedded copies.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 16:48:56 +02:00
d6de73ed61 fix(build): escape \${_k} as ''\${_k} in Nix ''...'' string
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
Nix ''...'' strings interpolate \${...} — use ''$ to produce a literal
dollar sign so bash sees TypesPart\${_k}.hs not Nix interpolation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-30 23:20:14 +02:00
5b144b6b96 fix(build): 8-way split + eliminate Generated.Types re-export hub
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
Root cause: any module re-exporting all 119 IHP entities produces a .hi
file ≥ 287 MB, crashing GHC 9.10.3 Data.Binary.Get at exactly position
287,686,318 — even after 4-way split (30 entities × 9.6 MB/entity = 287 MB).

Fix:
- 8-way split of Generated.Types (~15 entities each, ~144 MB .hi — safe)
- Generated.Types replaced with empty stub, removed from exposed-modules
  (any re-export hub for 119 entities → ~1.1 GB .hi → crash downstream)
- pname == "inter-hub-lib" postUnpack patches all 148 `import Generated.Types`
  lines to import Generated.TypesPart1 through TypesPart8 directly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-30 23:18:52 +02:00
c8c6c5c68b fix(build): 4-way split of Generated.Types to stay under 287 MB .hi limit
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
2-way split (60 entities per part) still crashes: TypesPart1.hi itself
reaches 287 MB due to mandatory type-class instance data per IHP entity.
4-way split (~30 entities each, ~150 MB .hi) stays safely under the limit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-30 22:52:10 +02:00
1011557874 fix(build): configureFlags is a list, use ++ not + for -O0 flag
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
2026-04-30 22:38:17 +02:00
c03badc9dd fix(build): force -O0 via configureFlags.ghc-option (cabal ghc-options not reliable in postUnpack) 2026-04-30 22:36:40 +02:00
0f73061d41 fix(build): add ghc-options -O0 to inter-hub-models — strips unfoldings from .hi files, keeps them under GHC 9.10.3 287MB binary limit
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
2026-04-30 17:15:51 +02:00
df1d3fe118 fix(build): fix 8-space indent for TypesPart1/2 cabal entries (Cabal rejects 4-space)
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
2026-04-30 17:01:02 +02:00
3283ad62ee fix(nix): intercept callCabal2nix to patch inter-hub-models
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
Previous attempt failed: inter-hub-models is not a named attribute in
haskellPackages (IHP creates it via callCabal2nix locally), so the
hasAttr guard bailed silently.

New approach: override callCabal2nix itself. When called with
name == "inter-hub-models", inject a postUnpack phase that copies
TypesPart1/TypesPart2 into the build sandbox and replaces Types.hs
with the thin wrapper. Applied to both haskellPackages and
haskell.packages.ghc910 to cover whichever set IHP uses.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-30 00:38:12 +02:00
9cbf4caadf fix(nix): fix GHC 9.10.3 interface-file crash and binary name
Generated.Types imports 119 modules, pushing the combined .hi read past
a ~287 MB binary-deserialization limit in GHC 9.10.3. Fix by adding a
nixpkgs overlay that patches the inter-hub-models derivation: replaces
Generated/Types.hs with a thin TypesPart1/TypesPart2 re-export wrapper
after build-generated-code runs, and adds the two split modules to the
cabal exposed-modules list.

Also fix the production binary name from /bin/App to /bin/RunProdServer
in deployment.yaml and RUNBOOK.md (the IHP NixSupport build produces
RunProdServer, not App). Switch packages.docker to IHP's built-in
unoptimized-docker-image which already uses the correct binary path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-29 23:16:44 +02:00
3fc99d17ec fix(WP-0018/R1): correct binary name in docker CMD to /bin/App
Some checks failed
Test / test (push) Has been cancelled
IHP cabal executable is named 'App' (not 'inter-hub'), matching the
executable declaration in App.cabal.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-29 17:27:57 +02:00
df181d1dec feat(WP-0018/R1): add OCI container image build to flake.nix
Some checks failed
Test / test (push) Has been cancelled
packages.docker using dockerTools.buildLayeredImage wraps the IHP
production binary with cacert for Anthropic API calls. Push target:
92.205.130.254:32166/coulomb/inter-hub:TAG via skopeo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-29 16:07:27 +02:00
ce42607fca fix(WP-0014/A2): close remaining pure-param and structural compilation errors
Convert all remaining `<- paramOrNothing / param / paramOrDefault /
currentUserOrNothing` monadic binds to `let` — these functions are pure
(ImplicitParams-based) in IHP v1.5, so `<-` is a type error in an IO
do-block.

Controllers fixed:
  AgentDelegations, AiGovernancePolicies, Annotations, ApiConsumers,
  CollectiveProposals, DecisionRecords, DeploymentRecords,
  HubCapabilityManifests, HubRoutingRules, InstitutionalKnowledge,
  OutcomeCorrelations, RequirementCandidates, TypeRegistries,
  WebhookSubscriptions, Widgets,
  Api/V2/{Annotations,InteractionEvents,Token}

WebhookSubscriptions: remove orphaned `Right () ->` case arm that was
left inside a bare `unless` block (structural parse error).

Also carries forward all in-progress fixes from the working tree:
  helpers (AgentBridge, ApiRateLimit, BottleneckDetector,
            CrossHubPropagation, FrictionScore),
  views (CanSelect instances, HSX lambda extraction, formFor wrappers),
  env/build (envrc GHCi perms, flake.nix Tailwind + GHC resource limits,
             static/app.css additional Tailwind output).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-10 01:14:08 +00:00
f1978c3888 fix(WP-0014): pre-flight compilation fixes, Tailwind pipeline, and admin seed
A2 — Compilation fixes:
- Remove inline FK constraints from Schema.sql; IHP schema compiler cannot
  parse them. Add 1744329600-restore-fk-constraints.sql migration to restore
  referential integrity at the DB level.
- Rename `#label` → `#label_` throughout to avoid clash with Haskell built-in.
- Fix `hub.id == hid` UUID comparisons to use `toUUID hub.id`.
- Replace non-existent `setStatus`/`respondJson` calls with
  `renderJsonWithStatusCode` throughout Api controllers.
- Fix qualified package import for `cryptohash-sha256` in Auth.hs.
- Add `CanSelect (Text, Text)` instance in Helper.View.
- Refactor HSX inline lambdas to named helper functions in 100+ views
  (GHC cannot infer types for anonymous functions inside quasi-quoted HSX).
- Fix missing imports (IHP.QueryBuilder, IHP.Fetch, Web.Routes, Only, etc.)
  across helpers and controllers.
- Remove duplicate `diffUTCTime` definition in BottleneckDetector.
- Change `createEventForHub` return type from `IO ResponseReceived` to `IO ()`.
- Seed type-registry vocabulary via 1744502400-seed-type-registries.sql
  (moved from Schema.sql where IHP does not execute INSERT statements).

A3 — Tailwind build pipeline:
- Add `tailwindcss` to flake.nix native packages.
- Uncomment `tailwind.exec` process in devenv shell config.
- Add tailwind/tailwind.config.js (scans Web/View/**/*.hs).
- Add tailwind/app.css with @tailwind directives.

A4 — Admin user seed:
- Add 1744416000-seed-admin-user.sql: inserts admin@inter-hub.local
  with bcrypt-hashed password admin1234! (cost 10).
- Add .env.example documenting all required environment variables
  and default admin credentials.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 09:55:12 +00:00
3cac021213 feat(WP-0010): IHF Phase 9 — External API Surface and Consumer SDKs
Some checks failed
Test / test (push) Has been cancelled
Delivers the full Phase 9 external API layer:

- Versioned REST API (/api/v2/) with OpenAPI 3.1 spec; enum arrays for
  widget_type, event_type, annotation category drawn live from registry tables
- OAuth 2.0 client credentials flow (/api/v2/token); hub:*:write scopes
  gated on active HubCapabilityManifest FK
- API key management: SHA256-hashed tokens, key_prefix for display,
  one-time reveal on creation, revocation support
- TypeScript and Python consumer SDKs generated from registry tables
  (/api/v2/sdk/ihf-client.ts, /api/v2/sdk/ihf-client.py)
- Webhook delivery: HMAC-SHA256 signing, append-only webhook_deliveries,
  fire-and-forget dispatch via forkIO, 3-retry logic
- Admin API dashboard with 24h stats (request count, error rate, last seen)
- Rate limiting (per-minute) and daily quota enforcement via api_request_log
- Schema migration: api_consumers, api_keys, webhook_subscriptions (CHECK
  constraint on 6 framework lifecycle topics), webhook_deliveries
  (append-only trigger), api_request_log
- ARCHITECTURE-LAYERS.md scorecard: 3.34 → 3.41 (approaching Strong)
- contracts/functional/interaction-reporting-v1.md extended with Phase 9
  endpoint catalogue and 422 validation error format

GAAF: no bare TEXT discriminators; webhook event_type uses CHECK constraint
over 6 allowed framework lifecycle topic strings (not widget event types).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 19:52:20 +00:00
2605c1c977 feat(P5): IHF Phase 5 complete — agent-assisted distillation
Some checks failed
Test / test (push) Has been cancelled
Adds bounded AI support to the IHF governance loop. All AI outputs are
attributed (model_ref), reviewable (AgentReviewRecord), and reversible.
No autonomous decisions; no silent requirement promotion.

- T01: Schema — agent_proposals, agent_review_records,
  confidence_annotations (migration 1743379200)
- T02: AgentProposalsController (index/show/accept/reject, idempotent
  review guard), global nav "Agent" link
- T03: SummarizeClusterAction — Claude API cluster summary on widget show
- T04: DraftRequirementAction — AI requirement draft; acceptance creates
  RequirementCandidate (human-gated)
- T05: DetectDuplicatesAction — duplicate_flag proposal on candidate show
- T06: DetectPolicySensitivityAction — policy_flag with
  ConfidenceAnnotations per concern scope
- T07: ProposeImplementationAction — impl_proposal from decision show
- T08: AgentAuditDashboardAction — autoRefresh; KPI row, unreviewed queue,
  recent proposals, attribution log matrix
- T09: integration tests, SCOPE.md updated, phase5-summary.md, flake.nix
  adds http-conduit/aeson/string-conversions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-29 15:54:33 +00:00
ff11913d5c feat(T01): bootstrap IHP v1.5 project scaffold
Merged ihp-new generated scaffold into repo. Sets appName to inter-hub,
adds Nix flake with IHP inputs, devenv config, and standard IHP project
structure. Nix + ihp-new + direnv installed system-wide.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 01:36:18 +00:00