Add post-dump plausibility gate returning status:degraded (#334)#433
Open
yangsec888 wants to merge 1 commit into
Open
Add post-dump plausibility gate returning status:degraded (#334)#433yangsec888 wants to merge 1 commit into
yangsec888 wants to merge 1 commit into
Conversation
Compare persisted SQLite node counts to in-memory dump counts after index_repository completes so partial WAL/durability loss surfaces as status:"degraded" instead of silent indexed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
index_repositorycompletes: when persisted SQLite node rows fall far below the in-memory graph buffer count at dump time, returnstatus:"degraded"withexpected_nodes/expected_edgesinstead of silentstatus:"indexed".Fixes #334 (design b as discussed in the issue thread).
Motivation
Rapid kill/restart cycles could leave
status:"indexed"with a small fraction of the true node count. Maintainer agreed on design (b): compare persisted rows to extracted/committed rows (self-referential, no cross-repo assumptions).Changes
src/foundation/dump_verify.c— purecbm_dump_verify_is_degraded()+CBM_DUMP_VERIFY_MIN_RATIOenv (default 0.5,0disables).src/pipeline/pipeline.c— capturecommitted_nodes/committed_edgesat dump; accessorcbm_pipeline_get_committed_counts.src/mcp/mcp.c— gate after successful pipeline; checkpoint+recount once; new response fields.tests/test_dump_verify.c— pure-function case matrix.tests/test_dump_verify_io.c— store I/O tests (realcbm_store_count_nodes, shortfall simulation, fork/crash WAL recovery).Response shape
{ "project": "...", "status": "degraded", "nodes": 469, "edges": 1200, "expected_nodes": 5915, "expected_edges": 9531, "hint": "Persisted far fewer nodes than indexed — likely durability loss..." }isErrorremains false so partial graphs stay queryable. Downstream parsers that only requirenodes/edgescontinue to work; newstatusis opt-in.Design notes
resolve_storeNULL (integrity auto-clean) →degradedwithnodes:0, not silentindexed.CBM_DUMP_VERIFY_MIN_RATIO=0disables the gate (escape hatch).committed_nodes = -1sentinel when dump did not run (explicit init;calloczero would be ambiguous).Test plan
make -f Makefile.cbm testgreen (5581 passed)suite_dump_verifypure-function matrixsuite_dump_verify_iostore I/O + fork/crash WAL recovery (POSIX)status:"degraded"Related