Commit Graph
725 Commits
Author SHA1 Message Date
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
Andrew Hundt c0aa7e6f20 feat(mcp): use overlay rows for graph search
Wire search_graph graph-mode node searches to cbm_store_search_overlay_view() when ready overlay file tombstones exist and the request does not require relationship/connected edge semantics.

Add freshness.read_model=overlay_active_nodes and overlay count metadata when the active node read model is used. Relationship/connected requests stay canonical with an explicit warning until overlay edge reads are implemented.

Validation: CBM_ONLY_SUITE=mcp make -f Makefile.cbm -j8 test -> /private/tmp/cbm-pan83-overlay-mcp-search-mcp-suite-20260703T1928.log (145 passed); CBM_ONLY_SUITE=store_nodes make -f Makefile.cbm -j8 test -> /private/tmp/cbm-pan83-overlay-mcp-search-store-suite-20260703T1931.log (92 passed); make -f Makefile.cbm -j8 cbm -> /private/tmp/cbm-pan83-overlay-mcp-search-product-build-20260703T1931.log; bash scripts/check-source-safety.sh -> /private/tmp/cbm-pan83-overlay-mcp-search-source-safety-20260703T1931.log; git diff --check clean.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 19:10:42 -04:00
Andrew Hundt 8adef05c5d feat(store): add overlay-aware search primitive
Add cbm_store_search_overlay_view() as an opt-in active node read view over canonical nodes minus ready overlay file tombstones plus owned nodes from the latest ready overlay per changed file.

Refactor canonical search to share the SQL execution, allocation, scan, cleanup, and error path with the new overlay search primitive. Default search_graph/search_code/query behavior remains unchanged.

Tests cover canonical fallback with no ready overlay and a full-rebuild oracle comparison where old rows are hidden, stable rows remain visible, latest overlay rows win, non-canonical overlay ids stay zero, and the degree-filter SQL wrapper is exercised.

Validation: CBM_ONLY_SUITE=store_nodes make -f Makefile.cbm -j8 test -> /private/tmp/cbm-pan83-overlay-search-store-suite-20260703T1910.log (92 passed); CBM_ONLY_SUITE=mcp make -f Makefile.cbm -j8 test -> /private/tmp/cbm-pan83-overlay-search-mcp-suite-20260703T1914.log (144 passed); make -f Makefile.cbm -j8 cbm -> /private/tmp/cbm-pan83-overlay-search-product-build-20260703T1915.log; bash scripts/check-source-safety.sh -> /private/tmp/cbm-pan83-overlay-search-source-safety-20260703T1915.log; git diff --check clean; isolated dogfood index/search artifacts under /private/tmp/cbm-pan83-overlay-search-dogfood-*.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 19:04:01 -04:00
Andrew Hundt 77cb098b07 feat(mcp): report overlay read-view status
Expose overlay_read_view counts on index_status and codebase://status when ready overlay tombstones exist, while keeping canonical nodes/edges counts unchanged.

Warn that search and trace remain canonical until overlay-aware tools are enabled, so callers do not mistake status visibility for query behavior.

Validation: CBM_ONLY_SUITE=mcp make -f Makefile.cbm -j8 test -> /private/tmp/cbm-pan83-overlay-status-mcp-suite-20260703T1908.log (144 passed); CBM_ONLY_SUITE=store_nodes make -f Makefile.cbm -j8 test -> /private/tmp/cbm-pan83-overlay-status-store-suite-20260703T1914.log (90 passed); make -f Makefile.cbm -j8 cbm -> /private/tmp/cbm-pan83-overlay-status-product-build-20260703T1914.log; bash scripts/check-source-safety.sh -> /private/tmp/cbm-pan83-overlay-status-source-safety-20260703T1914.log; git diff --check -> /private/tmp/cbm-pan83-overlay-status-diff-check-20260703T1912.log.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 18:48:02 -04:00
Andrew Hundt f4b9630876 feat(store): read file nodes through overlay view
Add cbm_store_find_nodes_by_file_overlay_view(), a bounded file-scoped helper that returns canonical nodes unless a ready overlay tombstone exists, then returns owned nodes from the latest ready overlay for that file.

Overlay rows are returned with id=CBM_STORE_NO_NODE_ID because overlay row ids are not canonical graph node ids. The helper shares the existing node scan/allocation path and keeps default query behavior unchanged.

Validation: CBM_ONLY_SUITE=store_nodes make -f Makefile.cbm -j8 test (90 passed); CBM_ONLY_SUITE=sqlite_writer make -f Makefile.cbm -j8 test (10 passed); make -f Makefile.cbm -j8 cbm; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 18:40:01 -04:00
Andrew Hundt bcbc95829f feat(store): summarize overlay node read view
Add a read-only overlay node view summary that computes canonical visible nodes plus owned nodes from the latest ready overlay per file. This is the first tested base-minus-tombstone-plus-overlay read primitive and does not alter existing query behavior.

Validation: CBM_ONLY_SUITE=store_nodes make -f Makefile.cbm -j8 test (89 passed); CBM_ONLY_SUITE=sqlite_writer make -f Makefile.cbm -j8 test (10 passed); make -f Makefile.cbm -j8 cbm; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 18:33:23 -04:00
Andrew Hundt 6b8e3ac22a feat(store): publish file deltas to overlay rows
Add overlay node, edge, and tombstone tables tied to overlay generation metadata, plus cbm_store_publish_overlay_file_delta() for transactional file-level overlay publishes.

The publish path reuses cbm_store_file_delta_t rather than adding another extractor, rejects failed/non-publishable generations, preserves canonical nodes and edges, and keeps replacement idempotent per project/generation/path.

Validation: CBM_ONLY_SUITE=store_nodes make -f Makefile.cbm -j8 test (88 passed); CBM_ONLY_SUITE=sqlite_writer make -f Makefile.cbm -j8 test (10 passed); make -f Makefile.cbm -j8 cbm; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 18:25:37 -04:00
Andrew Hundt 8cdfcc8016 feat(store): add overlay generation metadata
Add overlay generation status vocabulary, a store-level overlay_generations table, and narrow APIs to reserve, update, and count overlay generations. This is metadata only: dirty files still do not hide canonical graph rows, and active overlay read semantics remain a later P.A.N8 slice.

Validation:

- CBM_ONLY_SUITE=store_nodes make -f Makefile.cbm -j8 test: /private/tmp/cbm-pan82-overlay-generation-store-suite-20260703T1815.log (85 passed)

- CBM_ONLY_SUITE=sqlite_writer make -f Makefile.cbm -j8 test: /private/tmp/cbm-pan82-overlay-generation-sqlite-writer-suite-20260703T1815.log (10 passed)

- make -f Makefile.cbm -j8 cbm: /private/tmp/cbm-pan82-overlay-generation-product-build-20260703T1815.log

- bash scripts/check-source-safety.sh: /private/tmp/cbm-pan82-overlay-generation-source-safety-20260703T1815.log

- git diff --check: /private/tmp/cbm-pan82-overlay-generation-diff-check-20260703T1815.log

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 18:05:57 -04:00
Andrew Hundt 5d5c5a513b fix(ui): report dirty freshness on native endpoints
Expose the existing MCP dirty-freshness JSON helpers for reuse and apply them to /api/project-health and /api/layout, so native UI endpoints warn when they are serving canonical graph rows while dirty-file changes are pending overlay or reindex work.

Validation:

- make -f Makefile.cbm -j8 cbm: /private/tmp/cbm-pan8-ui-dirty-product-build-20260703T-final.log

- CBM_ONLY_SUITE=mcp make -f Makefile.cbm -j8 test: /private/tmp/cbm-pan8-ui-dirty-mcp-suite-20260703T-final.log (143 passed)

- CBM_ONLY_SUITE=ui make -f Makefile.cbm -j8 test: /private/tmp/cbm-pan8-ui-dirty-ui-suite-20260703T-final.log (14 passed)

- CBM_ONLY_SUITE=tool_consolidation make -f Makefile.cbm -j8 test: /private/tmp/cbm-pan8-ui-dirty-tool-consolidation-suite-20260703T-final.log (99 passed)

- bash scripts/check-source-safety.sh: /private/tmp/cbm-pan8-ui-dirty-source-safety-20260703T-final.log

- native UI smoke with cbm-with-ui: /private/tmp/cbm-pan8-ui-parity-smoke-20260703T1829.log

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 17:52:59 -04:00
Andrew Hundt 0c330c5c4d fix(mcp): report dirty freshness for source search
Add dirty-file freshness metadata to search_code responses without hiding live source matches. The handler computes dirty counts once and passes them into the existing search_code JSON assembly path, avoiding post-hoc mutation of the outer MCP text wrapper.

Cover the behavior with a focused MCP test that keeps the live source match visible, preserves dirty ledger state, and asserts the source-search-specific graph freshness warning.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 17:24:00 -04:00
Andrew Hundt 179b3c4c4d fix(mcp): report dirty freshness for status resources
Add canonical-only dirty freshness metadata to index_status, codebase://status, and codebase://architecture responses so status/resource reads disclose pending dirty files without hiding canonical counts or summaries.

Cover the behavior with focused MCP and tool_consolidation canaries, and validate with mcp and tool_consolidation suites, source-safety, diff hygiene, and product build logs under /private/tmp.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 17:01:07 -04:00
Andrew Hundt 56c8e10bc5 fix(mcp): report dirty freshness for architecture
Add canonical-only dirty freshness metadata to get_architecture responses so architecture summaries stay visible while pending dirty files are disclosed.

Cover the behavior with an MCP regression test and validate with focused architecture canary, full MCP suite, source-safety, diff hygiene, and product build logs under /private/tmp.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 16:54:18 -04:00
Andrew Hundt 509ce5352d fix(mcp): report dirty freshness for traces
Add canonical-only dirty freshness metadata to trace_path responses so traced callers/callees stay visible while pending dirty files are disclosed.

Cover the behavior with an MCP regression test and validate with focused trace canary, full MCP suite, source-safety, diff hygiene, and product build logs under /private/tmp.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 16:48:54 -04:00
Andrew Hundt 5eeeed8b1a fix(mcp): report dirty freshness for cypher queries
Add canonical-only dirty freshness metadata to query_graph responses so Cypher results stay visible while pending dirty files are disclosed.

Cover the behavior with an MCP regression test and validate the slice with focused query_graph canary, full MCP suite, source-safety, diff hygiene, and product build logs under /private/tmp.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 16:42:04 -04:00
Andrew Hundt 442abe643c fix(mcp): report dirty freshness for graph queries
Decorate search_graph query/BM25 JSON responses with the same dirty-file freshness metadata used by graph-mode search_graph results.

Keep clean projects on the existing fast path by checking dirty counts before parsing and rewriting the query JSON payload.

Add an MCP canary proving query results remain visible while dirty metadata is reported. A pre-fix ASan run caught a project-string lifetime bug; the final MCP suite and source-safety gate pass.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 16:35:13 -04:00
Andrew Hundt 420b1a3e46 feat(store): add dirty freshness ledger
Add a metadata-only dirty_files ledger with named status/source vocabulary, cached store APIs, and validation for dirty source strings.

Mark incremental classifications dirty before publish work, clear them after successful exact or containment publish, and retain them on publish failures so callers can warn instead of silently using stale canonical context.

Expose dirty freshness counts on graph-mode search_graph without hiding canonical rows, and add focused MCP/pipeline canaries plus source-safety validation coverage.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 16:21:49 -04:00
Andrew Hundt bf079b3d0d fix(pipeline): make header fallback replace projects safely
Preserve macro-expanded call recovery without leaking metadata from the preprocessor pass by adding a calls-only unified extraction path.

When exact delta cannot bound a C-family header frontier, fall back to a full rebuild instead of containment. For existing DBs, publish that fallback through the store project-replacement path so dependency sibling projects are preserved and MCP dependency refreshes cannot retain stale skipped-dir rows.

Validation:

- make -j8 -f Makefile.cbm cbm

- CBM_ONLY_SUITE=pipeline build/c/test-runner

- CBM_ONLY_SUITE=mcp build/c/test-runner

- CBM_ONLY_SUITE=extraction build/c/test-runner

- CBM_ONLY_SUITE=watcher build/c/test-runner

- uv run python scripts/benchmark-incremental-speed.py --self-dogfood --transport mcp --self-dogfood-scenarios one_source_file

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 03:10:57 -04:00
Andrew Hundt 188f718e72 fix(pipeline): preserve import frontier parity
Consolidate URL-argument route detection so sequential and parallel call resolution emit the same route nodes and HTTP_CALLS edges for arg-url callsites.

Follow package/module re-export IMPORTS edges when building per-file import maps, preventing same-name suffix collisions from selecting the wrong target.

Expand exact and FAST regular incremental frontiers through persisted graph IMPORTS edges, while keeping full/moderate modes on full rebuild when global derived edges make regular expansion unsafe.

Validation: git diff --check; product build /private/tmp/cbm-pan1-20260703T-prod-build-after-import-frontier-constants.log rc=0; pipeline suite /private/tmp/cbm-pan1-20260703T-pipeline-suite-after-import-frontier-constants.log rc=0 with 309 passed.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 02:04:46 -04:00
Andrew Hundt 3a3a442d6a fix(watcher): refresh baseline after explicit index
Successful index_repository and startup autoindex have just observed the current git state. Refresh the watcher baseline with a dedicated cbm_watcher_mark_indexed() operation instead of reusing idempotent watch(), so the watcher does not immediately reindex the same dirty status after the response.

Keep cbm_watcher_watch() idempotent for ordinary project access and already-indexed startup registration. The new helper shares watcher path validation and the existing baseline snapshot logic, and keeps git I/O outside the watcher mutex.

Validation: CBM_ONLY_SUITE=watcher make -f Makefile.cbm test -> 64 passed (/private/tmp/cbm-pan1-20260703T0505Z-mark-indexed-watcher-suite.log); make -f Makefile.cbm lint-source-safety -> rc 0 (/private/tmp/cbm-pan1-20260703T0510Z-mark-indexed-source-safety.log); make -f Makefile.cbm cbm -> rc 0 (/private/tmp/cbm-pan1-20260703T0512Z-mark-indexed-cbm-build.log); targeted MCP self-dogfood one_source_file -> rc 0 and canonical graph equal (/private/tmp/cbm-pan1-20260703T0514Z-mark-indexed-one-source-mcp.json). Broad MCP self-dogfood improved but remains not fully green: noop and one_source_file pass; route_handler, store_pipeline_batch, and multi_file_small still have containment canonical gaps (/private/tmp/cbm-pan1-20260703T0516Z-mark-indexed-self-dogfood-mcp.json).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 01:03:11 -04:00
Andrew Hundt ea218e17e9 fix(watcher): baseline dirty worktrees
Record the git dirty hash during watcher baseline so an already-dirty worktree registered after explicit MCP indexing is not treated as a new change on the next watcher poll. This prevents watcher-driven full reindex from mutating the project DB after index_repository has returned.

Also preserve adaptive backoff after normal baseline snapshots while still honoring a real touch during an in-flight poll by recording the snapshot's original next_poll_ns.

Validation: CBM_ONLY_SUITE=watcher make -f Makefile.cbm test -> 63 passed (/private/tmp/cbm-pan1-20260703T0538Z-watcher-baseline-suite.log); make -f Makefile.cbm lint-source-safety -> rc 0 (/private/tmp/cbm-pan1-20260703T0544Z-lint-source-safety.log); make -f Makefile.cbm cbm -> rc 0 (/private/tmp/cbm-pan1-20260703T0546Z-watcher-cbm-build.log); targeted MCP self-dogfood one_source_file -> rc 0 and canonical graph equal (/private/tmp/cbm-pan1-20260703T0549Z-watcher-baseline-one-source-mcp.json).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-03 00:41:57 -04:00
Andrew Hundt f00604b926 feat(incremental): expose exact delta telemetry
Add optional exact_delta metadata to index_repository responses so benchmark artifacts can distinguish changed, affected, and published exact-delta path counts without scraping logs. Keep the benchmark parser backward-compatible by reading response metadata first and stderr markers for older binaries.

Validation: make -j16 -f Makefile.cbm cbm; make -j16 -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=mcp CBM_ONLY_TEST=tool_index_repository_reports_incremental_containment_reason build/c/test-runner; CBM_ONLY_SUITE=mcp build/c/test-runner; bash scripts/check-source-safety.sh; uv run python -m py_compile scripts/benchmark-incremental-speed.py; MCP telemetry smoke /private/tmp/cbm-pan2-20260703T0353Z-exact-delta-telemetry-smoke.json.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 22:53:26 -04:00
Andrew Hundt 8ec34350a1 perf(mcp): use git grep for source search
Use git grep --untracked for unscoped search_code requests when the indexed project root is a git worktree. Exact path_filter keeps the one-file grep path and file_pattern keeps the existing recursive grep behavior to preserve include semantics.

Dogfood retained the same two exact-identifier results while reducing elapsed_ms from 80836 to 423 and from 79378 to 422 on the current worktree cache. An isolated temp git fixture also verified that non-ignored untracked active edits remain searchable after indexing.

Validation: product build rc 0; lint-source-safety rc 0; isolated CLI fixture rc 0. The ASan test-runner build was attempted but clang was terminated by signal 15 before the focused MCP suite could run, so that validation remains pending.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 22:31:28 -04:00
Andrew Hundt 3944d4a13f fix(store): derive delta owners from file state
Use file_state as the authoritative indexed-file set when rebuilding node_owners and edge_owners, with File nodes retained as a legacy fallback for imported stores. This fixes same-stem file cases where structural File-node QNs collide, such as src/pipeline/pipeline.c and src/pipeline/pipeline.h, leaving file-backed source nodes ownerless and forcing exact incremental planning to fall back with inbound_edges_require_full.

Add a store_nodes regression covering the same-stem .c/.h case and inbound edge provenance.

Validation: CBM_ONLY_SUITE=store_nodes make -j8 -f Makefile.cbm test (83 passed); make -j8 -f Makefile.cbm cbm; make -f Makefile.cbm lint-source-safety; git diff --check. Benchmarks recorded in /private/tmp/cbm-owner-file-state-cap64-selfdogfood.json, cap256, and cap512.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 18:58:14 -04:00
Andrew Hundt 8584ea2667 fix(registry): make suffix ties deterministic
Resolve equal-score suffix-match candidates by qualified-name order so full indexing, containment incremental indexing, and exact scratch seeding do not choose different targets when registry insertion order differs.

Adds a focused registry regression test for reversed same-name Field insertion order and records the self-dogfood benchmark correction in the ignored evidence ledger.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 18:32:15 -04:00
Andrew Hundt ee97c0c755 perf(mcp): fast-scope exact source path filters
Optimize search_code when path_filter is an anchored literal file regex and file_pattern is omitted. The handler now searches that exact project-relative file instead of recursively grepping the whole project root, while general regex path filters keep the existing post-filter behavior to preserve semantics and freshness.

Clarify the search_code descriptions so file_pattern is the traversal-narrowing control and path_filter is a result filter except for the exact-file fast path. Add search_scope response metadata for non-timing assertions and free compiled path_filter regex state on early returns.

Validation: make -f Makefile.cbm -j16 cbm rc=0 (/private/tmp/cbm-search-code-exact-build1.log); make -f Makefile.cbm -j16 build/c/test-runner rc=0 (/private/tmp/cbm-search-code-exact-test-runner-build1.log); CBM_ONLY_SUITE=mcp ./build/c/test-runner 135/135 rc=0 (/private/tmp/cbm-search-code-exact-mcp-suite1.log); CBM_ONLY_SUITE=tool_consolidation ./build/c/test-runner 98/98 rc=0 (/private/tmp/cbm-search-code-exact-tool-consolidation-suite1.log); make -f Makefile.cbm lint-source-safety rc=0 (/private/tmp/cbm-search-code-exact-source-safety2.log); git diff --check rc=0.

Dogfood: before this fix, path_filter-only search for ^src/pagerank/pagerank\.c$ was interrupted after more than 60s with rc=130. After this fix, the same isolated-cache query returned cbm_rank_refresh_publish_from_pipeline with elapsed_ms=23 and search_scope=path_filter_exact (/private/tmp/cbm-search-code-exact-pathfilter-only-after.stdout).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 18:18:51 -04:00
Andrew Hundt 16f683a98f fix(cli): make subcommand help non-mutating
Return install, uninstall, and update subcommand help before auto-answer parsing, home lookup, index scans, prompts, release checks, downloads, or file mutation.

Refresh top-level usage for existing install/update flags and add focused CLI tests that prove help works with HOME and USERPROFILE unset.

Validation: product build /private/tmp/cbm-cli-help-build1.log rc 0; ASan test-runner build /private/tmp/cbm-cli-help-test-runner-build2.log rc 0; CLI suite /private/tmp/cbm-cli-help-cli-suite2.log rc 0 (118/118); source-safety /private/tmp/cbm-cli-help-source-safety1.log rc 0; manual help smoke outputs under /private/tmp/cbm-cli-help-{install,uninstall,update}1.*.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 17:59:41 -04:00
Andrew Hundt 3b8de83b8e feat(pagerank): support incremental rank deferral
Add an opt-in rank_refresh=stale_on_incremental policy while preserving eager as the default and stale_on_exact as exact-only. Replacement publishes now mark rank-derived views stale before refresh, and MCP index, autoindex, and watcher paths share a publish-kind mapper so refresh policy is applied consistently.

Validation: make -f Makefile.cbm -j8 cbm rc=0 (/private/tmp/cbm-rank-refresh-dry-build1.log); make -f Makefile.cbm -j8 build/c/test-runner rc=0 (/private/tmp/cbm-rank-refresh-dry-test-runner-build1.log); CBM_ONLY_SUITE=pagerank build/c/test-runner rc=0, 57/57 (/private/tmp/cbm-rank-refresh-dry-pagerank2.log); CBM_ONLY_SUITE=pipeline build/c/test-runner rc=0, 307/307 (/private/tmp/cbm-rank-refresh-dry-pipeline2.log); make -f Makefile.cbm lint-source-safety rc=0 (/private/tmp/cbm-rank-refresh-dry-source-safety1.log); git diff --check clean.

Benchmark note: stale_on_exact vs stale_on_incremental self-dogfood comparison is still pending because the escalated uv benchmark run was rejected by the environment usage limit. Historical baseline remains /private/tmp/cbm-pan6-no-late-fallback-selfdogfood-cap256.json.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 17:40:02 -04:00
Andrew Hundt 0db05d3fc9 fix(pipeline): avoid late exact fallback on mixed frontiers
Reject exact upsert before scratch/delta construction when an expanded cross-file frontier also contains file-owned inbound edges from unowned source nodes. The final planner cannot prove regeneration for that mixed shape until after parsing, so early containment avoids paying the large exact batch cost only to fall back later.

Keep ordinary expanded frontiers and single-file regenerated unowned-source edges eligible. Add a pipeline canary that injects the mixed ownership shape, verifies early inbound_edges_require_full fallback, and confirms the changed file is still fresh after containment.

Validation: test-runner rebuild rc=0; CBM_ONLY_SUITE=pipeline rc=0 (307/307); source-safety rc=0; escalated CBM_ONLY_SUITE=incremental CBM_ONLY_TEST=exact rc=0 (1/1); cap256 self-dogfood rc=0 improved from prior 1.39x late fallback to 3.36x early fallback with correctness/oracles/cleanup passing.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 14:47:36 -04:00
Andrew Hundt 2b05dc5a03 fix(pipeline): accept regenerated file-owned inbound edges
Allow exact-delta planning to handle inbound edges whose source node has no file owner when the edge itself is owned by a path in the delta batch and the replacement batch regenerates the same source/target/type edge.

Keep the final planner authoritative so stale unowned-source edges still fall back to full/containment handling. Add paired pipeline canaries for regenerated versus stale file-owned unowned-source CALLS edges.

