Skip to content

MCP budget: get_pg_io_trend's default call now fits the 32 KB budget (#4198) - #4263

Merged
erikdarlingdata merged 2 commits into
devfrom
fix/4198-pg-io-trend-default
Sep 25, 2026
Merged

erikdarlingdata merged 2 commits into
devfrom
fix/4198-pg-io-trend-default

Conversation

@erikdarlingdata

@erikdarlingdata erikdarlingdata commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Part of #4198.

Why

get_pg_io_trend's point is the widest in the trend family. It has 28 numeric/boolean fields: read/write/extend
rates, cache-hit ratio, per-op latency, several tracking flags. There is no text field to truncate.

Every trend tool's default (auto-sized) call shares one 200-point target, TrendBuckets.McpPointBudget, when the
caller leaves bucket_minutes to the tool. That fits most of the family. But get_pg_io_trend's wide point puts
a default 24-hour, one-series call's 10-minute bucketing at 145 points. That measured 56-59 KB. This held both on
a production store and on this PR's own live fixture. It is well over the shared McpResponseBudget.DefaultBytes
target of 32 KB (#4198).

What changes

  • PerformanceMonitor.Common/Mcp/TrendBuckets.cs: a new TrendBudget.Mcp(autoPoints, maxPoints) overload.
    Also TrendBuckets.PgIoMcpAutoPoints (70), get_pg_io_trend's own, narrower MCP auto-sizing target. Its doc
    comment records the measured bytes/point and the window sweep it was checked against. This keeps Trend tools return every raw point: get_file_io_trend sends 12,451 points / 1.4 MB for one server at defaults, more than an LLM client's context #3897's
    design intact: the read's own cap on an explicit bucket_minutes, PgIoMaxPoints (650), is untouched. So is
    the one-arg TrendBudget.Mcp(maxPoints) factory every other trend tool uses.
  • Darling/PerformanceMonitor.Darling.Service/Mcp/DarlingMcpPgTrendTools.cs: get_pg_io_trend's MCP entry point
    now passes TrendBudget.Mcp(PgIoMcpAutoPoints, PgIoMaxPoints) instead of TrendBudget.Mcp(PgIoMaxPoints).
  • The web viewer's /api/read mirror keeps calling the internal overload with TrendBudget.Chart directly. This
    PR does not touch the chart.
  • A default call now lands on a 30-minute bucket for the 24-hour default window, instead of 10 minutes. Other
    windows get correspondingly wider, still auto-sized, ladder-picked buckets too.
  • No tool description or parameter text changed. Darling/Darling.Tests/McpToolsListBudget/DarlingMcpPgTrendTools.txt
    needed no edit.
  • New file: Darling/Darling.Tests/PgIoTrendDefaultBudgetLiveTests.cs. It seeds one (backend_type, context) pair
    at one-minute cadence for just over a day. It calls the tool with every argument defaulted, the literal default
    call, and asserts the UTF-8 byte count stays under McpResponseBudget.DefaultBytes. It fails on the pre-fix
    shape and passes on the fixed one. A second assertion in the same test confirms an explicit bucket_minutes
    still returns the full window's points, unaffected by the narrower default target.

Test plan

Rig: reused the stopped rig-ta rig (port 55976, already UTC). Dropped and recreated darlingtest and probe
first, since a prior lane had left data there.

Measured bytes, get_pg_io_trend, default call (24h, one series), on this PR's live fixture:

  • Before: 145 points, 59.0 KB (60,456 bytes), over the 32 KB budget. Matches the roughly 56 KB
    production-store measurement in the brief.
  • After: 48 points, 21.5 KB (22,016 bytes), under budget.
  • Explicit bucket_minutes is unaffected. TrendPayloadBudgetLiveTests' cap-side case is 168h at the
    narrowest width the 650-point cap admits. It still measures 631 points / 248.6 KB, same as before this
    change.
  • No Lite twin: Lite does not monitor PostgreSQL, so this tool, and every get_pg_* tool, has no Lite surface.
    Skipped the common brief's Lite steps and the Lite.Tests run, per this lane's own brief.

Targeted classes (rig, DARLING_TEST_PG against rig-ta):

  • PgIoTrendDefaultBudgetLiveTests (new): 1/1 passed after the fix.
  • TrendPayloadBudgetLiveTests: passed clean on the run kept as final. Two earlier runs each failed once, on
    a different tool's line each time: get_file_io_trend, then get_pg_io_trend. Both failures were a
    connection-level "Exception while reading from stream", not a size assertion. This fixture seeds a
    600-file, 300-tenant-database series, and that heavy seeding looks like the real cause, not a
    get_pg_io_trend-specific defect. A clean rerun on a freshly recreated darlingtest passed all tools,
    including get_pg_io_trend at every window.
  • TrendBucketingLiveTests: 6/6 passed. All calls there use an explicit bucket_minutes, so this change
    cannot affect them, and the pass confirms that.
  • TrendBucketsTests (unit, no rig): 37/37 passed.

Full suite, once, after merging origin/dev (clean merge) and recreating darlingtest:

  • Darling.Tests: Total 13,856, Errors 0, Failed 2, Skipped 47 (expected env-gated fixtures), Not Run 1,
    625.8s. Build: 0 Warning(s), 0 Error(s).
  • The 2 failures are ServerListAndSummaryPlanShapeTests.TheShippedReads_TouchFarFewerChunks_AndReturnTheSame NewestCollection_AgainstDevPostgres and CaptureDownChunkOrderTests.TheShippedRead_ExecutesOnlyTheNewestChunk_ AndTheNewestRunDecides_AgainstDevPostgres. Both are TimescaleDB chunk-exclusion EXPLAIN-plan-shape assertions
    on collect.collection_log. That is a subsystem this PR's diff does not touch: server-list/summary reads and
    collection-log chunk pruning, not trend reads. I reproduced both deterministically alone on rig-ta. They are
    pre-existing: dev's own latest CI Build run (36108125880, 2026-09-25T07:32:06Z) shows 0 failures across all
    three Darling PG test shards, 13,855 tests total. The most likely cause is a TimescaleDB build or version
    difference between this reused rig and CI's freshly provisioned one. It sits outside this lane's
    get_pg_io_trend brief, in a subsystem I have no context on. I am flagging it for the coordinator instead of
    fixing it here.
  • Lite.Tests: not run. This tool has no Lite twin, because Lite does not monitor PostgreSQL.

CHANGELOG entry

SECTION: Fixed
ENTRY:

Generated with Claude Code

https://claude.ai/code/session_01TszxYhJJbTEh4LrZ56NYo3

erikdarlingdata and others added 2 commits September 25, 2026 03:30
…budget (#4198)

The tool's point is the widest in the trend family (28 numeric/boolean fields,
no text to truncate), so the shared 200-point auto-sizing target every other
trend tool leaves its default to put a default 24-hour call's 10-minute
bucketing at 145 points, measured 56-59 KB on a live fixture - well over
McpResponseBudget.DefaultBytes (32 KB). Gives get_pg_io_trend its own,
narrower MCP auto-sizing target (70 points, TrendBuckets.PgIoMcpAutoPoints)
via a new TrendBudget.Mcp(autoPoints, maxPoints) overload, so the default call
lands on a 30-minute bucket instead: measured 48 points, 21.5 KB. An explicit
bucket_minutes is unaffected - it still reaches the read's own 650-point cap.

The web viewer's /api/read mirror keeps TrendBudget.Chart, untouched.

New live test: Darling.Tests.PgIoTrendDefaultBudgetLiveTests, seeding one
(backend_type, context) pair at one-minute cadence and measuring the literal
default call's UTF-8 bytes. Fails on the old shape (60,456 bytes measured),
passes on the new one (22,016 bytes measured).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TszxYhJJbTEh4LrZ56NYo3
@erikdarlingdata erikdarlingdata changed the title DO NOT MERGE (MCP budget): get_pg_io_trend's default call now fits the 32 KB budget (#4198) MCP budget: get_pg_io_trend's default call now fits the 32 KB budget (#4198) Sep 25, 2026
@erikdarlingdata
erikdarlingdata marked this pull request as ready for review September 25, 2026 07:59
@erikdarlingdata
erikdarlingdata enabled auto-merge (squash) September 25, 2026 08:06
@erikdarlingdata
erikdarlingdata merged commit dbafd3b into dev Sep 25, 2026
18 of 20 checks passed
@erikdarlingdata
erikdarlingdata deleted the fix/4198-pg-io-trend-default branch September 25, 2026 08:07
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.

1 participant