Skip to content
Merged
7 changes: 7 additions & 0 deletions .changeset/extraction-heuristics-admission.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@schlessera/brain-common": minor
"@schlessera/brain": minor
"@schlessera/brain-ui-server": minor
---

Add the `taint.classifier` governance policy setting, `off` by default. With `heuristics`, the host judges each outgoing call of a tainted session at admission with the deterministic extraction heuristics measured in #3434: a call that copies a file the session read to a new or writing destination is refused with the reason as its tool result, a suspicious call asks with the reason on a per-use card (even to a host the session already reached), and a clean read admits the hosts it names without the tainted-destination card while it runs. Deny, `allowlist` mode, budgets, outward cards and voice refusals are unchanged. `brain policy check` reports the resolved setting.
5 changes: 5 additions & 0 deletions api-report/ui-server.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,10 @@ signatures (every public export and the types it is made of)
max_tool_calls: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>>;
taint: z.ZodOptional<z.ZodObject<{
classifier: z.ZodOptional<z.ZodEnum<{
heuristics: "heuristics";
off: "off";
}>>;
egress: z.ZodOptional<z.ZodObject<{
allow: z.ZodArray<z.ZodString>;
}, z.core.$strict>>;
Expand Down Expand Up @@ -2767,6 +2771,7 @@ signatures (every public export and the types it is made of)
max_tool_calls: number;
};
taint: {
classifier: "heuristics" | "off";
egress: {
allow: string[];
};
Expand Down
45 changes: 37 additions & 8 deletions docs/decisions/governed-writable-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2447,7 +2447,7 @@ reports which applies as `governed.egress`. Making the relay work without
managed storage is follow-up work. Each connection is recorded as a governance event, and a recording
failure ends the turn. Without a governance recorder the policy still applies
and only the records are absent (`prepareTurnEgress`,
`packages/ui-server/src/brain/turn-egress.ts:84-204`). The note says egress is
`packages/ui-server/src/brain/turn-egress.ts:86-216`). The note says egress is
recorded only when the backend actually routed the worker through the proxy.
API-key Claude profiles (2026-10-22) and pi turns (2026-10-23) are routed
too. A pi turn whose credential the relay cannot carry is refused rather than
Expand Down Expand Up @@ -4049,7 +4049,7 @@ outward host skips the card only while every classified call in progress is a
visible read, or an approved outward action that names that host. A GitHub
write names the GitHub API hosts, and a push or HTTP write names its target's
host. Any unknown or opaque call in progress withholds the exception
(`createOutwardCalls`, `packages/ui-server/src/brain/turn-egress.ts:60-82`).
(`createOutwardCalls`, `packages/ui-server/src/brain/turn-egress.ts:62-84`).
A background process left by an earlier call can still connect inside such a
window; the proxy records it either way.

