Repository navigation
Description
Context
On a hosted install with managed native storage, the daily maintain cron job (brain maintain through brain-ui-cron, in a credentialed maintenance worker) fails its git step on every run:
"step": "git",
"result": "FAILED — fatal: sha1 file '.git/objects/pack/tmp_pack_XXXXXX' write error. Out of diskspace"
The brain's .git is several GB, and the data volume has several GB free, so the volume is not the limit. The message names no limit, so an operator cannot tell what to change.
The limit, from source (inference, not yet reproduced): a hosted maintenance worker writes to a private output stage, not the brain. Its writable capacity is one output-staging allowance, BRAIN_UI_OUTPUT_STAGING_BYTES, 256 MiB by default (DEFAULT_OUTPUT_STAGING_BYTES, packages/ui-sdk/src/server/worker-state-limits.ts:127). The stage is reserved at that size (stage = await native.manager.prepareStage, packages/ui-sdk/src/server/worker-native-output.ts:247), and maintenance output is prepared on it (outputs = await prepareMaintenanceOutput, packages/ui-server/src/brain/host-boundary.ts:631). docs/hosting/agent-workers.md (the BRAIN_UI_OUTPUT_STAGING_BYTES table, line 866, and the paragraph after it) says Git adapter data is held in that bounded tmpfs and that writes past it fail with ENOSPC. The git step runs git maintenance run with loose-objects, incremental-repack and pack-refs (packRepository, packages/core/src/lib/git-storage.ts:78-86). It is not a full repack. Each new pack is written into the stage, and a pack over 256 MiB fails with git's Out of diskspace.
brain storage pack --json already reports no_space and the .git store's statfs headroom (runStoragePack, packages/core/src/cli/commands/storage.ts:48-67; gitPackingHeadroom, packages/core/src/lib/git-storage.ts:96-105). brain maintain's git step (packages/core/src/cli/commands/maintain.ts:152-170) reports only git's first stderr line.
Split on 2026-11-02 from the original report, which also carried two independent problems:
- Gemini calls in the same maintenance runs fail with
API_KEY_INVALID: ui-server: hosted cron maintenance sends Gemini requests with an invalid key since 0.44.0 #3363. - The cron record does not name the failing step: core: a failed brain maintain cron run's error message does not name the failing step #3364.
Scope
- Confirm the limit with a fixture: a hosted-boundary maintenance run whose git packing needs more than the output-staging allowance.
- When the git step runs out of space, report it as a named refusal. The step result must say:
- that the pack ran out of space in the maintenance worker's output stage;
- the allowance in bytes and the setting that controls it,
BRAIN_UI_OUTPUT_STAGING_BYTES; - the space available when the step started, measured the way
gitPackingHeadroommeasures it.
- The host knows the setting's name; core does not. The PR may pass it to the worker as data, or have the host add it to a step that failed with
ENOSPC. Core must not hard-code abrain-uisetting for unhosted brains. An unhosted brain that runs out of disk gets the same space report without the hosted setting. - Document the remedy in
docs/hosting/agent-workers.md: raiseBRAIN_UI_OUTPUT_STAGING_BYTES(and its budget), with the cost that every consumer then reserves the larger allowance.
Out of scope
- A separate, larger allowance for maintenance packing, changing the 256 MiB default, or moving packing out of the worker. Each is a policy change that needs a ruling of its own.
- Running
git gc, expiring reflogs or any destructive packing. - The Gemini
API_KEY_INVALIDfailure (ui-server: hosted cron maintenance sends Gemini requests with an invalid key since 0.44.0 #3363) and the cron record's message (core: a failed brain maintain cron run's error message does not name the failing step #3364).
Acceptance criteria
- A test runs
brain maintainthrough the hosted maintenance boundary (the native app fixture used bypackages/ui-server/tests/maintenance-provider-relay.test.ts), withBRAIN_UI_OUTPUT_STAGING_BYTESset below the size of the pack the fixture repository produces. Thegitstep result names the output-staging limit, its byte value,BRAIN_UI_OUTPUT_STAGING_BYTESand the starting headroom. On current main the same test fails on the bareOut of diskspace. The PR records that failing run. - With the allowance above the pack size, the same fixture reports
ok — packed N loose object(s). - An unhosted
brain maintainwhose git write hitsENOSPCreports the space shortfall without naming a hosted setting (unit test with an injected git failure). -
brain maintain --json's shape is unchanged. Only theresultstring changes. -
docs/hosting/agent-workers.mdstates that maintenance git packing is bounded by the output-staging allowance and how to raise it.
Verification
bun run test packages/core/tests/maintain.test.tsand the new hosted-boundary test, with the failing-first receipt on main.- On a hosted native-storage install, after raising the allowance above the largest pack: one
maintainrun whosegitstep reportsok. That check is for the operator after merge and does not block coding.
Contract impact
None. brain maintain --json keeps its shape; step result strings are not contract.
2026-11-02 triage: identified the likeliest limit from source and docs (the 256 MiB output-staging allowance) and corrected "full repack" to the incremental tasks git actually runs. Split the Gemini failure into #3363 and the cron message into #3364. Removed incident specifics of one deployment. Made the criteria checkable against a fixture.
Activity
[-]core: hosted brain maintain fails daily: git pack hits an unnamed space limit, and Gemini calls get API_KEY_INVALID since 0.44.0[/-][+]core: hosted brain maintain's git step fails with a bare out-of-disk when its pack exceeds the maintenance output-staging allowance[/+]schlessera commentedon Nov 2, 2026
Triage (2026-11-02, source at
3984040f1).API_KEY_INVALIDfrom hosted cron maintenance → ui-server: hosted cron maintenance sends Gemini requests with an invalid key since 0.44.0 #3363 (needs: repro).priority: p1. None blocks another..gitinto its output stage. That stage is capped byBRAIN_UI_OUTPUT_STAGING_BYTES(256 MiB by default), and writes past it fail withENOSPC.docs/hosting/agent-workers.mddocuments both. The step runs git's incrementalloose-objects/incremental-repacktasks, not a full repack, so a single new pack over 256 MiB fails exactly as reported. The other candidates (maintenance temp budget, native qgroup) were not ruled out by measurement. The first criterion's fixture settles it.area: ui-serverfor the host-side limit naming.agent-ready: the brief is complete and noneeds:remains.schlessera commentedon Nov 2, 2026
Claiming (token
wi-3357-d55c). Branchfix/3357-output-staging-cap-docsfromorigin/main@3984040f1. Path collision report: #3335 also touchesdocs/hosting/agent-workers.mdandpackages/ui-server/src/brain/host-boundary.ts.schlessera commentedon Nov 2, 2026
Status (claim
wi-3357-d55c): implementation is complete in draft #3373 (head61e25ff84, milestone 0.45.0), with failing-first and mutation receipts in the PR. I did not request confirmation because main is red (incident #3361, fix #3366 declared). To resume oncebun scripts/integrate.ts main-status --jsonreports green, runbun scripts/integrate.ts confirm 3373 --issues schlessera/brain-kit#3357. Releasing my assignment; the PR stays open for confirmation.CONTRACT: fix(core): name the output-staging limit when maintain's gi…
Merge origin/main into epic/3234-chat-deletion