Skip to content

policy: stop advertising what policy will not grant - #52

Merged
blakebauman merged 1 commit into
mainfrom
policy/server-initiated-pair
Aug 13, 2026
Merged

blakebauman merged 1 commit into
mainfrom
policy/server-initiated-pair

Conversation

@blakebauman

Copy link
Copy Markdown
Member

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 found from 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. TestServerInitiatedDenialIsAudited now drives exactly that path — grant, call, Reload to 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. ElicitationHandler carries 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 green
  • make conformance — 40/40
  • make 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
  • 7 bridge tests, including the two new capability assertions

🤖 Generated with Claude Code

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]>
@blakebauman
blakebauman merged commit 8ad4869 into main Aug 13, 2026
7 checks passed
@blakebauman
blakebauman deleted the policy/server-initiated-pair branch August 13, 2026 16:11
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