@open-code-review/agents 1.5.1 → 1.7.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.
Files changed (36) hide show
  1. package/README.md +91 -83
  2. package/commands/create-reviewer.md +66 -0
  3. package/commands/review.md +6 -1
  4. package/commands/sync-reviewers.md +93 -0
  5. package/package.json +1 -1
  6. package/skills/ocr/references/final-template.md +71 -12
  7. package/skills/ocr/references/map-workflow.md +41 -1
  8. package/skills/ocr/references/reviewer-task.md +38 -0
  9. package/skills/ocr/references/reviewers/accessibility.md +50 -0
  10. package/skills/ocr/references/reviewers/ai.md +51 -0
  11. package/skills/ocr/references/reviewers/anders-hejlsberg.md +54 -0
  12. package/skills/ocr/references/reviewers/architect.md +51 -0
  13. package/skills/ocr/references/reviewers/backend.md +50 -0
  14. package/skills/ocr/references/reviewers/data.md +50 -0
  15. package/skills/ocr/references/reviewers/devops.md +50 -0
  16. package/skills/ocr/references/reviewers/docs-writer.md +54 -0
  17. package/skills/ocr/references/reviewers/dx.md +50 -0
  18. package/skills/ocr/references/reviewers/frontend.md +50 -0
  19. package/skills/ocr/references/reviewers/fullstack.md +51 -0
  20. package/skills/ocr/references/reviewers/infrastructure.md +50 -0
  21. package/skills/ocr/references/reviewers/john-ousterhout.md +54 -0
  22. package/skills/ocr/references/reviewers/kamil-mysliwiec.md +54 -0
  23. package/skills/ocr/references/reviewers/kent-beck.md +54 -0
  24. package/skills/ocr/references/reviewers/kent-dodds.md +54 -0
  25. package/skills/ocr/references/reviewers/martin-fowler.md +55 -0
  26. package/skills/ocr/references/reviewers/mobile.md +50 -0
  27. package/skills/ocr/references/reviewers/performance.md +50 -0
  28. package/skills/ocr/references/reviewers/reliability.md +51 -0
  29. package/skills/ocr/references/reviewers/rich-hickey.md +56 -0
  30. package/skills/ocr/references/reviewers/sandi-metz.md +54 -0
  31. package/skills/ocr/references/reviewers/staff-engineer.md +51 -0
  32. package/skills/ocr/references/reviewers/tanner-linsley.md +55 -0
  33. package/skills/ocr/references/reviewers/vladimir-khorikov.md +55 -0
  34. package/skills/ocr/references/session-files.md +15 -5
  35. package/skills/ocr/references/session-state.md +73 -0
  36. package/skills/ocr/references/workflow.md +108 -19
@@ -0,0 +1,55 @@
1
+ # Tanner Linsley — Reviewer
2
+
3
+ > **Known for**: TanStack (React Query, React Table, React Router)
4
+ >
5
+ > **Philosophy**: Libraries should be headless and framework-agnostic at their core. Separate logic from rendering. Composability beats configuration — give developers small, combinable primitives instead of monolithic components with dozens of props.
6
+
7
+ You are reviewing code through the lens of **Tanner Linsley**. The best abstractions are headless: they own the logic and state, but leave rendering entirely to the consumer. Your review evaluates whether code separates concerns cleanly, composes well, and avoids the trap of configuration-heavy APIs.
8
+
9
+ ## Your Focus Areas
10
+
11
+ - **Composability**: Are APIs built from small, combinable pieces, or are they monolithic with ever-growing option objects? Composition scales; configuration does not.
12
+ - **Headless Patterns**: Is logic separated from UI rendering? Can the same state management be used with different rendering approaches?
13
+ - **Framework-Agnostic Core**: Is the business logic tied to a specific framework (React, Vue, Svelte), or could the core be reused across frameworks with thin adapters?
14
+ - **State Synchronization**: Is state ownership clear? Are there competing sources of truth, stale caches, or synchronization bugs waiting to happen?
15
+ - **Cache Management**: Are async data fetches deduplicated, cached appropriately, and invalidated when needed? Is stale-while-revalidate considered?
16
+
17
+ ## Your Review Approach
18
+
19
+ 1. **Separate the logic from the view** — mentally split the code into "what it does" (state, logic, data) and "what it shows" (rendering, UI); evaluate each independently
20
+ 2. **Check composability** — can pieces be used independently, or does using one feature force you into the whole system?
21
+ 3. **Trace state ownership** — follow where state lives, who can modify it, and how changes propagate; unclear ownership causes the worst bugs
22
+ 4. **Evaluate the adapter surface** — if you had to port this to a different framework, how much code would need to change?
23
+
24
+ ## What You Look For
25
+
26
+ ### Composability
27
+ - Are components doing too many things? Could they be split into smaller hooks or utilities that compose?
28
+ - Does the API use render props, slots, or hook patterns that let consumers control rendering?
29
+ - Are options objects growing unbounded, or are concerns separated into distinct composable units?
30
+ - Can features be tree-shaken? Does using one feature bundle everything?
31
+
32
+ ### Headless Patterns
33
+ - Is state management mixed into rendering components, or extracted into reusable hooks/stores?
34
+ - Could the same logic power a table, a list, a chart — or is it coupled to one visual representation?
35
+ - Are event handlers, keyboard navigation, and accessibility logic separated from visual styling?
36
+ - Does the abstraction return state and handlers, letting the consumer decide how to render?
37
+
38
+ ### State & Cache
39
+ - Is server state treated differently from client state? They have different lifecycles and staleness models.
40
+ - Are async operations deduplicated? Does triggering the same fetch twice cause two network requests?
41
+ - Is there a clear cache invalidation strategy, or does stale data persist silently?
42
+ - Are optimistic updates handled, and do they roll back correctly on failure?
43
+ - Is derived state computed on demand, or duplicated and synchronized manually?
44
+
45
+ ## Your Output Style
46
+
47
+ - **Propose the headless version** — show how rendering could be separated from logic by sketching the hook or adapter interface
48
+ - **Identify configuration creep** — when an options object has more than 5 properties, suggest how to decompose it into composable pieces
49
+ - **Diagram state flow** — describe who owns the state and how it flows, especially when ownership is unclear
50
+ - **Flag framework coupling** — point to specific lines where framework-specific code has leaked into what should be a pure logic layer
51
+ - **Suggest composable alternatives** — show how a monolithic component could become a set of primitives that compose
52
+
53
+ ## Agency Reminder
54
+
55
+ You have **full agency** to explore the codebase. Look at how state flows between components, whether logic is reusable across different views, and whether the caching and synchronization strategy is consistent. Trace the boundary between framework-specific code and pure logic. Document what you explored and why.
@@ -0,0 +1,55 @@
1
+ # Vladimir Khorikov — Reviewer
2
+
3
+ > **Known for**: "Unit Testing Principles, Practices, and Patterns"
4
+ >
5
+ > **Philosophy**: Tests should maximize protection against regressions while minimizing maintenance cost. The highest-value tests verify observable behavior at domain boundaries. Output-based testing is superior to state-based, which is superior to communication-based testing.
6
+
7
+ You are reviewing code through the lens of **Vladimir Khorikov**. Not all tests are created equal — most codebases have too many low-value tests and too few high-value ones. Your review evaluates whether tests target the right layer, whether the architecture supports testability, and whether the test suite is an asset or a liability.
8
+
9
+ ## Your Focus Areas
10
+
11
+ - **Test Value**: Does each test provide meaningful protection against regressions relative to its maintenance cost? Low-value tests that break on every refactor are worse than no tests.
12
+ - **Domain vs. Infrastructure Separation**: Is the domain logic pure and testable in isolation, or is it entangled with infrastructure (databases, HTTP, file systems)?
13
+ - **Functional Core / Imperative Shell**: Does the architecture push decisions into a functional core that can be tested with output-based tests, with side effects at the edges?
14
+ - **Over-Specification**: Do tests verify observable behavior, or do they lock in implementation details through excessive mocking and interaction verification?
15
+ - **Test Classification**: Are unit, integration, and end-to-end tests targeting the right concerns at the right granularity?
16
+
17
+ ## Your Review Approach
18
+
19
+ 1. **Classify each test by style** — is it output-based (best), state-based (acceptable), or communication-based (suspect)?
20
+ 2. **Evaluate the test boundary** — is the test verifying behavior through the public API of a meaningful unit, or is it testing an internal implementation detail?
21
+ 3. **Check the mock count** — excessive mocking usually means the architecture is wrong, not that you need more mocks
22
+ 4. **Assess refactoring resilience** — if you refactored the implementation without changing behavior, how many tests would break?
23
+
24
+ ## What You Look For
25
+
26
+ ### Test Value
27
+ - Does the test verify a behavior that a user or caller would actually care about?
28
+ - Would this test catch a real regression, or does it just verify that code was called in a specific order?
29
+ - Is the test's maintenance cost proportional to the protection it provides?
30
+ - Are trivial tests (getters, simple mappings) adding noise without meaningful coverage?
31
+
32
+ ### Architecture for Testability
33
+ - Is domain logic separated from side effects (database calls, API requests, file I/O)?
34
+ - Can the domain layer be tested without any mocks or test doubles?
35
+ - Are infrastructure concerns pushed to the boundary where they can be replaced with real implementations in integration tests?
36
+ - Does the code follow the Humble Object pattern where needed?
37
+
38
+ ### Test Anti-patterns
39
+ - Mocking what you own instead of verifying outcomes
40
+ - Testing private methods directly instead of through the public interface
41
+ - Shared mutable test fixtures that create coupling between tests
42
+ - Assert-per-line patterns that verify every intermediate step instead of the final outcome
43
+ - Brittle tests that break when implementation changes but behavior does not
44
+
45
+ ## Your Output Style
46
+
47
+ - **Rate test value explicitly** — "this test provides high regression protection at low maintenance cost" or "this test will break on any refactor without catching real bugs"
48
+ - **Suggest architectural changes** — when tests are hard to write, the solution is often restructuring the code, not better test tooling
49
+ - **Propose output-based alternatives** — show how a communication-based test could be rewritten as output-based by restructuring the code under test
50
+ - **Flag over-specification** — name the specific mocks or assertions that couple the test to implementation
51
+ - **Distinguish test layers** — be explicit about whether a concern belongs in a unit test, integration test, or end-to-end test
52
+
53
+ ## Agency Reminder
54
+
55
+ You have **full agency** to explore the codebase. Examine the test suite alongside the production code. Trace the boundary between domain logic and infrastructure. Check whether the architecture enables output-based testing or forces communication-based testing. Document what you explored and why.
@@ -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
@@ -29,13 +30,16 @@ Every OCR session creates files in `.ocr/sessions/{session-id}/`:
29
30
  │ │ ├── quality-2.md
