repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

docs(ultra): plan actionable failures

5bdb27b305b69102fb8f43ee1a4ec2ef54cd9570

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (1)

+164 / −0 text lines

Diff layout

docs/super/plans/2026-07-13-ultra-actionable-failures.md

Added
new file mode 100644

+164 / −0 text lines

1# Ultra Actionable Failures Implementation Plan
2
3> **For agentic workers:** REQUIRED SUB-SKILL: Use /skill:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4
5**Goal:** Give outer orchestrators and later linear phases typed, bounded, actionable diagnostics for every dropped Ultra step.
6
7**Architecture:** The runner classifies expected failures into a discriminated `RunStepResult`; the engine enriches failures with phase position and item context; interpolation exposes prior failures through `{PHASE.failures}`. The tool returns the same structures externally, while UI formatting stays compact unless expanded.
8
9**Tech Stack:** TypeScript, TypeBox, Vitest, Pi extension APIs
11**Roadmap:** None
13**Phase:** Single-plan implementation
15---
17## Task 1: Typed runner failures
19**Files:**
21- Modify: `extensions/ultra/runner.ts`
22- Modify: `extensions/ultra/__tests__/runner.test.ts`
24- [ ] **Step 1: Add failing tests**
26Cover auth, transport, invalid JSON, schema, missing structured output, session creation/prompt exceptions, manual/external abort, attempt counts, model/thinking metadata, and 2,000-character transcript-tail capping.
28- [ ] **Step 2: Run focused tests to verify RED**
30```bash
31mise //extensions/ultra:test -- runner
32```
34- [ ] **Step 3: Implement `StepFailure` and discriminated results**
36Remove top-level `reason`, classify every expected terminal runner failure, catch tool-session exceptions, track manual abort, and retain only a bounded transcript tail.
38- [ ] **Step 4: Run focused tests to verify GREEN**
40```bash
41mise //extensions/ultra:test -- runner
42```
44- [ ] **Step 5: Commit**
46```bash
47git add extensions/ultra/runner.ts extensions/ultra/__tests__/runner.test.ts
48git commit -m "feat(ultra): classify subagent failures"
49```
51## Task 2: Phase failures and interpolation
53**Files:**
55- Modify: `extensions/ultra/engine.ts`
56- Modify: `extensions/ultra/interp.ts`
57- Modify: `extensions/ultra/__tests__/engine.test.ts`
58- Modify: `extensions/ultra/__tests__/interp.test.ts`
59- Modify: other Ultra tests constructing failed `RunStepResult` values
61- [ ] **Step 1: Add failing interpolation tests**
63Cover `{PHASE.failures}` in templates, selectors, `where`, unknown phases, and recovery fan-out.
65- [ ] **Step 2: Add failing engine tests**
67Cover positional failure records, `phaseFailures`, item/index/agent enrichment, launched and unlaunched aborts, skipped phases, recovery `when`/`over`, and return selection.
69- [ ] **Step 3: Run focused tests to verify RED**
71```bash
72mise //extensions/ultra:test -- interp engine
73```
75- [ ] **Step 4: Implement failure context**
77Add the failures namespace to interpolation, derive `phaseFailures` during normalization, and include it in the final workflow result.
79- [ ] **Step 5: Update failed-result fixtures**
81Replace old `reason` fixtures with typed failures without adding compatibility paths.
83- [ ] **Step 6: Run focused tests to verify GREEN**
85```bash
86mise //extensions/ultra:test -- interp engine
87```
89- [ ] **Step 7: Commit**
91```bash
92git add extensions/ultra
93git commit -m "feat(ultra): expose failures to recovery phases"
94```
96## Task 3: External result, UI, and authoring contract
98**Files:**
100- Modify: `extensions/ultra/wire.ts`
101- Modify: `extensions/ultra/index.ts`
102- Modify: `extensions/ultra/README.md`
103- Modify: `extensions/ultra/skills/authoring-workflows/SKILL.md`
104- Modify: `extensions/ultra/skills/authoring-workflows/references/spec-format.md`
105- Modify: `extensions/ultra/__tests__/wire.test.ts`
106- Modify: `extensions/ultra/__tests__/ui.test.ts`
107- Modify: `extensions/ultra/__tests__/harness.test.ts`
109- [ ] **Step 1: Add failing result-format tests**
111Require collapsed short failure lines, expanded typed diagnostics, and tool JSON containing `phaseFailures`.
113- [ ] **Step 2: Implement formatting and fallback result shapes**
115Render structured failures without exposing full transcripts in collapsed mode and update background/error fallback objects.
117- [ ] **Step 3: Document explicit linear recovery**
119Document failure fields, `{PHASE.failures}`, `when`/`over` recovery, bounded transcript tails, and the absence of automatic loops/timeouts.
121- [ ] **Step 4: Run Ultra tests**
123```bash
124mise //extensions/ultra:test
125```
127- [ ] **Step 5: Commit**
129```bash
130git add extensions/ultra
131git commit -m "docs(ultra): document linear failure recovery"
132```
134## Task 4: Verification
136**Files:**
138- No new production files expected
140- [ ] **Step 1: Run repository gates**
142```bash
143mise run check
144mise run lint
145mise run test
146```
148- [ ] **Step 2: Run a real recovery workflow**
150Use a temporary project and inline workflow where one phase deterministically fails structured output and a later phase consumes `{PHASE.failures}`.
152Assert the recovery agent receives code, retryability, attempts, item, model, and transcript tail, and the outer result contains identical diagnostics.
154- [ ] **Step 3: Verify infinite runtime remains unchanged**
156Confirm no timeout setting, timer race, or timeout failure code exists in Ultra runtime files.
158- [ ] **Step 4: Clean temporary artifacts**
160Delete only temporary verification files created for this plan.
162- [ ] **Step 5: Commit only verification-driven corrections**
164Do not create an empty verification commit.