feat: report clamped settings via §19 ConfigClamped (contract 1.9) - #46
Merged
Merged
Conversation
Retrofit of contract 1.9's §19.2 rule 6 to this SDK, which merged before the
rule existed.
The only clamp this SDK applies is §17.1 rule 2's memo TTL — §16's parameters
are constants here, with no caller-facing knob to clamp, which is why the
event carries only decision_memo_ttl. That is the clamp that matters most
anyway: an operator who sets a 60-second TTL believes their staleness bound is
60 seconds. It is five, and before this event nothing anywhere said so.
report_clamp is called from the builder rather than from DecisionMemo::new,
because the telemetry sink is assembled in the same expression and construction
is the only moment an operator can act on the report.
Three tests, two of them for what it must NOT do:
- a 60s TTL emits exactly one event naming decision_memo_ttl
- a 2s TTL emits nothing — it was already inside the limit
- the disabled default emits nothing, which matters because otherwise every
client ever built would fire a zero-to-zero "clamp"
Gates: cargo test --all-features green, clippy --all-targets --all-features
-D warnings clean, fmt clean, cargo doc with RUSTDOCFLAGS=-D warnings clean.
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.
Retrofit of contract 1.9's §19.2 rule 6 to this SDK, which merged before the rule existed.
Why
Two places in the contract require clamping rather than rejecting. Clamping is right — rejecting would break a caller whose configuration was merely optimistic, and honoring would let one client become the herd §16 exists to prevent. Doing it silently is the part that is wrong.
An operator who sets a 60-second decision-memo TTL believes their staleness bound is 60 seconds. It is five. Every conclusion they draw about how stale an
allowedcan be is wrong by a factor of twelve, and before this event nothing anywhere said so.Scope here is narrower than in C#
This SDK's only caller-facing clamp is §17.1 rule 2's memo TTL. §16's attempt cap, base delay and delay cap are constants with no knob to raise — deliberately, per §16.1 — so there is nothing to report for them. That is why the event carries only
decision_memo_ttl.(The C# SDK is the opposite case: its three retry settings were publicly settable upward, which is what prompted the rule.)
report_clampis called from the builder, not fromDecisionMemo::new, because the telemetry sink is assembled in the same expression and construction is the only moment an operator can act on the report.Three tests, two of them for what it must not do
decision_memo_ttl, effective value rendering the 5 s capThat last one matters more than it looks: without it, every client ever built would fire a zero-to-zero "clamp", and an event that fires when nothing happened trains its reader to ignore it.
Verification
cargo test --all-featurescargo clippy --all-targets --all-features -- -D warningscargo fmt --all --checkcargo doc --all-features --no-depswithRUSTDOCFLAGS=-D warningsRe-vendors
CONTRACT.mdat 1.9.Notes
--force-with-leaseafter confirming its prior head was content-identical tomain(squash-merged in feat: contract 1.8 — §16 retry, §17 memo, §18 close(), §19 telemetry (D5) #45).Generated by Claude Code