Repository navigation
perf: share one tools/list across manifest-reading rules - #172
Open
abu-tahir-0 wants to merge 1 commit into
Open
abu-tahir-0 wants to merge 1 commit into
abu-tahir-0 wants to merge 1 commit into
Conversation
Every HTTP rule built its own probe, so each rule that only reads the tool manifest fetched it again. A scan now carries a ManifestCache and those rules call probe.manifest(); rules that test the request itself keep calling tools_list() and still make every call they want.
This branch has not been deployed
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.
Problem
Every HTTP rule gets its own
Probe, so each rule that only reads the tool manifest fetchedtools/listagain. A full scan of the conformant fixture made 62tools/listrequests, most of them the same reply. Closes #151.Solution
run_scancreates oneManifestCacheper scan and attaches it to the probes it builds.Probe.manifest_cacheis deliberately not copied bywith_token()ornew_connection(): those exist to compare this principal or connection against another, so they must ask again.Probe.manifest()returns the shared reply; without a scan-attached cache it is exactlytools_list().manifest(): naming, ordering, schema, envelopetools-declare-input-schema/tools-are-named, the style and manifest-budget rules, andsnapshot.fetch_tools(so the injection/scope rules and the report's manifest hash reuse it too).tools_list()and make every call they want. The determinism rule still makes its twenty.Testing
tests/harness/test_manifest_cache.py(4 tests): seven manifest-reading rules make exactly onetools/list; the determinism rule still makes 21 (its 20 plus the report's manifest hash); the cache reuses a usable reply but retries an unusable one; a probe with no scan cache keeps asking.pytest tests/harness/test_manifest_cache.py— 4 passed.pytest tests -m unit -n auto— 396 passed, 4 failures (test_population.py::test_only_current_servers_are_graded, twotest_graybox.pycases,test_triage.py::test_a_baseline_never_hides_what_was_fixed). The same suites fail onmainunder-n autowith a different subset each run; they pass individually except the knowntest_populationandtest_fleet_servicecases recorded in the repo. Nothing here touches their assertions or the fingerprints they compare.ruff check .— clean;mypy— success (56 files).Measurements
Conformant fixture, JSON-RPC methods counted in
dispatch: 62 → 45tools/list, 122 → 105 total requests.benchmarks/servers/pysdk_demo.py(mcp2.3.0, loopback), median of five scans after warm-up, same 68 findings / 7 FAILs: 38.6 ms → 33.2 ms. Loopback has no network latency, so the saved work shows up mostly as 17 fewer roundtrips on a remote server. Recorded inbenchmarks/README.md.Impact
A remote scan no longer pays seventeen extra roundtrips just to read one manifest, while every rule that asserts on the request still sees a real reply.