Expand All @@ -4063,7 +4063,7 @@ listen on other ports: `gmail.googleapis.com`, `graph.microsoft.com`,
`smtp.sendgrid.net`, `api.mailgun.net`, `api.eu.mailgun.net`,
`smtp.mailgun.org`, `smtp.eu.mailgun.org`, `api.postmarkapp.com`,
`smtp.postmarkapp.com`, `api.resend.com` and `smtp.resend.com`
(`MAIL_SUBMISSION_PORTS`, `packages/ui-server/src/brain/turn-egress.ts:20-23`).
(`MAIL_SUBMISSION_PORTS`, `packages/ui-server/src/brain/turn-egress.ts:22-25`).
Microsoft Graph and Exchange Online carry more than mail, so their reads by
an opaque script also wait on the card. The coordinator chose this list for
#1665; the maintainer may override it.
Expand Down Expand Up @@ -4189,7 +4189,7 @@ charges only after admission); otherwise it is refused and recorded as an
`egress_denial` with reason `taint_allowlist` (an interactive turn asks first
since 2026-11-03, see [below](#tainted-destinations-ask)). The taint list
narrows and never widens: deny and `allowlist` mode still apply first (`prepareTurnEgress`,
`packages/ui-server/src/brain/turn-egress.ts:84-230`). Hosts without managed
`packages/ui-server/src/brain/turn-egress.ts:86-242`). Hosts without managed
native storage have no proxy, so the Bash classifier remains their shell rule
and nothing narrows their egress.

Expand Down Expand Up @@ -4237,12 +4237,12 @@ through the turn's tool-permission card (`toolName: "Network"`, `kind:
(`const narrowing`, `packages/ui-sdk/src/server/egress-proxy.ts:198-203`). The
card names the destination, the session's first taint source and the
consequence of allowing it
(`taintedDestinationDescription`, `packages/ui-server/src/brain/turn-egress.ts:39-44`).
(`taintedDestinationDescription`, `packages/ui-server/src/brain/turn-egress.ts:41-46`).
Concurrent connections to the same host share one card. An allowed
connection's admission adds its host to the turn's contacted hosts, and its
charged `egress_connection` record carries the host into the session's later
turns, so it is not asked for again; a different host still asks
(`const approveTainted`, `packages/ui-server/src/brain/turn-egress.ts:168-179`).
(`const approveTainted`, `packages/ui-server/src/brain/turn-egress.ts:172-183`).
A decline refuses: the record stays an `egress_denial` with reason
`taint_allowlist`, and the 403 carries a short reason the tool can print (`function describeRefusal`,
`packages/ui-sdk/src/server/egress-proxy.ts:88-104`). Stopping the turn while the
Expand All @@ -4252,6 +4252,35 @@ a card as before; deny and `allowlist` mode still refuse first. Maintainer
ruling A on #3430; B (ask only for reads) and C (keep refusing with an
after-the-fact notice) were rejected.

<a id="extraction-heuristics"></a>

