Repository navigation
CONTRACT: feat(ui-server): fetch allow-listed repositories for module cron jobs on the host - #4008
Merged
Merged
Conversation
… cron jobs on the host A module job runs in a maintenance worker that holds no Git credential, so a module that needs another repository, such as a private one with scripts it runs, could not reach it from cron (#3380). Per the maintainer's 2026-11-02 slice (b) rulings: - A module's config block declares the repositories it wants with a new core-owned `repositories` key, validated and stripped before the module's schema like `enabled`. `brain module list --json` reports it on each configured module, and `LoadedModule` gains the optional field. - The host grants only the intersection with the operator's allow-list, `BRAIN_UI_MODULE_REPOSITORIES`, read by the cron runner from host configuration and never forwarded to a job. An edit to brain.config.ts alone therefore cannot widen access. - Before each module job the runner runs a credential-free `brain module list --json` and maps the job to its module by its `<module>-<entry>` name and command. The crontab layout is unchanged. - The sync transport fetches each granted repository with the host's sync credential into a host-private bare mirror beside the sync mirror, never mounting the brain. The job's worker gets the mirror read-only and `url.file://<mirror>.insteadOf` rewrites, and never holds the credential. - A refused or failed fetch refuses the job before it starts: exit 1, with the repository and the setting named on stderr and in cron_runs. Contract: docs/integration-contract.md, the cli and package-api components, docs/modules.md and the hosting guide. The ruling is recorded in docs/decisions/governed-writable-workers.md. Moved citations follow their anchors. Refs #3380 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #3380 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 15, 2026
Closed
…ot brain A module job always runs `brain <command>`. A dashed job name running anything else is no module's job, so it now skips the module list and prints no note. Refs #3380 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 15, 2026
9 tasks done
7 tasks done
Closed
4 tasks
9 tasks done
This was referenced Nov 15, 2026
ui-server: a reference clone under workspaces/ counts toward files_changed and pauses the turn
#3793
Closed
Merged
8 of 9 tasks
9 tasks done
This was referenced Nov 15, 2026
Merged
schlessera
marked this pull request as ready for review
November 15, 2026 19:58
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 #3380
What changed
Slice (b) of #3380, on
main. Slice (a), the module state area and the boundary-naming read-only error (criteria 1 and 3), merged in #3384. This PR replaces draft #3393, which was stacked on #3384's branch. It carries #3393's commit onto currentmainand adds three commits.A module's cron job can now read another repository, including a private one, and its worker never holds a Git credential.
repositorieskey (modules: { "./modules/beacon": { repositories: ["https://github.com/ithaca/watchtower"] } }). Core validates the list and strips it before the module's schema sees it, as it does forenabled. Each URL must be HTTPS (or loopback HTTP) with no credential, query, fragment or dot segment, and a module may list at most 16.brain module list --jsonaddsrepositories: string[]to each configured module, andLoadedModulegains the optional field.BRAIN_UI_MODULE_REPOSITORIESallow-list. That list is host configuration: the runner reads it as a cron control variable, and it is never forwarded to a job. Editingbrain.config.tsalone cannot widen access.-), the runner runs a credential-free, shared-gatebrain module list --json. It matches the job by its<module>-<entry>name and itsbrain …command. The crontab layout is unchanged. That read is now CONTRACT: fix(ui-server): retry crontab module discovery, name its cause and record a skip #3382'sreadModuleList, so if the job cannot learn its module, its stderr says why. A dashed job name whose command is notbrain …is no module's job: it reads no module list and prints nothing. Hosted heavy feedback caught this on the first head, incron-bin.test.ts'sextra-envjob.syncTransportCommand) fetches each granted repository with the sync credential (BRAIN_UI_SYNC_GITHUB_TOKEN, elseGITHUB_TOKEN, sent only tohttps://github.com). It fetches into a host-private bare mirror beside the sync mirror, and the transport worker never mounts the brain.url.file://<mirror>.insteadOfrewrites for the URL's plain,/,.gitand.git/spellings. The module's owngit clone https://github.com/ithaca/watchtowertherefore reads the mirror with no credential and no network.cron_runs.error_messagename the repository and the setting.Why this shape
This follows the 2026-11-02 slice (b) rulings: grant option B, mapping option A. They are recorded in
docs/decisions/governed-writable-workers.md.@internalcredentialOrigininput, so the keyless fixture can require Basic auth on loopback. Production callers never set it, and no repository or brain input can.giterror. The refusal names the exact setting to change.Guard checklist (proportionate containment)
BRAIN_UI_MODULE_REPOSITORIES, or whose granted fetch fails. It does not cover a module job that asks for nothing, a core job, or a job whose module list cannot be read. That last job runs as before with no repository and a stderr note naming the cause.cron_runs.error_message, which/api/statuscronJobsshows, name the repository and the setting.a job no module owns, or a core job, fetches nothing and needs no module listanda refused repository fails the run…(packages/ui-server/tests/module-repositories.test.ts).Proof
Receipt head
4c3e4a4510e6e0eb230956bb009cc41dd165b110, which mergesorigin/main@2702e2bd. A second heavy-feedback request on the fixed head was cancelled by that refresh before admission; the native categories' evidence is the first run's. Heavy feedback run 43718462495 on the first heada42a98fapassed every category exceptunit (4). Its one failure wascron-bin.test.ts›run re-admits a generated wrapper extra…, where stderr carried a module-list note for the non-brainjobextra-env. The latest commit fixes that.{"version":1,"kind":"brain-check-pr-receipt","head":"4c3e4a4510e6e0eb230956bb009cc41dd165b110","base":"origin/main","mode":"focused","startedAt":"2026-11-15T18:59:55.436Z","finishedAt":"2026-11-15T19:01:44.749Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":12532.995780000001},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":105.84481500000038},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":70.1271369999995},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":27.112923000000592},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":96560.610548}]}New and changed tests:
packages/core/tests/module-repositories.test.ts(9):module list --jsonreports deduplicatedrepositories, and a strict module schema never sees the key.unavailablewithInvalid repositories for module "beacon".packages/ui-server/tests/module-repositories.test.ts(12, keyless and offline). A loopback smart-HTTP Git fixture requires Basic auth with a synthetic token. The tests run the transport's exact argv on the host with exactly the environmentmaintenanceLaunchgives its worker. They cover:brain.config.tsedit alone grants nothing;MODULE_LIST_CAUSE_NAMED, an unreadable module list names its cause and fetches nothing;NON_BRAIN_COMMAND_SKIPS_MODULE_LIST, a dashed job running a non-braincommand reads no module list.packages/ui-server/tests/host-execution-boundary.test.ts(+1, real worker). A cron run of the Odysseusbeaconmodule goes through the real boundary and fetches with the synthetic credential. The job clones from the mirror, and its dumpedprocess.envlacks the token. A laterbrain.config.tsedit addingithaca/treasuryis refused. This host cannot run maintenance workers (unshare: write failed /proc/self/uid_map: Operation not permitted). The test therefore fails here at the boundary, like every worker test in that file, and its execution is hosted native proof.Failing-first. #3393 recorded
packages/core/tests/module-repositories.test.tsfailing all 9 tests on the pre-change tree: the strict schema rejected the unstripped key. The ui-server tests import new modules, so their receipts are mutations.Mutation receipts. Each mutation was restored and the tree was clean afterwards. The first three were rerun on this branch; the rest are from #3393's head
960c23a6, whose code this PR carries unchanged.braincommand guard is removeda job no module owns, or a core job…→NON_BRAIN_COMMAND_SKIPS_MODULE_LIST(listed 2, expected 1)a module list that cannot be read names its cause…→MODULE_LIST_CAUSE_NAMEDGRANT_IS_INTERSECTION,UNLISTED_REPOSITORY_REFUSED(2 fail)Authentication failed; 3 tests failbrain.config.tsBRAIN_CONFIG_ALONE_GRANTS_NOTHING,BRAIN_CONFIG_EDIT_ALONE_REFUSED, the refused cron run testmaintenanceLaunchkeepsHOST_GIT_CREDENTIAL_ENVfor a non-transport workerJOB_WORKER_NEVER_HOLDS_CREDENTIALrunJobignores a refusala refused repository fails the run…→ expected exit1, received0Provider-history guard.
host-boundary.ts'scommand()is on a turn's path, but it adds nothing unless an execution carriesrepositories, and only a cron launch does. The guard needs the worker boundary, which this host lacks, so hosted CI must run it.Collisions (
bun scripts/collisions.ts --json --pr 4008, head68f4b89f): a textual overlap with draft #3806 ondocs/integration-contract.md(separate index sections); 12 closure-only. #3393 is closed in favour of this PR.Refreshed to head
d75a4cb6onorigin/main@2702e2bdby merge only; the merged commits touch none of this PR's files, so the receipt stands.Checklist
docs/reflect the change, or nothing documented moved.docs/decisions/provider-history.md): the provider-history guard passes, or nothing on a turn's path changed. (hosted)Anything left open
Nothing beyond the hosted native proof. The core job
hygiene-propagationhas a dashed name and runsbrain, so each of its runs pays the credential-free module-list read that ruling A accepts for module jobs. No module can own it, so it never fetches anything.🤖 Generated with Claude Code