@open-code-review/agents 1.5.0 → 1.6.0

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/README.md CHANGED
@@ -1,8 +1,34 @@
1
1
  # @open-code-review/agents
2
2
 
3
- The skill definitions, reviewer personas, and workflow references that power Open Code Review.
3
+ Skill definitions, reviewer personas, and workflow references that power [Open Code Review](https://github.com/spencermarx/open-code-review).
4
4
 
5
- > Browse review output and map artifacts in the [Dashboard](../dashboard/README.md) or through your AI assistant's slash commands.
5
+ ## Getting Started
6
+
7
+ All OCR workflows require the CLI for session state management. Install it first:
8
+
9
+ ```bash
10
+ # 1. Install the CLI
11
+ npm install -g @open-code-review/cli
12
+
13
+ # 2. Initialize in your project (copies these assets to .ocr/)
14
+ cd your-project
15
+ ocr init
16
+ ```
17
+
18
+ To update after a package upgrade:
19
+
20
+ ```bash
21
+ ocr update
22
+ ```
23
+
24
+ This updates skills and workflow references while **preserving your `.ocr/config.yaml`** and **all reviewer personas** (both default and custom).
25
+
26
+ ### Via Claude Code Plugin
27
+
28
+ ```bash
29
+ /plugin marketplace add spencermarx/open-code-review
30
+ /plugin install ocr@aclarify
31
+ ```
6
32
 
7
33
  ## What This Package Contains
8
34
 
@@ -17,64 +43,46 @@ agents/
17
43
  │ │ ├── discourse.md # Multi-agent debate rules
18
44
  │ │ ├── final-template.md # Final review template
19
45
  │ │ └── reviewers/ # Persona definitions (customizable)
20
- │ │ ├── principal.md # Architecture, design patterns
21
- │ │ ├── quality.md # Code style, best practices
22
- │ │ ├── security.md # Auth, data handling, vulnerabilities
23
- │ │ └── testing.md # Coverage, edge cases
46
+ │ │ ├── principal.md # Architecture, design patterns
47
+ │ │ ├── quality.md # Code style, best practices
48
+ │ │ ├── security.md # Auth, data handling, vulnerabilities
49
+ │ │ └── testing.md # Coverage, edge cases
24
50
  │ └── assets/
25
- │ ├── config.yaml # Default configuration
51
+ │ ├── config.yaml # Default configuration
26
52
  │ └── reviewer-template.md
27
- ├── commands/ # Slash command definitions
53
+ ├── commands/ # Slash command definitions
28
54
  │ ├── review.md
29
55
  │ ├── map.md
30
56
  │ ├── doctor.md
31
57
  │ ├── history.md
32
58
  │ ├── show.md
33
59
  │ ├── reviewers.md
34
- └── post.md
35
- └── .claude-plugin/ # Claude Code plugin manifest
60
+ ├── post.md
61
+ │ ├── address.md
62
+ │ └── translate-review-to-single-human.md
63
+ └── .claude-plugin/ # Claude Code plugin manifest
36
64
  └── plugin.json
37
65
  ```
38
66
 
39
- ## Prerequisites
40
-
41
- All OCR workflows require the CLI for session state management. Before running any review or map command, ensure the CLI is installed:
42
-
43
- ```bash
44
- npm install -g @open-code-review/cli
45
- ocr init
46
- ```
47
-
48
- The CLI provides the `ocr state` commands that track workflow progress through each phase. Without it, reviews will fail at phase transitions.
49
-
50
- ## Installation
51
-
52
- ### Via CLI (Recommended)
53
-
54
- The CLI copies these assets to your project's `.ocr/` directory:
55
-
56
- ```bash
57
- npx @open-code-review/cli init
58
- ```
59
-
60
- To update after a package upgrade:
61
-
62
- ```bash
63
- ocr update
64
- ```
65
-
66
- This updates skills and workflow references while **preserving your `.ocr/config.yaml`** and **all reviewer personas** (both default and custom).
67
+ ## Commands
67
68
 
68
- ### Via Claude Code Plugin
69
+ | File | Windsurf | Claude Code / Cursor |
70
+ |------|----------|----------------------|
71
+ | `review.md` | `/ocr-review` | `/ocr:review` |
72
+ | `map.md` | `/ocr-map` | `/ocr:map` |
73
+ | `post.md` | `/ocr-post` | `/ocr:post` |
74
+ | `doctor.md` | `/ocr-doctor` | `/ocr:doctor` |
75
+ | `reviewers.md` | `/ocr-reviewers` | `/ocr:reviewers` |
76
+ | `history.md` | `/ocr-history` | `/ocr:history` |
77
+ | `show.md` | `/ocr-show` | `/ocr:show` |
78
+ | `address.md` | `/ocr-address` | `/ocr:address` |
79
+ | `translate-review-to-single-human.md` | `/ocr-translate-review-to-single-human` | `/ocr:translate-review-to-single-human` |
69
80
 
70
- ```bash
71
- /plugin marketplace add spencermarx/open-code-review
72
- /plugin install ocr@aclarify
73
- ```
81
+ **Why two formats?** Windsurf requires flat command files with a prefix (`/ocr-command`), while Claude Code and Cursor support subdirectories (`/ocr:command`). Both invoke the same underlying functionality.
74
82
 
75
83
  ## Skill Architecture
76
84
 
77
- The `SKILL.md` file defines the **Tech Lead** role—the orchestrator that:
85
+ The `SKILL.md` file defines the **Tech Lead** role the orchestrator that:
78
86
 
79
87
  1. Discovers project context (config, OpenSpec, reference files)
80
88
  2. Analyzes changes and identifies risk areas
@@ -82,62 +90,47 @@ The `SKILL.md` file defines the **Tech Lead** role—the orchestrator that:
82
90
  4. Facilitates discourse between reviewers
83
91
  5. Synthesizes findings into a unified review
84
92
 
85
- Each reviewer in `references/reviewers/` is a specialized persona. You can customize the built-in reviewers or add your own.
93
+ ### Reviewer Personas
94
+
95
+ **Built-in** (customizable):
96
+ - **Principal** — Architecture, design patterns, holistic review
97
+ - **Quality** — Code style, readability, best practices
98
+ - **Security** — Authentication, data handling, vulnerabilities
99
+ - **Testing** — Coverage, edge cases, test strategy
100
+
101
+ **Custom**: Create your own by adding files to `.ocr/skills/references/reviewers/`. See the [reviewer template](skills/ocr/assets/reviewer-template.md).
86
102
 
87
103
  ### Map Agent Personas
88
104
 
89
- The `/ocr:map` command uses a separate set of specialized agents defined in `references/map-personas/`:
105
+ The `/ocr:map` command uses specialized agents:
90
106
 
91
107
  | Persona | Role |
92
108
  |---------|------|
93
- | **Map Architect** | Analyzes change topology, determines optimal section groupings and review ordering |
109
+ | **Map Architect** | Analyzes change topology, determines section groupings and review ordering |
94
110
  | **Flow Analyst** | Traces upstream/downstream dependencies, groups related changes by data and control flow |
95
- | **Requirements Mapper** | Maps changes to requirements/specs when provided, identifies coverage gaps |
111
+ | **Requirements Mapper** | Maps changes to requirements/specs, identifies coverage gaps |
96
112
 
97
- These agents run with configurable redundancy (default: 2) to increase confidence in groupings. See `.ocr/config.yaml` → `code-review-map.agents` for tuning.
113
+ These run with configurable redundancy (default: 2). See `.ocr/config.yaml` → `code-review-map.agents`.
98
114
 
99
115
  ## Session Structure
100
116
 
101
- OCR uses a **round-first architecture** for session storage:
102
-
103
117
  ```
104
118
  .ocr/sessions/{YYYY-MM-DD}-{branch}/
105
- ├── discovered-standards.md # Project context (shared across rounds)
106
- ├── context.md # Change analysis (shared)
119
+ ├── discovered-standards.md # Project context (shared across rounds)
120
+ ├── context.md # Change analysis (shared)
107
121
  └── rounds/
108
122
  ├── round-1/
109
- │ ├── reviews/ # Individual reviewer outputs
110
- │ ├── discourse.md # Cross-reviewer discussion
111
- │ └── final.md # Synthesized review
112
- └── round-2/ # Created on re-review
113
- └── ...
123
+ │ ├── reviews/ # Individual reviewer outputs
124
+ │ ├── discourse.md # Cross-reviewer discussion
125
+ │ └── final.md # Synthesized review
126
+ └── round-2/ # Created on re-review
114
127
  ├── maps/
115
- ├── run-1/
116
- ├── map.md # Code Review Map output
117
- └── flow-analysis.md # Dependency graph (Mermaid)
118
- │ └── run-2/ # Created on re-map
119
- │ └── ...
128
+ └── run-1/
129
+ ├── map.md # Code Review Map
130
+ └── flow-analysis.md # Dependency graph (Mermaid)
120
131
  ```
121
132
 
122
- **Multi-round reviews**: Running `/ocr-review` again on an existing session creates a new round (`round-2/`, `round-3/`, etc.) if the previous round is complete. This enables iterative "review fix → re-review" workflows while preserving history.
123
-
124
- **Map runs**: Running `/ocr-map` creates map artifacts in `maps/run-{n}/`. Like review rounds, subsequent runs create new directories without modifying previous ones.
125
-
126
- See `references/session-files.md` for the complete file manifest.
127
-
128
- ## Commands
129
-
130
- | File | Windsurf | Claude Code / Cursor |
131
- |------|----------|----------------------|
132
- | `review.md` | `/ocr-review` | `/ocr:review` |
133
- | `map.md` | `/ocr-map` | `/ocr:map` |
134
- | `doctor.md` | `/ocr-doctor` | `/ocr:doctor` |
135
- | `reviewers.md` | `/ocr-reviewers` | `/ocr:reviewers` |
136
- | `history.md` | `/ocr-history` | `/ocr:history` |
137
- | `show.md` | `/ocr-show` | `/ocr:show` |
138
- | `post.md` | `/ocr-post` | `/ocr:post` |
139
-
140
- **Why two formats?** Windsurf requires flat command files with a prefix (`/ocr-command`), while Claude Code and Cursor support subdirectories (`/ocr:command`). Both invoke the same underlying functionality.
133
+ Running `/ocr-review` again on an existing session creates a new round if the previous round is complete. See `references/session-files.md` for the complete file manifest.
141
134
 
142
135
  ## License
143
136
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-code-review/agents",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "AI-native skills, commands, and reviewer personas for Open Code Review",
5
5
  "type": "module",
6
6
  "files": [
@@ -1,12 +1,6 @@
1
- # OCR Session Directory .gitignore
2
- # Copy this to .ocr/.gitignore to exclude review sessions from git
3
-
4
- # Exclude all session data by default
1
+ # OCR:START managed by open-code-review (do not edit this block)
5
2
  sessions/
6
-
7
- # Or selectively include/exclude:
8
- # sessions/*
9
- # !sessions/important-review/
10
-
11
- # Keep the directory structure
12
- !.gitignore
3
+ data/
4
+ *.db-shm
5
+ *.db-wal
6
+ # OCR:END
@@ -23,7 +23,8 @@ This synthesis process is designed to mirror how high-performing engineering tea
23
23
 
24
24
  - **Preserve all feedback** — Every finding from every reviewer appears, attributed
25
25
  - **Identify blockers** — Surface anything that should prevent merge
26
- - **Present suggestions** — Non-blocking improvements for author consideration
26
+ - **Categorize should-fix items** — Issues that aren't blocking but should be addressed
27
+ - **Present suggestions** — Lower-priority improvements for author consideration
27
28
  - **Assess requirements** — Evaluate against provided requirements (if any)
28
29
  - **Recommend action** — Clear verdict with rationale
29
30
 
@@ -53,11 +54,49 @@ A finding is a **blocker** if ANY of the following are true:
53
54
 
54
55
  **Any single reviewer can flag a blocker.** This is not subject to consensus—one engineer seeing a security hole is sufficient to block.
55
56
 
56
- ### Step 3: Collect Suggestions
57
+ ### Step 3: Categorize Non-Blocking Findings
57
58
 
58
- All non-blocking feedback is preserved and attributed:
59
+ All non-blocking feedback is categorized into **Should Fix** or **Suggestions**, then preserved and attributed.
60
+
61
+ **Should Fix** — Issues that aren't blocking but should be addressed before or shortly after merge:
62
+
63
+ | Should Fix Criteria | Examples |
64
+ |---------------------|----------|
65
+ | **Code quality issues** | Missing error handling, dead code, untested critical paths |
66
+ | **Potential bugs** | Silent fallthrough, unvalidated input at boundaries, race conditions (non-data-loss) |
67
+ | **Important refactors** | DRY violations with real maintenance cost, tight coupling between modules |
68
+ | **Missing validation** | Input boundaries not enforced, missing null checks on external data |
69
+ | **Functional gaps** | Feature partially implemented, edge case not handled |
70
+
71
+ **Suggestions** — Low-priority improvements for author consideration:
72
+
73
+ | Suggestion Criteria | Examples |
74
+ |---------------------|----------|
75
+ | **Style preferences** | Naming, formatting, early returns vs nested ifs |
76
+ | **Minor refactors** | Extract small helper, reorder parameters, simplify expression |
77
+ | **Documentation** | Add JSDoc, clarify comment, update README |
78
+ | **Testing ideas** | Additional edge cases, snapshot tests, performance benchmarks |
79
+ | **Informational** | Alternative approaches, FYI notes, future considerations |
59
80
 
60
81
  ```markdown
82
+ ## Should Fix
83
+
84
+ ### 1. {Title}
85
+
86
+ **Flagged by**: @principal-1, @quality-1
87
+ **Location**: `path/to/file.ts:42-50`
88
+
89
+ {Description of the issue and why it should be fixed.}
90
+
91
+ ### 2. {Title}
92
+
93
+ **Flagged by**: @quality-2
94
+ **Location**: `path/to/other-file.ts:15`
95
+
96
+ {Description.}
97
+
98
+ ---
99
+
61
100
  ## Suggestions
62
101
 
63
102
  ### Code Quality
@@ -74,7 +113,7 @@ All non-blocking feedback is preserved and attributed:
74
113
  - "Edge case for empty input not covered" — @testing-1
75
114
  ```
76
115
 
77
- **No suggestion is lost.** Even if only one reviewer mentions something, it surfaces.
116
+ **No feedback is lost.** Even if only one reviewer mentions something, it surfaces.
78
117
 
79
118
  ### Step 4: Note Consensus and Dissent
80
119
 
@@ -200,15 +239,35 @@ The Tech Lead determines the verdict based on simple rules:
200
239
 
201
240
  ---
202
241
 
242
+ ## Should Fix
243
+
244
+ {Issues that aren't blocking but should be addressed. Use numbered sub-headings.}
245
+
246
+ ### 1. {Title}
247
+
248
+ **Flagged by**: @principal-1, @quality-1
249
+ **Location**: `path/to/file.ts:42-50`
250
+
251
+ {Description and why it should be fixed.}
252
+
253
+ ### 2. {Title}
254
+
255
+ **Flagged by**: @quality-2
256
+ **Location**: `path/to/other-file.ts:15`
257
+
258
+ {Description.}
259
+
260
+ ---
261
+
203
262
  ## Suggestions
204
263
 
205
- {All non-blocking feedback, preserved and attributed}
264
+ {Lower-priority improvements and informational feedback, preserved and attributed.}
206
265
 
207
266
  ### Code Quality
208
267
  - "Consider extracting the validation logic into a separate function" — @principal-1
209
268
  - "The error messages could be more user-friendly" — @quality-1
210
269
 
211
- ### Performance
270
+ ### Performance
212
271
  - "This query could benefit from an index on `user_id`" — @principal-2
213
272
 
214
273
  ### Testing
@@ -271,12 +330,12 @@ The Tech Lead determines the verdict based on simple rules:
271
330
 
272
331
  Full reviews available in session directory:
273
332
 
274
- | Reviewer | Blockers | Suggestions | File |
275
- |----------|----------|-------------|------|
276
- | @principal-1 | 0 | 3 | `rounds/round-{n}/reviews/principal-1.md` |
277
- | @principal-2 | 0 | 2 | `rounds/round-{n}/reviews/principal-2.md` |
278
- | @quality-1 | 0 | 4 | `rounds/round-{n}/reviews/quality-1.md` |
279
- | @security-1 | 1 | 2 | `rounds/round-{n}/reviews/security-1.md` |
333
+ | Reviewer | Blockers | Should Fix | Suggestions | File |
334
+ |----------|----------|------------|-------------|------|
335
+ | @principal-1 | 0 | 1 | 3 | `rounds/round-{n}/reviews/principal-1.md` |
336
+ | @principal-2 | 0 | 0 | 2 | `rounds/round-{n}/reviews/principal-2.md` |
337
+ | @quality-1 | 0 | 1 | 4 | `rounds/round-{n}/reviews/quality-1.md` |
338
+ | @security-1 | 1 | 0 | 2 | `rounds/round-{n}/reviews/security-1.md` |
280
339
 
281
340
  **Session**: `.ocr/sessions/{session-id}/`
282
341
  **Discourse**: `rounds/round-{n}/discourse.md`
@@ -405,10 +405,49 @@ See `references/map-personas/flow-analyst.md` for persona details.
405
405
  [ "$EXPECTED" -ne "$MAPPED" ] && echo "ERROR: Missing files!"
406
406
  ```
407
407
 
408
- 11. **Save final map**:
408
+ 11. **Pipe structured map data to CLI**:
409
+
410
+ Construct a JSON object with the map's structured data and pipe it to the CLI. The CLI validates, writes `map-meta.json`, and records a `map_completed` orchestration event — all in one command.
411
+
412
+ ```bash
413
+ cat <<'JSON' | ocr state map-complete --stdin
414
+ {
415
+ "schema_version": 1,
416
+ "sections": [
417
+ {
418
+ "section_number": 1,
419
+ "title": "Section Title",
420
+ "description": "Section description",
421
+ "files": [
422
+ {
423
+ "file_path": "src/example.ts",
424
+ "role": "Entry point",
425
+ "lines_added": 10,
426
+ "lines_deleted": 2
427
+ }
428
+ ]
429
+ }
430
+ ],
431
+ "dependencies": [
432
+ {
433
+ "from_section": 2,
434
+ "from_title": "Tests",
435
+ "to_section": 1,
436
+ "to_title": "Core Logic",
437
+ "relationship": "tests"
438
+ }
439
+ ]
440
+ }
441
+ JSON
442
+ ```
443
+
444
+ > The CLI validates the JSON schema, writes `map-meta.json` to the correct run directory, and records the event in SQLite. The orchestrator MUST NOT write `map-meta.json` directly.
445
+
446
+ 12. **Save final map** (presentation artifact):
409
447
  ```
410
448
  .ocr/sessions/{id}/map/runs/run-{n}/map.md
411
449
  ```
450
+ > `map.md` is the human-readable presentation artifact. The dashboard uses `map-meta.json` for structured data; `map.md` is stored as raw markdown for display and chat context.
412
451
 
413
452
  ### Map Output Format
414
453
 
@@ -426,6 +465,7 @@ See `references/map-template.md` for the complete template.
426
465
  - [ ] Section Dependencies table generated
427
466
  - [ ] File Index complete
428
467
  - [ ] Completeness validated (all files appear in tables)
468
+ - [ ] `map-meta.json` piped to CLI via `ocr state map-complete --stdin`
429
469
  - [ ] `map.md` written
430
470
  - [ ] `ocr state transition` called with `--phase "synthesis"`
431
471
 
@@ -17,7 +17,8 @@ Every OCR session creates files in `.ocr/sessions/{session-id}/`:
17
17
  │ │ ├── topology.md # File categorization and sections
18
18
  │ │ ├── flow-analysis.md # Dependency tracing results
19
19
  │ │ ├── requirements-mapping.md # Coverage matrix (if requirements)
20
- │ │ └── map.md # Final map output
20
+ │ │ ├── map-meta.json # Structured map data (written by CLI via map-complete --stdin)
21
+ │ │ └── map.md # Final map output (presentation artifact)
21
22
  │ └── run-2/ # Subsequent runs (created on re-map)
22
23
  │ └── ... # Same structure as run-1
23
24
  └── rounds/ # All round-specific artifacts
@@ -31,11 +32,13 @@ Every OCR session creates files in `.ocr/sessions/{session-id}/`:
31
32
  │ │ ├── testing-1.md # (if testing reviewer assigned)
32
33
  │ │ └── {type}-{n}.md # (additional assigned custom reviewers)
33
34
  │ ├── discourse.md # Cross-reviewer discussion for round 1
35
+ │ ├── round-meta.json # Structured review data (written by CLI via round-complete --stdin)
34
36
  │ └── final.md # Synthesized final review for round 1
35
37
  └── round-2/ # Subsequent rounds (created on re-review)
36
38
  ├── reviews/
37
39
  │ └── ... # Same structure as round-1
38
40
  ├── discourse.md
41
+ ├── round-meta.json
39
42
  └── final.md
40
43
  ```
41
44
 
@@ -80,7 +83,8 @@ OCR uses a **run-based architecture** for maps, parallel to review rounds.
80
83
  | `topology.md` | 2 | File categorization and section groupings |
81
84
  | `flow-analysis.md` | 3 | Upstream/downstream dependency tracing |
82
85
  | `requirements-mapping.md` | 4 | Requirements coverage matrix (if requirements provided) |
83
- | `map.md` | 5 | Final synthesized Code Review Map |
86
+ | `map-meta.json` | 5 | Structured map data (written by CLI via `map-complete --stdin`) |
87
+ | `map.md` | 5 | Final synthesized Code Review Map (presentation artifact) |
84
88
 
85
89
  **When to use multiple runs**:
86
90
  - Changeset has evolved since last map
@@ -97,6 +101,7 @@ OCR uses a **run-based architecture** for maps, parallel to review rounds.
97
101
  | `context.md` | 2 | Change summary, diff analysis, Tech Lead guidance | All reviewers |
98
102
  | `rounds/round-{n}/reviews/{type}-{n}.md` | 4 | Individual reviewer outputs | Discourse, Synthesis |
99
103
  | `rounds/round-{n}/discourse.md` | 6 | Cross-reviewer discussion results | Synthesis |
104
+ | `rounds/round-{n}/round-meta.json` | 7 | Structured review data (written by CLI via `round-complete --stdin`) | Dashboard |
100
105
  | `rounds/round-{n}/final.md` | 7 | Synthesized final review | Show, Post commands |
101
106
 
102
107
  ### Optional Files
@@ -139,7 +144,7 @@ rounds/round-1/reviews/performance-1.md # Custom reviewer
139
144
  | 4 | Parallel Reviews | `rounds/round-{n}/reviews/{type}-{n}.md` for each reviewer, call `ocr state transition` |
140
145
  | 5 | Aggregation | (Inline analysis), call `ocr state transition` |
141
146
  | 6 | Discourse | `rounds/round-{n}/discourse.md`, call `ocr state transition` |
142
- | 7 | Synthesis | `rounds/round-{n}/final.md`, call `ocr state transition` |
147
+ | 7 | Synthesis | Pipe data to `ocr state round-complete --stdin` (writes `round-meta.json`), write `final.md` |
143
148
  | 8 | Presentation | Call `ocr state close` |
144
149
 
145
150
  ## State Transitions and File Validation
@@ -153,7 +158,7 @@ When calling `ocr state transition`, verify the corresponding file exists:
153
158
  | `"analysis"` | `context.md` (with Tech Lead guidance) |
154
159
  | `"reviews"` | At least 2 files in `rounds/round-{current_round}/reviews/` |
155
160
  | `"discourse"` | `rounds/round-{current_round}/discourse.md` |
156
- | `"synthesis"` | `rounds/round-{current_round}/final.md` |
161
+ | `"synthesis"` | `rounds/round-{current_round}/round-meta.json`, `rounds/round-{current_round}/final.md` |
157
162
 
158
163
  ## Session ID Format
159
164
 
@@ -141,6 +141,79 @@ ocr state show
141
141
 
142
142
  Outputs the current session state from SQLite. Use this to inspect current session state.
143
143
 
144
+ ### `ocr state round-complete` — Sync structured round metrics
145
+
146
+ **Recommended: pipe structured data from stdin** (CLI writes the file + event):
147
+
148
+ ```bash
149
+ cat <<'JSON' | ocr state round-complete --stdin
150
+ { "schema_version": 1, "verdict": "APPROVE", "reviewers": [...] }
151
+ JSON
152
+ ```
153
+
154
+ The `--stdin` flag makes the CLI the **sole writer** of `round-meta.json`. The CLI:
155
+ 1. Validates the JSON schema
156
+ 2. Writes `round-meta.json` to the correct session round directory
157
+ 3. Derives counts from the findings array (never trusts self-reported counts)
158
+ 4. Records a `round_completed` orchestration event in SQLite
159
+
160
+ The dashboard picks this up via `DbSyncWatcher` for real-time updates.
161
+
162
+ **Alternative: read from existing file** (for manual use or debugging):
163
+
164
+ ```bash
165
+ ocr state round-complete --file "rounds/round-1/round-meta.json"
166
+ ```
167
+
168
+ Optional flags (both modes):
169
+ ```bash
170
+ --session-id "{session-id}" # Auto-detects active session if omitted
171
+ --round 1 # Auto-detects current round if omitted
172
+ ```
173
+
174
+ ### `ocr state map-complete` — Sync structured map metrics
175
+
176
+ **Recommended: pipe structured data from stdin** (CLI writes the file + event):
177
+
178
+ ```bash
179
+ cat <<'JSON' | ocr state map-complete --stdin
180
+ {
181
+ "schema_version": 1,
182
+ "sections": [
183
+ {
184
+ "section_number": 1,
185
+ "title": "Core Logic",
186
+ "description": "Main business logic",
187
+ "files": [
188
+ { "file_path": "src/index.ts", "role": "Entry point", "lines_added": 10, "lines_deleted": 2 }
189
+ ]
190
+ }
191
+ ],
192
+ "dependencies": []
193
+ }
194
+ JSON
195
+ ```
196
+
197
+ The `--stdin` flag makes the CLI the **sole writer** of `map-meta.json`. The CLI:
198
+ 1. Validates the JSON schema
199
+ 2. Writes `map-meta.json` to the correct session map run directory
200
+ 3. Derives counts from the sections array (never trusts self-reported counts)
201
+ 4. Records a `map_completed` orchestration event in SQLite
202
+
203
+ The dashboard picks this up via `DbSyncWatcher` for real-time updates.
204
+
205
+ **Alternative: read from existing file** (for manual use or debugging):
206
+
207
+ ```bash
208
+ ocr state map-complete --file "map/runs/run-1/map-meta.json"
209
+ ```
210
+
211
+ Optional flags (both modes):
212
+ ```bash
213
+ --session-id "{session-id}" # Auto-detects active session if omitted
214
+ --map-run 1 # Auto-detects current map run if omitted
215
+ ```
216
+
144
217
  ### `ocr state sync` — Rebuild from filesystem
145
218
 
146
219
  ```bash
@@ -129,7 +129,7 @@ Before proceeding to each phase, verify the required artifacts exist:
129
129
  | 4 | `context.md` exists | `rounds/round-{n}/reviews/{type}-{n}.md` for each reviewer; call `ocr state transition` |
130
130
  | 5 | ≥2 files in `rounds/round-{n}/reviews/` | Aggregated findings (inline); call `ocr state transition` |
131
131
  | 6 | Reviews complete | `rounds/round-{n}/discourse.md`; call `ocr state transition` |
132
- | 7 | `rounds/round-{n}/discourse.md` exists | `rounds/round-{n}/final.md`; call `ocr state transition` |
132
+ | 7 | `rounds/round-{n}/discourse.md` exists | `rounds/round-{n}/round-meta.json`, `rounds/round-{n}/final.md`; call `ocr state round-complete` |
133
133
  | 8 | `rounds/round-{n}/final.md` exists | Present to user; call `ocr state close` |
134
134
 
135
135
  **NEVER skip directly to `final.md`** — this breaks progress tracking.
@@ -592,11 +592,11 @@ See `references/discourse.md` for detailed instructions.
592
592
  - Challenged and defended: +1
593
593
  - Challenged and undefended: -1
594
594
 
595
- 4. Categorize findings:
596
- - **Must Fix**: Critical issues, security vulnerabilities
597
- - **Should Fix**: Important improvements
598
- - **Consider**: Nice-to-haves, style suggestions
599
- - **What's Working Well**: Positive feedback
595
+ 4. Categorize findings into three sections (see `references/final-template.md` for criteria):
596
+ - **Blockers**: Security vulnerabilities, data integrity risks, correctness bugs, breaking changes — must resolve before merge
597
+ - **Should Fix**: Code quality issues, potential bugs, missing validation, important refactors — address before or shortly after merge
598
+ - **Suggestions**: Style preferences, minor refactors, documentation, testing ideas — author's discretion
599
+ - **What's Working Well**: Positive feedback (separate encouragement section, not counted)
600
600
 
601
601
  5. **If requirements were provided**, include Requirements Assessment:
602
602
  - Which requirements are fully met?
@@ -612,7 +612,57 @@ See `references/discourse.md` for detailed instructions.
612
612
 
613
613
  These go in a prominent "Clarifying Questions" section for stakeholder response.
614
614
 
615
- 7. **Write the final review file**:
615
+ 7. **Pipe structured round data to the CLI (BEFORE `final.md`)**:
616
+
617
+ > The CLI is the **sole writer** of `round-meta.json`. The orchestrator constructs JSON in memory and pipes it to the CLI, which validates the schema, writes the file to the correct session path, and records a `round_completed` orchestration event — all in one command.
618
+
619
+ Construct the JSON from synthesis knowledge, then pipe to the CLI:
620
+
621
+ ```bash
622
+ cat <<'JSON' | ocr state round-complete --stdin
623
+ {
624
+ "schema_version": 1,
625
+ "verdict": "REQUEST CHANGES",
626
+ "reviewers": [
627
+ {
628
+ "type": "principal",
629
+ "instance": 1,
630
+ "severity_high": 1,
631
+ "severity_medium": 4,
632
+ "severity_low": 2,
633
+ "severity_info": 0,
634
+ "findings": [
635
+ {
636
+ "title": "SQL Injection in query builder",
637
+ "category": "blocker",
638
+ "severity": "high",
639
+ "file_path": "src/db/query.ts",
640
+ "line_start": 42,
641
+ "line_end": 45,
642
+ "summary": "User input passed directly to raw SQL...",
643
+ "flagged_by": ["@principal-1", "@security-1"]
644
+ }
645
+ ]
646
+ }
647
+ ]
648
+ }
649
+ JSON
650
+ ```
651
+
652
+ The CLI will:
653
+ 1. Validate the JSON schema (schema_version, verdict, reviewers, findings)
654
+ 2. Write `round-meta.json` to `{session_dir}/rounds/round-{n}/round-meta.json`
655
+ 3. Compute derived counts from the findings array (never self-reported)
656
+ 4. Record a `round_completed` orchestration event in SQLite
657
+
658
+ **Finding categories**: `"blocker"` | `"should_fix"` | `"suggestion"` | `"style"`
659
+ **Finding severity**: `"critical"` | `"high"` | `"medium"` | `"low"` | `"info"`
660
+
661
+ Optional flags: `--session-id <id>` (auto-detects active session), `--round <number>` (auto-detects current round).
662
+
663
+ > **Do NOT write `round-meta.json` directly** — always pipe through the CLI so the schema is validated and the event is recorded atomically.
664
+
665
+ 8. **Write the final review file**:
616
666
  ```bash
617
667
  # OUTPUT FILE - must be exactly this path:
618
668
  FINAL_FILE="$SESSION_DIR/rounds/round-$CURRENT_ROUND/final.md"
@@ -620,7 +670,7 @@ See `references/discourse.md` for detailed instructions.
620
670
 
621
671
  Save synthesized review to `$FINAL_FILE`.
622
672
 
623
- See `references/final-template.md` for the template format.
673
+ See `references/final-template.md` for the template format.
624
674
 
625
675
  ### Phase 7 Checkpoint — MANDATORY VALIDATION
626
676
 
@@ -630,9 +680,18 @@ See `references/final-template.md` for the template format.
630
680
  # Set these based on your current session
631
681
  SESSION_DIR=".ocr/sessions/$(ls -1t .ocr/sessions/ | head -1)"
632
682
  CURRENT_ROUND=$(ls -1d "$SESSION_DIR/rounds/round-"* 2>/dev/null | wc -l | tr -d ' ')
683
+ ROUND_META="$SESSION_DIR/rounds/round-$CURRENT_ROUND/round-meta.json"
633
684
  FINAL_FILE="$SESSION_DIR/rounds/round-$CURRENT_ROUND/final.md"
634
685
 
635
- # Check file exists
686
+ # Check round-meta.json exists
687
+ if [ -f "$ROUND_META" ]; then
688
+ echo "OK round-meta.json exists at $ROUND_META"
689
+ else
690
+ echo "FAIL round-meta.json not found at $ROUND_META"
691
+ exit 1
692
+ fi
693
+
694
+ # Check final.md exists
636
695
  if [ -f "$FINAL_FILE" ]; then
637
696
  echo "OK final.md exists at $FINAL_FILE"
638
697
  else
@@ -650,8 +709,9 @@ fi
650
709
  ```
651
710
 
652
711
  **STOP and verify before proceeding:**
712
+ - [ ] `rounds/round-{n}/round-meta.json` exists with valid structured data
653
713
  - [ ] `rounds/round-{n}/final.md` exists
654
- - [ ] Contains prioritized findings (Must Fix, Should Fix, Consider)
714
+ - [ ] Contains categorized findings (Blockers, Should Fix, Suggestions)
655
715
  - [ ] Contains Clarifying Questions section (if any)
656
716
  - [ ] If requirements provided: Contains Requirements Assessment
657
717
 
@@ -670,9 +730,9 @@ fi
670
730
  # Code Review: {branch}
671
731
 
672
732
  ## Summary
673
- {X} must-fix, {Y} should-fix, {Z} suggestions
733
+ {X} blockers, {Y} should-fix, {Z} suggestions
674
734
 
675
- ## Must Fix
735
+ ## Blockers
676
736
  ...
677
737
 
678
738
  ## Should Fix
@@ -713,5 +773,5 @@ fi
713
773
  | 4 | Spawn reviewer tasks, `ocr state transition` | `rounds/round-{n}/reviews/*.md` |
714
774
  | 5 | Compare redundant runs, `ocr state transition` | aggregated findings |
715
775
  | 6 | Reviewer discourse, `ocr state transition` | `rounds/round-{n}/discourse.md` |
716
- | 7 | Synthesize and prioritize, `ocr state transition` | `rounds/round-{n}/final.md` |
776
+ | 7 | Synthesize, pipe data to `ocr state round-complete --stdin`, write `final.md` | `rounds/round-{n}/round-meta.json` (CLI-written), `rounds/round-{n}/final.md` |
717
777
  | 8 | Display/post, `ocr state close` | Terminal output, GitHub |