30
31
  │ │ ├── security-1.md # (if security reviewer assigned)
31
32
  │ │ ├── testing-1.md # (if testing reviewer assigned)
33
+ │ │ ├── ephemeral-1.md # (if --reviewer flag used)
32
34
  │ │ └── {type}-{n}.md # (additional assigned custom reviewers)
33
35
  │ ├── discourse.md # Cross-reviewer discussion for round 1
36
+ │ ├── round-meta.json # Structured review data (written by CLI via round-complete --stdin)
34
37
  │ └── final.md # Synthesized final review for round 1
35
38
  └── round-2/ # Subsequent rounds (created on re-review)
36
39
  ├── reviews/
37
40
  │ └── ... # Same structure as round-1
38
41
  ├── discourse.md
42
+ ├── round-meta.json
39
43
  └── final.md
40
44
  ```
41
45
 
@@ -80,7 +84,8 @@ OCR uses a **run-based architecture** for maps, parallel to review rounds.
80
84
  | `topology.md` | 2 | File categorization and section groupings |
81
85
  | `flow-analysis.md` | 3 | Upstream/downstream dependency tracing |
82
86
  | `requirements-mapping.md` | 4 | Requirements coverage matrix (if requirements provided) |
83
- | `map.md` | 5 | Final synthesized Code Review Map |
87
+ | `map-meta.json` | 5 | Structured map data (written by CLI via `map-complete --stdin`) |
88
+ | `map.md` | 5 | Final synthesized Code Review Map (presentation artifact) |
84
89
 
85
90
  **When to use multiple runs**:
86
91
  - Changeset has evolved since last map
@@ -97,6 +102,7 @@ OCR uses a **run-based architecture** for maps, parallel to review rounds.
97
102
  | `context.md` | 2 | Change summary, diff analysis, Tech Lead guidance | All reviewers |
98
103
  | `rounds/round-{n}/reviews/{type}-{n}.md` | 4 | Individual reviewer outputs | Discourse, Synthesis |
99
104
  | `rounds/round-{n}/discourse.md` | 6 | Cross-reviewer discussion results | Synthesis |
105
+ | `rounds/round-{n}/round-meta.json` | 7 | Structured review data (written by CLI via `round-complete --stdin`) | Dashboard |
100
106
  | `rounds/round-{n}/final.md` | 7 | Synthesized final review | Show, Post commands |
101
107
 
102
108
  ### Optional Files
@@ -109,7 +115,7 @@ OCR uses a **run-based architecture** for maps, parallel to review rounds.
109
115
 
110
116
  **Pattern**: `{type}-{n}.md`
111
117
 
112
- - `{type}`: One of `principal`, `quality`, `security`, `testing`, or custom reviewer name
118
+ - `{type}`: One of `principal`, `quality`, `security`, `testing`, `ephemeral`, or custom reviewer name
113
119
  - `{n}`: Sequential number starting at 1
114
120
 
115
121
  **Examples** (for round 1):
@@ -121,6 +127,8 @@ rounds/round-1/reviews/quality-2.md
121
127
  rounds/round-1/reviews/security-1.md
122
128
  rounds/round-1/reviews/testing-1.md
123
129
  rounds/round-1/reviews/performance-1.md # Custom reviewer
130
+ rounds/round-1/reviews/ephemeral-1.md # Ephemeral reviewer (from --reviewer)
131
+ rounds/round-1/reviews/ephemeral-2.md # Ephemeral reviewer (from --reviewer)
124
132
  ```
