Query library and layering: extract tool logic from the 38k-line bin-only server.rs, move registry.rs out of core, split IndexAccess into an access crate #517
Labels
No labels
code-review
correctness
dos
performance
security
severity/high
severity/low
severity/medium
tech-debt
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
h-dv/code-index#517
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Consolidated scope (triage 2026-11-09)
Priority: Medium: one query path instead of three, and the remaining module cycles.
This issue is now the canonical tracker for:
core/src/registry.rsmakescoredepend on the signing crate; splitIndexAccessand the wire rows into anaccesscrate (edges moved to #543) (from #526, closed and merged here; its full report stays readable there)access↔local_indexis resolved by the access crate;clilink↔mainis harmless crate-root coupling (from #32, closed and merged here; its full report stays readable there)Original report
Summary
The logic behind every MCP tool lives in
crates/mcp-server/src/server.rs, which is 38,497 lines with 558 top-level items and 41 interleaved#[cfg(test)]blocks, inside a crate with nolib.rs. That one fact produces three query paths and several workarounds:crates/cli/src/query.rs:20-48explains it directly: "crates/mcp-serveris a BIN-ONLY crate … the same move here means publishing a 28k-line server as a library". Socode-index queryspawnscode-index-mcpand speaks stdio to it. That doc comment is itself stale: the file has grown about 10k lines since.IndexAccess:daemon/src/local_index.rs(12.8k lines),graph.rs(4.3k) andrefactor.rs(5.0k).server.rsalso opens SQLite directly, bypassingIndexAccess(around:2308, :4330, :4348, :4384, :8929), and makes about 198code_index_indexer::references.single_process(crates/mcp-server/src/main.rs:995-1387) is a fourth wiring of the same tools for--no-daemon.Related size problems:
indexer/src/index.rsis 22k lines,daemon/src/local_index.rs12.8k, anddaemon/src/main.rsrunis one async fn spanning lines 653-1750 (1,098 lines), followed byrearm_for_activation(244 lines). Parallel lanes concentrate their merge conflicts in these files, and every edit to them recompiles and re-reviews a very large unit.Proposal (mechanical, no redesign)
code-index-querylibrary crate holding the tool handlers, argument checking and the disclosure envelope (annotate_evidence_gaps), written only againstIndexAccess. Move the direct SQLite health probes behindIndexAccessmethods.code-index-mcp,code-index queryand--no-daemonall become thin transports over that library. The CLI calls it in-process against an RPCIndexAccess, with no process spawn, and still returns the same answers and the same envelope, which keeps #282's requirement.tools/<tool>.rs) with its unit tests beside it.runinto startup, the event-loop body and shutdown functions.Acceptance
COSI_E2E_LEG=daemon.code-index queryreturns byte-identical JSON before and after, except that the spawn disappears. Measure its latency.Related: #32 (dependency cycles). Found by automated architecture and bloat reviews (2026-11-09). The bin-only crate and the query.rs rationale were verified by hand.
Filed from a five-agent review of master @
e3ec6ead(bloat, robustness, agent usefulness, docs, architecture). Every finding was spot-checked in the main session before filing.Extract tool logic from the 38k-line bin-only server.rs into a query library; the CLI spawns a server process per queryto Query library and layering: extract tool logic from the 38k-line bin-only server.rs, move registry.rs out of core, split IndexAccess into an access crate