Skip to content

CONTRACT: feat(ui-server): route the host GitHub reads under the provider policy (G2) (#4029) - #4124

Merged
schlessera merged 3 commits into
mainfrom
feat/4029-github-g2-routing
Nov 17, 2026
Merged

schlessera merged 3 commits into
mainfrom
feat/4029-github-g2-routing

Conversation

@schlessera

@schlessera schlessera commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Closes #4029

Part of epic #3791.

What changed

The host GitHub read tools now follow the provider policy's data routing (G2). GitHub is the provider-policy recipient github, beside apify, the web providers and typesafe. Before any request, brain_github_issue_read and brain_github_issue_search check the turn's frozen policy, its type-to-folder map and the conversation's recorded provider exposures. A conversation that has shown a provider folder the policy keeps from github is refused with policy_denied / recipient_restricted. Under a policy that restricts github, a conversation whose exposure cannot be judged is refused with policy_denied / recipient_unproven: an unnamed conversation, an unreadable exposure record, a type selector without its folders, a turn with no frozen policy, or a routing check that throws. A refused call sends GitHub nothing, returns no GitHub text and taints nothing. Writes are not routed. Following the maintainer ruling of 2026-11-16, the card and outward.github.repositories stay their gate, and a write in a restricted conversation still reaches its card unchanged.

Why this shape

  • One rule, shared. recipientRouting (packages/ui-server/src/web-tools/routing.ts) is the rule webRoutingRefusal already applied, now returning a coded verdict (recipient_restricted / recipient_unproven, the same reasons Apify's routingGate uses). webRoutingRefusal wraps it, so its messages are byte-identical for the web tools and the extraction judge.
  • The turn binds routing, not the call. GithubToolsTurn.routing is a required field, so a caller cannot forget it. The bridge builds it from the turn's frozen policy and the recorded exposures. The governance bridge option now also carries the hold's typeFolders, as the extraction judge already uses them, so type selectors are judged whether or not the turn's own inference recipient has masks. In the host, a throw from routing counts as unproven.
  • Order. The credential check comes first, then routing, then the schema parse and the requests. Every refusal sends nothing.
  • Writes exempt (ruling). The write path never asks routing. A host test and an end-to-end test pin this.

Proof

New and updated tests:

  • packages/ui-server/tests/github-tools-host.test.ts, "data routing (G2, ui-server: apply provider-policy data routing (G2) to the host GitHub tools #4029)": restricted, unproven and a throwing check each refuse both read tools with the coded reason. Each asks the recipient github, and the loopback stand-in receives no request and no taint is recorded. An admitting check reads as before.
  • packages/ui-server/tests/github-write-tools.test.ts, "data routing does not gate writes": under a routing that refuses github, create and comment return results equal to the unrouted baseline, with identical cards and identical POSTs, and routing is never asked.
  • packages/ui-server/tests/ws-github.test.ts: real createApp Claude turns under a governance policy providers: [{ paths: [journal/**], allow: [anthropic] }]. (1) With an earlier turn's recorded exposure showing journal, read and search are refused recipient_restricted and taint nothing. A write in the same turn still raises one card with the exact input, and the stand-in receives only that POST. (2) With an unreadable exposure record, read and search are refused recipient_unproven, and the stand-in receives nothing. (3) With journal shown but still masked, both read as before. The existing unrestricted read and write cases still pass.
  • github-details.test.ts turns gain routing. web-tools-admission, web-tools-broker, ws-web-access and extraction-judge pass unchanged.

Mutation receipts. Each source was restored from its backup afterwards and the tree checked clean:

  • Skip the routing check in the host (routed = null): github-tools-host.test.ts fails GITHUB_ROUTING_REFUSED_brain_github_issue_read for restricted, unproven and the throwing check, plus the admitted case's asked. ws-github.test.ts fails GITHUB_APP_ROUTING_RESTRICTED brain_github_issue_read and GITHUB_APP_ROUTING_UNPROVEN brain_github_issue_read (6 fail, 20 pass).
  • Bridge admits everything (return null instead of recipientRouting): ws-github.test.ts fails GITHUB_APP_ROUTING_RESTRICTED and GITHUB_APP_ROUTING_UNPROVEN (2 fail, 7 pass).
  • Bridge treats an unreadable exposure as clean (catch { shown = []; }): GITHUB_APP_ROUTING_UNPROVEN brain_github_issue_read fails (1 fail, 8 pass).
  • Route writes too: GITHUB_WRITE_NOT_ROUTED brain_github_issue_create and GITHUB_APP_WRITE_NOT_ROUTED fail (2 fail, 23 pass).

bun run build, tsc --noEmit and bun run lint are clean.

bun run check:pr --base origin/main
{"version":1,"kind":"brain-check-pr-receipt","head":"7559742b03e5a366220bbc6d57e21976477e5dec","base":"origin/main","mode":"focused","startedAt":"2026-11-17T00:41:30.393Z","finishedAt":"2026-11-17T00:42:24.818Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":20709.677197000005},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":146.27440700000443},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":121.58589100000245},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":23.967507000001206},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":33404.558419999994}]}

Checklist

  • Focused local preflight/behavioral receipts and complete selected hosted proof passed; actual head/base/job checkout evidence is in Proof. (Local receipt above. Hosted proof runs at confirmation.)
  • Acceptance criteria from the issue are all met, or the gap is named below.
  • The PR and completed/advanced issues have verified release milestones under docs/process/github.md.
  • A changeset is included, or this changes nothing a consumer can see. (.changeset/4029-github-g2-routing.md, with the release-note effect on existing policies.)
  • No personal data anywhere in the diff — the leakage gate covers the whole tree.
  • The integration contract index or relevant component is updated in this same commit, or nothing in the machine surface moved. (docs/integration-contract.md index entry, mcp.md#github-data-routing-additive-0450-4029, supported-inputs.md "Tool recipients (G2)". Additive: a new recipient name and two new refusal reasons on the read tools.)
  • Docs under docs/ reflect the change, or nothing documented moved.
  • A fail-closed guard added or changed answers the proportionate-containment checklist in this body, or no guard changed.
  • Provider history stays append-only: nothing on the provider-facing path changes. Tool definitions and schemas are unchanged, and a refusal is an ordinary tool result.

Proportionate-containment checklist (G2 routing on the GitHub reads)

  • What triggers it, and which failures it does not cover: a GitHub read or search in a conversation whose recorded exposures include a provider folder that a providers rule keeps from github. Under such a rule, it also triggers when the exposure cannot be judged. It does not cover the writes (ruled out: the card is their gate), raw curl/gh connections (the Network card, ui-server, docs: prove the Network card for raw GitHub API connections and document the GitHub tools #3799), or content a turn read before a rule selected its folder (not tracked, as for every recipient).
  • What it restricts: one call to one recipient. The conversation keeps every other tool, including GitHub writes. Other conversations are unaffected, and a policy that allows github restricts nothing. Nothing narrower exists: the query is model-written text that can quote anything the conversation was shown.
  • Restricted mode considered: redacting the query. It was rejected because the host cannot tell which words came from a restricted folder. Refusing the call is the restricted mode, as for Apify and the web providers.
  • How it clears: automatically. A new conversation has no exposure record, and an unnamed one is judged once it is named. An owner who wants GitHub to receive a folder adds github to that rule's allow. That is a policy decision, so it needs a human.
  • Where the cause is recorded: the refusal carries a coded reason (recipient_restricted / recipient_unproven) and a message naming github, returned to the model and kept in the conversation's tool result. The exposures it is judged on are the server's durable session_provider_exposure record.
  • Which test shows one scope failing leaves another usable: ws-github.test.ts refuses the reads and files the write in the same turn. github-write-tools.test.ts shows writes unchanged under a refusing routing.

Collisions

bun scripts/collisions.ts --json --pr 4124 at head 7559742b03e5a366220bbc6d57e21976477e5dec: no path or unknown collisions. There are closure-only overlaps (shared test graph, no shared changed file) with #3056, #3059, #3069, #3581, #3622, #4002, #4036, #4102, #4106, #4112, #4113, #4115, #4118, #4122 and #4123.

Anything left open

Nothing. The GitHub tools docs slice (#3799) has not landed yet, so the routing paragraph lives in the MCP contract's GitHub section, which #3799 can link from its docs.

🤖 Generated with Claude Code

…ider policy (G2) (#4029)

GitHub is now the provider-policy recipient `github`. Before any request,
`brain_github_issue_read` and `brain_github_issue_search` refuse a
conversation that has shown a provider folder the policy keeps from github
(`policy_denied`, `recipient_restricted`), and, under a policy restricting
github, one whose exposure cannot be judged (`recipient_unproven`). The
rules are the web providers' and Apify's, shared through
`recipientRouting`. The turn binds its frozen policy, type folders and the
conversation's recorded exposures; a throw counts as unproven.

Writes are not routed (maintainer ruling, 2026-11-16): the approval card
and `outward.github.repositories` stay their gate, and a test pins that a
write in a restricted conversation still reaches its card unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 786ba74 against base 7dfadc2. Reviewer: agent. No findings.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4124,
  "head": "786ba74f0434e35e0eb17a4f755563a0e546e6a9",
  "base": "7dfadc217c406255935f7fc626594acf2c2e8b9a",
  "reviewer": "agent",
  "outcome": "no-findings",
  "findings": []
}

@schlessera
schlessera marked this pull request as ready for review November 17, 2026 02:52
@schlessera
schlessera merged commit 3714b7f into main Nov 17, 2026
55 of 56 checks passed
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. 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: apply provider-policy data routing (G2) to the host GitHub tools

1 participant