feat(P4): IHF Phase 4 complete — Outcome Observation and Antifragility Loop
Some checks failed
Test / test (push) Has been cancelled

Closes the IHF improvement loop. Full antifragility chain now traversable:
Widget → Annotation → Candidate → Requirement → Decision → Deployment → OutcomeSignal

New artifacts:
- DeploymentRecord (immutable, links DecisionRecord to a deployed version)
- OutcomeSignal (append-only; DB trigger prevents UPDATE/DELETE)
- ChangeEvaluation (one-per-deployment; UNIQUE constraint; 1–5 score)

New capabilities:
- DeploymentRecordsController (index, show, new, create)
- RecordOutcomeSignalAction — capture improved/regressed/neutral/inconclusive signals
- Pre/post comparison panel on deployment show (±30-day event/annotation counts)
- Regression detection — improved signal followed by high/critical annotation
- ChangeEvaluation — idempotent score+rationale per deployment
- Recurrence tracking — cycle count per widget, leaderboard
- AntifragilityDashboardAction (autoRefresh, 5 panels) per hub
- Phase 4 integration tests (T01–T08 logic coverage)
- docs/phase4-summary.md; SCOPE.md updated to Phase 4 complete

State Hub: workstream 07e9c860 → completed

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-29 12:27:30 +00:00
parent bc57852473
commit 878d2577ae
22 changed files with 1782 additions and 44 deletions

View File

@@ -7,11 +7,14 @@ import IHP.ViewPrelude
import Application.Helper.View (widgetEnvelope)
data ShowView = ShowView
{ widget :: !Widget
, hub :: !Hub
, versions :: ![WidgetVersion]
, events :: ![InteractionEvent]
, annotations :: ![Annotation]
{ widget :: !Widget
, hub :: !Hub
, versions :: ![WidgetVersion]
, events :: ![InteractionEvent]
, annotations :: ![Annotation]
, recentSignals :: ![OutcomeSignal]
, isRegressed :: !Bool
, cycleCount :: !Int
}
instance View ShowView where
@@ -24,6 +27,24 @@ instance View ShowView where
<span>{widget.name}</span>
</div>
{if cycleCount >= 2 then [hsx|
<div class="mb-2 flex items-center gap-2 bg-yellow-50 border border-yellow-200 rounded-lg px-4 py-2">
<span class="text-yellow-700 font-semibold text-sm"> {show cycleCount} cycles</span>
<span class="text-yellow-600 text-xs">
Recurring friction this widget has been through {show cycleCount} improvement cycles.
</span>
</div>
|] else mempty}
{if isRegressed then [hsx|
<div class="mb-4 flex items-center gap-2 bg-red-50 border border-red-200 rounded-lg px-4 py-3">
<span class="text-red-600 font-semibold text-sm"> Regression detected</span>
<span class="text-red-500 text-xs">
This widget had an improved signal but has since received high/critical annotations.
</span>
</div>
|] else mempty}
{widgetEnvelope widget [hsx|
<div class="flex items-center justify-between mb-4">
<div>
@@ -95,6 +116,15 @@ instance View ShowView where
</div>
</section>
{if null recentSignals then mempty else [hsx|
<section class="mb-8">
<h2 class="text-lg font-medium mb-3">Recent Outcome Signals</h2>
<div class="bg-white rounded-lg border border-gray-200 divide-y divide-gray-100">
{forEach recentSignals renderSignalRow}
</div>
</section>
|]}
<section>
<h2 class="text-lg font-medium mb-3">Version History</h2>
<div class="bg-white rounded-lg border border-gray-200 overflow-hidden">
@@ -160,3 +190,21 @@ renderCategoryRow (cat, count) = [hsx|
<span class="font-semibold">{show count}</span>
</div>
|]
renderSignalRow :: OutcomeSignal -> Html
renderSignalRow sig = [hsx|
<div class="flex items-center gap-3 px-4 py-3 text-sm">
<span class={signalTypeClass sig.signalType <> " text-xs px-2 py-0.5 rounded font-medium"}>
{sig.signalType}
</span>
{maybe mempty (\v -> [hsx|<span class="font-mono text-gray-700">{show v}</span>|]) sig.value}
<span class="text-xs text-gray-400 ml-auto">{show sig.observedAt}</span>
</div>
|]
signalTypeClass :: Text -> Text
signalTypeClass "improved" = "bg-green-100 text-green-800"
signalTypeClass "regressed" = "bg-red-100 text-red-800"
signalTypeClass "neutral" = "bg-gray-100 text-gray-600"
signalTypeClass "inconclusive" = "bg-yellow-100 text-yellow-800"
signalTypeClass _ = "bg-gray-100 text-gray-600"