resolve main merge conflicts for alert context and beads state

This commit is contained in:
dirtydishes 2026-05-17 21:12:19 -04:00
commit dc932cf18e
11 changed files with 843 additions and 153 deletions

View file

@ -0,0 +1,194 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>ClickHouse Alert Context Hydration</title>
<style>
:root {
color-scheme: dark;
--bg: #06080b;
--panel: #111820;
--panel-soft: #0d141b;
--border: rgba(255, 255, 255, 0.12);
--text: #e6edf4;
--dim: #90a0b2;
--faint: #6e7b8c;
--accent: #f5a623;
--accent-soft: rgba(245, 166, 35, 0.14);
--ok: #25c17a;
}
body {
margin: 0;
background: var(--bg);
color: var(--text);
font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
main {
max-width: 980px;
margin: 0 auto;
padding: 42px 22px 64px;
}
header {
padding-bottom: 22px;
border-bottom: 1px solid var(--border);
}
h1,
h2 {
margin: 0;
line-height: 1.15;
}
h1 {
font-size: 1.8rem;
letter-spacing: 0.01em;
}
h2 {
margin-top: 30px;
font-size: 0.9rem;
color: var(--accent);
text-transform: uppercase;
letter-spacing: 0.12em;
}
p {
max-width: 74ch;
color: var(--dim);
}
ul {
display: grid;
gap: 8px;
padding-left: 20px;
color: var(--dim);
}
code {
padding: 2px 5px;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--panel-soft);
color: var(--text);
font-family: "SFMono-Regular", Consolas, monospace;
font-size: 0.9em;
}
pre {
overflow: auto;
padding: 14px;
border: 1px solid var(--border);
border-radius: 10px;
background: var(--panel);
}
.summary {
margin-top: 16px;
padding: 16px 18px;
border: 1px solid rgba(245, 166, 35, 0.28);
border-radius: 12px;
background: var(--accent-soft);
}
.status {
display: inline-flex;
margin-top: 12px;
padding: 4px 9px;
border: 1px solid rgba(37, 193, 122, 0.34);
border-radius: 999px;
color: var(--ok);
font-size: 0.72rem;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
</style>
</head>
<body>
<main>
<header>
<h1>ClickHouse Alert Context Hydration</h1>
<p class="summary">
Alert detail drawers now fetch persisted investigative context from ClickHouse by alert trace id, then merge linked flow packets and option prints into the existing pinned evidence maps.
</p>
<span class="status">Validated</span>
</header>
<section>
<h2>Summary</h2>
<p>
This change makes alert details durable. Selecting an alert no longer depends only on the live cache to resolve evidence; the terminal asks the API for a ClickHouse-backed alert context bundle and uses that bundle to populate the existing drawer, classifier support, smart-money support, and prefetch evidence stores.
</p>
</section>
<section>
<h2>Changes Made</h2>
<ul>
<li>Added <code>fetchAlertContextByTraceId</code> in storage to load an alert, linked flow packets, linked option prints, and unresolved evidence refs.</li>
<li>Added <code>GET /flow/alerts/:trace_id/context</code> to the API without changing existing alert list, history, replay, or websocket feeds.</li>
<li>Updated the terminal alert selection effect to fetch persisted context in live, replay, and history modes.</li>
<li>Merged hydrated packets and prints into pinned maps so existing evidence consumers share the resolved context.</li>
<li>Adjusted alert drawer copy and loading state to reference persisted context rather than live cache misses.</li>
<li>Expanded alert evidence print rows with execution NBBO side, bid, ask, mid, spread, quote age, underlying spot, bid, ask, and mid where available.</li>
</ul>
</section>
<section>
<h2>Context</h2>
<p>
Alert rows intentionally remain lightweight for live bursts. The detail drawer is the right place to hydrate heavier investigative context because it runs only when a user asks for a specific alert. The authoritative linkage remains <code>AlertEvent.evidence_refs</code>.
</p>
</section>
<section>
<h2>Important Implementation Details</h2>
<p>The new API response shape is:</p>
<pre><code>{
alert: AlertEvent | null,
flow_packets: FlowPacket[],
option_prints: OptionPrint[],
missing_refs: string[]
}</code></pre>
<p>
Flow packet refs are resolved with both prefixed and unprefixed candidates. Option print refs are resolved by <code>trace_id</code>. Missing refs are returned explicitly instead of failing the whole response.
</p>
</section>
<section>
<h2>Expected Impact for End-Users</h2>
<p>
Alert details should feel more trustworthy after cache churn or replay navigation. Users can select an older or non-hot alert and still see the preserved evidence context needed to evaluate the signal.
</p>
</section>
<section>
<h2>Validation</h2>
<ul>
<li><code>bun test packages/storage/tests</code></li>
<li><code>bun test services/api/tests</code></li>
<li><code>bun test apps/web/app/terminal.test.ts</code></li>
<li><code>bun --cwd=apps/web run build</code></li>
</ul>
</section>
<section>
<h2>Issues, Limitations, and Mitigations</h2>
<ul>
<li>The endpoint is detail-time only, which avoids making alert list payloads heavier during bursts.</li>
<li>Malformed trace ids are rejected by route-level validation.</li>
<li>Missing evidence refs remain visible to the drawer as diagnostics rather than hiding partial context.</li>
<li>No schema migration was needed because option prints already persist execution context fields.</li>
</ul>
</section>
<section>
<h2>Follow-up Work</h2>
<p>No follow-up beads issue was filed. The requested storage, API, frontend, tests, build, and documentation work is complete.</p>
</section>
</main>
</body>
</html>

View file

@ -0,0 +1,151 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Turn Document - Deploy Allowlist PR Packaging</title>
<style>
:root {
color-scheme: dark;
--bg: #0a1118;
--panel: #121b24;
--panel-2: #0d151e;
--border: rgba(255, 255, 255, 0.14);
--text: #e6edf3;
--muted: #95a8bb;
--accent: #89d1ff;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: "Segoe UI", Tahoma, sans-serif;
background: linear-gradient(180deg, #09121a 0%, #060b10 100%);
color: var(--text);
}
main {
width: min(960px, calc(100vw - 32px));
margin: 0 auto;
padding: 28px 0 40px;
}
section {
background: var(--panel);
border: 1px solid var(--border);
border-radius: 14px;
padding: 20px 22px;
margin-bottom: 16px;
}
h1, h2 { margin-top: 0; }
h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.08em; }
p, li { line-height: 1.6; }
code, pre { font-family: "IBM Plex Mono", Menlo, monospace; }
code { color: var(--accent); }
pre {
margin: 0;
padding: 12px;
border-radius: 10px;
overflow-x: auto;
border: 1px solid var(--border);
background: var(--panel-2);
}
.meta { color: var(--muted); }
</style>
</head>
<body>
<main>
<section>
<h1>Deploy Allowlist PR Packaging</h1>
<p>
Packaged the deploy allowlist cleanup into a PR-ready branch with multiple commits, documented all changes,
and tracked work in Beads issue <code>islandflow-9j5</code>.
</p>
<p class="meta">Generated: 2026-05-17 11:48 EDT</p>
</section>
<section>
<h2>Summary</h2>
<p>
Removed <code>deployment/npm/</code> from the deploy script's remote untracked allowlist so deploy preflight
only tolerates the required signal-cli tarball artifact.
</p>
</section>
<section>
<h2>Changes Made</h2>
<ul>
<li>Updated <code>scripts/deploy.ts</code> to tighten <code>ALLOWED_REMOTE_UNTRACKED</code>.</li>
<li>Created this turn document in <code>docs/turns/</code> as required by repository workflow.</li>
<li>Tracked and managed the work through Beads issue <code>islandflow-9j5</code>.</li>
</ul>
</section>
<section>
<h2>Context</h2>
<p>
The deploy preflight checks remote repository cleanliness before rollout. Keeping broad allowlist exceptions
can hide stale or accidental files on the target host and reduce deployment confidence.
</p>
</section>
<section>
<h2>Important Implementation Details</h2>
<p>
The allowlist now contains only:
</p>
<pre><code>deployment/docker/signal-cli-0.14.3-Linux-native.tar.gz</code></pre>
<p>
The removed entry:
</p>
<pre><code>deployment/npm/</code></pre>
<p>
This change ensures remote preflight fails if <code>deployment/npm/</code> appears unexpectedly.
</p>
</section>
<section>
<h2>Expected Impact for End-Users</h2>
<ul>
<li>Deployments should fail faster when unexpected remote workspace artifacts exist.</li>
<li>Operators get stricter hygiene checks before production rollouts.</li>
<li>No runtime behavior change to API/web/services outside deploy validation logic.</li>
</ul>
</section>
<section>
<h2>Validation</h2>
<ul>
<li>
<code>bun test</code> was run for the repository and reported 2 failing tests plus 1 module-loading error:
<code>services/api/tests/live.test.ts</code> (hot-head cap expectation mismatch) and
<code>apps/web/app/terminal.test.ts</code> (Next navigation export mismatch).
</li>
<li>
The user requested skipping dependency-install remediation before completion, so no additional test-fix work
was performed in this turn.
</li>
<li><code>git diff</code> review to confirm only intended allowlist and documentation updates were included.</li>
</ul>
</section>
<section>
<h2>Issues, Limitations, and Mitigations</h2>
<ul>
<li>
This turn did not add new deploy integration tests for the allowlist branch logic. Mitigation: kept the
change scoped to one constant and validated via repository test run plus manual diff inspection.
</li>
<li>
A local untracked signal-cli tarball remains in the working tree by design and was not added to Git.
</li>
</ul>
</section>
<section>
<h2>Follow-up Work</h2>
<ul>
<li>No additional follow-up issues were created from this scoped cleanup.</li>
<li>If full CI confidence is required, run <code>bun install</code> and <code>bun test</code> in a dependency-ready environment.</li>
</ul>
</section>
</main>
</body>
</html>