Commit Graph
771 Commits
Author SHA1 Message Date
Andrew Hundt 52b017f84b fix(pipeline): block unsafe broad header overlays
High-cap diagnostics showed that publishing non-tombstone additive overlay rows for broad C-family header exact frontiers can leave stale canonical edges visible in the active overlay view and can be slower than a full rebuild.

Keep the single-header overlay path separate, but require broad header batches to publish through the exact route until a strict additive-subset proof exists. Update the pipeline canary to require exact publish and fresh-rebuild equivalence for this case.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 13:06:09 -04:00
Andrew Hundt af4022b91f feat(pipeline): publish additive header overlays
Add a pipeline wrapper for non-tombstone overlay publishes and reuse the store active overlay CTE for file-node reads and summary counts. This lets header/type overlay rows refresh active read views without hiding canonical source-owned rows.

Add focused tests for duplicate-QN additive overlay ranking, single header type/implementation additive overlay behavior, and exact-frontier overlay dirty state.

Validation: bash scripts/check-source-safety.sh; bash scripts/test-source-safety.sh; git diff --check; make -f Makefile.cbm -j8 cbm; CBM_ONLY_SUITE=store_nodes build/c/test-runner; CBM_ONLY_SUITE=pipeline build/c/test-runner.

Scope: this is not the store_pipeline_batch default speed fix. Current benchmark evidence still shows safe full fallback around 2.6x, so narrower dependency-slice or active-read algorithm work remains open.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 12:53:55 -04:00
Andrew Hundt 170aa7d830 feat(store): support additive overlay rows
Split active overlay readability from file replacement tombstones. Replacement overlay publishes still hide canonical file rows, while the new additive publish API layers safe overlay facts without tombstoning the file.

Update the active-overlay CTE, node-view summary, and benchmark mirror so additive overlay rows are visible while canonical rows for the same file remain visible.

Add a store canary proving an additive overlay symbol is readable without creating a file tombstone or hiding existing canonical rows.

Validation: uv py_compile benchmark harness passed; ASan/UBSan test-runner build passed; store_nodes suite passed 108; source-safety passed; diff check clean; production build passed.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 11:52:11 -04:00
Andrew Hundt 320d63a7d2 fix(pipeline): guard unsafe header overlay pairs
Keep the single-header overlay fast path for safe header-only additions, but fall back when a C-family header delta contains type-like nodes and a same-stem implementation file exists.

This prevents active overlay from selecting header-owned type rows where a fresh full rebuild selects richer source-owned type rows, as seen in the store.h/store.c batch diagnostics.

Adds a pipeline canary for header type/implementation pair fallback while preserving the single-header overlay and multi-file header safety canaries.

Validation: focused header overlay tests passed; pipeline suite passed 326; source safety OK; diff check clean; production build passed; one_source_file benchmark stayed incremental_overlay at 29.677x. Full ASan target was also run and was not clean, with obsolete in-run and environment-sensitive failures recorded in the notes.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 11:42:28 -04:00
Andrew Hundt b6cc825941 perf(pipeline): allow single-header overlay publishes
Permit the early overlay publish route for a single changed C-family header while keeping multi-file header batches on the conservative exact/full path. The route is still gated by the active overlay graph equality checks instead of relying on an unchecked fast path.

Add a pipeline canary that edits a header, verifies incremental_overlay publication, confirms canonical rows stay unchanged, and confirms overlay rows become ready. The existing multi-file header safety canary remains in place.

Validation: pipeline suite 325 passed; source-safety OK; diff check clean; production build signed; self-dogfood one_source_file benchmark passed via incremental_overlay with 20.7767x speedup and cleanup complete.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 11:07:58 -04:00
Andrew Hundt 1406f2ee9b fix(pipeline): suppress unresolved route suffix self-calls
Parallel resolve used an unresolved route-registration suffix fallback for callees such as .get and .post. When no route literal was present, that fallback could fall through to a normal CALLS edge using the source node as the target, which fabricated self-calls for ordinary receiver accessors like ec.get(e.type).

Return without emitting when the suffix-only fallback has no route literal, while preserving resolved route API calls and unresolved route registrations that do have a valid route path. Add a parallel resolver canary that first proves extraction sees ec.get and then asserts no self CALLS edge is emitted.

Validation: build/c/test-runner rebuilt; CBM_ONLY_SUITE=parallel CBM_ONLY_TEST=parallel_unresolved_route_suffix_does_not_emit_self_call passed; CBM_ONLY_SUITE=parallel passed 27 tests; lint-source-safety passed; git diff --check passed; make -f Makefile.cbm cbm built and signed; MCP self-dogfood overlay matrix passed 5/5 with cleanup.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 10:52:51 -04:00
Andrew Hundt 47e9a6c6fc fix(pipeline): preserve scoped recursive complexity
Scoped exact and overlay updates run complexity with an incomplete call graph, so they cannot prove that an existing recursive SCC disappeared. Preserve stored recursive=true in scoped complexity mode while full complexity continues to recompute from the current graph.