Validation: build/c/test-runner rebuild rc=0; CBM_ONLY_SUITE=pipeline rc=0 (306/306); source-safety rc=0; escalated CBM_ONLY_SUITE=incremental CBM_ONLY_TEST=exact rc=0 (1/1); self-dogfood cap64 rc=0 moved first blocker to frontier_too_large; cap128/cap256 benchmark evidence recorded in notes.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 14:35:00 -04:00
Andrew Hundt 179d0bb498 feat(pipeline): configure exact frontier limits
Add config-backed exact delta changed/affected frontier limits while preserving the conservative defaults. Exact delete and upsert paths now read the effective limits through shared pipeline getters instead of hardcoded live caps.

Add TDD coverage for default clamping, registry entries, and a configured 5-file inbound frontier that publishes exact and matches a fresh rebuild. Extend the incremental benchmark harness with repeatable --config key=value overrides so cap experiments are reproducible.

Validation: ASan/UBSan test-runner build rc=0; CBM_ONLY_SUITE=pipeline passed 304/304; source-safety rc=0 after harness edit; production cbm build rc=0; benchmark pycompile rc=0. Self-dogfood one_source_file with incremental_exact_max_affected_paths=64 passed canonical/oracle/cleanup checks but still fell back to containment with exact_reason=inbound_edges_require_full and only 3.30x speedup, so incremental remains off by default.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 14:10:41 -04:00
Andrew Hundt 3bd69d4a91 perf(graph-buffer): keep indexes for containment delete
Preserve graph indexes while deleting the target project row in cbm_gbuf_flush_to_store(), then drop/recreate them only around the replacement insert workload. This keeps SQLite's ON DELETE CASCADE from scanning large child tables without FK lookup indexes during incremental containment publishes.

Adds opt-in CBM_PROFILE phase timings for gbuf_flush using the existing structured profiling path; no MCP stdout output and no new heap ownership.

Validation: product build rc=0; ASan/UBSan graph_buffer 66/66; ASan/UBSan pipeline 301/301; source-safety rc=0. Profiled self-dogfood one_source_file improved from 1.51x to 3.52x speedup, with incremental.flush down from 13366 ms to 3914 ms and delete_project down from 10206 ms to 633 ms.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 13:42:22 -04:00
Andrew Hundt fd0b67fd0d fix(pipeline): preserve dependencies during containment
Publish incremental containment through a project-scoped transactional flush instead of replacing the whole SQLite file. The target project is deleted and reinserted so graph/freshness metadata is cleared through existing cascades while sibling dependency subprojects remain available for no-op dependency indexing.

Add a flush-before-commit fault injection point and expand pipeline coverage so publish failures keep the prior DB and fast containment preserves a seeded dependency subproject.

Validation: CBM_ONLY_SUITE=pipeline passed 301/301, graph_buffer 66/66, depindex 35/35, source-safety passed, production cbm build passed, and manual isolated self-dogfood one-file containment returned rc=0 with six dependency subprojects still present. Remaining: containment publish is still slow and benchmark failure reporting needs stronger artifacts before performance claims.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 13:14:36 -04:00
Andrew Hundt 5674782658 fix(mcp): honor per-call dependency controls
Wire index_repository auto_index_deps and auto_dep_limit arguments through the MCP indexing path so explicit calls can disable or cap dependency indexing without changing background/session defaults.

Keep the existing cbm_dep_auto_index API config-driven for current callers and add an already-effective-limit helper for MCP. Add focused MCP tests for false boolean overrides and per-call dependency caps.

Validation: CBM_ONLY_SUITE=mcp build/c/test-runner (134/134), CBM_ONLY_SUITE=depindex build/c/test-runner (35/35), source-safety, production cbm build, and isolated CLI dogfood for auto_index_deps:false and auto_dep_limit:1.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 11:59:42 -04:00
Andrew Hundt 88d7ded8d5 fix(store): reset project metadata reads
Reset cached get_project and list_projects statements after read completion so callers can perform schema/index maintenance on the same store handle.

This fixes the dependency auto-index flush lock exposed by dogfooding: resolve_store verifies the project before dependency indexing, then dependency flush drops/recreates indexes.

Validation: ASan/UBSan test-runner rebuild passed; CBM_ONLY_SUITE=store_nodes passed 83/83; CBM_ONLY_SUITE=depindex passed 35/35; source-safety passed; production cbm build passed; isolated dogfood index no longer logs gbuf.flush.err or database-table-locked and reports dependencies_indexed=6.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 11:34:34 -04:00
Andrew Hundt b776bcbceb perf(depindex): skip unchanged dependency reindex
Persist dependency flush-store replacement metadata through the shared replacement path so dependency file_hash/file_state/pass-fingerprint data is available after auto-indexing.

