feat(WP-0016/C1-C4): Layer 2 isolation and clean-base infrastructure

- Add Web/Controller/Prelude.hs (was missing; 8 controllers failed to import it)
- Add .ghci-core and scripts/compile-check-core to compile Layer 1+2 in
  isolation without loading Main.hs or any controller/view (Layer 3)
- Fix Application/Helper/BottleneckDetector.hs: replace coerce :: Id' -> UUID
  with unpackId (IHP Id' wraps a type family; Data.Coerce cannot cross it)
- Fix devenv.nix: add pkgs.nodePackages.tailwindcss so devenv process scripts
  find the tailwindcss binary (devenv v2 builds scripts with only local packages)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-10 15:38:01 +00:00
parent 3d2e8ec9e1
commit 64a9d4eeb4
5 changed files with 128 additions and 9 deletions

View File

@@ -8,7 +8,6 @@ import Generated.Types
import Web.Routes ()
import Data.Time.Clock (addUTCTime, getCurrentTime, NominalDiffTime)
import Database.PostgreSQL.Simple (Only(..))
import Data.Coerce (coerce)
-- | Severity based on how much older than the threshold the record is.
staleSeverity :: NominalDiffTime -> NominalDiffTime -> Text
@@ -47,7 +46,7 @@ detectBottlenecks hubId hubWidgets candidates requirements decisions deployments
| c <- candidates
, c.status == "open"
, c.createdAt < addUTCTime (negate candidateThreshold) now
, c.id `notElem` map coerce existingSubjects
, unpackId c.id `notElem` existingSubjects
]
-- Stage 2: requirements with no decision older than 60 days
@@ -57,7 +56,7 @@ detectBottlenecks hubId hubWidgets candidates requirements decisions deployments
| r <- requirements
, r.createdAt < addUTCTime (negate requirementThreshold) now
, r.id `notElem` linkedReqIds
, r.id `notElem` map coerce existingSubjects
, unpackId r.id `notElem` existingSubjects
]
-- Stage 3: decisions with no deployment older than 30 days
@@ -67,7 +66,7 @@ detectBottlenecks hubId hubWidgets candidates requirements decisions deployments
| d <- decisions
, d.decidedAt < addUTCTime (negate decisionThreshold) now
, d.id `notElem` linkedDecisionIds
, d.id `notElem` map coerce existingSubjects
, unpackId d.id `notElem` existingSubjects
]
-- Stage 4: deployments with no outcome signal older than 14 days
@@ -80,7 +79,7 @@ detectBottlenecks hubId hubWidgets candidates requirements decisions deployments
| dep <- deployments
, dep.deployedAt < addUTCTime (negate observationThreshold) now
, not (any (\wid -> wid `elem` signalWids) widgetIdSet)
, dep.id `notElem` map coerce existingSubjects
, unpackId dep.id `notElem` existingSubjects
]
let mkBottleneck stage subjType subjId stalledSince threshold = do
@@ -95,10 +94,10 @@ detectBottlenecks hubId hubWidgets candidates requirements decisions deployments
|> set #severity severity
|> createRecord
r1 <- mapM (\(c, t) -> mkBottleneck "candidate" "RequirementCandidate" (coerce c.id :: UUID) t candidateThreshold) staleCandidates
r2 <- mapM (\(r, t) -> mkBottleneck "requirement" "Requirement" (coerce r.id :: UUID) t requirementThreshold) stalRequirements
r3 <- mapM (\(d, t) -> mkBottleneck "decision" "DecisionRecord" (coerce d.id :: UUID) t decisionThreshold) staleDecisions
r4 <- mapM (\(d, t) -> mkBottleneck "observation" "DeploymentRecord" (coerce d.id :: UUID) t observationThreshold) staleDeployments
r1 <- mapM (\(c, t) -> mkBottleneck "candidate" "RequirementCandidate" (unpackId c.id) t candidateThreshold) staleCandidates
r2 <- mapM (\(r, t) -> mkBottleneck "requirement" "Requirement" (unpackId r.id) t requirementThreshold) stalRequirements
r3 <- mapM (\(d, t) -> mkBottleneck "decision" "DecisionRecord" (unpackId d.id) t decisionThreshold) staleDecisions
r4 <- mapM (\(d, t) -> mkBottleneck "observation" "DeploymentRecord" (unpackId d.id) t observationThreshold) staleDeployments
pure (r1 <> r2 <> r3 <> r4)