fix(mcp): make the docstring budget test environment-independent, trim get_change_risk#955
Merged
Merged
Conversation
…m get_change_risk The budget test measured `fn.__doc__` straight off the registered tool, and `@mcp.tool()` does not return the same string on every version of the `mcp` package. 1.27 runs the docstring through `inspect.cleandoc`; 1.26, which is the version in uv.lock and therefore the one CI installs, leaves each line's source indentation attached. On a long docstring that is a ~90 char swing, enough for `get_change_risk` to measure 1576 locally and 1669 in CI from identical source. The test passed for anyone whose environment had drifted ahead of the lock and failed on main. The test now dedents before measuring, so it scores the prose an agent reads rather than the dependency's normalizing behaviour, and no local environment can be more lenient than CI. Normalizing alone would have hidden a real overage, since under the locked version the schema genuinely shipped 1669 chars. `get_change_risk` also loses the sentence describing `extensions` and `exclude_patterns`, which restated what its own Args block says two paragraphs later. Raw is now 1578 and dedented 1489, so it fits under either version's behaviour.
|
✅ Health: 7.5 (unchanged) 📋 At a glance 📌 Before you merge
🗺️ Change map flowchart LR
subgraph PR ["Changed in this PR (1 with dependents)"]
f_packages_server_src_repowise_server_mcp_server_tool_change_risk_py[".../mcp_server/tool_change_risk.py 🔥"]:::changed
end
f_packages_server_src_repowise_server_mcp_server___init___py[".../mcp_server/__init__.py"]
f_packages_server_src_repowise_server_mcp_server_tool_change_risk_py --> f_packages_server_src_repowise_server_mcp_server___init___py
t_tests_unit_server_mcp_test_change_risk_py(["✅ .../mcp/test_change_risk.py"]):::guard
t_tests_unit_server_mcp_test_change_risk_py -.-> f_packages_server_src_repowise_server_mcp_server_tool_change_risk_py
classDef changed fill:#dbeafe,stroke:#1d4ed8,color:#1e3a5f
classDef warn fill:#fef3c7,stroke:#b45309,color:#78350f
classDef guard fill:#dcfce7,stroke:#15803d,color:#14532d
Solid arrows: code that imports the changed files (1 direct dependent, from the last indexed snapshot). Dashed: history/tests. 🩹 Review priority (files here with the most recent bug-fix history — defects cluster, so review these first)
🔎 More signals (1)🔥 Hotspot touched (1)
📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-20 08:39 UTC |
swati510
approved these changes
Jul 20, 2026
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.
mainis currently red ontest_every_tool_docstring_fits_the_schema_budget, reportingget_change_riskat 1669 chars against a 1600 ceiling.The test's verdict depended on a transitive dependency
It measured
fn.__doc__straight off the registered tool, and@mcp.tool()does not return the same string on every version of themcppackage:uv.lock, so what CI installs)fn.__doc__inspect.cleandoc: 1576On a long docstring that is roughly a 90 char swing. The result: the budget passed for anyone whose environment had drifted ahead of the lock, and failed in CI, from byte-identical source. Any local run was systematically more lenient than CI.
The test now dedents before measuring, so it scores the prose an agent actually reads rather than the dependency's normalizing behaviour, and no environment can score more leniently than CI.
Normalizing alone would have hidden a real overage
Under the locked version the schema genuinely was shipping 1669 chars, about 417 tokens against the ~400 the budget exists to enforce. So
get_change_riskalso loses the sentence describingextensionsandexclude_patterns, which restated what its ownArgsblock says two paragraphs later.Measured from source under both behaviours:
Every registered tool now fits under either interpretation;
get_change_riskis the largest remaining at 1578 raw.Scope
The docstring crossed the limit in #946, and this is not a regression from the two changes that landed after it.
docs/MCP_TOOLS.mddoes not duplicate the removed sentence, and no other test pins it.Worth deciding separately:
uv.lockpinsmcp1.26.0 while newer environments install 1.27.x. Closing that drift deliberately would prevent the next version-dependent surprise.Testing
26 tests across the docstring, change-risk, tool-selection, tool-table-drift and prior-fixes suites pass.