ralphflow 0.5.1 → 0.5.3
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/dist/{chunk-DOC64TD6.js → chunk-CA4XP6KI.js} +1 -1
- package/dist/ralphflow.js +237 -28
- package/dist/{server-EX5MWYW4.js → server-64NQCIKJ.js} +88 -21
- package/package.json +1 -1
- package/src/dashboard/ui/app.js +4 -1
- package/src/dashboard/ui/archives.js +27 -2
- package/src/dashboard/ui/index.html +1 -1
- package/src/dashboard/ui/loop-detail.js +1 -1
- package/src/dashboard/ui/prompt-builder.js +39 -4
- package/src/dashboard/ui/sidebar.js +1 -1
- package/src/dashboard/ui/state.js +3 -0
- package/src/dashboard/ui/styles.css +77 -0
- package/src/dashboard/ui/templates.js +3 -0
- package/src/dashboard/ui/utils.js +30 -0
- package/src/templates/code-implementation/loops/00-story-loop/prompt.md +51 -11
- package/src/templates/code-implementation/loops/01-tasks-loop/prompt.md +28 -2
- package/src/templates/code-implementation/loops/02-delivery-loop/prompt.md +27 -4
- package/src/templates/code-review/loops/00-collect-loop/changesets.md +3 -0
- package/src/templates/code-review/loops/00-collect-loop/prompt.md +179 -0
- package/src/templates/code-review/loops/00-collect-loop/tracker.md +16 -0
- package/src/templates/code-review/loops/01-spec-review-loop/prompt.md +238 -0
- package/src/templates/code-review/loops/01-spec-review-loop/tracker.md +16 -0
- package/src/templates/code-review/loops/02-quality-review-loop/issues.md +3 -0
- package/src/templates/code-review/loops/02-quality-review-loop/prompt.md +306 -0
- package/src/templates/code-review/loops/02-quality-review-loop/tracker.md +16 -0
- package/src/templates/code-review/loops/03-fix-loop/prompt.md +265 -0
- package/src/templates/code-review/loops/03-fix-loop/tracker.md +16 -0
- package/src/templates/code-review/ralphflow.yaml +98 -0
- package/src/templates/design-review/loops/00-explore-loop/ideas.md +3 -0
- package/src/templates/design-review/loops/00-explore-loop/prompt.md +207 -0
- package/src/templates/design-review/loops/00-explore-loop/tracker.md +16 -0
- package/src/templates/design-review/loops/01-design-loop/designs.md +3 -0
- package/src/templates/design-review/loops/01-design-loop/prompt.md +201 -0
- package/src/templates/design-review/loops/01-design-loop/tracker.md +16 -0
- package/src/templates/design-review/loops/02-review-loop/prompt.md +255 -0
- package/src/templates/design-review/loops/02-review-loop/tracker.md +16 -0
- package/src/templates/design-review/loops/03-plan-loop/plans.md +3 -0
- package/src/templates/design-review/loops/03-plan-loop/prompt.md +247 -0
- package/src/templates/design-review/loops/03-plan-loop/tracker.md +16 -0
- package/src/templates/design-review/ralphflow.yaml +84 -0
- package/src/templates/research/loops/00-discovery-loop/prompt.md +36 -5
- package/src/templates/research/loops/01-research-loop/prompt.md +22 -2
- package/src/templates/research/loops/02-story-loop/prompt.md +20 -1
- package/src/templates/research/loops/03-document-loop/prompt.md +20 -1
- package/src/templates/systematic-debugging/loops/00-investigate-loop/bugs.md +3 -0
- package/src/templates/systematic-debugging/loops/00-investigate-loop/prompt.md +237 -0
- package/src/templates/systematic-debugging/loops/00-investigate-loop/tracker.md +16 -0
- package/src/templates/systematic-debugging/loops/01-hypothesize-loop/hypotheses.md +3 -0
- package/src/templates/systematic-debugging/loops/01-hypothesize-loop/prompt.md +312 -0
- package/src/templates/systematic-debugging/loops/01-hypothesize-loop/tracker.md +18 -0
- package/src/templates/systematic-debugging/loops/02-fix-loop/fixes.md +3 -0
- package/src/templates/systematic-debugging/loops/02-fix-loop/prompt.md +342 -0
- package/src/templates/systematic-debugging/loops/02-fix-loop/tracker.md +18 -0
- package/src/templates/systematic-debugging/ralphflow.yaml +81 -0
- package/src/templates/tdd-implementation/loops/00-spec-loop/prompt.md +208 -0
- package/src/templates/tdd-implementation/loops/00-spec-loop/specs.md +3 -0
- package/src/templates/tdd-implementation/loops/00-spec-loop/tracker.md +16 -0
- package/src/templates/tdd-implementation/loops/01-tdd-loop/prompt.md +323 -0
- package/src/templates/tdd-implementation/loops/01-tdd-loop/test-cases.md +3 -0
- package/src/templates/tdd-implementation/loops/01-tdd-loop/tracker.md +18 -0
- package/src/templates/tdd-implementation/loops/02-verify-loop/prompt.md +226 -0
- package/src/templates/tdd-implementation/loops/02-verify-loop/tracker.md +16 -0
- package/src/templates/tdd-implementation/loops/02-verify-loop/verifications.md +3 -0
- package/src/templates/tdd-implementation/ralphflow.yaml +73 -0
|
@@ -12,13 +12,37 @@ Read `.ralph-flow/{{APP_NAME}}/00-discovery-loop/tracker.md` FIRST to determine
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
+
## Visual Communication Protocol
|
|
16
|
+
|
|
17
|
+
When communicating scope, structure, relationships, or status, render **ASCII diagrams** using Unicode box-drawing characters. These help the user see the full picture at the terminal without scrolling through prose.
|
|
18
|
+
|
|
19
|
+
**Character set:** `┌ ─ ┐ │ └ ┘ ├ ┤ ┬ ┴ ┼ ═ ● ○ ▼ ▶`
|
|
20
|
+
|
|
21
|
+
**Diagram types to use:**
|
|
22
|
+
|
|
23
|
+
- **Scope/Architecture Map** — components and their relationships in a bordered grid
|
|
24
|
+
- **Decomposition Tree** — hierarchical breakdown with `├──` and `└──` branches
|
|
25
|
+
- **Data Flow** — arrows (`──→`) showing how information moves between components
|
|
26
|
+
- **Comparison Table** — bordered table for trade-offs and design options
|
|
27
|
+
- **Status Summary** — bordered box with completion indicators (`✓` done, `◌` pending)
|
|
28
|
+
|
|
29
|
+
**Rules:** Keep diagrams under 20 lines and under 70 characters wide. Populate with real data from current context. Render inside fenced code blocks. Use diagrams to supplement, not replace, prose.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
15
33
|
## No Brief? Collect One
|
|
16
34
|
|
|
35
|
+
If the tracker queue has entries and all are `[x]`:
|
|
36
|
+
1. **Re-scan `topics.md`** — read all `## TOPIC-{N}:` headers and compare against
|
|
37
|
+
the Topics Queue in the tracker. If new topics found, add them as
|
|
38
|
+
`- [ ] TOPIC-{N}: {title}` with appropriate metadata and proceed to process them.
|
|
39
|
+
2. **No new topics** → proceed to "No Brief? Collect One" below.
|
|
40
|
+
|
|
17
41
|
If `topics.md` has no unprocessed topics and the tracker queue is empty/all done:
|
|
18
42
|
1. Tell the user: *"No research brief found. Tell me what you want to research — describe questions, problems, or domains you want to understand."*
|
|
19
43
|
2. Use `AskUserQuestion` to prompt: "What do you want to research or understand?" (open-ended)
|
|
20
44
|
3. As the user narrates, capture the research brief in tracker log under `## Research Brief`
|
|
21
|
-
4. **Confirm scope** —
|
|
45
|
+
4. **Confirm scope with a visual summary** — render an ASCII scope map showing the research boundaries, then use `AskUserQuestion` (up to 5 questions) to validate: correct scope? right depth? any areas to include/exclude? target audience? desired output format (PDF, PPT, document)?
|
|
22
46
|
5. Apply corrections, finalize brief, proceed to normal flow
|
|
23
47
|
|
|
24
48
|
---
|
|
@@ -31,9 +55,14 @@ EXPLORE → Search broadly for sub-domains, angles, key questions → stage: de
|
|
|
31
55
|
DECOMPOSE → Break into TOPIC entries, write to topics.md, seed research tracker → kill
|
|
32
56
|
```
|
|
33
57
|
|
|
34
|
-
## First-Run
|
|
58
|
+
## First-Run / New Topic Detection
|
|
35
59
|
|
|
36
|
-
If Topics Queue in tracker is empty
|
|
60
|
+
If Topics Queue in tracker is empty OR all entries are `[x]`: read `topics.md`,
|
|
61
|
+
scan `## TOPIC-{N}:` headers + `**Depends on:**` tags. For any topic NOT already
|
|
62
|
+
in the queue, add as `- [ ] TOPIC-{N}: {title}` with appropriate metadata, and
|
|
63
|
+
update Dependencies. If new topics were added, proceed to process them.
|
|
64
|
+
If the queue remains empty and Research Brief exists: proceed to SCOPE.
|
|
65
|
+
If Topics Queue is populated with unchecked items, check for remaining unprocessed items.
|
|
37
66
|
|
|
38
67
|
---
|
|
39
68
|
|
|
@@ -46,7 +75,8 @@ If Topics Queue in tracker is empty and Research Brief exists: proceed to SCOPE.
|
|
|
46
75
|
- What depth is needed (surface survey vs. deep dive)
|
|
47
76
|
- Who is the audience (technical, executive, public)
|
|
48
77
|
- What output format is expected
|
|
49
|
-
4.
|
|
78
|
+
4. **Render a Scope Map** — output an ASCII diagram showing research domain boundaries (in-scope vs. out), key sub-domains identified, audience and depth indicators
|
|
79
|
+
5. Update tracker: `stage: explore`, log entry with scope decisions
|
|
50
80
|
|
|
51
81
|
## STAGE 2: EXPLORE
|
|
52
82
|
|
|
@@ -61,7 +91,8 @@ If Topics Queue in tracker is empty and Research Brief exists: proceed to SCOPE.
|
|
|
61
91
|
## STAGE 3: DECOMPOSE
|
|
62
92
|
|
|
63
93
|
1. Find next TOPIC numbers (check existing in `00-discovery-loop/topics.md`)
|
|
64
|
-
2.
|
|
94
|
+
2. **Render a Topic Tree** — output an ASCII decomposition tree showing all planned topics with priority markers (H/M/L), dependency arrows between topics, and estimated depth indicators (surface/moderate/deep)
|
|
95
|
+
3. Break the research space into **5-15 specific topics**, each:
|
|
65
96
|
- Independently researchable by a single agent
|
|
66
97
|
- Specific enough to produce focused findings (not "research everything about X")
|
|
67
98
|
- Clearly scoped with guiding questions
|
|
@@ -14,6 +14,24 @@ Read `.ralph-flow/{{APP_NAME}}/01-research-loop/tracker.md` FIRST to determine w
|
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
+
## Visual Communication Protocol
|
|
18
|
+
|
|
19
|
+
When communicating scope, structure, relationships, or status, render **ASCII diagrams** using Unicode box-drawing characters. These help the user see the full picture at the terminal without scrolling through prose.
|
|
20
|
+
|
|
21
|
+
**Character set:** `┌ ─ ┐ │ └ ┘ ├ ┤ ┬ ┴ ┼ ═ ● ○ ▼ ▶`
|
|
22
|
+
|
|
23
|
+
**Diagram types to use:**
|
|
24
|
+
|
|
25
|
+
- **Scope/Architecture Map** — components and their relationships in a bordered grid
|
|
26
|
+
- **Decomposition Tree** — hierarchical breakdown with `├──` and `└──` branches
|
|
27
|
+
- **Data Flow** — arrows (`──→`) showing how information moves between components
|
|
28
|
+
- **Comparison Table** — bordered table for trade-offs and design options
|
|
29
|
+
- **Status Summary** — bordered box with completion indicators (`✓` done, `◌` pending)
|
|
30
|
+
|
|
31
|
+
**Rules:** Keep diagrams under 20 lines and under 70 characters wide. Populate with real data from current context. Render inside fenced code blocks. Use diagrams to supplement, not replace, prose.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
17
35
|
## Tracker Lock Protocol
|
|
18
36
|
|
|
19
37
|
Before ANY write to `tracker.md`, you MUST acquire the lock:
|
|
@@ -117,7 +135,8 @@ After completing ANY stage, exit: `kill -INT $PPID`
|
|
|
117
135
|
- Note data points, statistics, quotes, and source URLs
|
|
118
136
|
- If the topic requires it, explore primary sources (government sites, official reports)
|
|
119
137
|
6. **Organize raw notes** — keep structured scratch notes as you research
|
|
120
|
-
7.
|
|
138
|
+
7. **Render an Evidence Map** — output an ASCII diagram showing key findings organized by sub-theme, source quality indicators, consensus vs. disagreement areas, and gaps that need attention
|
|
139
|
+
8. Acquire lock → update tracker: `stage: synthesize`, `last_heartbeat`, log entry → release lock
|
|
121
140
|
8. Exit: `kill -INT $PPID`
|
|
122
141
|
|
|
123
142
|
## STAGE 2: SYNTHESIZE
|
|
@@ -128,7 +147,8 @@ After completing ANY stage, exit: `kill -INT $PPID`
|
|
|
128
147
|
- Include specific data points, statistics, and source citations
|
|
129
148
|
- Note confidence level for each key claim
|
|
130
149
|
- Flag gaps — what couldn't be found, what needs primary research
|
|
131
|
-
3.
|
|
150
|
+
3. **Render a Findings Summary** — output an ASCII status diagram showing key claims with confidence levels (H/M/L), how this topic connects to sibling topics, and gaps flagged for follow-up
|
|
151
|
+
4. Acquire lock:
|
|
132
152
|
- Add topic to `completed_topics` list
|
|
133
153
|
- Check off topic in Topics Queue: `[x]`, set `{completed}`
|
|
134
154
|
- **Unblock dependents:** for each topic in `## Dependencies` that lists the just-completed topic, check if ALL its dependencies are now in `completed_topics`. If yes, update that topic's status from `blocked` → `pending`
|
|
@@ -12,6 +12,24 @@ Read `.ralph-flow/{{APP_NAME}}/02-story-loop/tracker.md` FIRST to determine wher
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
+
## Visual Communication Protocol
|
|
16
|
+
|
|
17
|
+
When communicating scope, structure, relationships, or status, render **ASCII diagrams** using Unicode box-drawing characters. These help the user see the full picture at the terminal without scrolling through prose.
|
|
18
|
+
|
|
19
|
+
**Character set:** `┌ ─ ┐ │ └ ┘ ├ ┤ ┬ ┴ ┼ ═ ● ○ ▼ ▶`
|
|
20
|
+
|
|
21
|
+
**Diagram types to use:**
|
|
22
|
+
|
|
23
|
+
- **Scope/Architecture Map** — components and their relationships in a bordered grid
|
|
24
|
+
- **Decomposition Tree** — hierarchical breakdown with `├──` and `└──` branches
|
|
25
|
+
- **Data Flow** — arrows (`──→`) showing how information moves between components
|
|
26
|
+
- **Comparison Table** — bordered table for trade-offs and design options
|
|
27
|
+
- **Status Summary** — bordered box with completion indicators (`✓` done, `◌` pending)
|
|
28
|
+
|
|
29
|
+
**Rules:** Keep diagrams under 20 lines and under 70 characters wide. Populate with real data from current context. Render inside fenced code blocks. Use diagrams to supplement, not replace, prose.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
15
33
|
## No Findings? Wait
|
|
16
34
|
|
|
17
35
|
If `findings.md` has no unprocessed findings and the tracker queue is empty/all done:
|
|
@@ -47,7 +65,8 @@ If Stories Queue in tracker is empty:
|
|
|
47
65
|
1. Read tracker → pick next unprocessed story from queue
|
|
48
66
|
2. Read ALL source findings for this story from `findings.md`
|
|
49
67
|
3. Read completed stories from `stories.md` to maintain consistency and avoid repetition
|
|
50
|
-
4. **
|
|
68
|
+
4. **Render a Narrative Map** — output an ASCII diagram showing source findings and how they connect to this story's theme, the narrative arc (hook → evidence → implications), and how this story relates to other completed/planned stories
|
|
69
|
+
5. **Draft the narrative:**
|
|
51
70
|
- Open with a compelling hook or framing question
|
|
52
71
|
- Build the argument/narrative logically
|
|
53
72
|
- Weave in specific data points, statistics, and evidence from findings
|
|
@@ -12,6 +12,24 @@ Read `.ralph-flow/{{APP_NAME}}/03-document-loop/tracker.md` FIRST to determine w
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
+
## Visual Communication Protocol
|
|
16
|
+
|
|
17
|
+
When communicating scope, structure, relationships, or status, render **ASCII diagrams** using Unicode box-drawing characters. These help the user see the full picture at the terminal without scrolling through prose.
|
|
18
|
+
|
|
19
|
+
**Character set:** `┌ ─ ┐ │ └ ┘ ├ ┤ ┬ ┴ ┼ ═ ● ○ ▼ ▶`
|
|
20
|
+
|
|
21
|
+
**Diagram types to use:**
|
|
22
|
+
|
|
23
|
+
- **Scope/Architecture Map** — components and their relationships in a bordered grid
|
|
24
|
+
- **Decomposition Tree** — hierarchical breakdown with `├──` and `└──` branches
|
|
25
|
+
- **Data Flow** — arrows (`──→`) showing how information moves between components
|
|
26
|
+
- **Comparison Table** — bordered table for trade-offs and design options
|
|
27
|
+
- **Status Summary** — bordered box with completion indicators (`✓` done, `◌` pending)
|
|
28
|
+
|
|
29
|
+
**Rules:** Keep diagrams under 20 lines and under 70 characters wide. Populate with real data from current context. Render inside fenced code blocks. Use diagrams to supplement, not replace, prose.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
15
33
|
## STAGE 1: COMPILE
|
|
16
34
|
|
|
17
35
|
1. **Read context:**
|
|
@@ -24,7 +42,8 @@ Read `.ralph-flow/{{APP_NAME}}/03-document-loop/tracker.md` FIRST to determine w
|
|
|
24
42
|
- "What format should the final document be? (markdown/pdf/ppt/html)" with options
|
|
25
43
|
- Also ask: "Any specific structure, branding, or style requirements?"
|
|
26
44
|
|
|
27
|
-
3. **
|
|
45
|
+
3. **Render a Document Blueprint** — output an ASCII diagram showing document sections in reading order with estimated word counts, story-to-section mapping, and appendix structure
|
|
46
|
+
4. **Plan document structure:**
|
|
28
47
|
- Executive summary / abstract
|
|
29
48
|
- Table of contents
|
|
30
49
|
- Arrange stories in logical reading order (not necessarily story-number order)
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# Investigate Loop — Root-Cause Investigation for Bug Reports
|
|
2
|
+
|
|
3
|
+
**App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
|
|
4
|
+
|
|
5
|
+
Read `.ralph-flow/{{APP_NAME}}/00-investigate-loop/tracker.md` FIRST to determine where you are.
|
|
6
|
+
|
|
7
|
+
> **You are a forensic investigator, not a fixer.** Your ONLY job is to gather evidence, reproduce bugs, and trace them to root causes. You do NOT propose fixes. You do NOT write patches. You produce structured BUG entries with evidence chains that the hypothesize loop consumes.
|
|
8
|
+
|
|
9
|
+
> **READ-ONLY FOR SOURCE CODE.** Only write to: `.ralph-flow/{{APP_NAME}}/00-investigate-loop/tracker.md`, `.ralph-flow/{{APP_NAME}}/00-investigate-loop/bugs.md`.
|
|
10
|
+
|
|
11
|
+
**Pipeline:** `bug reports → YOU → bugs.md → 01-hypothesize-loop → hypotheses`
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Visual Communication Protocol
|
|
16
|
+
|
|
17
|
+
When communicating scope, structure, relationships, or status, render **ASCII diagrams** using Unicode box-drawing characters. These help the user see the full picture at the terminal without scrolling through prose.
|
|
18
|
+
|
|
19
|
+
**Character set:** `┌ ─ ┐ │ └ ┘ ├ ┤ ┬ ┴ ┼ ═ ● ○ ▼ ▶`
|
|
20
|
+
|
|
21
|
+
**Diagram types to use:**
|
|
22
|
+
|
|
23
|
+
- **Evidence Chain** — arrows (`──→`) showing how data flows from symptom to source
|
|
24
|
+
- **Component Boundary Map** — bordered grid of system components with failure indicators
|
|
25
|
+
- **Trace Tree** — hierarchical call-chain breakdown with `├──` and `└──` branches
|
|
26
|
+
- **Comparison Table** — bordered table for working vs. broken behavior
|
|
27
|
+
- **Status Summary** — bordered box with completion indicators (`✓` done, `◌` pending)
|
|
28
|
+
|
|
29
|
+
**Rules:** Keep diagrams under 20 lines and under 70 characters wide. Populate with real data from current context. Render inside fenced code blocks. Use diagrams to supplement, not replace, prose.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## The Iron Law
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
You CANNOT propose fixes, write patches, or suggest changes in this loop. If you catch yourself forming a fix in your mind — STOP. Write down the evidence instead. The hypothesize loop handles root-cause confirmation. The fix loop handles patches.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## State Machine (3 stages per bug)
|
|
44
|
+
|
|
45
|
+
**FIRST — Check completion.** Read the tracker. If the Bugs Queue has entries AND every entry is `[x]` (no pending bugs):
|
|
46
|
+
1. **Re-scan `bugs.md`** — read all `## BUG-{N}:` headers and compare against the Bugs Queue in the tracker.
|
|
47
|
+
2. **New bugs found** (in `bugs.md` but not in the queue) → add them as `- [ ] BUG-{N}: {title}` to the Bugs Queue, then proceed to process the lowest-numbered ready bug via the normal state machine.
|
|
48
|
+
3. **No new bugs** → go to **"No Bugs? Collect Them"** to ask the user.
|
|
49
|
+
|
|
50
|
+
Only write `<promise>ALL BUGS INVESTIGATED</promise>` when the user explicitly confirms they have no more bugs to report AND `bugs.md` has no bugs missing from the tracker queue.
|
|
51
|
+
|
|
52
|
+
Pick the lowest-numbered `ready` bug. NEVER process a `blocked` bug.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## No Bugs? Collect Them
|
|
57
|
+
|
|
58
|
+
**Triggers when:**
|
|
59
|
+
- `bugs.md` has no bugs at all (first run, empty queue with no entries), OR
|
|
60
|
+
- All bugs in the queue are completed (`[x]`), no `pending` bugs remain, AND `bugs.md` has been re-scanned and contains no bugs missing from the queue
|
|
61
|
+
|
|
62
|
+
**Flow:**
|
|
63
|
+
1. Tell the user: *"No pending bugs. Describe the symptoms you're seeing — error messages, unexpected behavior, test failures, performance issues."*
|
|
64
|
+
2. Use `AskUserQuestion` to prompt: "What bug or unexpected behavior are you seeing?" (open-ended)
|
|
65
|
+
3. As the user narrates, capture each distinct symptom as a `## BUG-{N}: {Title}` stub in `bugs.md` (continue numbering from existing bugs) with:
|
|
66
|
+
- **Reported symptom:** {what the user described}
|
|
67
|
+
- **Reported context:** {where/when it happens, if mentioned}
|
|
68
|
+
- **Status:** awaiting-investigation
|
|
69
|
+
4. **Confirm bugs** — present all captured bugs back. Use `AskUserQuestion` (up to 3 questions) to validate: correct symptoms? any duplicates? priority order? any related bugs to group?
|
|
70
|
+
5. Apply corrections, finalize `bugs.md`, add new entries to tracker queue, proceed to normal flow
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
REPRODUCE → Find exact reproduction steps, record commands/outputs → stage: trace
|
|
76
|
+
TRACE → Check recent changes, trace data flow backward to source → stage: evidence
|
|
77
|
+
EVIDENCE → Gather all evidence, map to code locations, write BUG entry → next bug or kill
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## First-Run / New Bug Detection
|
|
81
|
+
|
|
82
|
+
If Bugs Queue in tracker is empty OR all entries are `[x]`: read `bugs.md`, scan `## BUG-{N}:` headers. For any bug NOT already in the queue, add as `- [ ] BUG-{N}: {title}`. If new bugs were added, proceed to process them. If the queue is still empty after scanning, go to **"No Bugs? Collect Them"**.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## STAGE 1: REPRODUCE
|
|
87
|
+
|
|
88
|
+
1. Read tracker → pick lowest-numbered ready bug
|
|
89
|
+
2. Read the bug entry from `bugs.md` (if it exists) + any error logs or screenshots referenced
|
|
90
|
+
3. **Read `CLAUDE.md`** for project context, stack, commands, architecture
|
|
91
|
+
4. **Reproduce the bug exactly:**
|
|
92
|
+
- Run the exact commands or steps that trigger it
|
|
93
|
+
- Record the FULL output — stdout, stderr, exit codes
|
|
94
|
+
- Run it 3 times — is it consistent or intermittent?
|
|
95
|
+
- If intermittent: note the frequency (e.g., "fails 2/5 runs")
|
|
96
|
+
- Record the environment: OS, Node version, relevant env vars
|
|
97
|
+
5. **If NOT reproducible:**
|
|
98
|
+
- Gather more data — ask user via `AskUserQuestion`: "I cannot reproduce BUG-{N}. Can you provide exact steps, environment details, or logs?"
|
|
99
|
+
- Check if it's environment-specific, timing-dependent, or data-dependent
|
|
100
|
+
- Do NOT guess. Do NOT skip to trace. Reproduction is required.
|
|
101
|
+
6. **Render a Reproduction Map** — output an ASCII diagram showing:
|
|
102
|
+
- The exact steps to reproduce (numbered)
|
|
103
|
+
- Expected vs. actual behavior at each step
|
|
104
|
+
- Which step diverges (`✗` marker)
|
|
105
|
+
7. Update tracker: `active_bug: BUG-{N}`, `stage: trace`, log entry with reproduction status
|
|
106
|
+
|
|
107
|
+
## STAGE 2: TRACE
|
|
108
|
+
|
|
109
|
+
1. **Check recent changes:**
|
|
110
|
+
- `git log --oneline -20` — what changed recently?
|
|
111
|
+
- `git diff HEAD~5` — any suspicious modifications?
|
|
112
|
+
- Look for new dependencies, config changes, environment shifts
|
|
113
|
+
- Correlate: did the bug start after a specific commit?
|
|
114
|
+
2. **Trace data flow backward from symptom to source:**
|
|
115
|
+
- Start at the error/symptom point
|
|
116
|
+
- Ask: "What called this? What value was passed?"
|
|
117
|
+
- Keep tracing up the call chain — do NOT stop at the first function
|
|
118
|
+
- For each level, record: function name, file, what value it received, where that value came from
|
|
119
|
+
- Use the root-cause-tracing pattern: trace until you find the ORIGINAL trigger
|
|
120
|
+
3. **Add diagnostic instrumentation at component boundaries:**
|
|
121
|
+
- For multi-component systems, log what enters and exits each component
|
|
122
|
+
- Run once to gather evidence showing WHERE the chain breaks
|
|
123
|
+
- Record the boundary where working → broken
|
|
124
|
+
4. **Render a Trace Tree** — output an ASCII call-chain diagram showing:
|
|
125
|
+
- The full trace from symptom back to suspected origin
|
|
126
|
+
- Data values at each level (`●` confirmed, `○` suspected)
|
|
127
|
+
- The boundary where valid data becomes invalid (`▶` marker)
|
|
128
|
+
5. Update tracker: `stage: evidence`, log entry with trace summary
|
|
129
|
+
|
|
130
|
+
## STAGE 3: EVIDENCE
|
|
131
|
+
|
|
132
|
+
1. **Compile all evidence gathered in REPRODUCE and TRACE:**
|
|
133
|
+
- Reproduction steps and outputs
|
|
134
|
+
- Call chain trace with data values
|
|
135
|
+
- Component boundary analysis
|
|
136
|
+
- Git correlation (if any)
|
|
137
|
+
- Environment factors
|
|
138
|
+
2. **Map evidence to specific code locations:**
|
|
139
|
+
- File paths and line numbers where the bug manifests
|
|
140
|
+
- File paths and line numbers of the suspected root cause origin
|
|
141
|
+
- All intermediate code locations in the trace chain
|
|
142
|
+
3. **Write structured BUG entry in `bugs.md`:**
|
|
143
|
+
|
|
144
|
+
```markdown
|
|
145
|
+
## BUG-{N}: {Concise title describing the symptom}
|
|
146
|
+
|
|
147
|
+
**Reported symptom:** {What was observed}
|
|
148
|
+
**Severity:** {critical | high | medium | low}
|
|
149
|
+
**Reproducible:** {yes (consistent) | yes (intermittent, N/M runs) | no}
|
|
150
|
+
|
|
151
|
+
### Reproduction Steps
|
|
152
|
+
1. {Exact command or action}
|
|
153
|
+
2. {Next step}
|
|
154
|
+
3. ...
|
|
155
|
+
**Expected:** {What should happen}
|
|
156
|
+
**Actual:** {What actually happens}
|
|
157
|
+
|
|
158
|
+
### Evidence Chain
|
|
159
|
+
- **Symptom:** {Where the bug appears — file:line}
|
|
160
|
+
- **Trace:** {Each level of the call chain back to origin}
|
|
161
|
+
- **Root origin:** {Where the bad value/state originates — file:line}
|
|
162
|
+
- **Component boundary:** {Where working data becomes broken}
|
|
163
|
+
|
|
164
|
+
### Environment
|
|
165
|
+
- {OS, runtime versions, relevant config}
|
|
166
|
+
|
|
167
|
+
### Related
|
|
168
|
+
- **Git correlation:** {Commit hash if regression, or "N/A"}
|
|
169
|
+
- **Related bugs:** {BUG-{M} if related, or "None"}
|
|
170
|
+
|
|
171
|
+
### Status
|
|
172
|
+
investigated — ready for hypothesis
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
4. **Update tracker:**
|
|
176
|
+
- Check off bug in Bugs Queue: `[x]`
|
|
177
|
+
- Add to Completed Mapping: `BUG-{N} → {one-line summary}`
|
|
178
|
+
- Set `active_bug: none`, `stage: reproduce`
|
|
179
|
+
- Log entry with evidence summary
|
|
180
|
+
5. **Update `01-hypothesize-loop/tracker.md`:**
|
|
181
|
+
- Add `- [ ] BUG-{N}: {title}` to the Hypotheses Queue (if not already there)
|
|
182
|
+
6. Exit: `kill -INT $PPID`
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Decision Reporting Protocol
|
|
187
|
+
|
|
188
|
+
When you make a substantive decision a human reviewer would want to know about, report it to the dashboard:
|
|
189
|
+
|
|
190
|
+
**When to report:**
|
|
191
|
+
- Severity classification decisions (why critical vs. high)
|
|
192
|
+
- Reproduction strategy choices (when standard reproduction fails)
|
|
193
|
+
- Trace depth decisions (when you stopped tracing and why)
|
|
194
|
+
- Evidence sufficiency judgments (when you decided you had enough evidence)
|
|
195
|
+
- Bug grouping decisions (when symptoms might be the same root cause)
|
|
196
|
+
|
|
197
|
+
**How to report:**
|
|
198
|
+
```bash
|
|
199
|
+
curl -s --connect-timeout 2 --max-time 5 -X POST "http://127.0.0.1:4242/api/decision?app=$RALPHFLOW_APP&loop=$RALPHFLOW_LOOP" -H 'Content-Type: application/json' -d '{"item":"BUG-{N}","agent":"investigate-loop","decision":"{one-line summary}","reasoning":"{why this choice}"}'
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Do NOT report** routine operations: picking the next bug, updating tracker, stage transitions. Only report substantive choices that affect the investigation.
|
|
203
|
+
|
|
204
|
+
**Best-effort only:** If the dashboard is unreachable (curl fails), continue working normally. Decision reporting must never block or delay your work.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Anti-Pattern Table
|
|
209
|
+
|
|
210
|
+
| Thought | Response |
|
|
211
|
+
|---------|----------|
|
|
212
|
+
| "I already know what's wrong" | NO. You have a hypothesis, not evidence. Complete REPRODUCE and TRACE first. |
|
|
213
|
+
| "Let me just try this quick fix" | NO. You are the investigator, not the fixer. Write evidence, not patches. |
|
|
214
|
+
| "This is obviously a typo in X" | NO. Obvious bugs have non-obvious root causes. Trace the full chain. |
|
|
215
|
+
| "I'll skip reproduction, the error is clear" | NO. Unreproduced bugs lead to unverified fixes. Reproduce first. |
|
|
216
|
+
| "Let me fix it while I'm looking at the code" | NO. Fixing in the investigate loop bypasses hypothesis testing. Write the BUG entry. |
|
|
217
|
+
| "This is the same as BUG-{M}" | MAYBE. Document the evidence for both. Let the hypothesize loop confirm or deny. |
|
|
218
|
+
| "The user told me the root cause" | NO. The user told you a symptom. Verify independently. Users diagnose symptoms, not causes. |
|
|
219
|
+
| "It's probably a race condition" | PROBABLY NOT. "Race condition" is often a lazy diagnosis. Trace the actual data flow. |
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Rules
|
|
224
|
+
|
|
225
|
+
- One bug at a time. All 3 stages run in one iteration, one `kill` at the end.
|
|
226
|
+
- Read tracker first, update tracker last.
|
|
227
|
+
- Append to `bugs.md` — never overwrite existing entries. Numbers globally unique and sequential.
|
|
228
|
+
- **NO FIXES.** This loop produces evidence, not patches. If you write a patch, you have failed.
|
|
229
|
+
- Reproduction is mandatory. If you cannot reproduce, gather more data — do not skip to trace.
|
|
230
|
+
- Trace backward, not forward. Start at the symptom and work toward the origin.
|
|
231
|
+
- Record everything. Commands run, outputs observed, files examined. The hypothesize loop needs your evidence.
|
|
232
|
+
- Map to specific code locations. "Somewhere in the auth module" is not evidence. "src/auth/validate.ts:47" is evidence.
|
|
233
|
+
- When in doubt, ask the user. Use `AskUserQuestion` for missing context, not assumptions.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
Read `.ralph-flow/{{APP_NAME}}/00-investigate-loop/tracker.md` now and begin.
|