Skip to content

ui-server: a scheduled module job has no governed GitHub API access to its granted repositories #4259

Closed

Description

@schlessera

Context

A module's scheduled job runs in a maintenance worker that holds no Git or
GitHub credential (HOST_GIT_CREDENTIAL_ENV,
packages/ui-sdk/src/server/subprocess-env.ts:247). #3380 (through #4008)
added a read path for Git content only: a module asks for a repository with the
core-owned repositories key, the operator allow-lists it in
BRAIN_UI_MODULE_REPOSITORIES, and the host fetches a mirror the worker can
clone (grantModuleRepositories and moduleRepositoryWorkerAccess,
packages/ui-server/src/brain/module-repositories.ts:67-113;
docs/modules.md).

A scheduled job that must talk to the GitHub API of an allow-listed
repository has no supported path. A repository "heartbeat" is one example: a
module job that, every 30 minutes, reads the repository's recently closed
issues (REST and GraphQL), comments on an issue closed without a reason, and
reopens it. Telemachus's ithaca/watchtower would run that check. With no
credential, every API call fails, and the job either cannot run or needs a
token injected into the worker, which the governed-worker rules forbid.

The hosted chat already solved the same problem for turns with fixed host
tools that hold the credential (#3791, BRAIN_UI_GITHUB_TOOLS_TOKEN, a
policy allow-list for writes and owner approval). Those cannot serve a module
job as they stand: a scheduled job has no owner to approve a card, and its
operations are not the four chat tools.

Scope

Per the 2026-11-20 maintainer ruling (option 1: a host GitHub API relay for
module jobs
):

  • Grant. A job gets the relay only for the repositories the mirror path
    already grants it (its module's repositories ∩ BRAIN_UI_MODULE_REPOSITORIES).
    The worker receives a per-run Unix socket, bound read-only from a private
    server-owned directory into that run's worker only, never a GitHub token.
  • Credential. A new host-only variable, BRAIN_UI_MODULE_GITHUB_TOKEN
    (final name in the PR), with no fallback to GITHUB_TOKEN, the sync
    credential or BRAIN_UI_GITHUB_TOOLS_TOKEN. It is stripped from every
    worker. Without it, the relay refuses every call, naming the setting.
  • Reads. REST GET under /repos/<owner>/<repo>/… for a granted
    repository. GraphQL queries only (no mutations or subscriptions) whose
    single root field is repository(owner:, name:) naming a granted
    repository. Anything else is refused before a request leaves the host.
  • Writes. A fixed set of operations, each enabled per repository by an
    operator allow-list in host configuration (for example
    BRAIN_UI_MODULE_GITHUB_WRITES, final name in the PR), so editing
    brain.config.ts cannot widen it. The first set is issue_comment
    (POST /repos/<r>/issues/<n>/comments, body only) and issue_state
    (PATCH /repos/<r>/issues/<n> with only state/state_reason).
    Any other method, path or field is refused.
  • Bounds and record. Request and response sizes and a per-run call budget
    are bounded. Each write is recorded on the job's Activity run with its
    repository, operation and target number, never the token.

Out of scope

Acceptance criteria

  • A module job granted https://github.com/ithaca/watchtower can read its
    issues and post an issue comment through the host, and a test against a
    loopback GitHub stand-in proves both. No credential appears in the worker's
    environment, files or process arguments, and a test asserts that.
  • A call to a repository or operation outside the grant is refused before any
    request leaves the host, with a message that names the setting. A test covers
    each.
  • A GraphQL mutation, a query rooted outside a granted repository, and a
    write operation the operator list does not enable are each refused without
    a request, and a test covers each.
  • The relay without BRAIN_UI_MODULE_GITHUB_TOKEN refuses every call, and
    the token is never read from any other variable, proven by a test.
  • docs/modules.md and the environment reference describe the grant, the
    allowed operations and the credential.

Verification

Integration tests with a loopback GitHub stand-in. No network and no real
token.

Contract impact

Additive: a new module-job capability, its host configuration and its
documented operations.

2026-11-20: Scoped by the maintainer ruling (option 1) recorded in the comment below.

2026-11-20: The relay endpoint is a per-run Unix socket rather than a loopback port with a bearer: maintenance workers have no route to the host's loopback.

Activity

  1. added
    type: featA new capability or a change in user-visible behaviour.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    priority: p2Wanted, not scheduled. Pulled in when a milestone has room.
    needs: decisionBlocked on a maintainer or designer ruling, not on code.
    area: modulesFirst-party content modules and the module seam.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    contractTouches the integration contract: CONTRACT: commit, contract doc updated in the same commit.
    and removed
    needs: decisionBlocked on a maintainer or designer ruling, not on code.
    on Nov 20, 2026
  2. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-20): option 1, a host GitHub API relay for module jobs. The grant follows the existing mirror grant. A dedicated host-only credential with no fallback is never placed in a worker. Reads are limited to the granted repositories (REST GET, and GraphQL queries rooted at a granted repository). Writes are a fixed operation set (issue_comment, issue_state) enabled per repository by an operator allow-list in host configuration. Options 2 (a token in the worker) and 3 (no kit support) were not taken. The body now carries the scope and acceptance criteria.

  3. self-assigned this
    on Nov 20, 2026
  4. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-cc55e738. Branch: feat/4259-module-github-relay.

    No path collisions expected; new relay beside the provider relay.

  5. added this to the 0.45.0 milestone on Nov 20, 2026
  6. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    2026-11-20 implementation note: a maintenance worker has its own network namespace with no route to the host's loopback. The relay is therefore a per-run Unix socket in a private server-owned directory, bound read-only only into that run's worker, like the CLI provider relay (#1673). The socket's reach replaces the "per-run bearer" in the scope. Everything else in the ruling is unchanged. Implementation: #4265.

  7. 12 remaining items

  8. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    Delivered by #4265, squash 134c0eee935f1c88ddbef5f1f59aee8b2363fe3a, milestone 0.45.0 (rulings 2026-11-20: host relay; the token's scope bounds reads below the granted root).

    A module cron job granted a github.com repository reaches its API through a per-run Unix-socket relay (BRAIN_MODULE_GITHUB_SOCKET).

    • Credential: the relay holds BRAIN_UI_MODULE_GITHUB_TOKEN, which has no fallback, is host-only and is stripped from every worker. /etc/environment is now covered in every host-view worker.
    • Reads: REST GET under a granted repository, and strict-subset GraphQL queries rooted at a granted repository.
    • Writes: issue_comment and issue_state, only where BRAIN_UI_MODULE_GITHUB_WRITES enables them.
    • Refusals and bounds: every refusal names its setting. Sizes, calls and calls in flight are bounded. Each write is recorded on the run's Activity and output, even when GitHub's answer is lost.
    • Proof: unit, runner and native worker tests with mutation receipts, and recorded fresh-context reviews whose findings were all answered. Automatic main proof for the squash was pending at merge.

    A module needs no kit helper: send ordinary GitHub API requests to the socket (see docs/modules.md).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: modulesFirst-party content modules and the module seam.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.contractTouches the integration contract: CONTRACT: commit, contract doc updated in the same commit.priority: p2Wanted, not scheduled. Pulled in when a milestone has room.type: featA new capability or a change in user-visible behaviour.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions