# Risk Context — call graph SQLite edge store incremental update

> Generated by openlore on 2026-05-08. Re-run `/gsd:openlore-orient` after structural changes.

## Summary

- **Phase intent**: call graph SQLite edge store incremental update (PR #76)
- **Domains**: services (mcp-watcher, edge-store), analyzer (artifact-generator)
- **Max risk score**: 82 — `handleChange` (critical)
- **Decision**: 🟡 Proceed with caution — risk is pre-existing orchestration complexity, not introduced by this PR

## Functions in Scope

| Function | File | Risk | Hub | Note |
|----------|------|------|-----|------|
| `handleChange` | `mcp-watcher.ts` | 82 (critical) | no | fanOut=17, downstream=32 — existing orchestrator complexity |
| `writeEdgesToSQLite` | `artifact-generator.ts` | 29 (low) | no | fanIn=1, well contained |
| `EdgeStore.*` | `edge-store.ts` | — | no | New file, fanIn=0 on all methods (call graph not yet propagated) |

## Callers to Protect

`writeEdgesToSQLite` upstream chain (fanIn=1):
- `AnalysisArtifactGenerator.generateAndSave` → `generateAndSaveArtifacts` → `runAnalysis` / `openloreRun` / `openloreAnalyze`

`handleChange` has no internal callers (entry point — called by chokidar event loop).

## Blocking Refactors

**`handleChange` (riskScore=82)** — tool flags "decompose fan-out". Not blocking this PR because:
1. fanOut=17 is inherent to the orchestration (check hash, delete edges, re-parse, insert, patch signatures, re-embed)
2. All 36 watcher tests pass, including the new DB update tests
3. Risk is pre-existing; PR does not increase fanOut

Recommended follow-up: extract DB mutation steps into a helper (`patchGraphForFile`) to reduce `handleChange` fanOut from 17 to ~10.

## Relevant Spec Requirements

None matched for "call graph SQLite edge store incremental update". Area not yet spec'd.

Spec match quality was poor (best match: `Clicallgraph` in api domain — surface match only).

## Known Issues Found During Tooling Exercise

**Path normalization bug**: orient returned mixed absolute/relative filePaths for nodes in `edge-store.ts`:
- Some nodes: `src/core/services/edge-store.ts` (relative ✓)
- Some nodes: `/Users/laurent/Projets/openlore/src/core/services/edge-store.ts` (absolute ✗)

This caused all `callPaths` to return empty callers/callees (DB lookup by ID fails when path prefix differs). Pre-existing issue in call graph path normalization, not introduced by this PR.

## Insertion Points

Top candidate from orient: `EdgeStore.clearAll` (entry_point, score=0.988) — correct anchor for extending graph store operations.

## Verdict

🟡 **Proceed with caution.** `handleChange` complexity warrants a follow-up refactor ticket. PR #76 itself is safe — all paths tested (2584 passing), DB populated and verified e2e.
