Commit Graph
1123 Commits
Author SHA1 Message Date
Andrew Hundt cbe17f43cd test(pipeline): cover incremental postpass failure
Add an internal test-only incremental phase fault hook and a focused pipeline canary that injects postpass failure directly through cbm_pipeline_run_incremental(). The test verifies the existing DB remains intact and the newly edited symbol is not published after the injected failure.

Also correct stale incremental comments to describe the current full-graph containment path, and replace local timing conversion macros in pipeline_incremental.c with shared constants.

Validation: make -f Makefile.cbm cbm; make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=pipeline ./build/c/test-runner (226 passed); CBM_ONLY_SUITE=incremental CBM_INCR_TEST_ARTIFACT_DIR=/private/tmp/cbm-incr-artifacts-6ea9927-plus ./build/c/test-runner (160 passed, escalated for FastAPI fixture network); bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 09:53:51 -04:00
Andrew Hundt 86ff3010c5 test(storage): cover concurrent writer entry
Add a bounded two-thread sqlite_writer regression that starts independent cbm_write_db calls together and verifies both generated databases with SQLite integrity, root_path, node count, and edge count checks.

This guards the reentrant sort-context fix without relying on sleeps, network, or pipeline state. TSan remains the separate race-detection gate.

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=sqlite_writer ./build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 09:18:05 -04:00
Andrew Hundt e4fd561f0e fix(storage): make writer sorting reentrant
Remove process-global SQLite writer sort comparator state while preserving the existing parallel index-sort phase. Each sort job now carries immutable node/edge context, using qsort_r where available and a no-global fallback elsewhere.

Also make the shared source-code import edge helper build local_name JSON with yyjson so long aliases are not truncated after the import emission consolidation.

Validation: make -f Makefile.cbm cbm; make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=pipeline ./build/c/test-runner; CBM_ONLY_SUITE=sqlite_writer ./build/c/test-runner; CBM_ONLY_SUITE=graph_buffer ./build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 09:12:33 -04:00
Andrew Hundt 91bc0655c3 fix(cli): clarify default MCP tools
Separate the default streamed MCP surface from advanced and CLI-callable tools in --help output. This keeps help aligned with tool_mode=streamlined, get_code, and _hidden_tools without changing dispatch, schemas, config, or handlers.\n\nValidated with production build, rendered --help, source-safety, and diff check.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 08:41:55 -04:00
Andrew Hundt e63b05a076 fix(mcp): align hidden tool payload
Share MCP tool-visibility predicates between tools/list and _hidden_tools so configured advanced tools are reported as already visible instead of still hidden. Build the _hidden_tools payload with yyjson and keep the progressive reveal/list_changed behavior intact.\n\nAdd a focused configured-tool regression and validate with tool_consolidation, mcp, production build, source-safety, diff check, and bounded MCP protocol replay.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 08:38:11 -04:00
Andrew Hundt 47ad730a23 fix(mcp): advertise advanced tool params
Add missing schema entries for handler-supported get_code_snippet.compact and get_architecture.exclude. Tighten advanced tool descriptions so detect_changes.depth and ingest_traces do not claim unimplemented multi-hop or trace-edge behavior.

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=tool_consolidation build/c/test-runner; CBM_ONLY_SUITE=mcp build/c/test-runner; make -f Makefile.cbm cbm; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 08:20:23 -04:00
Andrew Hundt f7bd1e0b0b fix(pipeline): share import edge emission
Route sequential and parallel source-code IMPORTS edges through one internal helper so local_name escaping and self-edge filtering cannot drift. Fix import-map decoding for escaped local_name strings by keeping the raw fast path and using yyjson only when escapes are present.

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=pipeline build/c/test-runner; CBM_ONLY_SUITE=edge_imports build/c/test-runner; CBM_ONLY_SUITE=parallel build/c/test-runner; make -f Makefile.cbm cbm; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 08:11:12 -04:00
Andrew Hundt a2623e1ae2 fix(mcp): validate snippet response contract
Reject invalid get_code/get_code_snippet mode values instead of silently falling back to full-source output, keeping handler behavior aligned with the advertised full/signature/head_tail enum.

Keep the snippet source field reserved for code text by moving provenance to source_origin and preserving colliding node properties as property_source. Add focused MCP and depindex regressions for the enum and duplicate-key contracts.

