Summary
src/graph/storage.ts has zero test coverage. It contains two functions — saveGraph and loadGraph — that are part of the critical path between a completed scan and a usable graph. Neither is tested.
Additionally, loadGraph has a silent failure: it catches a JSON parse error and returns null with no log and no context. A missing file and a corrupted file are indistinguishable to the caller. That is a bug in the contract.
What needs to happen
- Write a test file for
storage.ts
- Test
loadGraph returns null on a missing file path
- Test
loadGraph returns null (or throws with context) on a corrupted JSON file — these two states should be distinguishable
- Test
saveGraph writes a file that loadGraph can read back correctly (round-trip test)
- Test
saveGraph behavior when the target path is not writable
Why this matters
The storage layer is the only persistence mechanism for scan output. Silent failures here mean a user runs a scan, gets no graph, and has no idea why. That is the worst possible failure mode for a tool whose core value is showing you a graph.
Acceptance criteria
Summary
src/graph/storage.tshas zero test coverage. It contains two functions —saveGraphandloadGraph— that are part of the critical path between a completed scan and a usable graph. Neither is tested.Additionally,
loadGraphhas a silent failure: it catches a JSON parse error and returnsnullwith no log and no context. A missing file and a corrupted file are indistinguishable to the caller. That is a bug in the contract.What needs to happen
storage.tsloadGraphreturnsnullon a missing file pathloadGraphreturnsnull(or throws with context) on a corrupted JSON file — these two states should be distinguishablesaveGraphwrites a file thatloadGraphcan read back correctly (round-trip test)saveGraphbehavior when the target path is not writableWhy this matters
The storage layer is the only persistence mechanism for scan output. Silent failures here mean a user runs a scan, gets no graph, and has no idea why. That is the worst possible failure mode for a tool whose core value is showing you a graph.
Acceptance criteria
loadGraphon a missing file: returnsnull, no error thrownloadGraphon corrupted JSON: distinguishable from missing file (log or structured error)saveGraphthenloadGraphreturns the original graphsaveGrapherror handling on unwritable path is explicit and surfaces to the caller