Commit Graph
1107 Commits
Author SHA1 Message Date
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
Andrew Hundt 9105f0f73e fix: keep CLI auto-index defaults config-backed
Attach the normal config store before one-shot CLI tool dispatch so CLI calls honor the same registry defaults and env/config overrides as the stdio MCP server. This keeps explicit path search auto-indexing enabled by default for user-facing CLI calls while embedded/no-config helpers remain manual unless CBM_AUTO_INDEX explicitly opts in.

Clarify tool/config/help strings to describe the real behavior: streamlined lists 5 core tools plus _hidden_tools discovery, get_architecture is available after reveal or classic mode, and default tools can auto-index the server CWD or explicit repository paths when enabled.

Validation:

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

- CBM_ONLY_SUITE=mcp build/c/test-runner: 113 passed

- CBM_ONLY_SUITE=tool_consolidation build/c/test-runner: 94 passed

- CBM_ONLY_SUITE=input_validation build/c/test-runner: 43 passed

- CBM_ONLY_SUITE=cli build/c/test-runner: 102 passed

- CLI smoke: isolated explicit repo path auto-indexed without CBM_AUTO_INDEX=true and returned cli_autoindex_sentinel

- CLI stdout/stderr split: JSON on stdout, logs on stderr

- git diff --check

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 11:52:43 -04:00
Andrew Hundt a1c8bf9a0e fix: honor auto_index on first use
Share the MCP auto-index enablement decision across startup, synchronous first-use indexing, and explicit path indexing. Production servers still attach config and keep the registry default auto_index=true, while embedded/no-config servers remain manual unless CBM_AUTO_INDEX explicitly opts in.

This prevents search/trace/resource paths from bypassing auto_index=false after startup and avoids accidental full worktree indexing in test or embedded contexts. The path auto-index regression test now opts in explicitly and restores CBM_AUTO_INDEX afterward.

Validation:

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

- CBM_ONLY_SUITE=mcp build/c/test-runner: 113 passed

- CBM_ONLY_SUITE=tool_consolidation build/c/test-runner: 94 passed

- CBM_ONLY_SUITE=input_validation build/c/test-runner: 43 passed

- git diff --check

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 11:43:46 -04:00
Andrew Hundt 4eb19bc7c5 fix: preserve trace alias and tame embedded startup
Keep the upstream trace_call_path spelling as an unlisted compatibility alias for trace_path. This preserves upstream caller behavior without expanding the streamlined or classic tools/list surface.

Avoid hidden startup work for no-config embedded/test MCP servers: disable the optional release check and keep auto-index manual unless CBM_AUTO_INDEX explicitly opts in. Production CLI servers still attach runtime config before run, so the registry default auto_index=true remains effective there.

Validation: make -f Makefile.cbm build/c/test-runner; 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 11:34:53 -04:00
Andrew Hundt d9dd97ca0b fix: compose semantic search with BM25
Keep search_graph query mode and semantic_query composable: BM25 still owns normal results, while semantic_query is parsed through the same vector-search path and can append semantic_results.

Share the semantic_query type-error response across BM25 and graph search paths so invalid semantic_query values no longer get silently ignored when query is present.

Add MCP regression coverage for query plus invalid semantic_query, and clarify the advertised search_graph parameter descriptions.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 11:20:51 -04:00
Andrew Hundt d4dcf23ff5 fix: frame MCP notifications by transport
Use one protocol writer for JSON-RPC responses and notifications so notification framing matches the active MCP transport.

When a client sends Content-Length-framed requests, _hidden_tools list_changed and resource-change notifications are now emitted as Content-Length frames instead of raw newline JSON that can corrupt the stream.

Add line-mode and framed-transport regression coverage for revealing hidden tools. The new framed fixture is Unix-only because it uses pipe/fdopen/alarm; production framing code is shared.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 11:13:14 -04:00
Andrew Hundt bb30f9f401 test: cover hidden MCP tool reveal
Exercise the real MCP event loop with tools/list, _hidden_tools, and a second tools/list request.

Assert that the server emits notifications/tools/list_changed and that advanced tools become visible to clients that only use advertised tools.

The transport fixture remains Unix-only because it uses pipe, fdopen, and alarm; production notification code stays shared across platforms.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 10:53:55 -04:00
Andrew Hundt d9e97ba2ca fix: clarify MCP API guidance
Document search_graph query as the BM25 path and make clear that graph filters and sort_by do not apply there.

Describe semantic_query as an array that appends separate semantic_results instead of implying it changes the normal result ranking.

Update installed agent guidance and hooks to prefer the streamlined get_code surface, avoid hyperbole, and describe auto-indexing as best-effort.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 10:46:41 -04:00
Andrew Hundt 13fb2659d8 fix: advertise search_graph handler parameters
Expose existing search_graph handler capabilities in tools/list: pattern, query, case_sensitive, and summary. These were already parsed by handle_search_graph but omitted from the schema, making them hard for real MCP clients and models to discover.

Also rename a misleading tool-consolidation test so its name matches the default streamlined-mode behavior it validates.

Verification: make -f Makefile.cbm cbm; make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=tool_consolidation build/c/test-runner (94/94).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 10:37:02 -04:00
Andrew Hundt 5a5af98c88 fix: prevent broad install stops and Codex hook duplicates
Limit install/update process termination to MCP servers running the exact target binary path instead of every process named codebase-memory-mcp. This prevents fake HOME or alternate-prefix installs from killing unrelated agent sessions.