Validated with: make -f Makefile.cbm cbm; make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=mcp build/c/test-runner; CBM_ONLY_SUITE=depindex build/c/test-runner; CBM_ONLY_SUITE=tool_consolidation build/c/test-runner; CBM_ONLY_SUITE=token_reduction build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 07:58:33 -04:00
Andrew Hundt 4fb9c8c6e6 fix(mcp): normalize positive result limits
search_code and trace_path accepted nonpositive per-call limits even though their config ranges are positive. search_code(limit=0) could emit no structured results, and trace_path(max_results=0) bound LIMIT 0 into traversal.

Add a shared MCP helper for positive integer args and use it for search_graph, search_code, and trace_path so invalid config or request values consistently fall back to the documented defaults.

Add focused MCP regressions for search_code(limit=0) and trace_path(max_results=0).

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=mcp ./build/c/test-runner; CBM_ONLY_SUITE=tool_consolidation ./build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 07:40:19 -04:00
Andrew Hundt 26f574c215 fix(mcp): honor bm25 search_limit
search_graph documented limit as configurable through search_limit, but the BM25 query path used its internal fallback when callers omitted limit. That made default pagination depend on search mode.

Read the config-backed default once in handle_search_graph, apply it to both BM25 and regex/vector paths, and share the search_limit config-key definition with CLI/tests.

Add an MCP regression that sets search_limit=1, omits the request limit, and verifies BM25 returns one result with has_more=true.

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=mcp ./build/c/test-runner; CBM_ONLY_SUITE=tool_consolidation ./build/c/test-runner; CBM_ONLY_SUITE=cli ./build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 07:31:10 -04:00
Andrew Hundt cbacf99e74 docs(cli): list dependency ranking config
search_graph already reads search_disable_dep_ranking, and the MCP schema names that config key. Add it to CBM_CONFIG_REGISTRY so config list/get guidance exposes the same setting users see in the API description.

Add a CLI registry regression test for the key, default, range, and dependency-ranking guidance. This does not change search behavior, MCP schemas, DB schema, or tool visibility.

Validated with make -f Makefile.cbm build/c/test-runner, CBM_ONLY_SUITE=cli ./build/c/test-runner, CBM_ONLY_SUITE=tool_consolidation ./build/c/test-runner, git diff --check, and bash scripts/check-source-safety.sh.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 07:19:07 -04:00
Andrew Hundt d8613a2974 docs(mcp): clarify compact config defaults
The search_graph, trace_path, and streamlined get_code handlers read the compact config key before applying a per-call compact override. Make the tool schema descriptions say that explicitly instead of implying a fixed schema-only default.

Add a tool_consolidation schema assertion so the streamlined tools/list output continues to mention the compact config key. No handler behavior, tool visibility, API names, or DB/schema behavior changed.

Validated with make -f Makefile.cbm build/c/test-runner, CBM_ONLY_SUITE=tool_consolidation ./build/c/test-runner, CBM_ONLY_SUITE=mcp ./build/c/test-runner, git diff --check, and bash scripts/check-source-safety.sh.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 07:11:28 -04:00
Andrew Hundt 561d5dd0a4 refactor(pipeline): share httplink binding maps
FastAPI, Express, and cross-file group prefix resolution had duplicate fixed-size regex capture maps and ad hoc span copies. Replace them with a local bounded binding helper and named limits.

Overlong captures now fail closed instead of leaving empty match keys or prefixes, and temporary route path buffers are sized from the destination path field. No route extraction semantics, API surface, DB schema, or global state changed.

Validated with make -f Makefile.cbm build/c/test-runner, CBM_ONLY_SUITE=httplink ./build/c/test-runner, CBM_ONLY_SUITE=pipeline ./build/c/test-runner, git diff --check, and bash scripts/check-source-safety.sh.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 07:02:22 -04:00
Andrew Hundt acb94a73df perf(pipeline): precompute route match descriptors
Infra route matching repeatedly reclassified every Route while scanning each infra URL. Build a temporary per-pass descriptor array for eligible handler Routes so broker filtering, handler path extraction, file path capture, and prefix-route detection are computed once.

