@igorjpimenta/manifold 0.0.0-bootstrap.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/.migrations/ops/0000_futuristic_karma.sql +111 -0
  2. package/.migrations/ops/0001_low_maximus.sql +7 -0
  3. package/.migrations/ops/meta/0000_snapshot.json +763 -0
  4. package/.migrations/ops/meta/0001_snapshot.json +173 -0
  5. package/.migrations/ops/meta/_journal.json +20 -0
  6. package/.migrations/runtime/0000_real_boomer.sql +180 -0
  7. package/.migrations/runtime/0001_hot_dakota_north.sql +2 -0
  8. package/.migrations/runtime/0002_breezy_vertigo.sql +8 -0
  9. package/.migrations/runtime/0003_dashing_jack_flag.sql +5 -0
  10. package/.migrations/runtime/0004_panoramic_ego.sql +1 -0
  11. package/.migrations/runtime/0005_tidy_ben_grimm.sql +10 -0
  12. package/.migrations/runtime/0006_wet_nightmare.sql +57 -0
  13. package/.migrations/runtime/0007_ambiguous_chronomancer.sql +8 -0
  14. package/.migrations/runtime/0008_wealthy_thundra.sql +301 -0
  15. package/.migrations/runtime/0009_lying_shocker.sql +96 -0
  16. package/.migrations/runtime/0010_solid_phantom_reporter.sql +160 -0
  17. package/.migrations/runtime/0011_windy_demogoblin.sql +175 -0
  18. package/.migrations/runtime/0012_restore_harness_fks.sql +103 -0
  19. package/.migrations/runtime/meta/0000_snapshot.json +1181 -0
  20. package/.migrations/runtime/meta/0001_snapshot.json +1209 -0
  21. package/.migrations/runtime/meta/0002_snapshot.json +1261 -0
  22. package/.migrations/runtime/meta/0003_snapshot.json +1292 -0
  23. package/.migrations/runtime/meta/0004_snapshot.json +1240 -0
  24. package/.migrations/runtime/meta/0006_snapshot.json +1310 -0
  25. package/.migrations/runtime/meta/0007_snapshot.json +1362 -0
  26. package/.migrations/runtime/meta/0008_snapshot.json +1742 -0
  27. package/.migrations/runtime/meta/0009_snapshot.json +2413 -0
  28. package/.migrations/runtime/meta/0010_snapshot.json +2562 -0
  29. package/.migrations/runtime/meta/0011_snapshot.json +2812 -0
  30. package/.migrations/runtime/meta/0012_snapshot.json +2812 -0
  31. package/.migrations/runtime/meta/_journal.json +97 -0
  32. package/README.md +1584 -0
  33. package/RELEASING.md +89 -0
  34. package/agent/fleet.js +100 -0
  35. package/bin/cli.js +854 -0
  36. package/bin/manifold.js +4 -0
  37. package/boot/flow-revival.js +536 -0
  38. package/budget/index.js +495 -0
  39. package/budget/lib.js +59 -0
  40. package/dashboard/cost.js +528 -0
  41. package/dashboard/dist/assets/index-CUfp63sj.css +1 -0
  42. package/dashboard/dist/assets/index-Qy9JMpma.js +371 -0
  43. package/dashboard/dist/index.html +13 -0
  44. package/dashboard/event-log.js +267 -0
  45. package/dashboard/index.html +12 -0
  46. package/dashboard/package-lock.json +2877 -0
  47. package/dashboard/package.json +37 -0
  48. package/dashboard/pipeline-graph.js +131 -0
  49. package/dashboard/postcss.config.js +6 -0
  50. package/dashboard/search.js +183 -0
  51. package/dashboard/server.js +1015 -0
  52. package/dashboard/src/App.tsx +42 -0
  53. package/dashboard/src/api/client.ts +118 -0
  54. package/dashboard/src/api/types.ts +510 -0
  55. package/dashboard/src/api/ws.tsx +112 -0
  56. package/dashboard/src/components/CancelButton.tsx +63 -0
  57. package/dashboard/src/components/ClickToCopy.tsx +68 -0
  58. package/dashboard/src/components/CopyButton.tsx +61 -0
  59. package/dashboard/src/components/DailyCostTrend.tsx +85 -0
  60. package/dashboard/src/components/DailyTimeTrend.tsx +94 -0
  61. package/dashboard/src/components/Funnel.tsx +149 -0
  62. package/dashboard/src/components/GateForm.tsx +158 -0
  63. package/dashboard/src/components/GraphView.tsx +302 -0
  64. package/dashboard/src/components/GroupPathsSummary.tsx +47 -0
  65. package/dashboard/src/components/Histogram.tsx +292 -0
  66. package/dashboard/src/components/Layout.tsx +28 -0
  67. package/dashboard/src/components/NeedsAttention.tsx +98 -0
  68. package/dashboard/src/components/NodeContextCard.tsx +132 -0
  69. package/dashboard/src/components/PathTrail.tsx +35 -0
  70. package/dashboard/src/components/PipelineCostBreakdown.tsx +277 -0
  71. package/dashboard/src/components/RerunButton.tsx +46 -0
  72. package/dashboard/src/components/RunComparison.tsx +53 -0
  73. package/dashboard/src/components/Sparkline.tsx +94 -0
  74. package/dashboard/src/components/StatStrip.tsx +147 -0
  75. package/dashboard/src/components/StateTree.tsx +84 -0
  76. package/dashboard/src/components/StatusBadge.tsx +18 -0
  77. package/dashboard/src/components/SubflowPathPills.tsx +38 -0
  78. package/dashboard/src/components/SubflowSummary.tsx +24 -0
  79. package/dashboard/src/components/SubflowsCard.tsx +327 -0
  80. package/dashboard/src/components/TodayStrip.tsx +86 -0
  81. package/dashboard/src/components/TranscriptPane.tsx +99 -0
  82. package/dashboard/src/components/TranscriptRow.tsx +69 -0
  83. package/dashboard/src/components/ui/badge.tsx +38 -0
  84. package/dashboard/src/components/ui/button.tsx +28 -0
  85. package/dashboard/src/components/ui/card.tsx +42 -0
  86. package/dashboard/src/components/ui/skeleton.tsx +9 -0
  87. package/dashboard/src/components/ui/table.tsx +62 -0
  88. package/dashboard/src/index.css +26 -0
  89. package/dashboard/src/lib/anomaly.ts +42 -0
  90. package/dashboard/src/lib/format.ts +30 -0
  91. package/dashboard/src/lib/step-history.ts +13 -0
  92. package/dashboard/src/lib/subflow.ts +154 -0
  93. package/dashboard/src/lib/use-click-outside.ts +28 -0
  94. package/dashboard/src/lib/use-ignored-clusters.ts +67 -0
  95. package/dashboard/src/lib/utils.ts +6 -0
  96. package/dashboard/src/main.tsx +10 -0
  97. package/dashboard/src/types/shims.d.ts +4 -0
  98. package/dashboard/src/views/Home.tsx +478 -0
  99. package/dashboard/src/views/PipelineDetail.tsx +1185 -0
  100. package/dashboard/src/views/PipelinesList.tsx +111 -0
  101. package/dashboard/src/views/RunDetail.tsx +248 -0
  102. package/dashboard/src/views/Search.tsx +196 -0
  103. package/dashboard/stats.js +668 -0
  104. package/dashboard/tailwind.config.ts +43 -0
  105. package/dashboard/tree-stats.js +12 -0
  106. package/dashboard/tsconfig.json +25 -0
  107. package/dashboard/views.js +231 -0
  108. package/dashboard/vite.config.ts +34 -0
  109. package/drizzle.config.js +12 -0
  110. package/drizzle.config.ops.js +12 -0
  111. package/elevation.js +116 -0
  112. package/engine/admission-promotion-resume.js +127 -0
  113. package/engine/agent-dispatch.js +64 -0
  114. package/engine/child-resume-trigger.js +315 -0
  115. package/engine/executor-budget.js +87 -0
  116. package/engine/executor-cancel.js +83 -0
  117. package/engine/executor-errors.js +122 -0
  118. package/engine/executor-helpers.js +254 -0
  119. package/engine/executor-nodes.js +292 -0
  120. package/engine/executor-persist.js +212 -0
  121. package/engine/executor-subflow-children.js +275 -0
  122. package/engine/executor.js +1013 -0
  123. package/engine/global-concurrency.js +33 -0
  124. package/engine/loader.js +528 -0
  125. package/engine/needs-resolver.js +229 -0
  126. package/engine/pipelines-watcher.js +133 -0
  127. package/engine/result-replay.js +34 -0
  128. package/engine/revival-messages.js +11 -0
  129. package/engine/spawn-child.js +55 -0
  130. package/engine/wait-for-flow-settlement.js +109 -0
  131. package/events/catalog.js +26 -0
  132. package/events/emit.js +44 -0
  133. package/events/kinds.js +118 -0
  134. package/events/serve-ws.js +74 -0
  135. package/events/stream.js +35 -0
  136. package/events/ws-dialog.js +257 -0
  137. package/events/ws-frame.js +194 -0
  138. package/events/ws-run-events.js +70 -0
  139. package/events.js +32 -0
  140. package/gates/gate-resolver.js +576 -0
  141. package/gates/paused-flows.js +55 -0
  142. package/graphql/columns.js +67 -0
  143. package/graphql/schema.js +333 -0
  144. package/index.js +49 -0
  145. package/mcp/http.js +159 -0
  146. package/mcp/identity.js +94 -0
  147. package/mcp/stdio.js +80 -0
  148. package/mcp/tools.js +245 -0
  149. package/mcp/wire-ops.js +178 -0
  150. package/package.json +51 -0
  151. package/routes/bearer-auth.js +57 -0
  152. package/routes/discuss-audio.js +87 -0
  153. package/routes/discuss-component.js +39 -0
  154. package/routes/discuss-draft.js +159 -0
  155. package/routes/discuss-helpers.js +20 -0
  156. package/routes/discuss.js +848 -0
  157. package/routes/failures.js +104 -0
  158. package/routes/graphql.js +61 -0
  159. package/routes/health.js +54 -0
  160. package/routes/operator-discuss.js +193 -0
  161. package/routes/operator-resume.js +32 -0
  162. package/routes/operator-retry.js +301 -0
  163. package/routes/operator.js +539 -0
  164. package/routes/pipelines.js +118 -0
  165. package/routes/runs.js +1129 -0
  166. package/scripts/ci/import-check.mjs +50 -0
  167. package/scripts/link-core-self.mjs +31 -0
  168. package/scripts/with-guard.sh +24 -0
  169. package/server/app.js +503 -0
  170. package/server/registry.js +53 -0
  171. package/server/serve.js +163 -0
  172. package/state/admission-queue-store.js +325 -0
  173. package/state/attribution-registries.js +102 -0
  174. package/state/batch-writer.js +162 -0
  175. package/state/db-guard.js +63 -0
  176. package/state/db-health.js +27 -0
  177. package/state/db.js +122 -0
  178. package/state/discuss-store.js +299 -0
  179. package/state/failure-store.js +427 -0
  180. package/state/migrate.js +104 -0
  181. package/state/node-cost.js +67 -0
  182. package/state/node-executions.js +775 -0
  183. package/state/node-health-store.js +124 -0
  184. package/state/ops-merge.js +93 -0
  185. package/state/paths.js +146 -0
  186. package/state/pipeline-dirs.js +99 -0
  187. package/state/pipeline-registry.js +449 -0
  188. package/state/run-store.js +697 -0
  189. package/state/schema.js +438 -0
  190. package/state/schema.ops.js +44 -0
  191. package/state/session-index.js +177 -0
  192. package/state/session-keys.js +39 -0
  193. package/state/state-store.js +311 -0
  194. package/state/subflow-state.js +126 -0
  195. package/state/tool-handoff.js +169 -0
  196. package/telemetry/budget-alert.js +353 -0
  197. package/telemetry/cli.js +331 -0
  198. package/telemetry/grammar.js +119 -0
  199. package/telemetry/http-budget.js +132 -0
  200. package/telemetry/http-cost.js +670 -0
  201. package/telemetry/http-helpers.js +134 -0
  202. package/telemetry/http-tree.js +349 -0
  203. package/telemetry/http.js +44 -0
  204. package/telemetry/index.js +307 -0
  205. package/telemetry/ingest.js +134 -0
  206. package/telemetry/labels.js +115 -0
  207. package/telemetry/pricer.js +77 -0
  208. package/telemetry/resolver.js +314 -0
  209. package/telemetry/store.js +147 -0
  210. package/utils/run-patch.js +43 -0