125
133
 
126
134
  **Rules**:
@@ -128,6 +136,8 @@ rounds/round-1/reviews/performance-1.md # Custom reviewer
128
136
  - Use hyphens, not underscores
129
137
  - Instance numbers are sequential per reviewer type
130
138
  - Custom reviewers follow the same `{type}-{n}.md` pattern
139
+ - Ephemeral reviewers (from `--reviewer`) use the `ephemeral-{n}` pattern
140
+ - Ephemeral reviewers are NOT persisted to `reviewers-meta.json` or the reviewers directory
131
141
 
132
142
  ## Phase-to-File Mapping
133
143
 
@@ -139,7 +149,7 @@ rounds/round-1/reviews/performance-1.md # Custom reviewer
139
149
  | 4 | Parallel Reviews | `rounds/round-{n}/reviews/{type}-{n}.md` for each reviewer, call `ocr state transition` |
140
150
  | 5 | Aggregation | (Inline analysis), call `ocr state transition` |
141
151
  | 6 | Discourse | `rounds/round-{n}/discourse.md`, call `ocr state transition` |
142
- | 7 | Synthesis | `rounds/round-{n}/final.md`, call `ocr state transition` |
152
+ | 7 | Synthesis | Pipe data to `ocr state round-complete --stdin` (writes `round-meta.json`), write `final.md` |
143
153
  | 8 | Presentation | Call `ocr state close` |
144
154
 
145
155
  ## State Transitions and File Validation
@@ -153,7 +163,7 @@ When calling `ocr state transition`, verify the corresponding file exists:
153
163
  | `"analysis"` | `context.md` (with Tech Lead guidance) |
154
164
  | `"reviews"` | At least 2 files in `rounds/round-{current_round}/reviews/` |
155
165
  | `"discourse"` | `rounds/round-{current_round}/discourse.md` |
156
- | `"synthesis"` | `rounds/round-{current_round}/final.md` |
166
+ | `"synthesis"` | `rounds/round-{current_round}/round-meta.json`, `rounds/round-{current_round}/final.md` |
157
167
 
158
168
  ## Session ID Format
159
169
 
@@ -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.
@@ -421,6 +421,21 @@ See `references/context-discovery.md` for detailed algorithm.
421
421
  | Logic changes | + 1x Testing (if not in config) |
422
422
  | User says "add security" | + 1x Security |
423
423
 
424
+ 5. **Handle `--team` override** (if provided):
425
+
426
+ If the user passed `--team reviewer-id:count,...`, use those reviewers **instead of** `default_team` from config. Parse the comma-separated list into reviewer IDs and counts.
427
+
428
+ 6. **Handle `--reviewer` ephemeral reviewers** (if provided):
429
+
430
+ Each `--reviewer "..."` value adds one ephemeral reviewer to the team. These are **in addition to** library reviewers (from `--team` or `default_team`).
431
+
432
+ For each `--reviewer` value:
433
+ - Synthesize a focused reviewer persona from the description (see below)
434
+ - Spawn with redundancy 1 (ephemeral reviewers are inherently unique)
435
+ - Output file: `ephemeral-{n}.md` (e.g., `ephemeral-1.md`, `ephemeral-2.md`)
436
+
437
+ **Synthesizing an ephemeral persona**: Use the description to create a focused reviewer identity. For example, `--reviewer "Focus on error handling in the auth flow"` becomes a reviewer whose persona is: "You are reviewing this code with a specific focus on error handling patterns in the authentication flow. Evaluate error propagation, edge cases, failure modes, and recovery paths." The persona should be specific enough to guide the review but broad enough to catch related issues.
438
+
424
439
  ---
425
440
 
426
441
  ## Phase 4: Spawn Reviewers
@@ -464,15 +479,29 @@ See `references/context-discovery.md` for detailed algorithm.
464
479
 
465
480
  Examples: `principal-1.md`, `principal-2.md`, `quality-1.md`, `quality-2.md`, `testing-1.md`
466
481
 
467
- 3. Each task receives:
468
- - Reviewer persona (from `references/reviewers/{name}.md`)
482
+ 3. **Spawn ephemeral reviewers** (if `--reviewer` was provided):
483
+
484
+ For each ephemeral reviewer, create a task with a synthesized persona (no `.md` file lookup). The task receives the same context as library reviewers but uses the synthesized persona instead of a file-based one.
485
+
486
+ ```bash
487
+ # From --reviewer "Focus on error handling"
488
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/ephemeral-1.md
489
+
490
+ # From --reviewer "Review as a junior developer"
491
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/ephemeral-2.md
492
+ ```
493
+
494
+ See `references/reviewer-task.md` for the ephemeral reviewer task variant.
495
+
496
+ 4. Each task receives:
497
+ - Reviewer persona (from `references/reviewers/{name}.md` for library reviewers, or synthesized for ephemeral)
469
498
  - Project context (from `discovered-standards.md`)
470
499
  - **Requirements context (from `requirements.md` if provided)**
471
500
  - Tech Lead guidance (including requirements assessment)
472
501
  - The diff to review
473
502
  - **Instruction to explore codebase with full agency**
474
503
 
475
- 4. Save each review to `.ocr/sessions/{id}/rounds/round-{current_round}/reviews/{type}-{n}.md`.
504
+ 5. Save each review to `.ocr/sessions/{id}/rounds/round-{current_round}/reviews/{type}-{n}.md`.
476
505
 
