Commit Graph
683 Commits
Author SHA1 Message Date
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 1f4491b248 test(mcp): cover active inbound overlay edges
Add a focused MCP canary for active overlay graph reads where an unchanged canonical caller points to a changed overlay target. The test proves the old canonical target is hidden by the overlay tombstone while search_graph relationship reads still return the caller and replacement target with overlay_active_graph metadata.

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

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 05:45:33 -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 e227296a5b test(mcp): cover overlay compaction worker failures
Add reusable MCP overlay-compaction fixtures and cleanup helpers, then cover missing project DB no-create behavior, invalid input rejection, and server-free joins of pending compaction workers.\n\nValidation:\n- make -f Makefile.cbm -j8 build/c/test-runner\n- CBM_ONLY_SUITE=mcp build/c/test-runner\n- git diff --check\n- bash scripts/check-source-safety.sh tests/test_mcp.c

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 04:36:03 -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 fcce029177 test(pipeline): cover repeated overlay publish
Add a focused pipeline canary for repeated opt-in overlay publishes of the same changed file. The test proves active overlay reads stay idempotent from the caller perspective: canonical base remains unchanged, the overlay view exposes one function, dirty_files remains a single overlay_ready row, and no reserved canonical generation is leaked.

This is intentionally test-only. It does not claim overlay generation retention or duplicate-publish suppression is solved; those remain separate compaction/cleanup design items.

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.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 02:12:05 -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 56485c2f0e test(incremental): reuse pinned FastAPI fixture cache
Validate FastAPI fixtures by required files and the pinned 0.99.1 commit before reuse. A user-provided CBM_TEST_FASTAPI_REPO is treated as read-only; the managed CBM_TEST_FASTAPI_CACHE/default temp cache is refreshed only when invalid.

Each suite still clones an isolated mutable working repo from the validated source, preserving test isolation while avoiding repeated network clones on subsequent runs.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-04 01:54:55 -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 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 c0cb5a23f0 test(mcp): guard edge-derived query_graph fallback
Cover the conservative active query_graph boundary for EXISTS in addition to relationship patterns, id(), and degree-derived projections.

The implementation still only opts active overlays into node-only Cypher. Edge-derived Cypher shapes stay canonical-only until active relationship/id semantics are designed and validated.

Validation: make -f Makefile.cbm -j8 build/c/test-runner; CBM_ONLY_SUITE=mcp ./build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 23:48:01 -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
Andrew Hundt 7bdb6a3a8d fix(mcp): mark canonical-only overlay gaps
Report read_model=canonical_only for query_graph and get_architecture when dirty or ready overlay state exists but the handler still reads canonical tables.

Include ready-overlay summary counts for canonical-only paths so callers can see that overlay rows exist but are not included by Cypher or architecture summaries yet.

Validation: CBM_ONLY_SUITE=mcp make -j8 -f Makefile.cbm test, 149 passed, log /private/tmp/cbm-pan84-canonical-only-read-model-mcp-20260703T205047-0400.log. Validation: make -j8 -f Makefile.cbm cbm, log /private/tmp/cbm-pan84-canonical-only-read-model-product-build-20260703T205047-0400.log.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 20:54:12 -04:00
Andrew Hundt ca0666b6f0 feat(mcp): use overlay rows for code search
Annotate search_code live-source matches with active overlay node rows when a ready file overlay exists, so changed files no longer inherit stale canonical graph metadata.

Preserve live-source grep behavior and canonical fallback, and dedupe no-id overlay nodes by qualified name/file identity instead of collapsing every overlay node with id 0.

Validation: CBM_ONLY_SUITE=mcp make -j8 -f Makefile.cbm test, 148 passed, log /private/tmp/cbm-pan84-search-code-overlay-mcp-20260703T204143-0400.log. Validation: make -j8 -f Makefile.cbm cbm, log /private/tmp/cbm-pan84-search-code-overlay-product-build-20260703T204143-0400.log.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 20:44:28 -04:00
Andrew Hundt 78ececf7f8 feat(mcp): use overlay rows for query search
Make search_graph query mode use the active overlay read model when ready overlay file tombstones exist.

The query path now suppresses canonical BM25 hits from tombstoned files, unions changed-file overlay nodes by bounded node-text matching, and reports overlay_active_nodes freshness metadata. The active overlay CTE builder is shared from the store layer so MCP and store reads use the same tombstone/latest-ready semantics.

Add an MCP regression that proves a fresh overlay symbol appears while the obsolete canonical FTS hit from the same file is hidden. Also refresh status warnings that previously said search/trace stayed canonical.

Validation: CBM_ONLY_SUITE=mcp make -f Makefile.cbm test -> 147 passed; CBM_ONLY_SUITE=store_nodes build/c/test-runner -> 93 passed; make -f Makefile.cbm cbm -> rc 0; git diff --check -> clean.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 20:35:27 -04:00
Andrew Hundt 273e696164 feat(mcp): resolve trace names through overlay
Teach trace_path function_name resolution to use active overlay node rows when overlay deltas are ready. This adds store-level active qn/name lookups, removes the synthetic no-id qn fallback, and keeps fallback search on the same active read model so tombstoned canonical symbols are not resurrected.

Validation: CBM_ONLY_SUITE=store_nodes make -f Makefile.cbm -j8 test (/private/tmp/cbm-pan83-overlay-trace-name-store-20260703T2050.log, 93 passed); CBM_ONLY_SUITE=mcp build/c/test-runner (/private/tmp/cbm-pan83-overlay-trace-name-mcp-20260703T2054.log, 146 passed); make -f Makefile.cbm -j8 cbm (/private/tmp/cbm-pan83-overlay-trace-name-product-build-20260703T2055.log); bash scripts/check-source-safety.sh (/private/tmp/cbm-pan83-overlay-trace-name-source-safety-20260703T2055.log).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 20:14:12 -04:00
Andrew Hundt 52f09e5f59 feat(mcp): enable overlay qualified-name trace
Add a store-level qualified-name overlay traversal helper over active node and relationship rows, then wire trace_path qualified_name requests to it when overlay rows are ready. The public trace response shape is unchanged; function_name resolution remains canonical until a separate active-name-resolution slice is designed.

Validation: CBM_ONLY_SUITE=store_nodes make -f Makefile.cbm -j8 test (/private/tmp/cbm-pan83-overlay-trace-store-20260703T2010.log, 93 passed); CBM_ONLY_SUITE=mcp build/c/test-runner (/private/tmp/cbm-pan83-overlay-trace-mcp-rerun-20260703T2024.log, 146 passed); bash scripts/check-source-safety.sh (/private/tmp/cbm-pan83-overlay-trace-source-safety-rerun-20260703T2024.log); make -f Makefile.cbm -j8 cbm (/private/tmp/cbm-pan83-overlay-trace-product-build-rerun-20260703T2025.log).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 20:05:30 -04:00
Andrew Hundt 07141b5458 feat(mcp): enable overlay connected search
Teach search_graph include_connected to use overlay active graph rows when overlay deltas are ready. The store now populates existing connected_names results by qualified name from the active graph, and MCP serialization treats those names as authoritative to avoid leaking stale canonical neighbors.

Validation: CBM_ONLY_SUITE=store_nodes make -f Makefile.cbm -j8 test (/private/tmp/cbm-pan83-overlay-connected-store-20260703T2231.log, 93 passed); CBM_ONLY_SUITE=mcp build/c/test-runner (/private/tmp/cbm-pan83-overlay-connected-mcp-20260703T2236.log, 146 passed); make -f Makefile.cbm -j8 cbm (/private/tmp/cbm-pan83-overlay-connected-product-build-20260703T2237.log); bash scripts/check-source-safety.sh (/private/tmp/cbm-pan83-overlay-connected-source-safety-20260703T2237.log).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 19:53:24 -04:00
Andrew Hundt a21970f4f5 feat(mcp): enable overlay relationship search
Use the active overlay graph read model for search_graph relationship-only requests while keeping connected-neighbor enrichment on canonical ids until that path is separately implemented.

Add active_edges CTE support to cbm_store_search_overlay_view so relationship filters, entry-point filters, and degree filters can use visible canonical edges plus latest ready owned overlay edges keyed by qualified name.

Make search degree-filter wrapping fail explicitly on allocation or SQL truncation instead of silently truncating generated SQL.

Validation: CBM_ONLY_SUITE=store_nodes make -f Makefile.cbm -j8 test (/private/tmp/cbm-pan83-overlay-relationship-store-20260703T2043.log, 93 passed); CBM_ONLY_SUITE=mcp build/c/test-runner (/private/tmp/cbm-pan83-overlay-relationship-mcp-20260703T2048.log, 146 passed); make -f Makefile.cbm -j8 cbm (/private/tmp/cbm-pan83-overlay-relationship-product-build-20260703T2048.log); bash scripts/check-source-safety.sh (/private/tmp/cbm-pan83-overlay-relationship-source-safety-20260703T2048.log); git diff --check (/private/tmp/cbm-pan83-overlay-relationship-diff-check-20260703T2048.log).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 19:41:10 -04:00