Skip to content

fix(graph): report uninspected status fields as not inspected - #215

Open
chiliec wants to merge 1 commit into
mex-memory:mainfrom
chiliec:fix-204-status-not-inspected
Open

chiliec wants to merge 1 commit into
mex-memory:mainfrom
chiliec:fix-204-status-not-inspected

Conversation

@chiliec

@chiliec chiliec commented Sep 19, 2026

Copy link
Copy Markdown

What

Fixes #204.

When inspectGraphStatus skips immutable inspection — a stranded graph.db-wal, an unreadable sidecar, a containment failure, a failed quick-check or invariant audit — it still filled lastSuccessfulIndexAt, parseHealth and changes with placeholders, and printStatus rendered 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 parseHealth and changes non-nullable (~160 references, invariant checks in read-session.ts), so this is the additive-flag option:

  • GraphStatus.inspected?: boolean — optional, additive. graphStatus() defaults it to true; every early return that fills parseHealth with the empty placeholder passes false (15 sites). The GRAPH_INDEX_MISSING path stays true: there is no store, and Sources: N added is a real live-tree measurement there.
  • printStatus prints Last successful index: not inspected / Sources: not inspected / Parse health: not inspected when inspected === false; the diagnostic line and Next: remediation are unchanged.
  • --json gains "inspected": false on those paths; parseHealth and changes keep their shape.

Text output on the stranded-WAL repro now reads:

Graph status: degraded
Repository: main @ …
Last successful index: not inspected
Sources: not inspected
Parse health: not inspected
WARNING GRAPH_INDEX_SIDECAR_ACTIVE: Graph maintenance or recovery is active (graph.db-wal); immutable inspection was skipped.
Next: mex graph repair

Tests

  • src/graph/__tests__/status.test.ts: inspected is false on the corrupt and active-WAL paths, and true (with a real parseHealth.total) once the WAL is checkpointed.
  • src/graph/__tests__/cli-graph.test.ts: builds a store, strands a graph.db-wal, runs runGraphStatus and asserts the three not inspected lines, the sidecar warning, no 0 ok/never, and inspected: false under --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:

npx vitest run src/graph/__tests__/cli-graph.test.ts src/graph/__tests__/status.test.ts
  Tests  55 passed | 1 skipped (56)
npx vitest run test/graph-integration.test.ts test/graph-cli-freshness.test.ts test/graph-cli-parse-degraded.test.ts src/hub/__tests__/services.test.ts test/reporter.test.ts test/tui.test.ts packages/hub-contracts
  Tests  140 passed | 1 skipped (141)
npx tsc --noEmit  # clean

A full npx vitest run on 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.

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
@chiliec

chiliec commented Sep 19, 2026

Copy link
Copy Markdown
Author

Note: #213 was opened for the same issue shortly before this one (it was not up when I started on #204). This one keeps the diff to status.ts / cli-graph.ts / the contract type plus tests, and leaves src/drift/index.ts untouched. Happy to close in favour of #213 if you prefer that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

graph status prints uninspected fields as measured zeros — a stranded graph.db-wal reads as an empty graph

1 participant