Adds a focused in-memory pipeline canary for the persisted recursive property. Validated with the focused canary, complexity subset, full pipeline suite, source-safety, diff check, and a production build.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 10:32:08 -04:00
Andrew Hundt ce009783da fix(store): dedupe active overlay edges
Project active overlay edges as logical graph edges instead of per-file overlay ownership rows. Cross-file edges can be owned by multiple changed files in one overlay generation for cleanup and compaction bookkeeping, but AI-facing active views must not inflate degree or schema counts.

Mirror the production active-edge semantics in the self-dogfood benchmark and add a store regression for duplicate cross-file overlay edge ownership.

Validation: CBM_ONLY_SUITE=store_nodes build/c/test-runner; make -f Makefile.cbm cbm; self-dogfood full matrix at /private/tmp/cbm-overlay-active-edge-dedupe-full-self-dogfood-20260704T.json; source-safety at /private/tmp/cbm-overlay-active-edge-dedupe-source-safety-20260704T.log.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 10:10:42 -04:00
Andrew Hundt 793ede109e fix(pipeline): keep header deltas off active overlay
Guard C-family header changes from active overlay publication until active edge parity is proven against fresh rebuilds. Bounded header edits can still use exact base-delta publication, preserving correctness without forcing every safe case to full rebuild.

Add a focused C-header incremental canary that verifies no overlay publish, exact frontier expansion, exact publish stats, and fresh-rebuild equality. Clean up stale direct-frontier helper code from the failed cap64 overlay experiment.

Validation: CBM_ONLY_SUITE=pipeline build/c/test-runner -> 323 passed; make -f Makefile.cbm lint-source-safety -> OK; self-dogfood cap16/cap64 store_pipeline_batch passed canonical equality but still fell back with frontier_too_large at 2.81x/2.74x.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 09:47:04 -04:00
Andrew Hundt f17f2db19a fix(pipeline): preserve overlay graph parity
Serialize call args consistently for call-derived edges across sequential and parallel indexing, including CONFIGURES edges used by MCP graph responses and data-flow derivation.

Add a generic argument-list fallback for call extraction so grammars exposing arguments as argument_list still populate CBMCall.args.

Guard exact delta and overlay publication against cross-file node-QN collisions, falling back instead of letting a changed header override a canonical source definition in the active overlay view.

Validation: build/c test runner and binary rebuild passed; CBM_ONLY_SUITE=pipeline passed; lint-source-safety passed; full self-dogfood MCP matrix passed 5/5 in /private/tmp/cbm-cross-file-qn-guard-full-self-dogfood-20260704T.json.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 07:30:46 -04:00
Andrew Hundt 0aa4e4062b fix(pipeline): preserve file node extension identity
Keep symbol and module FQNs compatible while making File node qualified names injective for same-stem files such as .c/.h pairs.

Add a regression canary for File node FQNs and update pipeline import-map fixtures to use the extension-preserving file identity. Keep the package-map module lookup compatible by trying the legacy exact QN before a deterministic File-node fallback.

Validation: CBM_ONLY_SUITE=fqn build/c/test-runner; CBM_ONLY_SUITE=registry build/c/test-runner; CBM_ONLY_SUITE=pipeline build/c/test-runner; CBM_ONLY_SUITE=mcp build/c/test-runner; make -f Makefile.cbm lint-source-safety.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 06:47:51 -04:00
Andrew Hundt 4e8ef6018e feat(pipeline): publish small overlays before exact frontier expansion
Add an overlay-first pure-upsert route for overlay_publish=small_deltas so bounded changed-file overlays can publish before recursive exact inbound-frontier expansion falls through to containment.

The route reuses existing scratch seed, extract/resolve, postpass, delta metadata, preserved-inbound, and overlay publish helpers. It is gated to pure upserts in FAST-or-higher modes within the existing exact changed/affected path caps, and falls through to the existing exact/containment paths on failure.

Avoid a duplicate failed overlay generation when overlay-first reaches the publish step and fails; exact upsert skips the second overlay publish attempt and continues to canonical exact fallback.

Add a wide-inbound pipeline canary proving a changed Leaf with four unchanged callers now publishes incremental_overlay before frontier_too_large and active overlay BFS still sees CallerA -> Leaf.

Validation: make -f Makefile.cbm -j8 build/c/test-runner; CBM_ONLY_SUITE=pipeline build/c/test-runner (321 passed); CBM_ONLY_SUITE=mcp build/c/test-runner (166 passed); scripts/check-source-safety.sh on touched files; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 06:15:11 -04:00
Andrew Hundt d752729e56 feat(pipeline): add preserved inbound overlay delta helper
Carry inbound edge properties through cbm_store_list_file_delta_inbound_edges so active overlay rows do not lose relationship metadata.

Promote the recomputed-edge skip policy into a shared pipeline predicate with edge-type constants, and reuse it from incremental replay.

Add cbm_pipeline_file_delta_add_preserved_inbound_edges for overlay-producer support: upsert deltas preserve only non-recomputed one-hop inbound edges whose target QN still exists in the new delta, with duplicate suppression.

Validation: make -f Makefile.cbm -j8 build/c/test-runner; CBM_ONLY_SUITE=store_nodes build/c/test-runner (105 passed); CBM_ONLY_SUITE=pipeline build/c/test-runner (320 passed); CBM_ONLY_SUITE=mcp build/c/test-runner (166 passed); scripts/check-source-safety.sh on touched files; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 06:00:23 -04:00
Andrew Hundt 0f12f28b78 fix(pipeline): align parallel env access graphing
Reuse the existing sequential EnvVar/CONFIGURES materialization helper from the parallel full-index registry phase so full rebuilds remain a valid oracle for incremental slices.

Add a sequential-vs-parallel pipeline canary for C getenv access that verifies the CONFIGURES edge and canonical graph equality. This fixes the route_handler self-dogfood mismatch where incremental containment had EnvVar data that parallel full rebuild omitted.

Validation: make -f Makefile.cbm -j8 build/c/test-runner; CBM_ONLY_SUITE=pipeline build/c/test-runner; bash scripts/check-source-safety.sh src/pipeline/pass_definitions.c src/pipeline/pass_parallel.c src/pipeline/pipeline_internal.h tests/test_pipeline.c; git diff --check; make -f Makefile.cbm -j8 cbm; route_handler self-dogfood rerun passed.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 05:25:19 -04:00
Andrew Hundt e41a49d4b7 fix(pipeline): preserve nested folder containment
Create ancestor folder nodes before child folder edges in the full structure pass so first-seen nested directories produce deterministic CONTAINS_FOLDER edges.

Add the matching CBM_PIPELINE_EDGE_CONTAINS_FOLDER constant and reuse it in the exact-delta structural context path. Strengthen the pipeline structure canary to require pkg -> pkg/util containment and keep cleanup ahead of final assertions.

Validation: make -f Makefile.cbm -j8 build/c/test-runner; CBM_ONLY_SUITE=pipeline build/c/test-runner; bash scripts/check-source-safety.sh src/pipeline/pipeline.c src/pipeline/pipeline_delta.c src/pipeline/pipeline_internal.h tests/test_pipeline.c; git diff --check; make -f Makefile.cbm -j8 cbm; refreshed bounded P.A.N8.7 overlay CLI matrix passed 5/5.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 05:01:50 -04:00
Andrew Hundt 0f684ddc08 feat(mcp): trigger overlay compaction after publish
Add opt-in overlay_compaction_policy=after_publish with a bounded overlay_compaction_max_generations setting. index_repository now starts a one-shot compaction worker only after a successful incremental_overlay publish and reports the trigger status in the response.\n\nValidation:\n- make -f Makefile.cbm -j8 build/c/test-runner\n- CBM_ONLY_SUITE=mcp build/c/test-runner\n- CBM_ONLY_SUITE=pipeline build/c/test-runner\n- make -f Makefile.cbm -j8 cbm\n- git diff --check\n- bash scripts/check-source-safety.sh src/mcp/mcp.c src/cli/cli.c src/pipeline/pipeline.h tests/test_mcp.c tests/test_pipeline.c

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 04:45:48 -04:00
Andrew Hundt cde4978e64 feat(mcp): add overlay compaction worker
Add a one-shot MCP server overlay compaction worker that opens its own project store handle, reuses the bounded store drain helper, and is joined explicitly or during server teardown. The worker is not exposed as an MCP tool, does not poll or sleep, and does not change default behavior.

Reject duplicate starts until the previous worker is joined, validate project names before spawning, use the existing project DB path helper, and open databases with the no-create query path to avoid ghost cache files.

Cover the lifecycle with an isolated-cache MCP canary that compacts one overlay, rejects a duplicate start, joins cleanly, then drains the remaining overlay. Validation: make -f Makefile.cbm -j8 build/c/test-runner; CBM_ONLY_SUITE=mcp build/c/test-runner (161 passed); git diff --check; scripts/check-source-safety.sh src/mcp/mcp.c src/mcp/mcp.h tests/test_mcp.c; make -f Makefile.cbm -j8 cbm.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 04:25:29 -04:00
Andrew Hundt 1b9b4ebb26 feat(store): drain ready overlay compactions
Add a bounded store helper that repeatedly reuses compact_next for ready overlay generations. A named CBM_STORE_COMPACT_ALL_GENERATIONS constant documents the drain-all mode, while positive limits cap the number of generations compacted by one API call.

Cover no-ready drain behavior and a two-overlay canary that proves a one-generation limit leaves later ready overlays visible for a subsequent drain. This prepares the future background worker to reuse one store path instead of duplicating compaction loops.

