Skip to content

perf(code-index): resolve trait dispatch from relation keys - #2243

Merged
ScriptedAlchemy merged 1 commit into
masterfrom
fleet/receipt-callers-files
Sep 26, 2026
Merged

ScriptedAlchemy merged 1 commit into
masterfrom
fleet/receipt-callers-files

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Three receipt follow-ups, grouped because they share the relation-key code, the contracts retrieval surface, and one test file.

(a) Trait dispatch from relation keys

With MCP defaults (depth 3, trait dispatch on) the dispatch check read every direct callee's summary and incoming edges, on every page. augment_callee_dispatch_keys now finds every callee's container in one batched relation_keys step (incoming Contains), reads only the distinct containers to learn which are traits, and reads callees, implementors and their children only under a trait. The per-callee visit_trait_dispatch_targets is deleted.

relation_page_cost::a_default_callees_page_resolves_dispatch_without_reading_every_callee (105-callee fixture, defaults, page 1 and the cursor page), (point reads, adjacency queries, rows):

  • master: FAILS (221, 108, 315): seed + 105 callee summaries + 105 edge reads + 10 hydrations, one fan-out per callee
  • this PR: PASSES (11, 5, 315) on both pages, the same as with dispatch off

typed_callees_carry_their_read_cost… moves from (6, 3, 4) to (3, 4, 5).

Starship @ cc825b00, src/modules/mod.rs::handle, defaults, every page (built production,hotpath binary, isolated HOME, capped daemon):

before (#2224) after
reads / page 1,066 31
adjacency queries / page 315 12
whole walk (31 pages, 309 rows, same rows) ~33,000 reads 962 reads
page 1: items=10 total=309 reads=31 adjacency_queries=12 adjacency_rows=1550 bytes=81183 wall_us=87799
  stderr: tracedecay_cost: wall_us=87799 graph_sealed_reads=31 graph_staging_reads=0 adjacency_queries=12 adjacency_rows=1550 bytes_hydrated=81183
          tracedecay_metrics: before=30720 after=2647
defaults pages 31 rows 309 distinct 309 total reads 962
depth1 (no dispatch) pages 11 rows 107 distinct 107 total reads 118

(b) Callers (and the other symbol-graph reads) are metered

code_callers and the other symbol-graph primitive reads (symbol and signature search, implementations, type hierarchy) open their reader through the same CodeGraphReadCostMeter. SymbolGraphPortOutcome::{Completed, Partial} carry the receipt, and symbol_page puts it on the envelope.

typed_callers_carry_their_read_cost (callers of Walk::read): master FAILS with no cost ((Null, Null, Null)); now PASSES with {"graph_sealed": 3, "graph_staging": 0}, 1 query, 2 rows, plus a matching tracedecay_cost trailer. On starship, tracedecay_callers on handle: graph_sealed_reads=9 adjacency_queries=1 adjacency_rows=6.

(c) #2226: callable-code touched files

CodeQueryRow names the file each callable-code row was read from, CodeQueryPage::touched_files collects them, and the callable-code service puts them on the envelope, so these reads get the tracedecay_metrics footer.

callable_code_reads_carry_their_files_and_the_accounting_footer:

  • tracedecay_code_symbol_search "Walk": ends with tracedecay_metrics: before=672 …, touched_files: ["src/walk.rs", "src/lib.rs"]. This already passed on master: symbol search is on the symbol-graph route, which reported files. It stays as the regression literal.
  • tracedecay_callees (callable code): master FAILS, no footer; now PASSES, touched_files: ["src/walk.rs"], tracedecay_metrics: before=35 …. On starship, tracedecay_code_exact_occurrence "handle" now ends with tracedecay_metrics: before=4101 after=779.

Checks

  • cargo test -p tracedecay --features test-transport --test mcp_suite: 570 passed, 1 failed. The failure is status_behavior_test::tracedecay_status_reports_the_sealed_branch_and_keeps_diagnostics_opt_in (status markdown now includes github_source since fix(configuration): provision the GitHub origin source binding #2221; red on master, not touched here). After the final rebase, -- graph_query test_map: 50 passed.
  • tracedecay-code-index-runtime lib 515; tracedecay-application lib 476 + application_suite 64 + pr_tracking 7; tracedecay-contracts lib 419 + contracts_suite 276; tracedecay-query 263 + 77 integration; tracedecay-mcp 392 + 12 integration; tracedecay-code-index 257 + 166
  • cargo clippy -p tracedecay-code-index-runtime -p tracedecay-application -p tracedecay-contracts -p tracedecay --all-targets --features tracedecay/test-transport -- -D warnings; cargo fmt --all -- --check; pnpm run contracts:check: contracts up to date

Fixes #2226

With the MCP defaults (depth 3, trait dispatch on) every callees page
read each direct callee's summary and incoming edges to find its
container, so a page of a 309-row listing read 1,066 entities over 315
queries. The dispatch check now finds every callee's container in one
batched relation-key step and reads only the distinct containers, and
the callees, implementors' children, and names under a trait.

Callers and the other symbol-graph primitive reads (symbol and
signature search, implementations, type hierarchy) open a metered
reader too, so their envelopes carry the request cost receipt.

Callable-code reads report the files of the rows they returned as
touched files, so their responses carry the tracedecay_metrics footer.

Fixes #2226
@changeset-bot

changeset-bot Bot commented Sep 26, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 200bfde

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-26T16:58:36.340708Z 200bfde PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ScriptedAlchemy
ScriptedAlchemy merged commit 6a4635f into master Sep 26, 2026
1 check passed
@ScriptedAlchemy
ScriptedAlchemy deleted the fleet/receipt-callers-files branch September 26, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(mcp): callable-code reads report no touched files, so no metrics footer

1 participant