Skip to content

CONTRACT: feat(ui-server,common): ask Jev about the extraction heuristics' ambiguous band, routed under G2, metered and budgeted (#4089) - #4101

Merged
schlessera merged 2 commits into
mainfrom
feat/4089-jev-extraction-band
Nov 16, 2026
Merged

schlessera merged 2 commits into
mainfrom
feat/4089-jev-extraction-band

Conversation

@schlessera

@schlessera schlessera commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Closes #4089

What changed

A new policy setting, taint.judge, defaults to { mode: off, floor: 0.9 }. With mode: jev, and only beside taint.classifier: heuristics, an interactive turn sends a tainted session's outgoing call to Jev when the call's heuristic score falls in the ambiguous band (0.2 to below 0.35, the #3434 calibration). Without the setting, that call raises the per-use card. The call goes through the host's own Jev client (createJevClient, production mode: one attempt, receipt model and usage read). The client is shared across turns, so its breaker is too. Jev sees a three-part state:

  • the outgoing request, with its body cut at 2,000 characters;
  • the wording of what tainted the session, e.g. fetched a web page;
  • the overlap score.

It never sees the conversation, the tainting content or any file the session read. The model is pinned to jev-1.13.0. benign admits the call, and extraction refuses it, only at or above the floor. Every other result asks:

  • suspicious;
  • an answer below the floor;
  • no answer, or an HTTP error;
  • a timeout, an open breaker or a missing key;
  • a different answering model;
  • an exhausted budget or no ledger;
  • a provider rule that keeps the conversation's folders from typesafe.

Each physical request is metered against the turn, its conversation and its UTC day. It is recorded as a typesafe attempt with the new operation extraction_judge: dispatched just before it leaves, then the settled outcome with the tokens TypeSafe reports. No rate is held for it, so its cost is unknown, never zero. Voice turns never call the judge and keep refusing.

Why this shape

  • The host client, not the worker relay. The judge runs in the host at admission, where the heuristics already hold the call. The relay serves worker requests. The judge reuses the relay's meter (observeProvider/providerAdmission, the same observe path in prepareRelayedEgress) and its typesafe recipient, origin and key name (ui-sdk: relay Jev reranking for governed workers, so hosted search is not always unranked #3792).
  • G2 as the web providers apply it (webRoutingRefusal, recipient typesafe). The judge is shown text the model wrote, which can quote any folder the model saw. A conversation that is not yet named has no recorded exposure, so it sends nothing whenever a rule restricts typesafe.
  • dispatched from inside the client (classify(request, { dispatched })). A call the breaker or a missing key skips records no spend.
  • Floor bounded to 0.5–1. The floor is the only thing standing between Jev's 0.82–0.88 benign on the tuning beacon and the card, so the setting cannot remove it.
  • The taint source is sent as its wording, not the spike's WebFetch <host> name. Production keeps only the source kind, and the wording carries no tainting content. The replay uses the recorded answers; evals: requalify the Jev extraction band with extraction cases that reach it before it is enabled by default #4090 requalifies the band live.
  • A refusal's text is the heuristics' reason. The judge's answer never reaches the conversation.

Proof

bun run check:pr --base origin/main   # exit 0 at 5fff54d20, receipt below

tsc --noEmit (8 GiB heap), bun run build, bun run api-report (ui-server report: taint.judge in schema and resolved policy) and bun run lint are clean.

New and neighbouring suites: extraction-judge (23 tests), extraction-classifier-labelled (4), extraction-admission (9), provider-relay-budgets and the inbox-triage suites give 60 pass and 0 fail. The policy suites (core/governance-policy, core/policy-cli and common/taint-trust) give 16 + 12 pass.

Acceptance criteria, by named test (packages/ui-server/tests/extraction-judge.test.ts; TypeSafe is a stub at fetch, the lowest request method the host client uses):

  • Only the band reaches the judge, and it gets only the request, the source name and the overlap: JUDGE_NOT_ASKED_BELOW_BAND, JUDGE_ONLY_AMBIGUOUS_BAND, JUDGE_STATE_ONLY_THREE_THINGS, JUDGE_NEVER_SEES: <read-file text, tainting text, WebFetch prompt>, JUDGE_MODEL_PINNED and JUDGE_BODY_TRUNCATED.
  • Band mapping: JUDGE_BENIGN_AT_FLOOR_NO_CLASSIFIER_CARD / …_NO_TAINT_CARD (benign at exactly 0.9 admits a new host with no card), and JUDGE_EXTRACTION_REFUSES. Each of the following raises the card: JUDGE_SUB_FLOOR_BENIGN_ASKS, JUDGE_SUSPICIOUS_ASKS, JUDGE_SUB_FLOOR_EXTRACTION_ASKS, JUDGE_NO_ANSWER_ASKS, JUDGE_HTTP_ERROR_ASKS, JUDGE_TIMEOUT_ASKS, JUDGE_OPEN_BREAKER_ASKS (+ _NO_CALL, _NO_RECEIPT), JUDGE_OTHER_MODEL_ASKS and JUDGE_NO_KEY_ASKS.
  • Metering and budget: JUDGE_RECEIPTS, JUDGE_METERED_ON_TURN, JUDGE_TOKENS_CHARGED_{turn,session,day}, JUDGE_COST_UNKNOWN_NOT_ZERO_* and JUDGE_EXHAUSTED_BUDGET_ASKS / JUDGE_NO_LEDGER_ASKS (no call, no receipt). G2 routing: JUDGE_ROUTING_REFUSES_SHOWN_FOLDER, JUDGE_ROUTING_REFUSES_UNKNOWN_EXPOSURE and JUDGE_ROUTING_ADMITS_UNSHOWN.
  • Voice and the setting: JUDGE_VOICE_KEEPS_REFUSING, JUDGE_VOICE_NEVER_CALLS, JUDGE_OFF_BY_DEFAULT and JUDGE_NEEDS_HEURISTICS. Autonomous turns get no turn proxy (prepareRelayedEgress only), so they never build one.
  • Nothing reaches the conversation: JUDGE_EMITS_NOTHING, JUDGE_REPORTS_NO_ACTIVITY, JUDGE_CARD_HAS_NO_VERDICT and JUDGE_REFUSAL_HAS_NO_VERDICT.
  • Replay (extraction-classifier-labelled.test.ts): the recorded results-2026-11-16.json answers go through createExtractionJudge over a stubbed createJevClient with the 0.9 floor. For each of the three repetitions, all 86 calls match the recorded heuristics+jev#<rep> row (JEV_REPLAY_MATCHES_RECORDED_RUN#<rep>). Held-out gives 1 leak, 3 benign cards, 0 benign refused and 8 judged calls. The realistic session asks on 2 of 22.
  • Policy: JUDGE_DEFAULT_OFF, JUDGE_FLOOR_CONFIGURABLE and JUDGE_STRICT_VALUE (rejects floor: 0.4, floor: 1.1, an unknown mode and a model key).

Failing first. The judge modules stay, but the call in turn-extraction.ts that consults the judge is removed. Then the new tests give 10 pass / 13 fail, including JUDGE_BENIGN_AT_FLOOR_NO_CLASSIFIER_CARD and JUDGE_ROUTING_ADMITS_UNSHOWN, and every *_ASKS case fails its judge-call count. This is not a module-load failure. The line was then restored.

Mutations (each restored; the suites pass again):

Mutation Fails
Drop the floor (judgeBand: if (!answer) return "ask") JUDGE_SUB_FLOOR_BENIGN_ASKS, JUDGE_SUB_FLOOR_EXTRACTION_ASKS, FLOOR_BENIGN_BELOW, JEV_REPLAY_MATCHES_RECORDED_RUN#0 (19 pass / 4 fail)
No answer is benign (judgeBand(null) → allow) NO_ANSWER_ASKS
No answer is benign, at the client (if (!answer) → allow) JUDGE_NO_ANSWER_ASKS
Transport failure is benign (outcome !== "answered" → allow) JUDGE_HTTP_ERROR_ASKS, JUDGE_TIMEOUT_ASKS, JUDGE_FAILURE_ASKS
Drop the model pin JUDGE_OTHER_MODEL_ASKS
Skip budget admission JUDGE_EXHAUSTED_BUDGET_ASKS
Skip G2 routing JUDGE_ROUTING_REFUSES_SHOWN_FOLDER
Judge every network call, not only the band JUDGE_NOT_ASKED_BELOW_BAND
Let voice call the judge JUDGE_VOICE_KEEPS_REFUSING

Provider history. Nothing on the provider-facing path changes: no tool, system prompt, append or transcript change. The judge's answers are host state, and a judged call reaches the conversation only as the existing card or refusal text. The keyless guards (ui-backend-claude and ui-backend-pi provider-history.test.ts) cannot start their CLIs on this host. They fail the same way with origin/main's packages/common and packages/ui-sdk checked out (Claude Code process exited with code 1; pi probe()), so this is environment-only. They ran in hosted draft heavy feedback instead.

Hosted draft heavy feedback, run 43940170497: conclusion success, and its jobs checked out head 5fff54d20e224a10a09943587e7c1e0e48c00f54 (HEAD is now at 5fff54d20). Every selected job passed: runtime, runtime_host, browser 1–3, layout 1–2, captures, endurance, pack and unit 1–4. The provider-history guards run in the unit shards. This is feedback, not merge proof.

{"version":1,"kind":"brain-check-pr-receipt","head":"279fb4530f64c46e34357ac14a4a5552204deba1","base":"origin/main","mode":"focused","startedAt":"2026-11-16T23:23:34.292Z","finishedAt":"2026-11-16T23:25:07.622Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":13200.332188999997},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":108.94221899999684},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":81.12373600000137},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":20.18761799999993},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":79902.925318}]}