Validation: make -f Makefile.cbm -j8 build/c/test-runner; CBM_ONLY_SUITE=store_nodes build/c/test-runner (105 passed); git diff --check; scripts/check-source-safety.sh src/store/store.c src/store/store.h tests/test_store_nodes.c; make -f Makefile.cbm -j8 cbm.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 04:14:26 -04:00
Andrew Hundt f98f08b9c8 feat(store): compact next ready overlay
Add a reusable store primitive that claims the oldest ready overlay generation, reserves a canonical index generation, and reuses the existing overlay compaction path. On reservation or compaction failure, the helper releases the compaction claim and marks the reserved generation failed when applicable.

Keep the behavior inert unless explicitly called by future compaction workers. Cover the no-ready CBM_STORE_NOT_FOUND contract and route an existing tombstone compaction canary through the new helper.

Validation: CBM_ONLY_SUITE=store_nodes build/c/test-runner (104 passed); git diff --check; scripts/check-source-safety.sh src/store/store.c src/store/store.h tests/test_store_nodes.c; make -f Makefile.cbm -j8 cbm.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 04:04:33 -04:00
Andrew Hundt ce26e4eb9c feat(store): lease overlay compaction claims
Replace status-based overlay compaction claims with an explicit overlay_compaction_claims lease table. Claiming now inserts a lease for the oldest unclaimed overlay_ready generation instead of changing the generation status to compacting, so active overlay read paths keep seeing the fresh overlay while a future background compactor owns it.

Recovery now releases abandoned lease rows after process restart or confirmed worker shutdown. The tests cover double-claim prevention, recovery/reclaim, failed-generation preservation, active read visibility while claimed, and FK cleanup of the claim when compaction deletes the overlay generation.

Validation: make -f Makefile.cbm -j8 build/c/test-runner; CBM_ONLY_SUITE=store_nodes build/c/test-runner; git diff --check; bash scripts/check-source-safety.sh src/store/store.c src/store/store.h tests/test_store_nodes.c; make -f Makefile.cbm -j8 cbm.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 03:54:44 -04:00
Andrew Hundt 3439153ec4 feat(store): recover overlay compaction claims
Add a default-inert recovery primitive for overlay generations left in compacting after process restart or confirmed worker shutdown. The API requeues compacting generations to overlay_ready in one existing BEGIN IMMEDIATE transaction and returns the number recovered, with no timeout heuristic or live-worker assumption.

Cover the recovery path in store_nodes by claiming a ready generation, recovering it, proving failed generations are untouched, and proving the recovered generation can be claimed again. The header documents that callers must not run recovery while a compactor is active.

Validation: make -f Makefile.cbm -j8 build/c/test-runner; CBM_ONLY_SUITE=store_nodes build/c/test-runner; git diff --check; bash scripts/check-source-safety.sh src/store/store.c src/store/store.h tests/test_store_nodes.c; make -f Makefile.cbm -j8 cbm.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 03:43:06 -04:00
Andrew Hundt 66703ad9eb feat(store): claim overlay compactions
Add cbm_store_claim_ready_overlay_generation() as the narrow store lifecycle primitive for a future background compactor. The claim runs in the existing BEGIN IMMEDIATE transaction path, selects the oldest ready overlay generation, and moves it from overlay_ready to compacting with a guarded status update so two callers cannot claim the same generation.

Cover oldest-ready ordering, non-ready filtering, invalid output handling, and claim-plus-compact composition in store_nodes. This keeps the change default-inert: no background thread, no default-on policy, and no shared store-handle concurrency are introduced.

Validation: make -f Makefile.cbm -j8 build/c/test-runner; CBM_ONLY_SUITE=store_nodes build/c/test-runner; git diff --check; bash scripts/check-source-safety.sh src/store/store.c src/store/store.h tests/test_store_nodes.c; make -f Makefile.cbm -j8 cbm.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 03:38:16 -04:00
Andrew Hundt 8c0c63a37a feat(store): compact ready overlay generations
Persist full overlay file delta metadata so ready overlay generations can be promoted into canonical rows without re-running extraction. Store file hashes, file state, imports, exports, and derived-view metadata alongside overlay nodes, edges, and tombstones.

Add cbm_store_compact_overlay_generation() as a manual, default-inert store API. It loads persisted overlay deltas, reuses the canonical delete/publish bodies inside one transaction, marks derived graph views stale, finishes the reserved canonical generation, clears dirty file rows, and removes promoted overlay rows.

Cover both upsert and delete-only compaction paths in store_nodes. Validated with ASan/UBSan test-runner build, store_nodes, pipeline, production cbm build, git diff --check, and focused stdout/string-safety scans. Logs are under /private/tmp/cbm-pan85-overlay-compaction-*20260704T.log.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 03:25:00 -04:00
Andrew Hundt 7afc2d9cd8 feat(watcher): admit dirty file metadata
Record changed git paths in the dirty-file ledger before invoking the watcher index callback so freshness surfaces remain truthful if reindexing is slow or fails.

