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