**Extraction heuristics at admission — 2026-11-16
([#4088](https://github.com/schlessera/brain-kit/issues/4088)).** Asking for
every new host shows the card often enough to be rubber-stamped, and admits
anything sent to a host the session already reached. The policy setting
`taint.classifier: heuristics` (default `off`) runs the deterministic
heuristics #3434 measured ([the plan](../plans/extraction-classifier.md)) on
each call a tainted session makes, at the per-call admission every backend
awaits with the call's full input (`wrap`,
`packages/ui-server/src/brain/turn-extraction.ts:137-158`). The signals and
bands are pure (`classify`,
`packages/ui-server/src/governance/extraction-classifier.ts:583-590`); their
session state (shingle hashes of the files read, the hosts the tainting
content named, each site's earlier payloads) is in-memory host state, never
recorded or sent to a provider. `block` refuses the call with the reason as
its tool result, the only verdict text the model sees. `ask` raises a per-use
card naming the reason, for any call, including one to a contacted host;
voice refuses instead. `allow` relaxes only the #3430 card, only for the hosts
a readable call (a WebFetch, a visible curl/wget or `gh` read) names, and only
while that call is in progress; an opaque or unattributable call in progress
withholds it, because the proxy cannot tell which process opened a connection
(`relaxes`, `packages/ui-server/src/brain/turn-extraction.ts:193-197`). Deny,
`allowlist` mode, the byte ceiling, the outward-host card and the outward
action cards never consult it. A session this process did not observe from
its first turn, or whose state outgrew its bounds, never allows. The setting
stays off by default until a maintainer ruling on #4088 after the band is
requalified (#4090).

<a id="refusals-say-why"></a>

**Refusals say why — 2026-11-04
Expand All @@ -4266,7 +4295,7 @@ the byte ceiling, an unapproved outward host, or a tainted session's host
outside its allow-list, with the session's first taint source and what the
user can do (`function describeRefusal`,
`packages/ui-sdk/src/server/egress-proxy.ts:88-104`; the source wording,
`cause: () =>`, `packages/ui-server/src/brain/turn-egress.ts:195`). The status
`cause: () =>`, `packages/ui-server/src/brain/turn-egress.ts:207`). The status
line carries the reason because `curl -v`, `git` and `egress-connect` print
only that line for a refused CONNECT. The provider relay passes the proxy's
reason through as the refusal body's `error.message` and an additive
Expand Down Expand Up @@ -4371,7 +4400,7 @@ admission (`relayed`, `packages/ui-sdk/src/server/egress-proxy.ts:338`), and
worker HTTP and `CONNECT` traffic cannot claim it, even to a provider's host
(`narrowed`, `packages/ui-sdk/src/server/egress-proxy.ts:196`). Turn egress
records neither a taint nor a contacted host for the operation
(`admitted`, `packages/ui-server/src/brain/turn-egress.ts:204-209`). So in a
(`admitted`, `packages/ui-server/src/brain/turn-egress.ts:216-221`). So in a
tainted session, the worker's own traffic stays narrowed away from the
provider's host.

Expand Down
7 changes: 6 additions & 1 deletion docs/hosting/agent-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,12 @@ connections reach only `taint.egress.allow` and hosts its proxies already
admitted. In an interactive turn, a connection to any other host first shows
a permission card naming the host and what tainted the session; allowing it
admits that host for the rest of the session (#3430). Voice turns refuse
without a card. Refusals, including a declined card, are `egress_denial`
without a card. With `taint.classifier: heuristics` in the governance policy
(off by default), the host also judges each call a tainted session makes
before it runs (#4088): a call that looks like it carries the session's
notes out is refused, or asks with the reason on the card, even to a host
the session already reached, and a clean read admits the hosts it names
without the card while it runs. Refusals, including a declined card, are `egress_denial`
events with reason `taint_allowlist`. Every refusal with a policy cause
(taint, the deny or allow list, the byte ceiling, an unapproved outward host)
answers with a status text and a body naming that cause, so `curl -v`, `git`
Expand Down
9 changes: 9 additions & 0 deletions docs/integration-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ same-commit update of the index or relevant authoritative component. How they ar

The reasoning is in [decisions/contract-versioning.md](decisions/contract-versioning.md).

## Extraction classifier setting (additive, 0.45.0, #4088)

The governance policy gains optional `taint.classifier`, `off` (the default) or
`heuristics`, and `brain policy check --json` reports it in `effective.taint`.
See [the supported input](supported-inputs.md#governance-policy),
[the CLI component](integration-contract/cli.md) and
[the package API](integration-contract/package-api.md#extraction-classifier-setting-additive-0450-4088).
This ships in a minor; no breaking ruling is required.

## Reference pool growth status (additive, 0.45.0, #3515)

The host-only `brain-native-store pool` projection gains a read-only `growth`
Expand Down
2 changes: 2 additions & 0 deletions docs/integration-contract/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ by default, or the complete validated canonical trust entries from the
[supported input](../supported-inputs.md#prospective-trust-policy-data-additive-3607),
with explicit incoming/recipient defaults. This reports data, not a runtime
trust exemption or new review capability; sticky taint enforcement is unchanged.
Since #4088 (additive), `effective.taint` also includes `classifier`, `"off"`
unless the file sets `"heuristics"`.
Valid and missing inputs exit 0 with `ok: true`, and invalid inputs exit 1 with
`ok: false`. Missing inputs have a null hash, no errors and built-in defaults.
Invalid input returns defaults, its validation errors, and a hash when its bytes
Expand Down
10 changes: 10 additions & 0 deletions docs/integration-contract/package-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5350,6 +5350,16 @@ helpers remain on the existing brain-common internal governance-policy entry
point and establish no new extension seam or runtime authority. No SDK safety
capability, HTTP endpoint, history DTO or provider conversation changes here.

## Extraction classifier setting (additive, 0.45.0, #4088)

The governance policy types reachable through ui-server's public signatures
accept optional `taint.classifier` (`"off" | "heuristics"`) and resolve it to
`"off"` by default. The [supported input](../supported-inputs.md#governance-policy)
describes what `heuristics` does. The same-commit API report records this
additive type change. No SDK type, HTTP endpoint, card field or provider
conversation changes: the classifier's card and refusal are existing
permission requests and tool-result text.

## Live brain orientation and task status (additive, #3623)

`LiveConversationOpenOptions.orientation?: ConversationOrientation` supplies an
Expand Down
18 changes: 15 additions & 3 deletions docs/plans/extraction-classifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ to be rubber-stamped.

The harness, the labelled set and the recorded runs are in
[`evals/3434-extraction-classifier/`](../../evals/3434-extraction-classifier/README.md).
Nothing here changes production admission.
The heuristics now ship behind `taint.classifier: heuristics`, off by default
([#4088](https://github.com/schlessera/brain-kit/issues/4088); how they sit in
admission is [the decision record](../decisions/governed-writable-workers.md#extraction-heuristics)).
`packages/ui-server/tests/extraction-classifier-labelled.test.ts` runs the
labelled set through the production classifier and compares every call with
the recorded offline run. The Jev band is not built
([#4089](https://github.com/schlessera/brain-kit/issues/4089)).

## Where it runs and what it may change

Expand All @@ -30,7 +36,7 @@ It is advisory and narrow:
- An `allow` may relax exactly one thing, the #3430 card for a host the
tainted session has not contacted
(`const narrowing`, `packages/ui-sdk/src/server/egress-proxy.ts:280-285`;
`const approveTainted`, `packages/ui-server/src/brain/turn-egress.ts:168-179`).
`const approveTainted`, `packages/ui-server/src/brain/turn-egress.ts:172-183`).
Because the proxy cannot tell which process opened a connection, that
relaxation can only cover the hosts a readable call names while it is in
progress, as the outward exception already does. An opaque call withholds
Expand Down Expand Up @@ -75,7 +81,7 @@ Each is deterministic and was scored alone
| Taint host | A destination's site appears among the hosts the tainting content named. |
| Encoded blob | A base64 or hex token of at least twelve characters in subdomain, path, query or body; an undecodable one must be twenty characters with a digit. `encodedText`: the blob decodes to readable text. |
| Volume | A query of 120 characters or data of 512 bytes to a host the session has not contacted. |
| Write-shaped | Paste, webhook, request-bin, form, upload and collect hosts, the built-in outward mail hosts (`MAIL_SUBMISSION_PORTS`, `packages/ui-server/src/brain/turn-egress.ts:20`), a writing method to a submit, issue, comment, gist or message path, a beacon path, or an MCP tool named send, create, post, upload, comment, write, update, append or share. |
| Write-shaped | Paste, webhook, request-bin, form, upload and collect hosts, the built-in outward mail hosts (`MAIL_SUBMISSION_PORTS`, `packages/ui-server/src/brain/turn-egress.ts:22`), a writing method to a submit, issue, comment, gist or message path, a beacon path, or an MCP tool named send, create, post, upload, comment, write, update, append or share. |
| Fan-out | Five earlier calls, or three distinct hosts, to one site the session had not used before its taint. |
| Method | A writing method, or a tool the policy classifies outward or opaque. |

Expand Down Expand Up @@ -278,3 +284,9 @@ These stay with the card, whatever configuration is chosen:
reason is the only verdict text the model sees.
- **Outward actions are not blocked by overlap.** They keep their own card, with
the overlap as evidence on it.
- **Production derives the tool class from the command policy.** The
labelled set authors it per case. A curl or wget write is an outward action
with its own card in production, and the classifier scores it as the set
does: a writing method to a named host, blocked for a strong copy. `gh api`
with fields is a GitHub write in production, so it keeps the outward card
that the set's GraphQL reads do not show.
2 changes: 1 addition & 1 deletion docs/plans/reviewable-session-safety.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public design or its fixtures. Fictional examples use the Odysseus world.
never prove finalized delivery or complete coverage.
- The turn proxy records each admitted non-provider connection and terminal
exposure observation (`prepareTurnEgress`,
`packages/ui-server/src/brain/turn-egress.ts:84-272`). Relay admissions join
`packages/ui-server/src/brain/turn-egress.ts:86-295`). Relay admissions join
this proxy's submitted terminal observations and its own announced session
binding before reading fresh safety (`settleTurnSessionBinding`,
`packages/ui-server/src/ws/bridge-session-binding.ts:14-28`), without excluding
Expand Down
Loading
Loading