Skip to content

Instantly share code, notes, and snippets.

@aviadr1
Created March 26, 2026 21:59
Show Gist options
  • Select an option

  • Save aviadr1/572da88a1467440b070e19a6ee64b614 to your computer and use it in GitHub Desktop.

Select an option

Save aviadr1/572da88a1467440b070e19a6ee64b614 to your computer and use it in GitHub Desktop.
Planning Quality Research — Round 5: Final (Grand Synthesis, Implementation Roadmap, Simple Mental Model)

R5: Grand Synthesis — The Full Picture

March 2026


1. What We Now Know for Certain

About the failure mode at the issue→plan boundary:

The agent does not make bad decisions at design forks. It fails to perceive the fork as a fork. Once it finds a technically valid path, it enters execution mode without noticing that alternatives exist or that the path's failure modes differ from alternatives in survival-critical ways. This is not ignorance — it is the absence of a trigger that would convert execution-mode into design-mode. The failure is a perception failure, not a reasoning failure.

The GitHub evidence confirms five failure categories: (1) plan addresses work items but not the observable goal, (2) proposed fix treated as specification rather than hypothesis, (3) single design implemented without surface-the-choice question, (4) implementation placed where it cannot be unit-tested, (5) plan designed before codebase survey. In 7 of 8 documented failures, the information needed to avoid the mistake was present in the issue body or in adjacent repository artifacts. The failures arose from what agents chose not to look at, not from information gaps.

About the root cause:

Two mechanisms cause this. First, the planning phase of kaizen-evaluate has no mandatory grounding step between "read the issue" and "draft the plan." Plan formation begins with whatever the agent's first interpretation produces. The issue body's goal is not extracted before work items are listed; existing tools are not surveyed before new abstractions are designed; the proposed fix's assumption is not named before implementation is planned. These omissions compound: a plan that misses the goal passes plan-coverage review (which checks requirements, not goals) and reaches implementation.

Second, agents lack indexed negative exemplars for this codebase. The review-findings loss incident, the OOM stop-hook incident, the cross-worktree contamination — these failures are documented in GitHub issues but not retrievable at planning time. An agent forming a plan that uses the accumulate-then-flush shape has no path from "proposed design" to "this shape has failed here before, specifically." The principle is known (state resilience matters); the indexed negative exemplar is not available.

About the solution space:

The five pre-plan questions (R4C's Phase 4.5) address 4 of 5 failure categories with zero infrastructure. They are the highest-leverage intervention. The FSI / Category Library adds indexed retrieval of past failures and transforms known failure categories into recognition-fast priors — but requires bootstrap data from real incidents and is not the right first step. The Plan Battery formalizes quality checks as enforcement gates but, per the pre-mortem, risks false confidence from text-that-looks-correct and overhead creep if not scoped precisely to blocking-worthy failures. The right architecture sequences all three but builds them in the correct order.


2. The Complete Theory of the Issue→Plan Gap

The gap is not informational. It is architectural: the issue→plan transformation has no retrieval phase and no structured pre-plan formation discipline. The agent reads the issue body once, linearly, and begins planning from its first interpretation.

This produces plans that address what the issue says to build rather than what will make the problem stop happening. The plan inherits the issue's proposed solution without questioning it. It designs from first principles without checking what already exists. It commits to a single architecture without naming the one it's competing against. It assigns behavior to a location without verifying that location is testable in isolation. All four omissions can be present simultaneously, and plan-coverage review — which checks completeness — passes all four.

The root cause is that plans are downstream commitment points but upstream grounding is absent. Plans are reviewed after formation for completeness. They are not reviewed before formation for grounding quality. The missing phase is what a staff engineer does before drafting any plan: extract what "done" means in observable terms, survey what already exists, name the choice at the highest-risk design fork, ask whether the proposed fix's assumption is correct, and confirm the implementation location is testable. These five operations are prior to planning, not part of the plan.

What the evidence shows: when this grounding is absent, the plan can be technically correct, pass all coverage checks, and still produce implementations that build the wrong infrastructure, miss the observable goal, or create test-free zones. The fix is not more review after plan formation — it is mandatory grounding before plan formation begins.

The category library and FSI add a second layer: retrieved failure history converts "I know state resilience is a principle" into "I know this specific design shape has failed in this codebase." The distinction is the same one that separates abstract knowledge from indexed negative exemplars. Without retrieval, agents apply general principles correctly but miss specific traps the codebase has already encountered.


3. The Three-Tier Solution Architecture

Tier 1 (Now, 1 PR): Phase 4.5 in kaizen-evaluate — the five mandatory pre-plan steps

Insert Phase 4.5 between Phase 4 (Critique Spec) and Phase 5 (Ask Admin). Five sequential steps: extract success criteria (GOAL + DONE WHEN before reading any code), survey existing tools (grep before designing), generate and reject at least one alternative (name the highest-risk choice and its failure mode), validate the hypothesis (state the assumption, run the fastest test to confirm or falsify), map testability seams (name the file, test file, and seam for each significant behavior before deciding where it lives). Concrete skill text for each step is ready in R4C.

Time cost: 10-20 minutes per evaluation. Addresses: categories 1, 2, 3, 4 from the failure taxonomy. Infrastructure cost: zero. This is the MVC. The five steps are not a checklist — each one requires looking at something the agent has not yet looked at. The sequence matters: GOAL before code, survey before design, alternatives before commitment, hypothesis before plan, seam before location.

Tier 2 (Next, 1-2 PRs): Plan schema enforcement + FSI bootstrap

Two additions. First: enforce the structured plan schema in store-plan — the sections ## Success Criteria, ## Information Retrieved, ## Design Alternatives Considered, ## Seam Map, ## Test Plan must be present. Warn (not error) on missing sections, surface warnings visibly. This creates an auditable trail: a future reviewer can see whether Phase 4.5 was actually performed, not just whether a plan was stored.

Second: build src/cli-experience.ts with add-entry and query subcommands, bootstrap .claude/kaizen/failure-signatures/ with 5 entries from known incidents (review-findings loss, OOM stop-hook, WSL2 /proc hang, cross-worktree contamination, KAIZEN_UNFINISHED false positive). Add Phase 0.7 to kaizen-evaluate: if the FSI store has entries, query by issue keywords before plan formation begins. Wire add-entry into /kaizen-reflect as a mandatory step when filing issues with FSI-eligible labels. This makes experience accumulation automatic and gives the Recurrence weight R in the DPS formula an empirical grounding.

Tier 3 (Later, 2-3 PRs): Category Library + recognition algorithm + plan battery

The full category library: 10 YAML files under .claude/kaizen/categories/, each with recognition signature, structural test, failure topology, resilient/fragile shape taxonomy, and incident links. The recognition algorithm: three-pass (keyword pre-filter, structural test, precursor signals), under 60 seconds, outputs confirmed categories with confidence scores. The plan battery: 7 dimensions from R3's plan battery spec, enforced after store-plan, blocking on goal-traceability, hypothesis-validation, codebase-survey, and design-alternatives when the plan touches irreversible decisions.

This tier requires Tier 2's FSI data to be calibrated. Build categories from incidents, not from theory. The pre-mortem risks (false confidence, overhead creep, category capture) apply at this tier; mitigations are incorporated (executable grep output rather than prose claims, match-confidence threshold to prevent ambiguous matches from loading wrong priors, soft-block on most dimensions to preserve autonomy).


4. Behavioral Changes at Each Tier

Before Tier 1: Agent reads issue, forms plan based on first interpretation, proceeds. Plans routinely miss the goal while passing coverage review. No record of whether alternatives were considered. Testability gaps discovered after 70 lines are written in main().

After Tier 1: Agent is forced to write DONE WHEN before reading any code — this single discipline prevents goal-drift. Agent runs grep before designing — this surfaces existing tools that would have been reinvented. Agent names the highest-risk design choice and states what would disqualify the alternative — the orchestrator-batch vs. agent-stores question gets asked, not defaulted. Hypothesis about the proposed fix is stated and tested before planning — wrong-root-cause implementations are caught. Testability seam is named before location is chosen — behaviors get extracted to testable modules. The four most expensive failure categories are addressed.

After Tier 2: Plans carry auditable records of what was retrieved. FSI queries surface "this design shape failed here before" at planning time. The Recurrence weight R is evidence-grounded. Kaizen-reflect automatically captures new failures into the index. The gap between "principle known" and "negative exemplar retrievable" begins closing.

After Tier 3: Category recognition fires before design evaluation begins, loading failure topology for the matched category. The agent doesn't reason from scratch about state resilience — it loads "session-boundary-state" category, sees "accumulate-then-flush" is fragile, proceeds with write-through as prior. Plan battery provides a formal gate with enforcement. Proportionality is automatic: clean category match + high confidence = near-zero overhead; novel territory = full exploration with explicit documentation.


5. The Staff Engineer Analogy Fully Resolved

After five rounds, the honest answer:

What is trainable (encodable in skills and tools): category recognition given a curated library, option generation and comparison as mechanical steps, adversarial simulation when explicitly prompted, proportionality calculation given explicit signals, the format of design thinking (name category → sketch options → state failure modes → choose). An agent given a good category library and Phase 4.5 discipline will match staff engineer judgment on known categories.

What requires accumulated incident history: the ability to weight failure modes by visceral salience. A staff engineer who burned on state-resilience failures feels unease when writing session-scoped state before articulating why. That unease is not articulable as a rule — it is procedural memory built over hundreds of incidents, each emotionally weighted. The agent's equivalent is the FSI's confirmed_recurrences field: not felt weight, but counted recurrence. It's a functional substitute, not the same thing.

What is genuinely irreducible: anomaly detection — noticing that something doesn't fit the prototype. Human experts notice this before articulating why; the feeling precedes the analysis. AI agents can simulate the output of anomaly detection (generate failure scenarios, falsify hypotheses) but cannot replicate the precognitive trigger. The pre-mortem's "category capture" failure mode illustrates this: an agent under pressure takes the closest category match without the human expert's felt sense that the match is wrong.

The calibration target is not "give the agent staff engineer judgment." It is "make the agent behaviorally equivalent to a staff engineer on known failure categories, and make it explicitly slower in novel territory." That is achievable. The 80% coverage that the trainable elements provide is worth building for. The 20% irreducible gap is worth naming, not pretending closed.


6. The Virtuous Cycle

The loop:

Incident/kaizen-reflect files issue with FSI-eligible label → mandatory add-entry --from-issue N → new FSI entry added to index, matched to existing category or flagged for new category creation.

FSI entry → at planning time, Phase 0.7 queries by issue keywords and shape → top-3 entries injected into agent context before plan formation → agent's Information Retrieved section cites the retrieved entry by name.

Better planning → Phase 4.5 grounds the plan + FSI entry warns against specific anti-pattern → plan selects preferred shape → implementation avoids the failure → no new incident for this category.

Category stabilization → FSI entries for this category accumulate positive outcomes (preferred_pattern_selected) → confidence increases → future retrievals surface this category faster → cost of recognition falls toward near-zero for this failure class.

Novel failure (the loop's other branch) → failure not in FSI, not in category library → incident filed → becomes FSI entry → was_category_retrieved_at_design_time: false flags retrieval gap → missing keyword added to FSI entry's surface_trigger_keywords → future issues with that vocabulary trigger retrieval.

The loop is asymptotically self-improving for the known failure space and self-expanding for the novel failure space. What it cannot do: prevent a genuinely novel failure mode in territory the library has never encountered. The pre-mortem's concurrent-write-on-shared-document example remains outside the loop until it happens once.


7. The Risks That Matter

From the pre-mortem, ranked by likelihood:

Most likely: false confidence from well-formed but ungrounded plan text. The battery evaluates text. Text can be correct-looking without being grounded — a plan that claims "no existing tool found" passes the codebase-survey dimension if the battery cannot call grep. Mitigation: the codebase-survey step in Phase 4.5 requires actual grep output stored in the Information Retrieved section, not a prose claim. This is partially executable verification rather than assertion. The battery dimension then checks for the presence of grep output, not the claim of a search.

Second most likely: retrieval without integration. FSI entry retrieved, Information Retrieved section populated, anti-pattern noted, plan proceeds with the anti-pattern anyway. The plan is auditable but hollow. Mitigation: if the plan's frontmatter lists fsi_entries_consulted, the design alternatives section must name the retrieved entry's anti_pattern_shape explicitly — not in a summary, in the alternatives analysis. "I considered the anti-pattern and rejected it because..." is forced acknowledgment that cannot be satisfied by copying the FSI entry title.

Third most likely: overhead creep in the battery. Every post-mortem adds a dimension. By month five, 13 dimensions and variable names blocks trivial changes. Mitigation: the battery's blocking scope is narrowly defined from the start — blocks only on goal-traceability, hypothesis-validation, codebase-survey, design-alternatives when the plan touches irreversible decisions. Non-blocking dimensions generate PARTIAL findings with warnings. Scope is written into the battery protocol, not adjustable issue-by-issue. New dimensions require a kaizen issue and admin approval, not just a reflect step.

The override risk. If any of the three systems generate enough interrupts, agents route around them. The bypass path becomes the normal path. This is the mechanism by which all L1 enforcement eventually fails. Mitigation: Tier 1 (Phase 4.5) adds time but not interrupts — it is procedural, not a gate. Tier 2 adds observability but only warns, not blocks. Tier 3's battery is the only gating mechanism; its blocking criteria are narrow and its escalation path goes to the admin only after 2 revision cycles. Monitor admin override rate: above 20% means the system is miscalibrated, not the agent.


8. What Remains Unknown

Whether Phase 4.5 will be followed faithfully without enforcement. The five steps are L1 instructions in a SKILL.md. The existing evidence (issue #947: agents skip steps buried past a certain depth) predicts that Phase 4.5 will be followed initially and skipped under pressure over time. The MVC addresses 4/5 failure categories at zero infrastructure cost; the cost is that it is L1. Empirical observation of whether the steps are performed will determine whether Tier 2's schema enforcement (which makes omission visible) is sufficient or whether a hook that checks Phase 4.5 completion is required.

Whether the FSI retrieval mechanism will produce integration or just acknowledgment. The audit trail created by fsi_entries_consulted and the was_category_retrieved_at_design_time field will answer this after 10-15 evaluations. If plans consistently cite FSI entries but proceed with the anti-pattern, retrieval without integration is confirmed as the bottleneck and the forced-acknowledgment requirement (naming the shape in the alternatives analysis) should be elevated from advisory to blocking.

Whether the bottleneck is plan quality or implementation fidelity. The pre-mortem raises this explicitly: PR #894's 3 undelivered acceptance criteria were in the plan, not missing from it. The implementation dropped them. Better plans wouldn't have changed that. If post-merge issues for undelivered acceptance criteria do not decrease after Tier 1 ships, implementation fidelity is the next bottleneck and the locus of improvement shifts to kaizen-implement, not kaizen-evaluate.

The novel failure floor. The pre-mortem's concurrent-write scenario is a real upper bound on what the system can prevent. The systems address known failure categories; novel failures are definitionally outside their scope. Kaizen's most expensive historical failures have often been novel. The systems are expected to reduce recurrence of known categories significantly; their effect on novel failures is zero by construction. This is not a reason to not build them — it is a calibration: success is "known failures stop recurring," not "all failures stop occurring."


The bet: Phase 4.5 is the MVC because it addresses the most common failure modes at zero infrastructure cost. The FSI bootstrap makes the category library empirically grounded rather than theoretically derived. The plan battery formalizes what Phase 4.5 establishes as discipline. Build in that order. Test against real evaluations. Update when the evidence contradicts the model.

R5: Implementation Roadmap

March 2026 — Delivery-ready. Ready to paste into GitHub.


Preamble

This roadmap flows from four rounds of design analysis. The five failure categories are real, documented by GitHub evidence. The sequence below delivers maximum leverage at minimum infrastructure cost, deferring complexity until the preceding step produces evidence that complexity is warranted.

The sequencing principle: ship the instruction change first (zero infrastructure, immediate effect), then add persistence artifacts (one PR, low risk), then build retrieval infrastructure only after baseline data accumulates.


Issue 1 — Ship First

Title: feat(kaizen-evaluate): add Phase 4.5 Plan Formation — five grounding steps before any plan is written

Exact scope:

Single file change: /home/aviadr1/projects/kaizen/.claude/skills/kaizen-evaluate/SKILL.md

Insert the complete Phase 4.5 block (from r4-concrete-skill-text.md, section 7) between the existing Phase 4 (Critique the Spec) and Phase 5 (Ask the Admin). The insertion point is after the paragraph ending "Write the critique into the spec document itself" and before the ### Phase 5: Ask the admin heading.

The five steps added:

  1. Extract success criteria (GOAL + DONE WHEN before reading code)
  2. Survey what already exists (grep commands, CLAUDE.md Key Files table)
  3. Generate and reject alternatives (OPTION A selected / OPTION B rejected with failure mode)
  4. Validate the hypothesis (HYPOTHESIS / VALIDATION / IF WRONG triple)
  5. Map testability seams before placing code (BEHAVIOR / LIVES IN / TESTED IN / SEAM)

Also update the Workflow Tasks table: add a row between Task 4 (Critique spec) and Task 5 (Ask admin): 4.5 | Plan Formation | Five grounding steps: success criteria, codebase survey, alternatives, hypothesis validation, testability seams.

No new infrastructure. No new CLI commands. No new files.

Acceptance criteria:

  • The five steps appear in SKILL.md between Phase 4 and Phase 5 with the exact imperative voice matching adjacent phases
  • Each step has an explicit time budget
  • The plan output template (Success Criteria / Information Retrieved / Design Alternatives Considered / Tasks / Seam Map / Test Plan) appears as the final sub-step
  • store-plan command appears at the end of Phase 4.5 so plans are stored before admin review
  • Workflow Tasks table has the 4.5 row

Success signal (observable change in agent behavior): Plans produced after this change will contain GOAL: and DONE WHEN: lines, an Information Retrieved section with grep evidence or explicit "nothing found" statements, and an OPTION A / OPTION B pair at the highest-risk design choice. Plans without these sections are out of compliance with Phase 4.5. The diff between a pre-4.5 plan and a post-4.5 plan is immediately visible in structure.

Estimated size: ~120 lines added to SKILL.md. One PR.

Risk if deferred: Issues #666 (schema built, 0 SKILL.md files populated) and #957 (custom storage over existing tools) are both repeatable right now. Every evaluation that runs without Phase 4.5 has the same structural exposure. Deferring for one sprint means 4-8 evaluations with the same failure surface.


Issue 2 — Plan Schema + Persistence Artifact

Title: feat(kaizen-implement): enforce plan schema sections — Information Retrieved and Design Alternatives Considered required

Exact scope:

Two changes:

  1. /home/aviadr1/projects/kaizen/.claude/skills/kaizen-implement/SKILL.md — In Step 0b (Plan Formation), update the plan template to add two required sections: ## Information Retrieved and ## Design Alternatives Considered. These sections are already produced by Phase 4.5 of kaizen-evaluate; this change makes kaizen-implement's plan template match the structure Phase 4.5 produces.

  2. src/cli-structured-data.ts (or src/plan-store.ts) — Add a soft schema validation to store-plan: warn (exit 0, print warning) when the plan text is missing ## Information Retrieved or ## Design Alternatives Considered. Warning format: [plan-schema] Missing section: "Information Retrieved" — plans should document what was surveyed before designing. This is advisory, not a hard block.

Dependency on Issue 1: Phase 4.5 (Issue 1) produces these sections. Issue 2 adds the template and the validator that checks they were produced. Without Issue 1, the sections won't exist. Without Issue 2, they won't be auditable.

Acceptance criteria:

  • store-plan warns (does not error) when ## Information Retrieved is absent from plan text
  • store-plan warns when ## Design Alternatives Considered is absent
  • store-plan still exits 0 in both cases (advisory, not blocking)
  • kaizen-implement's plan template in SKILL.md has both sections
  • npm test passes with at least one test covering the warning path

Success signal: list-review-rounds on plans stored after this change will show plans that either have both sections (compliant) or triggered warnings (non-compliant but tracked). The warning output is the audit trail — it creates visibility without blocking.


Issue 3 — Failure Signature Index (FSI) Bootstrap

Title: feat(kaizen-experience): bootstrap FSI store with 10 categories from documented incidents — Phase 0.7 retrieval in kaizen-evaluate

Exact scope:

Three parts:

  1. Schema + storage: Create .claude/kaizen/categories/ directory. Each category is one YAML file with fields: id, name, description, anti_pattern_shape, preferred_shape, trigger_keywords, structural_tests (list of yes/no questions), incident_refs (list of GitHub issue numbers), confidence (float). Seed with the 10 categories from r3-category-library.md: goal-vs-work-item, hypothesis-as-contract, plan-before-survey, testability-gap, single-design, session-boundary-state, enforcement-level-mismatch, accumulate-then-flush, worktree-isolation, batch-write-race.

  2. CLI: npx tsx src/cli-experience.ts query --keywords "..." --limit 3 — keyword scan against trigger_keywords, returns top-N matches as plain text blocks. No confidence filtering in v1. Also: cli-experience.ts add-incident --category <id> --issue <N> to increment incident_refs.

  3. SKILL.md wiring: Insert Phase 0.7 in kaizen-evaluate SKILL.md between Phase 0.5 (Check for existing spec) and Phase 1 (Gather incidents):

### Phase 0.7: Retrieve relevant experience

Run: npx tsx src/cli-experience.ts query --keywords "<3-5 keywords from issue title/body>"

If entries are returned: read the anti_pattern_shape for each. These are shapes that previous plans fell into. Note them before Phase 4.5 — Step 3 (alternatives) should explicitly name any anti-pattern that applies to this issue.

If no entries: proceed. Record this as a gap after Phase 6 if the evaluation reveals a novel failure mode.

Dependency on Issues 1+2: The FSI categories are calibrated against Phase 4.5's five steps. Without Phase 4.5, agents won't know how to act on retrieved entries. Without Issue 2's schema validation, there's no audit trail to confirm entries are being used.

Acceptance criteria:

  • .claude/kaizen/categories/ exists with 10 YAML files
  • npx tsx src/cli-experience.ts query --keywords "state session hook" returns at least 2 matching entries
  • npx tsx src/cli-experience.ts query --keywords "storage plan" returns at least 1 entry (plan-before-survey)
  • Phase 0.7 appears in kaizen-evaluate SKILL.md
  • npm test covers the query command with at least one keyword-match test and one no-match test

When to ship: After Issue 1 has run for at least 4 evaluations (4-6 real kaizen cases evaluated post-Phase 4.5). This gives the FSI categories the chance to be validated against real retrieval — if Phase 4.5's Step 2 (codebase survey) is catching plan-before-survey failures independently, the FSI adds retrieval speed; if it's not, the FSI categories need recalibration before being wired in.


Issue 4 — Category Recognition Algorithm

Title: feat(kaizen-experience): add two-pass category recognition — keyword scan + structural test confirmation

Exact scope:

Extend src/cli-experience.ts with a recognize subcommand:

  • Pass 1: keyword scan (already exists from Issue 3's query)
  • Pass 2: for each candidate from Pass 1, output the structural_tests as yes/no questions for the agent to answer
  • Output: match_confidence field — 1.0 (all structural tests YES), 0.5 (ambiguous), 0.0 (structural test NO). Only return categories with match_confidence >= 0.8 as confirmed matches.
  • Ambiguous matches (0.5) are returned as candidates with a flag: low-confidence — proceed with full exploration

Add to cli-experience.ts add-incident: accept --match-confidence <float> to update category confidence score from incident feedback.

Update Phase 0.7 in kaizen-evaluate to call recognize instead of query, and act on match_confidence: confirmed matches load as priors into Step 3 (alternatives); ambiguous matches are noted but don't constrain.

When to ship: After FSI has at least 8-10 real incident entries logged across at least 3 different categories. Recognition without calibrated incident data produces high noise. The trigger: run cli-experience.ts query on 3 recent kaizen issues and verify at least 2 return a genuine match (not keyword noise). If query quality is poor, recalibrate keywords before building recognition.

Acceptance criteria:

  • recognize --issue-text "..." returns confirmed matches (confidence >= 0.8) only when structural tests are clearly YES
  • Ambiguous inputs produce match_confidence: 0.5 with a proceed-with-full-exploration flag, not a false positive match
  • npm test covers: clear match, ambiguous match, clear non-match, confidence update path

Issue 5 — Full Plan Battery as Gate (Deferred)

Why deferred: The Plan Battery (r3-plan-battery.md) is the most rigorous enforcement. It is also the most likely to produce the failures the pre-mortem documents: overhead creep, false confidence from well-formed but ungrounded text, and gaming by agents who learn to write battery-passing plans. The pre-mortem's most likely failure mode — "the battery passes because the plan's text is structurally correct, not because the survey actually happened" — applies most strongly when the battery runs before Phase 4.5 is well-practiced.

When to build it: When all three of these conditions are true:

  1. Issues 1-3 have been live for at least 8 weeks
  2. The FSI has at least 15 incident entries with match_confidence data
  3. At least 2 kaizen PRs have shipped where Phase 4.5 demonstrably prevented a failure (observable: plan's Information Retrieved section cited an existing tool that would otherwise have been reinvented)

The third condition is the gate. The battery's codebase-survey dimension (Dimension 3) is only meaningful if the FSI provides context about what to search for. Without FSI data, the dimension degenerates to "did the plan say it searched?" — which is what Phase 4.5 Step 2 already checks, without a battery.

What changes the decision: If post-mortem analysis after Issue 3 shows that Phase 4.5 is insufficient for complex multi-component issues — plans are well-formed but still failing in the implementation phase on architecture questions — that's the trigger to build the battery. If Phase 4.5 is catching the failures, the battery adds process overhead without proportional benefit.


Observability Plan

How to know if any of this is working:

  1. Plan section compliance rate (from Issue 2 warnings): Track the fraction of stored plans that contain ## Information Retrieved and ## Design Alternatives Considered. Target: 100% within 4 evaluations of Issue 2 shipping. If compliance is below 80% after 6 evaluations, Phase 4.5 instructions are being skipped — investigate.

  2. Plan-before-survey incidents (Issue #957 class): Count GitHub issues filed with "custom storage built over existing tool" or equivalent descriptions. Baseline: 2 incidents in the last 6 months (issues #957 and adjacents). Target: 0 in the 8 weeks after Issue 1 ships. If count doesn't drop, Phase 4.5 Step 2 (codebase survey) is not being performed.

  3. Goal-extraction failures (Issue #666 class): Count post-merge issues filed where "implementation was correct but didn't solve the goal." Baseline: 1 confirmed incident (#666). Target: 0 in 8 weeks. If this occurs again, Phase 4.5 Step 1 (GOAL / DONE WHEN) is not grounding the plan.

  4. FSI retrieval usage (after Issue 3): Track whether ## Information Retrieved sections in plans cite FSI entries when relevant. Spot-check 3 plans per month: manually verify that the cited entries match what cli-experience.ts query would return for that issue's keywords.

  5. Admin override rate: If the Scope Reduction Discipline gate (already in SKILL.md) is triggered more than 3 times in 8 weeks, Phase 4.5 may be generating plans that are too complex or too deferral-heavy — investigate.

Where to watch: Plan bodies stored via store-plan on GitHub issues. The ## Information Retrieved and ## Design Alternatives Considered sections are the primary artifacts.


Rollback Criteria

Issue 1 (Phase 4.5): Rollback signal: evaluations consistently take >30 minutes and admin feedback indicates Phase 4.5 is creating analysis paralysis rather than grounding. Observable: admin says "skip the grounding, just implement" more than twice in 4 weeks. Rollback: revert the SKILL.md change. The five steps are contained in one block; removal is clean.

Issue 2 (plan schema validation): Rollback signal: store-plan warnings are triggering on plans that are genuinely well-formed but use different section names (false positives). Observable: store-plan warning on a plan that demonstrably surveyed the codebase. Rollback: remove the schema warning from store-plan. Issue 1's SKILL.md change is independent and survives.

Issue 3 (FSI bootstrap): Rollback signal: Phase 0.7 retrieval is returning irrelevant entries that are cluttering plan formation — agents citing FSI entries that don't apply to the issue. Observable: ## Information Retrieved sections citing FSI categories that have no structural match to the issue. Rollback: remove Phase 0.7 from SKILL.md. The YAML category files and CLI are harmless if not wired in. Issue 1 and 2 survive independently.

Issue 4 (recognition algorithm): Rollback signal: match_confidence false positives — the algorithm confirms matches that are structurally wrong, loading wrong priors into plan alternatives. Observable: a plan that passed recognition and used the preferred shape, but the preferred shape was wrong for the actual issue. Rollback: revert Phase 0.7 to use query instead of recognize. The two-pass algorithm is contained in cli-experience.ts; the SKILL.md wiring is a one-line change.


This document is the delivery brief. Issue 1 can be filed and shipped this week. Issues 2-4 have explicit trigger conditions that determine when they become active. Issue 5 has no schedule — it ships when the evidence says it's needed.

The Simple Mental Model: Why Plans Fail

Round 5 — March 2026


Part 1: The One-Page Mental Model

The Core Insight

Plans fail not because agents are lazy or wrong, but because they start from the wrong question. An agent given an issue asks: "What does this issue want me to build?" The right question is: "What must be true, that currently isn't, for this problem to be solved?" These questions produce different plans. Only the second produces solved problems.

In 7 of 8 observed failures, the information to form the correct plan was in the issue body. The agent read the issue. The agent missed the goal.


The 4 Questions to Answer Before Writing a Plan

Ask these in order. If you cannot answer all four, the plan is not ready.

1. What does "done" look like from the outside? Write: DONE WHEN: [observable outcome an external person can verify without reading the code] "Tests pass" qualifies. "The feature works" does not. If you can't write this before reading any code, the issue is underspecified — stop and ask.

2. What already exists in this problem area? Read CLAUDE.md's Key Files table. Run one grep for the domain (storage, hooks, review, dimensions). State what you found or that nothing was found. A plan that proposes new infrastructure without a search result is not ready.

3. What is the plan's core assumption, and how would you know it's wrong? The issue's "proposed fix" is a hypothesis. State it as one: HYPOTHESIS: [what it assumes] / IF WRONG: [what evidence would show it]. Run the cheapest validation available before committing to the plan.

4. Where does the test live, and what is the seam? For the plan's most significant behavior: name the file it lives in, name the test file, and name the injection point that isolates it. If the location is a CLI entry point or script's global scope, add an extraction step first. Logic in main() is not testable.


The 30-Second Test: Is My Plan Good Enough?

Read your plan's task list. For each task, ask: "If this task is done perfectly, how does it connect to the DONE WHEN criterion?" If any task fails this trace, either remove it or add a task that makes the connection explicit. A plan where every task traces to the success criterion is a plan that solves the problem. A plan where some tasks don't trace is building infrastructure — useful, but not the goal.

One more check: find the highest-risk decision in the plan (where state lives, who owns a contract, what to build vs. reuse). Is there a rejected alternative named anywhere? If not, the plan inherited a default without examining the choice.


The Learning Flywheel

Each plan makes the next one better through the store-plan step. Stored plans become retrievable evidence: when a future issue touches the same domain, the survey step (Question 2) surfaces the prior plan. When a hypothesis turns out to be wrong, the IF WRONG record tells the next agent what evidence to look for. When an extraction step was needed (Question 4), the pattern propagates to future plans in that file.

The flywheel has three turns:

  1. Plan quality improves because previous plans are retrievable at survey time.
  2. Hypothesis validation improves because IF WRONG criteria accumulate into a failure-mode library.
  3. Testability improves because extraction patterns propagate to adjacent files.

None of this works if plans aren't stored. Store immediately after writing, before implementation begins.


Part 2: The Zen Formulation

A plan that addresses requirements but not the goal is not a plan — it's a task list.
The task list builds. The goal doesn't move.

The issue's proposed fix is a hypothesis wearing a specification's clothes.
Treat it as what it is: a best guess that deserves five minutes of doubt before thirty hours of implementation.

Survey the territory before you map a route through it.
The infrastructure you build today is the infrastructure someone already built yesterday.
Grep first. Design second. Build last.

A test you can't write is a design you can't trust.
If the location doesn't have a seam, the problem isn't the test — it's the location.

Every plan stores a "done when."
Every "done when" stores a lesson.
The lessons are the compound interest.

Part 3: The Before/After

Case: Issue #666 — Skill metadata schema

The issue asked: "Adding a new skill requires reading workflow docs to understand where it fits. Skills should declare their dependencies in YAML frontmatter so the chain can be mechanically validated."

Before (what the plan produced):

Tasks:
1. Define SkillMetadata TypeScript interface
2. Write YAML frontmatter parser
3. Add validation in kaizen-setup
4. Write 22 unit tests for the parser

All four tasks were completed. CI was green. The issue was closed. The skill chain was still implicit — because none of the 16 SKILL.md files were updated. The plan extracted work items from the issue body and ignored the success criterion in the same body.

After (with the mental model):

DONE WHEN: Running `kaizen-list-skills --show-deps` produces a dependency graph,
and all 16 SKILL.md files contain valid frontmatter that the parser accepts.

Information Retrieved: No existing frontmatter tooling found. section-editor.ts
covers structured storage but not schema validation — won't reuse directly.

Hypothesis: Declaring deps in YAML frontmatter is sufficient to make the chain
non-implicit. IF WRONG: Frontmatter exists but is never read by anything, leaving
the chain implicit in practice (not just in files). Validate by checking whether
kaizen-setup or any skill consumer reads the metadata after it's written.

Tasks:
1. Define SkillMetadata interface and parser [traces to: parser can read frontmatter]
2. Update all 16 SKILL.md files with valid frontmatter [traces to: DONE WHEN #1]
3. Wire parser output into kaizen-list-skills --show-deps [traces to: DONE WHEN #2]
4. Tests covering parser + list-skills output [seam: parser function, injected file path]

The difference is not more tasks. It is tasks that trace. Task 2 (update all 16 files) was invisible in the original plan because no one asked "what must be true for the problem to stop?" It becomes mandatory the moment you write the DONE WHEN criterion.


The theme across five rounds: the tools, the phases, and the enforcement already exist. The gap is the eight minutes before the plan is written — the time it takes to ask what "done" looks like, what already exists, and whether the proposed fix is actually right. Four questions. Thirty minutes of work prevented per wasted implementation. That is the whole model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment