Repository navigation
CONTRACT: feat(ui-server,backends,common): GitHub write tools behind a policy repository allow-list and approval cards - #4076
Merged
Conversation
…a policy repository allow-list and approval cards Both backends register `brain_github_issue_create` and `brain_github_issue_comment` in every interactive session's fixed roster, after the two read tools and in the contract's order, whatever the host's configuration or the turn's posture; no autonomous roster lists them. The governance policy gains `outward.github.repositories`: entries are `owner/repo` exactly or `owner/*`, with GitHub's name grammar, compared without case. A malformed entry or an unknown key invalidates the policy; absent or empty, no write is admitted (`githubWriteAllowance`, `packages/common/src/governance-policy.ts`). The host (`packages/ui-server/src/github/host.ts`) decides each write from the turn's admitted policy: outside the list it refuses `policy_denied` (`repository_not_allowed`, naming the key) before any card; voice refuses before the card; without the credential it answers `unavailable`. Inside the list it raises one per-use command card on the turn's own approval surface whose input is exactly the request body plus the repository (and number), sends it once on an unedited allow, and never retries or follows a redirect. A denial, an edited approval, or a turn that ended or lost its authority while the card was open sends nothing. Each refusal, answer and approval is an `outward_action` (`gh_write`) governance event, so the turn journal lists it as irreversible; the approval is recorded before the request, and an unrecorded approval sends nothing. Both backends auto-allow the writes only in a typed turn with a grant surface and a host handler, so the host's card is the only one; voice and no-grant turns refuse them at the runtime's permission boundary. The integration-contract index, the MCP component, the CLI policy check envelope (`effective.outward.github.repositories`), the supported-inputs policy reference and the Claude SDK-options snapshot (two roster names and the schema digest in the four interactive modes) are updated here. Closes #3798 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
9 tasks done
schlessera
marked this pull request as ready for review
November 16, 2026 00:05
schlessera
marked this pull request as draft
November 16, 2026 00:33
schlessera
marked this pull request as ready for review
November 16, 2026 00:33
schlessera
marked this pull request as draft
November 16, 2026 01:32
schlessera
marked this pull request as ready for review
November 16, 2026 01:32
This was referenced Nov 16, 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 #3798
What changed
A hosted turn can now file a GitHub issue (
brain_github_issue_create) or comment on one (brain_github_issue_comment) through the host tools slice 1 (#3797) declared. Both backends register the two write tools in every interactive session's fixed roster, after the reads and in the contract's order, and in no autonomous roster. The governance policy gainsoutward.github.repositories:owner/repoexactly orowner/*, using GitHub's name grammar and compared without case. A malformed entry or an unknown key makes the policy invalid. When the list is absent or empty, no write is admitted. The host checks the turn's admitted policy first, and a repository outside the list is refused withpolicy_denied/repository_not_allowedbefore any card, with the policy key named in the message. Voice is refused before the card. Inside the list, the turn's own approval surface shows one per-use command card whose input is exactly what will be sent. The write is sent once on an unedited allow, and is never retried or redirected. A denial, an edited approval, or a turn that ended or lost authority while the card was open sends nothing. Each refusal, answer and approval is anoutward_action(gh_write) governance event, which the turn journal already lists as irreversible. The approval is recorded (awaited) before the request goes out, so an approval whose record fails sends nothing.Why this shape
toolAvailabilityRefusal,piToolAvailabilityRefusal) refuses the tool before the host is reached, and the host refuses voice again.githubDirectUrlscope. A case-sensitive repository match would only refuse a differently spelled name for the same repository.gh_writeaction withrule: null. The governance event schema is unchanged.needs: decision).Proof
New and updated tests:
packages/ui-server/tests/github-write-tools.test.ts(15 cases, loopback stand-in). One card with the exact repository, title, body and labels; Allow files exactly one issue, with the body sent as shown; the comment path; deny, edited and aborted or revoked approvals send nothing; an unrecorded approval sends nothing; a failed or redirected write is sent once. Outside the list it is refused before any card, with no request. The exact andowner/*forms are accepted, case-insensitively, and nothing that is not listed gets through. An absent or empty list refuses every write. No credential means no card. Voice is refused before the card. A turn without a write surface (autonomous) is refused.packages/ui-server/tests/ws-github.test.ts: realcreateAppturns on pi and Claude. The turn's governance policy file opensodysseus/ithaca:circe/aiaiais refused before any card, and the allowed write raises onetool_approval_requestwith the exact input, sends one POST, and recordsrefusedthenapprovedoutward_actionevents bound to the session. With no policy, writes are refused and nothing is sent.packages/core/tests/governance-policy.test.ts: the default is[], valid forms are accepted, 17 malformed entries are refused, a mixed list is refused (not skipped), unknown keys are refused, and the list is bounded.githubWriteAllowanceis covered for exact, wildcard and case matches and for non-matches.sdk-options-mcp.test.tsand pigithub-tools.test.tspin all four names, schemas and order, byte-identical across typed, no-grant and voice, with or without a handler, and absent from autonomous rosters. They also pin that writes are auto-allowed only in a typed turn with a handler.github-write-availability.test.tscovers the Claude permission boundary. The SDK-options snapshot is re-recorded: the two names and the schema digest change in the four interactive modes, and nothing else moves.Mutation receipts. Each mutation was run against
github-write-tools.test.tsorgovernance-policy.test.ts, and the source was restored and checked byte-identical withcmp:if (false && !allowance)):GITHUB_OUTSIDE_LIST_REFUSED brain_github_issue_createfails, receiving"ok": true, along withGITHUB_NOT_ALLOWEDandGITHUB_NO_LIST_REFUSED(3 fail, 12 pass).|| edited):GITHUB_EDITED_REFUSED another repositoryfails.GITHUB_VOICE_REFUSED brain_github_issue_createfails.GITHUB_WRITES_MALFORMED_REFUSED: odysseusfails.bun run build,tsc --noEmitandbun run lintare clean.bun run api-reportchanges only the two new common exports and theoutward.githubtype.{"version":1,"kind":"brain-check-pr-receipt","head":"c8366a75d0f80c4511930b1a488759979c45b16c","base":"origin/main","mode":"focused","startedAt":"2026-11-16T00:58:14.246Z","finishedAt":"2026-11-16T00:59:43.864Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":12646.895675},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":106.37779999999839},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":69.4120780000012},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":19.319226999999955},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":76760.072913}]}Checklist
docs/integration-contract.md,mcp.md#github-writes-additive-0450-3798,cli.mdpolicy check,supported-inputs.md#governance-policy.)docs/reflect the change, or nothing documented moved.Proportionate-containment checklist (the allow-list and approval guard)
outward.github.repositories; a voice or surface-less turn; a declined, edited or stale approval; an unrecorded approval. It does not cover rawcurl/ghconnections (those keep theNetworkcard, ui-server, docs: prove the Network card for raw GitHub API connections and document the GitHub tools #3799) or G2 data routing (ui-server: apply provider-policy data routing (G2) to the host GitHub tools #4029).outward_actiongovernance event in the turn journal's irreversible list.github-write-tools.test.ts"a write outside the list is refused…" refusescirce/aiaiawhile the same host filesodysseus/ithaca.ws-github.test.tsrefuses one write and admits the next in the same turn.Anything left open
Candidate confirmation run 43781082783 (
unit (1)) failed ontests/installed-turn-surface.test.ts, which pins the installed CLI's brain-ui tool count: it expected 43 and got 45. That was this change, andc8366a75dfixes it: the count is now 45, both write names are checked, and the fixture'sSTABLE_BRIDGE_ROSTERlists them. Three experiment-tier turn-surface tests also fail onorigin/main849751e without this change; that is the existing test: turn-surface capture and overlap retain stale deferred core inventories #4003, which has no milestone.ui-server: apply provider-policy data routing (G2) to the host GitHub tools #4029 (
needs: decision): G2 provider-policy routing for the GitHub tools, the write tools included.ui-server, docs: prove the Network card for raw GitHub API connections and document the GitHub tools #3799: the raw-connection
Networkcard proof and the decision-record text.🤖 Generated with Claude Code