The projects.root_path integrity check only accepted '/' or an uppercase
'A'-'Z' first character. On Windows, drive letters are commonly lowercase
(c:/repo, y:/share), so such a path was flagged store.corrupt and the DB
was auto-deleted on open — a likely cause of the mapped-drive DB deletion
in #227/#367. Accept 'a'-'z' as well.
Relates to #227, #367.
cbm_pipeline_run_incremental was destructively overwriting a project's
graph when the index mode was downgraded. find_deleted_files classified
ANY stored file absent from the current discovery list as deleted and
purged its nodes via cbm_gbuf_delete_by_file. In a full → fast mode
downgrade, directories matching FAST_SKIP_DIRS (tools, scripts, bin,
build, docs, __tests__, migrations, ...) are excluded from discovery
but still exist on disk — so they were getting silently destroyed.
Real-world incident, 2026-04-13: the Skyline graph collapsed from 2819
nodes (full-mode nightly) to 2303 mid-day when a concurrent fast-mode
reindex obliterated packages/mcp/src/tools/ (~500 nodes / 18 files).
Fix:
- find_deleted_files now stat()s each stored-but-missing file. Files
that exist on disk are mode-skipped (nodes AND hash rows preserved);
only ENOENT/ENOTDIR results purge. Other errnos (EACCES, EIO, ELOOP,
transient NFS, ...) preserve. NULL repo_path preserves. snprintf
truncation preserves. strdup OOM mid-record drops the entry rather
than persist a NULL rel_path that would silently fail upsert. stat()
not lstat() is intentional — the indexer follows symlinks during
discovery so a stale symlink has no source to parse.
- Mode-skipped hash rows are threaded through dump_and_persist →
persist_hashes and re-upserted into the rebuilt DB. Without this,
the next reindex's stored hashes wouldn't include the file → the
deletion-detection contract breaks → orphaned graph nodes survive
forever once the file is eventually deleted.
- persist_hashes now checks the upsert return code on both the
current-files loop and the new mode_skipped loop and logs a warning
with scope/rel_path/rc on failure. Partial-failure policy: a single
bad row no longer silently drops, but does not abort the whole
reindex either — partial preservation beats total loss.
Tests:
- incremental_fast_preserves_mode_skipped_tools_dir walks the failure
end-to-end across four phases: full index, fast reindex preserves
the tools dir, mutate-and-fast-reindex exercises dump_and_persist's
hash carry (NOT the noop fast-path that would hide bugs there),
then delete-on-disk full reindex confirms the deletion-detection
contract still holds.
- store_file_hash_upsert_rejects_null_required_fields pins the API
contract that cbm_store_upsert_file_hash returns CBM_STORE_ERR on
NULL required fields, so a future schema change relaxing any NOT
NULL is caught at the producer layer rather than letting the new
warning go silent.
Conflict resolution against current main: the dump_and_persist
signature now takes both mode_skipped/mode_skipped_count (this PR) and
repo_path (added on main for cbm_artifact_export); the call site
passes cbm_pipeline_repo_path(p) alongside the mode_skipped pair.
Full suite: 2837 passed, 0 failed under ASan + UBSan + LeakSanitizer.
Closes#251.
Co-authored-by: Peter Cox <info@petercox.ie>
Add cbm_store_check_integrity() that validates:
- projects table has <= 5 rows (1 project per .db file)
- root_path starts with / or drive letter (not numeric garbage)
Wire into resolve_store (MCP queries) and pipeline routing:
- MCP: corrupt DB auto-deleted with ERROR log, returns "not indexed"
- Pipeline: corrupt DB deleted, falls through to full reindex
Root cause: user-reported corrupt DBs had 48K rows in projects table
with node IDs in text columns. Exact write path TBD, but detection
+ auto-clean prevents the symptom from persisting.
5 unit tests: clean DB, empty DB, bad path, too many rows, NULL.
- Arena-allocate pair_field_types in cpp_stdlib_data.c (was stack array
escaping scope via registry pointer — caught by GCC ASan)
- Add sysfs fallback for L2 cache on Linux ARM (sysconf returns 0)
- Expose cbm_node_free_fields() and fix 12+ leak sites in tests where
find_node_by_id/qn results were never freed (caught by LeakSanitizer)
Enforce WarningsAsErrors: '*' with zero suppressions of entire check categories.
All non-FP warnings fixed at source; true false positives get per-instance NOLINT
with reasoning. Fixes include: braces around statements (1679), isolate declarations
(75), explicit casts for multilevel pointer conversions, missing includes, function
parameter documentation via NOLINT, and proper NOLINTBEGIN/NOLINTEND nesting.
Complete C implementation of the indexing pipeline (src/), parallel worker
pool, graph buffer with merge support, SQLite writer, and 1893-test suite.
Linter setup: zero warnings from clang-tidy (all checks enabled, no NOLINT
suppressions), cppcheck, and clang-format. All issues fixed at source —
proper headers for external linkage, GROW_ARRAY macro restructured to
eliminate type parameter, null-deref paths guarded, named intermediates
for suspicious-argument checks.