@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.
- package/README.md +35 -1
- package/commands/address.md +117 -0
- package/commands/map.md +170 -0
- package/commands/post.md +14 -3
- package/commands/review.md +25 -10
- package/commands/show.md +1 -1
- package/commands/translate-review-to-single-human.md +116 -0
- package/package.json +1 -1
- package/skills/ocr/AGENTS.md +5 -1
- package/skills/ocr/SKILL.md +12 -1
- package/skills/ocr/assets/config.yaml +12 -0
- package/skills/ocr/references/map-agent-task.md +252 -0
- package/skills/ocr/references/map-personas/architect.md +82 -0
- package/skills/ocr/references/map-personas/flow-analyst.md +94 -0
- package/skills/ocr/references/map-personas/requirements-mapper.md +119 -0
- package/skills/ocr/references/map-template.md +273 -0
- package/skills/ocr/references/map-workflow.md +717 -0
- package/skills/ocr/references/session-files.md +57 -47
- package/skills/ocr/references/session-state.md +145 -75
- package/skills/ocr/references/setup-guard.md +20 -0
- package/skills/ocr/references/workflow.md +155 -121
|
@@ -0,0 +1,717 @@
|
|
|
1
|
+
# OCR Map Workflow
|
|
2
|
+
|
|
3
|
+
Complete 6-phase process for generating a Code Review Map.
|
|
4
|
+
|
|
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.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
The Code Review Map is a **human-facing navigation tool** for large, complex changesets. It uses multi-agent orchestration to analyze changes and produce a structured document that helps humans:
|
|
14
|
+
- Understand the overall approach and intent
|
|
15
|
+
- Navigate changes in logical order
|
|
16
|
+
- Track review progress with checkboxes
|
|
17
|
+
- See how changes map to requirements (if provided)
|
|
18
|
+
|
|
19
|
+
**Primary audience**: Humans (the last line of defense on code changes)
|
|
20
|
+
|
|
21
|
+
**When to use**: Extremely large changesets that would take multiple hours for human review.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Phase 0: Session State Verification
|
|
26
|
+
|
|
27
|
+
Before starting ANY work, verify the current session state.
|
|
28
|
+
|
|
29
|
+
### Step 1: Check for existing session
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Get current branch and sanitize for filesystem (replace / with -)
|
|
33
|
+
BRANCH_RAW=$(git branch --show-current)
|
|
34
|
+
BRANCH=$(echo "$BRANCH_RAW" | tr '/' '-')
|
|
35
|
+
DATE=$(date +%Y-%m-%d)
|
|
36
|
+
SESSION_DIR=".ocr/sessions/${DATE}-${BRANCH}"
|
|
37
|
+
|
|
38
|
+
ls -la "$SESSION_DIR" 2>/dev/null
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Step 2: If `--fresh` flag provided
|
|
42
|
+
|
|
43
|
+
Delete existing map artifacts and start fresh:
|
|
44
|
+
```bash
|
|
45
|
+
rm -rf "$SESSION_DIR/map"
|
|
46
|
+
mkdir -p "$SESSION_DIR/map/runs/run-1"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Step 3: Map Run Resolution
|
|
50
|
+
|
|
51
|
+
Determine which map run to use (parallel to review rounds):
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
MAP_DIR="$SESSION_DIR/map/runs"
|
|
55
|
+
|
|
56
|
+
if [ ! -d "$MAP_DIR" ]; then
|
|
57
|
+
CURRENT_RUN=1
|
|
58
|
+
mkdir -p "$MAP_DIR/run-1"
|
|
59
|
+
else
|
|
60
|
+
HIGHEST=$(ls -1 "$MAP_DIR" | grep -E '^run-[0-9]+$' | sed 's/run-//' | sort -n | tail -1)
|
|
61
|
+
HIGHEST=${HIGHEST:-0}
|
|
62
|
+
|
|
63
|
+
if [ -f "$MAP_DIR/run-$HIGHEST/map.md" ]; then
|
|
64
|
+
CURRENT_RUN=$((HIGHEST + 1))
|
|
65
|
+
mkdir -p "$MAP_DIR/run-$CURRENT_RUN"
|
|
66
|
+
else
|
|
67
|
+
CURRENT_RUN=$HIGHEST
|
|
68
|
+
fi
|
|
69
|
+
fi
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Step 4: Initialize session state for map workflow
|
|
73
|
+
|
|
74
|
+
**CRITICAL**: Before proceeding, you MUST initialize the session in SQLite using `ocr state` commands.
|
|
75
|
+
|
|
76
|
+
If this is a **new session** (no prior review or map in this session):
|
|
77
|
+
```bash
|
|
78
|
+
ocr state init \
|
|
79
|
+
--session-id "$SESSION_ID" \
|
|
80
|
+
--branch "$BRANCH" \
|
|
81
|
+
--workflow-type map \
|
|
82
|
+
--session-dir "$SESSION_DIR"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Then transition to the first map phase:
|
|
86
|
+
```bash
|
|
87
|
+
ocr state transition \
|
|
88
|
+
--phase "map-context" \
|
|
89
|
+
--phase-number 1 \
|
|
90
|
+
--current-map-run $CURRENT_RUN
|
|
91
|
+
```
|
|
92
|
+
|
|
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
|
|
99
|
+
```
|
|
100
|
+
|
|
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.
|
|
102
|
+
|
|
103
|
+
### Step 5: Report to user
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
Session: {session_id}
|
|
107
|
+
Map run: {current_run}
|
|
108
|
+
Current phase: {current_phase}
|
|
109
|
+
Action: [Starting fresh | Resuming from Phase X]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## State Tracking
|
|
115
|
+
|
|
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
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
This updates the session in SQLite and logs an orchestration event.
|
|
126
|
+
|
|
127
|
+
**Map phase values**: `map-context`, `topology`, `flow-analysis`, `requirements-mapping`, `synthesis`, `complete`
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Phase 1: Context Discovery (Shared with Review)
|
|
132
|
+
|
|
133
|
+
**Goal**: Build context from config + discovered files + user requirements.
|
|
134
|
+
|
|
135
|
+
**State**: Call `ocr state transition --phase "map-context" --phase-number 1 --current-map-run $CURRENT_RUN`
|
|
136
|
+
|
|
137
|
+
This phase is **identical** to the review workflow's context discovery. See `references/context-discovery.md` for the complete algorithm.
|
|
138
|
+
|
|
139
|
+
### Steps
|
|
140
|
+
|
|
141
|
+
1. **Load OCR Configuration** — Read `.ocr/config.yaml`
|
|
142
|
+
2. **Pull OpenSpec Context** — If enabled, read specs and active changes
|
|
143
|
+
3. **Discover Reference Files** — AGENTS.md, CLAUDE.md, etc.
|
|
144
|
+
4. **Gather Requirements** — If user provided specs/proposals/tickets
|
|
145
|
+
5. **Merge Into discovered-standards.md**
|
|
146
|
+
|
|
147
|
+
### Map-Specific: Load Redundancy Config
|
|
148
|
+
|
|
149
|
+
Read `code-review-map` section from `.ocr/config.yaml`:
|
|
150
|
+
|
|
151
|
+
```yaml
|
|
152
|
+
code-review-map:
|
|
153
|
+
agents:
|
|
154
|
+
flow_analysts: 2 # Range: 1-10, default: 2
|
|
155
|
+
requirements_mappers: 2 # Range: 1-10, default: 2
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Parsing Logic**:
|
|
159
|
+
1. Read `.ocr/config.yaml`
|
|
160
|
+
2. Extract `code-review-map.agents.flow_analysts` → store as `FLOW_ANALYST_COUNT`
|
|
161
|
+
3. Extract `code-review-map.agents.requirements_mappers` → store as `REQ_MAPPER_COUNT`
|
|
162
|
+
4. If section is missing or commented out, use defaults: `FLOW_ANALYST_COUNT=2`, `REQ_MAPPER_COUNT=2`
|
|
163
|
+
5. Clamp values to range 1-10
|
|
164
|
+
|
|
165
|
+
**Use these values** when spawning agents in Phase 3 and Phase 4.
|
|
166
|
+
|
|
167
|
+
### Phase 1 Checkpoint
|
|
168
|
+
|
|
169
|
+
- [ ] `discovered-standards.md` written (or reused from existing session)
|
|
170
|
+
- [ ] If requirements provided: `requirements.md` written
|
|
171
|
+
- [ ] Agent redundancy config loaded
|
|
172
|
+
- [ ] `ocr state transition` called with `--phase "map-context"`
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Phase 2: Topology Analysis (Map Architect)
|
|
177
|
+
|
|
178
|
+
**Goal**: Enumerate changed files and identify logical structure.
|
|
179
|
+
|
|
180
|
+
**State**: Call `ocr state transition --phase "topology" --phase-number 2 --current-map-run $CURRENT_RUN`
|
|
181
|
+
|
|
182
|
+
### Steps
|
|
183
|
+
|
|
184
|
+
1. **Get the changeset** (determine target from user request):
|
|
185
|
+
|
|
186
|
+
| Target | Command |
|
|
187
|
+
|--------|---------|
|
|
188
|
+
| Staged changes (default) | `git diff --cached --name-only` |
|
|
189
|
+
| Unstaged changes | `git diff --name-only` |
|
|
190
|
+
| Specific commit | `git diff {commit}^ {commit} --name-only` |
|
|
191
|
+
| Commit range | `git diff {from}..{to} --name-only` |
|
|
192
|
+
| Branch vs main | `git diff main...{branch} --name-only` |
|
|
193
|
+
| PR (via gh CLI) | `gh pr diff {number} --name-only` |
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Default: staged changes
|
|
197
|
+
git diff --cached --name-only
|
|
198
|
+
|
|
199
|
+
# Store canonical file list for completeness validation
|
|
200
|
+
git diff --cached --name-only > /tmp/ocr-canonical-files.txt
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**CRITICAL**: Store this canonical file list. It's used for completeness validation in Phase 5.
|
|
204
|
+
|
|
205
|
+
2. **Categorize each file**:
|
|
206
|
+
- Entry points (routes, handlers, CLI, UI components)
|
|
207
|
+
- Core logic (business logic, services, domain)
|
|
208
|
+
- Infrastructure (config, utilities, shared)
|
|
209
|
+
- Tests
|
|
210
|
+
- Documentation
|
|
211
|
+
|
|
212
|
+
3. **Identify logical sections**:
|
|
213
|
+
- Group by feature boundary
|
|
214
|
+
- Group by architectural layer
|
|
215
|
+
- Group by execution flow
|
|
216
|
+
- Group by concern (security, performance)
|
|
217
|
+
|
|
218
|
+
4. **Determine review order** within sections:
|
|
219
|
+
- Entry points first
|
|
220
|
+
- Core implementations next
|
|
221
|
+
- Supporting files
|
|
222
|
+
- Tests last
|
|
223
|
+
|
|
224
|
+
5. **Save topology to session**:
|
|
225
|
+
```
|
|
226
|
+
.ocr/sessions/{id}/map/runs/run-{n}/topology.md
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Phase 2 Checkpoint
|
|
230
|
+
|
|
231
|
+
- [ ] All changed files enumerated
|
|
232
|
+
- [ ] Files categorized by type
|
|
233
|
+
- [ ] Logical sections identified
|
|
234
|
+
- [ ] `topology.md` written
|
|
235
|
+
- [ ] `ocr state transition` called with `--phase "topology"`
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Phase 3: Flow Tracing (Flow Analysts)
|
|
240
|
+
|
|
241
|
+
**Goal**: Trace upstream/downstream dependencies for each changed file.
|
|
242
|
+
|
|
243
|
+
**State**: Call `ocr state transition --phase "flow-analysis" --phase-number 3 --current-map-run $CURRENT_RUN`
|
|
244
|
+
|
|
245
|
+
### Steps
|
|
246
|
+
|
|
247
|
+
1. **Spawn Flow Analysts** — spawn `FLOW_ANALYST_COUNT` agents (from config, default: 2)
|
|
248
|
+
|
|
249
|
+
2. **Assign files** to each analyst (can overlap for coverage)
|
|
250
|
+
|
|
251
|
+
3. **Each analyst traces**:
|
|
252
|
+
- Upstream: What calls this code?
|
|
253
|
+
- Downstream: What does this code call?
|
|
254
|
+
- Related: Tests, config, siblings
|
|
255
|
+
|
|
256
|
+
4. **Collect findings** from all analysts
|
|
257
|
+
|
|
258
|
+
5. **Aggregate with redundancy validation**:
|
|
259
|
+
- Findings from multiple analysts = high confidence
|
|
260
|
+
- Unique findings = lower confidence but still valid
|
|
261
|
+
|
|
262
|
+
6. **Save flow analysis**:
|
|
263
|
+
```
|
|
264
|
+
.ocr/sessions/{id}/map/runs/run-{n}/flow-analysis.md
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Spawning Flow Analysts
|
|
268
|
+
|
|
269
|
+
For each analyst, provide:
|
|
270
|
+
- Their persona (`references/map-personas/flow-analyst.md`)
|
|
271
|
+
- Discovered standards
|
|
272
|
+
- Assigned files to trace
|
|
273
|
+
- Instructions to explore freely
|
|
274
|
+
|
|
275
|
+
See `references/map-personas/flow-analyst.md` for persona details.
|
|
276
|
+
|
|
277
|
+
### Phase 3 Checkpoint
|
|
278
|
+
|
|
279
|
+
- [ ] Flow Analysts spawned (`FLOW_ANALYST_COUNT` from config)
|
|
280
|
+
- [ ] All changed files have flow context
|
|
281
|
+
- [ ] Findings aggregated
|
|
282
|
+
- [ ] `flow-analysis.md` written
|
|
283
|
+
- [ ] `ocr state transition` called with `--phase "flow-analysis"`
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Phase 4: Requirements Mapping (If Provided)
|
|
288
|
+
|
|
289
|
+
**Goal**: Map changes to requirements and identify coverage.
|
|
290
|
+
|
|
291
|
+
**State**: Call `ocr state transition --phase "requirements-mapping" --phase-number 4 --current-map-run $CURRENT_RUN`
|
|
292
|
+
|
|
293
|
+
**Skip this phase** if no requirements were provided.
|
|
294
|
+
|
|
295
|
+
### Steps
|
|
296
|
+
|
|
297
|
+
1. **Spawn Requirements Mappers** — spawn `REQ_MAPPER_COUNT` agents (from config, default: 2)
|
|
298
|
+
|
|
299
|
+
2. **Provide context**:
|
|
300
|
+
- Requirements from `requirements.md`
|
|
301
|
+
- Changed files and their purposes (from topology)
|
|
302
|
+
- Flow context (from Phase 3)
|
|
303
|
+
|
|
304
|
+
3. **Each mapper**:
|
|
305
|
+
- Parses requirements into discrete items
|
|
306
|
+
- Maps each change to relevant requirements
|
|
307
|
+
- Identifies coverage status (full/partial/none)
|
|
308
|
+
- Notes gaps and deviations
|
|
309
|
+
|
|
310
|
+
4. **Aggregate findings**:
|
|
311
|
+
- Consistent mappings = high confidence
|
|
312
|
+
- Divergent mappings = flag for human review
|
|
313
|
+
|
|
314
|
+
5. **Save requirements mapping**:
|
|
315
|
+
```
|
|
316
|
+
.ocr/sessions/{id}/map/runs/run-{n}/requirements-mapping.md
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Phase 4 Checkpoint
|
|
320
|
+
|
|
321
|
+
- [ ] Requirements Mappers spawned (if requirements exist)
|
|
322
|
+
- [ ] Coverage matrix created
|
|
323
|
+
- [ ] Gaps identified
|
|
324
|
+
- [ ] `requirements-mapping.md` written
|
|
325
|
+
- [ ] `ocr state transition` called with `--phase "requirements-mapping"`
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Phase 5: Map Synthesis (Map Architect)
|
|
330
|
+
|
|
331
|
+
**Goal**: Combine all findings into the final Code Review Map optimized for reviewer workflow.
|
|
332
|
+
|
|
333
|
+
**State**: Call `ocr state transition --phase "synthesis" --phase-number 5 --current-map-run $CURRENT_RUN`
|
|
334
|
+
|
|
335
|
+
### Template Structure (in order)
|
|
336
|
+
|
|
337
|
+
1. **Executive Summary** — Context first
|
|
338
|
+
2. **Questions & Clarifications** — Ambiguities to resolve with author
|
|
339
|
+
3. **Requirements Coverage** — Coverage matrix (if requirements provided)
|
|
340
|
+
4. **Critical Review Focus** — High-value areas for human judgment
|
|
341
|
+
5. **Manual Verification** — Tests to run before/during review
|
|
342
|
+
6. **File Review** — Per-section file tracking (main tracking area)
|
|
343
|
+
7. **Section Dependencies** — Cross-section dependency graph data
|
|
344
|
+
8. **File Index** — Alphabetical reference
|
|
345
|
+
9. **Map Metadata** — Run info
|
|
346
|
+
|
|
347
|
+
### Steps
|
|
348
|
+
|
|
349
|
+
1. **Load all artifacts**:
|
|
350
|
+
- `topology.md` — Section structure
|
|
351
|
+
- `flow-analysis.md` — Dependency context
|
|
352
|
+
- `requirements-mapping.md` — Coverage annotations (if exists)
|
|
353
|
+
|
|
354
|
+
2. **Construct Executive Summary**:
|
|
355
|
+
- 1-2 paragraph narrative hypothesis
|
|
356
|
+
- Key approaches observed
|
|
357
|
+
- Frame as hypothesis, not assertion
|
|
358
|
+
|
|
359
|
+
3. **Gather Questions & Clarifications**:
|
|
360
|
+
- Extract ambiguities from requirements mapping
|
|
361
|
+
- List assumptions made during mapping
|
|
362
|
+
- Include questions about deferred work or unclear intent
|
|
363
|
+
|
|
364
|
+
4. **Build Requirements Coverage** (if requirements provided):
|
|
365
|
+
- Coverage matrix with status indicators
|
|
366
|
+
- Note any gaps
|
|
367
|
+
|
|
368
|
+
5. **Generate Critical Review Focus**:
|
|
369
|
+
- Identify areas where human judgment adds value
|
|
370
|
+
- Focus on: business logic, security, edge cases, architectural decisions
|
|
371
|
+
- Map each to requirement or concern
|
|
372
|
+
- Do NOT perform code review — just flag areas for attention
|
|
373
|
+
|
|
374
|
+
6. **Generate Manual Verification**:
|
|
375
|
+
- **Critical Path**: Happy-path tests from requirements
|
|
376
|
+
- **Edge Cases & Error Handling**: From implementation analysis
|
|
377
|
+
- **Non-Functional**: Performance, security checks
|
|
378
|
+
- Omit only if changeset is purely docs/config
|
|
379
|
+
|
|
380
|
+
7. **Build File Review sections**:
|
|
381
|
+
For each section from topology:
|
|
382
|
+
- Narrative hypothesis (1-2 sentences)
|
|
383
|
+
- File table with `Done` column (empty, reviewer marks `X`)
|
|
384
|
+
- Flow summary
|
|
385
|
+
- Requirements coverage
|
|
386
|
+
- **Review Suggestions** (only if key things to watch for):
|
|
387
|
+
- Specific areas mapped to requirements/concerns
|
|
388
|
+
- Do NOT do code review — just flag for reviewer attention
|
|
389
|
+
|
|
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**:
|
|
398
|
+
- Alphabetical list of ALL changed files
|
|
399
|
+
- Section reference for each
|
|
400
|
+
|
|
401
|
+
10. **Validate completeness**:
|
|
402
|
+
```bash
|
|
403
|
+
EXPECTED=$(git diff --cached --name-only | wc -l)
|
|
404
|
+
MAPPED=$(grep -oE '\| `[^`]+` \|' map.md | wc -l)
|
|
405
|
+
[ "$EXPECTED" -ne "$MAPPED" ] && echo "ERROR: Missing files!"
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
11. **Save final map**:
|
|
409
|
+
```
|
|
410
|
+
.ocr/sessions/{id}/map/runs/run-{n}/map.md
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Map Output Format
|
|
414
|
+
|
|
415
|
+
See `references/map-template.md` for the complete template.
|
|
416
|
+
|
|
417
|
+
### Phase 5 Checkpoint
|
|
418
|
+
|
|
419
|
+
- [ ] Executive Summary with hypothesis
|
|
420
|
+
- [ ] Questions & Clarifications populated
|
|
421
|
+
- [ ] Requirements Coverage matrix (if applicable)
|
|
422
|
+
- [ ] Critical Review Focus areas identified
|
|
423
|
+
- [ ] Manual Verification tests generated (or omitted if docs-only)
|
|
424
|
+
- [ ] All File Review sections with file tables
|
|
425
|
+
- [ ] Review Suggestions per section (only where key things to flag)
|
|
426
|
+
- [ ] Section Dependencies table generated
|
|
427
|
+
- [ ] File Index complete
|
|
428
|
+
- [ ] Completeness validated (all files appear in tables)
|
|
429
|
+
- [ ] `map.md` written
|
|
430
|
+
- [ ] `ocr state transition` called with `--phase "synthesis"`
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## Phase 6: Present
|
|
435
|
+
|
|
436
|
+
**Goal**: Display the map to the user.
|
|
437
|
+
|
|
438
|
+
**State**: Call `ocr state transition --phase "complete" --phase-number 6 --current-map-run $CURRENT_RUN` after presenting.
|
|
439
|
+
|
|
440
|
+
### Steps
|
|
441
|
+
|
|
442
|
+
1. **Read the final map**:
|
|
443
|
+
```bash
|
|
444
|
+
cat .ocr/sessions/{id}/map/runs/run-{n}/map.md
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
2. **Present to user** with summary:
|
|
448
|
+
```
|
|
449
|
+
Code Review Map Generated
|
|
450
|
+
|
|
451
|
+
Session: {session_id}
|
|
452
|
+
Files mapped: {count}
|
|
453
|
+
Sections: {section_count}
|
|
454
|
+
|
|
455
|
+
The map is saved at: .ocr/sessions/{id}/map/runs/run-{n}/map.md
|
|
456
|
+
|
|
457
|
+
[Display map content]
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
3. **Update state**:
|
|
461
|
+
```bash
|
|
462
|
+
ocr state transition \
|
|
463
|
+
--phase "complete" \
|
|
464
|
+
--phase-number 6 \
|
|
465
|
+
--current-map-run $CURRENT_RUN
|
|
466
|
+
```
|
|
467
|
+
|
|
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
|
|
471
|
+
|
|
472
|
+
- [ ] Map presented to user
|
|
473
|
+
- [ ] `ocr state transition` called with `--phase "complete"`
|
|
474
|
+
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
## Artifact Summary
|
|
478
|
+
|
|
479
|
+
| Phase | Artifact Created |
|
|
480
|
+
|-------|------------------|
|
|
481
|
+
| 1 | `discovered-standards.md`, `requirements.md` (if provided) |
|
|
482
|
+
| 2 | `map/runs/run-{n}/topology.md` |
|
|
483
|
+
| 3 | `map/runs/run-{n}/flow-analysis.md` |
|
|
484
|
+
| 4 | `map/runs/run-{n}/requirements-mapping.md` (if requirements) |
|
|
485
|
+
| 5 | `map/runs/run-{n}/map.md` |
|
|
486
|
+
| 6 | (presentation only) |
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
## Intermediate Artifact Templates
|
|
491
|
+
|
|
492
|
+
### topology.md Format
|
|
493
|
+
|
|
494
|
+
```markdown
|
|
495
|
+
# Topology Analysis
|
|
496
|
+
|
|
497
|
+
**Generated**: {timestamp}
|
|
498
|
+
**Files**: {count} changed files
|
|
499
|
+
|
|
500
|
+
## Canonical File List
|
|
501
|
+
|
|
502
|
+
```
|
|
503
|
+
{complete list from git diff --name-only}
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
## File Categorization
|
|
507
|
+
|
|
508
|
+
### Entry Points
|
|
509
|
+
| File | Type | Description |
|
|
510
|
+
|------|------|-------------|
|
|
511
|
+
| `api/auth.ts` | API Route | Authentication endpoints |
|
|
512
|
+
| `cli/index.ts` | CLI Command | Main CLI entry |
|
|
513
|
+
|
|
514
|
+
### Core Logic
|
|
515
|
+
| File | Type | Description |
|
|
516
|
+
|------|------|-------------|
|
|
517
|
+
| `services/auth.service.ts` | Service | Auth business logic |
|
|
518
|
+
|
|
519
|
+
### Infrastructure
|
|
520
|
+
| File | Type | Description |
|
|
521
|
+
|------|------|-------------|
|
|
522
|
+
| `utils/helpers.ts` | Utility | Shared helpers |
|
|
523
|
+
|
|
524
|
+
### Tests
|
|
525
|
+
| File | Coverage For |
|
|
526
|
+
|------|--------------|
|
|
527
|
+
| `tests/auth.test.ts` | `services/auth.service.ts` |
|
|
528
|
+
|
|
529
|
+
### Documentation
|
|
530
|
+
| File | Description |
|
|
531
|
+
|------|-------------|
|
|
532
|
+
| `README.md` | Project readme |
|
|
533
|
+
|
|
534
|
+
## Proposed Sections
|
|
535
|
+
|
|
536
|
+
### Section 1: {Name}
|
|
537
|
+
- **Purpose**: {what this section covers}
|
|
538
|
+
- **Files**: `file1.ts`, `file2.ts`, `file3.ts`
|
|
539
|
+
- **Entry Point**: `file1.ts`
|
|
540
|
+
- **Review Order**: file1 -> file2 -> file3
|
|
541
|
+
|
|
542
|
+
### Section 2: {Name}
|
|
543
|
+
...
|
|
544
|
+
|
|
545
|
+
## Unrelated Files
|
|
546
|
+
|
|
547
|
+
Files that don't fit into logical sections:
|
|
548
|
+
- `misc/cleanup.ts` — Opportunistic refactor, unrelated to main changes
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
### flow-analysis.md Format
|
|
552
|
+
|
|
553
|
+
```markdown
|
|
554
|
+
# Flow Analysis
|
|
555
|
+
|
|
556
|
+
**Generated**: {timestamp}
|
|
557
|
+
**Analysts**: {count} (redundancy: {n}x)
|
|
558
|
+
|
|
559
|
+
## Aggregated Findings
|
|
560
|
+
|
|
561
|
+
### File: `path/to/file1.ts`
|
|
562
|
+
|
|
563
|
+
**Confidence**: High (found by 2/2 analysts)
|
|
564
|
+
|
|
565
|
+
#### Upstream
|
|
566
|
+
| Caller | Location | Context |
|
|
567
|
+
|--------|----------|---------|
|
|
568
|
+
| `handleRequest()` | `api/routes.ts:42` | API entry point |
|
|
569
|
+
|
|
570
|
+
#### Downstream
|
|
571
|
+
| Callee | Location | Context |
|
|
572
|
+
|--------|----------|---------|
|
|
573
|
+
| `validateToken()` | `auth/validator.ts:15` | Token validation |
|
|
574
|
+
|
|
575
|
+
#### Related Files
|
|
576
|
+
- `tests/file1.test.ts` — Unit tests
|
|
577
|
+
- `config/auth.yaml` — Configuration
|
|
578
|
+
|
|
579
|
+
#### Section Assignment
|
|
580
|
+
**Proposed**: Section 1 (Authentication Flow)
|
|
581
|
+
**Rationale**: Entry point for auth, calls auth services
|
|
582
|
+
|
|
583
|
+
---
|
|
584
|
+
|
|
585
|
+
### File: `path/to/file2.ts`
|
|
586
|
+
...
|
|
587
|
+
|
|
588
|
+
## Cross-File Flows
|
|
589
|
+
|
|
590
|
+
### Flow 1: Authentication Request
|
|
591
|
+
```
|
|
592
|
+
api/auth.ts -> services/auth.service.ts -> utils/token.ts -> db/users.ts
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
### Flow 2: ...
|
|
596
|
+
|
|
597
|
+
## Analyst Agreement
|
|
598
|
+
|
|
599
|
+
| File | Analyst 1 Section | Analyst 2 Section | Final |
|
|
600
|
+
|------|-------------------|-------------------|-------|
|
|
601
|
+
| `file1.ts` | Auth Flow | Auth Flow | Auth Flow |
|
|
602
|
+
| `file2.ts` | Auth Flow | API Layer | Auth Flow (majority) |
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
### requirements-mapping.md Format
|
|
606
|
+
|
|
607
|
+
```markdown
|
|
608
|
+
# Requirements Mapping
|
|
609
|
+
|
|
610
|
+
**Generated**: {timestamp}
|
|
611
|
+
**Mappers**: {count} (redundancy: {n}x)
|
|
612
|
+
|
|
613
|
+
## Requirements Parsed
|
|
614
|
+
|
|
615
|
+
| ID | Requirement | Source |
|
|
616
|
+
|----|-------------|--------|
|
|
617
|
+
| REQ-1 | User can log in via OAuth | spec.md:15 |
|
|
618
|
+
| REQ-2 | Sessions expire after 24h | spec.md:22 |
|
|
619
|
+
| REQ-3 | Failed logins are rate-limited | spec.md:28 |
|
|
620
|
+
|
|
621
|
+
## Coverage Matrix
|
|
622
|
+
|
|
623
|
+
| Requirement | Status | Files | Confidence |
|
|
624
|
+
|-------------|--------|-------|------------|
|
|
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) |
|
|
628
|
+
|
|
629
|
+
## Per-Section Coverage
|
|
630
|
+
|
|
631
|
+
### Section 1: Authentication Flow
|
|
632
|
+
- REQ-1: Full
|
|
633
|
+
- REQ-2: Partial (missing cleanup)
|
|
634
|
+
|
|
635
|
+
### Section 2: API Endpoints
|
|
636
|
+
- REQ-3: Not addressed
|
|
637
|
+
|
|
638
|
+
## Gaps
|
|
639
|
+
|
|
640
|
+
### Unaddressed Requirements
|
|
641
|
+
- **REQ-3**: Rate limiting not found in changeset
|
|
642
|
+
|
|
643
|
+
### Partial Coverage Details
|
|
644
|
+
- **REQ-2**: Session creation exists, but no expiry logic found
|
|
645
|
+
|
|
646
|
+
## Mapper Agreement
|
|
647
|
+
|
|
648
|
+
| Requirement | Mapper 1 | Mapper 2 | Final |
|
|
649
|
+
|-------------|----------|----------|-------|
|
|
650
|
+
| REQ-1 | Full | Full | Full |
|
|
651
|
+
| REQ-2 | Partial | None | Partial (conservative) |
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
---
|
|
655
|
+
|
|
656
|
+
## Aggregation Logic
|
|
657
|
+
|
|
658
|
+
When multiple agents produce findings, aggregate as follows:
|
|
659
|
+
|
|
660
|
+
### Flow Analyst Aggregation
|
|
661
|
+
|
|
662
|
+
1. **Collect** all flow analyses from all analysts
|
|
663
|
+
2. **Group** by file path
|
|
664
|
+
3. **Merge** upstream/downstream findings:
|
|
665
|
+
- Union of all unique callers/callees
|
|
666
|
+
- If same relationship found by multiple analysts = **High confidence**
|
|
667
|
+
- If found by only one analyst = **Medium confidence** (still include)
|
|
668
|
+
4. **Resolve** section assignments:
|
|
669
|
+
- If all analysts agree → use that section
|
|
670
|
+
- If disagreement → use majority, note dissent
|
|
671
|
+
- If no majority → Map Architect decides
|
|
672
|
+
|
|
673
|
+
### Requirements Mapper Aggregation
|
|
674
|
+
|
|
675
|
+
1. **Collect** all mappings from all mappers
|
|
676
|
+
2. **Compare** coverage assessments per requirement:
|
|
677
|
+
- If all agree → use that status
|
|
678
|
+
- If disagree → use **most conservative** (None < Partial < Full)
|
|
679
|
+
- Note disagreements for human review
|
|
680
|
+
3. **Merge** file-to-requirement mappings (union)
|
|
681
|
+
4. **Compile** unified gaps list
|
|
682
|
+
|
|
683
|
+
### Confidence Scoring
|
|
684
|
+
|
|
685
|
+
| Agreement | Confidence |
|
|
686
|
+
|-----------|------------|
|
|
687
|
+
| All agents agree | High |
|
|
688
|
+
| Majority agrees | Medium |
|
|
689
|
+
| No agreement | Low (flag for review) |
|
|
690
|
+
|
|
691
|
+
---
|
|
692
|
+
|
|
693
|
+
## Error Handling
|
|
694
|
+
|
|
695
|
+
### Incomplete Changeset
|
|
696
|
+
|
|
697
|
+
If `git diff` returns empty:
|
|
698
|
+
```
|
|
699
|
+
WARNING: No changes detected. Please stage changes or specify a target.
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
### Missing Config
|
|
703
|
+
|
|
704
|
+
If `.ocr/config.yaml` doesn't exist:
|
|
705
|
+
```
|
|
706
|
+
WARNING: OCR not configured. Run `ocr doctor` to check setup.
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
### Completeness Failure
|
|
710
|
+
|
|
711
|
+
If map doesn't include all files:
|
|
712
|
+
```
|
|
713
|
+
ERROR: Map incomplete: {missing_count} files not mapped.
|
|
714
|
+
Missing: [list files]
|
|
715
|
+
|
|
716
|
+
Re-running synthesis to include missing files...
|
|
717
|
+
```
|