Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
4ab7c4a
CONTRACT: feat(ui-server): fetch allow-listed repositories for module…
schlessera Nov 2, 2026
d3c68f3
refactor(ui-server): read a job's module list through the crontab dis…
schlessera Nov 15, 2026
a42a98f
docs: follow citations moved by the module repositories change
schlessera Nov 15, 2026
adf27c3
fix(ui-server): read no module list for a scheduled command that is n…
schlessera Nov 15, 2026
20b72c7
Merge remote-tracking branch 'origin/main' into fix/3380-module-repos…
schlessera Nov 15, 2026
68f4b89
Merge remote-tracking branch 'origin/main' into fix/3380-module-repos…
schlessera Nov 15, 2026
57be08b
Merge remote-tracking branch 'origin/main' into fix/3380-module-repos…
schlessera Nov 15, 2026
a6e9e6c
Merge remote-tracking branch 'origin/main' into fix/3380-module-repos…
schlessera Nov 15, 2026
3e572a3
Merge remote-tracking branch 'origin/main' into fix/3380-module-repos…
schlessera Nov 15, 2026
9163bc4
Merge remote-tracking branch 'origin/main' into fix/3380-module-repos…
schlessera Nov 15, 2026
332829a
Merge remote-tracking branch 'origin/main' into fix/3380-module-repos…
schlessera Nov 15, 2026
3e1746d
Merge remote-tracking branch 'origin/main' into fix/3380-module-repos…
schlessera Nov 15, 2026
d3b69f9
Merge remote-tracking branch 'origin/main' into fix/3380-module-repos…
schlessera Nov 15, 2026
4c3e4a4
Merge remote-tracking branch 'origin/main' into fix/3380-module-repos…
schlessera Nov 15, 2026
8a22206
Merge remote-tracking branch 'origin/main' into fix/3380-module-repos…
schlessera Nov 15, 2026
d75a4cb
Merge remote-tracking branch 'origin/main' into fix/3380-module-repos…
schlessera Nov 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/module-repositories.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@schlessera/brain": minor
"@schlessera/brain-ui-server": minor
---
A module's cron job can now read another repository, including a private one (#3380). The module's config block lists the repositories it needs with the new core-owned `repositories` key, and `brain module list --json` reports them. The host fetches a listed repository only when the operator's new `BRAIN_UI_MODULE_REPOSITORIES` allow-list names it too, so an edit to `brain.config.ts` alone cannot widen access. The host fetches with the sync transport's credential into a private mirror. The job's worker reads that mirror through a Git URL rewrite, so a plain `git clone <url>` works there, and the worker never holds the credential. A job whose module asks for a repository the operator has not allowed fails before it starts, with an error that names the repository and the setting.
1 change: 1 addition & 0 deletions api-report/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ signatures (every public export and the types it is made of)
dir: string;
config: C;
state?: "active" | "dormant";
repositories?: readonly string[];
declaration?: ModuleManifest<C>;
configInput?: unknown;
}
Expand Down
4 changes: 2 additions & 2 deletions docs/decisions/claude-code-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ next to it.
`/usr/local/bin/claude` and resolved with
`env.CLAUDE_CODE_PATH || "/usr/local/bin/claude"`. Since #213 it has no
default (`name: "CLAUDE_CODE_PATH"`,
`packages/ui-server/src/config/env.ts:584-584`) and is null when unset
(`claudeCodePath`, `packages/ui-server/src/config/env.ts:1200`). The whole `agent` block is copied into the backend's module
`packages/ui-server/src/config/env.ts:606-606`) and is null when unset
(`claudeCodePath`, `packages/ui-server/src/config/env.ts:1250`). The whole `agent` block is copied into the backend's module
config (`config: { ...agent }`,
`packages/ui-server/src/agent/backend.ts:532`), read back as a string
(`const claudeCodePath`, `packages/ui-backend-claude/src/module.ts:266-270`)
Expand Down
2 changes: 1 addition & 1 deletion docs/decisions/deterministic-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ version.
- **The container cron wrapper reads a result only from its own sync job.**
It parses stdout when the job is `sync` and its argv is exactly what the
crontab emitter writes (`isSyncJob`,
`packages/ui-server/src/cron/emit.ts:81-87`), and passes every other job's
`packages/ui-server/src/cron/emit.ts:83-89`), and passes every other job's
stdout through untouched. A new wrapper flag would have done the same, but
the wrapper command is deployment configuration, and a wrapper that did not
know the flag would have broken the nightly sync.
Expand Down
31 changes: 27 additions & 4 deletions docs/decisions/governed-writable-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ maintenance worker no longer receives the keys the provider relay carries
(`GEMINI_API_KEY`, `ANTHROPIC_API_KEY`, `OPENAI_API_KEY` and keys the operator
lists for it), and the brain's `.env*` files are masked as they are for a
credential-free worker. Its `brain` CLI reaches those providers through its own
relay (`providerRelayFor`, `packages/ui-server/src/brain/host-boundary.ts:426-433`).
relay (`providerRelayFor`, `packages/ui-server/src/brain/host-boundary.ts:432-439`).
What remains is narrower and stated in the status: keys the relay does not
carry (the `jev` reranker's, a `brain sync` agent runner's login) and every
key on a host without managed native storage, where there is no relay.
Expand Down Expand Up @@ -577,6 +577,29 @@ remote, through the mirror transport). The
Forwarding a generic `GITHUB_TOKEN` into maintenance workers and restoring
host-directory writes remain out of scope.

A second ruling the same day settled how point 2 grants and finds a repository:

