@open-code-review/agents 1.4.0 → 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 6-phase process for generating a Code Review Map.
4
4
 
5
- > ⚠️ **CRITICAL**: You MUST update `state.json` **BEFORE starting work** on each phase. Update the `current_phase` and `phase_number` immediately when transitioning.
5
+ > **CRITICAL**: You MUST call `ocr state transition` **BEFORE starting work** on each phase. Transition the `current_phase` and `phase_number` immediately when entering a new phase.
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
 
@@ -57,7 +59,7 @@ if [ ! -d "$MAP_DIR" ]; then
57
59
  else
58
60
  HIGHEST=$(ls -1 "$MAP_DIR" | grep -E '^run-[0-9]+$' | sed 's/run-//' | sort -n | tail -1)
59
61
  HIGHEST=${HIGHEST:-0}
60
-
62
+
61
63
  if [ -f "$MAP_DIR/run-$HIGHEST/map.md" ]; then
62
64
  CURRENT_RUN=$((HIGHEST + 1))
63
65
  mkdir -p "$MAP_DIR/run-$CURRENT_RUN"
@@ -67,82 +69,60 @@ else
67
69
  fi
68
70
  ```
69
71
 
70
- ### Step 4: Initialize state.json for map workflow
71
-
72
- **CRITICAL**: Before proceeding, you MUST update state.json to indicate a map workflow is starting.
72
+ ### Step 4: Initialize session state for map workflow
73
73
 
74
- > ⚠️ **TIMESTAMP RULE**: Always use `run_command` tool to get the current timestamp. **Never construct timestamps manually** — this causes incorrect elapsed time display in `ocr progress`.
74
+ **CRITICAL**: Before proceeding, you MUST initialize the session in SQLite using `ocr state` commands.
75
75
 
76
- **First, get the current timestamp** (run this command):
76
+ If this is a **new session** (no prior review or map in this session):
77
77
  ```bash
78
- date -u +"%Y-%m-%dT%H:%M:%SZ"
78
+ ocr state init \
79
+ --session-id "$SESSION_ID" \
80
+ --branch "$BRANCH" \
81
+ --workflow-type map \
82
+ --session-dir "$SESSION_DIR"
79
83
  ```
80
84
 
81
- Use the **exact output** (e.g., `2026-01-29T13:45:22Z`) in the state.json below.
82
-
85
+ Then transition to the first map phase:
83
86
  ```bash
84
- STATE_FILE="$SESSION_DIR/state.json"
85
- CURRENT_TIME="{OUTPUT_FROM_DATE_COMMAND}" # Use actual output, not a placeholder
86
-
87
- # Read existing state if present, or create new
88
- if [ -f "$STATE_FILE" ]; then
89
- # Preserve started_at from existing session
90
- STARTED_AT=$(jq -r '.started_at // empty' "$STATE_FILE")
91
- STARTED_AT=${STARTED_AT:-$CURRENT_TIME}
92
- else
93
- STARTED_AT=$CURRENT_TIME
94
- fi
87
+ ocr state transition \
88
+ --phase "map-context" \
89
+ --phase-number 1 \
90
+ --current-map-run $CURRENT_RUN
91
+ ```
95
92
 
96
- # Write updated state with map workflow fields
97
- cat > "$STATE_FILE" << EOF
98
- {
99
- "session_id": "{session_id}",
100
- "workflow_type": "map",
101
- "status": "active",
102
- "current_phase": "map-context",
103
- "phase_number": 1,
104
- "current_map_run": $CURRENT_RUN,
105
- "started_at": "$STARTED_AT",
106
- "map_started_at": "$CURRENT_TIME",
107
- "updated_at": "$CURRENT_TIME"
108
- }
109
- EOF
93
+ If this is an **existing session** (e.g., a map after a prior review), the session already exists in SQLite — just call `ocr state transition` to switch to the map workflow:
94
+ ```bash
95
+ ocr state transition \
96
+ --phase "map-context" \
97
+ --phase-number 1 \
98
+ --current-map-run $CURRENT_RUN
110
99
  ```
111
100
 
112
- **Why `map_started_at` is required**: If this session previously had a review workflow, `started_at` will reflect when the review started, not the map. Setting `map_started_at` ensures `ocr progress` shows accurate elapsed time for the map workflow.
101
+ The CLI commands handle timestamp management automatically `map_started_at` is set when transitioning to a map phase, ensuring `ocr progress` shows accurate elapsed time even if the session had a prior review workflow.
113
102
 
114
103
  ### Step 5: Report to user
115
104
 
116
105
  ```
