@hanzlaa/rcode 3.6.4 → 3.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzlaa/rcode",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.5",
|
|
4
4
|
"description": "rcode — the AI team that never forgets. Persistent memory, specialist agents, and slash commands for AI IDEs. Works in Claude Code, Cursor, Gemini, VS Code, and Antigravity.",
|
|
5
5
|
"main": "cli/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: rihal-debug
|
|
3
|
-
|
|
4
|
-
description: Root-cause debugging via the scientific method.
|
|
3
|
+
description: Root-cause debugging via the scientific method. Enforces investigate-before-fix, structured hypothesis iteration, multi-component evidence gathering, and architectural escalation after 3 failed fixes.
|
|
5
4
|
triggers:
|
|
6
5
|
# English
|
|
7
6
|
- "debug this"
|
|
@@ -12,11 +11,15 @@ triggers:
|
|
|
12
11
|
- "track this down"
|
|
13
12
|
- "narrow down the bug"
|
|
14
13
|
- "scientific method"
|
|
14
|
+
- "bug fix"
|
|
15
|
+
- "something is broken"
|
|
15
16
|
# Roman Urdu / Hindi
|
|
16
17
|
- "kharab kyu hai"
|
|
17
18
|
- "bug dhoondo"
|
|
18
19
|
- "fix karo bug"
|
|
19
20
|
- "theek karo"
|
|
21
|
+
- "kya masla hai"
|
|
22
|
+
- "kyu kaam nahi kar raha"
|
|
20
23
|
# Arabic native
|
|
21
24
|
- "صحّح هذا"
|
|
22
25
|
- "ما المشكلة"
|
|
@@ -29,29 +32,136 @@ user-invocable: false
|
|
|
29
32
|
@.rihal/references/karpathy-guidelines.md
|
|
30
33
|
|
|
31
34
|
|
|
35
|
+
## The Iron Law
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
If you have not completed Phase 1, you cannot propose a fix. "It seems to work" is a red flag — keep investigating until the mechanism is clear. Symptom fixes are failure.
|
|
42
|
+
|
|
32
43
|
## Overview
|
|
33
44
|
|
|
34
|
-
Debugging is investigation, not pattern-matching. Each iteration narrows the problem space — never widens it. The skill enforces a written hypothesis, an experiment that distinguishes "yes" from "no", and a captured observation. Random fixes
|
|
45
|
+
Debugging is investigation, not pattern-matching. Each iteration narrows the problem space — never widens it. The skill enforces a written hypothesis, an experiment that distinguishes "yes" from "no", and a captured observation. Random fixes are not allowed — the bug must be understood before the fix is written.
|
|
46
|
+
|
|
47
|
+
## Phase 1 — Root Cause Investigation
|
|
48
|
+
|
|
49
|
+
**BEFORE attempting ANY fix:**
|
|
50
|
+
|
|
51
|
+
1. **Reproduce consistently.** Write the exact steps. If not reproducible, make it reproducible first — anything else is guessing.
|
|
52
|
+
|
|
53
|
+
2. **Read the error carefully.** Don't skim stack traces. Note file paths, line numbers, error codes. They often contain the exact answer.
|
|
54
|
+
|
|
55
|
+
3. **Check recent changes.** `git diff`, recent commits, new dependencies, config changes, environment differences.
|
|
56
|
+
|
|
57
|
+
4. **Gather evidence in multi-component systems.**
|
|
58
|
+
|
|
59
|
+
When the system has multiple layers (API → service → DB, CI → build → signing, frontend → backend → queue):
|
|
60
|
+
|
|
61
|
+
Add diagnostic instrumentation at EACH component boundary BEFORE proposing fixes:
|
|
62
|
+
```
|
|
63
|
+
For EACH boundary:
|
|
64
|
+
- Log what data enters the component
|
|
65
|
+
- Log what data exits the component
|
|
66
|
+
- Verify env/config propagation
|
|
67
|
+
- Check state at each layer
|
|
68
|
+
|
|
69
|
+
Run ONCE to gather evidence showing WHERE it breaks.
|
|
70
|
+
THEN identify the failing component.
|
|
71
|
+
THEN investigate that specific component.
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Example:
|
|
75
|
+
```bash
|
|
76
|
+
# Layer 1: incoming request
|
|
77
|
+
console.log('[L1] body:', req.body, 'userId:', req.user?.id)
|
|
78
|
+
|
|
79
|
+
# Layer 2: service call
|
|
80
|
+
console.log('[L2] args to createTask:', args)
|
|
81
|
+
|
|
82
|
+
# Layer 3: DB query
|
|
83
|
+
console.log('[L3] Prisma input:', data)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
This reveals which layer fails — not guessing.
|
|
35
87
|
|
|
36
|
-
|
|
88
|
+
5. **Trace data flow backward.** Where does the bad value originate? What called this function with that bad value? Keep tracing up until you find the source. Fix at source, not at symptom.
|
|
37
89
|
|
|
38
|
-
|
|
39
|
-
2. **State the hypothesis.** "I think the bug is in <component>; specifically <mechanism>." One sentence, falsifiable.
|
|
40
|
-
3. **Design the experiment.** What single test, log line, or dataflow change would distinguish a true hypothesis from a false one?
|
|
41
|
-
4. **Run it. Capture the observation.** Console output verbatim, screenshot, stack trace, network response — whatever the experiment produced.
|
|
42
|
-
5. **Update the hypothesis.** Either confirmed (now narrow to the next layer) or refuted (form a new hypothesis based on what was observed).
|
|
43
|
-
6. **Stop conditions:** the bug is reproducible from a unit test (then hand to `rihal-prove-it`), OR the root cause is a known external constraint (e.g. third-party API behaviour) that you record in `incidents/known-issues.md`.
|
|
44
|
-
7. **Never apply a fix without understanding why it works.** "It seems to fix it" is a red flag — keep investigating until the mechanism is clear.
|
|
90
|
+
## Phase 2 — Pattern Analysis
|
|
45
91
|
|
|
46
|
-
|
|
92
|
+
Before forming a hypothesis, find the comparison point:
|
|
93
|
+
|
|
94
|
+
1. **Find working examples.** Locate similar code in the same codebase that works. What's different?
|
|
95
|
+
2. **Read reference implementations completely.** Don't skim — partial understanding guarantees bugs.
|
|
96
|
+
3. **List every difference**, however small. Don't assume "that can't matter."
|
|
97
|
+
4. **Check assumptions.** What config, environment, or state does this code assume?
|
|
98
|
+
|
|
99
|
+
## Phase 3 — Hypothesis and Experiment
|
|
100
|
+
|
|
101
|
+
Scientific method:
|
|
102
|
+
|
|
103
|
+
1. **State ONE hypothesis.** "I think X is the root cause because Y." Write it down. Be specific, not vague.
|
|
104
|
+
2. **Design the minimal experiment.** What single test, log line, or code change would confirm or refute this hypothesis?
|
|
105
|
+
3. **Run it. Capture the observation verbatim.** Console output, stack trace, network response — whatever was produced.
|
|
106
|
+
4. **Update.** Confirmed → Phase 4. Refuted → form a new hypothesis based on what was observed. Do NOT add more fixes on top.
|
|
107
|
+
|
|
108
|
+
## Phase 4 — Implementation
|
|
109
|
+
|
|
110
|
+
1. **Create a failing test first.** Simplest possible reproduction. Use `rihal-prove-it` for writing the test that locks the fix in.
|
|
111
|
+
2. **Implement ONE fix.** Address the root cause identified. No "while I'm here" improvements. No bundled refactors.
|
|
112
|
+
3. **Verify.** Test passes. No other tests broken. Issue actually resolved.
|
|
113
|
+
4. **If fix doesn't work:** STOP. Count fix attempts.
|
|
114
|
+
- < 3 attempts: return to Phase 1 with new information.
|
|
115
|
+
- **≥ 3 attempts: STOP — this is an architectural problem.**
|
|
116
|
+
|
|
117
|
+
## Architectural Escalation (after 3 failed fixes)
|
|
118
|
+
|
|
119
|
+
Pattern that signals architectural problem:
|
|
120
|
+
- Each fix reveals new coupling or shared state in a different place
|
|
121
|
+
- Fixes require "massive refactoring" to implement
|
|
122
|
+
- Each fix creates new symptoms elsewhere
|
|
123
|
+
|
|
124
|
+
When this pattern appears:
|
|
125
|
+
1. Stop attempting fixes
|
|
126
|
+
2. Ask: is this pattern fundamentally sound, or are we continuing through inertia?
|
|
127
|
+
3. Discuss with the user before attempting more fixes
|
|
128
|
+
4. Consider `/rihal-council` for a cross-functional review
|
|
129
|
+
|
|
130
|
+
## Sentry / Observability Integration
|
|
47
131
|
|
|
48
132
|
If the project has Sentry (`@sentry/*` in `package.json` or `sentry-sdk` in Python):
|
|
49
133
|
|
|
50
|
-
- Quote the actual Sentry issue ID and stack trace in the hypothesis
|
|
51
|
-
-
|
|
52
|
-
- Check
|
|
134
|
+
- Quote the actual Sentry issue ID and stack trace in the hypothesis
|
|
135
|
+
- Read breadcrumbs for the chain of events leading to the error
|
|
136
|
+
- Check "first seen / last seen" — recurring or one-off matters
|
|
53
137
|
- Cross-reference with deployment timestamps to identify regressions
|
|
54
138
|
|
|
139
|
+
## Red Flags — STOP and return to Phase 1
|
|
140
|
+
|
|
141
|
+
If you catch yourself thinking any of these:
|
|
142
|
+
- "Quick fix for now, investigate later"
|
|
143
|
+
- "Just try changing X and see if it works"
|
|
144
|
+
- "Add multiple changes and run tests"
|
|
145
|
+
- "It's probably X, let me fix that"
|
|
146
|
+
- "I don't fully understand but this might work"
|
|
147
|
+
- "It seems to fix it"
|
|
148
|
+
- "One more fix attempt" (when already tried 2+)
|
|
149
|
+
- Proposing solutions before tracing data flow
|
|
150
|
+
- Each fix reveals a new problem in a different place
|
|
151
|
+
|
|
152
|
+
**ALL of these mean: STOP. Return to Phase 1.**
|
|
153
|
+
|
|
154
|
+
## Common Rationalizations
|
|
155
|
+
|
|
156
|
+
| Excuse | Reality |
|
|
157
|
+
|--------|---------|
|
|
158
|
+
| "Issue is simple, don't need process" | Simple bugs have root causes too. Process is fast for simple bugs. |
|
|
159
|
+
| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
|
|
160
|
+
| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
|
|
161
|
+
| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
|
|
162
|
+
| "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
|
|
163
|
+
| "One more fix attempt" (after 2+) | 3+ failures = architectural problem. Escalate, don't fix again. |
|
|
164
|
+
|
|
55
165
|
## Output Format
|
|
56
166
|
|
|
57
167
|
```
|
|
@@ -59,9 +169,12 @@ Reproduction:
|
|
|
59
169
|
<exact steps>
|
|
60
170
|
<observed vs expected>
|
|
61
171
|
|
|
172
|
+
Phase 1 — Evidence
|
|
173
|
+
<what layers were instrumented and what they showed>
|
|
174
|
+
|
|
62
175
|
Iteration 1
|
|
63
|
-
Hypothesis: <falsifiable claim>
|
|
64
|
-
Experiment: <
|
|
176
|
+
Hypothesis: <falsifiable claim — "I think X because Y">
|
|
177
|
+
Experiment: <the single test/log that would confirm or refute>
|
|
65
178
|
Observation: <verbatim output>
|
|
66
179
|
Outcome: confirmed | refuted | partial
|
|
67
180
|
|
|
@@ -69,26 +182,30 @@ Iteration N
|
|
|
69
182
|
...
|
|
70
183
|
|
|
71
184
|
Root cause:
|
|
72
|
-
<one paragraph
|
|
185
|
+
<one paragraph — the actual mechanism, not the symptom>
|
|
73
186
|
|
|
74
187
|
Fix scope:
|
|
75
|
-
<minimum change that
|
|
188
|
+
<minimum change that addresses the cause>
|
|
76
189
|
|
|
77
190
|
Regression test:
|
|
78
|
-
<hand
|
|
191
|
+
<hand to rihal-prove-it — the test that locks the fix in>
|
|
79
192
|
```
|
|
80
193
|
|
|
81
|
-
Do NOT include: "tried X and it seems to work"
|
|
194
|
+
Do NOT include: "tried X and it seems to work" · speculative "maybe it's caching" · broad refactors disguised as bug fixes.
|
|
82
195
|
|
|
83
196
|
## Examples
|
|
84
197
|
|
|
85
|
-
**Happy path** — "Login fails for Arabic usernames" → reproduce: POST `/login` with `محمد` returns 500 →
|
|
198
|
+
**Happy path** — "Login fails for Arabic usernames" → reproduce: POST `/login` with `محمد` returns 500 → Phase 1: hex-dump log of raw request body → observation: UTF-8 bytes, but Postgres driver re-encodes as Latin-1 → root cause: `client_encoding` mismatch → fix: pin `client_encoding=utf8` in connection string → regression test asserts non-ASCII login returns 200.
|
|
199
|
+
|
|
200
|
+
**Multi-component** — "Tasks not appearing after creation" → instrument three layers: controller logs input, service logs DB call args, DB query logs row count → observation: service receives correct args, DB returns `rowCount: 0` → hypothesis: wrong table name in query → confirmed → one-line fix, regression test added.
|
|
201
|
+
|
|
202
|
+
**Edge case — flaky test** — Passes locally, fails in CI 30% of the time → hypothesis: race condition → experiment: `--runInBand` → still flaky → next hypothesis: filesystem timing → experiment: `await fs.stat` after write → confirmed → fix.
|
|
86
203
|
|
|
87
|
-
**
|
|
204
|
+
**Negative — shotgun fix** — "I added a try/catch around the whole function and now it doesn't crash." Refuse. The exception is silently swallowed; the bug still exists. Restore the throw and form a real hypothesis.
|
|
88
205
|
|
|
89
|
-
**
|
|
206
|
+
**Architectural escalation** — Three separate fixes attempted (missing await, wrong env var, stale cache) — each fix exposed a new problem elsewhere. Stop. The async data-flow design is wrong. Escalate to `/rihal-council` before attempting Fix #4.
|
|
90
207
|
|
|
91
208
|
## Memory Bank Hooks
|
|
92
209
|
|
|
93
|
-
- **Reads:** `.rihal/memory/incidents/known-issues.md` (
|
|
94
|
-
- **Writes:** append
|
|
210
|
+
- **Reads:** `.rihal/memory/incidents/known-issues.md` (prior debugging context), `.rihal/memory/project/stack.md` (Sentry presence, observability tools)
|
|
211
|
+
- **Writes:** append root cause to `.rihal/memory/incidents/post-mortems/YYYYMMDD-<slug>.md` when resolved; remove from `known-issues.md` once fix is verified in production
|