Conversation
chrsmith
added this pull request to stack #12123
September 16, 2026 22:58
common/callbacks.Validator only ever bounded a single request: its check compares len(cbs) against MaxCallbacksPerExecution, so it never sees the callbacks an execution already holds. The cumulative check is instead open-coded in five places across the CHASM libraries and mutable state, with two different denominators. Add ValidateAdditions as the shared cumulative counterpart. Callers pass their own denormalized totals via ValidateAdditionsOptions so the check stays O(1) rather than walking the execution's callbacks. Errors are FailedPrecondition, not InvalidArgument: the request may be well-formed and fail only because of what is already attached. Also introduce callback.totalMaxSizePerExecution, resolving the TODO for an aggregate size budget. Without it, MaxPerExecution (2000) and NexusHandlerSourceContextMaxSize (1 MiB) multiply out to ~2 GiB of source context on a single execution. It ships defaulted to 0 (disabled) so the limit can be observed before it is enforced. Only the callback specification counts toward the budget, never the delivery bookkeeping in CallbackState (attempt, failures, timestamps), which mutates after attach and would let an execution drift over the cap on its own. The budget is enforced against the API proto but the CHASM proto is what gets persisted; TestAPIAndChasmCallbackSizesAgree pins the two to the same size so the enforced budget cannot drift from the stored one. No behavior change: nothing calls ValidateAdditions yet. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…teAdditions Both components open-coded the same cumulative callback check against MaxCallbacksPerExecution. Route them through callbacks.ValidateAdditions instead, so the count limit and the (still disabled) aggregate size limit are enforced from one place rather than re-derived per component. The limits are unchanged: the count cap is still MaxPerExecution, and TotalMaxSizePerExecution defaults to 0. Only the error wording moves from "to an activity" / "to a nexus operation" to "to an execution", which no test outside these two packages asserts on. Nexus Operation keeps its ordering: the idempotency probe still runs before the closed check, so a retry whose first attempt was persisted succeeds even if the operation closed in between. Standalone Activity was overwriting an existing callback map entry where Workflow and Nexus Operation both skip. That resets the delivery state of an already-persisted callback, and it would corrupt the size counter a later commit derives from insertions, so it now skips too. callbacks.Validator was previously built only in the frontend fx graph. The cumulative check runs in history, which needs an identically configured validator: the frontend bounds a single request and history bounds the execution's cumulative totals, so configuring them differently would let a request be accepted at one and rejected at the other. Each graph builds its own, and both functions carry a comment pointing at the other so the duplication stays deliberate. The Nexus Operation tests built a callbacks.ValidatorConfig by hand and panicked on error. They now start from common/testing's shared config and override only the limit under test, matching the standalone Activity tests. The hand-rolled config used tighter ID, service and operation name limits than the shared one; nothing asserted on them, because the service and operation name limits those tests exercise come from the library's own Config rather than the callback validator's. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
chrsmith
force-pushed
the
chrsmith/cb-1-validate-additions
branch
from
September 17, 2026 15:50
047aa9d to
25aac58
Compare
chrsmith
force-pushed
the
chrsmith/cb-2-standalone-components
branch
from
September 17, 2026 15:50
66a9bda to
efe7c20
Compare
chrsmith
force-pushed
the
chrsmith/cb-1-validate-additions
branch
from
September 18, 2026 19:20
25aac58 to
06522d3
Compare
chrsmith
removed this pull request from stack #12123
September 18, 2026 19:21
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.
Stack 2/6 — base:
chrsmith/cb-1-validate-additions(#12117)Why
Both components open-coded the same cumulative callback check against
MaxCallbacksPerExecution.What
Routes them through
callbacks.ValidateAdditions, so the count limit and the (still disabled) aggregate size limit are enforced from one place rather than re-derived per component.The limits are unchanged: the count cap is still
MaxPerExecution, andTotalMaxSizePerExecutiondefaults to0. Only the error wording moves from "to an activity" / "to a nexus operation" to "to an execution", which no test outside these two packages asserts on.Notes for review
Nexus Operation keeps its ordering: the idempotency probe still runs before the closed check, so a retry whose first attempt was persisted succeeds even if the operation closed in between.
Standalone Activity was overwriting an existing callback map entry where Workflow and Nexus Operation both skip. That resets the delivery state of an already-persisted callback, and it would corrupt the size counter a later PR derives from insertions, so it now skips too.
callbacks.Validatorwas previously built only in the frontend fx graph. The cumulative check runs in history, which needs an identically configured validator: the frontend bounds a single request and history bounds the execution's cumulative totals, so configuring them differently would let a request be accepted at one and rejected at the other. Each graph builds its owncallbackValidatorProvider, and both carry a comment pointing at the other so the duplication stays deliberate.The Nexus Operation tests built a
callbacks.ValidatorConfigby hand and panicked on error. They now start fromcommon/testing's shared config and override only the limit under test, matching the standalone Activity tests. The hand-rolled config used tighter ID, service and operation name limits than the shared one; nothing asserted on them, because the service and operation name limits those tests exercise come from the library's ownConfigrather than the callback validator's.🤖 Generated with Claude Code