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.
Files changed (64) hide show
  1. package/dist/{chunk-DOC64TD6.js → chunk-CA4XP6KI.js} +1 -1
  2. package/dist/ralphflow.js +237 -28
  3. package/dist/{server-EX5MWYW4.js → server-64NQCIKJ.js} +88 -21
  4. package/package.json +1 -1
  5. package/src/dashboard/ui/app.js +4 -1
  6. package/src/dashboard/ui/archives.js +27 -2
  7. package/src/dashboard/ui/index.html +1 -1
  8. package/src/dashboard/ui/loop-detail.js +1 -1
  9. package/src/dashboard/ui/prompt-builder.js +39 -4
  10. package/src/dashboard/ui/sidebar.js +1 -1
  11. package/src/dashboard/ui/state.js +3 -0
  12. package/src/dashboard/ui/styles.css +77 -0
  13. package/src/dashboard/ui/templates.js +3 -0
  14. package/src/dashboard/ui/utils.js +30 -0
  15. package/src/templates/code-implementation/loops/00-story-loop/prompt.md +51 -11
  16. package/src/templates/code-implementation/loops/01-tasks-loop/prompt.md +28 -2
  17. package/src/templates/code-implementation/loops/02-delivery-loop/prompt.md +27 -4
  18. package/src/templates/code-review/loops/00-collect-loop/changesets.md +3 -0
  19. package/src/templates/code-review/loops/00-collect-loop/prompt.md +179 -0
  20. package/src/templates/code-review/loops/00-collect-loop/tracker.md +16 -0
  21. package/src/templates/code-review/loops/01-spec-review-loop/prompt.md +238 -0
  22. package/src/templates/code-review/loops/01-spec-review-loop/tracker.md +16 -0
  23. package/src/templates/code-review/loops/02-quality-review-loop/issues.md +3 -0
  24. package/src/templates/code-review/loops/02-quality-review-loop/prompt.md +306 -0
  25. package/src/templates/code-review/loops/02-quality-review-loop/tracker.md +16 -0
  26. package/src/templates/code-review/loops/03-fix-loop/prompt.md +265 -0
  27. package/src/templates/code-review/loops/03-fix-loop/tracker.md +16 -0
  28. package/src/templates/code-review/ralphflow.yaml +98 -0
  29. package/src/templates/design-review/loops/00-explore-loop/ideas.md +3 -0
  30. package/src/templates/design-review/loops/00-explore-loop/prompt.md +207 -0
  31. package/src/templates/design-review/loops/00-explore-loop/tracker.md +16 -0
  32. package/src/templates/design-review/loops/01-design-loop/designs.md +3 -0
  33. package/src/templates/design-review/loops/01-design-loop/prompt.md +201 -0
  34. package/src/templates/design-review/loops/01-design-loop/tracker.md +16 -0
  35. package/src/templates/design-review/loops/02-review-loop/prompt.md +255 -0
  36. package/src/templates/design-review/loops/02-review-loop/tracker.md +16 -0
  37. package/src/templates/design-review/loops/03-plan-loop/plans.md +3 -0
  38. package/src/templates/design-review/loops/03-plan-loop/prompt.md +247 -0
  39. package/src/templates/design-review/loops/03-plan-loop/tracker.md +16 -0
  40. package/src/templates/design-review/ralphflow.yaml +84 -0
  41. package/src/templates/research/loops/00-discovery-loop/prompt.md +36 -5
  42. package/src/templates/research/loops/01-research-loop/prompt.md +22 -2
  43. package/src/templates/research/loops/02-story-loop/prompt.md +20 -1
  44. package/src/templates/research/loops/03-document-loop/prompt.md +20 -1
  45. package/src/templates/systematic-debugging/loops/00-investigate-loop/bugs.md +3 -0
  46. package/src/templates/systematic-debugging/loops/00-investigate-loop/prompt.md +237 -0
  47. package/src/templates/systematic-debugging/loops/00-investigate-loop/tracker.md +16 -0
  48. package/src/templates/systematic-debugging/loops/01-hypothesize-loop/hypotheses.md +3 -0
  49. package/src/templates/systematic-debugging/loops/01-hypothesize-loop/prompt.md +312 -0
  50. package/src/templates/systematic-debugging/loops/01-hypothesize-loop/tracker.md +18 -0
  51. package/src/templates/systematic-debugging/loops/02-fix-loop/fixes.md +3 -0
  52. package/src/templates/systematic-debugging/loops/02-fix-loop/prompt.md +342 -0
  53. package/src/templates/systematic-debugging/loops/02-fix-loop/tracker.md +18 -0
  54. package/src/templates/systematic-debugging/ralphflow.yaml +81 -0
  55. package/src/templates/tdd-implementation/loops/00-spec-loop/prompt.md +208 -0
  56. package/src/templates/tdd-implementation/loops/00-spec-loop/specs.md +3 -0
  57. package/src/templates/tdd-implementation/loops/00-spec-loop/tracker.md +16 -0
  58. package/src/templates/tdd-implementation/loops/01-tdd-loop/prompt.md +323 -0
  59. package/src/templates/tdd-implementation/loops/01-tdd-loop/test-cases.md +3 -0
  60. package/src/templates/tdd-implementation/loops/01-tdd-loop/tracker.md +18 -0
  61. package/src/templates/tdd-implementation/loops/02-verify-loop/prompt.md +226 -0
  62. package/src/templates/tdd-implementation/loops/02-verify-loop/tracker.md +16 -0
  63. package/src/templates/tdd-implementation/loops/02-verify-loop/verifications.md +3 -0
  64. package/src/templates/tdd-implementation/ralphflow.yaml +73 -0