Collisions (bun scripts/collisions.ts --json --pr 4101, head 5fff54d20): there are no path collisions. The textual ones are #3622 in docs/integration-contract/package-api.md and packages/ui-server/src/app.ts, and #4002 in packages/ui-server/src/ws/session-run/backend-entry.ts; whichever lands second merges. The rest are closure only (a shared test/build closure, not shared files): #3054, #3056, #3059, #3069, #3581, #4036, #4068, #4070, #4074, #4075 and #4080.

Checklist

  • Focused local preflight/behavioral receipts passed; hosted draft heavy feedback run 43940170497 is success at head 5fff54d20.
  • Acceptance criteria from the issue are all met (the live measurement stays outside CI, as scoped).
  • The PR and ui-server: ask Jev about the ambiguous extraction band, routed under G2, metered and budgeted #4089 carry milestone 0.45.0.
  • A changeset is included (.changeset/extraction-judge-band.md).
  • No personal data anywhere in the diff; the leakage gate passes.
  • The integration contract index, cli.md, package-api.md and supported-inputs.md are updated in the CONTRACT: commit.
  • Docs under docs/ reflect the change: the decision record (#extraction-judge), the plan, and hosting/agent-workers.md.
  • Proportionate containment (the judge relaxes a guard, so it answers the checklist). Narrowest scope: one call's card. Restricted before refusing: every uncertain outcome asks rather than refuses; only extraction at or above the floor refuses. Self-recovery: the shared breaker re-probes on its own. Boot: nothing persists, so no historical record can block. Durable cause: each attempt and its outcome is in provider_relay_usage. Unknown never clean: no answer, an unknown exposure or no ledger never admits. No host-wide failure: a dead TypeSafe costs one probe per breaker window and leaves the card.
  • Provider history stays append-only: nothing on the provider path changed, and the guard passed in hosted run 43940170497 (see Proof).

Anything left open

🤖 Generated with Claude Code

…tics' ambiguous band, routed under G2, metered and budgeted (#4089)

Add the `taint.judge` governance policy setting, `{ mode: off, floor: 0.9 }`
by default. With `mode: jev` beside `taint.classifier: heuristics`, an
interactive turn puts a tainted session's outgoing call whose heuristic score
falls in the ambiguous band (0.2 to below 0.35, as #3434 calibrated it) to Jev
through the host's own client instead of raising its card.

- The state is the outgoing request (body cut at 2,000 characters), the
  wording of what tainted the session and the overlap score: never the
  conversation, the tainting content or a read file.
- The model is pinned to jev-1.13.0. `benign` admits and `extraction` refuses
  only at or above the floor (configurable, 0.5 to 1). `suspicious`, a
  sub-floor answer, no answer, a timeout, an open breaker, a missing key and a
  different answering model all ask.
- G2: TypeSafe is the recipient `typesafe` under the web providers' routing
  rule; a conversation shown a folder the policy keeps from it, or one whose
  exposure cannot be judged, sends nothing. A blocked budget scope or no ledger
  sends nothing either.
- Each physical request is recorded as a `typesafe` attempt with the new
  operation `extraction_judge` against the turn, its conversation and its UTC
  day, with the tokens TypeSafe reports; unpriced, so its cost is unknown.
- Voice never calls the judge and keeps refusing. Answers stay host state.

The recorded #3434 Jev answers replayed through the production judge reproduce
the plan's heuristics-plus-Jev row in every repetition: held-out 1 leak and 3
benign cards, the realistic session 2 of 22.

Contract: additive `taint.judge` in the policy schema and in
`brain policy check --json` `effective.taint`, the `extraction_judge` metered
operation, and the ui-server API report; documented in the contract index,
cli.md, package-api.md and supported-inputs.md.

Closes #4089

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 16, 2026
@schlessera schlessera added type: feat A new capability or a change in user-visible behaviour. area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. security Auth, isolation, egress, secrets, or anything in the threat model. labels Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. security Auth, isolation, egress, secrets, or anything in the threat model. type: feat A new capability or a change in user-visible behaviour.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ui-server: ask Jev about the ambiguous extraction band, routed under G2, metered and budgeted

1 participant