117
- 📍 Session: {session_id}
118
- 🗺️ Map run: {current_run}
119
- 📊 Current phase: {current_phase}
120
- 🔄 Action: [Starting fresh | Resuming from Phase X]
106
+ Session: {session_id}
107
+ Map run: {current_run}
108
+ Current phase: {current_phase}
109
+ Action: [Starting fresh | Resuming from Phase X]
121
110
  ```
122
111
 
123
112
  ---
124
113
 
125
114
  ## State Tracking
126
115
 
127
- At **every phase transition**, update `.ocr/sessions/{id}/state.json`:
128
-
129
- ```json
130
- {
131
- "session_id": "{id}",
132
- "workflow_type": "map",
133
- "status": "active",
134
- "current_phase": "flow-analysis",
135
- "phase_number": 3,
136
- "current_map_run": 1,
137
- "started_at": "{PRESERVE_ORIGINAL}",
138
- "map_started_at": "{SET_ONCE_ON_MAP_START}",
139
- "updated_at": "{CURRENT_ISO_TIMESTAMP}"
140
- }
116
+ At **every phase transition**, call `ocr state transition` with the `--current-map-run` flag:
117
+
118
+ ```bash
119
+ ocr state transition \
120
+ --phase "flow-analysis" \
121
+ --phase-number 3 \
122
+ --current-map-run $CURRENT_RUN
141
123
  ```
142
124
 
143
- **CRITICAL**:
144
- - Always include `"workflow_type": "map"` — this enables `ocr progress` to track map workflows.
145
- - Set `"map_started_at"` ONCE when starting a new map run — this ensures accurate elapsed time tracking even if the session had a prior review workflow.
125
+ This updates the session in SQLite and logs an orchestration event.
146
126
 
147
127
  **Map phase values**: `map-context`, `topology`, `flow-analysis`, `requirements-mapping`, `synthesis`, `complete`
148
128
 
@@ -152,6 +132,8 @@ At **every phase transition**, update `.ocr/sessions/{id}/state.json`:
152
132
 
153
133
  **Goal**: Build context from config + discovered files + user requirements.
154
134
 
135
+ **State**: Call `ocr state transition --phase "map-context" --phase-number 1 --current-map-run $CURRENT_RUN`
136
+
155
137
  This phase is **identical** to the review workflow's context discovery. See `references/context-discovery.md` for the complete algorithm.
156
138
 
157
139
  ### Steps
@@ -182,12 +164,12 @@ code-review-map:
182
164
 
183
165
  **Use these values** when spawning agents in Phase 3 and Phase 4.
184
166
 
185
- ### Phase 1 Checkpoint
167
+ ### Phase 1 Checkpoint
186
168
 
187
169
  - [ ] `discovered-standards.md` written (or reused from existing session)
188
170
  - [ ] If requirements provided: `requirements.md` written
189
171
  - [ ] Agent redundancy config loaded
190
- - [ ] `state.json` updated: `current_phase: "map-context"`
172
+ - [ ] `ocr state transition` called with `--phase "map-context"`
191
173
 
192
174
  ---
193
175
 
@@ -195,6 +177,8 @@ code-review-map:
195
177
 
196
178
  **Goal**: Enumerate changed files and identify logical structure.
197
179
 
180
+ **State**: Call `ocr state transition --phase "topology" --phase-number 2 --current-map-run $CURRENT_RUN`
181
+
198
182
  ### Steps
199
183
 
200
184
  1. **Get the changeset** (determine target from user request):
@@ -211,11 +195,11 @@ code-review-map:
211
195
  ```bash
212
196
  # Default: staged changes
213
197
  git diff --cached --name-only
214
-
198
+
215
199
  # Store canonical file list for completeness validation
216
200
  git diff --cached --name-only > /tmp/ocr-canonical-files.txt
217
201
  ```
218
-
202
+
219
203
  **CRITICAL**: Store this canonical file list. It's used for completeness validation in Phase 5.
220
204
 
221
205
  2. **Categorize each file**:
@@ -242,13 +226,13 @@ code-review-map:
242
226
  .ocr/sessions/{id}/map/runs/run-{n}/topology.md
243
227
  ```
244
228
 
245
- ### Phase 2 Checkpoint
229
+ ### Phase 2 Checkpoint
246
230
 
247
231
  - [ ] All changed files enumerated
248
232
  - [ ] Files categorized by type
249
233
  - [ ] Logical sections identified
250
234
  - [ ] `topology.md` written
251
- - [ ] `state.json` updated: `current_phase: "topology"`
235
+ - [ ] `ocr state transition` called with `--phase "topology"`
252
236
 
253
237
  ---
254
238
 
@@ -256,6 +240,8 @@ code-review-map:
256
240
 
257
241
  **Goal**: Trace upstream/downstream dependencies for each changed file.
258
242
 
243
+ **State**: Call `ocr state transition --phase "flow-analysis" --phase-number 3 --current-map-run $CURRENT_RUN`
244
+
259
245
  ### Steps
260
246
 
261
247
  1. **Spawn Flow Analysts** — spawn `FLOW_ANALYST_COUNT` agents (from config, default: 2)
@@ -288,13 +274,13 @@ For each analyst, provide:
288
274
 
289
275
  See `references/map-personas/flow-analyst.md` for persona details.
290
276
 
291
- ### Phase 3 Checkpoint
277
+ ### Phase 3 Checkpoint
292
278
 
293
279
  - [ ] Flow Analysts spawned (`FLOW_ANALYST_COUNT` from config)
294
280
  - [ ] All changed files have flow context
295
281
  - [ ] Findings aggregated
296
282
  - [ ] `flow-analysis.md` written
297
- - [ ] `state.json` updated: `current_phase: "flow-analysis"`
283
+ - [ ] `ocr state transition` called with `--phase "flow-analysis"`
298
284
 
299
285
  ---
300
286
 
@@ -302,6 +288,8 @@ See `references/map-personas/flow-analyst.md` for persona details.
302
288
 
303
289
  **Goal**: Map changes to requirements and identify coverage.
304
290
 
291
+ **State**: Call `ocr state transition --phase "requirements-mapping" --phase-number 4 --current-map-run $CURRENT_RUN`
292
+
305
293
  **Skip this phase** if no requirements were provided.
306
294
 
307
295
  ### Steps
@@ -328,13 +316,13 @@ See `references/map-personas/flow-analyst.md` for persona details.
328
316
  .ocr/sessions/{id}/map/runs/run-{n}/requirements-mapping.md
329
317
  ```
330
318
 
331
- ### Phase 4 Checkpoint
319
+ ### Phase 4 Checkpoint
332
320
 
333
321
  - [ ] Requirements Mappers spawned (if requirements exist)
334
322
  - [ ] Coverage matrix created
335
323
  - [ ] Gaps identified
336
324
  - [ ] `requirements-mapping.md` written
337
- - [ ] `state.json` updated: `current_phase: "requirements-mapping"`
325
+ - [ ] `ocr state transition` called with `--phase "requirements-mapping"`
338
326
 
339
327
  ---
340
328
 
@@ -342,6 +330,8 @@ See `references/map-personas/flow-analyst.md` for persona details.
342
330
 
343
331
  **Goal**: Combine all findings into the final Code Review Map optimized for reviewer workflow.
344
332
 
333
+ **State**: Call `ocr state transition --phase "synthesis" --phase-number 5 --current-map-run $CURRENT_RUN`
334
+
345
335
  ### Template Structure (in order)
346
336
 
347
337
  1. **Executive Summary** — Context first
@@ -350,8 +340,9 @@ See `references/map-personas/flow-analyst.md` for persona details.
350
340
  4. **Critical Review Focus** — High-value areas for human judgment
351
341
  5. **Manual Verification** — Tests to run before/during review
352
342
  6. **File Review** — Per-section file tracking (main tracking area)
353
- 7. **File Index** — Alphabetical reference
354
- 8. **Map Metadata** — Run info
343
+ 7. **Section Dependencies** — Cross-section dependency graph data
344
+ 8. **File Index** — Alphabetical reference
345
+ 9. **Map Metadata** — Run info
355
346
 