3. **The grant is an intersection.** The module's config block declares the
repositories it wants (a core-owned `repositories` key), and the host
refuses any that the operator's allow-list, `BRAIN_UI_MODULE_REPOSITORIES`
in host configuration outside the brain, does not also name.
`brain.config.ts` is protected by default, but a governance policy may
release it to governed turns. Without the host list, a governed edit
could have turned the host credential into a read of every private
repository it reaches. With it, the brain can narrow the host's grant but
never widen it.
4. **The runner maps a job to its module at run time.** Before each module
job, the runner runs a credential-free `brain module list --json`, which
reports each module's `repositories`, and matches the job by its
`<module>-<entry>` name and its command. Names alone are ambiguous because
both parts may contain `-`. The crontab layout stays as it is.

A refused or failed fetch refuses the job before it starts. The fetch reuses
the sync transport unchanged: the same fixed mirror configuration, the
credential sent only to `https://github.com`, and a transport worker that
never mounts the brain
([the contract](../integration-contract/package-api.md#module-repositories)).

The protected list below keeps the policy intact, keeps secrets out of workers,
and stops a turn from steering later turns' permissions or start-up code.

Expand Down Expand Up @@ -4329,7 +4352,7 @@ files, `.claude/`, `.agents/`, `.pi/`, `.mcp.json`, and
- The core CLI loads `brain.config.ts` or `brain.config.json` at the canonical
brain cwd (`loadUserConfig`, `packages/core/src/lib/config.ts:660-694`).
Host commands bind that cwd to the selected brain (`function hostSpawn`,
`packages/ui-server/src/brain/host-boundary.ts:518-529`).
`packages/ui-server/src/brain/host-boundary.ts:526-537`).
- Bun startup uses root `bunfig.toml` and `package.json`; retained literal
preload/module inputs can identify a nested module's nearest package scope.
The inventory walks parent directories only within the originating journal
Expand Down Expand Up @@ -4372,8 +4395,8 @@ is now consumer-qualified independently of reference classification (#2028). The
| Local JS/TS inputs | Literal module imports/exports/requires identified by Bun's parser | File-relative bounded resolution, including genuine text/extensionless resources. Runtime resource reads, computed imports and package resolution remain unknown. |

This mapping was checked against core's (`loadModules`,
`packages/core/src/lib/module-loader.ts:95-103`), (`importManifest`,
`packages/core/src/lib/module-loader.ts:192-224`), Pi's (`build`,
`packages/core/src/lib/module-loader.ts:114-122`), (`importManifest`,
`packages/core/src/lib/module-loader.ts:221-253`), Pi's (`build`,
`packages/ui-backend-pi/src/session-resources.ts:93-137`) and the installed
Pi 0.99.2 package-manager/settings consumers and Claude SDK 0.3.293 settings
schema. Nothing imports or evaluates repository configuration on the host.
Expand Down
4 changes: 2 additions & 2 deletions docs/decisions/module-mcp-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export function defineModuleTool<C, I, O>(tool: ModuleTool<C, I, O>): ModuleTool
produces `mcp__brain__jobs_review`, so 64 leaves headroom under 128.
- **Collisions are impossible by construction and still checked.** Module
names are unique at load (`if (seenNames.has(manifest.name))`,
`packages/core/src/lib/module-loader.ts:108-111`), local names are keys of
`packages/core/src/lib/module-loader.ts:127-130`), local names are keys of
one record, and `brain` is reserved. Registration nevertheless checks
every composed name against the names already registered, core's first,
then modules in config order. On a duplicate it fails with
Expand Down Expand Up @@ -315,7 +315,7 @@ A module that stops shipping a documented tool is making a breaking change.
### 9. Lint and documentation checks

`brain module lint <name>` gains these checks
(`function moduleLint`, `packages/core/src/cli/commands/module.ts:107-158`):
(`function moduleLint`, `packages/core/src/cli/commands/module.ts:108-159`):

- `tool-load`: every declared tool imports, and its definition passes §1
and §3.
Expand Down
8 changes: 8 additions & 0 deletions docs/hosting/agent-workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,14 @@ refuses rather than run git on the host.
process and must not load the brain's `bunfig.toml` or `.env`. The runner
starts each repository job in the brain itself, in a maintenance worker,
and reconciles any governed turn a dead server left behind first.
- **A module job's repositories** are fetched by the host, never by the job
(#3380). Before a module job, the runner reads `brain module list --json`
in a credential-free worker. It fetches each repository the job's module
asks for only if `BRAIN_UI_MODULE_REPOSITORIES`, the operator's allow-list,
names it too, and refuses the job otherwise. The sync transport fetches
into a private mirror beside the sync mirror, using the sync credential.
The job's worker reads that mirror through a Git URL rewrite and holds no
Git credential. Leave the setting empty to fetch nothing.

**When the boundary holds.** `governed` is the default profile, so the
boundary holds wherever `governed` can run, and from then on for good: once
Expand Down
12 changes: 12 additions & 0 deletions docs/integration-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,18 @@ an `allowlist` egress mode, or the exact origins in
[the G6 ruling](decisions/governed-writable-workers.md#untrusted-input-g6) and
[supported inputs](supported-inputs.md).

## Module repositories (additive, 0.45.0, #3380)

A module's config block accepts an optional core-owned `repositories` list of
repository URLs its cron jobs may read, and `brain module list --json` adds
`repositories: string[]` to each configured module. The cron runner fetches a
listed repository only when the operator's new `BRAIN_UI_MODULE_REPOSITORIES`
host setting names it too; otherwise the job is refused before it starts. The
host fetches with its sync credential into a private mirror, and the job's
worker reads the mirror through a Git URL rewrite without any credential. See
[the package API component](integration-contract/package-api.md#module-repositories).
This ships in a minor; no breaking ruling is required.

## Module state area (additive, 0.45.0, #3380)

A module keeps durable state in `<brain>/.brain-ui/modules/<module-name>/`,
Expand Down
Loading
Loading