Repository navigation
CONTRACT: test(ui-server): prove the Network card for raw GitHub API connections and document the GitHub tools (#3799) - #4132
Merged
Conversation
…on at a live client (#3799) An unclassified shell connection to api.github.com raises the Network card at the connected client, naming method and host; allowing admits the held tunnel, declining refuses it with the reason the tool sees, stopping the turn cancels it and withdraws the card, and a card raised with no client connected is held and delivered to the next client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st tools and record the kept Network card (#3799) Both backends' fixed outward note now names the host GitHub tools under the backend's visible names, says the worker holds no GitHub credential so gh, curl and WebFetch cannot act as the user, and says to report and stop when the tools are absent or answer unavailable or policy_denied. Each keyless provider-history guard asserts the line is in the provider-facing system on every request. The governed-writable-workers decision records the #3791 rulings: host tools, the dedicated credential, the write allow-list and the kept Network card with its proven allow, deny, stop and reconnect behaviour. The MCP contract, the contract index and the policy reference describe the raw connection path. The BRAIN_UI_GITHUB_TOOLS_TOKEN reference now covers the write tools and their fine-grained permissions, and the hosting guide gains a token setup section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
Owner
Author
Independent reviewReviewed head 0c3661f against base 40779d4. Reviewer: agent. No findings. |
…e fixed system brief, not the per-turn note (#3799) The outward note travels in each turn's new-tail host context, not the system prompt, so the previous commit's line moved the exact generated note and never reached the fixed system. The line now lives in buildSystemPromptAppend behind an optional githubTools input. Claude passes it in the append each interactive session retains once; pi passes it through its fixed caps. A session retained earlier keeps its append byte for byte. The outward note is back to its main bytes. The Claude SDK-options snapshot re-records only the inserted bullet in the four interactive modes. The API report records the additive GithubToolsBrief type and option, and the package-API contract describes them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…type (#3799) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Collisions at head
|
Owner
Author
Independent reviewReviewed head 76467d9 against base 7dfadc2. Reviewer: agent. No findings. |
schlessera
marked this pull request as ready for review
November 17, 2026 04:54
8 of 10 tasks
This was referenced Nov 17, 2026
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 #3799
What changed
This PR proves end to end that a raw, unclassified shell connection to GitHub's API keeps its
Networkapproval card (#3791 ruling 2). A new test drives the real app's WebSocket handlers, governed admission and the turn's own egress proxy (packages/ui-server/tests/github-network-card.test.ts). The fixture runs the hosted report's compoundcurlcommand, which the classifier reads as opaque. The card reaches the connected client withtoolName: "Network",input: { host: "api.github.com", port: 443, method: "CONNECT" }and the descriptionCONNECT to api.github.com:443. The client's status readsWaiting for approval: Network, and nothing is contacted before an answer.403 Forbidden - outward connection not approved, with the reason the tool prints.Both backends' fixed system brief (
buildSystemPromptAppend, the append each interactive session retains once) now carries one bullet naming the four host GitHub tools under the backend's visible names (mcp__brain-ui__brain_github_*on Claude, the bare names on pi). It tells the model not to usegh,curlor WebFetch for GitHub, and to report and stop when the tools answerunavailableorpolicy_denied. The input is the new optionalgithubTools(additive, in the package-API contract and API report). A session retained before this keeps its append byte for byte. The docs now record the shipped behaviour:BRAIN_UI_GITHUB_TOOLS_TOKENenv reference, which previously covered only the reads, now with fine-grained permissions checked against GitHub's permissions page;Why this shape
I found no runtime gap, so no product code changes beyond the note. The issue's suspected gap was a card that never reaches a client that isn't watching. The host already holds such a card and re-sends it on reconnect (
resendPendingInteractive); the test now pins that behaviour. The remedy for a phone that stays away is the existing hold, bounded by the turn's timeout. No separate notification exists for a held card; that is recorded in the decision, not filed as a defect.The first head (0c3661f) put the line in
workerOutwardNote. That note travels in each turn's new-tail host context, not the system prompt, so heavy feedback failed: the guard found no line in the system, andworker-sandbox-note.test.tssaw the exact generated note move. The line now lives in the fixed brief, and the outward note is back to main's bytes. Claude's retained append passesgithub: truelike the other always-present tools; pi passes it through its fixed caps (github: truewas missing there). The Claude SDK-options snapshot is re-recorded for exactly that one inserted bullet in the four interactive modes. Autonomous modes and every other option stay byte-identical; I checked the diff field by field.Proof
bun run check:pr --base origin/main # exit 0, receipt belowLive-client test.
github-network-card.test.tspassed 4/4 in three consecutive runs (about 3.5 s each). Each mutation was applied, run and restored:GITHUB_API_HOSTSfromoutwardHosts(turn-egress.ts)GITHUB_NETWORK_CARD_REACHES_CLIENT(3 tests),GITHUB_NETWORK_AWAY_CARD_HELDGITHUB_NETWORK_CARD_NAMES_METHOD_AND_HOST(all 4)approveOutwardadmit on denyGITHUB_NETWORK_DENY_REFUSESsignal: new AbortController().signal)GITHUB_NETWORK_STOP_RECORDED(denied, notcancelled)turns.tsand the safety-subscription expiry inpermissions.tsGITHUB_NETWORK_STOP_WITHDRAWS_CARDresendPendingApprovalsa no-opGITHUB_NETWORK_CARD_REACHES_CLIENT(reconnect test)The drain-only mutation survived on its own, because the safety subscription also withdraws the card on abort. That is a genuine second path, so both had to be broken together.
Brief. New tests, each with its mutation:
ui-sdk/tests/github-tools-brief.test.tsgithubToolsLinepushGITHUB_BRIEF_NAMES_TOOLS claudeui-backend-claude/tests/sdk-options-units.test.ts(fixed append)github: falsein the retained appendCLAUDE_FIXED_APPEND_GITHUB_LINEui-backend-pi/tests/github-tools-brief.test.ts(new session, and a retained pre-#3799 append kept byte for byte)github: truefrom pi's fixed capsPI_FIXED_APPEND_GITHUB_LINELocally,
worker-sandbox-note.test.tsnow passes theCLAUDE_EXACT_NEW_TAIL_NOTEassertion that failed on the first head. Its pi half needs user namespaces, which this host lacks.Provider-history guards.
packages/ui-backend-{claude,pi}/tests/provider-history.test.tsnow assert the brief's GitHub bullet is in the provider-facing system on every captured request; the existing identity tests hold its bytes. These areruntime-category tests. They cannot run on this host: bubblewrap cannot create an unprivileged user namespace. They fail the same way on anorigin/mainworktree, even with the sandbox lifted, so their proof is requested from hosted heavy feedback on this draft.Hosted heavy feedback. Run 44008629928 on 76467d9 completed
success, including the unit, runtime and provider-history jobs; the independent review of 76467d9 found nothing. The first head's run (43997233028, 0c3661f) failed for the reason described under Why this shape.Merge and checks.
origin/mainmerged at 7dfadc2 and again at 16dfb9c (#4124's routing docs landed beside this PR's sections; both merges were clean, no conflicts), thencheck:prreran on 7e3d187. Typecheck and build. Roottsc --noEmitpassed withNODE_OPTIONS=--max-old-space-size=8192; it runs out of heap at the default size on this host.bun run buildandbun run lintpassed.Fixture note. The first draft opened its connection immediately after
session_info. The host then refused the card as a stale safety admission, because the session binding landed in between. A real turn cannot reach that state: its first model request passes the inference relay, which settles the binding before any tool runs (settleOperation). The fixture now waits for the committed binding, with a comment saying why.{"version":1,"kind":"brain-check-pr-receipt","head":"7e3d187ff6b6d412f2453f2a68af45a93f9487b3","base":"origin/main","mode":"focused","startedAt":"2026-11-17T04:34:20.889Z","finishedAt":"2026-11-17T04:35:34.411Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":13076.318677},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":123.60387700000138},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":96.25088099999994},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":23.376659000001382},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":60184.36686400001}]}Checklist
.changeset/3799-github-tools-brief.md).CONTRACT:commits.docs/reflect the change.Anything left open
docs/decisions/governed-writable-workers.mdis also edited by draft CONTRACT: feat(ui-server): bind managed source to turn authority #4002, in a different section.🤖 Generated with Claude Code