477
506
  See `references/reviewer-task.md` for the task template.
478
507
 
@@ -489,12 +518,12 @@ REVIEWS_DIR="$SESSION_DIR/rounds/round-$CURRENT_ROUND/reviews"
489
518
  echo "Validating: $REVIEWS_DIR"
490
519
  ls -la "$REVIEWS_DIR/"
491
520
 
492
- # Verify all files match {type}-{n}.md pattern (principal, quality, security, testing)
521
+ # Verify all files match {slug}-{n}.md pattern
493
522
  for f in "$REVIEWS_DIR/"*.md; do
494
- if [[ "$(basename "$f")" =~ ^(principal|quality|security|testing)-[0-9]+\.md$ ]]; then
523
+ if [[ "$(basename "$f")" =~ ^[a-z][a-z0-9-]*-[0-9]+\.md$ ]]; then
495
524
  echo "OK $(basename "$f")"
496
525
  else
497
- echo "FAIL $(basename "$f") does not match {type}-{n}.md pattern"
526
+ echo "FAIL $(basename "$f") does not match {slug}-{n}.md pattern"
498
527
  exit 1
499
528
  fi
500
529
  done
@@ -592,11 +621,11 @@ See `references/discourse.md` for detailed instructions.
592
621
  - Challenged and defended: +1
593
622
  - Challenged and undefended: -1
594
623
 
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
624
+ 4. Categorize findings into three sections (see `references/final-template.md` for criteria):
625
+ - **Blockers**: Security vulnerabilities, data integrity risks, correctness bugs, breaking changes — must resolve before merge
626
+ - **Should Fix**: Code quality issues, potential bugs, missing validation, important refactors — address before or shortly after merge
627
+ - **Suggestions**: Style preferences, minor refactors, documentation, testing ideas — author's discretion
628
+ - **What's Working Well**: Positive feedback (separate encouragement section, not counted)
600
629
 
601
630
  5. **If requirements were provided**, include Requirements Assessment:
602
631
  - Which requirements are fully met?
@@ -612,7 +641,57 @@ See `references/discourse.md` for detailed instructions.
612
641
 
613
642
  These go in a prominent "Clarifying Questions" section for stakeholder response.
614
643
 
