Repository navigation
Description
Context
The brain CLI's paid providers (Gemini reranking and embeddings, Anthropic completions, image providers) reach their upstream through the metered provider relay (#1673). The relay shares the turn proxy's admission as ordinary turn egress (G5) (relayedOperation, packages/ui-sdk/src/server/egress-proxy.ts:243-254; the call in packages/ui-sdk/src/server/provider-relay.ts:324). That has two G6 consequences:
- An admitted relayed provider request is treated as a worker connection other than the inference relay. It records the session's
taint(admitted,packages/ui-server/src/brain/turn-egress.ts:133-142), withdetail: "POST generativelanguage.googleapis.com:443". - Once a session is tainted, a provider host the session has not contacted yet is refused with
taint_allowlist(narrowed,packages/ui-sdk/src/server/egress-proxy.ts:119). The CLI then reportsprovider_unavailableand degrades. For reranking, that meansdegradedTo: lifecycle_order.
So in a governed session, the order of tool use changes what works:
brain_contextwith reranking first taints the session, and a later WebFetch of a new host is refused.- WebFetch first taints the session, and a later
brain_contextloses reranking unless the provider host is inpolicy.taint.egress.allow.
The report names the separate runtime-traffic correction under #3244 and its proposed PROVIDER_RELAY_TAINT_UNCHANGED test. At inspected main a84d9bfbcb4e608b504aa0a9feb1144ad9a0b77e, #3244 is still open and that named test/assertion is absent. Treat the runtime correction/test as candidate context until delivered; the provider-relay admission facts above are independently present on this main source.
The G6 rule in docs/decisions/governed-writable-workers.md ("Untrusted input (G6)") taints on "any connection from inside the worker other than the inference relay". A relayed provider request is sent by the host with the host's key, through a validated provider route to a built-in or explicitly host-authorized exact origin. This is a bounded host-relayed provider capability rather than arbitrary worker traffic; it does not make provider output inherently trustworthy. The #1673 decision, however, deliberately made it ordinary turn egress with "the turn's deny/allow and taint rules".
Decision (maintainer, 2026-11-02)
Selected option C: approved host-relayed provider requests neither trigger session taint nor undergo taint-based destination narrowing. They still pass ordinary deny/allowlist rules, exact origin/recipient/route authorization, byte limits, budget admission, cancellation and accounting. The exemption belongs only to validated provider-relay operations, never arbitrary worker HTTP/CONNECT traffic or a hostname-wide bypass.
Reason: provider-first and browsing-first orders should both work for already-authorized provider capabilities. The accepted tradeoff is explicit: permitted content may reach those approved providers after untrusted input enters the session. This does not declare provider output trusted, authorize a new recipient, clear existing taint or relax any other untrusted-input/outward-action rule.
Rejected A (keep both restrictions/document them): preserves the conservative existing rule but leaves tool-order failures. Rejected B (no new taint but retain narrowing): repairs only provider-first order and keeps browsing-first provider failures.
Scope
- Implement C in provider-relay admission and governance taint handling, preserving all unrelated controls and existing inference-relay behavior.
- Append the ruling, scope and rejected alternatives to the G6 and ui-sdk: route the brain CLI's paid provider calls from workers through metered host relays #1673 provider-egress sections of docs/decisions/governed-writable-workers.md. Preserve historical policy with a dated supersession rather than silently rewriting the old decision.
- Update supported-input/contract semantics and capability explanations to accurately describe the provider-only exemption, including its after-untrusted-input data-routing implication.
Out of scope
- The inference relay, ui-server: the Claude runtime's own api.anthropic.com traffic taints every governed turn, blocking WebFetch and reranking #3244 runtime traffic pins, WebFetch/WebSearch taint and all other existing input-taint sources.
- Taint allowlist defaults, ordinary worker network privileges, outward-action confirmation rules, provider recipient defaults and host credential authorization.
- New public configuration/schema fields, new provider routes, budget policy, pricing, receipt shapes, cleanup policy or provider-facing conversation changes.
Acceptance criteria
- The decision record and implementation implement C only; no remaining A/B branch or undocumented hostname-wide exemption.
- A keyless governed-session provider-first → WebFetch fixture admits both when ordinarily permitted. The provider request creates no taint; the first taint is the actual WebFetch/untrusted-input source.
- A WebFetch-first → provider fixture retains the WebFetch taint and admits the otherwise-authorized provider request without taint-derived provider_unavailable/degradation. The provider operation neither clears nor replaces the first taint.
- Ordinary untrusted input still taints, and ordinary worker requests remain subject to existing narrowing. Prove that arbitrary HTTP/CONNECT traffic cannot claim the exemption, including traffic to a provider hostname. Provider admission must not silently grant ordinary worker traffic a contacted-host privilege.
- Denied and non-allowlisted destinations remain denied; unauthorized origins/credentials/routes remain refused; byte ceilings, budget stops, existing unknown-spend/accounting treatment, cancellation and actual admission refusals remain enforced. Test these controls through the real relay rather than a predicate-only mock.
- Preserve distinct provider usage/connection receipts and credential secrecy. Do not mislabel provider requests as actual inference merely to reuse an exemption, falsify coverage or change which traffic is charged.
- Update docs/decisions/governed-writable-workers.md, supported policy/authoritative contract guidance and capability-note explanation consistently. Any dynamic capability explanation must respect append-only provider history: do not mutate a session's earlier tools/system/messages; use only an already-authorized new-tail mechanism if needed, and run the keyless history guard for any affected turn-path changes.
- Document migration/compatibility: the taint rule alone will no longer restrict these approved provider routes after untrusted input. Ordinary deny/allowlist and exact host-origin authorization still apply. Do not claim a new opt-out field, approval capability or wire shape.
Verification
Use a keyless loopback provider fixture through actual provider-relay admission and governance storage. For both operation orders assert actual destination admission/denial, exact first-taint origin, unchanged sticky taint and provider degradation outcome. Include denied/allowlisted destinations, forged/mismatched routes/origins, arbitrary ordinary HTTP/CONNECT and byte/budget/cancellation controls. Preserve normal cost/usage and unknown-outcome accounting.
Run bun run test packages/ui-server/tests/turn-egress.test.ts packages/ui-sdk and the focused provider-relay tests. Record failing-first/restored causal mutations for the two-order behavior and exemption boundary. No live provider/key/network-dependent tests. Run the provider-history guard when the changed path affects provider-facing history.
Contract impact
This is an intentional semantic change to documented supported governance/taint policy, even though no event or configuration shape changes. Classify it as a pre-1.0 breaking minor under docs/decisions/supported-inputs.md and docs/decisions/contract-versioning.md; this maintainer C ruling authorizes the narrow policy change before implementation. Carry contract and breaking, use a CONTRACT-prefixed implementation commit, update the relevant authoritative integration-contract/supported-input documentation in that commit, and provide a minor changeset naming the behavioral break and migration. The relay helpers themselves remain internal; this does not make a public extension seam. No release milestone is committed here.
Dependencies and decision status
Independent of #3244's narrower runtime-traffic correction. Its candidate test is not delivery proof for this issue; the context above identifies the inspected source snapshot rather than claiming its current completion.
All decision questions are answered. Remove needs: decision and add agent-ready because no other needs label remains. Decision-record and implementation work remain on this issue.
2026-11-02 decision review: recorded option C and its explicit data-routing tradeoff, replaced conditional acceptance branches with real two-order/boundary proof, retained ordinary egress and accounting controls, and classified the supported-policy semantic change. No implementation, proof completion or release commitment is claimed.
Current state (2026-11-02)
- Option C and the maintainer's cross-turn ruling (an optional
provider: trueonegress_connection, excluded bycontactedHosts) are implemented in PR CONTRACT: fix(ui-server): exempt validated provider-relay requests from session taint (#3246) #3394 againstepic/1645-egress-controls. The PR has failing-first and mutation receipts and is marked ready. - Remaining: hosted selected proof for the current head, then the epic batch landing on
main.
Blocked by #3461
Activity
schlessera commentedon Nov 2, 2026
Decision (maintainer, 2026-11-02): Selected C: approved provider-relay operations neither create session taint nor undergo taint-based destination narrowing. Ordinary deny/allowlist checks, exact origin/recipient/route authorization, byte ceilings, budgets, cancellation and accounting remain enforced.
The exemption is scoped to validated host-relayed provider routes, not arbitrary worker HTTP/CONNECT traffic or provider hostnames. Existing taint stays sticky; browsing and other untrusted-input sources still taint. Provider output is not declared inherently trustworthy. The accepted tradeoff is that permitted content may reach those approved providers after untrusted input enters the session.
Rejected A leaves both tool-order failures; rejected B repairs only provider-first order. The body now has C-specific two-order acceptance criteria, real relay/governance fixture and mutation requirements, and negative controls proving the exemption cannot widen ordinary worker traffic or recipient authority.
Implementation must append the ruling and supersession to G6/#1673 in docs/decisions/governed-writable-workers.md and update supported-policy/contract explanations. Because documented taint-policy semantics change, carry contract/breaking, a CONTRACT-prefixed implementation commit, same-commit authoritative documentation and a minor changeset naming the pre-1.0 behavioral break. The selected C ruling supplies prior maintainer authorization; no schema expansion or release commitment is implied.
Remove needs: decision and add agent-ready: no other needs label remains. This records policy and scope, not delivered implementation or proof.
schlessera commentedon Nov 2, 2026
Claiming for implementation (claim token
wi-3246-c7f2). Branchfix/3246-provider-relay-taint, based onepic/1645-egress-controls; the PR targets that integration branch and closes this issue when the epic batch lands on main.Collision report: path overlap on
docs/decisions/governed-writable-workers.mdwith #3316, #3342, #3343, #3369, #3371, #3373, #3384, #3386. #3369 also touchespackages/ui-sdk/src/server/provider-relay.ts. All other reports are closure-only.schlessera commentedon Nov 2, 2026
Needs decision (2026-11-02): cross-turn contacted-host grant from provider-relay requests.
Draft PR #3394 (base
epic/1645-egress-controls) implements option C. Validated provider-relay requests no longer taint and are not narrowed. Within a turn, they grant worker traffic no contacted host.The open clause. One acceptance-criterion clause is not met across turns: "Provider admission must not silently grant ordinary worker traffic a contacted-host privilege."
egress_connectionrows that charged bytes, excluding onlyinference: true(contactedHosts,packages/ui-server/src/governance/session-taint.ts:43-49). A provider-relay row has the same public payload as a worker row. So if turn 1 makes a provider request, a workerCONNECTto that provider host is admitted in a tainted turn 2. A keyless scratch run through the real relay and proxy returned 200 where 403 is required. The base does the same, so this is not a regression of CONTRACT: fix(ui-server): exempt validated provider-relay requests from session taint (#3246) #3394.Options
provider: trueliteral toegress_connectionv1. It would mirrorinference: true, be set only by validated provider-relay operations, and be excluded bycontactedHosts. This is an additive contract change in the sameCONTRACT:commit, indocs/http-api.mdand the contract index. Consequence: the clause closes durably, and existing rows stay as they are. Rows written before the change remain unmarked, so they can still grant the host for already-existing sessions only.contactedHostssubtracts. Consequence: no public shape change, but this is a second, private record of the same connection, with its own migration and retention.Recommendation: A1. It is the smallest change that matches how
inferencealready works. It is additive (a minor release) and keeps one public record per connection.To resume: a maintainer picks an option here. If A1 or A3, implement it on #3394's branch with a failing-first cross-turn test (
CROSS_TURN_PROVIDER_HOST_NARROWED), then mark the PR ready. If A2, amend the acceptance criteria and the G6 doc, then mark it ready.6 remaining items
schlessera commentedon Nov 2, 2026
Implemented the 2026-11-02 cross-turn ruling in #3394 (head 24bcc50, base
epic/1645-egress-controls2f8f11d), in oneCONTRACT:commit:egress_connectionrecord now carries the optionalprovider: truefield.contactedHostsexcludes those records.docs/http-api.md, the contract entry, the G6 ruling and the API report are updated in the same commit.Receipts:
CROSS_TURN_PROVIDER_HOST_NARROWEDreturned 200 where 403 was required before the fix.The bug-class audit found no other reader that classifies connection records by relay. The PR is marked ready, and hosted proof is pending.
schlessera commentedon Nov 3, 2026
Production evidence (hosted 0.44.0, 2026-11-02), showing this is not limited to tool order. Two things combine:
Almost every session is tainted at its first shell command.
commandTaintSource(packages/ui-server/src/activity/command-taint.ts:2-27) exempts only barelsandbrain search. In one session the user's first input was!brain diagram --help. That recordedtaintwithsource: "unclassified_command".Every relayed provider is then refused. Later in that session,
brain imagefailed on both providers:POST api.openai.com /v1/images/generationswas denied withreason: "taint_not_allowed";POST generativelanguage.googleapis.com /v1beta/interactionswas denied the same way.The CLI reported
OpenAI: Provider network admission refused (region not supported, or the org is not verified)andGemini: Provider network admission refused. The first message's hint in parentheses is wrong for this cause and sent the agent looking for an account problem.So on a hosted install, image generation, Gemini embeddings and completions, and Anthropic completions fail in nearly every governed session once any ordinary shell command has run, independent of #3244. Raising to p1.
The instance currently works around it by listing the three provider hosts in
taint.egress.allow. That is the hostname-wide exemption option C rejects as the design, so it is meant to be removed once this ships.Also worth a line in the fix: the CLI's provider-refusal message should not append the region/verification hint when the relay refused on admission.
CONTRACT: fix(ui-server): exempt validated provider-relay requests fr…
schlessera commentedon Nov 3, 2026
Delivered to
epic/1645-egress-controlsasc648b9307via #3394, after ready-candidate proof passed on the exact epic base. This issue closes when the epic batch lands on main.schlessera commentedon Nov 3, 2026
Delivered on
epic/1645-egress-controls. Its landing on main (#3443) is blocked by #3461: the ready-candidate run 41625377355 failedruntime_hoston that issue's maintenance-admission race, which is not rerun into green under the strict-flake rule. The landing resumes once #3461 merges.Merge branch 'main' into epic/3428-session-taint
CONTRACT: fix(ui-sdk, modules): taint and egress refusals say why (#3431