fix(graph): report uninspected status fields as not inspected - #215
Conversation
When immutable inspection is skipped — a stranded graph.db-wal, an unreadable sidecar, a containment failure or a failed invariant audit — mex graph status printed the placeholder values in the same shape as measurements: "Last successful index: never", "Sources: 0 changed" and "Parse health: 0 ok", all false for an intact store. Add an additive inspected flag to GraphStatus, set false on every early return that fills parseHealth with an empty placeholder, and render those three lines as "not inspected" in the text output. parseHealth and changes keep their shape so no consumer changes. Fixes mex-memory#204
theDakshJaitly
left a comment
There was a problem hiding this comment.
This fixes the stranded-WAL case, but the GRAPH_SNAPSHOT_CONTENT_MISMATCH early return still reports unmeasured fields as facts. It has read parse-health counts, but has not compared sources and does not populate the index timestamps. The new default therefore labels its placeholder changes and timestamps as inspected: true.
Please handle this partial-inspection return too: mark the unavailable fields as not inspected, using the existing flag conservatively or an equivalent explicit distinction. Add a regression that builds a graph, changes its recorded snapshot digest, modifies a source file, and verifies both text and JSON output.
Non-blocking consistency suggestion: unavailableGraphStatus() in src/drift/index.ts still omits inspected when the status loader throws. Consider setting it to false and covering the failed-loader case so the separate mex check fallback carries the same explicit signal. The requested-changes blocker is the snapshot-mismatch behavior above.
Validation on 857a90d: 197 existing focused tests passed across graph status, CLI, graph integration/freshness/degradation, Hub services/contracts, and reporter/TUI. Workspace typecheck and git diff --check passed. Additional controls confirm fresh/missing-index behavior and stranded-WAL text/JSON output, including unchanged database/WAL bytes. The snapshot-mismatch regression fails; an injected loader failure also confirms the unset fallback flag. Full repository, packaging, and performance suites were not rerun.
… not inspected The GRAPH_SNAPSHOT_CONTENT_MISMATCH early return had read parse health but never compared sources or populated the index timestamps, so the placeholder changes and null lastSuccessfulIndexAt shipped as inspected: true. Mark that partial inspection as not inspected, and give the mex check fallback status the same explicit flag when the status loader throws. Regressions: build a graph, corrupt the snapshot digest, edit a source, and verify text + JSON output; inject a loader failure and verify the fallback carries inspected: false.
|
Thanks — you're right, the snapshot-mismatch return was a missed case. Pushed
Both new tests fail on the previous head and pass now; |
theDakshJaitly
left a comment
There was a problem hiding this comment.
The snapshot-content-mismatch path now reports inspected: false, and the unavailable-status fallback does the same. Both have regression coverage. The final review of the complete PR found no remaining actionable issues.
Validation on 84a5058: 199 focused repository tests, all 5 independent review assertions, and workspace typecheck passed. CI is green, including Node 22/24, Windows/macOS portability, browser, packaging, and release-performance checks: https://github.com/mex-memory/mex/actions/runs/35678969841
What
Fixes #204.
When
inspectGraphStatusskips immutable inspection — a strandedgraph.db-wal, an unreadable sidecar, a containment failure, a failed quick-check or invariant audit — it still filledlastSuccessfulIndexAt,parseHealthandchangeswith placeholders, andprintStatusrendered them in the same shape as measurements:Last successful index: never,Sources: 0 changed,Parse health: 0 ok. All three are false for an intact store.Why
Per the issue, the JSON contract keeps
parseHealthandchangesnon-nullable (~160 references, invariant checks inread-session.ts), so this is the additive-flag option:GraphStatus.inspected?: boolean— optional, additive.graphStatus()defaults it totrue; every early return that fillsparseHealthwith the empty placeholder passesfalse(15 sites). TheGRAPH_INDEX_MISSINGpath staystrue: there is no store, andSources: N addedis a real live-tree measurement there.printStatusprintsLast successful index: not inspected/Sources: not inspected/Parse health: not inspectedwheninspected === false; the diagnostic line andNext:remediation are unchanged.--jsongains"inspected": falseon those paths;parseHealthandchangeskeep their shape.Text output on the stranded-WAL repro now reads:
Tests
src/graph/__tests__/status.test.ts:inspectedisfalseon the corrupt and active-WAL paths, andtrue(with a realparseHealth.total) once the WAL is checkpointed.src/graph/__tests__/cli-graph.test.ts: builds a store, strands agraph.db-wal, runsrunGraphStatusand asserts the threenot inspectedlines, the sidecar warning, no0 ok/never, andinspected: falseunder--json.Both new tests fail on
main(expected undefined to be false,expected […] to include 'Last successful index: not inspected') and pass with the change.Ran locally:
A full
npx vitest runon my box hit the 15 s per-test timeout on unrelated Relay/hub tests under load, so I relied on the targeted runs above plus CI.Changelog entry added under
[0.8.2] → Fixed.