@@ -0,0 +1,292 @@
1
+ import { Fragment, useState } from "react";
2
+ import type { HistogramEntry } from "@/api/types";
3
+ import { formatDuration } from "@/lib/format";
4
+ import { useIgnoredClusters, clusterKey } from "@/lib/use-ignored-clusters";
5
+
6
+ type SortKey = "impact" | "count" | "recency";
7
+
8
+ // Recency thresholds. <24h = active fire, <7d = recent simmering, older
9
+ // = historical. Drives row tone so the operator can spot fresh clusters
10
+ // without reading dates.
11
+ const DAY_MS = 86_400_000;
12
+ function recencyTone(at: number | null | undefined): { text: string; label: string } {
13
+ if (!at) return { text: "text-fg-dim/60", label: "no data" };
14
+ const age = Date.now() - at;
15
+ if (age < DAY_MS) return { text: "text-status-red", label: "today" };
16
+ if (age < 7 * DAY_MS) return { text: "text-status-amber", label: `${Math.floor(age / DAY_MS)}d ago` };
17
+ return { text: "text-fg-dim/60", label: `${Math.floor(age / DAY_MS)}d ago` };
18
+ }
19
+
20
+ // Tiny inline sparkline reused per row. Bars proportional to the row's
21
+ // per-day failure count; flat rows render as low-contrast stubs so an
22
+ // "all on one day" cluster stands out visually.
23
+ function MiniBars({ perDay }: { perDay: { day: string; count: number }[] }) {
24
+ if (!perDay?.length) return null;
25
+ const max = Math.max(1, ...perDay.map((d) => d.count));
26
+ return (
27
+ <span className="inline-flex items-end gap-[1px] h-3 align-middle" aria-hidden>
28
+ {perDay.map((d) => {
29
+ const h = d.count > 0 ? Math.max(20, Math.round((d.count / max) * 100)) : 8;
30
+ return (
31
+ <span
32
+ key={d.day}
33
+ className={`w-[3px] rounded-[1px] ${d.count > 0 ? "bg-status-amber" : "bg-bg-elev2"}`}
34
+ style={{ height: `${h}%` }}
35
+ title={`${d.day}: ${d.count}`}
36
+ />
37
+ );
38
+ })}
39
+ </span>
40
+ );
41
+ }
42
+
43
+ // Failure/cancel histogram — Sprint 1 of the strategic redesign.
44
+ // Each row is a CLUSTER (step + normalized error signature) rather
45
+ // than just a step name, so two failures with the same root cause
46
+ // collapse into one triage row. Row tone signals recency (today red /
47
+ // 7d amber / older dim) so the operator can spot fresh fires without
48
+ // reading dates. Sparkline shows per-day occurrence to surface
49
+ // "clustered today" vs "scattered across the month".
50
+ //
51
+ // Sort dimensions:
52
+ // - impact (default): count × p50 block time
53
+ // - count: pure frequency
54
+ // - recency: most recent first
55
+ export function Histogram({ entries, limit = 8, showPipeline = false }: { entries: HistogramEntry[]; limit?: number; showPipeline?: boolean }) {
56
+ const [sort, setSort] = useState<SortKey>("impact");
57
+ const [expanded, setExpanded] = useState<string | null>(null);
58
+ // Suppression: once the operator's triaged a cluster, they can hide
59
+ // it from the active queue so fresh fires actually stand out. State
60
+ // is localStorage-backed via useIgnoredClusters.
61
+ const { ignored, ignore, unignore } = useIgnoredClusters();
62
+ const [showIgnored, setShowIgnored] = useState(false);
63
+ if (!entries?.length) return <div className="italic text-fg-dim py-4">none</div>;
64
+ const hasImpactSignal = entries.some((e) => (e.impactMs ?? 0) > 0);
65
+ const hasRecency = entries.some((e) => (e.lastFailedAt ?? 0) > 0);
66
+
67
+ const sorted = (() => {
68
+ if (sort === "count" || !hasImpactSignal) return [...entries].sort((a, b) => b.count - a.count);
69
+ if (sort === "recency") return [...entries].sort((a, b) => (b.lastFailedAt ?? 0) - (a.lastFailedAt ?? 0));
70
+ return entries; // backend already sorted by impact desc
71
+ })();
72
+ const isIgnored = (e: HistogramEntry) => clusterKey(e.pipelineId, e.key) in ignored;
73
+ const ignoredCount = sorted.filter(isIgnored).length;
74
+ // Default view filters out ignored clusters. The "show ignored"
75
+ // toggle inverts: when on, only ignored rows appear so the operator
76
+ // can unignore them. Two modes are easier to reason about than a
77
+ // merged-but-flagged list.
78
+ const visible = showIgnored
79
+ ? sorted.filter(isIgnored)
80
+ : sorted.filter((e) => !isIgnored(e));
81
+ const top = visible.slice(0, limit);
82
+ const metricValue = (e: HistogramEntry) => sort === "count" ? e.count : (e.impactMs ?? e.count);
83
+ const max = Math.max(...top.map(metricValue));
84
+
85
+ // When grouping by pipeline, collect each pipeline's rows together so
86
+ // the umbrella truly contains its children — even when sort order
87
+ // would otherwise interleave a third pipeline's row between two of
88
+ // this pipeline's rows. Pipelines themselves are ordered by their
89
+ // top entry's metric, so the highest-impact umbrella appears first.
90
+ const grouped: { pipelineId: string | null; rows: HistogramEntry[] }[] = (() => {
91
+ if (!showPipeline) return [{ pipelineId: null, rows: top }];
92
+ const byPipe = new Map<string, HistogramEntry[]>();
93
+ const order: string[] = [];
94
+ for (const e of top) {
95
+ const pid = e.pipelineId ?? "?";
96
+ if (!byPipe.has(pid)) { byPipe.set(pid, []); order.push(pid); }
97
+ byPipe.get(pid)!.push(e);
98
+ }
99
+ return order.map((pid) => ({ pipelineId: pid, rows: byPipe.get(pid)! }));
100
+ })();
101
+
102
+ return (
103
+ <div>
104
+ {hasImpactSignal && (
105
+ <div className="flex items-center gap-2 mb-2">
106
+ <div className="text-xs text-fg-dim">failure clusters — {sort === "impact" ? "by impact" : sort === "count" ? "by count" : "most recent"}</div>
107
+ <div className="ml-auto inline-flex rounded border border-border overflow-hidden text-[10px] font-mono">
108
+ <button
109
+ type="button"
110
+ onClick={() => setSort("impact")}
111
+ className={sort === "impact" ? "px-2 py-0.5 bg-status-blue/20 text-fg" : "px-2 py-0.5 text-fg-dim hover:text-fg"}
112
+ >impact</button>
113
+ <button
114
+ type="button"
115
+ onClick={() => setSort("count")}
116
+ className={sort === "count" ? "px-2 py-0.5 border-l border-border bg-status-blue/20 text-fg" : "px-2 py-0.5 border-l border-border text-fg-dim hover:text-fg"}
117
+ >count</button>
118
+ {hasRecency && (
119
+ <button
120
+ type="button"
121
+ onClick={() => setSort("recency")}
122
+ className={sort === "recency" ? "px-2 py-0.5 border-l border-border bg-status-blue/20 text-fg" : "px-2 py-0.5 border-l border-border text-fg-dim hover:text-fg"}
123
+ >recent</button>
124
+ )}
125
+ </div>
126
+ </div>
127
+ )}
128
+ {/*
129
+ 5 columns: step + signature | bar | sparkline | last-seen | count.
130
+ Tap-to-expand pattern matches NodeCostBreakdown / Funnel — the
131
+ clicked row reveals the full untruncated error message + recent
132
+ flow ids underneath via `col-span-5`. One row open at a time.
133
+ */}
134
+ {grouped.map((group, gi) => (
135
+ <div
136
+ key={group.pipelineId ?? `g${gi}`}
137
+ className={showPipeline ? "border border-border rounded mb-2 last:mb-0" : ""}
138
+ >
139
+ {/* Umbrella header: pipeline-scoped roll-up across its rows.
140
+ Counts collapsed errors and total occurrences so the
141
+ operator sees at the umbrella level whether this pipeline
142
+ has one broken step or many. */}
143
+ {showPipeline && group.pipelineId && (() => {
144
+ const totalCount = group.rows.reduce((s, r) => s + r.count, 0);
145
+ const distinctErrors = group.rows.reduce((s, r) => s + (r.errors?.length ?? 0), 0);
146
+ const newestAt = Math.max(0, ...group.rows.map((r) => r.lastFailedAt ?? 0));
147
+ const headTone = recencyTone(newestAt || null);
148
+ return (
149
+ <div className="flex items-center gap-2 px-2 py-1 border-b border-border/60 bg-bg-elev2/30">
150
+ <span className="font-mono text-[11px] text-fg truncate">{group.pipelineId}</span>
151
+ <span className={`text-[10px] ${headTone.text}`}>{headTone.label}</span>
152
+ <span className="ml-auto text-[10px] text-fg-dim tabular-nums">
153
+ {group.rows.length} step{group.rows.length === 1 ? "" : "s"} ·{" "}
154
+ {totalCount} occurrence{totalCount === 1 ? "" : "s"}
155
+ {distinctErrors > 0 && <> · {distinctErrors} distinct error{distinctErrors === 1 ? "" : "s"}</>}
156
+ </span>
157
+ </div>
158
+ );
159
+ })()}
160
+ <div className={`grid grid-cols-[auto_1fr_auto_auto_auto] items-center gap-x-2.5 gap-y-1.5 font-mono text-xs ${showPipeline ? "px-2 py-1.5" : ""}`}>
161
+ {group.rows.map((i, idx) => {
162
+ const tone = recencyTone(i.lastFailedAt);
163
+ const rowKey = `${i.pipelineId ?? ""}::${i.key}::${gi}::${idx}`;
164
+ const isOpen = expanded === rowKey;
165
+ return (
166
+ <Fragment key={rowKey}>
167
+ <button
168
+ type="button"
169
+ onClick={() => setExpanded(isOpen ? null : rowKey)}
170
+ aria-expanded={isOpen}
171
+ className="contents text-left group"
172
+ >
173
+ {/* Collapsed view: step only (pipeline lives in the
174
+ header above when showPipeline=true). Per-error
175
+ breakdown is in the expansion. */}
176
+ <span className="min-w-0 max-w-[260px] group-hover:bg-bg-elev2/40 rounded-l-[2px] pl-0.5" title={`${showPipeline && i.pipelineId ? `${i.pipelineId} · ` : ""}${i.key}`}>
177
+ <span className="flex items-center gap-1 whitespace-nowrap">
178
+ <span className={`truncate ${tone.text}`}>{i.key}</span>
179
+ <span className="text-[10px] text-fg-dim shrink-0">{isOpen ? "▾" : "▸"}</span>
180
+ </span>
181
+ </span>
182
+ <span className="relative h-3 bg-bg-elev2 rounded-[2px] overflow-hidden group-hover:bg-bg-elev2/60">
183
+ <span
184
+ className="absolute top-0 left-0 bottom-0 bg-status-amber opacity-75"
185
+ style={{ width: `${(metricValue(i) / Math.max(1, max) * 100).toFixed(1)}%` }}
186
+ />
187
+ </span>
188
+ <span className="px-1 group-hover:bg-bg-elev2/40">
189
+ {i.perDay && i.perDay.length > 0 ? <MiniBars perDay={i.perDay} /> : null}
190
+ </span>
191
+ <span className={`text-right whitespace-nowrap text-[10px] ${tone.text} group-hover:bg-bg-elev2/40`} title={i.lastFailedAt ? new Date(i.lastFailedAt).toISOString() : ""}>
192
+ {tone.label}
193
+ </span>
194
+ <span
195
+ className="text-right text-fg-dim whitespace-nowrap tabular-nums pr-0.5 group-hover:bg-bg-elev2/40 rounded-r-[2px]"
196
+ title={i.p50BlockMs != null ? `${i.count} × ${formatDuration(i.p50BlockMs)} median block` : `${i.count} occurrences`}
197
+ >
198
+ {sort === "count"
199
+ ? i.count
200
+ : (i.p50BlockMs != null ? `${i.count}×${formatDuration(i.p50BlockMs)}` : `${i.count}`)}
201
+ </span>
202
+ </button>
203
+ {isOpen && (
204
+ <div className="col-span-5 pl-1 pr-1 pt-0.5 pb-1.5 text-[10px] text-fg-dim space-y-2">
205
+ {/* Per-error breakdown. Each distinct error signature
206
+ at this step renders as a sub-block with its own
207
+ count + recency + full message + recent flow ids.
208
+ Sorted by recency desc so the freshest bug is on
209
+ top. */}
210
+ {i.errors && i.errors.length > 0 ? i.errors.map((err, ei) => {
211
+ const eTone = recencyTone(err.lastFailedAt);
212
+ return (
213
+ <div key={ei} className="border-l border-border pl-2">
214
+ <div className="flex items-baseline gap-2 mb-0.5">
215
+ <span className="tabular-nums text-fg">{err.count}×</span>
216
+ <span className={`text-[10px] ${eTone.text}`}>{eTone.label}</span>
217
+ <span className="text-fg-dim truncate">{err.signature}</span>
218
+ </div>
219
+ {err.exemplarMessage && err.exemplarMessage !== err.signature && (
220
+ <pre className="font-mono text-[10px] whitespace-pre-wrap break-words bg-bg-elev2 border border-border rounded px-1.5 py-1 text-fg-dim max-h-40 overflow-auto">
221
+ {err.exemplarMessage}
222
+ </pre>
223
+ )}
224
+ {err.recentRuns && err.recentRuns.length > 0 && (
225
+ <div className="flex flex-wrap gap-1.5 mt-1">
226
+ <span className="text-fg-dim">recent:</span>
227
+ {err.recentRuns.map((r) => (
228
+ <a
229
+ key={r.flowId}
230
+ href={`#/runs/${r.flowId}`}
231
+ onClick={(e) => e.stopPropagation()}
232
+ className="font-mono text-fg-dim hover:text-fg underline-offset-2 hover:underline"
233
+ title={r.at ? new Date(r.at).toISOString() : ""}
234
+ >
235
+ {r.flowId.slice(0, 8)}
236
+ </a>
237
+ ))}
238
+ </div>
239
+ )}
240
+ </div>
241
+ );
242
+ }) : <p className="italic">no error messages recorded</p>}
243
+ <div className="flex items-center gap-2 pt-1 font-mono text-fg-dim/80">
244
+ <span>
245
+ {i.count} total occurrence{i.count === 1 ? "" : "s"} across {i.errors?.length ?? 0} distinct error{(i.errors?.length ?? 0) === 1 ? "" : "s"}
246
+ {i.p50BlockMs != null && <> · median block {formatDuration(i.p50BlockMs)}</>}
247
+ {i.impactMs != null && i.impactMs > 0 && <> · total impact {formatDuration(i.impactMs)}</>}
248
+ </span>
249
+ {/* Ignore / unignore action — hides this cluster
250
+ from the active triage queue. State is
251
+ persisted to localStorage, so the choice
252
+ survives reload. Cluster key is (pipeline,
253
+ step); ignoring covers all signatures within. */}
254
+ {(() => {
255
+ const ck = clusterKey(i.pipelineId, i.key);
256
+ const isIgn = ck in ignored;
257
+ return (
258
+ <button
259
+ type="button"
260
+ onClick={(ev) => {
261
+ ev.stopPropagation();
262
+ if (isIgn) unignore(ck); else ignore(ck);
263
+ }}
264
+ className="ml-auto text-[10px] text-fg-dim hover:text-fg underline-offset-2 hover:underline"
265
+ title={isIgn ? "stop ignoring — bring this cluster back into the active queue" : "ignore this cluster — hide from the active queue until unignored"}
266
+ >
267
+ {isIgn ? "unignore" : "ignore cluster"}
268
+ </button>
269
+ );
270
+ })()}
271
+ </div>
272
+ </div>
273
+ )}
274
+ </Fragment>
275
+ );
276
+ })}
277
+ </div>
278
+ </div>
279
+ ))}
280
+ {/* Footer summary + show/hide ignored toggle. Only renders when
281
+ there's at least one ignored cluster in the current entries. */}
282
+ {ignoredCount > 0 && (
283
+ <div className="mt-2 text-[10px] font-mono text-fg-dim">
284
+ {showIgnored
285
+ ? <>showing {ignoredCount} ignored cluster{ignoredCount === 1 ? "" : "s"} · <button type="button" onClick={() => setShowIgnored(false)} className="underline-offset-2 hover:underline hover:text-fg">back to active</button></>
286
+ : <>{ignoredCount} cluster{ignoredCount === 1 ? "" : "s"} ignored · <button type="button" onClick={() => setShowIgnored(true)} className="underline-offset-2 hover:underline hover:text-fg">show</button></>
287
+ }
288
+ </div>
289
+ )}
290
+ </div>
291
+ );
292
+ }
@@ -0,0 +1,28 @@
1
+ import type { ReactNode } from "react";
2
+ import { useWsState } from "@/api/ws";
3
+ import { cn } from "@/lib/utils";
4
+
5
+ export function Layout({ children }: { children: ReactNode }) {
6
+ const conn = useWsState();
7
+ return (
8
+ <div className="min-h-screen">
9
+ <header className="sticky top-0 z-10 flex items-center gap-3 sm:gap-4 bg-bg-elev px-3 sm:px-5 py-[10px] border-b border-border">
10
+ <a href="#/" className="font-mono font-semibold tracking-wide text-fg">manifold</a>
11
+ <nav className="flex gap-3 sm:gap-4 flex-1">
12
+ <a href="#/" className="text-fg-dim py-1 hover:no-underline hover:text-fg">runs</a>
13
+ <a href="#/pipelines" className="text-fg-dim py-1 hover:no-underline hover:text-fg">pipelines</a>
14
+ <a href="#/search" className="text-fg-dim py-1 hover:no-underline hover:text-fg">search</a>
15
+ </nav>
16
+ <div
17
+ className={cn(
18
+ "font-mono text-xs",
19
+ conn === "live" ? "text-status-green" : conn === "dead" ? "text-status-red" : "text-fg-dim"
20
+ )}
21
+ >
22
+ {conn === "live" ? "live" : conn === "dead" ? "disconnected" : "connecting…"}
23
+ </div>
24
+ </header>
25
+ <main className="max-w-[1400px] mx-auto p-3 sm:p-5">{children}</main>
26
+ </div>
27
+ );
28
+ }
@@ -0,0 +1,98 @@
1
+ // "Needs attention" strip — a glanceable summary of runs that warrant
2
+ // operator action. Renders nothing when there's nothing to flag, so the
3
+ // strip's presence is itself the signal.
4
+ //
5
+ // Categories surfaced (cheap derivations over the home-page runs window):
6
+ // - stuck: status=waiting|blocked, updated > 1h ago
7
+ // - failed: status=failed, ended/updated < 24h ago
8
+ //
9
+ // Lower-priority signals (low-success-rate pipelines, stalled runs
10
+ // without recent state change) require multi-pipeline aggregation that
11
+ // the home stats endpoint doesn't expose yet — parked for a follow-up.
12
+
13
+ import { useState } from "react";
14
+ import { Card } from "@/components/ui/card";
15
+ import { formatTime } from "@/lib/format";
16
+ import { cn } from "@/lib/utils";
17
+ import type { FlowRunSummary } from "@/api/types";
18
+
19
+ const HOUR = 3_600_000;
20
+ const DAY = 86_400_000;
21
+
22
+ interface Bucket {
23
+ label: string;
24
+ className: string;
25
+ runs: FlowRunSummary[];
26
+ }
27
+
28
+ function classify(runs: FlowRunSummary[]): Bucket[] {
29
+ const now = Date.now();
30
+ // "waiting" is never actually written anywhere (confirmed repo-wide) —
31
+ // gate pauses are always persisted as "blocked".
32
+ const stuck = runs.filter((r) =>
33
+ r.status === "blocked" &&
34
+ r.updatedAt != null &&
35
+ now - r.updatedAt > HOUR
36
+ );
37
+ const failed = runs.filter((r) =>
38
+ r.status === "failed" &&
39
+ r.updatedAt != null &&
40
+ now - r.updatedAt < DAY
41
+ );
42
+ const buckets: Bucket[] = [];
43
+ if (stuck.length) buckets.push({ label: "stuck > 1h", className: "text-status-amber", runs: stuck });
44
+ if (failed.length) buckets.push({ label: "failed in last 24h", className: "text-status-red", runs: failed });
45
+ return buckets;
46
+ }
47
+
48
+ export function NeedsAttention({ runs }: { runs: FlowRunSummary[] }) {
49
+ const [open, setOpen] = useState<string | null>(null);
50
+ const buckets = classify(runs);
51
+ if (buckets.length === 0) return null;
52
+
53
+ return (
54
+ <Card className="border-status-amber/30 bg-status-amber/[0.04]">
55
+ <div className="flex items-center gap-2 mb-2">
56
+ <span className="text-status-amber font-semibold uppercase tracking-[0.5px] text-xs">needs attention</span>
57
+ <span className="text-fg-dim text-xs">— glanceable signals; expand to see the runs</span>
58
+ </div>
59
+ <div className="flex flex-wrap gap-2">
60
+ {buckets.map((b) => (
61
+ <button
62
+ key={b.label}
63
+ onClick={() => setOpen(open === b.label ? null : b.label)}
64
+ className={cn(
65
+ "font-mono text-xs px-2.5 py-1 rounded-full border border-border bg-bg-elev hover:bg-bg-elev2 transition-colors",
66
+ open === b.label && "bg-bg-elev2"
67
+ )}
68
+ >
69
+ <span className={b.className}>{b.runs.length}</span> {b.label}
70
+ </button>
71
+ ))}
72
+ </div>
73
+ {open && (() => {
74
+ const bucket = buckets.find((b) => b.label === open);
75
+ if (!bucket) return null;
76
+ return (
77
+ <div className="mt-3 border-t border-border pt-2 grid grid-cols-1 gap-1 text-sm">
78
+ {bucket.runs.slice(0, 8).map((r) => (
79
+ <a
80
+ key={r.flowId}
81
+ href={`#/runs/${r.flowId}`}
82
+ className="flex items-center gap-3 py-1 hover:bg-bg-elev2 rounded px-2 -mx-2 min-w-0"
83
+ >
84
+ <span className="font-mono text-xs text-fg-dim w-[72px] shrink-0">{r.flowId.slice(0, 8)}</span>
85
+ <span className="font-mono flex-1 min-w-0 truncate">{r.pipelineId ?? "?"}</span>
86
+ <span className="font-mono text-fg-dim text-xs truncate hidden sm:inline">{r.currentStep ?? "?"}</span>
87
+ <span className="text-fg-dim text-xs whitespace-nowrap shrink-0">{formatTime(r.updatedAt)}</span>
88
+ </a>
89
+ ))}
90
+ {bucket.runs.length > 8 && (
91
+ <div className="text-fg-dim text-xs italic px-2 mt-1">…and {bucket.runs.length - 8} more — refine filters to see them all</div>
92
+ )}
93
+ </div>
94
+ );
95
+ })()}
96
+ </Card>
97
+ );
98
+ }
@@ -0,0 +1,132 @@
1
+ // Right-rail context panel shown when a graph node is tapped. Surfaces
2
+ // per-node visit/failure/block counts and the most recent runs that touched
3
+ // the node — clicking a row deep-links into the run detail view.
4
+
5
+ import { useEffect, useState } from "react";
6
+ import { Card, CardHeader, CardTitle } from "@/components/ui/card";
7
+ import { Badge } from "@/components/ui/badge";
8
+ import { Table, THead, TBody, TR, TH, TD } from "@/components/ui/table";
9
+ import { StatusBadge } from "@/components/StatusBadge";
10
+ import { api } from "@/api/client";
11
+ import type { NodeStats } from "@/api/types";
12
+
13
+ function fmtRel(ts: number | null): string {
14
+ if (!ts) return "";
15
+ const d = Date.now() - ts;
16
+ if (d < 60_000) return `${Math.floor(d / 1000)}s ago`;
17
+ if (d < 3_600_000) return `${Math.floor(d / 60_000)}m ago`;
18
+ if (d < 86_400_000) return `${Math.floor(d / 3_600_000)}h ago`;
19
+ return `${Math.floor(d / 86_400_000)}d ago`;
20
+ }
21
+
22
+ export function NodeContextCard({
23
+ pipelineId,
24
+ nodeId,
25
+ onClose,
26
+ }: {
27
+ pipelineId: string;
28
+ nodeId: string;
29
+ onClose: () => void;
30
+ }) {
31
+ const [stats, setStats] = useState<NodeStats | null>(null);
32
+ const [error, setError] = useState<string | null>(null);
33
+
34
+ useEffect(() => {
35
+ let cancelled = false;
36
+ setStats(null);
37
+ setError(null);
38
+ api.pipelineNodeStats(pipelineId, nodeId)
39
+ .then((s) => { if (!cancelled) setStats(s); })
40
+ .catch((e) => { if (!cancelled) setError(e?.message ?? String(e)); });
41
+ return () => { cancelled = true; };
42
+ }, [pipelineId, nodeId]);
43
+
44
+ return (
45
+ <Card>
46
+ <CardHeader>
47
+ <CardTitle>
48
+ <span className="font-mono">{nodeId}</span>
49
+ <button
50
+ className="ml-3 text-xs text-fg-dim hover:text-fg"
51
+ onClick={onClose}
52
+ aria-label="close node context"
53
+ >
54
+ ✕ close
55
+ </button>
56
+ </CardTitle>
57
+ </CardHeader>
58
+ {error && <p className="text-status-red text-sm">{error}</p>}
59
+ {!error && !stats && <p className="italic text-fg-dim text-sm">loading…</p>}
60
+ {stats && (
61
+ <>
62
+ <div className="grid grid-cols-2 sm:grid-cols-4 gap-2 mb-3">
63
+ <Stat label="visits" value={stats.visits} />
64
+ <Stat label="failed-here" value={stats.failedHere} tone={stats.failedHere ? "red" : null} />
65
+ <Stat label="blocked-here" value={stats.blockedHere} tone={stats.blockedHere ? "amber" : null} />
66
+ <Stat label="terminated-here" value={stats.terminatedHere} tone={stats.terminatedHere ? "amber" : null} />
67
+ </div>
68
+ <div className="text-xs text-fg-dim mb-1">
69
+ visited by {stats.visits} of {stats.totalRuns} run{stats.totalRuns === 1 ? "" : "s"}
70
+ </div>
71
+ {stats.recentRuns.length === 0 ? (
72
+ <p className="italic text-fg-dim text-sm">no runs have touched this node yet.</p>
73
+ ) : (
74
+ <>
75
+ {/* Mobile card list (<sm). currentStep clipped off the
76
+ table on phones; the card surfaces the status pill +
77
+ relative time on the same row, with step + flow id
78
+ on the second row. */}
79
+ <div className="sm:hidden flex flex-col gap-1.5">
80
+ {stats.recentRuns.map((r) => (
81
+ <a
82
+ key={r.flowId}
83
+ href={`#/runs/${r.flowId}`}
84
+ className="block rounded border border-border bg-bg-elev2/30 hover:bg-bg-elev2 px-2.5 py-1.5"
85
+ >
86
+ <div className="flex items-center gap-2">
87
+ <StatusBadge status={r.status} />
88
+ <span className="font-mono text-xs truncate flex-1">{r.flowId.slice(0, 12)}…</span>
89
+ <span className="text-[10px] text-fg-dim shrink-0">{fmtRel(r.updatedAt)}</span>
90
+ </div>
91
+ {r.currentStep && (
92
+ <div className="mt-0.5 text-[11px] font-mono text-fg-dim">{r.currentStep}</div>
93
+ )}
94
+ </a>
95
+ ))}
96
+ </div>
97
+ <div className="hidden sm:block">
98
+ <Table>
99
+ <THead>
100
+ <TR><TH>flow</TH><TH>status</TH><TH>currentStep</TH><TH>updated</TH></TR>
101
+ </THead>
102
+ <TBody>
103
+ {stats.recentRuns.map((r) => (
104
+ <TR key={r.flowId}>
105
+ <TD className="font-mono text-xs">
106
+ <a href={`#/runs/${r.flowId}`} className="hover:underline">{r.flowId.slice(0, 12)}…</a>
107
+ </TD>
108
+ <TD><StatusBadge status={r.status} /></TD>
109
+ <TD className="font-mono text-xs text-fg-dim">{r.currentStep ?? ""}</TD>
110
+ <TD className="text-xs text-fg-dim">{fmtRel(r.updatedAt)}</TD>
111
+ </TR>
112
+ ))}
113
+ </TBody>
114
+ </Table>
115
+ </div>
116
+ </>
117
+ )}
118
+ </>
119
+ )}
120
+ </Card>
121
+ );
122
+ }
123
+
124
+ function Stat({ label, value, tone }: { label: string; value: number; tone?: "red" | "amber" | null }) {
125
+ const toneClass = tone === "red" ? "text-status-red" : tone === "amber" ? "text-status-amber" : "text-fg";
126
+ return (
127
+ <div className="border border-border rounded p-2">
128
+ <div className="text-xs text-fg-dim">{label}</div>
129
+ <div className={`font-mono text-lg ${toneClass}`}>{value}</div>
130
+ </div>
131
+ );
132
+ }
@@ -0,0 +1,35 @@
1
+ // Executed-path trail under the run-detail main graph: the flow's visited
2
+ // top-level nodes (from GET /manifold/runs/:flowId/tree — see RunDetail.tsx)
3
+ // rendered as pills with ❯ separators. Consecutive duplicates (a genuine
4
+ // loop-back reentry, e.g. PROPOSE → PROPOSE) get a `repeat` style so the
5
+ // operator can distinguish a single step from the same step happening twice.
6
+
7
+ import { cn } from "@/lib/utils";
8
+
9
+ export function PathTrail({ history }: { history: string[] | null | undefined }) {
10
+ if (!history || history.length === 0) return null;
11
+ const full = ["__start__", ...history];
12
+ return (
13
+ <div className="flex flex-wrap gap-1 items-center mt-2.5 pt-2.5 border-t border-dashed border-border font-mono text-[11px]">
14
+ <span className="text-fg-dim mr-1.5">path · {history.length} step{history.length === 1 ? "" : "s"}:</span>
15
+ {full.map((step, i) => {
16
+ const repeat = i > 0 && full[i - 1] === step;
17
+ return (
18
+ <span key={i} className="flex items-center gap-1">
19
+ <span
20
+ className={cn(
21
+ "px-1.5 py-0.5 rounded border text-[11px] font-mono",
22
+ repeat
23
+ ? "bg-status-green/10 border-status-green/35 text-status-green"
24
+ : "bg-bg-elev2 text-fg border-border"
25
+ )}
26
+ >
27
+ {step}
28
+ </span>
29
+ {i < full.length - 1 && <span className="text-fg-dim text-[10px] mx-0.5">❯</span>}
30
+ </span>
31
+ );
32
+ })}
33
+ </div>
34
+ );
35
+ }