Repository navigation
get_ag_health fills its fleet-wide answer to the 32 KB budget by size, not a fixed group count - #4568
Merged
Merged
Conversation
… not a fixed count A 42-group production fleet (2 replicas plus 6-14 databases per group) measured 63,333 characters against the shared 32 KB MCP response budget, about 2x over. The fixed default page (11 groups) was sized from a 2.7 KB/group fixture; real groups ran closer to 6 KB. The fill is now measured by actual serialized bytes: groups are added most-severe-first while the running UTF-8 size stays under the budget, stopping before the group that would cross it. At least one group is always returned, even an oversized one. groups_truncated and its note now say whether the byte budget or the caller's limit was the reason. Refs #4471 #4474
…ps to fit the budget
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.
Refs #4471 #4474
Why
A 42-group production fleet returned 63,333 characters against the shared 32 KB MCP response budget — about 2x over. The default page cap (11 groups) was sized from a fixture averaging about 2.7 KB per group (3 databases per AG); real groups averaged closer to 6 KB (2 replicas plus 6-14 database rows), so the fixed count overshot badly on real data.
What changes
DarlingAgReader.Buildnow fills the returned page by MEASURED serialized bytes, most-severe-first, instead of a fixed group count:McpResponseBudget.DefaultBytes(32 KB) — never after.limitargument still applies as an upper bound underneath the budget (whichever is smaller cuts the page).groups_returned,groups_total, andgroups_truncatedstay truthful against the whole scope.groups_truncated_notenow names the actual reason — the byte budget or the caller'slimit— since the two can now disagree.DefaultGroupLimitdoc comment and the tool'sDescription/parameter text to describe the new "as many as fit ~32 KB, most-severe-first" default, withlimitstill an upper bound.Test plan
Pure pins added to
Darling/Darling.Tests/DarlingAgReaderTests.cs(no live store needed), against a realistic wide-group fixture (2 replicas + N databases, real-shaped LSNs/queue sizes/suspend reasons):groups_returned< 42,groups_truncatedtrue, note names the byte budget.groups_truncatedis false (a lone group isn't itself a cut).limitsmaller than what the byte budget would allow: caps at exactly thatlimit.get_ag_healthtest withlimitat or above the group count asserts the truthful counts, the budget wording in the note, and that the serialized response itself fits the budget.Runtime RED on dev, measured: with the fill reverted to dev's count-based
groups.Take(limit), the 42-wide-group pin returned 280,142 bytes (all 42 groups; the pin callsBuildwithout the tool's default count) against its<= 32,768assertion, so it fails on dev. Restoring the byte fill turned it green.Also re-ran and confirmed green (no regression):
DarlingAgReaderTests(53 existing + 4 new = 64 total incl. surface/budget classes below)DarlingMcpAgToolsSurfaceTests(tool surface/schema contract)McpToolsListBudgetTests(tools/list byte ceiling — trimmed the tool'sDescription/parameter text to fit; theparam get_ag_health.limitceiling line dropped from 155 to 146, banking the saving as the test requires)DarlingMcpAgToolsLivePostgresTests(gated onDARLING_TEST_PG, runs in CI) was not run here (no rig); it wasn't touched and its assertions (default-limit-caps behavior on a 42+1 group live fixture) still hold under the byte-fit fill since that fixture's groups are far under 32 KB — CI decides it.Build:
dotnet build Darling/Darling.Tests/Darling.Tests.csproj -c Release -p:EnableWindowsTargeting=true— 0 warnings, 0 errors.CHANGELOG
SECTION: Fixed
ENTRY: -
get_ag_healthkeeps its fleet-wide answer within the 32 KB MCP budget ([#4568]) - The fleet-wide default page now fills most-severe-first by measured size instead of a fixed 11 groups. On a real fleet whose groups carry many databases, those 11 groups came to about twice the budget.limitstill caps the page, andgroups_truncatedsays whether the size budget or the limit cut it.REF: [#4568]: #4568