Keep allocation failure safe by falling back to the scan path through the same match helper. This improves constant factors without adding permanent graph indexes or changing route semantics.

Validated with infrascan, route_canon, pipeline, diff checks, and source-safety.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 06:50:47 -04:00
Andrew Hundt 6e45c08c70 fix(store): disambiguate generic cluster labels
Generic cluster names such as get/load could still collide when two communities lived under the same top-level package. Add a label-only namespace context derived from existing qualified names so labels can distinguish communities like app.orders and app.billing without changing the public packages field.

Add a store_arch regression for the same-top-package collision class. Validated with the focused store_arch and store_search suites plus diff/source-safety checks.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 06:45:07 -04:00
Andrew Hundt 3fbcc0c077 refactor(pipeline): share route property extraction
Replace duplicate route-node JSON string extractors with one checked helper that fails closed on missing, empty, or overlong values rather than routing on truncated data.

Extend the infrascan route guard regression with an overlong HTTP url_path case so truncated Route nodes cannot reappear. Focused validation passed for route_canon, infrascan, parallel, pipeline, and source-safety.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 06:25:57 -04:00
Andrew Hundt dbf74e1ae3 test(pipeline): cover persisted route purity
Add an end-to-end pipeline regression that persists a FastAPI route and verifies filesystem-looking and slash-command literals do not appear as Route nodes or Route search results.

The fixture uses the existing decorator route-definition path as its positive control and checked CBM_PATH_MAX buffers for generated temp paths. Focused validation passed for route_canon, infrascan, parallel, pipeline, and source-safety.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 06:18:32 -04:00
Andrew Hundt d5295ee51a refactor(pipeline): consolidate route identity
Add a shared pipeline-internal route identity builder for HTTP and async Route nodes, including common ANY/async defaults and JSON properties.

Use it from sequential, parallel, route-node, cross-repo, decorator, arg-url, and infra async topic paths so route QName and property formatting cannot drift between emitters.

This also fixes malformed Route/INFRA_MAPS properties that could previously persist bare method/broker strings or unescaped infra values.

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=route_canon ./build/c/test-runner; CBM_ONLY_SUITE=infrascan ./build/c/test-runner; CBM_ONLY_SUITE=parallel ./build/c/test-runner; CBM_ONLY_SUITE=pipeline ./build/c/test-runner; bash scripts/check-source-safety.sh.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 06:05:15 -04:00
Andrew Hundt c76c2ade6d refactor(mcp): share trace result emission
Extract trace_path caller/callee JSON item emission into one local helper so filtering, deduplication, compact-name handling, risk labels, pagerank output, and dependency tagging cannot drift between directions.

The response shape is unchanged: callers/callees fields and totals keep their existing names and meanings, and traversal data is still freed only after JSON serialization because yyjson borrows node strings.

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=mcp ./build/c/test-runner; CBM_ONLY_SUITE=tool_consolidation ./build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 05:47:24 -04:00
Andrew Hundt 2d00624607 perf(mcp): reuse bfs pagerank scores
Carry the PageRank score already selected by cbm_store_bfs through cbm_node_hop_t so trace_path can serialize it without issuing one cbm_pagerank_get query per emitted node.

This keeps the trace_path response shape unchanged while removing up to O(k) extra point queries per traced direction, where k is the number of emitted traversal nodes.

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=store_search ./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-06-30 05:41:19 -04:00
Andrew Hundt 5f4ca14968 fix(cli): decouple session hook matchers
Use the Claude SessionStart matcher array length instead of the unrelated NUM_DIRS constant, and expose the helper with a Claude-specific name that matches the Gemini session hook API.

Add a focused CLI regression test that verifies startup, resume, clear, and compact SessionStart hooks are all installed and removed.

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=cli ./build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 05:35:11 -04:00
Andrew Hundt ec650bb3ce fix(cli): classify planned skill installs
Add a skill_dirs_planned array to the install --plan receipt and route planned Claude Code skill directory writes there instead of instruction_files_planned.

This keeps the no-mutation install receipt accurate for agents reviewing planned changes before install. Real install behavior and hook upsert paths are unchanged.

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=cli ./build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check; make -f Makefile.cbm cbm; HOME=/private/tmp/cbm-install-plan-smoke-20260630 ./build/c/codebase-memory-mcp install --plan.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 05:28:24 -04:00
Andrew Hundt 809b1db87a docs(cli): clarify installed guidance
Update generated agent instructions and SessionStart reminder text to use the same explicit auto-index conditions as the MCP schema: auto_index=true and under auto_index_limit.

Also describe search_code as text/regex source search instead of graph-augmented grep, avoiding an overclaim about behavior.

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=mcp ./build/c/test-runner; CBM_ONLY_SUITE=tool_consolidation ./build/c/test-runner; CBM_ONLY_SUITE=cli ./build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 05:19:48 -04:00
Andrew Hundt 0225ddb8b8 docs(api): clarify auto-index conditions
Tighten MCP and installed hook wording so auto-index behavior is described by its actual gates: auto_index=true and the repository remaining under auto_index_limit.

This keeps the streamlined/classic tool surfaces, hook matchers, and install behavior unchanged while making the descriptions more actionable for MCP clients and CLI hook users.

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=mcp ./build/c/test-runner; CBM_ONLY_SUITE=tool_consolidation ./build/c/test-runner; CBM_ONLY_SUITE=cli ./build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 05:15:01 -04:00
Andrew Hundt f3860a3830 perf(store): speed architecture edge weighting
Replace the architecture community preprocessing nested scans with sorted node refs and sorted normalized edge pairs. The weighting step now maps endpoints by binary search, sorts pairs, and merges duplicates deterministically instead of scanning nodes and accumulated edges for every raw edge.

This changes the preprocessing bound from roughly O(E*N + E*U) to O(N log N + E log E) plus linear merge, where U is the unique normalized edge count. It keeps the public cbm_louvain/cbm_leiden contract unchanged and ignores missing endpoints and self-edges as before.

Add a regression test for unsorted nodes, reversed duplicate edges, self-edges, and missing endpoints.

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=store_arch ./build/c/test-runner; bash scripts/check-source-safety.sh; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 05:09:27 -04:00
Andrew Hundt f66dd63772 test(runner): expose every suite filter
Expand CBM_ONLY_SUITE coverage to match the default full-run suite list. The previous allowlist declared 94 suites but exposed only 29 through the focused filter, which let relevant runs report 0 passed instead of executing the intended suite.

Validation: mechanical selector/default comparison reported filtered 94 default 94 with no missing or extra suites; make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=arena ./build/c/test-runner > /private/tmp/cbm-logs/only-suite-arena.log 2>&1 (31 passed); CBM_ONLY_SUITE=dump_verify_io ./build/c/test-runner > /private/tmp/cbm-logs/only-suite-dump-verify-io.log 2>&1 (3 passed); bash scripts/check-source-safety.sh > /private/tmp/cbm-logs/source-safety-only-suite-coverage.log 2>&1 ([source-safety] OK).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 04:41:36 -04:00
Andrew Hundt bd27722481 fix(lsp): keep C cross registry read-only
Guard C/C++ AST-discovered registry enrichment when the Tier-2 cross registry is shared across resolve workers. This covers default-arg min_params updates, bare function declarations, template type metadata, and class method pre-pass registration so worker-local arena pointers are not stored in shared registry state.

Add a focused c_lsp regression test and wire CBM_ONLY_SUITE=c_lsp so this path can be rerun cheaply. Also make every lsp_all.o variant depend on the included LSP sources/headers; otherwise resolver edits can silently link stale unity objects.

Validation: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=c_lsp ./build/c/test-runner > /private/tmp/cbm-logs/c-lsp-shared-registry.log 2>&1 (743 passed); CBM_ONLY_SUITE=parallel ./build/c/test-runner > /private/tmp/cbm-logs/parallel-c-lsp-shared-registry.log 2>&1 (22 passed); bash scripts/check-source-safety.sh > /private/tmp/cbm-logs/source-safety-c-lsp-shared-registry.log 2>&1 ([source-safety] OK).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 04:34:04 -04:00
Andrew Hundt 4631a483ed fix(graph): reject malformed dump inputs
Add graph-buffer structural invariant validation before SQLite writer handoff so invalid live node IDs, stale node_by_id mappings, missing edge endpoints, and inconsistent edge indexes fail before temp DB creation instead of being silently remapped or dropped.

Add focused graph-buffer tests for valid graphs and missing endpoint rejection, adjust the pipeline-path isolation fixture to use the same shared ID allocation contract as production worker buffers, and add a direct sqlite_writer replay for node_vectors and token_vectors payloads.

Validation: git diff --check; make -f Makefile.cbm build/c/test-runner; bash scripts/check-source-safety.sh; CBM_ONLY_SUITE=graph_buffer ./build/c/test-runner (58 passed); CBM_ONLY_SUITE=sqlite_writer ./build/c/test-runner (8 passed); CBM_ONLY_SUITE=pipeline ./build/c/test-runner (222 passed); CBM_ONLY_SUITE=incremental ./build/c/test-runner (160 passed).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 04:13:02 -04:00
Andrew Hundt c9d9fd2d8d fix(pipeline): stabilize incremental graph parity
Consolidate per-file import-map readers onto resolved IMPORTS edges so calls, usages, semantic, parallel resolve, and LSP-cross consumers share the same semantics instead of duplicating raw extraction-cache parsers.

Make duplicate short-name import fallback deterministic with import-path proximity scoring and qualified-name tie-breaks, and make semantic-edge call-neighbor selection deterministic before applying the MAX_CALLEES cap.

Refresh the shared worker ID source after registry build before parallel resolve in full and parallel-incremental paths, preventing worker-local node IDs from colliding with main graph nodes allocated between phases.

Add focused regression coverage for re-export parity, duplicate import fallback, sequential-vs-parallel duplicate import inheritance, and channel edges targeting Channel nodes after parallel full indexing.

Validation: git diff --check; bash scripts/check-source-safety.sh; make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=pipeline ./build/c/test-runner (222 passed); CBM_ONLY_SUITE=incremental ./build/c/test-runner (160 passed).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 03:30:34 -04:00
Andrew Hundt 7f87331e0c test(incremental): cover failed publish propagation
Expose the graph-buffer dump publish fault hook name from graph_buffer.h so tests and implementation share one constant instead of repeating the environment variable string.

Add a small pipeline incremental regression test that forces a dump failure before atomic replacement, asserts the incremental run returns failure, and verifies the previous DB remains unchanged with the new function unpublished.

Validation: git diff --check && make -f Makefile.cbm build/c/test-runner && CBM_ONLY_SUITE=graph_buffer ./build/c/test-runner && CBM_ONLY_SUITE=pipeline ./build/c/test-runner && bash scripts/check-source-safety.sh
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 01:35:42 -04:00
Andrew Hundt 0792a127d7 docs(agents): clarify reuse conventions
Add a general developer note to search for existing semantic capabilities and established architecture conventions before adding helpers, flags, metadata, APIs, algorithms, or new paths.

The guidance explicitly covers ownership, allocator, threading, logging, portability, protocol-output, naming, and prefix conventions, with CBM_* called out only as this repository's naming example.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 01:29:42 -04:00
Andrew Hundt bc6c76dac6 test(graph): cover failed dump publication
Add a narrow test-only fault hook at the graph-buffer dump publish boundary, after temp database verification and before atomic replacement. The hook is enabled only by CBM_TEST_FAIL_GBUF_DUMP_BEFORE_REPLACE and logs through cbm_log_error without stdout output.

Add a regression test that publishes an existing DB, injects a failure before replacement during a second dump, and verifies the original graph remains queryable while the new graph is not published.

Validation: git diff --check && make -f Makefile.cbm build/c/test-runner && CBM_ONLY_SUITE=graph_buffer ./build/c/test-runner && bash scripts/check-source-safety.sh
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 01:28:23 -04:00
Andrew Hundt 3c0210a9fe test(parallel): cover full-pipeline worker parity
Add a 66-file Python fixture that forces the production pipeline across the sequential and parallel branches. The test runs CBM_WORKERS=1, 2, 4, and default workers against isolated SQLite stores, then checks integrity, project root persistence, file-hash count, representative qualified names, and node/edge/type-count parity.

Use bounded formatting and existing test/platform helpers so fixture paths fail closed on truncation and cleanup removes SQLite sidecars without adding stdout-sensitive debug output.

Validation: make -f Makefile.cbm build/c/test-runner && CBM_ONLY_SUITE=parallel ./build/c/test-runner && bash scripts/check-source-safety.sh
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 01:16:41 -04:00
Andrew Hundt ecc8e4d43b fix(graph): harden determinism and safety canaries
Stabilize several graph-producing paths and add stronger regression coverage before the incremental redesign work continues.

Key changes:

- resolve call import maps from resolved graph-buffer IMPORTS edges so re-exported targets are reused consistently

- make semantic, similarity, complexity, route/section upserts, and resolver scoring more deterministic across full/incremental and worker-order differences

- propagate incremental phase/persist failures instead of continuing toward publication after failed phases

- add canonical graph diff helpers and stricter incremental artifacts for full-vs-incremental comparison

- add source-safety lint coverage for MCP stdout, unsafe string APIs, and new raw env/fs API usage

- replace touched unsafe string copies with bounded or project-wrapper-based forms

Validation:

- make -f Makefile.cbm build/c/test-runner

- CBM_ONLY_SUITE=pipeline ./build/c/test-runner: 217 passed

- CBM_ONLY_SUITE=graph_buffer ./build/c/test-runner: 55 passed

- CBM_ONLY_SUITE=mcp ./build/c/test-runner: 117 passed

- CBM_ONLY_SUITE=simhash ./build/c/test-runner: 24 passed

- CBM_ONLY_SUITE=parallel ./build/c/test-runner: 21 passed

- CBM_ONLY_SUITE=watcher ./build/c/test-runner: 57 passed

- bash scripts/check-source-safety.sh: OK

Known remaining:

- CBM_ONLY_SUITE=incremental still fails incr_accuracy_vs_full: 159 passed, 1 failed. Current artifacts show stale IMPORTS/CALLS/USAGE targets in unchanged importers and downstream SEMANTICALLY_RELATED drift; this is tracked in the forensic notes as a fallback-first incremental redesign task.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-30 00:38:07 -04:00
Andrew Hundt cce2365269 fix: scope architecture summaries by path
Port upstream get_architecture path scoping while preserving fork-specific route filtering, hotspot limits, Leiden resolution tuning, and cluster labels.

Add shared store helpers for normalized path prefixes, scoped node/edge/schema counts, and a scoped architecture entry point while keeping the existing store API as a no-path wrapper for internal compatibility.

MCP get_architecture now accepts path, emits normalized path plus root/scoped totals when scoped, and scopes architecture sections consistently. Tests cover store scoping, trailing slash/backslash normalization, and MCP response filtering.

Verified: make -f Makefile.cbm build/c/test-runner; make -B -f Makefile.cbm build/c/codebase-memory-mcp; make -f Makefile.cbm build/c/codebase-memory-mcp; CBM_ONLY_SUITE=store_arch, mcp, tool_consolidation.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 18:36:04 -04:00
Andrew Hundt 4fa1419910 fix: validate cache dbs before quarantine
Validate candidate project databases with the existing read-only CBM schema check before opening them through the read-write query path. This prevents unrelated SQLite files in CBM_CACHE_DIR from being touched by pragma setup or moved to .corrupt.

Keep quarantine limited to managed cache databases, retain corrupt files when quarantine cannot be proven safe, and update the store integrity comment so future callers do not treat arbitrary .db files as owned data.

Add an MCP regression that places a foreign SQLite database in the cache directory and verifies it remains in place without quarantine or WAL/SHM side effects.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 18:10:44 -04:00
Andrew Hundt c82129df26 test: clarify streamlined tool surface ownership
Update stale MCP tool-surface test wording to reflect the current design: canonical tools, including trace_path, are emitted from TOOLS[] in both classic and streamlined modes so schemas do not drift.

Keep get_code documented as the streamlined alias and describe _hidden_tools as an additional discovery hint, not one of the five user-facing default tools.

Verified with make -f Makefile.cbm build/c/test-runner, make -B -f Makefile.cbm build/c/codebase-memory-mcp, CBM_ONLY_SUITE=mcp (114 passed), and CBM_ONLY_SUITE=tool_consolidation (94 passed).

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 17:54:12 -04:00
Andrew Hundt bc969cf012 fix: quarantine corrupt cache databases
Stop deleting structurally corrupt derived cache DBs during MCP store resolution.

Move corrupt cache DBs to <project>.db.corrupt only when that quarantine target does not already exist, and keep the active corrupt cache path in place if quarantine fails. This is diagnostic quarantine, not a recovery backup.

Add cbm_move_file_no_replace() to keep no-overwrite move semantics centralized across POSIX and Windows, and use it for DB/WAL/SHM quarantine sidecars.

Verified with make -f Makefile.cbm build/c/test-runner, make -B -f Makefile.cbm build/c/codebase-memory-mcp, CBM_ONLY_SUITE=mcp (114 passed), and CBM_ONLY_SUITE=security (39 passed).

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 17:44:04 -04:00
Andrew Hundt a0581987f5 fix: align OpenClaw and worktree discovery
Port upstream OpenClaw MCP config behavior to the fork branch: OpenClaw now writes nested mcp.servers entries with enabled, command, and args instead of the generic mcpServers shape, while preserving existing config.

Also skip .claude-worktrees during discovery to avoid indexing stale duplicate worktree content alongside the existing .claude and .worktrees exclusions.

Verified: build/c/test-runner; build/c/codebase-memory-mcp; CBM_ONLY_SUITE=cli (107); CBM_ONLY_SUITE=discover (84).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 17:21:55 -04:00
Andrew Hundt 608b51374e fix: apply autoindex limits consistently
Use the bounded discover count for startup, first-use, and explicit path autoindexing so CBM_AUTO_INDEX_LIMIT cannot be bypassed by a later MCP handler path.

Move sync first-use indexing into resolve_project_store via a shared MCP-local helper, leaving REQUIRE_STORE responsible for joining an in-flight startup index and reporting missing stores. This avoids duplicate indexing attempts and duplicate over-limit warnings while preserving structured stderr logging.

Add an input-validation regression for over-limit explicit path projects and clarify the config help text to say the limit counts indexable files.

Verified: build/c/test-runner; build/c/codebase-memory-mcp; CBM_ONLY_SUITE=input_validation (44), mcp (113), discover (83), cli (104).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 17:09:51 -04:00
Andrew Hundt ba3d97c66a fix: bound autoindex with discover filters
Use the discover walker for MCP autoindex file-limit checks instead of shelling out to git ls-files, so non-git roots and ignored files follow the same filters as indexing.

Add typed effective config helpers so env-backed registry settings such as CBM_AUTO_INDEX_LIMIT and CBM_REINDEX_ON_STARTUP are honored consistently by MCP startup logic.

Repair the CBM_ONLY_SUITE discover allowlist and add regressions for bounded non-git discovery counts and env-over-db config priority.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 16:41:31 -04:00
Andrew Hundt b0858ee1b6 fix: preserve config store during index cleanup
Install, update, and uninstall cleanup paths are scoped to project indexes, but the old .db predicate also selected _config.db. Add a shared project-index predicate, exclude the persistent config store, and keep list/count/remove behavior consistent.

Verification: make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=cli build/c/test-runner; make -B -f Makefile.cbm build/c/codebase-memory-mcp.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 16:14:36 -04:00
Andrew Hundt a1120631da docs: clarify tool surface descriptions
Remove brittle hardcoded tool-count wording from MCP hidden-tool and CLI config descriptions. Keep the concrete tool names and discovery instructions intact so maintainers and MCP clients see the same capabilities without stale numeric claims.

Verification: make -f Makefile.cbm build/c/test-runner build/c/codebase-memory-mcp; CBM_ONLY_SUITE=tool_consolidation build/c/test-runner; CBM_ONLY_SUITE=mcp build/c/test-runner; CBM_ONLY_SUITE=cli build/c/test-runner.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 15:59:12 -04:00
Andrew Hundt 205e9692e4 fix: stabilize incremental route parity
Rebuild route-derived edges during incremental indexing and clear only derived HANDLES/DATA_FLOWS rows that are owned by the route reconciliation pass.

Make infra route matching order-independent by considering every matching handler route, and make prefix-route bridging inspect every registrar edge while keeping diagnostics on the existing logger.

Reuse the full-index file/folder structure helper for changed files so incremental updates restore File metadata and CONTAINS_FILE/CONTAINS_FOLDER edges consistently.

Add graph-buffer selective edge deletion and regression coverage for route matching, prefix bridging, and full-vs-incremental edge accuracy.