Make Codex config upserts idempotent when the MCP table and SessionStart hook share config.toml. Preserve hook sentinels during MCP section replacement and repair stale duplicate/orphan CMM hook blocks on the next upsert.

Verification: make -f Makefile.cbm cbm; make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=cli build/c/test-runner; fake-HOME install --force collapsed a corrupted Codex config to one MCP section and one SessionStart hook.
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 10:30:19 -04:00
Andrew Hundt 815813ebd3 fix: apply index config to auto-index paths
Centralize pipeline threshold config application and use it for explicit MCP indexing, synchronous and background auto-indexing, path auto-indexing, and dependency pipelines.

Update dependency auto-indexing to accept an optional config pointer instead of adding a compatibility alias, and pass NULL from the standalone watcher path where no config object is available.

Add a focused pipeline unit test for config-backed thresholds.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 10:03:18 -04:00
Andrew Hundt 794e25cb06 docs: correct MCP tool references
Update generated CLI skill text, packaged skill docs, and npm README examples for the current MCP surface: trace_path is the canonical trace tool, index_dependencies is present, and the streamlined/default surface should not be described as exactly 14 tools.

Replace unsupported search_graph direction examples with supported query_graph degree queries and fix stale query/result-limit wording in generated help. Keep measured performance/preprint claims unchanged.

Verified with: make -f Makefile.cbm cbm; make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=cli build/c/test-runner; git diff --check.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 09:46:39 -04:00
Andrew Hundt 0839cb60b1 fix: align streamlined MCP trace surface
Use trace_path as the single canonical call-tracing tool across classic and streamlined tool lists, with the streamlined list reusing the canonical schema to prevent drift. Revealing hidden tools now makes the classic-only tools discoverable through tools/list for clients that only call advertised tools.

Extend trace_path with the existing optional filters and modes exposed by the fork, validate cheap arguments before project resolution so malformed calls cannot trigger auto-indexing, and handle string-array allocation failures explicitly. Add focused coverage for schema parity, hidden-tool reveal, invalid trace modes, test filtering, risk labels, and exclude filters.

Verified 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=tool_consolidation build/c/test-runner; CBM_ONLY_SUITE=input_validation build/c/test-runner; CBM_ONLY_SUITE=token_reduction build/c/test-runner; git diff --check.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 09:40:25 -04:00
Andrew Hundt 60cad1ebbb fix: consolidate trace API and rank persistence
Use trace_path as the single public call-tracing tool across classic and streamlined MCP surfaces, while exposing existing semantic_query and search_code mode parameters in the advertised schemas. Keep the streamlined surface compact, but ensure the hidden-tool reveal covers the full classic capability set without trace aliases.

Persist PageRank, LinkRank, and node_degree rows with direct VALUES inserts instead of per-row SELECT probes. The node/edge project is loaded once with the graph rows so full-scope dependency attribution stays identical to the previous behavior.

Add focused coverage for dependency project attribution, streamlined parameter contracts, and targeted suite allowlist entries so these checks cannot silently run zero tests.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 08:36:56 -04:00
Andrew Hundt 44f7edf370 perf: index LSP call resolution per file
Move the per-file LSP resolved-call hash index into the shared lsp_resolve helper and use it from both sequential and parallel call resolution. This preserves the existing confidence floor, caller/callee match rule, and highest-confidence tie-break while reducing lookup cost from O(calls * resolved_calls) to O(calls + resolved_calls) when the index builds completely.

Reuse the existing registry/service-pattern TLS caches in sequential pass_calls so few-file workloads get the same repeated-name behavior as the parallel resolver. In the generated-parser fixture from tool_consolidation, pass=calls dropped from the prior ~167s shape to ~151ms under ASan.

Also skip callsite scanning when httplink route discovery finds zero routes, and add httplink to CBM_ONLY_SUITE so the focused route tests can be run directly. Validated with tool_consolidation (91 passed), httplink (37 passed), and diff hygiene.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 07:43:24 -04:00
Andrew Hundt 3c13aeb608 fix: reveal hidden MCP tools through tools/list
Streamlined mode kept advanced tools dispatchable but unlisted, which makes them unavailable to clients that only call tools advertised by tools/list. Track a per-session reveal after _hidden_tools, emit notifications/tools/list_changed when possible, and advertise the advanced tools on subsequent tools/list calls.

Keep the initial streamlined surface compact and preserve classic mode/config-enabled tool behavior. Add a regression test for the reveal flow and exact post-reveal tool list.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 07:43:09 -04:00
Andrew Hundt 9bd14cefbb test: lock MCP API surface contracts
Add exact tools/list regression checks for the fork's streamlined and classic MCP surfaces. The tests parse the actual JSON tool array instead of relying on substring matches, so descriptions cannot mask a missing or extra tool entry.

Keep upstream compatibility explicit by verifying the trace_path dispatch alias remains callable while the fork continues to list trace_call_path in its classic surface.

Validation: git diff --check; make -f Makefile.cbm build/c/test-runner; CBM_ONLY_SUITE=tool_consolidation build/c/test-runner (90 passed).
Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-06-28 06:58:53 -04:00