Skip to content

ui-server: a reference clone under workspaces/ counts toward files_changed and pauses the turn #3793

Closed

Description

@schlessera

Context

Fetching or checking out a reference repository under workspaces/ counts every file it touches against the turn's files_changed scope limit. One routine git fetch plus git checkout of a mid-sized repository is enough to pause an interactive turn.

  • workspaces/ is the brain's writable, gitignored scratch for repositories and outputs (backends: the worker sandbox leaves no persistent writable place for scratch, workspaces or file outputs #1626; its writability checks are resolveWorkspacesMount, packages/ui-sdk/src/server/worker-sandbox.ts:470-481). Steering detection already treats it as outside the brain (packages/ui-server/src/brain/journal-steering.ts:73).
  • The scope monitor counts turn.summary.changedPaths for files_changed without exception (packages/ui-server/src/brain/turn-scope.ts:78, :117, :192). Those paths come from the journal's observation of the whole brain, including ignored scratch.

Observed on a hosted 0.44.0 install.

  • One interactive turn refreshed a shallow clone of a public repository under workspaces/. It hit scope_cap files_changed (limit 1000, observed 1152) and was frozen. The roadblock records about 22 minutes waiting at the cap. The model's in-flight tool call came back "interrupted: the session ended before this call's result was recorded", and the user had to send "Continue".
  • Another turn reported 817 changed files, about 815 of them from a git checkout --detach origin/main in the same kind of clone, while the turn changed nothing in the brain.

Decision (maintainer, 2026-11-09)

Exclude workspaces/ from files_changed. turn_bytes and the free-space floor remain the bounds on scratch growth. A separate workspace budget and a documented no were both rejected.

Scope

  • files_changed counts only changed paths outside workspaces/. Use the same containment rule as journal-steering.ts:73 (isWithin), not a string prefix.
  • turn_bytes and the free-space floor still count workspaces/ writes, unchanged.
  • The journal summary keeps reporting all changed paths. If useful, it reports the workspace count separately, so the turn disclosure stays honest about what was touched.
  • Update the scope-limit paragraph in docs/decisions/governed-writable-workers.md and the governance policy reference (max_files_changed) to say the count excludes workspaces/.

Out of scope

  • The limits' values and defaults.
  • Changing what the journal retains for workspace files.
  • Any new policy key.

Acceptance criteria

  • A governed turn that writes 1,500 files under workspaces/ and changes no brain file is not paused by files_changed. A turn-scope test proves it and fails before the change.
  • A turn that changes 1,001 brain files is still paused at a limit of 1,000.
  • Workspace writes still count toward turn_bytes, so a turn writing past max_bytes_written under workspaces/ is still paused. A test proves it.
  • A path like workspaces-old/x.md, outside workspaces/ but sharing its prefix, still counts. A test proves it.
  • Mutation receipt: drop the exclusion, and the first criterion's test fails.

Verification

  • bun run test packages/ui-server/tests (turn-scope and ws-scope-caps cases).

Contract impact

None. This narrows what max_files_changed counts and documents it in the decision record and policy reference. No key, shape or tool changes.

Updated 2026-11-09: the decision recorded above replaced the open options. Scope and acceptance criteria now follow option 1.

Activity

  1. added
    type: fix
    area: ui-server
    needs: decision
    priority: p1
    on Nov 9, 2026
  2. added this to the 0.45.0 milestone on Nov 9, 2026
  3. schlessera commented on Nov 9, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-09): option 1. files_changed excludes workspaces/. turn_bytes and the free-space floor remain the bounds on scratch growth. A separate workspace budget and keeping the count are rejected.

    The body now follows this ruling. The decision record's scope-limit paragraph and the policy reference are updated with the implementation. No contract change.

  4. added
    agent-ready
    and removed
    needs: decision
    on Nov 9, 2026
  5. self-assigned this
    on Nov 15, 2026
  6. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-fde42a2b. Branch: fix/3793-workspaces-files-changed.

    Collisions: path collisions on docs/decisions/governed-writable-workers.md with draft PRs #4002, #4008, #4018, #4024 (doc paragraph only); closure collisions on turn-scope tests with #3622, #3806. None touch turn-scope.ts itself.

  7. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Delivered in #4025, squash eb3c53ac296808291e4aded36c9e4aa65a7e8aae on main (milestone 0.45.0).

    • files_changed now counts only changed paths outside workspaces/, using isWithin containment, so workspaces-old/ still counts. turn_bytes, the free-space floor and the scope summary's changedPaths still include workspace writes.
    • New tests in packages/ui-server/tests/turn-scope.test.ts cover each case: 1,500 workspace files do not pause the turn; 1,001 brain paths pause it at 1,000; workspace bytes pause it on turn_bytes; workspaces-old/x.md counts. They failed before the change. Two mutation receipts are recorded: dropping the exclusion, and replacing isWithin with a string prefix.
    • The decision record (G4 list and scope-limit paragraph) and the scope row of docs/supported-inputs.md are updated.
    • Contract note: the change is additive. The @internal onObservation observer facts gain workspacePaths. api-report records that member because the journal's type is inferred, so the change is documented in docs/integration-contract/package-api.md. No wire, HTTP or policy shape changed.
    • Heavy main proof for the squash is still pending at the time of this note.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: ui-serverpriority: p1type: fix

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions