perf(code-index): resolve trait dispatch from relation keys - #2243
Merged
Merged
Conversation
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
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_keysnow finds every callee's container in one batchedrelation_keysstep (incomingContains), reads only the distinct containers to learn which are traits, and reads callees, implementors and their children only under a trait. The per-calleevisit_trait_dispatch_targetsis 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):(221, 108, 315): seed + 105 callee summaries + 105 edge reads + 10 hydrations, one fan-out per callee(11, 5, 315)on both pages, the same as with dispatch offtyped_callees_carry_their_read_cost…moves from(6, 3, 4)to(3, 4, 5).Starship @ cc825b00,
src/modules/mod.rs::handle, defaults, every page (builtproduction,hotpathbinary, isolatedHOME, capped daemon):(b) Callers (and the other symbol-graph reads) are metered
code_callersand the other symbol-graph primitive reads (symbol and signature search, implementations, type hierarchy) open their reader through the sameCodeGraphReadCostMeter.SymbolGraphPortOutcome::{Completed, Partial}carry the receipt, andsymbol_pageputs it on the envelope.typed_callers_carry_their_read_cost(callers ofWalk::read): master FAILS with nocost((Null, Null, Null)); now PASSES with{"graph_sealed": 3, "graph_staging": 0}, 1 query, 2 rows, plus a matchingtracedecay_costtrailer. On starship,tracedecay_callersonhandle:graph_sealed_reads=9 adjacency_queries=1 adjacency_rows=6.(c) #2226: callable-code touched files
CodeQueryRownames the file each callable-code row was read from,CodeQueryPage::touched_filescollects them, and the callable-code service puts them on the envelope, so these reads get thetracedecay_metricsfooter.callable_code_reads_carry_their_files_and_the_accounting_footer:tracedecay_code_symbol_search"Walk": ends withtracedecay_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 withtracedecay_metrics: before=4101 after=779.Checks
cargo test -p tracedecay --features test-transport --test mcp_suite: 570 passed, 1 failed. The failure isstatus_behavior_test::tracedecay_status_reports_the_sealed_branch_and_keeps_diagnostics_opt_in(status markdown now includesgithub_sourcesince 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.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 dateFixes #2226