2026-03-27 01:36:18 +00:00
{
inputs = {
ihp . url = " g i t h u b : d i g i t a l l y i n d u c e d / i h p / v 1 . 5 " ;
nixpkgs . follows = " i h p / n i x p k g s " ;
nixpkgs-nixos . follows = " i h p / n i x p k g s - n i x o s " ;
flake-parts . follows = " i h p / f l a k e - p a r t s " ;
devenv . follows = " i h p / d e v e n v " ;
systems . follows = " i h p / s y s t e m s " ;
devenv-root = {
url = " f i l e + f i l e : / / / d e v / n u l l " ;
flake = false ;
} ;
} ;
outputs = inputs @ { self , nixpkgs , nixpkgs-nixos , ihp , flake-parts , systems , . . . }:
flake-parts . lib . mkFlake { inherit inputs ; } {
systems = import systems ;
imports = [ ihp . flakeModules . default ] ;
2026-04-30 17:01:02 +02:00
perSystem = { pkgs , config , lib , . . . }: {
2026-03-27 01:36:18 +00:00
ihp = {
appName = " i n t e r - h u b " ;
enable = true ;
projectPath = ./. ;
packages = with pkgs ; [
2026-04-04 09:55:12 +00:00
tailwindcss
2026-03-27 01:36:18 +00:00
] ;
haskellPackages = p : with p ; [
# Haskell dependencies go here
p . ihp
base
wai
text
# ihp-mail # Email support: https://ihp.digitallyinduced.com/Guide/mail.html
# ihp-datasync # Real-time DataSync
# ihp-job-dashboard # Job dashboard UI
# ihp-typed-sql # Type-safe SQL queries
# ihp-pglistener # PostgreSQL LISTEN/NOTIFY
feat(P5): IHF Phase 5 complete — agent-assisted distillation
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
# Phase 5: Anthropic API calls
http-conduit
aeson
string-conversions
feat(WP-0010): IHF Phase 9 — External API Surface and Consumer SDKs
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
# Phase 9: External API, crypto, SDK generation
cryptohash-sha256
base16-bytestring
random-bytestring
yaml
network-uri
2026-03-27 01:36:18 +00:00
] ;
devHaskellPackages = p : with p ; [
cabal-install
hlint
hspec
ihp-hspec
] ;
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
# Hoogle documentation server — disabled to save ~400 MB on constrained host
withHoogle = false ;
2026-03-27 01:36:18 +00:00
# Disable relation type machinery for faster compilation
# relationSupport = false;
# Skip tests/haddock for specific packages to speed up builds
# dontCheckPackages = [ "my-package" ];
# doJailbreakPackages = [ "my-package" ];
# dontHaddockPackages = [ "my-package" ];
# Production build tuning
# optimizationLevel = "2"; # Default: "1", use "2" for more optimized production binaries
# rtsFlags = "-A96m -N"; # GHC runtime flags for compiled binaries
# Mount additional directories under /static/ in production builds
# static.extraDirs = {
# # Frontend = self.packages.${system}.frontend;
# };
# static.makeBundling = true; # Set false if not using Makefile for CSS/JS bundling
} ;
2026-04-29 23:16:44 +02:00
# OCI container image for Kubernetes deployment (Railiance01).
2026-04-29 16:07:27 +02:00
# Build: nix build .#docker
2026-04-29 23:16:44 +02:00
# Push: skopeo copy docker-archive:result docker://92.205.130.254:32166/coulomb/inter-hub:SHA
# Uses IHP's built-in unoptimized image; binary is /bin/RunProdServer.
packages . docker = config . packages . unoptimized-docker-image ;
2026-04-29 16:07:27 +02:00
2026-03-27 01:36:18 +00:00
# Custom configuration that will start with `devenv up`
devenv . shells . default = {
# Start Mailhog on local development to catch outgoing emails
# services.mailhog.enable = true;
# PostgreSQL extensions
# services.postgres.extensions = extensions: [ extensions.postgis ];
2026-04-30 17:01:02 +02:00
# GHC 9.10.3 crash fix: Generated.Types imports 119 modules, exceeding
# the ~287 MB interface-file binary-deserialization limit.
#
# pkgs is built from `import nixpkgs { overlays = devenv.shells.default.overlays; }`.
# IHP adds ihp.overlays.default to this list, which sets
# pkgs.ghc = haskellPackages.override { overrides = ihpOverrides }.
# We extend pkgs.ghc with a mkDerivation override (lib.mkAfter ensures
# we run after IHP's overlay, so prev.ghc is already IHP's package set).
2026-04-30 22:52:10 +02:00
# 2-way split (60 entities) still crashes — TypesPart1.hi itself hits 287 MB.
# 4-way split (~30 entities, ~150 MB .hi each) stays safely under the limit.
2026-04-30 17:01:02 +02:00
# When pname == "inter-hub-models", postUnpack replaces the monolithic
2026-04-30 22:52:10 +02:00
# Types.hs with a thin re-export wrapper and adds TypesPart1-4 to cabal.
2026-04-30 17:01:02 +02:00
overlays = lib . mkAfter [
( final : prev : {
ghc = prev . ghc . extend ( hfinal : hprev : {
mkDerivation = args :
let drv = hprev . mkDerivation args ;
in if ( args . pname or " " ) = = " i n t e r - h u b - m o d e l s "
then drv . overrideAttrs ( old : {
2026-04-30 22:52:10 +02:00
# Splits Generated.Types (119 imports, ~287 MB .hi overflow in GHC 9.10.3)
# into four quarters (~30 entities each, ~150 MB .hi — safely under limit).
# -O0 strips unfoldings/specialisations for additional .hi size reduction.
2026-04-30 22:38:17 +02:00
configureFlags = ( old . configureFlags or [ ] ) ++ [ " - - g h c - o p t i o n = - O 0 " ] ;
2026-04-30 17:01:02 +02:00
postUnpack = ( old . postUnpack or " " ) + ''
_types = " $ s o u r c e R o o t / b u i l d / G e n e r a t e d / T y p e s . h s "
2026-04-30 22:52:10 +02:00
# TypesPart1: first quarter (~30 entities)
2026-04-30 17:01:02 +02:00
awk ' BEGIN { n = 0 } / ^ import Generated \ . / { n ++ ; mods [ n ] = $ 2 } END {
2026-04-30 22:52:10 +02:00
q = int ( n/4 ) + 1
2026-04-30 17:01:02 +02:00
print " m o d u l e G e n e r a t e d . T y p e s P a r t 1 ( "
2026-04-30 22:52:10 +02:00
for ( i = 1 ; i <= q ; i ++ ) {
if ( i < q ) print " m o d u l e " mods [ i ] " , "
else print " m o d u l e " mods [ i ]
2026-04-30 17:01:02 +02:00
}
print " ) w h e r e "
2026-04-30 22:52:10 +02:00
for ( i = 1 ; i <= q ; i ++ ) print " i m p o r t " mods [ i ]
2026-04-30 17:01:02 +02:00
} ' " $ _ t y p e s " > " $ s o u r c e R o o t / b u i l d / G e n e r a t e d / T y p e s P a r t 1 . h s "
2026-04-30 22:52:10 +02:00
# TypesPart2: second quarter
2026-04-30 17:01:02 +02:00
awk ' BEGIN { n = 0 } / ^ import Generated \ . / { n ++ ; mods [ n ] = $ 2 } END {
2026-04-30 22:52:10 +02:00
q1 = int ( n/4 ) + 1 ; q2 = int ( n/2 ) + 1
2026-04-30 17:01:02 +02:00
print " m o d u l e G e n e r a t e d . T y p e s P a r t 2 ( "
2026-04-30 22:52:10 +02:00
for ( i = q1 + 1 ; i <= q2 ; i ++ ) {
if ( i < q2 ) print " m o d u l e " mods [ i ] " , "
else print " m o d u l e " mods [ i ]
}
print " ) w h e r e "
for ( i = q1 + 1 ; i <= q2 ; i ++ ) print " i m p o r t " mods [ i ]
} ' " $ _ t y p e s " > " $ s o u r c e R o o t / b u i l d / G e n e r a t e d / T y p e s P a r t 2 . h s "
# TypesPart3: third quarter
awk ' BEGIN { n = 0 } / ^ import Generated \ . / { n ++ ; mods [ n ] = $ 2 } END {
q2 = int ( n/2 ) + 1 ; q3 = int ( 3 * n/4 ) + 1
print " m o d u l e G e n e r a t e d . T y p e s P a r t 3 ( "
for ( i = q2 + 1 ; i <= q3 ; i ++ ) {
if ( i < q3 ) print " m o d u l e " mods [ i ] " , "
else print " m o d u l e " mods [ i ]
}
print " ) w h e r e "
for ( i = q2 + 1 ; i <= q3 ; i ++ ) print " i m p o r t " mods [ i ]
} ' " $ _ t y p e s " > " $ s o u r c e R o o t / b u i l d / G e n e r a t e d / T y p e s P a r t 3 . h s "
# TypesPart4: fourth quarter
awk ' BEGIN { n = 0 } / ^ import Generated \ . / { n ++ ; mods [ n ] = $ 2 } END {
q3 = int ( 3 * n/4 ) + 1
print " m o d u l e G e n e r a t e d . T y p e s P a r t 4 ( "
for ( i = q3 + 1 ; i <= n ; i ++ ) {
2026-04-30 17:01:02 +02:00
if ( i < n ) print " m o d u l e " mods [ i ] " , "
else print " m o d u l e " mods [ i ]
}
print " ) w h e r e "
2026-04-30 22:52:10 +02:00
for ( i = q3 + 1 ; i <= n ; i ++ ) print " i m p o r t " mods [ i ]
} ' " $ _ t y p e s " > " $ s o u r c e R o o t / b u i l d / G e n e r a t e d / T y p e s P a r t 4 . h s "
2026-04-30 17:01:02 +02:00
# Thin wrapper replaces the monolithic Types.hs
printf ' % s \ n' \
' module Generated . Types ( ' \
' module Generated . TypesPart1 , ' \
2026-04-30 22:52:10 +02:00
' module Generated . TypesPart2 , ' \
' module Generated . TypesPart3 , ' \
' module Generated . TypesPart4' \
2026-04-30 17:01:02 +02:00
' ) where' \
' import Generated . TypesPart1' \
' import Generated . TypesPart2' \
2026-04-30 22:52:10 +02:00
' import Generated . TypesPart3' \
' import Generated . TypesPart4' \
2026-04-30 17:01:02 +02:00
> " $ _ t y p e s "
2026-04-30 22:52:10 +02:00
# Add TypesPart1-4 to cabal exposed-modules.
# 8-space indent: 4-space would be parsed as a new stanza field.
2026-04-30 17:01:02 +02:00
_cabal = $ ( ls " $ s o u r c e R o o t " /* . c a b a l | h e a d - 1 )
if ! grep - q ' Generated \ . TypesPart1' " $ _ c a b a l " ; then
2026-04-30 17:15:51 +02:00
awk ' / ^ exposed-modules:/ {
print " g h c - o p t i o n s : - O 0 "
print
next
} /Generated \ . LearningInsightInclude / {
2026-04-30 17:01:02 +02:00
print
print " G e n e r a t e d . T y p e s P a r t 1 "
print " G e n e r a t e d . T y p e s P a r t 2 "
2026-04-30 22:52:10 +02:00
print " G e n e r a t e d . T y p e s P a r t 3 "
print " G e n e r a t e d . T y p e s P a r t 4 "
2026-04-30 17:01:02 +02:00
next
} { print } ' " $ _ c a b a l " > " $ _ c a b a l . n e w "
mv " $ _ c a b a l . n e w " " $ _ c a b a l "
fi
'' ;
} )
else drv ;
} ) ;
} )
] ;
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
# Resource limits for constrained host (2 CPU, ~3.8 GiB RAM).
# -A32m: smaller minor heap (reduces GC pressure).
# -M2g: hard heap ceiling (prevents OOM on large compiles).
# Note: -N1 is intentionally omitted — it requires -threaded and
# would break build-generated-code and similar tools.
# GHC parallel module compilation is capped via -j1 in .ghci.
env . GHCRTS = " - A 3 2 m - M 2 g " ;
2026-03-27 01:36:18 +00:00
# Custom processes that don't appear in https://devenv.sh/reference/options/
processes = {
2026-04-04 09:55:12 +00:00
tailwind . exec = " t a i l w i n d c s s - c t a i l w i n d / t a i l w i n d . c o n f i g . j s - i . / t a i l w i n d / a p p . c s s - o s t a t i c / a p p . c s s - - w a t c h = a l w a y s " ;
2026-03-27 01:36:18 +00:00
} ;
} ;
} ;
# Adding the new NixOS configuration for "production"
# See https://ihp.digitallyinduced.com/Guide/deployment.html#deploying-with-deploytonixos for more info
# Used to deploy the IHP application
flake . nixosConfigurations . " p r o d u c t i o n " = import ./Config/nix/hosts/production/host.nix { inherit inputs ; } ;
} ;
# The following configuration speeds up build times by using the devenv, cachix and digitallyinduced binary caches
# You can add your own cachix cache here to speed up builds. For that uncomment the following lines and replace `CHANGE-ME` with your cachix cache name
nixConfig = {
extra-substituters = [
" h t t p s : / / d e v e n v . c a c h i x . o r g "
" h t t p s : / / c a c h i x . c a c h i x . o r g "
" h t t p s : / / d i g i t a l l y i n d u c e d . c a c h i x . o r g "
# "https://CHANGE-ME.cachix.org"
] ;
extra-trusted-public-keys = [
" d e v e n v . c a c h i x . o r g - 1 : w 1 c L U i 8 d v 3 h n o S P G A u i b Q v + f 9 T Z L r 6 c v / H m 9 X g U 5 0 c w = "
" c a c h i x . c a c h i x . o r g - 1 : e W N H Q l d w U O 7 G 2 V k j p n j D b W w y 4 K Q / H N x h t 7 H 4 S S o M c k M = "
" d i g i t a l l y i n d u c e d . c a c h i x . o r g - 1 : y + w Q v r n x Q + P d E s C t 9 1 r m v v 3 9 q R C Y z E g G Q a l d K 2 6 h C K E = "
# "CHANGE-ME.cachix.org-1:CHANGE-ME-PUBLIC-KEY"
] ;
} ;
}