Repository navigation
Description
Context
A module job runs from the generated crontab (brain-ui-cron run <module>-<job> -- brain <command>). Like every repository job, it runs inside a maintenance worker while the host execution boundary holds. That worker gives a module two things it may need and cannot have.
1. No durable state outside the brain. Inside the worker the host data directory, the app home and the brain are all read-only. Writes go to the private output stage (BRAIN_WORKER_DATA_ROOT/BRAIN_ROOT = /tmp/brain-maintenance-output), and only what lands under the brain's own paths is published back. XDG_STATE_HOME is a per-run tmp directory (MAINTENANCE_XDG_DIRS, packages/ui-sdk/src/server/worker-launcher.ts:157). A module that keeps operational state in a host directory, as the module config allowed before 0.44.0, now fails on its first mkdir with EROFS: read-only file system. The only durable place left is a gitignored path inside the brain. That works, but it goes through output staging and publication on every run, and core neither names nor documents such a place for modules (packages/core/src/lib/module-loader.ts:65 declares cron with no state contract).
2. No credential for another repository. Module jobs are credentialed and exclusive (cronJobClass, packages/ui-server/src/brain/host-boundary.ts:150-156). In practice that means the model OAuth token and the provider relay. GITHUB_TOKEN and the other HOST_GIT_CREDENTIAL_ENV names (packages/ui-sdk/src/server/subprocess-env.ts:227-231) are kept from the worker, and no git credential helper is configured inside it. Only sync reaches GitHub, through the host mirror transport. So a module that has to clone or fetch a private repository other than the brain cannot do it from cron at all.
Example: the Odysseus brain declares a local module ./modules/beacon whose run job, every 30 minutes, refreshes a shallow clone of the private ithaca/watchtower repository and runs that repo's scripts/beacon.ts, keeping per-check "last ran" state between runs. On 0.43.x this worked with the clone and state in a host directory and GITHUB_TOKEN in the environment. On 0.44.0 every run fails. Remove the EROFS and the clone still fails (git ls-remote on the private repo fails without a credential).
Scope
Decide, and then document, how a module's cron job:
- keeps small durable state between runs (a named per-module state area, or a documented "use
<brain>/.brain-ui/modules/<name>/and expect publication" rule); and - gets a scoped, non-brain repository credential when its configuration declares one. One possible shape is a host-transported fetch like the sync mirror, keyed by a repository allow-list in module config. That needs a decision; this issue does not presume it.
Out of scope
- Restoring host-directory writes or forwarding generic
GITHUB_TOKENinto maintenance workers. - The
synctransport itself.
Acceptance criteria
- The integration contract states where a module job may keep durable state, and a test shows state written by one cron run is readable by the next.
- Either a module job can authenticate to a configured private repository through a scoped route, proven by a fixture with a synthetic credential and helper, or the limitation is documented as a decision with the supported alternative.
- A module job that hits a read-only host path fails with a message that names the boundary, not a bare
EROFS.
Verification
Use a fictional local module and a fixture git server or helper. No real credentials.
Contract impact
Yes: module cron state and credential rules become part of the module contract.
Activity
schlessera commentedon Nov 2, 2026
Decision (maintainer, 2026-11-02):
<brain>/.brain-ui/modules/<name>/, exact path to be fixed in the contract). It is part of the module contract and is published through output staging on each run. A test proves that state written by one cron run is readable by the next.GITHUB_TOKENor a generic credential. Prove it with a fixture git server and a synthetic credential and helper.Both are additive module-contract changes (
CONTRACT:prefix, contract docs updated in the same commit). The existing out-of-scope items stand: no host-directory writes, and no genericGITHUB_TOKENforwarding into maintenance workers. A read-only host path must fail with a message naming the boundary.schlessera commentedon Nov 2, 2026
Claimed (token
wi-3380-c7e1), branchfix/3380-module-cron-state. Plan per the 2026-11-02 ruling, in slices: (a) the named per-module state area and a boundary-naming read-only error, then (b) the host-performed scoped fetch for allow-listed repositories. Collision report: path overlap with #3335 onpackages/ui-server/src/brain/host-boundary.ts; the rest is closure-only. Staying out of #3381's scope (cron module discovery retry).schlessera commentedon Nov 2, 2026
Slice (a) delivered for review in #3384 (state area,
ctx.stateDir(), boundary-naming read-only errors; acceptance criteria 1 and 3). It usesRefs, so this issue stays open for ruling point 2.Slice (b), the host-performed scoped fetch, needs two rulings the 2026-11-02 decision does not settle. Everything else in (b) follows the sync mirror. That means a host-private bare mirror per allow-listed repository beside the sync mirror, refreshed by a separate transport worker that holds the host credential and never mounts the brain. The job's worker gets the mirror read-only, plus
url.file://<mirror>.insteadOf <url>, so the module's owngit clone https://github.com/ithaca/watchtowerreads the mirror without any credential.Question 1: who may grant a repository? "Declared in module config" means
brain.config.ts, which is Tier B: protected by default, but a governance policy may release it. Once released, a governed turn could add any repository the host token can read, for example a privateithaca/treasury. The next cron run would then fetch it into the brain, where turns can read it.modules: { "./modules/beacon": { repositories: ["https://github.com/ithaca/watchtower"] } }, stripped before the module's schema likeenabled. Authority equalsbrain.config.ts's protection. Simplest, and matches the ruling's wording.Recommendation: B. It keeps the ruling's shape, and a released config cannot turn the host token into a read of every private repository that token can reach.
Question 2: how does the runner learn a job's module and allow-list at run time? A job is named
<module>-<entry>, and both module and entry names may contain-, so the name alone is ambiguous.brain module list --jsonin a maintenance worker (shared gate) and match the job by name and command.module list --jsongains an additiverepositoriesfield. This costs one extra short worker per module run, and leaves the crontab untouched.brain-ui-cron run <job> --module <name> -- …). This touchesemit.tsandbrain-ui-cron.ts, which overlaps ui-server: a transient module discovery failure at cron start silently drops every module job until the next restart #3381's scope, and the allow-list would still have to be read at run time.Recommendation: A. It needs no crontab change and avoids colliding with #3381.
Credential scope assumed in both cases: the host's existing GitHub credential (
BRAIN_UI_SYNC_GITHUB_TOKEN, falling back toGITHUB_TOKEN), sent only tohttps://github.comexactly assyncTransportCommanddoes. The proof would use a loopback smart-HTTP fixture that requires Basic auth with a synthetic token, reached through an@internalhost-side origin override that no repository input can set. Please say if a different credential or host scope is intended.Completion evidence to resume: a maintainer comment choosing an option for each question.
2 remaining items
schlessera commentedon Nov 2, 2026
Decision (maintainer, 2026-11-02), slice (b):
brain.config.tstherefore cannot widen access by itself.brain module list --jsonwith an additiverepositoriesfield to map the job to its module. The crontab layout, owned by ui-server: a transient module discovery failure at cron start silently drops every module job until the next restart #3381, is unchanged.Both changes are additive contract changes. Slice (a) is in #3384.
schlessera commentedon Nov 2, 2026
Claimed slice (b) (token
wi-3380-b4d2), branchfix/3380-module-repositories, stacked on #3384's branch (fix/3380-module-cron-state, head4a743c56) as an ordinary PR because nativegh stackis not installed here. Plan per the 2026-11-02 slice (b) ruling: module-configrepositoriesintersected with an operator host allow-list, host-performed scoped mirror fetch with the host credential, job-to-module mapping via credential-freebrain module list --json. Crontab layout (#3381) unchanged.CONTRACT: feat(ui-server): fetch allow-listed repositories for module…
schlessera commentedon Nov 2, 2026
Handoff (claim
wi-3380-b4d2): slice (b) is draft #3393, head960c23a6, stacked on #3384 (basefix/3380-module-cron-state@4a743c56). Local preflight against that parent passed (1050 pass, 0 fail), and the PR body has the failing-first and mutation receipts. Hosted native proof is still needed: the real-worker cron test,sync-mirrorand the provider-history guard cannot run on a host without user namespaces. To resume: land #3384 first (bun scripts/integrate.ts confirm 3384 --issues schlessera/brain-kit#3380). Then either retarget #3393 tomain(rebase ontoorigin/main, rerunbun run check:pr --base origin/main) and runbun scripts/integrate.ts confirm 3393 --issues schlessera/brain-kit#3380, or merge both through the stack procedure. #3380 closes once both layers are onmain. Releasing the assignment.CONTRACT: feat(core): give each module a durable state area and name …
schlessera commentedon Nov 15, 2026
Claimed for implementation. Claim token:
claim-bd9fbeb3. Branch:fix/3380-module-repositories-main.Resuming slice (b) from draft #3393 (its commit onto current main); path collision only with #3393 itself, which this replaces.
fix(ui-server): read no module list for a scheduled command that is n…
CONTRACT: feat(ui-server): fetch allow-listed repositories for module…
schlessera commentedon Nov 15, 2026
Delivered. Slice (b) merged in #4008 as
e1ce188d79dd47c88a4478359d38277098444a21(candidate run 43755383702). Slice (a) is #3384 (6f1d7d93), so all three acceptance criteria are onmain:BRAIN_UI_MODULE_REPOSITORIESalso allows. The host fetches it with its sync credential into a private mirror, and the job's worker reads the mirror through a Git URL rewrite without ever holding the credential. Proven with a loopback Git fixture, a synthetic token and a real-worker cron test (CONTRACT: feat(ui-server): fetch allow-listed repositories for module cron jobs on the host #4008).#4008 replaced the earlier stacked draft #3393, now closed. It also reuses #3382's module-list reader, so a job that cannot learn its module says why. Heavy post-merge proof runs on the squash's main run.