Reuse the existing git snapshot command plumbing, store project lookup, and project field free helper. Skip ledger writes for watched projects that have not been indexed yet so pre-index watcher tests and users do not get noisy warnings.

Add canaries for failing index callbacks and rename status parsing, including both current and previous paths from git porcelain -z output.

Validation: make -f Makefile.cbm -j8 build/c/test-runner; CBM_ONLY_SUITE=watcher build/c/test-runner; CBM_ONLY_SUITE=pipeline build/c/test-runner; CBM_ONLY_SUITE=store_nodes build/c/test-runner; make -f Makefile.cbm -j8 cbm. Logs under /private/tmp/cbm-pan82-watcher-dirty-admission-*20260704T.log.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 03:01:20 -04:00
Andrew Hundt 0fcd7ebb1d feat(store): prune superseded overlay rows
Prune older ready overlay rows for the same project/path after a newer overlay generation publishes successfully. The cleanup deletes overlay FTS rows before relational rows and removes only ready generations that become empty, so multi-file generations retain unrelated file rows.

Add store canaries for single-file generation pruning, path-scoped multi-file preservation, and FTS cleanup of stale overlay tokens.

Validation:

- git diff --check: /private/tmp/cbm-pan82-overlay-retention-diff-check2-20260704T.log

- make -f Makefile.cbm -j8 build/c/test-runner: /private/tmp/cbm-pan82-overlay-retention-test-build-20260704T.log

- CBM_ONLY_SUITE=store_nodes build/c/test-runner: /private/tmp/cbm-pan82-overlay-retention-store-nodes-20260704T.log (98 passed)

- CBM_ONLY_SUITE=pipeline build/c/test-runner: /private/tmp/cbm-pan82-overlay-retention-pipeline-20260704T.log (317 passed)

- bash scripts/check-source-safety.sh: /private/tmp/cbm-pan82-overlay-retention-source-safety-20260704T.log

- make -f Makefile.cbm -j8 cbm: /private/tmp/cbm-pan82-overlay-retention-product-build-20260704T.log

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 02:41:30 -04:00
Andrew Hundt 7a961e7f66 test(pipeline): cover overlay extract failure
Apply the existing incremental extract fault hook to the sequential path so small exact-delta runs can exercise the same failure boundary as the parallel path.

Add an opt-in overlay publish canary that injects extract failure before overlay generation reservation, verifies canonical rows remain unchanged, no overlay generations are ready or failed, and the dirty file remains pending rather than overlay_ready.

Validation:

- make -f Makefile.cbm -j8 build/c/test-runner: /private/tmp/cbm-pan82-overlay-extract-failure-test-build3-20260704T.log

- CBM_ONLY_SUITE=pipeline build/c/test-runner: /private/tmp/cbm-pan82-overlay-extract-failure-pipeline2-20260704T.log (317 passed)

- bash scripts/check-source-safety.sh: /private/tmp/cbm-pan82-overlay-extract-failure-source-safety-20260704T.log

- git diff --check: /private/tmp/cbm-pan82-overlay-extract-failure-diff-check3-20260704T.log

- make -f Makefile.cbm -j8 cbm: /private/tmp/cbm-pan82-overlay-extract-failure-product-build-20260704T.log

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 02:33:14 -04:00
Andrew Hundt d9d1d20542 test(pipeline): cover overlay publish failure
Add a CBM_TEST_FAIL_INCREMENTAL_PHASE value for the overlay producer boundary and share the existing phase-failure helper between incremental and delta code. When injected after overlay generation reservation, the producer marks the overlay generation failed and returns an error.

Add a focused pipeline canary proving opt-in overlay publish failure falls back to canonical exact publish: the changed symbol is present canonically, the failed overlay generation is recorded, no ready overlay generation or reserved canonical generation remains, and dirty rows are cleared after canonical repair.

Validation: initial build failed because the helper included the wrong declaration header; corrected to foundation/platform.h. Final gates: make -f Makefile.cbm build/c/test-runner -j8; CBM_ONLY_SUITE=pipeline build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check; make -f Makefile.cbm cbm -j8.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 02:21:53 -04:00
Andrew Hundt 290627f5e7 feat(pipeline): publish delete deltas to overlay
Extend the existing default-off overlay_publish=small_deltas path to the single-file exact delete route. The route now reuses the overlay file-delta batch producer to publish a tombstone before canonical generation reservation, leaving canonical state untouched and dirty_files marked overlay_ready for active read views.

Keep overlay_publish=off behavior unchanged: canonical exact delete still applies and existing full-rebuild parity coverage remains in place. Add a pipeline canary proving the opt-in delete overlay keeps canonical base rows visible, hides the deleted file through the overlay view, avoids reserved canonical generation leaks, and preserves overlay_ready freshness state.

Validation: make -f Makefile.cbm build/c/test-runner -j8; CBM_ONLY_SUITE=pipeline build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check; make -f Makefile.cbm cbm -j8.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 02:05:03 -04:00
Andrew Hundt a6fb2720f4 feat(pipeline): publish opt-in exact deltas to overlay
Add a default-off overlay_publish policy for bounded exact-delta incremental runs. When enabled, eligible non-noop exact deltas publish ready overlay rows and dirty freshness without mutating canonical graph rows, while default canonical behavior remains unchanged.

Use the latest complete canonical generation as the overlay base, avoid reserving a canonical generation for successful overlay publishes, and report incremental_overlay in pipeline telemetry and benchmark parsing.

Add focused store and pipeline canaries for latest complete generation lookup, opt-in overlay visibility, canonical invisibility, dirty overlay_ready state, and absence of stray reserved canonical generations.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 01:54:46 -04:00
Andrew Hundt ecbf04256e feat(pipeline): add overlay producer contract
Add an atomic store batch API for foreground overlay file deltas and keep the existing single-file API as a compatibility wrapper. The batch path validates one-project inputs, writes overlay rows and tombstones in one transaction, and marks the generation ready only after every file succeeds.

Add an internal pipeline producer helper that reserves an overlay generation, publishes existing file-delta facts, and marks dirty freshness as overlay_ready. If publish or freshness marking fails, the helper marks the overlay generation failed so active read views do not expose a misleading generation.

Cover the contract with focused store and pipeline canaries. Store coverage verifies multi-file rollback leaves no partial overlay rows. Pipeline coverage uses existing exact-delta extraction metadata to prove overlay-visible, canonical-invisible, dirty-ready behavior. Production incremental wiring, compaction, and default-readiness remain separate follow-up work.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 01:15:34 -04:00
Andrew Hundt 9637a0afd6 fix(store): clear overlay FTS on project replacement
Full canonical replacement deletes the project row and relies on FK cascade to remove overlay generations and rows, but contentless nodes_fts_overlay is not FK-backed. Remove overlay FTS entries while overlay_nodes still exists so full reindex/project delete cannot leave stale overlay tokens behind.

Cross-check: upstream/main has only canonical project replacement and no overlay tables, so this preserves upstream replacement semantics and adds fork-only derived-view cleanup.

Validation: CBM_ONLY_SUITE=store_nodes make -j8 -f Makefile.cbm test passed 95 tests after the pre-fix canary failed; bash scripts/check-source-safety.sh passed; make -j8 -f Makefile.cbm cbm built and signed; git diff --check passed.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 00:58:10 -04:00
Andrew Hundt 6916cca54a fix(mcp): restore indexed source search scope
Restore the upstream indexed-file scoped search_code fallback for non-git and file_pattern searches while preserving the fork's git_worktree fast path for active untracked edits.

Filter file_pattern against indexed file paths with sqlite3_strglob, write NUL-separated file lists for safer paths with spaces, and force grep -Hn so single-file scoped searches still produce file:line:content output for the existing parser.

Add a regression canary proving file_pattern searches do not scan unindexed generated files when an indexed file set exists.

Validation: CBM_ONLY_SUITE=mcp make -f Makefile.cbm -j8 test; bash scripts/check-source-safety.sh; make -f Makefile.cbm -j8 cbm; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 00:43:27 -04:00
Andrew Hundt 6672095863 feat(store): maintain overlay FTS rows
Add a separate nodes_fts_overlay FTS5 table for ready overlay node rows and maintain it transactionally with overlay file-delta publishes.

The delete path removes contentless FTS rows before overlay_nodes are deleted, and inserts use the assigned overlay_nodes rowid. search_graph query mode now reads changed-file overlay hits from the overlay FTS table while preserving the canonical nodes_fts fast path for visible base rows.

Validation: CBM_ONLY_SUITE=store_nodes make -f Makefile.cbm -j8 test; CBM_ONLY_SUITE=mcp build/c/test-runner; bash scripts/check-source-safety.sh; make -f Makefile.cbm -j8 cbm; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 00:25:15 -04:00
Andrew Hundt f24134b93f fix(mcp): preserve tokenless query fallback
When search_graph has ready overlay rows, tokenless BM25 queries now follow the same fallback behavior as the upstream canonical BM25 path instead of returning an overlay read error.

Add an MCP regression that combines query="!!!" with graph filters while an overlay replacement is ready, proving the graph filter path still returns overlay-active rows.

Validation: CBM_ONLY_SUITE=mcp make -f Makefile.cbm -j8 test; bash scripts/check-source-safety.sh; make -f Makefile.cbm -j8 cbm; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 00:14:08 -04:00
Andrew Hundt 13b1632881 fix(mcp): clarify architecture pattern freshness
Name relationship_patterns explicitly in the mixed architecture freshness warning so callers do not infer edge-derived summaries are active just because node sections used overlay rows.

Validation: make -f Makefile.cbm -j8 build/c/test-runner; CBM_ONLY_SUITE=mcp ./build/c/test-runner; bash scripts/check-source-safety.sh; make -f Makefile.cbm -j8 cbm; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 00:03:30 -04:00
Andrew Hundt eff338e571 feat(store): populate schema relationship patterns
Fill cbm_schema_info.rel_patterns from canonical, scoped, and active overlay schema reads using existing edge/node joins and active_edges visibility.

This makes the architecture relationship_patterns field real while preserving the mixed freshness policy for edge-derived summaries.

Validation: make -f Makefile.cbm -j8 build/c/test-runner; CBM_ONLY_SUITE=store_nodes ./build/c/test-runner; CBM_ONLY_SUITE=mcp ./build/c/test-runner; CBM_ONLY_SUITE=store_arch ./build/c/test-runner; bash scripts/check-source-safety.sh; make -f Makefile.cbm -j8 cbm; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 23:57:28 -04:00
Andrew Hundt da100e5182 feat(mcp): use overlay summaries for architecture resource
Teach codebase://architecture to reuse the existing architecture store dispatcher for the compact node-only sections that already support active overlay rows: languages, entry_points, and routes. Keep total counts, PageRank key_functions, and relationship_patterns canonical or stale-aware, and report that mixed read model explicitly.

Refactor the shared architecture JSON emitters so get_architecture and the resource use one implementation. Use yyjson string copies because resources/read serializes after the builder returns; ASan caught the borrowed-string UAF during the focused MCP canary.

Upstream compatibility: upstream/main has get_architecture but not this fork resource, and the get_architecture output shape is preserved. Validation: CBM_ONLY_SUITE=mcp 158 passed; CBM_ONLY_SUITE=tool_consolidation 99 passed; CBM_ONLY_SUITE=store_arch 59 passed; bash scripts/check-source-safety.sh OK; git diff --check OK; make -j8 -f Makefile.cbm cbm OK.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 23:39:06 -04:00
Andrew Hundt 222f27b663 feat(mcp): use overlay schema for graph schema
Add an active schema view with property-key discovery over active overlay nodes and edges, while keeping the existing canonical fallback for get_graph_schema when the active read is unavailable.

Keep codebase://schema on the counts-only path and make freshness metadata distinguish counts-only resources from full schema property reads. Tighten property discovery cleanup and malformed JSON handling.

Validation: build/c/test-runner build; CBM_ONLY_SUITE=store_nodes, mcp, store_search, store_arch; scripts/check-source-safety.sh; git diff --check; make -f Makefile.cbm cbm.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 23:25:16 -04:00
Andrew Hundt 1fa1857d7e fix(mcp): report graph schema freshness
Add canonical-only freshness metadata to get_graph_schema when dirty or ready overlay rows exist, preserving existing canonical schema and property-key output.

Add an MCP canary that proves ready overlay replacements are disclosed instead of silently omitted.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 23:08:26 -04:00
Andrew Hundt 7e53d5ef89 feat(mcp): use overlay rows for schema resource
Make codebase://schema read ready overlay node labels and edge types when an active overlay generation is available, with canonical counts as the fallback path.

Consolidate schema count array collection for canonical, scoped, and overlay schema count reads so memory ownership and SQLite step handling stay consistent.

Add store and MCP canaries for active schema counts, including stale canonical suppression and freshness metadata.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 22:59:06 -04:00
Andrew Hundt 4687ec6b2c fix(mcp): report overlay freshness for schema resource
Make codebase://schema disclose canonical-only freshness when ready overlay rows exist, matching the resource behavior added for codebase://architecture. The schema content remains canonical, while freshness metadata reports the ready overlay/tombstone counts and warning text instead of silently omitting overlay-only labels.

Add an MCP resources/read canary that publishes a ready overlay replacement, verifies the canonical Function schema remains visible, verifies the overlay-only Class label is not reported as canonical schema, and checks canonical_only freshness metadata.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 22:40:55 -04:00
Andrew Hundt 7f5bfac1eb fix(mcp): report overlay freshness for architecture resource
Add canonical-only overlay freshness metadata to codebase://architecture when ready overlay rows exist. The resource still returns canonical graph summaries, but now reports the same read-model limitation as graph tools instead of silently omitting ready overlay rows.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 22:33:20 -04:00
Andrew Hundt 85f447b6c3 perf(cypher): bound active unlabeled node scans
Reuse the active overlay node view with an optional SQL LIMIT and apply the same bounded seed limit used by canonical unlabeled Cypher scans. This prevents node-only active query_graph MATCH (n) queries from materializing every active node before max_rows is applied.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 22:26:32 -04:00
Andrew Hundt 3b2b552a15 fix(cypher): align query row defaults with upstream
Restore the Cypher executor safety ceiling to upstream's 100000 rows and expose the MCP query_graph default as query_max_rows. Explicit max_rows arguments remain caller-authoritative; omitted max_rows uses the config default. Add CLI registry and MCP coverage for the new discoverable default.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 22:20:15 -04:00
Andrew Hundt e5530eed30 test(mcp): guard active query derived fallbacks
Add MCP coverage proving ready overlay rows are not used for id() or degree-derived Cypher query_graph shapes. These queries stay canonical until active relationship/id semantics are designed and tested. Also fix stale Cypher header wording for LIMIT and row-ceiling semantics.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 22:13:06 -04:00
Andrew Hundt 0d9a83b527 feat(mcp): use overlay nodes for node-only query_graph
Add a reusable active-overlay node scan helper in the store and expose an opt-in Cypher executor that uses it only for node-only query shapes.

query_graph now reports overlay_active_nodes for supported node-only Cypher when ready overlay tombstones exist. Relationship, EXISTS, degree-derived, id(), and CASE edge-dependent queries remain canonical-only with explicit freshness warnings until active relationship views are designed.

Validation: store_nodes 93 passed; cypher 144 passed; mcp 153 passed; make -j8 -f Makefile.cbm cbm; bash scripts/check-source-safety.sh.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 22:04:41 -04:00
Andrew Hundt 4c55bcaa45 fix(cypher): restore upstream optional match semantics
Port the current upstream Cypher fixes before adding any active query_graph overlay behavior.

Preserve explicit LIMIT 0 as an empty result for RETURN and WITH clauses by using a distinct no-limit sentinel. Filter relationship expansion against already-bound terminal variables and drive one-hop optional matches from the bound terminal to avoid broad cross joins and wrong c IS NULL results.

Add focused regression coverage for LIMIT 0 and bound-terminal OPTIONAL MATCH. Validation: CBM_ONLY_SUITE=cypher ./build/c/test-runner (144 passed); CBM_ONLY_SUITE=mcp ./build/c/test-runner (152 passed); make -j8 -f Makefile.cbm cbm; bash scripts/check-source-safety.sh.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 21:49:37 -04:00
Andrew Hundt 435f182ba9 feat(mcp): use overlay rows for architecture file summaries
Extend get_architecture active overlay coverage to File-node summaries by routing languages and file_tree through the same active node view used for entry_points and routes.

Consolidate node-only architecture SQL construction and binding so canonical nodes and active overlay nodes share one path-scope and limit convention.

Add store and MCP canaries for ready overlay tombstones hiding stale File rows from scoped language and file_tree output.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 21:34:40 -04:00
Andrew Hundt b9b4ea2f45 feat(mcp): use overlay rows for architecture routes
Make get_architecture routes reuse the active overlay node read model when ready overlay tombstones exist, hiding stale canonical route rows from changed files and surfacing ready overlay replacements.

Generalize architecture freshness metadata so responses report read_model=mixed_active_nodes_canonical_summaries with active_sections naming entry_points, routes, or both.

Validation: CBM_ONLY_SUITE=store_arch make -j8 -f Makefile.cbm test, 58 passed, log /private/tmp/cbm-pan86-arch-routes-overlay-store-arch-20260703T211331-0400.log.

Validation: CBM_ONLY_SUITE=mcp make -j8 -f Makefile.cbm test, 151 passed, log /private/tmp/cbm-pan86-arch-routes-overlay-mcp-20260703T211331-0400.log.

Validation: make -j8 -f Makefile.cbm cbm, log /private/tmp/cbm-pan86-arch-routes-overlay-product-build-20260703T211331-0400.log.

Validation: make -f Makefile.cbm lint-source-safety, log /private/tmp/cbm-pan86-arch-routes-overlay-source-safety-20260703T211331-0400.log.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 21:15:00 -04:00
Andrew Hundt 66c85001c8 feat(mcp): use overlay rows for architecture entry points
Make get_architecture entry_points read active overlay node rows when ready overlay tombstones exist, while keeping counts and derived architecture summaries explicitly canonical or stale.

Report read_model=mixed_active_nodes_canonical_summaries with active_sections=[entry_points] so callers can distinguish the active entry-point slice from still-canonical summaries.

Validation: CBM_ONLY_SUITE=store_arch make -j8 -f Makefile.cbm test, 58 passed, log /private/tmp/cbm-pan85-arch-entry-overlay-store-arch-20260703T210121-0400.log.

Validation: CBM_ONLY_SUITE=mcp make -j8 -f Makefile.cbm test, 150 passed, log /private/tmp/cbm-pan85-arch-entry-overlay-mcp-20260703T210121-0400.log.

Validation: make -j8 -f Makefile.cbm cbm, log /private/tmp/cbm-pan85-arch-entry-overlay-product-build-20260703T210121-0400.log.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 21:05:49 -04:00