@open-code-review/agents 1.3.1 → 1.5.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.
@@ -2,7 +2,9 @@
2
2
 
3
3
  Complete 8-phase process for multi-agent code review.
4
4
 
5
- > ⚠️ **CRITICAL**: You MUST update `state.json` **BEFORE starting work** on each phase. The `ocr progress` CLI reads this file for real-time tracking. Update the `current_phase` and `phase_number` immediately when transitioning—do not wait until the phase is complete.
5
+ > **CRITICAL**: You MUST call `ocr state transition` **BEFORE starting work** on each phase. The `ocr progress` CLI reads session state for real-time tracking. Transition the `current_phase` and `phase_number` immediately when entering a new phase—do not wait until the phase is complete.
6
+
7
+ > **PREREQUISITE**: The `ocr` CLI must be installed (`npm install -g @open-code-review/cli`) or accessible via `npx`. Every phase transition calls `ocr state transition`, which requires the CLI.
6
8
 
7
9
  ---
8
10
 
@@ -13,8 +15,9 @@ Before starting ANY work, verify the current session state to avoid duplicating
13
15
  ### Step 1: Check for existing session
14
16
 
15
17
  ```bash
16
- # Get current branch
17
- BRANCH=$(git branch --show-current)
18
+ # Get current branch and sanitize for filesystem (replace / with -)
19
+ BRANCH_RAW=$(git branch --show-current)
20
+ BRANCH=$(echo "$BRANCH_RAW" | tr '/' '-')
18
21
  DATE=$(date +%Y-%m-%d)
19
22
  SESSION_DIR=".ocr/sessions/${DATE}-${BRANCH}"
20
23
 
@@ -33,7 +36,11 @@ Then proceed to Phase 1.
33
36
 
34
37
  ### Step 3: If session exists, verify state matches files
35
38
 
36
- Read `state.json` and verify actual files exist (see `references/session-files.md` for authoritative names):
39
+ Use `ocr state show` to read current state and verify actual files exist (see `references/session-files.md` for authoritative names):
40
+
41
+ ```bash
42
+ ocr state show
43
+ ```
37
44
 
38
45
  | Phase Complete? | File check |
39
46
  |-----------------|------------|
@@ -44,7 +51,7 @@ Read `state.json` and verify actual files exist (see `references/session-files.m
44
51
  | discourse | `rounds/round-{current_round}/discourse.md` exists |
45
52
  | synthesis | `rounds/round-{current_round}/final.md` exists |
46
53
 
47
- > **Note**: Phase completion is derived from filesystem (file existence). The `current_phase` field in `state.json` indicates which phase is active, not what's complete.
54
+ > **Note**: Phase completion is derived from filesystem (file existence). The `current_phase` field in the session state indicates which phase is active, not what's complete.
48
55
 
49
56
  ### Step 3b: Round Resolution Algorithm
50
57
 
@@ -61,7 +68,7 @@ else
61
68
  # Find highest round number
62
69
  HIGHEST=$(ls -1 "$ROUNDS_DIR" | grep -E '^round-[0-9]+$' | sed 's/round-//' | sort -n | tail -1)
63
70
  HIGHEST=${HIGHEST:-0}
64
-
71
+
65
72
  # Check if highest round is complete (has final.md)
66
73
  if [ -f "$ROUNDS_DIR/round-$HIGHEST/final.md" ]; then
67
74
  # Start new round
@@ -74,51 +81,40 @@ else
74
81
  fi
75
82
  ```
76
83
 
77
- Update `state.json` with `current_round` value. **When starting a new round (CURRENT_ROUND > 1), also set `round_started_at` to the current timestamp** so the CLI progress timer shows elapsed time for the current round, not the entire session.
84
+ When starting a new round (CURRENT_ROUND > 1), pass the `--current-round` flag to `ocr state transition` so the CLI progress timer shows elapsed time for the current round, not the entire session.
78
85
 
79
86
  ### Step 4: Determine resume point
80
87
 
81
- - **state.json missing, files exist**: Recreate `state.json` based on file existence
82
- - **state.json exists, files match**: Resume from `current_phase`
83
- - **state.json and files mismatch**: Ask user which to trust
88
+ - **No state in SQLite, files exist**: Use `ocr state init` to recreate the session, then `ocr state transition` to set the correct phase based on file existence
89
+ - **State exists, files match**: Resume from `current_phase` shown by `ocr state show`
90
+ - **State and files mismatch**: Ask user which to trust
84
91
  - **No session exists**: Create session directory and start Phase 1
85
92
 
86
93
  ### Step 5: Report to user
87
94
 
88
95
  Before proceeding, tell the user:
89
96
  ```
90
- 📍 Session: {session_id}
91
- 📊 Current phase: {current_phase} (Phase {phase_number}/8)
92
- 🔄 Action: [Starting fresh | Resuming from Phase X]
97
+ Session: {session_id}
98
+ Current phase: {current_phase} (Phase {phase_number}/8)
99
+ Action: [Starting fresh | Resuming from Phase X]
93
100
  ```
94
101
 
95
102
  ---
96
103
 
97
104
  ## State Tracking
98
105
 
99
- At **every phase transition**, update `.ocr/sessions/{id}/state.json`:
100
-
101
- ```json
102
- {
103
- "session_id": "{id}",
104
- "status": "active",
105
- "current_phase": "reviews",
106
- "phase_number": 4,
107
- "current_round": 1,
108
- "started_at": "{PRESERVE_ORIGINAL}",
109
- "round_started_at": "{CURRENT_ISO_TIMESTAMP}",
110
- "updated_at": "{CURRENT_ISO_TIMESTAMP}"
111
- }
112
- ```
113
-
114
- **Minimal schema** — round metadata is derived from filesystem, not stored in state.json.
106
+ At **every phase transition**, call `ocr state transition`:
115
107
 
116
- **CRITICAL**: Generate timestamps dynamically (e.g., `date -u +"%Y-%m-%dT%H:%M:%SZ"` on macOS/Linux). Preserve `started_at` from session creation; set `round_started_at` when starting a new round (> 1); always update `updated_at` with current time.
108
+ ```bash
109
+ ocr state transition --phase "reviews" --phase-number 4 --current-round 1
110
+ ```
117
111
 
118
- **Status values**: `active` (in progress), `closed` (complete and dismissed)
112
+ This updates the session in SQLite and logs an orchestration event.
119
113
 
120
114
  **Phase values**: `context`, `change-context`, `analysis`, `reviews`, `aggregation`, `discourse`, `synthesis`, `complete`
121
115
 
116
+ **Status values**: `active` (in progress), `closed` (complete — set via `ocr state close`)
117
+
122
118
  ## Artifact Checklist
123
119
 
124
120
  > **See `references/session-files.md` for the authoritative file manifest.**
@@ -127,14 +123,14 @@ Before proceeding to each phase, verify the required artifacts exist:
127
123
 
128
124
  | Phase | Required Before Starting | Artifact to Create |
129
125
  |-------|-------------------------|-------------------|
130
- | 1 | Session directory created | `state.json`, `discovered-standards.md`, `requirements.md` (if provided) |
131
- | 2 | `discovered-standards.md` exists | `context.md`, `rounds/round-1/reviews/` directory, update `state.json` |
132
- | 3 | `context.md` exists | Update `context.md` with Tech Lead guidance, update `state.json` |
133
- | 4 | `context.md` exists | `rounds/round-{n}/reviews/{type}-{n}.md` for each reviewer, update `state.json` |
134
- | 5 | ≥2 files in `rounds/round-{n}/reviews/` | Aggregated findings (inline), update `state.json` |
135
- | 6 | Reviews complete | `rounds/round-{n}/discourse.md`, update `state.json` |
136
- | 7 | `rounds/round-{n}/discourse.md` exists | `rounds/round-{n}/final.md`, update `state.json` |
137
- | 8 | `rounds/round-{n}/final.md` exists | Present to user, set `status: "closed"` and `current_phase: "complete"` |
126
+ | 1 | Session directory created | `discovered-standards.md`, `requirements.md` (if provided); call `ocr state init` |
127
+ | 2 | `discovered-standards.md` exists | `context.md`, `rounds/round-1/reviews/` directory; call `ocr state transition` |
128
+ | 3 | `context.md` exists | Update `context.md` with Tech Lead guidance; call `ocr state transition` |
129
+ | 4 | `context.md` exists | `rounds/round-{n}/reviews/{type}-{n}.md` for each reviewer; call `ocr state transition` |
130
+ | 5 | ≥2 files in `rounds/round-{n}/reviews/` | Aggregated findings (inline); call `ocr state transition` |
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` |
133
+ | 8 | `rounds/round-{n}/final.md` exists | Present to user; call `ocr state close` |
138
134
 
139
135
  **NEVER skip directly to `final.md`** — this breaks progress tracking.
140
136
 
@@ -155,6 +151,20 @@ This location is consistent regardless of how OCR is installed (CLI or plugin),
155
151
 
156
152
  **Goal**: Build review context from config + discovered files + user requirements.
157
153
 
154
+ **State**: Call `ocr state init` to create the session, then `ocr state transition --phase "context" --phase-number 1`:
155
+
156
+ ```bash
157
+ # Initialize the session in SQLite
158
+ ocr state init \
159
+ --session-id "$SESSION_ID" \
160
+ --branch "$BRANCH" \
161
+ --workflow-type review \
162
+ --session-dir "$SESSION_DIR"
163
+
164
+ # Transition to context phase
165
+ ocr state transition --phase "context" --phase-number 1
166
+ ```
167
+
158
168
  ### Steps
159
169
 
160
170
  **1a. Load OCR Configuration**
@@ -227,7 +237,7 @@ If requirements provided, save to `requirements.md` in session directory.
227
237
  ## OCR Config Context
228
238
  [content from .ocr/config.yaml context field]
229
239
 
230
- ## OpenSpec Context
240
+ ## OpenSpec Context
231
241
  [content from openspec/config.yaml]
232
242
 
233
243
  ## From: AGENTS.md
@@ -242,7 +252,7 @@ If requirements provided, save to `requirements.md` in session directory.
242
252
 
243
253
  See `references/context-discovery.md` for detailed algorithm.
244
254
 
245
- ### Phase 1 Checkpoint
255
+ ### Phase 1 Checkpoint
246
256
 
247
257
  **STOP and verify before proceeding:**
248
258
  - [ ] `discovered-standards.md` written to session directory
@@ -254,6 +264,8 @@ See `references/context-discovery.md` for detailed algorithm.
254
264
 
255
265
  **Goal**: Understand what changed and why.
256
266
 
267
+ **State**: Call `ocr state transition --phase "change-context" --phase-number 2`
268
+
257
269
  ### Steps
258
270
 
259
271
  1. Identify the review target:
@@ -266,13 +278,13 @@ See `references/context-discovery.md` for detailed algorithm.
266
278
  ```bash
267
279
  # Get the diff
268
280
  git diff --cached > /tmp/ocr-diff.txt
269
-
281
+
270
282
  # Get recent commit messages for intent
271
283
  git log --oneline -10
272
-
284
+
273
285
  # Get branch name
274
286
  git branch --show-current
275
-
287
+
276
288
  # List affected files
277
289
  git diff --cached --name-only
278
290
  ```
@@ -286,21 +298,21 @@ See `references/context-discovery.md` for detailed algorithm.
286
298
  4. Save context to `context.md`:
287
299
  ```markdown
288
300
  # Review Context
289
-
301
+
290
302
  **Session**: {SESSION_ID}
291
303
  **Target**: staged changes
292
304
  **Branch**: {branch}
293
305
  **Files**: {count} files changed
294
-
306
+
295
307
  ## Change Summary
296
308
  [Brief description of what changed]
297
-
309
+
298
310
  ## Affected Files
299
311
  - path/to/file1.ts
300
312
  - path/to/file2.ts
301
313
  ```
302
314
 
303
- ### Phase 2 Checkpoint
315
+ ### Phase 2 Checkpoint
304
316
 
305
317
  **STOP and verify before proceeding:**
306
318
  - [ ] Session directory created: `.ocr/sessions/{id}/`
@@ -313,46 +325,63 @@ See `references/context-discovery.md` for detailed algorithm.
313
325
 
314
326
  **Goal**: Summarize changes, analyze against requirements, identify risks, select reviewers.
315
327
 
328
+ **State**: Call `ocr state transition --phase "analysis" --phase-number 3`
329
+
316
330
  ### Steps
317
331
 
318
- 1. Review requirements (if provided):
332
+ 1. **Check for existing map reference** (optional):
333
+
334
+ If user explicitly references an existing map (e.g., "I've already generated a map", "use the map I created", "check the map in this session"):
335
+
336
+ ```bash
337
+ # Check for existing map artifacts
338
+ ls .ocr/sessions/{id}/map/runs/*/map.md 2>/dev/null
339
+ ```
340
+
341
+ - **If found AND user referenced it**: Read the latest `map.md` as supplementary context
342
+ - **If not found**: Inform user no map exists, proceed with standard review
343
+ - **If user did NOT reference a map**: Do NOT automatically use map artifacts
344
+
345
+ > **Note**: Maps are orthogonal tools. Only use if explicitly referenced by user.
346
+
347
+ 2. Review requirements (if provided):
319
348
  - What is the code SUPPOSED to do?
320
349
  - What are the acceptance criteria?
321
350
  - What edge cases are implied?
322
351
 
323
- 2. Analyze the diff to understand:
352
+ 3. Analyze the diff to understand:
324
353
  - What functionality is being added/changed/removed?
325
354
  - Does this align with requirements?
326
355
  - What is the likely intent?
327
356
  - What are the potential risk areas?
328
357
 
329
- 3. Create dynamic guidance for reviewers:
358
+ 4. Create dynamic guidance for reviewers:
330
359
  ```markdown
331
360
  ## Tech Lead Guidance
332
-
361
+
333
362
  ### Requirements Summary (if provided)
334
363
  The changes should implement OAuth2 authentication per spec...
335
364
  Key acceptance criteria:
336
365
  - Users can log in via Google OAuth
337
366
  - Session tokens expire after 24 hours
338
367
  - Failed logins are rate-limited
339
-
368
+
340
369
  ### Change Summary
341
370
  This PR adds user authentication via OAuth2...
342
-
371
+
343
372
  ### Requirements Assessment
344
- - OAuth login: Implemented
373
+ - OAuth login: Implemented
345
374
  - Token expiry: Not visible in diff - verify implementation
346
375
  - Rate limiting: Not found - may be missing
347
-
376
+
348
377
  ### Clarifying Questions (Tech Lead)
349
378
  - The spec says "fast response" - what's the target latency?
350
379
  - Should this include account lockout after N failures?
351
-
380
+
352
381
  ### Risk Areas
353
382
  - **Security**: New auth flow needs careful review
354
383
  - **Architecture**: New service layer pattern
355
-
384
+
356
385
  ### Focus Points
357
386
  - Validate token handling
358
387
  - Check for proper error handling
@@ -366,7 +395,7 @@ See `references/context-discovery.md` for detailed algorithm.
366
395
  # MUST read default_team from .ocr/config.yaml - do NOT use hardcoded values
367
396
  cat .ocr/config.yaml | grep -A10 'default_team:'
368
397
  ```
369
-
398
+
370
399
  Parse the `default_team` section to determine reviewer counts:
371
400
  ```yaml
372
401
  # Example config - actual values come from .ocr/config.yaml
@@ -376,21 +405,21 @@ See `references/context-discovery.md` for detailed algorithm.
376
405
  # security: 1 # Commented = not spawned by default
377
406
  testing: 1 # Spawn testing-1
378
407
  ```
379
-
408
+
380
409
  **Reviewer spawning rules**:
381
410
  - For each uncommented entry in `default_team`, spawn N instances
382
411
  - `principal: 2` → spawn `principal-1`, `principal-2`
383
- - `quality: 2` → spawn `quality-1`, `quality-2`
412
+ - `quality: 2` → spawn `quality-1`, `quality-2`
384
413
  - `testing: 1` → spawn `testing-1`
385
414
  - Commented entries (e.g., `# security: 1`) are NOT spawned unless auto-detected
386
-
415
+
387
416
  **Auto-detection** (adds reviewers beyond config):
388
417
  | Change Type | Additional Reviewers |
389
418
  |-------------|---------------------|
