Skip to content

core: hosted brain maintain's git step fails with a bare out-of-disk when its pack exceeds the maintenance output-staging allowance #3357

Closed

Description

@schlessera

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:

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 gitPackingHeadroom measures 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 a brain-ui setting 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: raise BRAIN_UI_OUTPUT_STAGING_BYTES (and its budget), with the cost that every consumer then reserves the larger allowance.

Out of scope

Acceptance criteria

  • A test runs brain maintain through the hosted maintenance boundary (the native app fixture used by packages/ui-server/tests/maintenance-provider-relay.test.ts), with BRAIN_UI_OUTPUT_STAGING_BYTES set below the size of the pack the fixture repository produces. The git step result names the output-staging limit, its byte value, BRAIN_UI_OUTPUT_STAGING_BYTES and the starting headroom. On current main the same test fails on the bare Out 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 maintain whose git write hits ENOSPC reports the space shortfall without naming a hosted setting (unit test with an injected git failure).
  • brain maintain --json's shape is unchanged. Only the result string changes.
  • docs/hosting/agent-workers.md states 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.ts and 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 maintain run whose git step reports ok. 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

  1. added
    type: fix
    area: core
    area: ui-sdk
    priority: p1
    on Nov 2, 2026
  2. added this to the 0.45.0 milestone on Nov 2, 2026
  3. changed the title [-]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[/+] on Nov 2, 2026
  4. added
    area: ui-server
    agent-ready
    on Nov 2, 2026
  5. schlessera commented on Nov 2, 2026

    @schlessera
    OwnerAuthor

    Triage (2026-11-02, source at 3984040f1).

    • Split. This issue bundled three independent problems. It now covers only the git step's space limit.
    • Limit identified from source, still to be confirmed by the fixture. A hosted maintenance worker writes .git into its output stage. That stage is capped by BRAIN_UI_OUTPUT_STAGING_BYTES (256 MiB by default), and writes past it fail with ENOSPC. docs/hosting/agent-workers.md documents both. The step runs git's incremental loose-objects/incremental-repack tasks, 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.
    • Scope kept narrow. Name the limit, the setting and the headroom, and document the remedy. A larger dedicated allowance for packing, or moving packing out of the worker, is a policy change and is excluded. If the maintainer wants it, it needs its own ruling.
    • Removed the incident specifics of one deployment from the body. Added area: ui-server for the host-side limit naming.
    • Labelled agent-ready: the brief is complete and no needs: remains.
  6. self-assigned this
    on Nov 2, 2026
  7. schlessera commented on Nov 2, 2026

    @schlessera
    OwnerAuthor

    Claiming (token wi-3357-d55c). Branch fix/3357-output-staging-cap-docs from origin/main @ 3984040f1. Path collision report: #3335 also touches docs/hosting/agent-workers.md and packages/ui-server/src/brain/host-boundary.ts.

  8. schlessera commented on Nov 2, 2026

    @schlessera
    OwnerAuthor

    Status (claim wi-3357-d55c): implementation is complete in draft #3373 (head 61e25ff84, 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 once bun scripts/integrate.ts main-status --json reports green, run bun scripts/integrate.ts confirm 3373 --issues schlessera/brain-kit#3357. Releasing my assignment; the PR stays open for confirmation.

  9. removed their assignment
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: corearea: ui-sdkarea: ui-serverpriority: p1type: fix

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions