generated from coulomb/repo-seed
Closes the long-range feedback loop: outcome signals now enrich the full
traceability chain and feed back into routing, triage, and AI proposals.
Schema (T01):
- outcome_correlations (CHECK correlation_type)
- pattern_performance_records
- adaptive_threshold_configs
- institutional_knowledge_entries (GIN tsvector FTS)
- learning_insights (CHECK insight_type)
- ALTER TABLE decision_records + requirement_candidates: outcome_summary JSONB
- AFTER INSERT trigger trg_enrich_lineage on outcome_signals
- contracts/core/ updated (outcome-summary-columns-v1, append-only addendum)
Correlation engine (T02):
- Application/Helper/CorrelationEngine.hs: pure annotation→outcome SQL
- Web/Controller/OutcomeCorrelations.hs: ComputeCorrelationsAction + index
Pattern performance (T03):
- Web/Controller/PatternPerformance.hs: ComputePatternPerformanceAction
Adaptive thresholds (T04):
- Web/Controller/AdaptiveThresholds.hs: CalibrateThresholdsAction
- Application/Helper/FrictionScore.hs: applyAdaptiveWeights
Institutional knowledge (T05):
- DistilDecisionAction in DecisionRecords controller
- Web/Controller/InstitutionalKnowledge.hs: QueryKnowledgeBaseAction
Lineage enrichment (T06):
- Web/Controller/LineageEnrichment.hs: EnrichLineageAction (batch backfill)
- enrich_lineage_on_outcome_batch() PL/pgSQL helper in migration
Learning dashboard (T07):
- Web/Controller/LearningDashboard.hs: 5-panel autoRefresh view
- "Learning" nav link in FrontController
API v2 learning endpoints (T08):
- GET /api/v2/outcome-correlations, /pattern-performance, /knowledge-base/{id}
- OpenAPI schemas: OutcomeCorrelation, PatternPerformanceRecord, InstitutionalKnowledgeEntry
GAAF scorecard + docs (T09):
- Core 3.8→3.9, Functional 3.6→3.8, overall 3.61→3.68
- CLAUDE.md: IHF v0.2 complete, no active workplan
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
303 lines
12 KiB
Haskell
303 lines
12 KiB
Haskell
module Web.Routes where
|
|
|
|
import IHP.RouterPrelude
|
|
import Generated.Types
|
|
import Web.Types
|
|
|
|
-- Hubs
|
|
instance AutoRoute HubsController
|
|
|
|
-- Widgets
|
|
instance AutoRoute WidgetsController
|
|
|
|
-- Interaction Events (POST /widgets/:widgetId/events)
|
|
instance AutoRoute InteractionEventsController
|
|
|
|
-- Annotations (scoped to widget: /widgets/:widgetId/annotations/)
|
|
instance AutoRoute AnnotationsController
|
|
|
|
-- Annotation Threads (scoped to widget)
|
|
instance AutoRoute AnnotationThreadsController
|
|
|
|
-- Requirement Candidates
|
|
instance AutoRoute RequirementCandidatesController
|
|
|
|
-- Requirements (Phase 3)
|
|
instance AutoRoute RequirementsController
|
|
|
|
-- Decision Records (Phase 3)
|
|
instance AutoRoute DecisionRecordsController
|
|
|
|
-- Deployment Records (Phase 4)
|
|
instance AutoRoute DeploymentRecordsController
|
|
|
|
-- Agent Proposals (Phase 5)
|
|
instance AutoRoute AgentProposalsController
|
|
|
|
-- Phase 6 — Cross-Framework UI Adaptation
|
|
|
|
-- API endpoint: POST /api/v1/interaction-events
|
|
instance CanRoute ApiInteractionEventsController where
|
|
parseRoute' = do
|
|
_ <- string "/api"
|
|
_ <- string "/v1"
|
|
_ <- string "/interaction-events"
|
|
endOfInput
|
|
pure CreateApiInteractionEventAction
|
|
|
|
instance HasPath ApiInteractionEventsController where
|
|
pathTo CreateApiInteractionEventAction = "/api/v1/interaction-events"
|
|
|
|
instance AutoRoute EnvelopeEmissionContractsController
|
|
instance AutoRoute InteractionReportingContractsController
|
|
instance AutoRoute WidgetAdapterSpecsController
|
|
|
|
-- Phase 7 — Advanced Observability
|
|
instance AutoRoute CrossHubPropagationsController
|
|
|
|
-- Phase 8 — Federated Hub Maturity
|
|
instance AutoRoute WidgetOwnershipsController
|
|
instance AutoRoute HubRoutingRulesController
|
|
instance AutoRoute FederatedPolicyOverlaysController
|
|
instance AutoRoute StewardshipRolesController
|
|
instance AutoRoute ArchiveRecordsController
|
|
instance AutoRoute FederatedGovernanceController
|
|
|
|
-- GAAF Compliance Foundation (IHUB-WP-0009)
|
|
instance AutoRoute TypeRegistriesController
|
|
instance AutoRoute HubCapabilityManifestsController
|
|
|
|
-- Phase 9 — External API Surface (IHUB-WP-0010)
|
|
|
|
-- Admin: API consumers, keys, webhooks, dashboard
|
|
instance AutoRoute ApiConsumersController
|
|
instance AutoRoute ApiKeysController
|
|
instance AutoRoute WebhookSubscriptionsController
|
|
instance AutoRoute ApiDashboardController
|
|
|
|
-- /api/v2/ REST endpoints (manual routing for versioned prefix)
|
|
|
|
instance CanRoute ApiV2WidgetsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/widgets"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexWidgetsAction
|
|
, do _ <- string "/"; wId <- parseUUID; endOfInput
|
|
pure ApiV2ShowWidgetAction { widgetId = Id wId }
|
|
]
|
|
|
|
instance HasPath ApiV2WidgetsController where
|
|
pathTo ApiV2IndexWidgetsAction = "/api/v2/widgets"
|
|
pathTo ApiV2ShowWidgetAction { widgetId } = "/api/v2/widgets/" <> show widgetId
|
|
|
|
instance CanRoute ApiV2InteractionEventsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/interaction-events"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexInteractionEventsAction
|
|
, do _ <- string "/"; eId <- parseUUID; endOfInput
|
|
pure ApiV2ShowInteractionEventAction { interactionEventId = Id eId }
|
|
]
|
|
|
|
instance HasPath ApiV2InteractionEventsController where
|
|
pathTo ApiV2IndexInteractionEventsAction = "/api/v2/interaction-events"
|
|
pathTo ApiV2ShowInteractionEventAction { interactionEventId } = "/api/v2/interaction-events/" <> show interactionEventId
|
|
pathTo ApiV2CreateInteractionEventAction = "/api/v2/interaction-events"
|
|
|
|
instance CanRoute ApiV2AnnotationsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/annotations"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexAnnotationsAction
|
|
, do _ <- string "/"; aId <- parseUUID; endOfInput
|
|
pure ApiV2ShowAnnotationAction { annotationId = Id aId }
|
|
]
|
|
|
|
instance HasPath ApiV2AnnotationsController where
|
|
pathTo ApiV2IndexAnnotationsAction = "/api/v2/annotations"
|
|
pathTo ApiV2ShowAnnotationAction { annotationId } = "/api/v2/annotations/" <> show annotationId
|
|
pathTo ApiV2CreateAnnotationAction = "/api/v2/annotations"
|
|
|
|
instance CanRoute ApiV2RequirementCandidatesController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/requirement-candidates"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexRequirementCandidatesAction
|
|
, do _ <- string "/"; rcId <- parseUUID; endOfInput
|
|
pure ApiV2ShowRequirementCandidateAction { requirementCandidateId = Id rcId }
|
|
]
|
|
|
|
instance HasPath ApiV2RequirementCandidatesController where
|
|
pathTo ApiV2IndexRequirementCandidatesAction = "/api/v2/requirement-candidates"
|
|
pathTo ApiV2ShowRequirementCandidateAction { requirementCandidateId } = "/api/v2/requirement-candidates/" <> show requirementCandidateId
|
|
|
|
instance CanRoute ApiV2DecisionRecordsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/decision-records"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexDecisionRecordsAction
|
|
, do _ <- string "/"; drId <- parseUUID; endOfInput
|
|
pure ApiV2ShowDecisionRecordAction { decisionRecordId = Id drId }
|
|
]
|
|
|
|
instance HasPath ApiV2DecisionRecordsController where
|
|
pathTo ApiV2IndexDecisionRecordsAction = "/api/v2/decision-records"
|
|
pathTo ApiV2ShowDecisionRecordAction { decisionRecordId } = "/api/v2/decision-records/" <> show decisionRecordId
|
|
|
|
instance CanRoute ApiV2DeploymentRecordsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/deployment-records"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexDeploymentRecordsAction
|
|
, do _ <- string "/"; drId <- parseUUID; endOfInput
|
|
pure ApiV2ShowDeploymentRecordAction { deploymentRecordId = Id drId }
|
|
]
|
|
|
|
instance HasPath ApiV2DeploymentRecordsController where
|
|
pathTo ApiV2IndexDeploymentRecordsAction = "/api/v2/deployment-records"
|
|
pathTo ApiV2ShowDeploymentRecordAction { deploymentRecordId } = "/api/v2/deployment-records/" <> show deploymentRecordId
|
|
|
|
instance CanRoute ApiV2OutcomeSignalsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/outcome-signals"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexOutcomeSignalsAction
|
|
, do _ <- string "/"; osId <- parseUUID; endOfInput
|
|
pure ApiV2ShowOutcomeSignalAction { outcomeSignalId = Id osId }
|
|
]
|
|
|
|
instance HasPath ApiV2OutcomeSignalsController where
|
|
pathTo ApiV2IndexOutcomeSignalsAction = "/api/v2/outcome-signals"
|
|
pathTo ApiV2ShowOutcomeSignalAction { outcomeSignalId } = "/api/v2/outcome-signals/" <> show outcomeSignalId
|
|
|
|
instance CanRoute ApiV2RegistriesController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/"
|
|
choice
|
|
[ do _ <- string "widget-types"; endOfInput; pure ApiV2ListWidgetTypesAction
|
|
, do _ <- string "event-types"; endOfInput; pure ApiV2ListEventTypesAction
|
|
, do _ <- string "annotation-categories"; endOfInput; pure ApiV2ListAnnotationCategoriesAction
|
|
]
|
|
|
|
instance HasPath ApiV2RegistriesController where
|
|
pathTo ApiV2ListWidgetTypesAction = "/api/v2/widget-types"
|
|
pathTo ApiV2ListEventTypesAction = "/api/v2/event-types"
|
|
pathTo ApiV2ListAnnotationCategoriesAction = "/api/v2/annotation-categories"
|
|
|
|
instance CanRoute ApiV2OpenApiController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/"
|
|
choice
|
|
[ do _ <- string "openapi.json"; endOfInput; pure ApiV2OpenApiJsonAction
|
|
, do _ <- string "openapi.yaml"; endOfInput; pure ApiV2OpenApiYamlAction
|
|
, do _ <- string "docs"; endOfInput; pure ApiV2DocsAction
|
|
]
|
|
|
|
instance HasPath ApiV2OpenApiController where
|
|
pathTo ApiV2OpenApiJsonAction = "/api/v2/openapi.json"
|
|
pathTo ApiV2OpenApiYamlAction = "/api/v2/openapi.yaml"
|
|
pathTo ApiV2DocsAction = "/api/v2/docs"
|
|
|
|
instance CanRoute ApiV2TokenController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/token"
|
|
endOfInput
|
|
pure ApiV2CreateTokenAction
|
|
|
|
instance HasPath ApiV2TokenController where
|
|
pathTo ApiV2CreateTokenAction = "/api/v2/token"
|
|
|
|
instance CanRoute ApiV2SdkController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/sdk"
|
|
choice
|
|
[ do endOfInput; pure ApiV2SdkIndexAction
|
|
, do _ <- string "/ihf-client.ts"; endOfInput; pure ApiV2SdkTsAction
|
|
, do _ <- string "/ihf-client.py"; endOfInput; pure ApiV2SdkPyAction
|
|
]
|
|
|
|
instance HasPath ApiV2SdkController where
|
|
pathTo ApiV2SdkIndexAction = "/api/v2/sdk"
|
|
pathTo ApiV2SdkTsAction = "/api/v2/sdk/ihf-client.ts"
|
|
pathTo ApiV2SdkPyAction = "/api/v2/sdk/ihf-client.py"
|
|
|
|
-- Phase 10 — Hub Registry and Widget Marketplace (IHUB-WP-0011)
|
|
instance AutoRoute HubRegistryController
|
|
instance AutoRoute WidgetPatternsController
|
|
instance AutoRoute GovernanceTemplatesController
|
|
instance AutoRoute MarketplaceDashboardController
|
|
|
|
-- /api/v2/ Phase 10 endpoints
|
|
|
|
instance CanRoute ApiV2HubRegistryController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/hub-registry"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexHubRegistryAction
|
|
, do _ <- string "/"; hId <- parseUUID; endOfInput
|
|
pure ApiV2ShowHubRegistryAction { hubId = Id hId }
|
|
]
|
|
|
|
instance HasPath ApiV2HubRegistryController where
|
|
pathTo ApiV2IndexHubRegistryAction = "/api/v2/hub-registry"
|
|
pathTo ApiV2ShowHubRegistryAction { hubId } = "/api/v2/hub-registry/" <> show hubId
|
|
|
|
instance CanRoute ApiV2WidgetPatternsController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2/widget-patterns"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexWidgetPatternsAction
|
|
, do _ <- string "/"; pId <- parseUUID
|
|
choice
|
|
[ do _ <- string "/adopt"; endOfInput
|
|
pure ApiV2AdoptWidgetPatternAction { widgetPatternId = Id pId }
|
|
, do endOfInput
|
|
pure ApiV2ShowWidgetPatternAction { widgetPatternId = Id pId }
|
|
]
|
|
]
|
|
|
|
instance HasPath ApiV2WidgetPatternsController where
|
|
pathTo ApiV2IndexWidgetPatternsAction = "/api/v2/widget-patterns"
|
|
pathTo ApiV2ShowWidgetPatternAction { widgetPatternId } = "/api/v2/widget-patterns/" <> show widgetPatternId
|
|
pathTo ApiV2AdoptWidgetPatternAction { widgetPatternId } = "/api/v2/widget-patterns/" <> show widgetPatternId <> "/adopt"
|
|
|
|
-- Phase 11 — Advanced AI Federation (IHUB-WP-0012)
|
|
instance AutoRoute AgentRegistrationsController
|
|
instance AutoRoute ModelRoutingPoliciesController
|
|
instance AutoRoute AgentDelegationsController
|
|
instance AutoRoute CollectiveProposalsController
|
|
instance AutoRoute AiGovernancePoliciesController
|
|
|
|
-- Phase 12 — Platform Memory and Continuous Learning (IHUB-WP-0013)
|
|
instance AutoRoute OutcomeCorrelationsController
|
|
instance AutoRoute PatternPerformanceController
|
|
instance AutoRoute AdaptiveThresholdsController
|
|
instance AutoRoute InstitutionalKnowledgeController
|
|
instance AutoRoute LineageEnrichmentController
|
|
instance AutoRoute LearningDashboardController
|
|
|
|
instance CanRoute ApiV2LearningController where
|
|
parseRoute' = do
|
|
_ <- string "/api/v2"
|
|
choice
|
|
[ do _ <- string "/outcome-correlations"; endOfInput
|
|
pure ApiV2IndexOutcomeCorrelationsAction
|
|
, do _ <- string "/pattern-performance"; endOfInput
|
|
pure ApiV2IndexPatternPerformanceAction
|
|
, do _ <- string "/knowledge-base"
|
|
choice
|
|
[ do endOfInput; pure ApiV2IndexKnowledgeBaseAction
|
|
, do _ <- string "/"; eid <- parseUUID; endOfInput
|
|
pure ApiV2ShowKnowledgeBaseAction { knowledgeEntryId = Id eid }
|
|
]
|
|
]
|
|
|
|
instance HasPath ApiV2LearningController where
|
|
pathTo ApiV2IndexOutcomeCorrelationsAction = "/api/v2/outcome-correlations"
|
|
pathTo ApiV2IndexPatternPerformanceAction = "/api/v2/pattern-performance"
|
|
pathTo ApiV2IndexKnowledgeBaseAction = "/api/v2/knowledge-base"
|
|
pathTo ApiV2ShowKnowledgeBaseAction { knowledgeEntryId } = "/api/v2/knowledge-base/" <> show knowledgeEntryId
|
|
|
|
-- Sessions
|
|
instance AutoRoute SessionsController
|