390
- | Auth/Security changes | + Security |
391
- | API changes | + Security |
392
- | Logic changes | + Testing (if not in config) |
393
- | User says "add security" | + Security |
419
+ | Auth/Security changes | + 1x Security |
420
+ | API changes | + 1x Security |
421
+ | Logic changes | + 1x Testing (if not in config) |
422
+ | User says "add security" | + 1x Security |
394
423
 
395
424
  ---
396
425
 
@@ -398,7 +427,9 @@ See `references/context-discovery.md` for detailed algorithm.
398
427
 
399
428
  **Goal**: Run each reviewer independently with configured redundancy.
400
429
 
401
- > **⚠️ CRITICAL**: Reviewer counts and types come from `.ocr/config.yaml` `default_team` section.
430
+ **State**: Call `ocr state transition --phase "reviews" --phase-number 4 --current-round $CURRENT_ROUND`
431
+
432
+ > **CRITICAL**: Reviewer counts and types come from `.ocr/config.yaml` `default_team` section.
402
433
  > Do NOT use hardcoded defaults. Do NOT skip the `-{n}` suffix in filenames.
403
434
  > See `references/session-files.md` for authoritative file naming.
404
435
 
@@ -407,30 +438,30 @@ See `references/context-discovery.md` for detailed algorithm.
407
438
  1. Load reviewer personas from `references/reviewers/`.
408
439
 
409
440
  2. **Parse `default_team` from config** (already read in Phase 3):
410
-
441
+
411
442
  For each reviewer type in config, spawn the specified number of instances:
412
-
443
+
413
444
  ```bash
414
445
  # Example: If config says principal: 2, quality: 2, testing: 1
415
446
  # You MUST spawn exactly these reviewers with numbered suffixes:
416
-
447
+
417
448
  # From default_team.principal: 2
418
- Create: rounds/round-$CURRENT_ROUND/reviews/principal-1.md
419
- Create: rounds/round-$CURRENT_ROUND/reviews/principal-2.md
420
-
421
- # From default_team.quality: 2
422
- Create: rounds/round-$CURRENT_ROUND/reviews/quality-1.md
423
- Create: rounds/round-$CURRENT_ROUND/reviews/quality-2.md
424
-
449
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/principal-1.md
450
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/principal-2.md
451
+
452
+ # From default_team.quality: 2
453
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/quality-1.md
454
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/quality-2.md
455
+
425
456
  # From default_team.testing: 1
426
- Create: rounds/round-$CURRENT_ROUND/reviews/testing-1.md
427
-
457
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/testing-1.md
458
+
428
459
  # Auto-detected (if applicable)
429
- Create: rounds/round-$CURRENT_ROUND/reviews/security-1.md
460
+ -> Create: rounds/round-$CURRENT_ROUND/reviews/security-1.md
430
461
  ```
431
-
462
+
432
463
  **File naming pattern**: `{type}-{n}.md` where n starts at 1.
433
-
464
+
434
465
  Examples: `principal-1.md`, `principal-2.md`, `quality-1.md`, `quality-2.md`, `testing-1.md`
435
466
 
436
467
  3. Each task receives:
@@ -445,7 +476,7 @@ See `references/context-discovery.md` for detailed algorithm.
445
476
 
446
477
  See `references/reviewer-task.md` for the task template.
447
478
 
448
- ### Phase 4 Checkpoint — MANDATORY VALIDATION
479
+ ### Phase 4 Checkpoint — MANDATORY VALIDATION
449
480
 
450
481
  **Run this validation command before proceeding:**
451
482
 
@@ -461,15 +492,15 @@ ls -la "$REVIEWS_DIR/"
461
492
  # Verify all files match {type}-{n}.md pattern (principal, quality, security, testing)
462
493
  for f in "$REVIEWS_DIR/"*.md; do
463
494
  if [[ "$(basename "$f")" =~ ^(principal|quality|security|testing)-[0-9]+\.md$ ]]; then
464
- echo " $(basename "$f")"
495
+ echo "OK $(basename "$f")"
465
496
  else
466
- echo " $(basename "$f") does not match {type}-{n}.md pattern"
497
+ echo "FAIL $(basename "$f") does not match {type}-{n}.md pattern"
467
498
  exit 1
468
499
  fi
469
500
  done
470
501
 
471
502
  REVIEWER_COUNT=$(ls -1 "$REVIEWS_DIR/"*.md 2>/dev/null | wc -l | tr -d ' ')
