Skip to content

Record cumulative callback size per execution as a metric - #12121

Draft
chrsmith wants to merge 1 commit into
chrsmith/cb-4-write-path-enforcementfrom
chrsmith/cb-5-size-metric
Draft

chrsmith wants to merge 1 commit into
chrsmith/cb-4-write-path-enforcementfrom
chrsmith/cb-5-size-metric

Conversation

@chrsmith

Copy link
Copy Markdown
Contributor

Stack 5/6 — base: chrsmith/cb-4-write-path-enforcement (#12120)

Why

TotalMaxSizePerExecution ships disabled. Before it is given a non-zero default, the fleet-wide distribution needs to be observable, so that the limit is chosen from how executions actually grow rather than guessed and discovered through rejected requests.

What

Samples the execution's running total whenever callbacks are attached, at the three points that maintain the counter. Each sample is the total the execution holds after the attach, not the increment, so the histogram describes executions rather than requests.

Emission goes through chasm.Context.MetricsHandler, which is already namespace-tagged, so all four execution types are covered without threading a handler into the components.

Follow-up, deliberately not in this stack

Flipping callback.totalMaxSizePerExecution from 0 to 2*1024*1024 is a separate one-line change, to be made once the p99 has been read from a real fleet. Until then the size cap is wired but inert.

When it is flipped: since the frontend already caps a single NexusHandler source context at 1 MiB, two large-context callbacks will exhaust the budget. That is the intended semantic. Executions already over the cap have their next attach rejected while existing callbacks keep firing; rollback is a per-namespace override back to 0.

🤖 Generated with Claude Code

@chrsmith
chrsmith added this pull request to stack #12123 September 16, 2026 22:58
TotalMaxSizePerExecution ships disabled. Before it is given a non-zero
default, the fleet-wide distribution needs to be observable, so that the
limit is chosen from how executions actually grow rather than guessed and
discovered through rejected requests.

Sample the execution's running total whenever callbacks are attached, at
the three points that maintain the counter. Each sample is the total the
execution holds after the attach, not the increment, so the histogram
describes executions rather than requests.

Emission goes through chasm.Context.MetricsHandler, which is already
namespace-tagged, so all four execution types are covered without
threading a handler into the components.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chrsmith
chrsmith force-pushed the chrsmith/cb-4-write-path-enforcement branch from 442fd5e to b546115 Compare September 17, 2026 15:50
@chrsmith
chrsmith force-pushed the chrsmith/cb-5-size-metric branch from f7fbad7 to a816ef2 Compare September 17, 2026 15:50
@chrsmith
chrsmith removed this pull request from stack #12123 September 18, 2026 19:21

This branch has not been deployed

No deployments
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