Repository navigation
CONTRACT: feat(ui-server, ui-sdk): a host GitHub API relay for module cron jobs (#4259) - #4265
Conversation
… cron jobs (#4259) A module job granted a github.com repository reaches its API through a per-run Unix-socket relay bound read-only into its worker. The relay adds BRAIN_UI_MODULE_GITHUB_TOKEN (no fallback), relays granted REST reads and repository GraphQL queries, and writes only what BRAIN_UI_MODULE_GITHUB_WRITES enables per repository; each write is a github_write Activity event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ub relay (#4259) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 0527e27 against base 65883f2. Reviewer: agent. 5 findings: 0 fixed, 0 filed, 0 rejected, 5 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4265,
"head": "0527e2707f67852c4966d67f774aff38cafdfcb7",
"base": "65883f2d5332220db8a17fd1ddba0f926a1888be",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/github/module-relay.ts:96 blanks GraphQL comments with #[^\\n]*, but GraphQL also ends a comment at \\r. 'query Q { repository(owner:\"ithaca\",name:\"watchtower\") { id } } # x\\r mutation M { closeIssue(...) }' sent with operationName M (accepted unchecked at :193) passes graphqlQueryRepository (reproduced), and GitHub runs the mutation. The same trick adds a second root on an ungranted repository."
},
{
"summary": "packages/ui-server/src/github/module-relay.ts:96 ends a block string at the first triple quote even when it is backslash-escaped, which GraphQL keeps inside the string. A granted repository query with label(name: <block string holding an escaped triple quote>) and trailing text returns ithaca/watchtower (reproduced). GitHub parses that trailing text as a second root, repository(owner:\"sparta\",name:\"barracks\"), outside the grant."
},
{
"summary": "packages/ui-sdk/src/server/subprocess-env.ts:35 and :247 list BRAIN_UI_MODULE_GITHUB_TOKEN in neither HOST_ONLY_SECRET_ENV nor HOST_GIT_CREDENTIAL_ENV, unlike BRAIN_UI_GITHUB_TOOLS_TOKEN. Naming it in BRAIN_UI_SUBPROCESS_ENV_EXTRA admits it to cron childEnv, agent turns and workers, and no launcher strip removes it. The scope requires it stripped from every worker."
},
{
"summary": "packages/ui-server/tests/maintenance-module-github-relay.test.ts:54 and cron-module-github-relay.test.ts:56 cannot fail: no input env (childEnv {PATH} at :47, the launch env) ever holds BRAIN_UI_MODULE_GITHUB_TOKEN, so no stripping path runs, and removing the env.ts and emit.ts exclusions stays green. Nothing checks the worker's files or process arguments, which the criterion requires."
},
{
"summary": "packages/ui-server/src/github/module-relay.ts:216 refuses an operation outside the set (DELETE, a write with a query string, another issue path) as not_relayed without naming a setting, and graphql_not_allowed at :196 names none either. The criterion wants every out-of-grant refusal to name the setting, and DELETE_REFUSED in module-github-relay.test.ts:54 checks only the status."
}
]
} |
…y token host-only, name settings in refusals (#4259) The relay now relays only a strict GraphQL subset (no comments, block strings, escapes or carriage returns) and checks operationName against the one query. BRAIN_UI_MODULE_GITHUB_TOKEN joins the host-only secrets and the stripped host credentials. Every out-of-grant refusal names its setting. Tests now put the token in the inputs and check the worker's environ and cmdline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 0527e27 against base 65883f2. Reviewer: agent. 5 findings: 5 fixed, 0 filed, 0 rejected, 0 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4265,
"head": "0527e2707f67852c4966d67f774aff38cafdfcb7",
"base": "65883f2d5332220db8a17fd1ddba0f926a1888be",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/github/module-relay.ts:96 blanks GraphQL comments with #[^\\n]*, but GraphQL also ends a comment at \\r. 'query Q { repository(owner:\"ithaca\",name:\"watchtower\") { id } } # x\\r mutation M { closeIssue(...) }' sent with operationName M (accepted unchecked at :193) passes graphqlQueryRepository (reproduced), and GitHub runs the mutation. The same trick adds a second root on an ungranted repository.",
"disposition": "fixed",
"commit": "b718919a31231eae83fa8bed7e439b89ef7116d5"
},
{
"summary": "packages/ui-server/src/github/module-relay.ts:96 ends a block string at the first triple quote even when it is backslash-escaped, which GraphQL keeps inside the string. A granted repository query with label(name: <block string holding an escaped triple quote>) and trailing text returns ithaca/watchtower (reproduced). GitHub parses that trailing text as a second root, repository(owner:\"sparta\",name:\"barracks\"), outside the grant.",
"disposition": "fixed",
"commit": "b718919a31231eae83fa8bed7e439b89ef7116d5"
},
{
"summary": "packages/ui-sdk/src/server/subprocess-env.ts:35 and :247 list BRAIN_UI_MODULE_GITHUB_TOKEN in neither HOST_ONLY_SECRET_ENV nor HOST_GIT_CREDENTIAL_ENV, unlike BRAIN_UI_GITHUB_TOOLS_TOKEN. Naming it in BRAIN_UI_SUBPROCESS_ENV_EXTRA admits it to cron childEnv, agent turns and workers, and no launcher strip removes it. The scope requires it stripped from every worker.",
"disposition": "fixed",
"commit": "b718919a31231eae83fa8bed7e439b89ef7116d5"
},
{
"summary": "packages/ui-server/tests/maintenance-module-github-relay.test.ts:54 and cron-module-github-relay.test.ts:56 cannot fail: no input env (childEnv {PATH} at :47, the launch env) ever holds BRAIN_UI_MODULE_GITHUB_TOKEN, so no stripping path runs, and removing the env.ts and emit.ts exclusions stays green. Nothing checks the worker's files or process arguments, which the criterion requires.",
"disposition": "fixed",
"commit": "b718919a31231eae83fa8bed7e439b89ef7116d5"
},
{
"summary": "packages/ui-server/src/github/module-relay.ts:216 refuses an operation outside the set (DELETE, a write with a query string, another issue path) as not_relayed without naming a setting, and graphql_not_allowed at :196 names none either. The criterion wants every out-of-grant refusal to name the setting, and DELETE_REFUSED in module-github-relay.test.ts:54 checks only the status.",
"disposition": "fixed",
"commit": "b718919a31231eae83fa8bed7e439b89ef7116d5"
}
]
} |
Independent reviewReviewed head b718919 against base 65883f2. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4265,
"head": "b718919a31231eae83fa8bed7e439b89ef7116d5",
"base": "65883f2d5332220db8a17fd1ddba0f926a1888be",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/github/module-relay.ts:234 buffers the whole upstream body with arrayBuffer() before comparing it to MAX_MODULE_GITHUB_RESPONSE_BYTES, and :155 does the same for a chunked request with no content-length. A granted GET of a large blob (e.g. /repos/ithaca/watchtower/git/blobs/<sha>) or a large chunked body is held in full in the cron runner's memory, so the bounds the issue requires limit only what is relayed, not what the host reads."
},
{
"summary": "packages/ui-server/src/github/module-relay.ts:236 records a write only after the response body was read and passed the size check. When GitHub has already performed the POST/PATCH but reading its body fails or exceeds the cap (:234-235), the handler throws (502 upstream_unreachable or response_too_large) and no github_write event reaches the Activity run, although the issue requires each write to be recorded."
}
]
} |
… once GitHub answers (#4259) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head b718919 against base 65883f2. Reviewer: agent. 2 findings: 2 fixed, 0 filed, 0 rejected, 0 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4265,
"head": "b718919a31231eae83fa8bed7e439b89ef7116d5",
"base": "65883f2d5332220db8a17fd1ddba0f926a1888be",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/github/module-relay.ts:234 buffers the whole upstream body with arrayBuffer() before comparing it to MAX_MODULE_GITHUB_RESPONSE_BYTES, and :155 does the same for a chunked request with no content-length. A granted GET of a large blob (e.g. /repos/ithaca/watchtower/git/blobs/<sha>) or a large chunked body is held in full in the cron runner's memory, so the bounds the issue requires limit only what is relayed, not what the host reads.",
"disposition": "fixed",
"commit": "4d058d61d61107d44e6a9512a9558223e8042fc5"
},
{
"summary": "packages/ui-server/src/github/module-relay.ts:236 records a write only after the response body was read and passed the size check. When GitHub has already performed the POST/PATCH but reading its body fails or exceeds the cap (:234-235), the handler throws (502 upstream_unreachable or response_too_large) and no github_write event reaches the Activity run, although the issue requires each write to be recorded.",
"disposition": "fixed",
"commit": "4d058d61d61107d44e6a9512a9558223e8042fc5"
}
]
} |
…over /etc/environment in every worker (#4259) Below the granted repository root, fields that reach another repository, owner or account are refused. A container's /etc/environment carries the cron runner's credentials for pam_env; every host-view worker now covers it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 4d058d6 against base 65883f2. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4265,
"head": "4d058d61d61107d44e6a9512a9558223e8042fc5",
"base": "65883f2d5332220db8a17fd1ddba0f926a1888be",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/github/module-relay.ts:132 checks only the GraphQL root field. A query rooted at a granted repository can nest owner { repository(name: \"barracks\") { issues { nodes { title } } } } (or owner.repositories, forks, parent) and read a repository outside the grant with the shared host token. The ruling limits reads to the granted repositories, so a job reads repositories granted only to another module. No test covers nested reach."
},
{
"summary": "packages/ui-server/src/cron/emit.ts:323 adds BRAIN_UI_MODULE_GITHUB_TOKEN to CRON_CONTROL_ENV_NAMES, so brain-ui-cron environment writes it into /etc/environment. A maintenance worker ro-binds / (ui-sdk worker-launcher.ts:668) and never masks /etc/environment, so a credential-free module job can read the token from a file, which the criterion forbids. maintenance-module-github-relay.test.ts never reads /etc/environment."
}
]
} |
Independent reviewReviewed head 4d058d6 against base 65883f2. Reviewer: agent. 2 findings: 2 fixed, 0 filed, 0 rejected, 0 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4265,
"head": "4d058d61d61107d44e6a9512a9558223e8042fc5",
"base": "65883f2d5332220db8a17fd1ddba0f926a1888be",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/github/module-relay.ts:132 checks only the GraphQL root field. A query rooted at a granted repository can nest owner { repository(name: \"barracks\") { issues { nodes { title } } } } (or owner.repositories, forks, parent) and read a repository outside the grant with the shared host token. The ruling limits reads to the granted repositories, so a job reads repositories granted only to another module. No test covers nested reach.",
"disposition": "fixed",
"commit": "7b8eccffd206e6661f8e1ad8bd48c5ede9bc5ff6"
},
{
"summary": "packages/ui-server/src/cron/emit.ts:323 adds BRAIN_UI_MODULE_GITHUB_TOKEN to CRON_CONTROL_ENV_NAMES, so brain-ui-cron environment writes it into /etc/environment. A maintenance worker ro-binds / (ui-sdk worker-launcher.ts:668) and never masks /etc/environment, so a credential-free module job can read the token from a file, which the criterion forbids. maintenance-module-github-relay.test.ts never reads /etc/environment.",
"disposition": "fixed",
"commit": "7b8eccffd206e6661f8e1ad8bd48c5ede9bc5ff6"
}
]
} |
…readable covered file Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 4922acc against base 65883f2. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4265,
"head": "4922accd5517c55e34611c773884d8a2b7852b65",
"base": "65883f2d5332220db8a17fd1ddba0f926a1888be",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/github/module-relay.ts:135/:159 blocks cross-repository traversal by field name, but the list misses author { ... on User { issues / pullRequests / gists / organizations } }, pullRequests { nodes { headRepository } } and CrossReferencedEvent source { ... on Issue { body } }. graphqlQueryRepository accepts each as ithaca/watchtower (reproduced), so a job reads other repositories' issues through the relay, contrary to docs/decisions/governed-writable-workers.md."
}
]
} |
…e more repository-selecting fields (#4259) The field denylist refuses fields that select another repository, owner or account by name; deeper traversal is bounded by the token's scope, which the docs now require the operator to limit to the granted repositories. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 4922acc against base 65883f2. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4265,
"head": "4922accd5517c55e34611c773884d8a2b7852b65",
"base": "65883f2d5332220db8a17fd1ddba0f926a1888be",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/github/module-relay.ts:135/:159 blocks cross-repository traversal by field name, but the list misses author { ... on User { issues / pullRequests / gists / organizations } }, pullRequests { nodes { headRepository } } and CrossReferencedEvent source { ... on Issue { body } }. graphqlQueryRepository accepts each as ithaca/watchtower (reproduced), so a job reads other repositories' issues through the relay, contrary to docs/decisions/governed-writable-workers.md.",
"disposition": "fixed",
"commit": "000c1811bd10da9ed890f81c79f9c322b41fb010"
}
]
} |
Independent reviewReviewed head 000c181 against base 65883f2. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4265,
"head": "000c1811bd10da9ed890f81c79f9c322b41fb010",
"base": "65883f2d5332220db8a17fd1ddba0f926a1888be",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/github/module-relay.ts:135 and :160 forward a query rooted at a granted repository that reaches other repositories: issues{nodes{author{... on User{issues(first:50){nodes{title body}}}}}} and a CrossReferencedEvent source{... on Issue{body}} both return ithaca/watchtower. The fix is a token limited to granted repositories (env.ts:211), but one host token covers all modules, so job A reads repositories granted only to module B."
},
{
"summary": "packages/ui-server/src/github/module-relay.ts:160 puts \"node\" and \"topic\" in CROSS_REPOSITORY_FIELDS, so a granted query in the standard connection form, repository(owner:\"ithaca\",name:\"watchtower\"){issues(first:5){edges{node{number}}}}, returns null and is refused as graphql_not_allowed. Neither field selects another repository or owner by name, so the relay refuses in-grant reads that docs/modules.md says are allowed."
}
]
} |
… token-scope ruling (#4259) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 000c181 against base 65883f2. Reviewer: agent. 2 findings: 1 fixed, 0 filed, 1 rejected, 0 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4265,
"head": "000c1811bd10da9ed890f81c79f9c322b41fb010",
"base": "65883f2d5332220db8a17fd1ddba0f926a1888be",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/github/module-relay.ts:135 and :160 forward a query rooted at a granted repository that reaches other repositories: issues{nodes{author{... on User{issues(first:50){nodes{title body}}}}}} and a CrossReferencedEvent source{... on Issue{body}} both return ithaca/watchtower. The fix is a token limited to granted repositories (env.ts:211), but one host token covers all modules, so job A reads repositories granted only to module B.",
"disposition": "rejected",
"reason": "Maintainer ruling 2026-11-20 on #4259: below the granted root the shared token's scope is the read boundary; docs now require the token limited to the union of module grants."
},
{
"summary": "packages/ui-server/src/github/module-relay.ts:160 puts \"node\" and \"topic\" in CROSS_REPOSITORY_FIELDS, so a granted query in the standard connection form, repository(owner:\"ithaca\",name:\"watchtower\"){issues(first:5){edges{node{number}}}}, returns null and is refused as graphql_not_allowed. Neither field selects another repository or owner by name, so the relay refuses in-grant reads that docs/modules.md says are allowed.",
"disposition": "fixed",
"commit": "8b4771e7a8aae825d98dec242fc967995130cdee"
}
]
} |
Independent reviewReviewed head 6b3296c against base 65883f2. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition. |
Independent reviewReviewed head 6b3296c against base 65883f2. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition. |
Independent reviewReviewed head 5532661 against base 65883f2. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition. |
Independent reviewReviewed head 5532661 against base 65883f2. Reviewer: agent. 2 findings: 2 fixed, 0 filed, 0 rejected, 0 without a disposition. |
Independent reviewReviewed head 3886c6d against base 65883f2. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4265,
"head": "3886c6d4b6b6d72a0c4f980e671cd247c1eab404",
"base": "65883f2d5332220db8a17fd1ddba0f926a1888be",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/tests/module-github-relay.test.ts:73 cannot fail: fetch normalizes /repos/ithaca/watchtower/../../sparta/barracks to /repos/sparta/barracks before sending, so it is refused as repository_not_granted. The dot-segment guard it claims to cover (module-relay.ts:258) cannot be reached either, since new URL(request.url) at :255 already removed the segments. Deleting that guard leaves the test green, and the assertion is only not.toBe(200)."
}
]
} |
…efuses empty segments (#4259) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 3886c6d against base 65883f2. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition. |
Independent reviewReviewed head c3b47ec against base 65883f2. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4265,
"head": "c3b47ec872e96a26cee4136665ee209de27f70d2",
"base": "65883f2d5332220db8a17fd1ddba0f926a1888be",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "docs/integration-contract/package-api.md:1045 records the relay's 503 refusals as `unavailable` (no token) and `relay_busy` only. 3886c6d4b added a third, 503 `relay_stopped` for a call arriving after the run ended (packages/ui-server/src/github/module-relay.ts:324), and it ships without its contract record, the same gap the cfc2226 review found and fixed for relay_busy."
},
{
"summary": "packages/ui-server/tests/module-github-relay.test.ts:201 is titled 'stopping lets a write in flight finish and be recorded, and takes no new call' but never sends a call after stop(), so deleting the stopping guard at packages/ui-server/src/github/module-relay.ts:324 (relay_stopped) leaves every test green. No test proves that a call arriving while the relay settles is refused."
}
]
} |
Independent reviewReviewed head c3b47ec against base 65883f2. Reviewer: agent. 2 findings: 2 fixed, 0 filed, 0 rejected, 0 without a disposition. |
Independent reviewReviewed head 68ded67 against base 65883f2. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition. |
…4259) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 68ded67 against base 65883f2. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition. |
Independent reviewReviewed head 7e98e6a against base 65883f2. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4265,
"head": "7e98e6a32572d789a908d2f87ecad8bea34a379b",
"base": "65883f2d5332220db8a17fd1ddba0f926a1888be",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "docs/modules.md:192 says a redirect is refused before any request leaves the host. It is not: module-relay.ts:321 refuses a redirect (502 redirect) only after the request was sent and GitHub answered, and the other 502 refusals (response_too_large, upstream_unreachable) also come after sending. The doc misstates when the guard acts, though the contract text in package-api.md describes it correctly as never following a redirect."
}
]
} |
…owed (#4259) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 7e98e6a against base 65883f2. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition. |
Independent reviewReviewed head dd3faa4 against base 65883f2. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition. |
…ed (#4259) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head dd3faa4 against base 65883f2. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition. |
Independent reviewReviewed head 43142ab against base 65883f2. Reviewer: agent. 2 findings: 0 fixed, 0 filed, 0 rejected, 2 without a disposition. |
…st-fallback limit of the relay token (#4259) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 43142ab against base 65883f2. Reviewer: agent. 2 findings: 1 fixed, 0 filed, 1 rejected, 0 without a disposition. |
Independent reviewReviewed head 6086ef6 against base 65883f2. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition. |
Independent reviewReviewed head 6086ef6 against base 65883f2. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 1 rejected, 0 without a disposition. |
Closes #4259
What changes
A module cron job granted a
github.comrepository now reaches its GitHub API through a host relay. Granted means listed in the module'srepositoriesand inBRAIN_UI_MODULE_REPOSITORIES, the same grant as the #3380 read mirror. The job's worker never holds a token.packages/ui-server/src/github/module-relay.ts): a per-run Unix socket in a private server-owned directory.https://api.github.comwithBRAIN_UI_MODULE_GITHUB_TOKENand no fallback, and never follows a redirect.GET /repos/<owner>/<repo>/…for a granted repository, and GraphQL queries whose only root field isrepository(owner:, name:)on a granted repository. Mutations, other roots, aliases, spreads and second operations are refused. Only a strict subset is relayed: no comments, block strings, escapes or carriage returns, so the relay and GitHub's parser cannot disagree on token boundaries.operationNamemust name the one query. Below the root, fields that select another repository, owner or account by name (owner,repositories,forks,parent,headRepository,search,viewerand the like) are refused. Deeper traversal (an author's other issues, a cross-referencing issue) is bounded by the token's own scope, as the REST timeline is. By the maintainer's 2026-11-20 ruling, the token's scope is the read boundary there, and the docs require the one shared token to be limited to the union of module grants.issue_commentandissue_state, each only whereBRAIN_UI_MODULE_GITHUB_WRITESenables it for that repository (https://github.com/<owner>/<repo>#<operation>). Bodies are strictly shaped.relay_busybefore anything is read). A write is recorded as soon as GitHub answers, even if its response is then refused.{ message, brain_relay_refusal }naming the setting.ui-sdk): the maintenance envelope gainsgithubRelay. The directory is bound read-only at/run/brain-githubafter the same private-directory and socket-ownership checks the provider relay uses, andBRAIN_MODULE_GITHUB_SOCKETis set. It holds no credential, so a credential-free worker may get it.github_writeevent on the job's Activity root span and a line in the run's output, and stops the relay when the run ends, after letting calls in flight finish for up to 10 s so their writes are recorded.BRAIN_UI_MODULE_GITHUB_TOKENjoinsHOST_ONLY_SECRET_ENV, so no escape hatch or spawn can admit it, andHOST_GIT_CREDENTIAL_ENV, so it is stripped from every worker./etc/environment: every host-view worker, agent and maintenance alike, now covers it. A container writes the cron runner's environment there for pam_env, and before this PR that already exposedGITHUB_TOKENand the sync token to workers; this PR's token would have joined them.BRAIN_UI_MODULE_GITHUB_WRITESare named in the run's output, never dropped silently.BRAIN_UI_MODULE_GITHUB_TOKENandBRAIN_UI_MODULE_GITHUB_WRITESare declared, read by the cron runner only (cron control env), and never forwarded to a job.docs/modules.md, the hosting worker reference, the contract index and the package API component (#module-github-relay), the decision record, and the env table.Deviation from the issue's wording: the ruling said "a per-run loopback endpoint and a per-run bearer". A maintenance worker has its own network namespace with no route to the host's loopback, so the relay is a per-run Unix socket in a private directory bound only into that run's worker, like the provider relay (#1673). Access is that socket's reach, so no separate bearer is needed. The issue is updated to match.
Contract: additive. The relay protocol, the worker socket variable and the two host settings are recorded in
docs/integration-contract/package-api.md#module-github-relayand the index, and the commit is prefixedCONTRACT:. Changesets: ui-server minor, ui-sdk minor.Guard checklist (proportionate containment)
/etc/environmentis covered in every host-view worker./etc/environmentcover hides one file that no worker reads.BRAIN_UI_MODULE_GITHUB_TOKEN,BRAIN_UI_MODULE_REPOSITORIESorBRAIN_UI_MODULE_GITHUB_WRITES. Only the operator can widen a grant, by design.github_writeevents on the job's Activity run, recorded even when the answer is lost or the relay stops first.module-github-relay.test.tsshows that a refused call leaves the relay serving the next one (BOUND_FREES_AFTER_FINISH, and the granted reads after foreign refusals).cron-module-github-relay.test.tsshows that a job without a GitHub grant runs normally with no relay.Validation
tests/module-github-relay.test.ts(9 tests, loopback GitHub stand-in): granted reads forwarded with the host token only; foreign repository and other paths refused with nothing forwarded; GraphQL query forwarded while mutation, other root, alias, second root, foreign variables and an extra mutation operation are refused; no token refuses and names the setting, with no fallback fromGITHUB_TOKEN, the sync token or the tools token; redirect refused; call budget; un-enabled write refused naming the setting; enabled writes forwarded and recorded; malformed write bodies refused; operator-list parsing.tests/cron-module-github-relay.test.ts: throughrunJob, a job granted a GitHub repository reaches the relay and its write lands on the Activity run, the token is not in the job's environment, and the relay directory is gone after the run. A job without a GitHub grant gets no relay.tests/maintenance-module-github-relay.test.ts(native): a real maintenance worker, launched with the cron runner's own module-job class (cronJobClass, credentialed), sees/run/brain-github/github.sockand reaches the stand-in through it with the host token. Its environment,/proc/self/environ,cmdlineand/etc/environmenthold no relay token, even when the launch env carried one. This host lacks user namespaces, so hosted CI proves it.FOREIGN_REPOSITORY_REFUSED.GRAPHQL_REFUSED: mutation ….RELAY_ENDS_WITH_RUN.UNANSWERED_WRITE_RECORDED_AT_STOP.DOUBLE_SLASH_REFUSED.GRAPHQL_REFUSED,COMMENT_REFUSED).operationNamecheck failsOPERATION_NAME_MISMATCH_REFUSED.MODULE_GITHUB_TOKEN_EXTRA_REFUSED.SDK_MAINTENANCE_MODULE_GITHUB_TOKEN_ABSENT.ANSWERED_WRITE_RECORDED.OVERSIZED_RESPONSE_REFUSEDandCHUNKED_REQUEST_BOUNDED.GRAPHQL_REFUSED: … owner { repository(name: "barracks") … }./etc/environmentin agent or maintenance workers failsETC_ENVIRONMENT_COVERED. The native test also reads the file inside a real worker.bun run typecheckpasses.Collisions
bun scripts/collisions.ts --json --pr 4265at head7f974c427: closure-only overlaps with #3054, #3056, #3059, #3069, #3581, #4151, #4270, #4273, #4312, #4314. No path collisions.Refreshed by a clean merge of
origin/main, which includes #4266. Thecheck:prreceipt below is from the last real change,6086ef669, and the recorded review covers that head plus this clean merge.{"version":1,"kind":"brain-check-pr-receipt","head":"6086ef6698805a91c4426955fb589bdafb7958ac","base":"origin/main","mode":"focused","startedAt":"2026-11-20T19:03:06.477Z","finishedAt":"2026-11-20T19:04:23.695Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":14045.248717999999},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":108.1235749999978},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":74.51328300000023},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":21.31738100000075},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":62951.393093000006}]}🤖 Generated with Claude Code