Use that metadata to skip unchanged dependency subprojects, keep cross-boundary import edges relinked and owned, and reset cached metadata read statements before later store maintenance.

Validation: build/c/test-runner rebuilt with ASan/UBSan; CBM_ONLY_SUITE=depindex passed 35/35; CBM_ONLY_SUITE=store_nodes passed 82/82; source-safety checks passed; production cbm build passed; profiled one-source MCP dogfood passed correctness and cleanup but remains containment/frontier_too_large at 1.155x, so default incremental remains blocked.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 11:27:16 -04:00
Andrew Hundt 9604dc1cfb fix(depindex): keep dependency replacements searchable
Refresh nodes_fts once after a successful dependency auto-index batch so dependency symbols are visible to BM25 search and stale dependency tokens are removed after replacement.

Delete cross-project edges that touch a project before replacing that project graph, so parent IMPORTS edges cannot keep old dependency nodes alive through foreign-key references. Reset cached count statements before returning to avoid active SQLITE_ROW statements locking later schema/index maintenance.

Add a real Python .venv dependency auto-index canary that indexes requests.get, rewrites the dependency to requests.put, reindexes, and verifies nodes_fts freshness. Validated with depindex, graph_buffer, store_nodes, store_edges, source-safety, product build, and final isolated MCP self-dogfood benchmark logs recorded in the plan/ledger.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 10:52:34 -04:00
Andrew Hundt 3c0584fff8 fix(graph-buffer): make store flush rollback-safe
Check every store operation in cbm_gbuf_flush_to_store, keep project replacement inside a transaction, create indexes before commit, and roll back on failure instead of silently committing partial work.

Add a regression that exercises a failed nested BEGIN and verifies the existing project graph is preserved. Validated with source-safety, focused graph_buffer and depindex suites, product build, and the MCP self-dogfood one_source_file scenario.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 10:23:08 -04:00
Andrew Hundt 82d1e6b40f perf(incremental): expand bounded inbound frontiers
Route exact upserts through a bounded transitive inbound source frontier before extraction, using existing file-delta owner metadata and the current affected-path cap. Unsupported, missing, or oversized frontiers still fail closed into containment with structured publish reasons.

Share exact-delta reason and CONTAINS_FILE spellings between the planner and incremental route, and add pipeline coverage for no-op preservation, exact small-frontier parity, and oversized-frontier fallback parity.

Validation: git diff --check; source-safety; ASan/UBSan test-runner build; focused frontier tests; CBM_ONLY_SUITE=pipeline 301/301; product cbm build; MCP self-dogfood one_source_file canonical/oracles passed with containment frontier_too_large and 1.10x speedup.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 09:58:26 -04:00
Andrew Hundt 8c68bb4a8c fix(graph-buffer): reindex mutated node metadata
Keep label/name secondary indexes in sync when an existing qualified-name node is promoted by upsert or merge. The complexity pass relies on Function label lookups, so stale secondary buckets could make fresh full builds omit derived recursive and transitive_loop_depth properties for promoted functions.

Add graph_buffer regressions for direct upsert and merge collisions so the old label/name buckets are emptied and the new buckets contain the existing node once.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 09:26:46 -04:00
Andrew Hundt 95c9c15c0f fix(depindex): honor auto dependency config
Route MCP, autoindex, and watcher dependency indexing through the existing runtime config so auto_index_deps and auto_dep_limit apply consistently instead of always using the default package limit.

Refresh file-delta owner metadata after MCP dependency indexing when incremental metadata is enabled, using a shared generation constant instead of a magic schema-default value.

Validation: source-safety passed; forced ASan/UBSan test-runner rebuild passed; focused depindex 33/33, mcp 132/132, and pipeline 300/300 passed; product cbm build passed. Evidence and remaining default-deps derived-property blocker are recorded in the ignored plan/forensics notes.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-02 09:03:19 -04:00