472
- echo " Found $REVIEWER_COUNT reviewer files"
503
+ echo "OK Found $REVIEWER_COUNT reviewer files"
473
504
  ```
474
505
 
475
506
  **STOP and verify before proceeding:**
@@ -484,6 +515,8 @@ echo "✓ Found $REVIEWER_COUNT reviewer files"
484
515
 
485
516
  **Goal**: Merge redundant reviewer runs and mark confidence.
486
517
 
518
+ **State**: Call `ocr state transition --phase "aggregation" --phase-number 5 --current-round $CURRENT_ROUND`
519
+
487
520
  ### Steps
488
521
 
489
522
  1. For reviewers with redundancy > 1, compare findings:
@@ -496,10 +529,10 @@ echo "✓ Found $REVIEWER_COUNT reviewer files"
496
529
  3. Create aggregated findings per reviewer:
497
530
  ```markdown
498
531
  ## Security Reviewer (2 runs)
499
-
532
+
500
533
  ### Confirmed Findings (2/2 runs)
501
534
  - SQL injection risk in query builder [VERY HIGH]
502
-
535
+
503
536
  ### Partial Findings (1/2 runs)
504
537
  - Potential timing attack in comparison [MEDIUM]
505
538
  ```
@@ -510,6 +543,8 @@ echo "✓ Found $REVIEWER_COUNT reviewer files"
510
543
 
511
544
  **Goal**: Let reviewers challenge and build on each other's findings.
512
545
 
546
+ **State**: Call `ocr state transition --phase "discourse" --phase-number 6 --current-round $CURRENT_ROUND`
547
+
513
548
  > Skip this phase if `--quick` flag is used.
514
549
 
515
550
  ### Steps
@@ -526,7 +561,7 @@ echo "✓ Found $REVIEWER_COUNT reviewer files"
526
561
 
527
562
  See `references/discourse.md` for detailed instructions.
528
563
 
529
- ### Phase 6 Checkpoint
564
+ ### Phase 6 Checkpoint
530
565
 
531
566
  **STOP and verify before proceeding:**
532
567
  - [ ] `rounds/round-{n}/discourse.md` written to round directory
@@ -539,6 +574,8 @@ See `references/discourse.md` for detailed instructions.
539
574
 
540
575
  **Goal**: Produce final prioritized review and save to **`final.md`**.
541
576
 
577
+ **State**: Call `ocr state transition --phase "synthesis" --phase-number 7 --current-round $CURRENT_ROUND`
578
+
542
579
  > **File**: `rounds/round-{n}/final.md`
543
580
  > **Template**: See `references/final-template.md` for format
544
581
  > **Manifest**: See `references/session-files.md` for authoritative file names
@@ -572,7 +609,7 @@ See `references/discourse.md` for detailed instructions.
572
609
  - Questions about scope boundaries
573
610
  - Questions about edge cases
574
611
  - Questions about intentional exclusions
575
-
612
+
576
613
  These go in a prominent "Clarifying Questions" section for stakeholder response.
577
614
 
578
615
  7. **Write the final review file**:
@@ -580,12 +617,12 @@ See `references/discourse.md` for detailed instructions.
580
617
  # OUTPUT FILE - must be exactly this path:
581
618
  FINAL_FILE="$SESSION_DIR/rounds/round-$CURRENT_ROUND/final.md"
582
619
  ```
583
-
620
+
584
621
  Save synthesized review to `$FINAL_FILE`.
585
622
 
586
623
  See `references/final-template.md` for the template format.
587
624
 
588
- ### Phase 7 Checkpoint — MANDATORY VALIDATION
625
+ ### Phase 7 Checkpoint — MANDATORY VALIDATION
589
626
 
590
627
  **Run this validation command before proceeding:**
591
628
 
@@ -597,17 +634,17 @@ FINAL_FILE="$SESSION_DIR/rounds/round-$CURRENT_ROUND/final.md"
597
634
 
598
635
  # Check file exists
599
636
  if [ -f "$FINAL_FILE" ]; then
600
- echo " final.md exists at $FINAL_FILE"
637
+ echo "OK final.md exists at $FINAL_FILE"
601
638
  else
602
- echo " final.md not found at $FINAL_FILE"
639
+ echo "FAIL final.md not found at $FINAL_FILE"
603
640
  exit 1
604
641
  fi
605
642
 
606
643
  # Check required content
607
644
  if grep -q '## Verdict' "$FINAL_FILE"; then
608
- echo " Contains Verdict section"
645
+ echo "OK Contains Verdict section"
609
646
  else
610
- echo " Missing '## Verdict' section"
647
+ echo "FAIL Missing '## Verdict' section"
611
648
  exit 1
612
649
  fi
613
650
  ```
@@ -624,18 +661,20 @@ fi
624
661
 
625
662
  **Goal**: Display results, optionally post to GitHub, and close the session.
626
663
 
664
+ **State**: Call `ocr state close` after presenting results.
665
+
627
666
  ### Steps
628
667
 
629
668
  1. Display the final review in a clear format:
630
669
  ```markdown
631
670
  # Code Review: {branch}
632
-
671
+
633
672
  ## Summary
634
673
  {X} must-fix, {Y} should-fix, {Z} suggestions
635
-
674
+
636
675
  ## Must Fix
637
676
  ...
638
-
677
+
639
678
  ## Should Fix
640
679
  ...
641
680
  ```
@@ -644,27 +683,22 @@ fi
644
683
  - Check for `gh` CLI: `which gh`
645
684
  - Post as PR comment: `gh pr comment {number} --body-file final.md`
646
685
 
647
- 3. **Close the session** by updating `state.json`:
648
- ```json
649
- {
650
- "session_id": "{id}",
651
- "status": "closed",
652
- "current_phase": "complete",
653
- "phase_number": 8,
654
- "current_round": 1,
655
- "updated_at": "{now}"
656
- }
686
+ 3. **Close the session**:
687
+ ```bash
688
+ ocr state close
657
689
  ```
658
-
659
- > **IMPORTANT**: Setting `status: "closed"` ensures:
690
+
691
+ This sets `status: "closed"` and `current_phase: "complete"` in SQLite.
692
+
693
+ > **IMPORTANT**: Closing the session ensures:
660
694
  > - The `ocr progress` CLI stops showing this session
661
695
  > - The session won't be picked up for resume
662
696
  > - The session remains accessible via `/ocr-history` and `/ocr-show`
663
697
 
664
698
  4. Confirm session saved:
665
699
  ```
666
- Review complete
667
- .ocr/sessions/{id}/rounds/round-{n}/final.md
700
+ Review complete
701
+ -> .ocr/sessions/{id}/rounds/round-{n}/final.md
668
702
  ```
669
703
 
670
704
  ---
@@ -673,11 +707,11 @@ fi
673
707
 
674
708
  | Phase | Command/Action | Output |
675
709
  |-------|---------------|--------|
676
- | 1 | Search for context files | `discovered-standards.md` |
677
- | 2 | git diff, create session | `context.md`, `rounds/round-1/reviews/` |
678
- | 3 | Analyze, select reviewers | guidance in `context.md` |
679
- | 4 | Spawn reviewer tasks | `rounds/round-{n}/reviews/*.md` |
680
- | 5 | Compare redundant runs | aggregated findings |
681
- | 6 | Reviewer discourse | `rounds/round-{n}/discourse.md` |
682
- | 7 | Synthesize and prioritize | `rounds/round-{n}/final.md` |
683
- | 8 | Display/post | Terminal output, GitHub |
710
+ | 1 | `ocr state init` + search for context files | `discovered-standards.md` |
711
+ | 2 | git diff, create session, `ocr state transition` | `context.md`, `rounds/round-1/reviews/` |
712
+ | 3 | Analyze, select reviewers, `ocr state transition` | guidance in `context.md` |
713
+ | 4 | Spawn reviewer tasks, `ocr state transition` | `rounds/round-{n}/reviews/*.md` |
714
+ | 5 | Compare redundant runs, `ocr state transition` | aggregated findings |
715
+ | 6 | Reviewer discourse, `ocr state transition` | `rounds/round-{n}/discourse.md` |
716
+ | 7 | Synthesize and prioritize, `ocr state transition` | `rounds/round-{n}/final.md` |
717
+ | 8 | Display/post, `ocr state close` | Terminal output, GitHub |