Wiki: open the architecture-deepening goal (spec #20, tickets #21-#26)
This commit is contained in:
1 parent
e1dc44225e
commit
cfec14e515
6 files changed
+634
-3
No files matched your search
+3
-2
@@ -64,8 +64,9 @@ A step consuming the outputs of several steps by name.
|
||||
The persisted per-run record: plan, per-step records, per-item records for each-step fan-out, and bounded outputs.
|
||||
_Avoid_: log, history
|
||||
|
||||
**Expanded plan**:
|
||||
The run's steps after item fan-out is resolved, as returned at start.
|
||||
**Start plan**:
|
||||
The run's plan as admitted: arguments interpolated into step briefs, each-steps still pending their item fan-out.
|
||||
_Avoid_: expanded plan (item fan-out resolves at release, not at start)
|
||||
|
||||
### Ultra
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# Journal-only persistence; no pi-durable dependency
|
||||
|
||||
v1 persists one journal entry per run (plan plus per-step records shaped for replay) but ships no resume machinery, and does not take `pi-durable` as a dependency. `research/pi-durable-async-subagents.md` evaluated durable both as an execution foundation and as a metadata/history store and rejected both: one-writer storage conflicts with the multi-process scheduler, and a second store adds divergence failure modes without solving scheduling. The journal's records adopt durable's task-record vocabulary (step id, input hash, status, attempt count) so future resume implements against the same shape; durable's recovery semantics (restart accounting, positional-vs-named replay) are the reference model when that work starts. Decided 2026-11-26 in the design grilling (issue #3 comment).
|
||||
|
||||
Amended 2026-12-01 in the architecture review: the job snapshot follows the journal's terminal-only granularity — persisted as a small entry at start and a full checkpoint at the terminal transition, never per transition. A run in flight at crash time restores as `interrupted` with no task rows; per-step detail lives only in the journal, which a crash also loses, so the two records stay aligned.
|
||||
@@ -1,3 +1,5 @@
|
||||
# Ultra completion notices push the consolidated answer; every other surface stays pull-based
|
||||
|
||||
A run started by the `ultra` tool is inline-sourced, and when it reaches a terminal state the extension sends a custom message — `pi.sendMessage({ customType: "pi-subagent-ultra-done", content, display: true, details }, { triggerTurn: true })` — carrying the run's status plus the journal's already-bounded output of the last succeeded step. A run with no succeeded step sends its status and error instead of partial output. This is a scoped amendment of the pull-based doctrine: `subagent_async` and `workflow` starts still never start an automatic model turn, and `PI_SUBAGENT_ULTRA_NOTIFY=off` restores pure pull for ultra runs too; `PI_SUBAGENT_ULTRA=off` removes the notice with the rest of the layer. Without this exception ultra mode is a polling chore, and the point of a plan is that the parent's context receives only the consolidated answer rather than every intermediate result. The notice is delivery, not a new record: the run's journal remains the audit record, and the payload reuses the journal's bounded outputs as-is, never re-expanding a child's output. Decided 2026-11-30 in the ultra-layer spec (issue #14).
|
||||
|
||||
Amended 2026-12-01 in the architecture review: pull stays pull-based but is bounded for runs — `subagent_jobs wait` on a run returns the run's status, a per-step summary, and the journal's bounded output of the last succeeded step (status and error when none succeeded), while `get` keeps the full snapshot as the explicit verbose path. A run's intermediate outputs reach the parent only by that explicit request, so both delivery paths carry the consolidated answer; single invocations keep their full results.
|
||||
@@ -0,0 +1,28 @@
|
||||
# Goal: deepen the architecture (run state, real seam, bounded observation)
|
||||
|
||||
The standing goal of this chief-of-staff effort. DRI: the chief-of-staff session. Opened 2026-12-01.
|
||||
|
||||
## What and why
|
||||
|
||||
Deepen six frictions found by the 2026-12-01 architecture review of the post-0.3.0 hot spots (the workflow layer, the workflow-supervisor split, the ultra layer): the run has no first-class state module, the supervisor's host interface is declared but not real, observation callbacks carry whole-state clones (O(N²) in tasks; `wait` returns every intermediate output), the step shape is hand-synced in eight places, `workflow.ts`/`workflows.ts` is a one-letter file-name trap holding three concerns, and task presentation rules fork across three modules. A two-round grilling session settled every decision; the verdicts are baked into the tickets. Full design: spec issue #20; provenance in `research/architecture-review-2026-12-01.html` (the review report with the evidence and before/after diagrams). New ADR amendments: 0006 (the pull path is bounded for runs too), 0004 (checkpoint granularity — start entry + terminal checkpoint). Vocabulary: `GLOSSARY.md` — "Expanded plan" renamed to "Start plan" with the corrected definition. The DAG algorithm itself is not touched (TLA+ spec `spec/SubagentJobs.tla` unchanged).
|
||||
|
||||
## Task graph
|
||||
|
||||
Waves (frontier ≤ 2 in flight):
|
||||
|
||||
- Wave 1: #21 (file split + start-plan rename)
|
||||
- Wave 2: #22 (the seam: `job-state.ts`, shared records, one cancel policy, limits on the run spec)
|
||||
- Wave 3: #23 (the run module: journal as projection) ∥ #24 (step mirrors: canonical step schema, whole-plan hash, TypeBox persisted shapes); merge sequentially (both touch `journal.ts` and `types.ts`)
|
||||
- Wave 4: #25 (observation: events, checkpoint, bounded pull) ∥ #26 (presentation: one rulebook); merge sequentially (both touch `job-format.ts`)
|
||||
- Then: two-axis review on the integration branch (Standards + Spec reviewers in parallel), fix findings in one worker, close tickets, report, retro.
|
||||
|
||||
## State log
|
||||
|
||||
- 2026-12-01: Architecture review complete (scout walk, every load-bearing claim verified against source); report committed to `research/`; grilling session (two rounds) settled all decisions with maintainer verdicts; ADR 0006 and ADR 0004 amended, GLOSSARY "Start plan" rename applied; spec #20 filed with verdicts baked in; tickets #21–#26 filed with native blocking edges (#22←#21, #23←#22, #24←#22, #25←#23, #26←#22), all labelled `ready-for-agent`; integration branch `architecture-deepening` created off main; all five gates green on the baseline — own-run tails: typecheck 2.8s, tests 215/215 (9.6s), TLC 31.6s, smoke 0.5s, wikicheck 0.2s.
|
||||
|
||||
## Conventions for this pipeline
|
||||
|
||||
- Integration branch: `architecture-deepening` (code merges only via merger dispatch; the DRI commits docs and wiki directly).
|
||||
- Worker worktrees: siblings under `../pi-subagent-worktrees/`, one branch `ticket/<slug>` per ticket; `node_modules` symlinked from the main checkout.
|
||||
- Worker briefs: point at `docs/wiki/worker-rules.md` (standing rules), the ticket, the spec, and name skill/doc files by absolute path.
|
||||
- Retro cadence: retro ~1 in 5 worker sessions via the retro skill, failure sessions first.
|
||||
+2
-1
@@ -4,7 +4,8 @@ Memory for the chief-of-staff effort on this repo. Pages cite sources; nothing h
|
||||
|
||||
## Goal
|
||||
|
||||
- [Goal: ship the ultra layer](goal-ultra-layer.md) — the active effort: spec #14, tickets #15–#19, wave state, pipeline conventions.
|
||||
- [Goal: deepen the architecture](goal-architecture-deepening.md) — the active effort: run state, the supervisor seam, bounded observation; spec #20, tickets #21–#26, wave state, pipeline conventions.
|
||||
- [Goal: ship the ultra layer](goal-ultra-layer.md) — shipped 2026-11-30 (0.3.0); kept as the pipeline's record.
|
||||
- [Goal: ship the declarative workflow layer](goal-workflow-layer.md) — shipped 2026-11-26 (0.2.0); kept as the pipeline's record.
|
||||
|
||||
## Operations
|
||||
|
||||
@@ -0,0 +1,597 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Architecture review — pi-subagent</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script type="module">
|
||||
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
|
||||
mermaid.initialize({ startOnLoad: true, theme: "neutral", securityLevel: "loose" });
|
||||
</script>
|
||||
<style>
|
||||
.seam-line { border-left: 2px dashed #64748b; }
|
||||
.leak { color: #dc2626; }
|
||||
.deep-box { background: linear-gradient(135deg, #0f172a, #1e293b); }
|
||||
.field-chip { font-family: ui-monospace, monospace; font-size: 10px; padding: 1px 6px; border-radius: 4px; }
|
||||
.module-box { border: 1px solid #94a3b8; background: #f8fafc; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-stone-50 text-slate-900 font-sans">
|
||||
<main class="max-w-6xl mx-auto px-6 py-12 space-y-14">
|
||||
|
||||
<!-- ============ HEADER ============ -->
|
||||
<header class="space-y-4">
|
||||
<h1 class="text-3xl font-serif font-bold">Architecture review — <span class="text-indigo-700">pi-subagent</span></h1>
|
||||
<div class="flex flex-wrap items-center gap-x-6 gap-y-2 text-xs text-slate-600">
|
||||
<span>2026-12-01</span>
|
||||
<span class="flex items-center gap-1.5"><span class="inline-block w-4 h-3 border border-slate-500 bg-slate-50"></span> module</span>
|
||||
<span class="flex items-center gap-1.5"><span class="inline-block w-5 border-t-2 border-dashed border-slate-500"></span> seam</span>
|
||||
<span class="flex items-center gap-1.5"><span class="inline-block w-5 border-t-2 border-red-600"></span> leakage</span>
|
||||
<span class="flex items-center gap-1.5"><span class="inline-block w-4 h-3 deep-box rounded-sm"></span> deep module</span>
|
||||
</div>
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400">Hot spots scanned: workflow layer, workflow-supervisor, ultra layer, observation path</p>
|
||||
</header>
|
||||
|
||||
<!-- ============ CANDIDATES ============ -->
|
||||
<section id="candidates" class="space-y-12">
|
||||
|
||||
<!-- ============ CANDIDATE 1 ============ -->
|
||||
<article id="c1" class="rounded-xl border border-slate-200 bg-white shadow-sm p-8 space-y-6">
|
||||
<div class="flex items-start justify-between gap-4 flex-wrap">
|
||||
<h2 class="text-xl font-serif font-semibold">A canonical state module for the run</h2>
|
||||
<div class="flex gap-2 shrink-0">
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-semibold bg-emerald-100 text-emerald-800">Strong</span>
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-medium bg-slate-100 text-slate-600">in-process</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="font-mono text-sm text-slate-600 leading-relaxed">src/workflow.ts · src/workflow-supervisor.ts · src/manager.ts · src/journal.ts · src/dashboard.ts · src/job-format.ts · src/render.ts · src/types.ts</p>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-6">
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-2">Before — one run, four shapes</p>
|
||||
<pre class="mermaid">
|
||||
flowchart TB
|
||||
plan["WorkflowPlan — parse"] --> spec["WorkflowRunSpec — prepare"]
|
||||
spec --> dag["WorkflowRunState — supervisor local, dies when run() returns"]
|
||||
spec --> flat["Execution.tasks — flat TaskSnapshot[], the only shape that survives"]
|
||||
dag --> flat
|
||||
flat --> journal["journal — itemsByStep() rebuilds the step/item DAG"]
|
||||
flat --> dash["dashboard"]
|
||||
flat --> jf["job-format"]
|
||||
flat --> rend["render"]
|
||||
restore["restore() — fabricates AgentConfig, never restores the workflow"] -.-> flat
|
||||
linkStyle 4,8 stroke:#dc2626,stroke-width:2px
|
||||
</pre>
|
||||
</div>
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-2">After — one deep run module, thin projections</p>
|
||||
<div class="deep-box rounded-lg p-4 text-white">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-300">run module</p>
|
||||
<div class="mt-2 flex flex-wrap gap-1.5">
|
||||
<span class="field-chip bg-emerald-900/60 text-emerald-200">start</span>
|
||||
<span class="field-chip bg-emerald-900/60 text-emerald-200">cancel</span>
|
||||
<span class="field-chip bg-emerald-900/60 text-emerald-200">snapshot()</span>
|
||||
<span class="field-chip bg-emerald-900/60 text-emerald-200">journal()</span>
|
||||
</div>
|
||||
<p class="mt-3 text-[10px] text-slate-400 leading-relaxed">stepTasks · itemTasks · pendingItems · itemCounts · attempts · restore identity — all inside</p>
|
||||
</div>
|
||||
<p class="text-center text-slate-400 text-xs my-1">↓ projection · ↓ projection · ↓ projection</p>
|
||||
<div class="grid grid-cols-3 gap-2">
|
||||
<div class="module-box rounded p-2 text-center"><p class="text-[10px] uppercase tracking-wider">JobSnapshot</p><p class="text-[9px] text-slate-500">flat view for the job system</p></div>
|
||||
<div class="module-box rounded p-2 text-center"><p class="text-[10px] uppercase tracking-wider">WorkflowJournal</p><p class="text-[9px] text-slate-500">audit record, built not rebuilt</p></div>
|
||||
<div class="module-box rounded p-2 text-center"><p class="text-[10px] uppercase tracking-wider">presentTask</p><p class="text-[9px] text-slate-500">labels for display</p></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-8 text-sm">
|
||||
<div><p class="font-semibold text-slate-700">Problem</p><p class="text-slate-600">One run exists as a plan, a prepared spec, a supervisor-local DAG, and a flat task array — and the journal plus three display modules reverse-engineer the step/item graph from rows that share a <span class="font-mono text-xs">stepId</span>, while restore fabricates agent configs and drops the workflow.</p></div>
|
||||
<div><p class="font-semibold text-slate-700">Solution</p><p class="text-slate-600">Promote the supervisor's run state to the run's canonical module, and make the snapshot, the journal, and task labels projections of it.</p></div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1 text-sm">
|
||||
<p class="font-semibold text-slate-700">Wins</p>
|
||||
<ul class="grid md:grid-cols-2 gap-x-6 list-disc list-inside text-slate-600">
|
||||
<li>locality: one run, one module</li>
|
||||
<li>retries get a home (<span class="font-mono text-xs">attempts</span> already anticipated)</li>
|
||||
<li>journal stops rebuilding the DAG</li>
|
||||
<li>restore keeps step identity, journal eligibility</li>
|
||||
<li>leverage: one interface, three projections</li>
|
||||
<li>tests: every projection from one state</li>
|
||||
</ul>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<!-- ============ CANDIDATE 2 ============ -->
|
||||
<article id="c2" class="rounded-xl border border-slate-200 bg-white shadow-sm p-8 space-y-6">
|
||||
<div class="flex items-start justify-between gap-4 flex-wrap">
|
||||
<h2 class="text-xl font-serif font-semibold">Make the host interface the real seam</h2>
|
||||
<div class="flex gap-2 shrink-0">
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-semibold bg-emerald-100 text-emerald-800">Strong</span>
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-medium bg-slate-100 text-slate-600">in-process</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="font-mono text-sm text-slate-600 leading-relaxed">src/workflow-supervisor.ts · src/manager.ts · test/workflow-run.test.ts</p>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-6">
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-2">Before — the declared seam is bypassed</p>
|
||||
<svg viewBox="0 0 560 300" width="100%" class="mb-2">
|
||||
<defs>
|
||||
<marker id="c2a-red" markerWidth="8" markerHeight="8" refX="7" refY="3" orient="auto"><path d="M0,0 L7,3 L0,6 z" fill="#dc2626"/></marker>
|
||||
</defs>
|
||||
<text x="280" y="14" text-anchor="middle" font-size="9" fill="#64748b">declared seam — WorkflowSupervisorHost (7 methods)</text>
|
||||
<line x1="280" y1="20" x2="280" y2="285" stroke="#64748b" stroke-width="1.5" stroke-dasharray="5 4"/>
|
||||
<rect x="6" y="30" width="208" height="240" rx="6" fill="#f8fafc" stroke="#94a3b8"/>
|
||||
<text x="110" y="48" text-anchor="middle" font-size="10" fill="#475569" letter-spacing="1">MANAGER</text>
|
||||
<rect x="20" y="66" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="110" y="83" text-anchor="middle" font-size="9" fill="#334155">Execution.tasks</text>
|
||||
<rect x="20" y="100" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="110" y="117" text-anchor="middle" font-size="9" fill="#334155">InternalTask.snapshot · .result</text>
|
||||
<rect x="20" y="134" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="110" y="151" text-anchor="middle" font-size="9" fill="#334155">plannedTaskCount</text>
|
||||
<rect x="20" y="168" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="110" y="185" text-anchor="middle" font-size="9" fill="#334155">FIFO pool · settleTask</text>
|
||||
<rect x="20" y="202" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="110" y="219" text-anchor="middle" font-size="9" fill="#334155">cancel paths ×3</text>
|
||||
<rect x="232" y="118" width="96" height="64" rx="4" fill="#fff" stroke="#059669"/>
|
||||
<text x="280" y="132" text-anchor="middle" font-size="8" fill="#065f46">host interface (7)</text>
|
||||
<text x="280" y="145" text-anchor="middle" font-size="7" fill="#334155">schedule · createTask</text>
|
||||
<text x="280" y="156" text-anchor="middle" font-size="7" fill="#334155">settleTask · cancelledResult</text>
|
||||
<text x="280" y="167" text-anchor="middle" font-size="7" fill="#334155">finalize · emit · now</text>
|
||||
<rect x="346" y="30" width="208" height="240" rx="6" fill="#f8fafc" stroke="#94a3b8"/>
|
||||
<text x="450" y="48" text-anchor="middle" font-size="10" fill="#475569" letter-spacing="1">SUPERVISOR</text>
|
||||
<rect x="360" y="66" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="450" y="83" text-anchor="middle" font-size="9" fill="#334155">WorkflowRunState — local to run()</text>
|
||||
<rect x="360" y="100" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="450" y="117" text-anchor="middle" font-size="9" fill="#334155">release / launch / settle</text>
|
||||
<rect x="360" y="134" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="450" y="151" text-anchor="middle" font-size="9" fill="#334155">skip propagation</text>
|
||||
<rect x="360" y="168" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="450" y="185" text-anchor="middle" font-size="9" fill="#334155">cancel — its own policy</text>
|
||||
<text x="280" y="77" text-anchor="middle" font-size="8" fill="#dc2626">execution.tasks ×6</text>
|
||||
<line x1="360" y1="83" x2="206" y2="83" stroke="#dc2626" stroke-width="1.5" marker-end="url(#c2a-red)"/>
|
||||
<text x="280" y="111" text-anchor="middle" font-size="8" fill="#dc2626">snapshot ×11 · result ×7</text>
|
||||
<line x1="360" y1="117" x2="206" y2="117" stroke="#dc2626" stroke-width="1.5" marker-end="url(#c2a-red)"/>
|
||||
<text x="280" y="145" text-anchor="middle" font-size="8" fill="#dc2626">plannedTaskCount +=</text>
|
||||
<line x1="360" y1="151" x2="206" y2="151" stroke="#dc2626" stroke-width="1.5" marker-end="url(#c2a-red)"/>
|
||||
<text x="280" y="205" text-anchor="middle" font-size="8" fill="#dc2626">sets execution.cancelRequested</text>
|
||||
<line x1="360" y1="185" x2="206" y2="212" stroke="#dc2626" stroke-width="1.5" marker-end="url(#c2a-red)"/>
|
||||
</svg>
|
||||
<p class="text-xs text-slate-500">Red traffic crosses the seam directly; the two modules also type-import each other. One adapter (production) — the seam is hypothetical.</p>
|
||||
</div>
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-2">After — state inside, effects through the interface</p>
|
||||
<svg viewBox="0 0 560 300" width="100%" class="mb-2">
|
||||
<defs>
|
||||
<marker id="c2b-slate" markerWidth="8" markerHeight="8" refX="7" refY="3" orient="auto"><path d="M0,0 L7,3 L0,6 z" fill="#475569"/></marker>
|
||||
</defs>
|
||||
<text x="280" y="14" text-anchor="middle" font-size="9" fill="#64748b">real seam — narrow host interface</text>
|
||||
<line x1="280" y1="20" x2="280" y2="285" stroke="#64748b" stroke-width="1.5" stroke-dasharray="5 4"/>
|
||||
<rect x="6" y="30" width="208" height="240" rx="6" fill="#f8fafc" stroke="#94a3b8"/>
|
||||
<text x="110" y="48" text-anchor="middle" font-size="10" fill="#475569" letter-spacing="1">MANAGER</text>
|
||||
<rect x="20" y="66" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="110" y="83" text-anchor="middle" font-size="9" fill="#334155">FIFO pool · workers</text>
|
||||
<rect x="20" y="100" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="110" y="117" text-anchor="middle" font-size="9" fill="#334155">Execution — job record</text>
|
||||
<rect x="20" y="134" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="110" y="151" text-anchor="middle" font-size="9" fill="#334155">snapshots · persistence</text>
|
||||
<rect x="20" y="168" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="110" y="185" text-anchor="middle" font-size="9" fill="#334155">job views (list · get · wait)</text>
|
||||
<text x="110" y="252" text-anchor="middle" font-size="8" fill="#059669">Execution / InternalTask → job-state.ts (cycle gone)</text>
|
||||
<rect x="232" y="110" width="96" height="88" rx="4" fill="#ecfdf5" stroke="#059669"/>
|
||||
<text x="280" y="124" text-anchor="middle" font-size="8" fill="#065f46">host interface</text>
|
||||
<text x="280" y="138" text-anchor="middle" font-size="7" fill="#334155">schedule</text>
|
||||
<text x="280" y="150" text-anchor="middle" font-size="7" fill="#334155">createTask</text>
|
||||
<text x="280" y="162" text-anchor="middle" font-size="7" fill="#334155">settleTask</text>
|
||||
<text x="280" y="174" text-anchor="middle" font-size="7" fill="#334155">finalize</text>
|
||||
<text x="280" y="186" text-anchor="middle" font-size="7" fill="#334155">emit · now</text>
|
||||
<rect x="346" y="30" width="208" height="240" rx="6" fill="#f8fafc" stroke="#94a3b8"/>
|
||||
<text x="450" y="48" text-anchor="middle" font-size="10" fill="#475569" letter-spacing="1">SUPERVISOR</text>
|
||||
<rect x="360" y="62" width="180" height="34" rx="4" fill="#0f172a"/><text x="450" y="78" text-anchor="middle" font-size="9" fill="#f1f5f9">RunState — canonical</text><text x="450" y="90" text-anchor="middle" font-size="7" fill="#94a3b8">stepTasks · itemTasks · attempts</text>
|
||||
<rect x="360" y="112" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="450" y="129" text-anchor="middle" font-size="9" fill="#334155">release / settle / skip policy</text>
|
||||
<rect x="360" y="146" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="450" y="163" text-anchor="middle" font-size="9" fill="#334155">cancel — one policy</text>
|
||||
<rect x="360" y="180" width="180" height="26" rx="4" fill="#fff" stroke="#94a3b8"/><text x="450" y="197" text-anchor="middle" font-size="9" fill="#334155">toSnapshot() · toJournal()</text>
|
||||
<line x1="360" y1="125" x2="216" y2="125" stroke="#475569" stroke-width="1.5" marker-end="url(#c2b-slate)"/>
|
||||
<line x1="360" y1="159" x2="216" y2="159" stroke="#475569" stroke-width="1.5" marker-end="url(#c2b-slate)"/>
|
||||
<line x1="360" y1="193" x2="216" y2="193" stroke="#475569" stroke-width="1.5" marker-end="url(#c2b-slate)"/>
|
||||
<text x="288" y="216" text-anchor="middle" font-size="8" fill="#475569">all effects through the interface</text>
|
||||
</svg>
|
||||
<p class="text-xs text-slate-500">RunState stays inside; a fake host in tests becomes the second adapter — the seam turns real.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-8 text-sm">
|
||||
<div><p class="font-semibold text-slate-700">Problem</p><p class="text-slate-600">The supervisor's interface claims to be the only seam, but the supervisor reads and mutates manager-owned <span class="font-mono text-xs">Execution</span>/<span class="font-mono text-xs">InternalTask</span> fields directly — and no test ever fakes the host, so all 21 workflow-run tests go through a real manager.</p></div>
|
||||
<div><p class="font-semibold text-slate-700">Solution</p><p class="text-slate-600">Give the run state to the supervisor behind an honest, narrow interface (or a pure transition function the manager applies), and move the shared state types out of the manager module.</p></div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1 text-sm">
|
||||
<p class="font-semibold text-slate-700">Wins</p>
|
||||
<ul class="grid md:grid-cols-2 gap-x-6 list-disc list-inside text-slate-600">
|
||||
<li>seam turns real: fake host adapter</li>
|
||||
<li>DAG tests without a manager</li>
|
||||
<li>cancellation policy in one place</li>
|
||||
<li>type cycle between modules dies</li>
|
||||
<li>interface shrinks to what's used</li>
|
||||
<li>locality: state mutation in one module</li>
|
||||
</ul>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<!-- ============ CANDIDATE 3 ============ -->
|
||||
<article id="c3" class="rounded-xl border border-slate-200 bg-white shadow-sm p-8 space-y-6">
|
||||
<div class="flex items-start justify-between gap-4 flex-wrap">
|
||||
<h2 class="text-xl font-serif font-semibold">Emit deltas through the observation seam</h2>
|
||||
<div class="flex gap-2 shrink-0">
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-semibold bg-emerald-100 text-emerald-800">Strong</span>
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-medium bg-slate-100 text-slate-600">local-substitutable</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="font-mono text-sm text-slate-600 leading-relaxed">src/runner.ts · src/manager.ts · src/index.ts · src/job-format.ts · src/persistence.ts · src/activity.ts</p>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-6">
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-2">Before — every transition re-projects the whole job</p>
|
||||
<pre class="mermaid">
|
||||
sequenceDiagram
|
||||
participant C as child
|
||||
participant R as runner
|
||||
participant M as manager
|
||||
participant I as index.ts
|
||||
participant P as session log
|
||||
C->>R: message_end
|
||||
R->>M: onUpdate — full messages array copied
|
||||
M->>M: emit → snapshot() — structuredClone of every task
|
||||
M->>I: onJobChange(whole JobSnapshot)
|
||||
I->>I: manager.list(true) — clone of every active job
|
||||
I->>P: appendEntry(persistedJob) — another clone
|
||||
Note over M,P: per task transition, ×256 tasks ≈ O(N²) clones; one 256-row snapshot ≈ 12 MiB
|
||||
</pre>
|
||||
</div>
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4 flex flex-col">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-3">After — compact events, one checkpoint</p>
|
||||
<div class="flex items-center gap-1 justify-center">
|
||||
<span class="w-2.5 h-2.5 rounded-full bg-slate-400"></span>
|
||||
<span class="flex-1 border-t-2 border-slate-300"></span>
|
||||
<span class="w-2.5 h-2.5 rounded-full bg-slate-400"></span>
|
||||
<span class="flex-1 border-t-2 border-slate-300"></span>
|
||||
<span class="w-2.5 h-2.5 rounded-full bg-slate-400"></span>
|
||||
<span class="flex-1 border-t-2 border-slate-300"></span>
|
||||
<span class="w-2.5 h-2.5 rounded-full bg-slate-400"></span>
|
||||
<span class="flex-1 border-t-2 border-slate-300"></span>
|
||||
<span class="w-4 h-4 rounded-full deep-box"></span>
|
||||
</div>
|
||||
<div class="flex justify-between text-[9px] text-slate-500 mt-1 mb-4">
|
||||
<span>task started</span><span>task finished</span><span>item released</span><span>step settled</span><span class="font-semibold text-slate-700">terminal checkpoint</span>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<div class="module-box rounded p-2.5"><p class="text-[10px] uppercase tracking-wider">formatJob</p><p class="text-xs text-slate-600">default: per-step summary + the last succeeded step's answer; verbose behind a flag</p></div>
|
||||
<div class="module-box rounded p-2.5"><p class="text-[10px] uppercase tracking-wider">wait on a run</p><p class="text-xs text-slate-600">returns the journal's bounded output — the consolidated answer, by default</p></div>
|
||||
</div>
|
||||
<p class="text-xs text-slate-500 mt-4">Events carry what changed (job id, status, changed rows); the whole snapshot is written once, at the terminal transition.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-8 text-sm">
|
||||
<div><p class="font-semibold text-slate-700">Problem</p><p class="text-slate-600">The observation interface carries whole-state projections — the runner copies the full transcript per message, the manager clones the full job per transition, and <span class="font-mono text-xs">wait</span> returns every step and item output with no aggregate bound, so caps stay per-row while cost grows O(N²) in tasks.</p></div>
|
||||
<div><p class="font-semibold text-slate-700">Solution</p><p class="text-slate-600">Emit compact change events plus one checkpoint at the terminal transition, and make the pull paths return bounded summaries by default.</p></div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1 text-sm">
|
||||
<p class="font-semibold text-slate-700">Wins</p>
|
||||
<ul class="grid md:grid-cols-2 gap-x-6 list-disc list-inside text-slate-600">
|
||||
<li>persistence: O(N²) → O(N)</li>
|
||||
<li>parent context receives summary only</li>
|
||||
<li>leverage: bounded wait output</li>
|
||||
<li>checkpoint concentrates the write</li>
|
||||
<li>dashboard refresh stops re-cloning</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="rounded-lg bg-amber-50 border border-amber-200 p-3 text-sm text-amber-800">
|
||||
ADR-0006 tension, not violation: the push notice correctly carries only the last succeeded step, but the pull path the ultra guidance recommends — <span class="font-mono text-xs">subagent_jobs wait</span> — returns every intermediate output, the opposite of the consolidated answer the ADR exists to protect. Deepening this seam <em>strengthens</em> the ADR.
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<!-- ============ CANDIDATE 4 ============ -->
|
||||
<article id="c4" class="rounded-xl border border-slate-200 bg-white shadow-sm p-8 space-y-6">
|
||||
<div class="flex items-start justify-between gap-4 flex-wrap">
|
||||
<h2 class="text-xl font-serif font-semibold">Collapse the step-shape mirrors</h2>
|
||||
<div class="flex gap-2 shrink-0">
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-semibold bg-emerald-100 text-emerald-800">Strong</span>
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-medium bg-slate-100 text-slate-600">in-process</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="font-mono text-sm text-slate-600 leading-relaxed">src/workflows.ts · src/workflow.ts · src/types.ts · src/journal.ts · src/persistence.ts</p>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-6">
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-3">Before — one shape, hand-synced in eight places</p>
|
||||
<div class="grid grid-cols-5 gap-2">
|
||||
<div>
|
||||
<p class="text-[9px] uppercase tracking-wider text-slate-500 mb-1 truncate">WorkflowStep</p>
|
||||
<div class="space-y-0.5">
|
||||
<span class="field-chip block bg-slate-100 text-slate-700">id</span><span class="field-chip block bg-slate-100 text-slate-700">agent</span><span class="field-chip block bg-slate-100 text-slate-700">task</span><span class="field-chip block bg-slate-100 text-slate-700">needs</span><span class="field-chip block bg-slate-100 text-slate-700">each</span><span class="field-chip block bg-slate-100 text-slate-700">model</span><span class="field-chip block bg-slate-100 text-slate-700">cwd</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-[9px] uppercase tracking-wider text-slate-500 mb-1 truncate">STEP_FIELDS</p>
|
||||
<div class="space-y-0.5">
|
||||
<span class="field-chip block bg-slate-100 text-slate-700">id</span><span class="field-chip block bg-slate-100 text-slate-700">agent</span><span class="field-chip block bg-slate-100 text-slate-700">task</span><span class="field-chip block bg-slate-100 text-slate-700">needs</span><span class="field-chip block bg-slate-100 text-slate-700">each</span><span class="field-chip block bg-slate-100 text-slate-700">model</span><span class="field-chip block bg-slate-100 text-slate-700">cwd</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-[9px] uppercase tracking-wider text-slate-500 mb-1 truncate">Expanded…</p>
|
||||
<div class="space-y-0.5">
|
||||
<span class="field-chip block bg-slate-100 text-slate-700">id</span><span class="field-chip block bg-slate-100 text-slate-700">agent</span><span class="field-chip block bg-slate-100 text-slate-700">task</span><span class="field-chip block bg-slate-100 text-slate-700">needs</span><span class="field-chip block bg-slate-100 text-slate-700">each</span><span class="field-chip block bg-slate-100 text-slate-700">model</span><span class="field-chip block bg-slate-100 text-slate-700">cwd</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-[9px] uppercase tracking-wider text-slate-500 mb-1 truncate">Prepared…Step</p>
|
||||
<div class="space-y-0.5">
|
||||
<span class="field-chip block bg-slate-100 text-slate-700">id</span><span class="field-chip block bg-slate-100 text-slate-700">needs</span><span class="field-chip block bg-slate-100 text-slate-700">template</span><span class="field-chip block bg-slate-100 text-slate-700">each</span><span class="field-chip block bg-slate-100 text-slate-700">prepared</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-[9px] uppercase tracking-wider text-slate-500 mb-1 truncate">PreparedTask</p>
|
||||
<div class="space-y-0.5">
|
||||
<span class="field-chip block bg-slate-100 text-slate-700">agent</span><span class="field-chip block bg-slate-100 text-slate-700">task</span><span class="field-chip block bg-slate-100 text-slate-700">cwd</span><span class="field-chip block bg-slate-100 text-slate-700">stepId</span><span class="field-chip block bg-slate-100 text-slate-700">item</span><span class="field-chip block bg-slate-100 text-slate-700">itemValue</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 rounded border border-red-200 bg-red-50 p-2.5 space-y-1">
|
||||
<p class="text-[9px] uppercase tracking-wider leak font-semibold">sync debt — hand-maintained elsewhere</p>
|
||||
<p class="text-xs text-red-800">journal.planInputs — 7 fields re-enumerated; miss one and the <span class="font-mono">inputHash</span> replay contract drifts silently</p>
|
||||
<p class="text-xs text-red-800">persistence validators — already drifted: <span class="font-mono">validTask</span> never checks <span class="font-mono">step</span>; <span class="font-mono">validJob</span> skips <span class="font-mono">startedAt · finishedAt · errorMessage · timedOut</span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-3">After — one list, derived projections</p>
|
||||
<div class="deep-box rounded-lg p-4 text-white">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-300">WorkflowStep — the one field list</p>
|
||||
<div class="mt-2 flex flex-wrap gap-1.5">
|
||||
<span class="field-chip bg-slate-700 text-slate-100">id</span><span class="field-chip bg-slate-700 text-slate-100">agent</span><span class="field-chip bg-slate-700 text-slate-100">task</span><span class="field-chip bg-slate-700 text-slate-100">needs</span><span class="field-chip bg-slate-700 text-slate-100">each</span><span class="field-chip bg-slate-700 text-slate-100">model</span><span class="field-chip bg-slate-700 text-slate-100">cwd</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-center text-slate-400 text-xs my-1.5">↓ ↓ ↓</p>
|
||||
<div class="space-y-2">
|
||||
<div class="module-box rounded p-2.5"><p class="text-[10px] uppercase tracking-wider">projections</p><p class="text-xs text-slate-600 mt-0.5"><span class="font-mono text-[11px]">Pick<WorkflowStep, …></span> — ExpandedWorkflowStep deleted</p></div>
|
||||
<div class="module-box rounded p-2.5"><p class="text-[10px] uppercase tracking-wider">inputHash</p><p class="text-xs text-slate-600 mt-0.5">hash the canonical plan object — new fields included by default</p></div>
|
||||
<div class="module-box rounded p-2.5"><p class="text-[10px] uppercase tracking-wider">validators</p><p class="text-xs text-slate-600 mt-0.5">derive from the type — TypeBox is already a dependency</p></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-8 text-sm">
|
||||
<div><p class="font-semibold text-slate-700">Problem</p><p class="text-slate-600">A step's shape is re-enumerated by hand in five types and three field lists, and the copies have already drifted — a new step field must be added in up to eight places or it silently vanishes from the journal hash, restore, or both.</p></div>
|
||||
<div><p class="font-semibold text-slate-700">Solution</p><p class="text-slate-600">Keep one canonical step type and derive the projections, the journal hash input, and the persistence validators from it.</p></div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1 text-sm">
|
||||
<p class="font-semibold text-slate-700">Wins</p>
|
||||
<ul class="grid md:grid-cols-2 gap-x-6 list-disc list-inside text-slate-600">
|
||||
<li>new step fields: one edit</li>
|
||||
<li>inputHash cannot silently drift</li>
|
||||
<li>validators derive from the type</li>
|
||||
<li>restore stops dropping fields</li>
|
||||
<li>locality: the shape lives once</li>
|
||||
<li>deletion test: three lists deleted</li>
|
||||
</ul>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<!-- ============ CANDIDATE 5 ============ -->
|
||||
<article id="c5" class="rounded-xl border border-slate-200 bg-white shadow-sm p-8 space-y-6">
|
||||
<div class="flex items-start justify-between gap-4 flex-wrap">
|
||||
<h2 class="text-xl font-serif font-semibold">Untangle workflow.ts and workflows.ts</h2>
|
||||
<div class="flex gap-2 shrink-0">
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-semibold bg-amber-100 text-amber-800">Worth exploring</span>
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-medium bg-slate-100 text-slate-600">in-process</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="font-mono text-sm text-slate-600 leading-relaxed">src/workflow.ts · src/workflows.ts · src/index.ts · src/workflow-supervisor.ts</p>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-6">
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-3">Before — one letter apart, three concerns inside</p>
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<div class="module-box rounded-lg overflow-hidden">
|
||||
<p class="px-3 py-1.5 text-sm font-mono font-semibold border-b border-slate-200 bg-slate-50">workflow.t<span class="leak">s</span></p>
|
||||
<div class="text-[10px] divide-y divide-slate-100">
|
||||
<p class="px-3 py-1.5 text-slate-700">run spec · interpolation · <span class="leak">/workflow command parser</span></p>
|
||||
<p class="px-3 py-1.5 text-slate-700">args + run-shape validation</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="module-box rounded-lg overflow-hidden">
|
||||
<p class="px-3 py-1.5 text-sm font-mono font-semibold border-b border-slate-200 bg-slate-50">workflows.t<span class="leak">s</span></p>
|
||||
<div class="text-[10px] divide-y divide-slate-100">
|
||||
<p class="px-3 py-1.5 text-slate-700">plan parsing · discovery · caps</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 space-y-1.5 text-xs">
|
||||
<p class="text-red-700">──▶ workflow-supervisor imports <span class="font-mono">validateWorkflowExpansion</span> — plan parsing in the runtime path</p>
|
||||
<p class="text-red-700">──▶ index.ts imports the command parser — a CLI concern in the run-types module</p>
|
||||
<p class="text-red-700">──▶ every conversation about "workflow" starts with: which file?</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-3">After — one concern per module, honest names</p>
|
||||
<div class="grid grid-cols-3 gap-2">
|
||||
<div class="module-box rounded-lg overflow-hidden">
|
||||
<p class="px-2 py-1.5 text-xs font-mono font-semibold border-b border-slate-200 bg-slate-50">workflow-<br/>plan.ts</p>
|
||||
<p class="px-2 py-1.5 text-[10px] text-slate-700">parse · discover · caps</p>
|
||||
</div>
|
||||
<div class="deep-box rounded-lg overflow-hidden">
|
||||
<p class="px-2 py-1.5 text-xs font-mono font-semibold text-white border-b border-slate-700">workflow-<br/>run.ts</p>
|
||||
<p class="px-2 py-1.5 text-[10px] text-slate-300">run spec · interpolation · release validation</p>
|
||||
</div>
|
||||
<div class="module-box rounded-lg overflow-hidden">
|
||||
<p class="px-2 py-1.5 text-xs font-mono font-semibold border-b border-slate-200 bg-slate-50">workflow-<br/>command.ts</p>
|
||||
<p class="px-2 py-1.5 text-[10px] text-slate-700">/workflow parser · formatter</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 space-y-1.5 text-xs text-slate-600">
|
||||
<p>──▶ supervisor → workflow-run (no plan-parsing import)</p>
|
||||
<p>──▶ index → workflow-command (CLI concern isolated)</p>
|
||||
<p>──▶ names answer "which file?"</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-8 text-sm">
|
||||
<div><p class="font-semibold text-slate-700">Problem</p><p class="text-slate-600">Two modules differ by one letter, and <span class="font-mono text-xs">workflow.ts</span> holds three concerns — run types, interpolation, and the <span class="font-mono text-xs">/workflow</span> command parser — so tracing one each-step spans six modules and every navigation starts with disambiguating the file names.</p></div>
|
||||
<div><p class="font-semibold text-slate-700">Solution</p><p class="text-slate-600">Rename by concern — plan, run, command — so each module has one job and a name that says what it is.</p></div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1 text-sm">
|
||||
<p class="font-semibold text-slate-700">Wins</p>
|
||||
<ul class="grid md:grid-cols-2 gap-x-6 list-disc list-inside text-slate-600">
|
||||
<li>AI-navigability: names answer "which file?"</li>
|
||||
<li>locality: one concern per module</li>
|
||||
<li>CLI concern leaves the run module</li>
|
||||
<li>low risk, mechanical move</li>
|
||||
</ul>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<!-- ============ CANDIDATE 6 ============ -->
|
||||
<article id="c6" class="rounded-xl border border-slate-200 bg-white shadow-sm p-8 space-y-6">
|
||||
<div class="flex items-start justify-between gap-4 flex-wrap">
|
||||
<h2 class="text-xl font-serif font-semibold">One presentation module, three surfaces</h2>
|
||||
<div class="flex gap-2 shrink-0">
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-semibold bg-amber-100 text-amber-800">Worth exploring</span>
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-medium bg-slate-100 text-slate-600">in-process</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="font-mono text-sm text-slate-600 leading-relaxed">src/render.ts · src/job-format.ts · src/dashboard.ts · src/index.ts</p>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-6">
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-3">Before — three projections, three rulebooks</p>
|
||||
<div class="grid grid-cols-3 gap-2 text-[10px]">
|
||||
<div class="module-box rounded p-2">
|
||||
<p class="uppercase tracking-wider text-slate-500 mb-1.5">render.ts<br/><span class="normal-case text-slate-400">TUI</span></p>
|
||||
<p class="leak font-mono">(skipped)</p>
|
||||
<p class="mt-1.5 text-slate-500">failed →</p><p class="font-mono">errorMessage ∥ stderr ∥ output</p>
|
||||
</div>
|
||||
<div class="module-box rounded p-2">
|
||||
<p class="uppercase tracking-wider text-slate-500 mb-1.5">job-format.ts<br/><span class="normal-case text-slate-400">tool text</span></p>
|
||||
<p class="leak font-mono">(skipped: reason)</p>
|
||||
<p class="mt-1.5 text-slate-500">failed →</p><p class="font-mono">Error: … + output</p>
|
||||
</div>
|
||||
<div class="module-box rounded p-2">
|
||||
<p class="uppercase tracking-wider text-slate-500 mb-1.5">dashboard.ts<br/><span class="normal-case text-slate-400">TUI</span></p>
|
||||
<p class="leak font-mono">errorMessage ?? "(skipped)"</p>
|
||||
<p class="mt-1.5 text-slate-500">failed →</p><p class="font-mono">output only</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 rounded border border-red-200 bg-red-50 p-2.5 space-y-1 text-xs text-red-800">
|
||||
<p><span class="font-mono">isFailedResult</span> lives in the TUI renderer but decides the subagent tool's model-facing error (index.ts:89)</p>
|
||||
<p><span class="font-mono">formatUsageStats</span> pulls the TUI module into the tool-text path</p>
|
||||
<p>renderSubagentResult's workflow branch is unreachable from production — test-only</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-3">After — one rulebook, thin surfaces</p>
|
||||
<div class="deep-box rounded-lg p-4 text-white">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-300">task presentation module</p>
|
||||
<p class="mt-1.5 text-xs text-slate-300">one rule per task state — skipped, failed, running, labels — behind one interface</p>
|
||||
</div>
|
||||
<p class="text-center text-slate-400 text-xs my-1.5">↓ ↓ ↓</p>
|
||||
<div class="grid grid-cols-3 gap-2">
|
||||
<div class="module-box rounded p-2 text-center"><p class="text-[10px] uppercase tracking-wider">render</p><p class="text-[9px] text-slate-500">TUI formatting only</p></div>
|
||||
<div class="module-box rounded p-2 text-center"><p class="text-[10px] uppercase tracking-wider">job-format</p><p class="text-[9px] text-slate-500">tool text</p></div>
|
||||
<div class="module-box rounded p-2 text-center"><p class="text-[10px] uppercase tracking-wider">dashboard</p><p class="text-[9px] text-slate-500">TUI rows</p></div>
|
||||
</div>
|
||||
<p class="text-xs text-slate-500 mt-3">The failure predicate moves out of the renderer; the surfaces keep their distinct layouts but share the rules.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-8 text-sm">
|
||||
<div><p class="font-semibold text-slate-700">Problem</p><p class="text-slate-600">The same task state is rendered by three modules with three divergent rulebooks — skipped, failed, and labels each differ — and the failure predicate that decides the model-facing tool error lives inside the TUI renderer, whose workflow branch nothing in production can reach.</p></div>
|
||||
<div><p class="font-semibold text-slate-700">Solution</p><p class="text-slate-600">Merge the rules into one presentation module and leave the three surfaces as thin adapters over it.</p></div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1 text-sm">
|
||||
<p class="font-semibold text-slate-700">Wins</p>
|
||||
<ul class="grid md:grid-cols-2 gap-x-6 list-disc list-inside text-slate-600">
|
||||
<li>one rule per task state</li>
|
||||
<li>three test suites become one</li>
|
||||
<li>unreachable renderer branch deleted</li>
|
||||
<li>failure predicate leaves the TUI</li>
|
||||
<li>locality: wording changes touch once</li>
|
||||
</ul>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<!-- ============ CANDIDATE 7 ============ -->
|
||||
<article id="c7" class="rounded-xl border border-slate-200 bg-white shadow-sm p-8 space-y-6">
|
||||
<div class="flex items-start justify-between gap-4 flex-wrap">
|
||||
<h2 class="text-xl font-serif font-semibold">Thread cap limits through the run spec</h2>
|
||||
<div class="flex gap-2 shrink-0">
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-semibold bg-amber-100 text-amber-800">Worth exploring</span>
|
||||
<span class="px-2.5 py-1 rounded-full text-xs font-medium bg-slate-100 text-slate-600">in-process</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="font-mono text-sm text-slate-600 leading-relaxed">src/workflows.ts · src/prepare.ts · src/workflow-supervisor.ts · src/index.ts · src/config.ts</p>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-6">
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-2">Before — three callers, three sources of truth</p>
|
||||
<pre class="mermaid">
|
||||
flowchart TB
|
||||
env["process.env.PI_SUBAGENT_WORKFLOW_MAX_ITEMS"]
|
||||
v["validateWorkflowExpansion(options ?? env)"]
|
||||
start["prepare — start-time call: every each-step count is 0, cannot fail"]
|
||||
rel["supervisor — release-time call: re-reads process.env"]
|
||||
card["index — review card: load-time config value"]
|
||||
start --> v
|
||||
rel --> v
|
||||
env -.-> v
|
||||
card -. can disagree with enforcement .-> rel
|
||||
linkStyle 3 stroke:#dc2626,stroke-width:2px
|
||||
</pre>
|
||||
<p class="text-xs text-slate-500 mt-1">Tests that want a custom cap must mutate global <span class="font-mono">process.env</span> (the suite runs single-threaded to make that safe).</p>
|
||||
</div>
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||
<p class="text-xs uppercase tracking-wider text-slate-400 mb-3">After — limits ride the run spec</p>
|
||||
<div class="space-y-2">
|
||||
<div class="module-box rounded p-2.5 text-center"><p class="text-[10px] uppercase tracking-wider">config (load time)</p><p class="text-xs text-slate-600 mt-0.5">one value, captured once</p></div>
|
||||
<p class="text-center text-slate-400 text-xs">↓</p>
|
||||
<div class="deep-box rounded p-2.5 text-center"><p class="text-[10px] uppercase tracking-wider text-slate-300">WorkflowRunSpec.limits</p><p class="text-xs text-slate-300 mt-0.5">required argument — no env seam, review card and enforcement share it</p></div>
|
||||
<p class="text-center text-slate-400 text-xs">↓</p>
|
||||
<div class="module-box rounded p-2.5 text-center"><p class="text-[10px] uppercase tracking-wider">release-time check</p><p class="text-xs text-slate-600 mt-0.5">uses spec.limits; the no-op start call becomes validatePlanShape</p></div>
|
||||
</div>
|
||||
<p class="text-xs text-slate-500 mt-3">Tests inject caps through the interface; the run path never touches <span class="font-mono">process.env</span>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid md:grid-cols-2 gap-8 text-sm">
|
||||
<div><p class="font-semibold text-slate-700">Problem</p><p class="text-slate-600">Cap enforcement reads <span class="font-mono text-xs">process.env</span> at release time while the review card and ultra guidance use the value captured at extension load, the start-time call is a guaranteed no-op, and a run-level cap violation is reported as a plan-validation error on the step.</p></div>
|
||||
<div><p class="font-semibold text-slate-700">Solution</p><p class="text-slate-600">Make limits a required argument captured once and threaded through the run spec, and say exactly what the start-time check checks.</p></div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1 text-sm">
|
||||
<p class="font-semibold text-slate-700">Wins</p>
|
||||
<ul class="grid md:grid-cols-2 gap-x-6 list-disc list-inside text-slate-600">
|
||||
<li>cap semantics in one argument</li>
|
||||
<li>tests stop mutating process.env</li>
|
||||
<li>review card matches enforcement</li>
|
||||
<li>no-op check becomes honest shape check</li>
|
||||
</ul>
|
||||
</div>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<!-- ============ LEFT ALONE ============ -->
|
||||
<section id="left-alone" class="rounded-xl border border-slate-200 bg-white p-6">
|
||||
<h2 class="text-lg font-serif font-semibold mb-3">Left alone — passed the deletion test</h2>
|
||||
<div class="grid md:grid-cols-2 gap-x-8 gap-y-1.5 text-sm text-slate-600">
|
||||
<p><span class="font-medium text-slate-800">TaskRunner / ProcessRunner seam</span> — two real adapters (process + FakeRunner); the model the supervisor seam should copy.</p>
|
||||
<p><span class="font-medium text-slate-800">PrepareContext</span> — structural seam with a compile-time guard; tests pass a small fake.</p>
|
||||
<p><span class="font-medium text-slate-800">output.ts · activity.ts</span> — deep, pure, property-tested; only their call sites are costly (candidate 3).</p>
|
||||
<p><span class="font-medium text-slate-800">config.ts</span> — consistent fallback cascade, tested.</p>
|
||||
<p><span class="font-medium text-slate-800">The DAG algorithm itself</span> — release order, skips, fail-soft items well covered (21 run tests + TLA+ spec); the interface around it is the problem, not the code.</p>
|
||||
<p><span class="font-medium text-slate-800">ultra-keyword · ultra-notify</span> — real modules with direct tests. <span class="font-mono text-xs">ultra.ts</span> is thin and its start formatter duplicates workflow's — fold into candidate 6, don't restructure the layer.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ============ TOP RECOMMENDATION ============ -->
|
||||
<section id="top-recommendation" class="rounded-xl border-2 border-emerald-600 bg-emerald-50/50 p-8">
|
||||
<p class="text-xs uppercase tracking-wider text-emerald-700 font-semibold mb-2">Top recommendation</p>
|
||||
<h2 class="text-2xl font-serif font-bold"><a href="#c2" class="text-emerald-800 hover:underline">Make the host interface the real seam</a></h2>
|
||||
<p class="mt-2 text-slate-700 max-w-3xl">It is the enabling move: once the run state sits behind an honest interface, candidate 1 builds directly on it (promote that state to the canonical run module), a fake host becomes the second adapter that makes the seam real, and the DAG's skip, cancel, and item semantics gain a test surface that no longer fabricates manager internals or needs temp agent directories. It is also the lowest-risk of the three structural candidates — mostly moving types and narrowing mutations, with the 21 existing run tests as the safety net.</p>
|
||||
</section>
|
||||
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user