Repository navigation
CONTRACT: feat(ui-server,common): judge a tainted session's outgoing calls with extraction heuristics at admission (#4088) - #4095
Merged
Conversation
) Adds the #3434 measurement harness: the request schema the classifier scores, seven deterministic signals scored alone and combined, the policy combination that lets an allow relax only the #3430 card, the Jev middle-band judge with its spend ledger, and a labelled set of 86 Odysseus calls over the fixture corpus, with adversarial cases per heuristic. Keyless experiment-tier tests use a deterministic judge stub. The plan records the schema, signals and the offline heuristics table: fingerprint overlap alone reaches 0.54 held-out extraction recall, so the early-stop condition is not met and the live Jev leg is required. Refs #3434 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #3434 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #3434 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dation (#3434) jev-1.13.0 answered all 52 ambiguous-band requests for $0.00152, p50 155 ms and p95 194 ms, with identical answers across three repetitions. On held-out it cuts benign cards from 11 to 3 of 33 with no added leak, but no held-out extraction call reached its band, and it labelled the one tuning beacon benign below the 0.9 floor. The plan now recommends heuristics first, then Jev for the band, each off by default until the band is requalified, and links the implementation tasks #4088, #4089 and #4090 under #3428. A replay test pins the recorded run's table. Closes #3434 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…calls with extraction heuristics at admission (#4088) Add the `taint.classifier` governance policy setting, `off` by default. With `heuristics`, the turn's egress wraps the bridge's per-call admission (`inputSafety.begin`), which every backend awaits with the call's full input, and runs the deterministic #3434 heuristics on each call a tainted session makes: - block refuses the call; the reason is 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 tainted-destination card, only for the hosts a readable call names, and only while that call is in progress. An opaque or unattributable call in progress withholds it. Session state (shingle hashes of the files read, the hosts the tainting content named, each site's earlier payloads) is bounded in-memory host state. A session not observed from its first turn, or that outgrew a bound, never allows. Deny, allowlist mode, budgets and outward cards never consult the classifier. The labelled #3434 set run through the production classifier reproduces the recorded heuristics run call by call: held-out 1 leak and 11 benign cards, the realistic session 7 of 22. Contract: additive `taint.classifier` in the policy schema, its resolved value in `brain policy check --json` `effective.taint`, and the ui-server API report; documented in the contract index, cli.md, package-api.md and supported-inputs.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 of 9 tasks
…heuristics # Conflicts: # docs/plans/extraction-classifier.md
This was referenced Nov 16, 2026
schlessera
marked this pull request as ready for review
November 16, 2026 17:54
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.
Closes #4088
#4071 (the #3434 spike) has merged as
80e5d372f. This branch mergedorigin/mainatc019c8fa5. The add/add conflict indocs/plans/extraction-classifier.mdwas resolved to main's version plus this PR's #4088 additions; main's copy is byte-identical to the spike tip, so nothing of the spike was lost. Every other spike file (evals/3434-extraction-classifier/*,experiments/3434-extraction-classifier.test.ts,docs/plans/README.md) is identical to main. The PR's diff against main is now only the 20 #4088 files.What changed
A new governance policy setting,
taint.classifier, isoffby default. Withheuristics, the host judges each outgoing call of a tainted session before it runs, using the deterministic #3434 heuristics. The seven signals are fingerprint overlap, taint host, encoded blob, volume, write-shaped destination, fan-out and method/tool class. The check sits on the bridge's per-call admission (inputSafety.begin), which every backend awaits with the call's full input. Ablockrefuses the call, and its reason is the call's own tool result, for example "Refused: this Bash call contains text fromhealth/checkup-log.md, and this session fetched a web page." Anaskraises a per-use card that names the reason, for any call, including one to a host the session already contacted, which #3430 admits without a card today. Voice refuses instead of asking. Anallowrelaxes only the #3430 tainted-destination card. It covers only the hosts a readable call names (a WebFetch, or a visible curl/wget/ghread), and only while that call is in progress. An opaque or unattributable call in progress withholds it. The session state is bounded and in memory, keyed by session: shingle hashes of the files read, the hosts the tainting content named, and each site's stream of matched hashes. A session that this process did not observe from its first turn, or whose state outgrew a bound, never allows. It still asks and refuses.Why this shape
inputSafety.begin/resultis the one place every backend (Claude hooks and canUseTool, Pi gate and worker RPC) hands the host the full input before the call runs, and the output after.turn-egresswraps the bridge it already owns, so the proxy (const narrowing),ui-sdkand the backends are unchanged. The relaxation goes through the existingtaint.contactedpredicate. The outward-host card (approveOutward) never consults the classifier.taint.egress.allowhost never reaches the ui-sdk: a tainted session's new destination is refused silently instead of asking the user #3430 card, so a proxy-side ask could be skipped. An approved card relaxes that readable call's hosts while it runs, so the user sees one card, not two. Cards arekind: "command", so they are never remembered or auto-allowed.prepareOutwardPlan(...).classification. A curl/wget write is scored as the set scores it (a writing method to a named host, so a strong copy is blocked), but it never relaxes.gh api -fis a GitHub write in production and keeps its outward card. This is noted in the plan doc.Proof
bun run check:pr --base origin/main # exit 0, receipt belowAfter merging main (
c019c8fa5, base80e5d372f):bun run typecheckwith an 8 GiB heap,bun run buildandbun run api-reportare clean, with no report change. The admission, labelled-set,tainted-destination-ask,turn-egress,shell-taint-proxy,provider-relay-taintandingestion-taintsuites give 51 pass and 0 fail. The policy tests give 15 + 12 pass, andexperiments/3434-extraction-classifier.test.tsgives 17 pass.check:prexits 0 (receipt below, at the new head). The hosted heavy-feedback run below tested the pre-merge head4995b6931; the merge brings in only main's commits, with the #4088 files unchanged.Labelled set through the production classifier (
packages/ui-server/tests/extraction-classifier-labelled.test.ts): all 86 calls match the recorded offline heuristics run (results-offline-2026-11-15.json) call by call. That gives held-out 1 leak and 11 benign cards, 0 benign refused, and the realistic session asks on 7 of 22. A ranking change failsLABELLED_SET_RANKING_CHANGEDwith the per-call diff.Real turn proxy on loopback (
packages/ui-server/tests/extraction-admission.test.ts, 9 tests). They cover the admit, ask and refuse paths, deny/allowlist, voice, the opaque withhold, the outward card, an incomplete state, and the no-conversation-output check.Failing first. The new admission tests against the original
turn-egress.ts(the classifier not wired in): 7 of 9 fail, each on its named assertion, including AC1:Mutations. Each was restored afterwards; all 9 pass again.
allowrelax an outward card (approveOutward:if (calls.covers(host) || extraction?.relaxes(host))):error: CLASSIFIER_ALLOW_KEEPS_OUTWARD_CARD, 8 pass / 1 fail.if (active.some(call => call.withholds)) return false;inrelaxes):error: CLASSIFIER_OPAQUE_WITHHOLDS_RELAXATION, 8 pass / 1 fail. A first version of this test let the mutation survive, because its opaque call named the host itself. The test now uses a script file that names nothing, which only the withhold catches.readable &&fromrelaxable):error: CLASSIFIER_CURL_WRITE_KEEPS_TAINT_CARD, 8 pass / 1 fail.Neighbouring suites. The new tests,
tainted-destination-ask,turn-egress,shell-taint-proxy,provider-relay-taint,reference-egress,session-taint,ingestion-taintandoutward-governancegive 46 pass and 2 fail. The 2 failures areturn-egress-composition's governed claude/pi turns, which need bubblewrap user namespaces (unshare: write failed /proc/self/uid_map) and are unavailable on this host. They are environment-only. The policy tests (core/governance-policy,core/policy-cli,common/taint-trust) pass.tsc --noEmitandbun run buildare clean, and the API report has been regenerated.Provider history. Nothing on the provider-facing path changed: no tool, system prompt, append or transcript change. The only verdict text is a refusal's tool result.
CLASSIFIER_EMITS_NOTHINGandCLASSIFIER_REPORTS_NO_ACTIVITYassert that judging and refusing emit no message or activity. The keyless provider-history guards cannot start a worker on this host, even outside the command sandbox (bwrap: No permissions to create a new namespace), so they ran in hosted draft heavy feedback instead.Hosted draft heavy feedback, run 43882820934:
success, jobs checked out head4995b6931fcb415c458a7930e352a2d373366326. Every selected job passed (verify, runtime, runtime_host, pack, browser 1–3, unit 1–4, layout 1–2, endurance, captures); onlysupersedewas skipped, as designed. The provider-history guard ran inunit (2)andunit (3), all passing:ui-backend-claude/tests/provider-history.test.ts(16 tests, e.g. Claude stable system stays byte-identical on resume, Claude tools stay identical typed -> voice -> typed (#2048)),ui-backend-pi/tests/provider-history.test.ts(13 tests), and bothprovider-history-apify.test.tsfiles. Both shards end with0 fail; the only(fail)lines in their logs are the suite's intentional timeout controls. This is feedback, not merge proof.{"version":1,"kind":"brain-check-pr-receipt","head":"963a721320b54990e4a02bf769e91e8c402c24e9","base":"origin/main","mode":"focused","startedAt":"2026-11-16T17:50:19.093Z","finishedAt":"2026-11-16T17:51:48.439Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":12498.565969000001},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":105.43713900000148},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":67.51417500000025},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":22.629290000000765},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":76635.713487}]}Collisions (
bun scripts/collisions.ts --json --pr 4095, rerun at headc019c8fa5): nopathcollisions.textual: #3622 indocs/integration-contract/package-api.md(both add a section; whichever lands second merges).closureonly (shared test/build closure, not shared files): #3054, #3056, #3059, #3069, #3581, #4002, #4036, #4060, #4068, #4070, #4074, #4075, #4080, #4096, #4099.Proportionate containment (new guard)
taint.classifier: heuristics, only on a tainted session, and only for calls admitted throughinputSafety.begin. It does not cover the known evasions listed in the plan (paraphrase, opaque transformation, one-bit beacons, leaks to an approved host, unknown encodings, cross-site trickles, the relay), shell reads (cat) of brain files, which are not fingerprinted, or a backend bridge with no admission collector, where nothing is classified or relaxed.blockrefuses only that call; the turn and session continue.askadds one per-use card.allow, and a new session clears it. No owner action is needed.CLASSIFIER_ALLOW_ONLY_NAMED_HOSTS,CLASSIFIER_ALLOW_ENDS_WITH_CALL,CLASSIFIER_INCOMPLETE_STATE_NEVER_ALLOWS, and the turn continuing afterCLASSIFIER_BLOCK_REFUSES: the later WebFetch call in that test is judged normally.Checklist
.changeset/extraction-heuristics-admission.md(common, brain, ui-server: minor).cli.md,package-api.md,supported-inputs.mdand the API report are updated in theCONTRACT:commit.governed-writable-workers.md#extraction-heuristics,hosting/agent-workers.md, the plan doc, and citations shifted by this change repaired.Anything left open
cat notes.md) are not fingerprinted. Only Read and brain-kit's read tools are. This matches the plan's scope ("shell-argument taint detection" is out of scope per ui-server: an ordinary shell command taints a governed session even when the egress proxy records real connections #3429).🤖 Generated with Claude Code