356
347
  ### Steps
357
348
 
@@ -396,18 +387,25 @@ See `references/map-personas/flow-analyst.md` for persona details.
396
387
  - Specific areas mapped to requirements/concerns
397
388
  - Do NOT do code review — just flag for reviewer attention
398
389
 
399
- 8. **Create File Index**:
390
+ 8. **Generate Section Dependencies**:
391
+ - Review flow analysis cross-file flows to identify section-to-section call chains
392
+ - For each pair of sections with meaningful dependencies, add a table row
393
+ - Direction: caller section → callee section
394
+ - Relationship should be a 3-8 word description (e.g., "Auth middleware protects routes")
395
+ - If sections are independent, leave the table body empty (headers only)
396
+
397
+ 9. **Create File Index**:
400
398
  - Alphabetical list of ALL changed files
401
399
  - Section reference for each
402
400
 
403
- 9. **Validate completeness**:
401
+ 10. **Validate completeness**:
404
402
  ```bash
405
403
  EXPECTED=$(git diff --cached --name-only | wc -l)
406
404
  MAPPED=$(grep -oE '\| `[^`]+` \|' map.md | wc -l)
407
405
  [ "$EXPECTED" -ne "$MAPPED" ] && echo "ERROR: Missing files!"
408
406
  ```
409
407
 
410
- 10. **Save final map**:
408
+ 11. **Save final map**:
411
409
  ```
412
410
  .ocr/sessions/{id}/map/runs/run-{n}/map.md
413
411
  ```
@@ -416,7 +414,7 @@ See `references/map-personas/flow-analyst.md` for persona details.
416
414
 
417
415
  See `references/map-template.md` for the complete template.
418
416
 
419
- ### Phase 5 Checkpoint
417
+ ### Phase 5 Checkpoint
420
418
 
421
419
  - [ ] Executive Summary with hypothesis
422
420
  - [ ] Questions & Clarifications populated
@@ -425,10 +423,11 @@ See `references/map-template.md` for the complete template.
425
423
  - [ ] Manual Verification tests generated (or omitted if docs-only)
426
424
  - [ ] All File Review sections with file tables
427
425
  - [ ] Review Suggestions per section (only where key things to flag)
426
+ - [ ] Section Dependencies table generated
428
427
  - [ ] File Index complete
429
428
  - [ ] Completeness validated (all files appear in tables)
430
429
  - [ ] `map.md` written
431
- - [ ] `state.json` updated: `current_phase: "synthesis"`
430
+ - [ ] `ocr state transition` called with `--phase "synthesis"`
432
431
 
433
432
  ---
434
433
 
@@ -436,6 +435,8 @@ See `references/map-template.md` for the complete template.
436
435
 
437
436
  **Goal**: Display the map to the user.
438
437
 
438
+ **State**: Call `ocr state transition --phase "complete" --phase-number 6 --current-map-run $CURRENT_RUN` after presenting.
439
+
439
440
  ### Steps
440
441
 
441
442
  1. **Read the final map**:
@@ -445,29 +446,31 @@ See `references/map-template.md` for the complete template.
445
446
 
446
447
  2. **Present to user** with summary:
447
448
  ```
448
- 🗺️ Code Review Map Generated
449
-
450
- 📍 Session: {session_id}
451
- 📁 Files mapped: {count}
452
- 📑 Sections: {section_count}
453
-
449
+ Code Review Map Generated
450
+
451
+ Session: {session_id}
452
+ Files mapped: {count}
453
+ Sections: {section_count}
454
+
454
455
  The map is saved at: .ocr/sessions/{id}/map/runs/run-{n}/map.md
455
-
456
+
456
457
  [Display map content]
457
458
  ```
458
459
 
459
460
  3. **Update state**:
460
- ```json
461
- {
462
- "current_phase": "map-complete",
463
- "phase_number": 6
464
- }
461
+ ```bash
462
+ ocr state transition \
463
+ --phase "complete" \
464
+ --phase-number 6 \
465
+ --current-map-run $CURRENT_RUN
465
466
  ```
466
467
 
467
- ### Phase 6 Checkpoint
468
+ > **Note**: Map completion does NOT close the session — the session stays `active` so further reviews or maps can be run.
469
+
470
+ ### Phase 6 Checkpoint
468
471
 
469
472
  - [ ] Map presented to user
470
- - [ ] `state.json` updated: `current_phase: "complete"`
473
+ - [ ] `ocr state transition` called with `--phase "complete"`
471
474
 
472
475
  ---
473
476
 
@@ -534,7 +537,7 @@ See `references/map-template.md` for the complete template.
534
537
  - **Purpose**: {what this section covers}
535
538
  - **Files**: `file1.ts`, `file2.ts`, `file3.ts`
536
539
  - **Entry Point**: `file1.ts`
537
- - **Review Order**: file1 file2 file3
540
+ - **Review Order**: file1 -> file2 -> file3
538
541
 
539
542
  ### Section 2: {Name}
540
543
  ...
@@ -586,7 +589,7 @@ Files that don't fit into logical sections:
586
589
 
587
590
  ### Flow 1: Authentication Request
588
591
  ```
589
- api/auth.ts services/auth.service.ts utils/token.ts db/users.ts
592
+ api/auth.ts -> services/auth.service.ts -> utils/token.ts -> db/users.ts
590
593
  ```
591
594
 
592
595
  ### Flow 2: ...
@@ -595,7 +598,7 @@ api/auth.ts → services/auth.service.ts → utils/token.ts → db/users.ts
595
598
 
596
599
  | File | Analyst 1 Section | Analyst 2 Section | Final |
597
600
  |------|-------------------|-------------------|-------|
598
- | `file1.ts` | Auth Flow | Auth Flow | Auth Flow |
601
+ | `file1.ts` | Auth Flow | Auth Flow | Auth Flow |
599
602
  | `file2.ts` | Auth Flow | API Layer | Auth Flow (majority) |
600
603
  ```
601
604
 
@@ -619,18 +622,18 @@ api/auth.ts → services/auth.service.ts → utils/token.ts → db/users.ts
619
622
 
620
623
  | Requirement | Status | Files | Confidence |
621
624
  |-------------|--------|-------|------------|
622
- | REQ-1 | Full | `auth.ts`, `oauth.ts` | High (2/2) |
623
- | REQ-2 | ⚠️ Partial | `session.ts` | Medium (1/2) |
624
- | REQ-3 | None | — | High (2/2) |
625
+ | REQ-1 | Full | `auth.ts`, `oauth.ts` | High (2/2) |
626
+ | REQ-2 | Partial | `session.ts` | Medium (1/2) |
627
+ | REQ-3 | None | — | High (2/2) |
625
628
 
626
629
  ## Per-Section Coverage
627
630
 
628
631
  ### Section 1: Authentication Flow
629
- - REQ-1: Full
630
- - REQ-2: ⚠️ Partial (missing cleanup)
632
+ - REQ-1: Full
633
+ - REQ-2: Partial (missing cleanup)
631
634
 
632
635
  ### Section 2: API Endpoints
633
- - REQ-3: Not addressed
636
+ - REQ-3: Not addressed
634
637
 
635
638
  ## Gaps
636
639
 
@@ -644,7 +647,7 @@ api/auth.ts → services/auth.service.ts → utils/token.ts → db/users.ts
644
647
 
645
648
  | Requirement | Mapper 1 | Mapper 2 | Final |
646
649
  |-------------|----------|----------|-------|
647
- | REQ-1 | Full | Full | Full |
650
+ | REQ-1 | Full | Full | Full |
648
651
  | REQ-2 | Partial | None | Partial (conservative) |
649
652
  ```
650
653
 
@@ -693,21 +696,21 @@ When multiple agents produce findings, aggregate as follows:
693
696
 
694
697
  If `git diff` returns empty:
695
698
  ```
696
- ⚠️ No changes detected. Please stage changes or specify a target.
699
+ WARNING: No changes detected. Please stage changes or specify a target.
697
700
  ```
698
701
 
699
702
  ### Missing Config
700
703
 
701
704
  If `.ocr/config.yaml` doesn't exist:
702
705
  ```
703
- ⚠️ OCR not configured. Run `ocr doctor` to check setup.
706
+ WARNING: OCR not configured. Run `ocr doctor` to check setup.
704
707
  ```
705
708
 
706
709
  ### Completeness Failure
707
710
 
708
711
  If map doesn't include all files:
709
712
  ```
710
- Map incomplete: {missing_count} files not mapped.
713
+ ERROR: Map incomplete: {missing_count} files not mapped.
711
714
  Missing: [list files]
712
715
 
713
716
  Re-running synthesis to include missing files...
@@ -8,7 +8,6 @@ Every OCR session creates files in `.ocr/sessions/{session-id}/`:
8
8
 
9
9
  ```
10
10
  .ocr/sessions/{YYYY-MM-DD}-{branch}/
11
- ├── state.json # Session state (REQUIRED)
12
11
  ├── discovered-standards.md # Merged project context (shared across rounds)
13
12
  ├── requirements.md # User-provided requirements (if any, shared)
14
13
  ├── context.md # Phase 2+3: Change summary + Tech Lead guidance (shared)
@@ -49,15 +48,15 @@ OCR uses a **round-first architecture** where all round-specific artifacts live
49
48
  - Subsequent `/ocr-review` on same day/branch creates `rounds/round-{n+1}/`
50
49
  - Previous rounds are preserved (never overwritten)
51
50
  - Each round has its own `discourse.md` and `final.md`
52
- - `state.json` tracks `current_round`; round metadata derived from filesystem
51
+ - SQLite tracks `current_round` via `ocr state show`; round metadata derived from filesystem
53
52
 
54
53
  **Shared vs per-round/run artifacts**:
55
54
  | Shared (session root) | Per-round (`rounds/round-{n}/`) | Per-run (`map/runs/run-{n}/`) |
56
55
  |----------------------|--------------------------------|-------------------------------|
57
- | `state.json` | `reviews/*.md` | `topology.md` |
58
- | `discovered-standards.md` | `discourse.md` | `flow-analysis.md` |
59
- | `requirements.md` | `final.md` | `requirements-mapping.md` |
60
- | `context.md` | | `map.md` |
56
+ | `discovered-standards.md` | `reviews/*.md` | `topology.md` |
57
+ | `requirements.md` | `discourse.md` | `flow-analysis.md` |
58
+ | `context.md` | `final.md` | `requirements-mapping.md` |
59
+ | | | `map.md` |
61
60
 
62
61
  **When to use multiple rounds**:
63
62
  - Author addresses feedback and requests re-review
@@ -73,7 +72,7 @@ OCR uses a **run-based architecture** for maps, parallel to review rounds.
73
72
  - Subsequent `/ocr-map` on same day/branch creates `map/runs/run-{n+1}/`
74
73
  - Previous runs are preserved (never overwritten)
75
74
  - Each run produces a complete `map.md`
76
- - `state.json` tracks `current_map_run`; run metadata derived from filesystem
75
+ - SQLite tracks `current_map_run` via `ocr state show`; run metadata derived from filesystem
77
76
 
78
77
  **Map artifacts per run**:
79
78
  | File | Phase | Description |
@@ -94,7 +93,6 @@ OCR uses a **run-based architecture** for maps, parallel to review rounds.
94
93
 
95
94
  | File | Phase | Description | Used By |
96
95
  |------|-------|-------------|---------|
97
- | `state.json` | 1 | Session state for progress tracking | CLI, resume logic |
98
96
  | `discovered-standards.md` | 1 | Merged project context from config + references | All reviewers |
99
97
  | `context.md` | 2 | Change summary, diff analysis, Tech Lead guidance | All reviewers |
100
98
  | `rounds/round-{n}/reviews/{type}-{n}.md` | 4 | Individual reviewer outputs | Discourse, Synthesis |
@@ -135,18 +133,18 @@ rounds/round-1/reviews/performance-1.md # Custom reviewer
135
133
 
136
134
  | Phase | Phase Name | Files to Create/Update |
137
135
  |-------|------------|------------------------|
138
- | 1 | Context Discovery | `state.json`, `discovered-standards.md`, `requirements.md` (if provided) |
139
- | 2 | Change Analysis | `context.md`, update `state.json` |
140
- | 3 | Tech Lead Analysis | Update `context.md` with guidance, update `state.json` |
141
- | 4 | Parallel Reviews | `rounds/round-{n}/reviews/{type}-{n}.md` for each reviewer, update `state.json` |
142
- | 5 | Aggregation | (Inline analysis), update `state.json` |
143
- | 6 | Discourse | `rounds/round-{n}/discourse.md`, update `state.json` |
144
- | 7 | Synthesis | `rounds/round-{n}/final.md`, update `state.json` |
145
- | 8 | Presentation | Set `state.json` status to `"closed"` |
136
+ | 1 | Context Discovery | `discovered-standards.md`, `requirements.md` (if provided) |
137
+ | 2 | Change Analysis | `context.md`, call `ocr state transition` |
138
+ | 3 | Tech Lead Analysis | Update `context.md` with guidance, call `ocr state transition` |
139
+ | 4 | Parallel Reviews | `rounds/round-{n}/reviews/{type}-{n}.md` for each reviewer, call `ocr state transition` |
140
+ | 5 | Aggregation | (Inline analysis), call `ocr state transition` |
141
+ | 6 | Discourse | `rounds/round-{n}/discourse.md`, call `ocr state transition` |
142
+ | 7 | Synthesis | `rounds/round-{n}/final.md`, call `ocr state transition` |
143
+ | 8 | Presentation | Call `ocr state close` |
146
144
 
147
145
  ## State Transitions and File Validation
148
146
 
149
- When updating `state.json`, verify the corresponding file exists:
147
+ When calling `ocr state transition`, verify the corresponding file exists:
150
148
 
151
149
  | Phase | Verify file exists |
152
150
  |---------------------------|-------------------|
@@ -180,30 +178,9 @@ SESSION_ID="$(date +%Y-%m-%d)-$(git branch --show-current | tr '/' '-')"
180
178
 
181
179
  ## File Content Requirements
182
180
 
183
- ### state.json (Minimal Schema)
184
-
185
- ```json
186
- {
187
- "session_id": "{session-id}",
188
- "status": "active",
189
- "current_phase": "{phase-name}",
190
- "phase_number": 4,
191
- "current_round": 1,
192
- "started_at": "{ISO-8601-timestamp}",
193
- "round_started_at": "{ISO-8601-timestamp}",
194
- "updated_at": "{ISO-8601-timestamp}"
195
- }
196
- ```
197
-
198
- > **Note**: `round_started_at` is set when starting a new round (> 1) for accurate per-round timing display.
199
-
200
- **Derived from filesystem** (not stored in state.json):
201
- - Round count: enumerate `rounds/round-*/` directories
202
- - Round completion: check for `final.md` in round directory
203
- - Reviewers in round: list files in `rounds/round-{n}/reviews/`
204
- - Discourse complete: check for `discourse.md` in round directory
181
+ ### Session State
205
182
 
206
- See `references/session-state.md` for complete state management details.
183
+ Session state is stored in SQLite at `.ocr/data/ocr.db`. Use `ocr state show` to inspect current state. See `session-state.md` for the full data model.
207
184
 
208
185
  ### Reviewer Files
209
186
 
@@ -233,14 +210,14 @@ The `ocr progress` CLI depends on these exact file names:
233
210
 
234
211
  | CLI Feature | Files Read |
235
212
  |-------------|-----------|
236
- | Session detection | `state.json` |
237
- | Phase tracking | `state.json` → `current_phase` |
238
- | Current round | `state.json` → `current_round` (reconciled with filesystem) |
213
+ | Session detection | `ocr state show` / SQLite |
214
+ | Phase tracking | SQLite → `current_phase` |
215
+ | Current round | SQLite → `current_round` (reconciled with filesystem) |
239
216
  | Reviewer progress | `rounds/round-{n}/reviews/*.md` file existence |
240
217
  | Round completion | `rounds/round-{n}/final.md` existence |
241
- | Elapsed time | `state.json` → `started_at` |
218
+ | Elapsed time | SQLite → `started_at` |
242
219
 
243
- **Filesystem as truth**: The CLI derives round metadata from the filesystem, using `state.json` as a hint. If state.json is missing or inconsistent, the CLI reconstructs state by:
220
+ **Filesystem as truth**: The CLI derives round metadata from the filesystem, using SQLite as the primary state store. Round-level details are always reconciled against the filesystem by:
244
221
  1. Enumerating `rounds/round-*/` to count rounds
245
222
  2. Checking `final.md` presence to determine completion
246
223
  3. Listing `reviews/*.md` to identify reviewers