Execute
→ Bug? Test failure? Unexpected behavior? → Find root cause first. No fixes without evidence.
- Isolate: read error → reproduce → check git diff → drill upward through diagnostic layers:
L1 symptom → L2 logic → L3 system → L4 architecture →
L5 cross-system contract → L6 platform constraint → L7 spec gap.
Stop when no deeper "why" remains OR terminal unactionable (T1-T4).
- Identify owner: compare with working code → locate canonical owner → flag duplicate owners as a finding
- Before fixing, run Patch-Shape Triage and Ripple Signal Triage if the candidate fix touches shared/core/cross-module behavior, contract, source-of-truth, fallback, adapter, duplicate owner, producer+consumer, or consumer-side patching. Surface Change Necessity for any new source-code path and non-trivial fixes. Run Minimality Check when the candidate fix adds a new branch, fallback, owner, adapter, or compatibility path. Also run Pre-Edit Complexity Check when the candidate fix touches an overloaded owner or may worsen source complexity.
- Prove: one hypothesis → smallest reproduction or verification → iterate. A failing test first is required only under explicit
TDD Route: strict. 3+ failed fixes = question architecture, do not attempt another code fix.
After fix, if any symptom persists → differential diagnosis (Phase 4 Step 4bis).
- Fix: minimal code at canonical owner → targeted verification → Reflection + architecture review → repair + retirement track
If the user asks for white-box auditability, include
Trace Digest after
evidence is collected; do not expose raw chain-of-thought or let trace
replace root-cause, rule-effect, and verification evidence.
→ Done when: confidence ≥ B, both tracks explicit, DeeperCause answered "no" with evidence, no H-class hard signal still active.
Systematic Debugging
Overview
Find root cause. Fix the bug class at its canonical owner; close repair and
retirement. This is not the smallest textual diff.
When to Use
Any technical issue: test failures, bugs, unexpected behavior, performance problems, build/integration failures.
Especially under time pressure, when "just one quick fix" seems obvious, after multiple failed fixes, or when duplicate owners / fallback chains may be involved.
Quick bug lane
For low-risk, single-owner bugs, keep the report compact: Symptom,
Reproduction, Root Cause, Aegis Visibility, Change Necessity, Fix Boundary, and
Verification. Quick bug lane must surface Change Necessity before source edits and before any new source-code path. Still collect root-cause evidence before editing; one compact sentence is enough when it names the user-visible
need, no-change / non-code option, why code change is necessary, minimum change
boundary, and an explicit decision token such as Decision: code-change;
minimum-boundary wording is not a substitute for the decision. If fallback,
duplicate owner, consumer-side patching, contract risk, shared logic, or
cross-module behavior appears, escalate to the full workflow.
Aegis Visibility for this workflow names how root-cause evidence,
canonical-owner selection, patch-shape triage, or verification discipline
changed the repair path. Use a natural stage transition when moving from
diagnosis to repair and from repair to verification.
This debugging report is a diagnosis/repair surface, not a separate completion
receipt. Before claiming the bug is fixed, pass root cause, avoided misfix,
fix boundary, verification, complexity, and residual risk to
verification-before-completion so the user-facing closeout uses the unified
Aegis impact/safety receipt.
The Four Phases
Phase 1: Root Cause Investigation
BEFORE attempting ANY fix:
Read Error Messages Carefully
- Don't skip past errors or warnings — they often contain the exact solution
- Read stack traces completely; note line numbers, file paths, error codes
Reproduce Consistently
- Can you trigger it reliably? What are the exact steps? Does it happen every time?
- If not reproducible → consult
feedback-loop-construction.md to build an automated reproduction loop; don't guess
- Record baseline: inputs, environment, version, logs, success/failure criteria
Check Recent Changes
- What changed that could cause this? Git diff, recent commits, new dependencies, config changes, environmental differences
Non-trivial bugs passively use relevant active CONTEXT.md terms. If
authority/glossary/code/tests differ, code is evidence; compose
establishing-project-context rather than silently rewrite meaning.
Gather Evidence in Multi-Component Systems
- Instrument each component boundary: log what enters and exits
- Run once to see where data breaks, then focus investigation there
Trace Data Flow (when error is deep in call stack)
- Where does bad value originate? What called this with bad value?
- Keep tracing up until you find the source. Fix at source, not at symptom.
- For the complete backward tracing technique, see
root-cause-tracing.md.
Drill Upward Through Diagnostic Layers
Start at L1. Exhaust all "why" questions at each layer before moving upward.
The chain is open-ended — architecture is not the endpoint.
L1 Symptom: what failed? where? exact reproduction?
L2 Logic: which branch, invariant, or state transition is wrong?
L3 System: which component boundary, dependency, or ownership seam?
L4 Architecture: what design choice, duplicated owner, or fallback chain?
L5 Cross-system: which API / SLA / timing contract between systems?
L6 Platform: what runtime / OS / framework constraint?
L7 Spec gap: who never defined correct behavior for this case?
Hard signal definitions (H/T/D) are in the Quality Gate — apply them there,
not during initial investigation.
When the stop layer is not obvious, the user asks where the diagnosis
stops, the issue crosses component/system boundaries, or a user-provided
fact falsifies the current layer, expose a compact Layer Stop Card before
fixing:
Layer Stop Card:
- Current Stop Layer: L1 Symptom | L2 Logic | L3 System | L4 Architecture | L5 Cross-system Contract | L6 Platform | L7 Spec Gap | T-class boundary
- Checked Path:
- Evidence For Stop:
- Excluded Layers:
- Falsifier:
- User Intervention Point:
- Next Action:
The card is an advisory readback of the diagnostic stop point. It is not a
GateDecision, PolicySnapshot, or completion authority.
Patch-Shape Triage Before Editing
Treat the first obvious fix as evidence, not clearance to edit. If the
candidate fix shape matches any item below, continue upward before changing
code unless you can prove the local layer is the canonical owner:
- keyword, phrase, regex, negation-word list, or sample-text exception
- local guard, extra conditional,
try/catch, early return, or one-off branch
- fallback, adapter, compatibility branch, prompt branch, or legacy path expansion
- consumer/caller/readiness/presentation-layer patch
- downstream re-parsing of raw text when typed intent, normalized state,
contract, or another source-of-truth already exists
- artifact/download/export/readback/cache patch that does not first locate
the producer and source-of-truth owner
- duplicate parsing, duplicate owner, or "keep both for now" reasoning
- fix that only names the observed sample instead of the bug class
Required output before editing when this gate fires:
PatchShape:
CanonicalOwner:
UpwardDrillSignal:
Decision: fix owner | continue investigation | escalate
After this gate fires, a locally green test does not erase it. Existing
checkpoint prose retains PatchShape, CanonicalOwner,
UpwardDrillSignal, Decision, outcome, and one bounded evidence ref.
Before an unplanned repair, compare invariant, owner seam, patch shape, and
topology; a renamed carrier is not a new direction.
If the tempting fix is "just add a small guard/fallback", also run:
Minimality Check:
- Smallest textual diff:
- Existing owner / reuse path:
- Correct owner:
- Bug class fixed:
- New branch/fallback added:
- Existence proof for new path:
- Old path retired or scheduled:
- Verdict: sufficient repair | local patch | needs first-principles review
local patch is a mitigation, not a sufficient repair, unless it is the
canonical owner and includes a retention reason plus retirement trigger.
For candidate additions that are not ordinary repair code, run an
Existence Check using docs/current/AEGIS_MINIMALITY_REFERENCE.md before
editing. This is behavior-triggered: if the candidate repair adds a fallback,
adapter, branch, or new owner, the check runs even when the user asked for
that fallback directly.
Existence Check:
- Proposed new surface:
- Existing owner / reuse candidate:
- Why existing surface is insufficient:
- Creation proof:
- Entropy / retirement impact:
- Decision: reuse-existing | add-with-proof | defer | reject | needs-first-principles-review
If the repair or retirement boundary depends on deleting old paths,
retaining compat for a proven external dependency, or stopping on
persistent-state risk, compose anti-entropy-governance before editing. It
decides the path; it does not grant destructive authority.
Change Necessity
After root cause and canonical owner are identified, but before repair code,
make the code-change decision visible. This is the "should code change at
all?" check; it is not a new artifact and does not belong in the
using-aegis hot path.
This is behavior-triggered, not prompt-triggered. If the next step adds any
new source-code path or makes a non-trivial source edit, expose a natural
readback even when the user did not ask for it. A tiny helper, small guard,
new branch, fallback, adapter, or owner is not exempt. Example: "Code
necessity check: a non-code path is insufficient because ; the
minimum change boundary is <canonical owner/files>, so the decision is
code-change."
Change Necessity:
- User-visible need:
- No-change / non-code option:
- Why code change is necessary:
- Minimum change boundary:
- Decision: no-change | docs/config-only | code-change | needs-clarification
In quick bug lane, keep Decision: explicit even when using natural prose.
If the decision is no-change, do not edit source code. If the decision is
docs/config-only, narrow the fix to that surface and verify it. If the
decision is needs-clarification, pause before repair. If the decision is
code-change, carry the minimum boundary into Fix Boundary,
Minimality Check, and verification.
Pre-Edit Complexity Check
After root cause and canonical owner are identified, check whether the fix
adds complexity to the wrong or overloaded place:
Use using-aegis/references/complexity-governance.md for shared pressure
signals and the meaning of over-budget.
Pre-Edit Complexity Check:
- Target edit file:
- Existing pressure signal:
- Owner fit:
- Safer edit boundary:
- Decision: edit-in-place | extract helper | add owner file | split task | pause for plan update
Pre-Edit Owner-Fit Decision:
- Edit intent: wiring-only | move-out / extract-first | local-fix-without-new-responsibility | new-responsibility | emergency / compatibility patch
- Owner fit:
- Safer edit boundary:
- Decision: edit-in-place | extract helper | add owner file | split task | pause for plan update
If the safer boundary changes the implementation shape, pause and update the
plan/spec.
If the likely repair would grow an already oversized maintained artifact and
the slice cannot govern that growth immediately, do not present the repair as
a completed fix boundary. Escalate with a plan update or a visible follow-up
requirement.
When the target edit file is over-budget or mixed-purpose, classify edit
intent before source edits. new-responsibility must not be added in place
by default. wiring-only, move-out / extract-first, and
local-fix-without-new-responsibility may proceed only when they do not add
a new responsibility and the verification boundary is clear. emergency / compatibility patch requires residual risk and a retirement trigger.
Phase 2: Pattern Analysis
- Find working examples in the same codebase — what works that's similar?
- Compare against references — read completely, don't skim
- Identify differences between working and broken — list every difference
- Understand dependencies — config, environment, assumptions
- Locate the canonical owner — which file/module should own this? Multiple owners = a finding, not normality
Phase 3: Hypothesis and Testing
- Form single hypothesis: "I think X is the root cause because Y" — be specific
- Prove minimally: use the smallest reproduction or verification, one
variable at a time. Prefer instrumentation over code edits while still
proving the cause. A failing reproduction may be useful evidence, but it is
not a RED gate or a prerequisite for production edits unless an explicit
TDD Route: strict says so.
- Verify: worked? → Phase 4. Didn't? → Form NEW hypothesis. Don't stack fixes.
- When you don't know: say "I don't understand X", don't pretend
- Run Reflection at the end of each loop:
- Goal | DeeperCause (yes/no/uncertain) | Evidence | Risk/Unknown | Decision (exit/iterate/escalate)
- If DeeperCause = uncertain → continue or escalate. Only exit when root cause is deep enough and evidence is sufficient.
Phase 3.5: Pre-Claim Gate
Before claiming a root cause and entering Phase 4, check whether the
Pre-Claim Gate applies. It applies whenever any Patch-Shape Triage signal is
active (candidate fix is a guard, fallback, consumer/caller patch,
artifact/cache patch, or sample-only naming — i.e. H1 / H3 / H8 / H10 / H11 /
H13), or whenever the diagnosis crosses a component or system boundary, or a
previous fix left a residual symptom.
When it applies, do not state a root cause or edit code until the five
mechanical checks below pass. See root-cause-claim-contract.md for the full
rationale, the six-topology table, and a worked example.
- Causal Closure — every causal edge from symptom to claimed root has an
evidence anchor (file:line, test, log, reproduction). One "probably" edge
leaves the chain open.
- Falsifier Checked — state "if X were not the root cause, observable F
would appear," and confirm F was checked and absent.
- Adversarial Self-Refutation — generate the strongest single argument
that this root cause is wrong, and show why it does not hold.
- Causal Topology Gate — classify the topology explicitly; do not default
to single-root. Topology and the anti-disguise check are in Phase 4 Step
4bis and in
root-cause-claim-contract.md.
- Layer Ceiling Proof — if the claim stops at L?, show why L?+1 is
unreachable by concrete constraint, not by omission.
Required output before entering Phase 4 when the gate fires:
Pre-Claim Gate Pass:
Topology: single-root | single-root-multi-symptom | chain | independent-compound | conjunctive-cluster | disjunctive-or
CausalClosure: closed | open-edge: <edge>
Falsifier: <if not-X then F; F checked: yes/no>
SelfRefutation: <strongest objection> -> <why it does not hold>
LayerCeiling: <L?> -> <why L?+1 unreachable>
Verdict: pass | fail-<which-gate>
This gate is advisory method-pack discipline. It is not a GateDecision,
PolicySnapshot, evidence sufficiency authority, or completion authority. It
turns a self-judged stop ("I think this is deep enough") into a checkable,
falsifiable claim ("here is the evidence chain, the falsifier I checked, the
objection I survived, and the ceiling I reached"). The quick bug lane is
exempt when no Patch-Shape signal fires and the bug is single-owner at the
canonical owner.
Phase 4: Implementation
Fix the root cause, not the symptom:
Choose Reproduction and Verification
- Under explicit
TDD Route: strict, create the smallest failing test before production code.
- With
TDD Mode: off and no strict route, do not require a failing test
first or RED / GREEN. A pre-change failing reproduction is permitted when
it helps diagnosis, but label it as evidence rather than a production-edit
gate; keep the smallest reproducible regression proof and targeted
verification that fit the fix.
Implement Single Fix
- Address the root cause identified. ONE change at a time.
- No "while I'm here" improvements. No bundled refactoring.
- Prefer changing the canonical owner instead of stacking more logic into a fallback path.
- If Change Necessity, Patch-Shape Triage, Ripple Signal Triage, or
Pre-Edit Complexity Check fired, carry its owner, downstream, contract,
source-of-truth, fallback, retirement, edit-boundary, minimum-boundary, and
verification findings into the fix boundary before editing code.
Verify Fix
- Does the selected verification pass? No other relevant tests broken? Issue actually resolved?
- Verify the intended compatibility boundary still holds.
- Verify you did not silently move authority to the wrong layer.
If Fix Doesn't Work
- STOP. Count: How many fixes have you tried?
- If < 3: Return to Phase 1, re-analyze with new information.
- If ≥ 3: STOP and question the architecture (step 6 below). DON'T attempt Fix #4 without architectural discussion.
4bis. Post-Fix Differential Diagnosis
After applying a fix, if ANY symptom persists:
STOP. Do NOT attempt another fix without diagnosis.
- Isolate the residual symptom precisely — what exactly remains?
- Trace its causal chain independently (fresh Phase 1 run).
- Compare with the causal chain of the fixed symptom:
| Residual pattern |
Diagnosis |
Action |
| Same reproduction conditions as fixed symptom |
Fix is incomplete |
Continue upward drilling from same source |
| Different reproduction conditions, chains converge to same source |
Fix was at wrong depth |
Drill upward again from the shared source |
| Different reproduction conditions, chains diverge |
Compound root cause (≥2 independent roots) |
Each root needs its own fix |
| Same symptom, reduced but not eliminated |
Fix was a downstream patch |
Drill upward again from source |
- If uncertain whether convergent or divergent: escalate. Do not guess.
Compound root cause forms (legacy shorthand):
- True compound — ≥2 independent bugs surfaced together
- Single-root multi-symptom — 1 root, ≥2 symptom paths → fix root, all resolve
- Chain causal — A causes B causes C → fix A, B and C auto-resolve
Causal Topology Gate (full form, used by the Pre-Claim Gate): the three
legacy forms above are a shorthand. Before claiming any root — single or
compound — classify the topology explicitly. The default is unknown; you
must actively exclude the multi-root topologies before collapsing to a
single-root claim. See root-cause-claim-contract.md for the full table,
member necessity/sufficiency tests, and the anti-disguise check.
| Topology |
Structure |
Stop condition |
Repair shape |
single-root |
A → symptom |
Layer Ceiling Proof at A |
fix A |
single-root-multi-symptom |
A → B, C, D |
Layer Ceiling Proof at A |
fix A; symptoms self-resolve |
chain |
A → B → C → symptom |
Layer Ceiling Proof at A |
drill to A, fix A |
independent-compound |
A → symptom, Y → symptom, A ⊥ Y |
each root passes Gate 1/2/5; no shared upstream |
fix A and Y; missing one leaves symptom |
conjunctive-cluster |
A ∧ B ∧ C → symptom (each necessary, none sufficient) |
enumerate members, necessity test each, sufficiency test the set, anti-disguise check |
fix all members; missing one leaves symptom |
disjunctive-or |
A ∨ B → symptom (any one suffices) |
enumerate all disjuncts |
fix one to stop symptom; enumerate rest for defense-in-depth |
Member proof (cluster / compound): each claimed member must pass a
necessity test ("if this member alone were removed, would the symptom still
occur?" — if yes, it is not a member). The set must pass a sufficiency test
(together the members explain every observed manifestation). Necessity
tests here are conceptual proofs, not empirical runs — a method-pack
ceiling; state this honestly when the cluster has many members.
Anti-disguise check (most often skipped): before accepting
conjunctive-cluster, ask whether members X and Y share a deeper common
cause Z, such that X and Y are merely two manifestations of Z. If yes, the
topology collapses to single-root-multi-symptom or chain rooted at Z —
drill to Z. The reverse check protects independent-compound: if two
divergent chains share upstream Z, they are not independent and Z is the
root.
If 3+ Fixes Failed: Question Architecture
Pattern indicating architectural problem:
- Each fix reveals new shared state/coupling/problem in different place
- Fixes require "massive refactoring" to implement
- Each fix creates new symptoms elsewhere
STOP and question fundamentals. Discuss with your human partner before attempting more fixes.
This is NOT a failed hypothesis — this is a wrong architecture.
Deliver Dual-Track Closure
For bug fixes, refactors, contract changes, or governance cleanup, always produce:
Repair track — root cause, canonical owner, smallest necessary change, compatibility boundary, verification method.
Retirement track — old owner / fallback / patch, whether it is still active on the main path, the only reason to keep it (if any), trigger for deletion, verification needed before removal.
Never add a new owner, fallback, prompt branch, or adapter path without stating what happens to the old one.
Quality Gate
Before you claim debugging is complete:
Workspace record for non-trivial debugging — if this is medium+ complexity
or it writes docs/aegis/ records, initialize/check through configured
Aegis workspace support when available:
python <aegis-workspace-helper> init --root <target-project-root>
python <aegis-workspace-helper> new-work --root <target-project-root> ...
python <aegis-workspace-helper> add-evidence --root <target-project-root> --work <YYYY-MM-DD-slug> ...
python <aegis-workspace-helper> check --root <target-project-root>
Fast bug fix or quick bug fix pressure does not skip this: if Ripple Signal
Triage fires, do the triage before editing and expand verification to the
canonical owner plus affected downstream path.
These records are method-pack evidence trails only. They do not grant
authoritative completion.
Stop-when review — re-read the diagnostic layer where you stopped. Did you reach "no deeper why remains" or a T-class terminal boundary? If the chain ended at L1-L2 and the evidence is conclusive, that is a valid endpoint. If there are still unexplained "why" questions, continue upward drilling before claiming done.
- Use a
Layer Stop Card when the stop point affects the fix boundary,
contract owner, spec/product decision, or user correction path. Keep
simple fast-path explanations cheap; do not emit the card for ordinary
factual Q&A about the skill itself.
Hard signal check — apply these countable facts, not judgments:
Must continue upward drilling (H-class — ANY hit = NOT done):
- H1 — fix added a conditional branch (
if / switch / catch / try)
- H2 — fix touched multiple sites but only 1 covered by the selected regression proof
- H3 — fix is at consumer/caller, not canonical owner
- H4 — same bug pattern exists elsewhere in repo (grep for it)
- H5 — original reproduction still produces any anomaly
- H6 —
git log --grep shows this symptom was "fixed" before → Read that commit's diff. Understand why it failed. Do not repeat the same patch pattern.
- H7 — candidate fix adds keyword, phrase, regex, negation-word list, or sample-text exception
- H8 — candidate fix adds a local guard, one-off branch, early return, fallback, adapter, compatibility branch, prompt branch, or legacy path expansion
- H9 — candidate fix patches a consumer/caller/readiness/presentation layer while an upstream owner could own correctness
- H10 — downstream logic re-parses raw text or re-infers action/state while typed intent, normalized state, contract, or another source-of-truth exists
- H11 — candidate fix patches artifact/download/export/readback/cache symptoms without proving the producer and source-of-truth owner
- H12 — candidate fix keeps duplicate owners active, moves authority silently, or says "keep both for now" without a retirement trigger
- H13 — candidate fix names only the observed sample wording/input instead of proving the bug class
- H14 — topology is
conjunctive-cluster or independent-compound but the member set is not enumerated, or a member was not necessity-tested
- H15 — topology was declared
conjunctive-cluster or independent-compound without running the anti-disguise check (a shared upstream Z may collapse the cluster/compound to a single root)
Terminal unactionable (T-class — any hit = stop drilling, switch to mitigation):
- T1 — required change is outside this repo's boundary
- T2 — would break published API contract with no migration path
- T3 — root is undefined spec behavior (nobody defined correctness)
- T4 — required permission or information is unavailable
→ On T-class: record root cause + system boundary + architecture review: what boundary vulnerability did this expose? can the system be made more resilient to this class of external failure?
Depth sufficient (D-class — ALL must pass before claiming done):
- D0 — fix eliminated ≥1 code path (paths after ≤ paths before)
- D1 — fix eliminated ≥1 conditional branch (not added a fallback)
- D2 — fix is at canonical owner
- D3 — original reproduction steps no longer trigger any anomaly
- D4 — no same-pattern occurrences remain unaddressed in repo
- D5 — Minimality Check verdict is
sufficient repair, or the local
patch is explicitly bounded with retention reason and retirement trigger
- D6 — Causal topology is explicitly classified (not defaulted to
single-root); if
conjunctive-cluster or independent-compound, every
member is enumerated and necessity-tested, and the set is sufficiency-tested
- D7 — anti-disguise check has been run for any
conjunctive-cluster
or independent-compound classification (a shared upstream Z was sought)
Reflection — re-run Goal / DeeperCause / Evidence / Risk/Unknown / Decision
Confirm the fix addressed the source, not just the sample
Retirement surface — did it shrink, stay, or grow?
Confidence:
A = direct evidence and regression coverage support the root-cause conclusion
B = strong evidence, limited coverage or some bounded unknowns remain
C = partial evidence only; do not present as fully resolved
If confidence is not at least B, do not speak as if the issue is fully closed.
Red Flags - STOP and Follow Process
If you catch yourself thinking:
- "Quick fix for now, investigate later"
- "Let me just try changing X and see if it works" (ignoring evidence, error messages, or hard signals)
- "Add multiple changes, run tests"
- "Skip the test, I'll manually verify"
- "I don't fully understand but this might work"
- Diagnosing by intuition — "It's probably X", listing fixes without investigation, proposing solutions before tracing data flow
- "One more fix attempt" (when already tried 2+)
- "Let's just add another fallback" instead of finding root cause
- "We can keep both owners for now" without a retirement condition
- Accepting a partial fix without differential diagnosis
ALL of these mean: STOP. Return to Phase 1.
If 3+ fixes failed: Question the architecture (see Phase 4 Step 5)
If symptoms persist after fix: Run differential diagnosis (see Phase 4 Step 4bis)
Human Partner Signals
If you hear "Is that not happening?", "Will it show us...?", "Stop guessing", "Ultrathink this" → STOP. Return to Phase 1.
When Process Reveals "No Root Cause"
If investigation reveals the issue is truly environmental, timing-dependent, or external:
document what you investigated, implement appropriate handling (retry, timeout, error message),
add monitoring.
Supporting Techniques
See root-cause-tracing.md, defense-in-depth.md, condition-based-waiting.md, feedback-loop-construction.md, and root-cause-claim-contract.md in this directory for deeper guidance on specific diagnostic scenarios.
Source: hashgraph-online/awesome-codex-plugins → plugins/GanyuanRan/Aegis/skills/systematic-debugging/SKILL.md
1---
2name: systematic-debugging-4
3description: "Use when encountering a bug, test failure, or unexpected behavior, before proposing fixes"
4category: engineering-core
5source_repo: hashgraph-online/awesome-codex-plugins
6source_path: "plugins/GanyuanRan/Aegis/skills/systematic-debugging/SKILL.md"
7source_url: https://github.com/hashgraph-online/awesome-codex-plugins/blob/HEAD/plugins/GanyuanRan/Aegis/skills/systematic-debugging/SKILL.md
8metadata:
9 source: https://skillmd.com/skills/hashgraph-online/systematic-debugging-4
10---
11
12
13# Execute
14
15→ Bug? Test failure? Unexpected behavior? → **Find root cause first. No fixes without evidence.**
16 1. Isolate: read error → reproduce → check git diff → drill upward through diagnostic layers:
17 L1 symptom → L2 logic → L3 system → L4 architecture →
18 L5 cross-system contract → L6 platform constraint → L7 spec gap.
19 Stop when no deeper "why" remains OR terminal unactionable (T1-T4).
20 2. Identify owner: compare with working code → locate canonical owner → flag duplicate owners as a finding
21 3. Before fixing, run Patch-Shape Triage and Ripple Signal Triage if the candidate fix touches shared/core/cross-module behavior, contract, source-of-truth, fallback, adapter, duplicate owner, producer+consumer, or consumer-side patching. Surface Change Necessity for any new source-code path and non-trivial fixes. Run Minimality Check when the candidate fix adds a new branch, fallback, owner, adapter, or compatibility path. Also run Pre-Edit Complexity Check when the candidate fix touches an overloaded owner or may worsen source complexity.
22 4. Prove: one hypothesis → smallest reproduction or verification → iterate. A failing test first is required only under explicit `TDD Route: strict`. 3+ failed fixes = question architecture, do not attempt another code fix.
23 After fix, if any symptom persists → differential diagnosis (Phase 4 Step 4bis).
24 5. Fix: minimal code at canonical owner → targeted verification → Reflection + architecture review → repair + retirement track
25 If the user asks for white-box auditability, include `Trace Digest` after
26 evidence is collected; do not expose raw chain-of-thought or let trace
27 replace root-cause, rule-effect, and verification evidence.
28→ Done when: confidence ≥ B, both tracks explicit, DeeperCause answered "no" with evidence, no H-class hard signal still active.
29
30# Systematic Debugging
31
32## Overview
33
34Find root cause. Fix the bug class at its canonical owner; close repair and
35retirement. This is not the smallest textual diff.
36
37## When to Use
38
39Any technical issue: test failures, bugs, unexpected behavior, performance problems, build/integration failures.
40
41Especially under time pressure, when "just one quick fix" seems obvious, after multiple failed fixes, or when duplicate owners / fallback chains may be involved.
42
43## Quick bug lane
44
45For low-risk, single-owner bugs, keep the report compact: `Symptom`,
46`Reproduction`, `Root Cause`, `Aegis Visibility`, `Change Necessity`, `Fix Boundary`, and
47`Verification`. Quick bug lane must surface Change Necessity before source edits and before any new source-code path. Still collect root-cause evidence before editing; one compact sentence is enough when it names the user-visible
48need, no-change / non-code option, why code change is necessary, minimum change
49boundary, and an explicit decision token such as `Decision: code-change`;
50minimum-boundary wording is not a substitute for the decision. If fallback,
51duplicate owner, consumer-side patching, contract risk, shared logic, or
52cross-module behavior appears, escalate to the full workflow.
53
54`Aegis Visibility` for this workflow names how root-cause evidence,
55canonical-owner selection, patch-shape triage, or verification discipline
56changed the repair path. Use a natural stage transition when moving from
57diagnosis to repair and from repair to verification.
58
59This debugging report is a diagnosis/repair surface, not a separate completion
60receipt. Before claiming the bug is fixed, pass root cause, avoided misfix,
61fix boundary, verification, complexity, and residual risk to
62`verification-before-completion` so the user-facing closeout uses the unified
63Aegis impact/safety receipt.
64
65## The Four Phases
66
67### Phase 1: Root Cause Investigation
68
69**BEFORE attempting ANY fix:**
70
711. **Read Error Messages Carefully**
72 - Don't skip past errors or warnings — they often contain the exact solution
73 - Read stack traces completely; note line numbers, file paths, error codes
74
752. **Reproduce Consistently**
76 - Can you trigger it reliably? What are the exact steps? Does it happen every time?
77 - If not reproducible → consult `feedback-loop-construction.md` to build an automated reproduction loop; don't guess
78 - Record baseline: inputs, environment, version, logs, success/failure criteria
79
803. **Check Recent Changes**
81 - What changed that could cause this? Git diff, recent commits, new dependencies, config changes, environmental differences
82
83 Non-trivial bugs passively use relevant active `CONTEXT.md` terms. If
84 authority/glossary/code/tests differ, code is evidence; compose
85 `establishing-project-context` rather than silently rewrite meaning.
86
874. **Gather Evidence in Multi-Component Systems**
88 - Instrument each component boundary: log what enters and exits
89 - Run once to see where data breaks, then focus investigation there
90
915. **Trace Data Flow** (when error is deep in call stack)
92 - Where does bad value originate? What called this with bad value?
93 - Keep tracing up until you find the source. Fix at source, not at symptom.
94 - For the complete backward tracing technique, see `root-cause-tracing.md`.
95
966. **Drill Upward Through Diagnostic Layers**
97
98 Start at L1. Exhaust all "why" questions at each layer before moving upward.
99 The chain is open-ended — architecture is not the endpoint.
100
101 ```
102 L1 Symptom: what failed? where? exact reproduction?
103 L2 Logic: which branch, invariant, or state transition is wrong?
104 L3 System: which component boundary, dependency, or ownership seam?
105 L4 Architecture: what design choice, duplicated owner, or fallback chain?
106 L5 Cross-system: which API / SLA / timing contract between systems?
107 L6 Platform: what runtime / OS / framework constraint?
108 L7 Spec gap: who never defined correct behavior for this case?
109 ```
110
111 Hard signal definitions (H/T/D) are in the Quality Gate — apply them there,
112 not during initial investigation.
113
114 When the stop layer is not obvious, the user asks where the diagnosis
115 stops, the issue crosses component/system boundaries, or a user-provided
116 fact falsifies the current layer, expose a compact `Layer Stop Card` before
117 fixing:
118
119 ```text
120 Layer Stop Card:
121 - Current Stop Layer: L1 Symptom | L2 Logic | L3 System | L4 Architecture | L5 Cross-system Contract | L6 Platform | L7 Spec Gap | T-class boundary
122 - Checked Path:
123 - Evidence For Stop:
124 - Excluded Layers:
125 - Falsifier:
126 - User Intervention Point:
127 - Next Action:
128 ```
129
130 The card is an advisory readback of the diagnostic stop point. It is not a
131 `GateDecision`, `PolicySnapshot`, or completion authority.
132
1337. **Patch-Shape Triage Before Editing**
134
135 Treat the first obvious fix as evidence, not clearance to edit. If the
136 candidate fix shape matches any item below, continue upward before changing
137 code unless you can prove the local layer is the canonical owner:
138
139 - keyword, phrase, regex, negation-word list, or sample-text exception
140 - local guard, extra conditional, `try`/`catch`, early return, or one-off branch
141 - fallback, adapter, compatibility branch, prompt branch, or legacy path expansion
142 - consumer/caller/readiness/presentation-layer patch
143 - downstream re-parsing of raw text when typed intent, normalized state,
144 contract, or another source-of-truth already exists
145 - artifact/download/export/readback/cache patch that does not first locate
146 the producer and source-of-truth owner
147 - duplicate parsing, duplicate owner, or "keep both for now" reasoning
148 - fix that only names the observed sample instead of the bug class
149
150 Required output before editing when this gate fires:
151
152 ```text
153 PatchShape:
154 CanonicalOwner:
155 UpwardDrillSignal:
156 Decision: fix owner | continue investigation | escalate
157 ```
158
159 After this gate fires, a locally green test does not erase it. Existing
160 checkpoint prose retains `PatchShape`, `CanonicalOwner`,
161 `UpwardDrillSignal`, `Decision`, outcome, and one bounded evidence ref.
162 Before an unplanned repair, compare invariant, owner seam, patch shape, and
163 topology; a renamed carrier is not a new direction.
164
165 If the tempting fix is "just add a small guard/fallback", also run:
166
167 ```text
168 Minimality Check:
169 - Smallest textual diff:
170 - Existing owner / reuse path:
171 - Correct owner:
172 - Bug class fixed:
173 - New branch/fallback added:
174 - Existence proof for new path:
175 - Old path retired or scheduled:
176 - Verdict: sufficient repair | local patch | needs first-principles review
177 ```
178
179 `local patch` is a mitigation, not a sufficient repair, unless it is the
180 canonical owner and includes a retention reason plus retirement trigger.
181 For candidate additions that are not ordinary repair code, run an
182 `Existence Check` using `docs/current/AEGIS_MINIMALITY_REFERENCE.md` before
183 editing. This is behavior-triggered: if the candidate repair adds a fallback,
184 adapter, branch, or new owner, the check runs even when the user asked for
185 that fallback directly.
186
187 ```text
188 Existence Check:
189 - Proposed new surface:
190 - Existing owner / reuse candidate:
191 - Why existing surface is insufficient:
192 - Creation proof:
193 - Entropy / retirement impact:
194 - Decision: reuse-existing | add-with-proof | defer | reject | needs-first-principles-review
195 ```
196
197 If the repair or retirement boundary depends on deleting old paths,
198 retaining compat for a proven external dependency, or stopping on
199 persistent-state risk, compose `anti-entropy-governance` before editing. It
200 decides the path; it does not grant destructive authority.
201
2028. **Change Necessity**
203
204 After root cause and canonical owner are identified, but before repair code,
205 make the code-change decision visible. This is the "should code change at
206 all?" check; it is not a new artifact and does not belong in the
207 `using-aegis` hot path.
208
209 This is behavior-triggered, not prompt-triggered. If the next step adds any
210 new source-code path or makes a non-trivial source edit, expose a natural
211 readback even when the user did not ask for it. A tiny helper, small guard,
212 new branch, fallback, adapter, or owner is not exempt. Example: "Code
213 necessity check: a non-code path is insufficient because <reason>; the
214 minimum change boundary is <canonical owner/files>, so the decision is
215 code-change."
216
217 ```text
218 Change Necessity:
219 - User-visible need:
220 - No-change / non-code option:
221 - Why code change is necessary:
222 - Minimum change boundary:
223 - Decision: no-change | docs/config-only | code-change | needs-clarification
224 ```
225
226 In quick bug lane, keep `Decision:` explicit even when using natural prose.
227
228 If the decision is `no-change`, do not edit source code. If the decision is
229 `docs/config-only`, narrow the fix to that surface and verify it. If the
230 decision is `needs-clarification`, pause before repair. If the decision is
231 `code-change`, carry the minimum boundary into `Fix Boundary`,
232 `Minimality Check`, and verification.
233
2349. **Pre-Edit Complexity Check**
235
236 After root cause and canonical owner are identified, check whether the fix
237 adds complexity to the wrong or overloaded place:
238
239 Use `using-aegis/references/complexity-governance.md` for shared pressure
240 signals and the meaning of `over-budget`.
241
242 ```text
243 Pre-Edit Complexity Check:
244 - Target edit file:
245 - Existing pressure signal:
246 - Owner fit:
247 - Safer edit boundary:
248 - Decision: edit-in-place | extract helper | add owner file | split task | pause for plan update
249
250 Pre-Edit Owner-Fit Decision:
251 - Edit intent: wiring-only | move-out / extract-first | local-fix-without-new-responsibility | new-responsibility | emergency / compatibility patch
252 - Owner fit:
253 - Safer edit boundary:
254 - Decision: edit-in-place | extract helper | add owner file | split task | pause for plan update
255 ```
256
257 If the safer boundary changes the implementation shape, pause and update the
258 plan/spec.
259
260 If the likely repair would grow an already oversized maintained artifact and
261 the slice cannot govern that growth immediately, do not present the repair as
262 a completed fix boundary. Escalate with a plan update or a visible follow-up
263 requirement.
264
265 When the target edit file is over-budget or mixed-purpose, classify edit
266 intent before source edits. `new-responsibility` must not be added in place
267 by default. `wiring-only`, `move-out / extract-first`, and
268 `local-fix-without-new-responsibility` may proceed only when they do not add
269 a new responsibility and the verification boundary is clear. `emergency /
270 compatibility patch` requires residual risk and a retirement trigger.
271
272### Phase 2: Pattern Analysis
273
2741. **Find working examples** in the same codebase — what works that's similar?
2752. **Compare against references** — read completely, don't skim
2763. **Identify differences** between working and broken — list every difference
2774. **Understand dependencies** — config, environment, assumptions
2785. **Locate the canonical owner** — which file/module should own this? Multiple owners = a finding, not normality
279
280### Phase 3: Hypothesis and Testing
281
2821. **Form single hypothesis**: "I think X is the root cause because Y" — be specific
2832. **Prove minimally**: use the smallest reproduction or verification, one
284 variable at a time. Prefer instrumentation over code edits while still
285 proving the cause. A failing reproduction may be useful evidence, but it is
286 not a RED gate or a prerequisite for production edits unless an explicit
287 `TDD Route: strict` says so.
2883. **Verify**: worked? → Phase 4. Didn't? → Form NEW hypothesis. Don't stack fixes.
2894. **When you don't know**: say "I don't understand X", don't pretend
2905. **Run Reflection** at the end of each loop:
291 - **Goal** | **DeeperCause** (yes/no/uncertain) | **Evidence** | **Risk/Unknown** | **Decision** (exit/iterate/escalate)
292 - If DeeperCause = uncertain → continue or escalate. Only exit when root cause is deep enough and evidence is sufficient.
293
294### Phase 3.5: Pre-Claim Gate
295
296Before claiming a root cause and entering Phase 4, check whether the
297Pre-Claim Gate applies. It applies whenever any Patch-Shape Triage signal is
298active (candidate fix is a guard, fallback, consumer/caller patch,
299artifact/cache patch, or sample-only naming — i.e. H1 / H3 / H8 / H10 / H11 /
300H13), or whenever the diagnosis crosses a component or system boundary, or a
301previous fix left a residual symptom.
302
303When it applies, do not state a root cause or edit code until the five
304mechanical checks below pass. See `root-cause-claim-contract.md` for the full
305rationale, the six-topology table, and a worked example.
306
3071. **Causal Closure** — every causal edge from symptom to claimed root has an
308 evidence anchor (file:line, test, log, reproduction). One "probably" edge
309 leaves the chain open.
3102. **Falsifier Checked** — state "if X were not the root cause, observable F
311 would appear," and confirm F was checked and absent.
3123. **Adversarial Self-Refutation** — generate the strongest single argument
313 that this root cause is wrong, and show why it does not hold.
3144. **Causal Topology Gate** — classify the topology explicitly; do not default
315 to single-root. Topology and the anti-disguise check are in Phase 4 Step
316 4bis and in `root-cause-claim-contract.md`.
3175. **Layer Ceiling Proof** — if the claim stops at L?, show why L?+1 is
318 unreachable by concrete constraint, not by omission.
319
320Required output before entering Phase 4 when the gate fires:
321
322```text
323Pre-Claim Gate Pass:
324Topology: single-root | single-root-multi-symptom | chain | independent-compound | conjunctive-cluster | disjunctive-or
325CausalClosure: closed | open-edge: <edge>
326Falsifier: <if not-X then F; F checked: yes/no>
327SelfRefutation: <strongest objection> -> <why it does not hold>
328LayerCeiling: <L?> -> <why L?+1 unreachable>
329Verdict: pass | fail-<which-gate>
330```
331
332This gate is advisory method-pack discipline. It is not a `GateDecision`,
333`PolicySnapshot`, evidence sufficiency authority, or completion authority. It
334turns a self-judged stop ("I think this is deep enough") into a checkable,
335falsifiable claim ("here is the evidence chain, the falsifier I checked, the
336objection I survived, and the ceiling I reached"). The quick bug lane is
337exempt when no Patch-Shape signal fires and the bug is single-owner at the
338canonical owner.
339
340### Phase 4: Implementation
341
342**Fix the root cause, not the symptom:**
343
3441. **Choose Reproduction and Verification**
345 - Under explicit `TDD Route: strict`, create the smallest failing test before production code.
346 - With `TDD Mode: off` and no strict route, do not require a failing test
347 first or RED / GREEN. A pre-change failing reproduction is permitted when
348 it helps diagnosis, but label it as evidence rather than a production-edit
349 gate; keep the smallest reproducible regression proof and targeted
350 verification that fit the fix.
351
3522. **Implement Single Fix**
353 - Address the root cause identified. ONE change at a time.
354 - No "while I'm here" improvements. No bundled refactoring.
355 - Prefer changing the canonical owner instead of stacking more logic into a fallback path.
356 - If Change Necessity, Patch-Shape Triage, Ripple Signal Triage, or
357 Pre-Edit Complexity Check fired, carry its owner, downstream, contract,
358 source-of-truth, fallback, retirement, edit-boundary, minimum-boundary, and
359 verification findings into the fix boundary before editing code.
360
3613. **Verify Fix**
362 - Does the selected verification pass? No other relevant tests broken? Issue actually resolved?
363 - Verify the intended compatibility boundary still holds.
364 - Verify you did not silently move authority to the wrong layer.
365
3664. **If Fix Doesn't Work**
367 - STOP. Count: How many fixes have you tried?
368 - If < 3: Return to Phase 1, re-analyze with new information.
369 - **If ≥ 3: STOP and question the architecture (step 6 below)**. DON'T attempt Fix #4 without architectural discussion.
370
3714bis. **Post-Fix Differential Diagnosis**
372
373 After applying a fix, if ANY symptom persists:
374
375 **STOP. Do NOT attempt another fix without diagnosis.**
376
377 1. Isolate the residual symptom precisely — what exactly remains?
378 2. Trace its causal chain independently (fresh Phase 1 run).
379 3. Compare with the causal chain of the fixed symptom:
380
381 | Residual pattern | Diagnosis | Action |
382 | --- | --- | --- |
383 | Same reproduction conditions as fixed symptom | Fix is incomplete | Continue upward drilling from same source |
384 | Different reproduction conditions, chains converge to same source | Fix was at wrong depth | Drill upward again from the shared source |
385 | Different reproduction conditions, chains diverge | Compound root cause (≥2 independent roots) | Each root needs its own fix |
386 | Same symptom, reduced but not eliminated | Fix was a downstream patch | Drill upward again from source |
387
388 4. If uncertain whether convergent or divergent: **escalate. Do not guess.**
389
390 **Compound root cause forms (legacy shorthand):**
391 - True compound — ≥2 independent bugs surfaced together
392 - Single-root multi-symptom — 1 root, ≥2 symptom paths → fix root, all resolve
393 - Chain causal — A causes B causes C → fix A, B and C auto-resolve
394
395 **Causal Topology Gate (full form, used by the Pre-Claim Gate):** the three
396 legacy forms above are a shorthand. Before claiming any root — single or
397 compound — classify the topology explicitly. The default is `unknown`; you
398 must actively exclude the multi-root topologies before collapsing to a
399 single-root claim. See `root-cause-claim-contract.md` for the full table,
400 member necessity/sufficiency tests, and the anti-disguise check.
401
402 | Topology | Structure | Stop condition | Repair shape |
403 | --- | --- | --- | --- |
404 | `single-root` | A → symptom | Layer Ceiling Proof at A | fix A |
405 | `single-root-multi-symptom` | A → B, C, D | Layer Ceiling Proof at A | fix A; symptoms self-resolve |
406 | `chain` | A → B → C → symptom | Layer Ceiling Proof at A | drill to A, fix A |
407 | `independent-compound` | A → symptom, Y → symptom, A ⊥ Y | each root passes Gate 1/2/5; no shared upstream | fix A **and** Y; missing one leaves symptom |
408 | `conjunctive-cluster` | A ∧ B ∧ C → symptom (each necessary, none sufficient) | enumerate members, necessity test each, sufficiency test the set, anti-disguise check | fix **all** members; missing one leaves symptom |
409 | `disjunctive-or` | A ∨ B → symptom (any one suffices) | enumerate all disjuncts | fix one to stop symptom; enumerate rest for defense-in-depth |
410
411 **Member proof (cluster / compound):** each claimed member must pass a
412 necessity test ("if this member alone were removed, would the symptom still
413 occur?" — if yes, it is not a member). The set must pass a sufficiency test
414 (together the members explain every observed manifestation). Necessity
415 tests here are conceptual proofs, not empirical runs — a method-pack
416 ceiling; state this honestly when the cluster has many members.
417
418 **Anti-disguise check (most often skipped):** before accepting
419 `conjunctive-cluster`, ask whether members X and Y share a deeper common
420 cause Z, such that X and Y are merely two manifestations of Z. If yes, the
421 topology collapses to `single-root-multi-symptom` or `chain` rooted at Z —
422 drill to Z. The reverse check protects `independent-compound`: if two
423 divergent chains share upstream Z, they are not independent and Z is the
424 root.
425
4265. **If 3+ Fixes Failed: Question Architecture**
427
428 **Pattern indicating architectural problem:**
429 - Each fix reveals new shared state/coupling/problem in different place
430 - Fixes require "massive refactoring" to implement
431 - Each fix creates new symptoms elsewhere
432
433 **STOP and question fundamentals.** Discuss with your human partner before attempting more fixes.
434 This is NOT a failed hypothesis — this is a wrong architecture.
435
4366. **Deliver Dual-Track Closure**
437
438 For bug fixes, refactors, contract changes, or governance cleanup, always produce:
439
440 **Repair track** — root cause, canonical owner, smallest necessary change, compatibility boundary, verification method.
441
442 **Retirement track** — old owner / fallback / patch, whether it is still active on the main path, the only reason to keep it (if any), trigger for deletion, verification needed before removal.
443
444 Never add a new owner, fallback, prompt branch, or adapter path without stating what happens to the old one.
445
446## Quality Gate
447
448Before you claim debugging is complete:
449
4500. **Workspace record for non-trivial debugging** — if this is medium+ complexity
451 or it writes `docs/aegis/` records, initialize/check through configured
452 Aegis workspace support when available:
453
454 ```bash
455 python <aegis-workspace-helper> init --root <target-project-root>
456 python <aegis-workspace-helper> new-work --root <target-project-root> ...
457 python <aegis-workspace-helper> add-evidence --root <target-project-root> --work <YYYY-MM-DD-slug> ...
458 python <aegis-workspace-helper> check --root <target-project-root>
459 ```
460
461 Fast bug fix or quick bug fix pressure does not skip this: if Ripple Signal
462 Triage fires, do the triage before editing and expand verification to the
463 canonical owner plus affected downstream path.
464
465 These records are method-pack evidence trails only. They do not grant
466 authoritative completion.
467
4681. **Stop-when review** — re-read the diagnostic layer where you stopped. Did you reach "no deeper why remains" or a T-class terminal boundary? If the chain ended at L1-L2 and the evidence is conclusive, that is a valid endpoint. If there are still unexplained "why" questions, continue upward drilling before claiming done.
469 - Use a `Layer Stop Card` when the stop point affects the fix boundary,
470 contract owner, spec/product decision, or user correction path. Keep
471 simple fast-path explanations cheap; do not emit the card for ordinary
472 factual Q&A about the skill itself.
4732. **Hard signal check** — apply these countable facts, not judgments:
474
475 Must continue upward drilling (H-class — ANY hit = NOT done):
476 - **H1** — fix added a conditional branch (`if` / `switch` / `catch` / `try`)
477 - **H2** — fix touched multiple sites but only 1 covered by the selected regression proof
478 - **H3** — fix is at consumer/caller, not canonical owner
479 - **H4** — same bug pattern exists elsewhere in repo (grep for it)
480 - **H5** — original reproduction still produces any anomaly
481 - **H6** — `git log --grep` shows this symptom was "fixed" before → Read that commit's diff. Understand why it failed. Do not repeat the same patch pattern.
482 - **H7** — candidate fix adds keyword, phrase, regex, negation-word list, or sample-text exception
483 - **H8** — candidate fix adds a local guard, one-off branch, early return, fallback, adapter, compatibility branch, prompt branch, or legacy path expansion
484 - **H9** — candidate fix patches a consumer/caller/readiness/presentation layer while an upstream owner could own correctness
485 - **H10** — downstream logic re-parses raw text or re-infers action/state while typed intent, normalized state, contract, or another source-of-truth exists
486 - **H11** — candidate fix patches artifact/download/export/readback/cache symptoms without proving the producer and source-of-truth owner
487 - **H12** — candidate fix keeps duplicate owners active, moves authority silently, or says "keep both for now" without a retirement trigger
488 - **H13** — candidate fix names only the observed sample wording/input instead of proving the bug class
489 - **H14** — topology is `conjunctive-cluster` or `independent-compound` but the member set is not enumerated, or a member was not necessity-tested
490 - **H15** — topology was declared `conjunctive-cluster` or `independent-compound` without running the anti-disguise check (a shared upstream Z may collapse the cluster/compound to a single root)
491
492 Terminal unactionable (T-class — any hit = stop drilling, switch to mitigation):
493 - **T1** — required change is outside this repo's boundary
494 - **T2** — would break published API contract with no migration path
495 - **T3** — root is undefined spec behavior (nobody defined correctness)
496 - **T4** — required permission or information is unavailable
497 → On T-class: record root cause + system boundary + architecture review: what boundary vulnerability did this expose? can the system be made more resilient to this class of external failure?
498
499 Depth sufficient (D-class — ALL must pass before claiming done):
500 - **D0** — fix eliminated ≥1 code path (paths after ≤ paths before)
501 - **D1** — fix eliminated ≥1 conditional branch (not added a fallback)
502 - **D2** — fix is at canonical owner
503 - **D3** — original reproduction steps no longer trigger any anomaly
504 - **D4** — no same-pattern occurrences remain unaddressed in repo
505 - **D5** — Minimality Check verdict is `sufficient repair`, or the local
506 patch is explicitly bounded with retention reason and retirement trigger
507 - **D6** — Causal topology is explicitly classified (not defaulted to
508 single-root); if `conjunctive-cluster` or `independent-compound`, every
509 member is enumerated and necessity-tested, and the set is sufficiency-tested
510 - **D7** — anti-disguise check has been run for any `conjunctive-cluster`
511 or `independent-compound` classification (a shared upstream Z was sought)
512
5133. **Reflection** — re-run Goal / DeeperCause / Evidence / Risk/Unknown / Decision
5144. **Confirm** the fix addressed the source, not just the sample
5155. **Retirement surface** — did it shrink, stay, or grow?
5166. **Confidence**:
517 - `A` = direct evidence and regression coverage support the root-cause conclusion
518 - `B` = strong evidence, limited coverage or some bounded unknowns remain
519 - `C` = partial evidence only; do not present as fully resolved
520
521If confidence is not at least `B`, do not speak as if the issue is fully closed.
522
523## Red Flags - STOP and Follow Process
524
525If you catch yourself thinking:
526
527- "Quick fix for now, investigate later"
528- "Let me just try changing X and see if it works" (ignoring evidence, error messages, or hard signals)
529- "Add multiple changes, run tests"
530- "Skip the test, I'll manually verify"
531- "I don't fully understand but this might work"
532- Diagnosing by intuition — "It's probably X", listing fixes without investigation, proposing solutions before tracing data flow
533- "One more fix attempt" (when already tried 2+)
534- "Let's just add another fallback" instead of finding root cause
535- "We can keep both owners for now" without a retirement condition
536- Accepting a partial fix without differential diagnosis
537
538**ALL of these mean: STOP. Return to Phase 1.**
539
540**If 3+ fixes failed:** Question the architecture (see Phase 4 Step 5)
541**If symptoms persist after fix:** Run differential diagnosis (see Phase 4 Step 4bis)
542
543## Human Partner Signals
544
545If you hear "Is that not happening?", "Will it show us...?", "Stop guessing", "Ultrathink this" → STOP. Return to Phase 1.
546
547## When Process Reveals "No Root Cause"
548
549If investigation reveals the issue is truly environmental, timing-dependent, or external:
550document what you investigated, implement appropriate handling (retry, timeout, error message),
551add monitoring.
552
553## Supporting Techniques
554
555See `root-cause-tracing.md`, `defense-in-depth.md`, `condition-based-waiting.md`, `feedback-loop-construction.md`, and `root-cause-claim-contract.md` in this directory for deeper guidance on specific diagnostic scenarios.
556
557---
558
559**Source:** [`hashgraph-online/awesome-codex-plugins`](https://github.com/hashgraph-online/awesome-codex-plugins) → `plugins/GanyuanRan/Aegis/skills/systematic-debugging/SKILL.md`