Tests: build/c/codebase-memory-mcp; CBM_ONLY_SUITE=graph_buffer build/c/test-runner; CBM_ONLY_SUITE=infrascan build/c/test-runner; CBM_ONLY_SUITE=pipeline build/c/test-runner; CBM_ONLY_SUITE=incremental build/c/test-runner; CBM_WORKERS=1 CBM_ONLY_SUITE=incremental build/c/test-runner.

Caveat: incremental remains below the >=10x speedup gate for default enablement; full rebuild remains the safe default until the delta design is redesigned and measured.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 15:39:54 -04:00
Andrew Hundt d15071c947 fix: suppress spurious route nodes
Tighten service-pattern matching so short framework ids such as gin. do not match unrelated QNs like plugin.*, while keeping separator-based wrappers such as requests_get working.

Reject bare HTTP-verb decorators like unittest.mock.patch as route decorators unless they have a receiver, and skip package manifests when promoting infra URL string refs to Route nodes.

Validation: build/c/test-runner builds; CBM_ONLY_SUITE=infrascan 4/4; extraction 195/195; depindex 32/32; lang_contract 31/31; edge_types_probe 52/52; isolated autorun index now stores 0 Route nodes.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 13:12:16 -04:00
Andrew Hundt cf481bd896 fix: disambiguate generic cluster labels
Add package context to architecture cluster labels only when the top hub name is generic, such as get or run. This keeps useful hub labels while avoiding repeated labels for separate package clusters.

Add a store_arch regression test with two get-centered synthetic clusters to verify package-qualified labels remain distinct.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 12:45:39 -04:00
Andrew Hundt cfdbe67c0d docs: update MCP surface wording
Replace stale 14-tool and incremental-refresh wording with the current streamlined-plus-classic tool model and configurable reindex policy.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 12:39:13 -04:00
Andrew Hundt 67bb858edd docs: clarify refresh policy claims
Update README, generated docs, and bundled skills so auto-index and watcher text no longer implies incremental refresh is the default path.

Keep the wording aligned with the current config-backed default: full atomic rebuild unless incremental_reindex is explicitly enabled for benchmarking or canary coverage.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 12:36:09 -04:00
Andrew Hundt abadfae9ed fix: default incremental reindex to full rebuilds
Default incremental_reindex to off so normal indexing uses the existing full atomic rebuild path until the disk incremental implementation avoids full-graph load, quality-pass, FTS rebuild, and dump work. This matches the measured behavior where small FastAPI edits can be slower through the current incremental path than a full rebuild.

Keep fast and always as explicit opt-ins for benchmarking and canary tests. Update pipeline tests that intentionally validate legacy incremental behavior to set incremental_reindex=always locally instead of relying on production defaults.

Validation: make -f Makefile.cbm build/c/test-runner cbm; CBM_ONLY_SUITE=pipeline build/c/test-runner: 212 passed; CBM_ONLY_SUITE=cli build/c/test-runner: 102 passed; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 12:27:27 -04:00
Andrew Hundt a7e80d8a61 fix: guard slow incremental reindex routing
Add a config-backed incremental_reindex policy with default fast so full and moderate indexes rebuild atomically instead of entering the current disk incremental path, which still performs full-graph quality work and can be slower than a clean rebuild. Keep always for benchmarking and off for deterministic full rebuilds.

Harden the existing incremental path around allocation failures before mutation: classify, changed-file list, graph buffer creation, changed-path set, and deleted-path copies now fail closed or preserve existing nodes rather than dereferencing NULL or recording corrupt path arrays.

Reuse the existing pipeline nanosecond constant for file-hash mtimes and keep the dedicated incremental suite opted into incremental_reindex=always so its canaries continue exercising the legacy disk incremental implementation.

Validation: make -f Makefile.cbm build/c/test-runner cbm; CBM_ONLY_SUITE=pipeline build/c/test-runner: 212 passed; CBM_ONLY_SUITE=cli build/c/test-runner: 102 passed; CBM_ONLY_SUITE=mcp build/c/test-runner: 113 passed; CBM_ONLY_SUITE=tool_consolidation build/c/test-runner: 94 passed; git diff --check.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 12:14:52 -04:00