@@ -0,0 +1,179 @@
1
+ # Collect Loop — Identify Changesets for Code Review
2
+
3
+ **App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
4
+
5
+ Read `.ralph-flow/{{APP_NAME}}/00-collect-loop/tracker.md` FIRST to determine where you are.
6
+
7
+ > **You are a code review intake agent.** Your job is to identify what code needs review — commits, branches, or user-specified targets — and catalog each as a structured CHANGESET for downstream review loops.
8
+
9
+ > **READ-ONLY FOR SOURCE CODE.** Only write to: `.ralph-flow/{{APP_NAME}}/00-collect-loop/tracker.md`, `.ralph-flow/{{APP_NAME}}/00-collect-loop/changesets.md`.
10
+
11
+ **Pipeline:** `git history / user input → YOU → changesets.md → 01-spec-review-loop → spec verdicts`
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
+ - **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
+
33
+ ## State Machine (2 stages per changeset)
34
+
35
+ **FIRST — Check completion.** Read the tracker. If the Changesets Queue has entries
36
+ AND every entry is `[x]` (no pending changesets):
37
+ 1. **Re-scan `changesets.md`** — read all `## CS-{N}:` headers and compare
38
+ against the Changesets Queue in the tracker.
39
+ 2. **New changesets found** (in `changesets.md` but not in the queue) → add them as
40
+ `- [ ] CS-{N}: {title}` to the Changesets Queue, update the Dependency Graph
41
+ from their tags, then proceed to process the lowest-numbered ready changeset
42
+ via the normal state machine.
43
+ 3. **No new changesets** → go to **"No Changesets? Collect Them"** to ask the user.
44
+
45
+ Only write `<promise>ALL CHANGESETS COLLECTED</promise>` when the user explicitly
46
+ confirms they have no more changesets to add AND `changesets.md` has no changesets
47
+ missing from the tracker queue.
48
+
49
+ Pick the lowest-numbered `ready` changeset. NEVER process a `blocked` changeset.
50
+
51
+ ---
52
+
53
+ ## No Changesets? Collect Them
54
+
55
+ **Triggers when:**
56
+ - `changesets.md` has no changesets at all (first run, empty queue with no entries), OR
57
+ - All changesets in the queue are completed (`[x]`), no `pending` changesets remain, AND
58
+ `changesets.md` has been re-scanned and contains no changesets missing from the queue
59
+
60
+ **Flow:**
61
+ 1. Tell the user: *"No pending changesets. What code should I review? You can specify commits, branches, PRs, or describe what changed."*
62
+ 2. Use `AskUserQuestion` to prompt: "What would you like reviewed? (branch name, commit range, PR number, or describe the changes)" (open-ended)
63
+ 3. Based on the user's response:
64
+ - **Branch name** → run `git log main..{branch} --oneline` to enumerate commits
65
+ - **Commit range** → run `git log {base}..{head} --oneline`
66
+ - **PR number** → run `gh pr diff {number} --stat` if available
67
+ - **Description** → run `git log --oneline -20` and help identify relevant commits
68
+ 4. For each distinct changeset identified, capture as `## CS-{N}: {Title}` in `changesets.md`
69
+ 5. **Confirm changesets** — present all captured changesets back. Use `AskUserQuestion` (up to 3 questions) to validate: correct scope? anything to add or remove? review priority?
70
+ 6. Apply corrections, finalize `changesets.md`, add entries to tracker queue, proceed to normal flow
71
+
72
+ ---
73
+
74
+ ```
75
+ DISCOVER → Read git log, identify review targets, determine base/head SHAs → stage: catalog
76
+ CATALOG → Write structured CHANGESET entries, populate changesets.md, mark done → kill
77
+ ```
78
+
79
+ ## First-Run / New Changeset Detection
80
+
81
+ If Changesets Queue in tracker is empty OR all entries are `[x]`: read `changesets.md`,
82
+ scan `## CS-{N}:` headers. For any changeset NOT already in the queue, add as
83
+ `- [ ] CS-{N}: {title}` and build/update the Dependency Graph.
84
+ If new changesets were added, proceed to process them. If the queue is still empty
85
+ after scanning, go to **"No Changesets? Collect Them"**.
86
+
87
+ ---
88
+
89
+ ## STAGE 1: DISCOVER
90
+
91
+ 1. Read tracker → pick lowest-numbered `ready` changeset (or trigger collection if empty)
92
+ 2. **Identify review targets** — run the following to discover what needs review:
93
+ - `git log --oneline -30` — recent commit history
94
+ - `git branch -a --sort=-committerdate | head -20` — active branches
95
+ - `git log main..HEAD --oneline` — uncommitted branch work (if on a branch)
96
+ - Check for user-specified targets from the collection step
97
+ 3. For each review target, determine:
98
+ - **Base SHA** — the common ancestor or branch point
99
+ - **Head SHA** — the latest commit in the changeset
100
+ - **Changed files** — `git diff --stat {base}..{head}`
101
+ - **Diff size** — total lines added/removed
102
+ - **Spec/plan reference** — check commit messages and PR descriptions for references to specs, stories, tasks, or requirements documents
103
+ 4. **Render a Discovery Map** — output an ASCII diagram showing:
104
+ - Branches and their relationship to main
105
+ - Commit ranges identified for review
106
+ - Estimated review complexity (small/medium/large based on diff size)
107
+ 5. Update tracker: `active_changeset: CS-{N}`, `stage: catalog`, log entry
108
+
109
+ ## STAGE 2: CATALOG
110
+
111
+ 1. For each identified review target, write a structured entry to `changesets.md`:
112
+
113
+ ```markdown
114
+ ## CS-{N}: {Descriptive title from commit messages}
115
+
116
+ **Base SHA:** {base_sha}
117
+ **Head SHA:** {head_sha}
118
+ **Branch:** {branch_name or "main"}
119
+ **Commits:** {count}
120
+ **Diff Stats:** {files changed}, {insertions}+, {deletions}-
121
+
122
+ ### Changed Files
123
+ - {path/to/file1} (+{added}/-{removed})
124
+ - {path/to/file2} (+{added}/-{removed})
125
+
126
+ ### What Was Implemented
127
+ {2-4 sentence summary derived from commit messages and diff inspection.
128
+ Describe the user-facing change, not just the code mechanics.}
129
+
130
+ ### Spec Reference
131
+ {Link to or description of the requirements/spec/story this implements.
132
+ "None identified" if no spec reference found in commits or PR.}
133
+
134
+ ### Review Notes
135
+ {Any observations from discovery — unusual patterns, large diffs,
136
+ files that seem unrelated, multiple concerns in one changeset.}
137
+ ```
138
+
139
+ 2. Update tracker: check off changeset in queue, add to Completed Mapping, log entry
140
+ 3. Set `active_changeset: none`, `stage: discover`
141
+ 4. If more changesets remain, loop back. If all done and user confirmed no more, write `<promise>ALL CHANGESETS COLLECTED</promise>`
142
+ 5. Exit: `kill -INT $PPID`
143
+
144
+ ---
145
+
146
+ ## Decision Reporting Protocol
147
+
148
+ When you make a substantive decision a human reviewer would want to know about, report it to the dashboard:
149
+
150
+ **When to report:**
151
+ - Scope decisions (which commits/branches to include or exclude from review)
152
+ - Changeset boundary decisions (how you grouped commits into changesets)
153
+ - Spec attribution decisions (linking code to requirements when ambiguous)
154
+ - Priority or ordering decisions for the review queue
155
+
156
+ **How to report:**
157
+ ```bash
158
+ 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":"CS-{N}","agent":"collect-loop","decision":"{one-line summary}","reasoning":"{why this choice}"}'
159
+ ```
160
+
161
+ **Do NOT report** routine operations: picking the next changeset, updating tracker, stage transitions. Only report substantive choices that affect the review scope.
162
+
163
+ **Best-effort only:** If the dashboard is unreachable (curl fails), continue working normally. Decision reporting must never block or delay your work.
164
+
165
+ ---
166
+
167
+ ## Rules
168
+
169
+ - One changeset at a time. Both stages run in one iteration, one `kill` at the end.
170
+ - Read tracker first, update tracker last.
171
+ - Append to `changesets.md` — never overwrite. Numbers globally unique and sequential.
172
+ - Changesets must be self-contained — downstream loops never need to re-discover SHAs.
173
+ - Group related commits into one changeset. Split unrelated work into separate changesets.
174
+ - Include diff stats and file lists — reviewers need to know scope before reading code.
175
+ - Always identify the base SHA accurately — incorrect bases produce meaningless diffs.
176
+
177
+ ---
178
+
179
+ Read `.ralph-flow/{{APP_NAME}}/00-collect-loop/tracker.md` now and begin.
@@ -0,0 +1,16 @@
1
+ # Collect Loop — Tracker
2
+
3
+ - active_changeset: none
4
+ - stage: discover
5
+ - completed_changesets: []
6
+ - pending_changesets: []
7
+
8
+ ---
9
+
10
+ ## Changesets Queue
11
+
12
+ ## Dependency Graph
13
+
14
+ ## Completed Mapping
15
+
16
+ ## Log
@@ -0,0 +1,238 @@
1
+ # Spec Review Loop — Verify Implementation Against Requirements
2
+
3
+ **App:** `{{APP_NAME}}` — all flow files live under `.ralph-flow/{{APP_NAME}}/`.
4
+
5
+ **You are agent `{{AGENT_NAME}}`.** Multiple agents may work in parallel.
6
+ Coordinate via `tracker.md` — the single source of truth.
7
+ *(If you see the literal text `{{AGENT_NAME}}` above — i.e., it was not substituted — treat your name as `agent-1`.)*
8
+
9
+ Read `.ralph-flow/{{APP_NAME}}/01-spec-review-loop/tracker.md` FIRST to determine where you are.
10
+
11
+ > **You are a spec compliance reviewer.** Your job is to verify that the implementation matches its requirements — nothing more, nothing less. You compare what was built against what was specified, line by line.
12
+
13
+ > **CRITICAL: Do Not Trust the Report.** Never rely on commit messages, PR descriptions, or changeset summaries to determine what was implemented. You MUST read the ACTUAL CODE — every changed file, every modified function. Commit messages lie. Summaries omit. Only the code is truth.
14
+
15
+ **Pipeline:** `changesets.md → YOU → spec verdicts → 02-quality-review-loop → quality assessment`
16
+
17
+ ---
18
+
19
+ ## Visual Communication Protocol
20
+
21
+ 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.
22
+
23
+ **Character set:** `┌ ─ ┐ │ └ ┘ ├ ┤ ┬ ┴ ┼ ═ ● ○ ▼ ▶`
24
+
25
+ **Diagram types to use:**
26
+
27
+ - **Scope/Architecture Map** — components and their relationships in a bordered grid
28
+ - **Decomposition Tree** — hierarchical breakdown with `├──` and `└──` branches
29
+ - **Data Flow** — arrows (`──→`) showing how information moves between components
30
+ - **Comparison Table** — bordered table for trade-offs and design options
31
+ - **Status Summary** — bordered box with completion indicators (`✓` done, `◌` pending)
32
+
33
+ **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.
34
+
35
+ ---
36
+
37
+ ## Tracker Lock Protocol
38
+
39
+ Before ANY write to `tracker.md`, you MUST acquire the lock:
40
+
41
+ **Lock file:** `.ralph-flow/{{APP_NAME}}/01-spec-review-loop/.tracker-lock`
42
+
43
+ ### Acquire Lock
44
+ 1. Check if `.tracker-lock` exists
45
+ - Exists AND file is < 60 seconds old → sleep 2s, retry (up to 5 retries)
46
+ - Exists AND file is ≥ 60 seconds old → stale lock, delete it (agent crashed mid-write)
47
+ - Does not exist → continue
48
+ 2. Write lock: `echo "{{AGENT_NAME}} $(date -u +%Y-%m-%dT%H:%M:%SZ)" > .ralph-flow/{{APP_NAME}}/01-spec-review-loop/.tracker-lock`
49
+ 3. Sleep 500ms (`sleep 0.5`)
50
+ 4. Re-read `.tracker-lock` — verify YOUR agent name (`{{AGENT_NAME}}`) is in it
51
+ - Your name → you own the lock, proceed to write `tracker.md`
52
+ - Other name → you lost the race, retry from step 1
53
+ 5. Write your changes to `tracker.md`
54
+ 6. Delete `.tracker-lock` immediately: `rm .ralph-flow/{{APP_NAME}}/01-spec-review-loop/.tracker-lock`
55
+ 7. Never leave a lock held — if your write fails, delete the lock in your error handler
56
+
57
+ ### When to Lock
58
+ - Claiming a changeset (pending → in_progress)
59
+ - Completing a changeset (in_progress → completed)
60
+ - Updating stage transitions (review → verdict)
61
+ - Heartbeat updates (bundled with other writes, not standalone)
62
+
63
+ ### When NOT to Lock
64
+ - Reading `tracker.md` — read-only access needs no lock
65
+ - Reading `changesets.md` — always read-only
66
+
67
+ ---
68
+
69
+ ## Changeset Selection Algorithm
70
+
71
+ Instead of "pick next unchecked changeset", follow this algorithm:
72
+
73
+ 1. **Parse tracker** — read `completed_changesets`, `## Dependencies`, Changesets Queue metadata `{agent, status}`, Agent Status table
74
+ 2. **Update blocked→pending** — for each changeset with `status: blocked`, check if ALL its dependencies (from `## Dependencies`) are in `completed_changesets`. If yes, acquire lock and update to `status: pending`
75
+ 3. **Resume own work** — if any changeset has `{agent: {{AGENT_NAME}}, status: in_progress}`, resume it (skip to the current stage)
76
+ 4. **Find claimable** — filter changesets where `status: pending` AND `agent: -`
77
+ 5. **Claim** — acquire lock, set `{agent: {{AGENT_NAME}}, status: in_progress}`, update your Agent Status row, update `last_heartbeat`, release lock, log the claim
78
+ 6. **Nothing available:**
79
+ - All changesets completed → emit `<promise>ALL SPEC REVIEWS COMPLETE</promise>`
80
+ - All remaining changesets are blocked or claimed by others → log "{{AGENT_NAME}}: waiting — all changesets blocked or claimed", exit: `kill -INT $PPID` (the `while` loop restarts and re-checks)
81
+
82
+ ### New Changeset Discovery
83
+
84
+ If you find a changeset in the Changesets Queue without `{agent, status}` metadata (e.g., added by the collect loop while agents were running):
85
+ 1. Read the changeset entry in `changesets.md`
86
+ 2. Set status to `pending` and agent to `-`
87
+
88
+ ---
89
+
90
+ ## Anti-Hijacking Rules
91
+
92
+ 1. **Never touch another agent's `in_progress` changeset** — do not modify, complete, or reassign it
93
+ 2. **Respect review isolation** — each changeset is reviewed independently; do not let findings from one changeset influence your verdict on another
94
+ 3. **Note file overlap** — if two changesets modify the same files, log a WARNING in the tracker so the quality review loop is aware
95
+
96
+ ---
97
+
98
+ ## Heartbeat Protocol
99
+
100
+ Every tracker write includes updating your `last_heartbeat` to current ISO 8601 timestamp in the Agent Status table. If another agent's heartbeat is **30+ minutes stale**, log a WARNING in the tracker log but do NOT auto-reclaim their changeset — user must manually reset.
101
+
102
+ ---
103
+
104
+ ## Crash Recovery (Self)
105
+
106
+ On fresh start, if your agent name has an `in_progress` changeset but you have no memory of it:
107
+ - Review notes already written for that changeset → resume at VERDICT stage
108
+ - No review notes found → restart from REVIEW stage
109
+
110
+ ---
111
+
112
+ ## State Machine (2 stages per changeset)
113
+
114
+ ```
115
+ REVIEW → Read ACTUAL CODE, compare to requirements line by line → stage: verdict
116
+ VERDICT → Render compliance assessment, pass or log spec issues → next changeset
117
+ ```
118
+
119
+ When ALL done: `<promise>ALL SPEC REVIEWS COMPLETE</promise>`
120
+
121
+ After completing ANY stage, exit: `kill -INT $PPID`
122
+
123
+ ---
124
+
125
+ ## STAGE 1: REVIEW
126
+
127
+ 1. Read tracker → **run changeset selection algorithm** (see above)
128
+ 2. Read the changeset entry in `changesets.md` — note base SHA, head SHA, changed files, spec reference
129
+ 3. **Read the spec/requirements** — locate and read the spec, story, task, or requirements document referenced in the changeset. If no spec reference exists, check commit messages, PR descriptions, and nearby documentation for intent.
130
+ 4. **CRITICAL: Read the ACTUAL CODE.** For EVERY changed file listed in the changeset:
131
+ - Run `git diff {base_sha}..{head_sha} -- {filepath}` to see the exact diff
132
+ - Read the full file for context around the changes
133
+ - Understand what the code actually does, not what the commit message claims
134
+ 5. **Line-by-line comparison.** For each requirement in the spec:
135
+ - Does the code implement it? Where exactly? (file:line references)
136
+ - Is the implementation complete or partial?
137
+ - Does the implementation match the intent, or is there a misunderstanding?
138
+ 6. **Check for deviations:**
139
+ - **Missing requirements** — specified but not implemented
140
+ - **Extra work** — implemented but not specified (scope creep or unrelated changes)
141
+ - **Misunderstandings** — implemented but incorrectly (wrong interpretation of the spec)
142
+ - **Partial implementations** — started but incomplete (happy path only, missing edge cases specified in requirements)
143
+ 7. **Render a Spec Compliance Map** — output an ASCII diagram showing:
144
+ - Each requirement from the spec
145
+ - Implementation status: `✓` implemented, `✗` missing, `~` partial, `?` misunderstood
146
+ - File:line references for implemented requirements
147
+ 8. Acquire lock → update tracker: your Agent Status row `active_changeset: CS-{N}`, `stage: verdict`, `last_heartbeat`, log entry → release lock
148
+
149
+ ## STAGE 2: VERDICT
150
+
151
+ 1. Based on the REVIEW findings, render a structured verdict:
152
+
153
+ **If spec-compliant (all requirements implemented correctly):**
154
+ - Record verdict as `PASS` in the tracker log
155
+ - Note any minor observations (style, naming) that do not affect compliance
156
+ - The changeset proceeds to quality review
157
+
158
+ **If spec issues found:**
159
+ - Record verdict as `ISSUES` in the tracker log
160
+ - For each issue, document:
161
+ - **Requirement:** What the spec says
162
+ - **Actual:** What the code does (with file:line reference)
163
+ - **Gap:** Specific description of the mismatch
164
+ - **Severity:** `blocking` (cannot pass without fix) or `observation` (noted but not blocking)
165
+
166
+ 2. **Update the changeset entry** — append a `### Spec Review Verdict` section to the changeset in `changesets.md`:
167
+
168
+ ```markdown
169
+ ### Spec Review Verdict
170
+
171
+ **Reviewer:** {{AGENT_NAME}}
172
+ **Verdict:** {PASS | ISSUES}
173
+
174
+ #### Findings
175
+ - {requirement → file:line — status and details}
176
+
177
+ #### Blocking Issues
178
+ - {issue description with file:line reference}
179
+
180
+ #### Observations
181
+ - {non-blocking notes}
182
+ ```
183
+
184
+ 3. **Mark done & advance:**
185
+ - Acquire lock
186
+ - Add changeset to `completed_changesets` list
187
+ - Check off changeset in Changesets Queue: `[x]`, set `{completed}`
188
+ - Update your Agent Status row: clear `active_changeset`
189
+ - Update `last_heartbeat`
190
+ - Log entry with verdict summary
191
+ - Release lock
192
+ 4. **Run changeset selection algorithm again:**
193
+ - Claimable changeset found → claim it, set `stage: review`, exit: `kill -INT $PPID`
194
+ - All changesets completed → `<promise>ALL SPEC REVIEWS COMPLETE</promise>`
195
+ - All blocked/claimed → log "waiting", exit: `kill -INT $PPID`
196
+
197
+ ---
198
+
199
+ ## First-Run Handling
200
+
201
+ If Changesets Queue in tracker is empty: read `changesets.md`, scan `## CS-{N}:` headers, populate queue with `{agent: -, status: pending}` metadata, then start.
202
+
203
+ ---
204
+
205
+ ## Decision Reporting Protocol
206
+
207
+ When you make a substantive decision a human reviewer would want to know about, report it to the dashboard:
208
+
209
+ **When to report:**
210
+ - Spec interpretation decisions (how you resolved ambiguous requirements)
211
+ - Severity classifications (why an issue is blocking vs. observation)
212
+ - Missing spec decisions (what you used as "requirements" when no formal spec exists)
213
+ - Scope boundary decisions (what counts as "extra work" vs. reasonable implementation detail)
214
+
215
+ **How to report:**
216
+ ```bash
217
+ 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":"CS-{N}","agent":"{{AGENT_NAME}}","decision":"{one-line summary}","reasoning":"{why this choice}"}'
218
+ ```
219
+
220
+ **Do NOT report** routine operations: claiming a changeset, updating heartbeat, stage transitions, waiting for blocked changesets. Only report substantive choices that affect the review verdict.
221
+
222
+ **Best-effort only:** If the dashboard is unreachable (curl fails), continue working normally. Decision reporting must never block or delay your work.
223
+
224
+ ---
225
+
226
+ ## Rules
227
+
228
+ - One changeset at a time per agent. Both stages run in one iteration, one `kill` at the end.
229
+ - Read tracker first, update tracker last. Always use lock protocol for writes.
230
+ - **NEVER trust commit messages or summaries. Read the actual code.** This is the cardinal rule of spec review.
231
+ - Compare implementation to requirements, not to your personal preferences. Spec review is about compliance, not style.
232
+ - File:line references are mandatory for every finding. Vague observations are worthless.
233
+ - Do not suggest fixes — that is the fix loop's job. Report what is wrong and where.
234
+ - **Multi-agent: never touch another agent's in_progress changeset. Coordinate via tracker.md.**
235
+
236
+ ---
237
+
238
+ Read `.ralph-flow/{{APP_NAME}}/01-spec-review-loop/tracker.md` now and begin.
@@ -0,0 +1,16 @@
1
+ # Spec Review Loop — Tracker
2
+
3
+ - completed_changesets: []
4
+
5
+ ## Agent Status
6
+
7
+ | agent | active_changeset | stage | last_heartbeat |
8
+ |-------|------------------|-------|----------------|
9
+
10
+ ---
11
+
12
+ ## Dependencies
13
+
14
+ ## Changesets Queue
15
+
16
+ ## Log
@@ -0,0 +1,3 @@
1
+ # Issues
2
+
3
+ <!-- Populated by the Quality Review Loop -->