Repository navigation
policy: stop advertising what policy will not grant - #52
Merged
Merged
Conversation
Phase 1 refused the reverse path but still told every upstream the caller could sample and elicit: it asked, it was refused, and it had learned something. Intersecting the mirrored capabilities with policy at session connect closes that — an upstream policy will never let ask is not told there is anything to ask for. Same pair as the forward path, pointed the other way. Handler and capability turn out to be one switch, not two: in the SDK, setting the handler is what advertises the capability. So withholding is implemented by not installing the handler, and that has a consequence the design did not anticipate and now records. A refused request no longer reaches fold at all — a well-behaved upstream's own SDK refuses before anything leaves it, a hostile one gets "method not found" below the gate — so a withheld capability produces no audit event. Better security, worse telemetry, and the trade is taken deliberately: nothing was asked, so there is nothing to record. What fold still refuses itself is the boundary case the design named: a session opened under a grant that a reload took away. The capability is stale but the handler re-reads policy per request, so the denial bites immediately and is audited. TestServerInitiatedDenialIsAudited now exercises exactly that path, and asserts the allowed exchange before the reload is recorded too. Staleness runs one way only, which is the safe way: a reload that removes a grant takes effect on the next request; one that adds a grant waits for a new bridged session. Also recorded while reading the SDK: sampling is deprecated as of protocol 2026-07-28 (SEP-2577), with a twelve-month-plus window; elicitation is not. That does not change the decision — ungoverned deprecated traffic is still ungoverned — but it means the elicitation half is the durable half, which is worth knowing before sizing the reverse limiter in phase 3. Conformance 40/40; the per-invocation thunk is unchanged at 32 B and one alloc. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.
Phase 2 of
docs/design-server-initiated.md, following #51.Phase 1 refused the reverse path but still told every upstream the caller could sample and elicit: it asked, it was refused, and it had learned something. Intersecting the mirrored capabilities with policy at session connect closes that — an upstream policy will never let ask is not told there is anything to ask for. The same enforcement pair as the forward path, pointed the other way.
The correction implementation forced
Handler and capability are one switch, not two: in the SDK, setting the handler is what advertises the capability, and there is no way to install one without the other. So withholding is implemented by not installing the handler — and a refused request then never reaches fold at all. A well-behaved upstream's own SDK refuses before anything leaves it; a hostile one that sends anyway gets
method not foundfrom fold's SDK client, below the gate.Consequence: a withheld capability produces no audit event. Phase 1 recorded every refusal; phase 2 makes most refusals stop happening. Better security, worse telemetry. The trade is taken deliberately and written down — an operator reading no sampling events under a deny posture is reading success, not silence. If "this upstream keeps probing" turns out to matter more, the fix is to install the handler and refuse in it (phase 1's behaviour), not to add a second refusal path.
What fold still refuses itself
The boundary case the design named: a session opened under a grant that a reload took away. The capability is stale, but the handler re-reads policy per request, so the denial bites immediately and is audited.
TestServerInitiatedDenialIsAuditednow drives exactly that path — grant, call,Reloadto deny, call again — and also asserts the allowed exchange before the reload is recorded.That test incidentally pins the staleness direction, which is the safe one: removing a grant takes effect on the next request; adding one waits for a new bridged session.
Noted while reading the SDK
Sampling is deprecated as of protocol 2026-07-28 (SEP-2577 — roots, sampling, and logging together), with a window of at least twelve months.
ElicitationHandlercarries no such notice. This changes nothing here — ungoverned deprecated traffic is still ungoverned, and the window outlasts any release this lands in — but it means the elicitation half is the durable half, and phase 3's reverse limiter should be sized for elicitation rather than sampling volume. Recorded as section 8 of the design record.Verification
make check— race suite greenmake conformance— 40/40make bench— the per-invocation thunk is unchanged at 32 B and one alloc; capability evaluation happens on the bridged-session connect path, not per request🤖 Generated with Claude Code