615
- 7. **Write the final review file**:
644
+ 7. **Pipe structured round data to the CLI (BEFORE `final.md`)**:
645
+
646
+ > 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.
647
+
648
+ Construct the JSON from synthesis knowledge, then pipe to the CLI:
649
+
650
+ ```bash
651
+ cat <<'JSON' | ocr state round-complete --stdin
652
+ {
653
+ "schema_version": 1,
654
+ "verdict": "REQUEST CHANGES",
655
+ "reviewers": [
656
+ {
657
+ "type": "principal",
658
+ "instance": 1,
659
+ "severity_high": 1,
660
+ "severity_medium": 4,
661
+ "severity_low": 2,
662
+ "severity_info": 0,
663
+ "findings": [
664
+ {
665
+ "title": "SQL Injection in query builder",
666
+ "category": "blocker",
667
+ "severity": "high",
668
+ "file_path": "src/db/query.ts",
669
+ "line_start": 42,
670
+ "line_end": 45,
671
+ "summary": "User input passed directly to raw SQL...",
672
+ "flagged_by": ["@principal-1", "@security-1"]
673
+ }
674
+ ]
675
+ }
676
+ ]
677
+ }
678
+ JSON
679
+ ```
680
+
681
+ The CLI will:
682
+ 1. Validate the JSON schema (schema_version, verdict, reviewers, findings)
683
+ 2. Write `round-meta.json` to `{session_dir}/rounds/round-{n}/round-meta.json`
684
+ 3. Compute derived counts from the findings array (never self-reported)
685
+ 4. Record a `round_completed` orchestration event in SQLite
686
+
687
+ **Finding categories**: `"blocker"` | `"should_fix"` | `"suggestion"` | `"style"`
688
+ **Finding severity**: `"critical"` | `"high"` | `"medium"` | `"low"` | `"info"`
689
+
690
+ Optional flags: `--session-id <id>` (auto-detects active session), `--round <number>` (auto-detects current round).
691
+
692
+ > **Do NOT write `round-meta.json` directly** — always pipe through the CLI so the schema is validated and the event is recorded atomically.
693
+
694
+ 8. **Write the final review file**:
616
695
  ```bash
617
696
  # OUTPUT FILE - must be exactly this path:
618
697
  FINAL_FILE="$SESSION_DIR/rounds/round-$CURRENT_ROUND/final.md"
@@ -620,7 +699,7 @@ See `references/discourse.md` for detailed instructions.
620
699
 
621
700
  Save synthesized review to `$FINAL_FILE`.
622
701
 
623
- See `references/final-template.md` for the template format.
702
+ See `references/final-template.md` for the template format.
624
703
 
625
704
  ### Phase 7 Checkpoint — MANDATORY VALIDATION
626
705
 
@@ -630,9 +709,18 @@ See `references/final-template.md` for the template format.
630
709
  # Set these based on your current session
631
710
  SESSION_DIR=".ocr/sessions/$(ls -1t .ocr/sessions/ | head -1)"
632
711
  CURRENT_ROUND=$(ls -1d "$SESSION_DIR/rounds/round-"* 2>/dev/null | wc -l | tr -d ' ')
712
+ ROUND_META="$SESSION_DIR/rounds/round-$CURRENT_ROUND/round-meta.json"
633
713
  FINAL_FILE="$SESSION_DIR/rounds/round-$CURRENT_ROUND/final.md"
634
714
 
635
- # Check file exists
715
+ # Check round-meta.json exists
716
+ if [ -f "$ROUND_META" ]; then
717
+ echo "OK round-meta.json exists at $ROUND_META"
718
+ else
719
+ echo "FAIL round-meta.json not found at $ROUND_META"
720
+ exit 1
721
+ fi
722
+
723
+ # Check final.md exists
636
724
  if [ -f "$FINAL_FILE" ]; then
637
725
  echo "OK final.md exists at $FINAL_FILE"
638
726
  else
@@ -650,8 +738,9 @@ fi
650
738
  ```
651
739
 
652
740
  **STOP and verify before proceeding:**
741
+ - [ ] `rounds/round-{n}/round-meta.json` exists with valid structured data
653
742
  - [ ] `rounds/round-{n}/final.md` exists
654
- - [ ] Contains prioritized findings (Must Fix, Should Fix, Consider)
743
+ - [ ] Contains categorized findings (Blockers, Should Fix, Suggestions)
655
744
  - [ ] Contains Clarifying Questions section (if any)
656
745
  - [ ] If requirements provided: Contains Requirements Assessment
657
746
 
@@ -670,9 +759,9 @@ fi
670
759
  # Code Review: {branch}
671
760
 
672
761
  ## Summary
673
- {X} must-fix, {Y} should-fix, {Z} suggestions
762
+ {X} blockers, {Y} should-fix, {Z} suggestions
674
763
 
675
- ## Must Fix
764
+ ## Blockers
676
765
  ...
677
766
 
678
767
  ## Should Fix
@@ -713,5 +802,5 @@ fi
713
802
  | 4 | Spawn reviewer tasks, `ocr state transition` | `rounds/round-{n}/reviews/*.md` |
714
803
  | 5 | Compare redundant runs, `ocr state transition` | aggregated findings |
715
804
  | 6 | Reviewer discourse, `ocr state transition` | `rounds/round-{n}/discourse.md` |
716
- | 7 | Synthesize and prioritize, `ocr state transition` | `rounds/round-{n}/final.md` |
805
+ | 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
806
  | 8 | Display/post, `ocr state close` | Terminal output, GitHub |