Repository navigation
A workspace file total, and a limit an operator can set - #1160
Merged
Merged
Conversation
…(Issue #1431) Every workspace in a data directory writes its attachment blobs to one files/ folder on one volume, and the only cap was 10 MiB per file. One workspace that uploaded a few hundred files filled the volume, and every other workspace then answered 507 on upload and SQLITE_FULL on writes. The engine now counts the attachment bytes a workspace holds. The count is derived from the workspace on every read, so it is rebuilt on load and moves with every attach and delete rather than being a cached total that can drift through trash, undo, import and restore. storageStats() carries it as fileBytes beside the existing sizeBytes, so GET /api/health ships it for the workspace in the request, with fileLimitBytes next to it. WEAVE_WORKSPACE_FILE_MAX_MB caps one workspace. Set, an attach that would take the workspace past the figure is refused before any blob is written, with the storage-full code the error contract already maps to 507, MCP -32008 and CLI exit 51, and a message naming what the workspace holds and what it may hold. Unset, weave counts and refuses nothing, so no existing instance changes behaviour on upgrade. Left for follow-up rows, named in the Issue note: the soft warning in the upload tile at 80% of the limit, which is client work on a surface this server batch did not touch, and resizing the production Railway volume, which the Issue already calls an operator step. ponytail: the count is a walk over the workspace entities on each read, the same walk storageStats already did, instead of a maintained counter. If a workspace ever grows past the point where that walk costs a health poll, cache it in the engine and invalidate it where #mark already runs. (Issue #1431) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Change-Id: I57a05b7bf18c4f41b0a64543f763c82be0142ede
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 weave Issue #1431 (https://weave.grunion.ai/w/weave, Development/Issue #1431).
What changed
Every workspace in a data directory writes its attachment blobs to one
files/folder on one volume, and the only cap was 10 MiB per file. One workspace that uploaded a few hundred files filled the volume, and every other workspace then answered 507 on upload andSQLITE_FULLon writes.src/engine.js: a private#fileBytes()sums the attachment and preview bytes a workspace holds.storageStats()carries it asfileBytesbeside the existingsizeBytes, withfileLimitBytesnext to it, soGET /api/healthships both for the workspace in the request.src/engine.js:workspaceFileMaxBytes()readsWEAVE_WORKSPACE_FILE_MAX_MB. When it is set,attachFilerefuses an attach that would take the workspace past the figure, before any blob is written, with thestorage-fullcode the error contract already maps to HTTP 507, MCP -32008 and CLI exit 51, and a message naming what the workspace holds and what it may hold. Unset, weave counts and refuses nothing, so no existing instance changes behaviour on upgrade.src/env.js, the rendered Environment reference guide,Dockerfileandcompose.yaml: the new variable, its default and what breaks when it is wrong.src/handbook/fields/attachments.md: the attachments page names the workspace cap as a second cause of the 507 it already documents.The count is derived from the workspace on every read rather than cached, so it is rebuilt on load and moves with every attach and delete without a second bookkeeping path through trash, undo, import and restore. It is the same walk
storageStats()already did.Refusing in the engine covers every door at once: the REST attach routes, the streamed upload (
attachFileseesstaged.size, and the route'sfinallyalready drops the staged blob on a refusal),weave file attachand MCP.Verification
Targeted suites, 258 cases,
fail 0, nothing skipped:workspace-file-budget,nav-stats,env-registry,deploy-artifacts,file-preview,backup,attachment-size-limit,upload-core,upload-stream,mcp-upload,agent-surface,no-inline-comments,handbook,docs-drift,changelog-fragments,files-delete-http,attachments-field,file-blobs,architecture-map,doc-owners,health,quality-mirror,region-index.test/workspace-file-budget.test.mjsis the new suite, written before the fix and red on the missing export. Its six cases cover the total apart from the database, the rebuild on load against the blobs on the volume, an unset budget, the refusal naming the total and the limit, the route's 507 and the health payload.Live on a scratch server from this worktree (port 4490,
WEAVE_WORKSPACE_FILE_MAX_MB=1): the first 600 KiB attach answered 201, the second answered507 storage-fullwith "This workspace holds 0.6 MB of files and can hold 1.0 MB, so blob2.bin (0.6 MB) was not attached", andGET /api/healthcarriedfileBytes: 614400, fileLimitBytes: 1048576. Before the change neither field existed and both attaches answered 201.Left for follow-up
public/surfaces this server batch did not touch; the number it needs now ships on health.🤖 Generated with Claude Code