Repository navigation
CONTRACT: fix(ui-server): leave workspaces/ out of the files_changed scope count - #4025
Merged
Merged
Conversation
…scope count A reference clone fetched or checked out under workspaces/ counted every touched file against the turn's files_changed limit and paused interactive turns that changed nothing in the brain (#3793). The journal's observation facts now carry workspacePaths, the changed paths contained in workspaces/ by isWithin (a GLOB only narrows the candidates, so workspaces-old/ still counts). The scope monitor caps changedPaths minus that count; turn_bytes, the free-space floor and the summary's changedPaths still include workspace writes. Contract: additive. The @internal onObservation observer is recorded in api-report because the journal's type is inferred; its facts gain workspacePaths. Documented in the package API component. No wire, HTTP or policy shape changes. The native journal test fixture now streams its synthetic delta in the same bounded 64 KiB chunks as the manager, so a test can observe a 1,500-file clone in one observation. Closes #3793 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 15, 2026
schlessera
marked this pull request as ready for review
November 15, 2026 18:37
9 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3793
What changed
A governed turn's
files_changedscope cap no longer counts changed paths underworkspaces/, so fetching or checking out a reference clone there no longer pauses a turn that changed nothing in the brain. The journal's observation facts gainworkspacePaths: the changed paths contained inworkspaces/byisWithin(a SQLGLOBonly narrows the candidates). The scope monitor capschangedPaths - workspacePaths.turn_bytes, the free-space floor and the scope summary'schangedPaths(the turn disclosure) still count every workspace write.workspaces-old/x.mdstill counts.Why this shape
This follows the maintainer's decision on #3793 (option 1). The summary's
changedPathskeeps reporting every path, so the disclosure stays honest and the wire field keeps its documented meaning. Only the cap's count, carried in a privatefilesChangedon the live turn, leaves workspaces out. The containment isisWithin(BRAIN_WORKSPACES_DIR, path, { includeRoot: false }), the rulejournal-steering.ts:73uses for scoped entries, not a string prefix.Contract (additive).
onObservationis tagged@internal, butapi-reportrecords it because the journal's return type is inferred, and the tag only applies to class and interface members. Its facts gain one field,workspacePaths. That one-lineapi-report/ui-server.txtaddition is documented indocs/integration-contract/package-api.md, with aminorchangeset. No wire, HTTP or policy shape changes.The native journal test fixture now streams its synthetic delta in bounded 64 KiB chunks, as the manager does. Before, it sent the whole delta as one chunk, and the parser refused a 1,500-file delta.
Docs: the G4 scope list and the scope-limit paragraph in
docs/decisions/governed-writable-workers.md, and thescoperow of the policy reference indocs/supported-inputs.md.Proof
Failing first (on this tree, with only
turn-journal.tsandturn-scope.tsreverted toorigin/main):files_changed leaves out a reference clone under workspaces/ …failed atWORKSPACE_CLONE_DOES_NOT_PAUSE_FILES_CHANGED: 1,500 workspace files raised afiles_changedreceipt.workspace writes still count toward turn_bytes …failed atWORKSPACE_BYTES_PAUSE_TURN_BYTES_ONLY: the receipt wasfiles_changed, notturn_bytes.shared snapshots …case failed:workspaces/shroudstill counted as a changed path.Mutations (each restored afterwards):
filesChanged = facts.changedPaths): the first test fails atWORKSPACE_CLONE_DOES_NOT_PAUSE_FILES_CHANGED.isWithinforpath.startsWith(BRAIN_WORKSPACES_DIR): the first test fails atBRAIN_PATHS_PAST_THE_CAP_STILL_PAUSE(expectedcount: 1001, received1000), becauseworkspaces-old/x.mdstopped counting.Acceptance criteria:
WORKSPACE_CLONE_DOES_NOT_PAUSE_FILES_CHANGED). The summary still discloses ≥1,500 paths.workspaces-old/x.mdplus one more brain file: paused atfiles_changed,count: 1001,cap: 1000.workspaces/withmax_bytes_written: 1024andmax_files_changed: 1: paused onturn_bytesonly.Environment-only failures:
turn-scope.test.tshas four failures in this sandbox:repeated ignored 100 MB …, bothsmall tmpfs brain …cases andreal host restart …. The same four fail on an unmodifiedorigin/mainworktree.{"version":1,"kind":"brain-check-pr-receipt","head":"aa2bbd42435ff099d4dddcb6a1bed7423a9ddbb6","base":"origin/main","mode":"focused","startedAt":"2026-11-15T16:47:20.022Z","finishedAt":"2026-11-15T16:48:27.055Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":12639.729349000001},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":108.33306199999788},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":67.43173200000092},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":19.301531000000978},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":54182.02304999999}]}Proportionate containment
The
files_changedscope cap is narrowed, not added.workspaces/. Scratch growth underworkspaces/stays bounded byturn_bytesand the free-space floor, both unchanged.scope_capgovernance event and the scope receipts record it.Checklist
docs/reflect the change, or nothing documented moved.docs/decisions/provider-history.md): the provider-history guard passes, or nothing on a turn's path changed.Collisions
bun scripts/collisions.ts --json --paths <diff>at headaa2bbd424reports path collisions with these open draft PRs:api-report/ui-server.txt,package-api.md,turn-journal.tsapi-report/ui-server.txt,package-api.md,native-journal-fixture.tsgoverned-writable-workers.md,package-api.mdgoverned-writable-workers.mdEach overlap is a separate paragraph or line.
Anything left open
Nothing.
🤖 Generated with Claude Code