Skip to content

A workspace file total, and a limit an operator can set - #1160

Merged
grunion-ai merged 1 commit into
mainfrom
codex/weave-fix-1431-wf-11201602
Nov 20, 2026
Merged

grunion-ai merged 1 commit into
mainfrom
codex/weave-fix-1431-wf-11201602

Conversation

@grunion-ai

Copy link
Copy Markdown
Owner

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 and SQLITE_FULL on writes.

  • src/engine.js: a private #fileBytes() sums the attachment and preview bytes a workspace holds. storageStats() carries it as fileBytes beside the existing sizeBytes, with fileLimitBytes next to it, so GET /api/health ships both for the workspace in the request.
  • src/engine.js: workspaceFileMaxBytes() reads WEAVE_WORKSPACE_FILE_MAX_MB. When it is set, attachFile refuses an attach that would take the workspace past the figure, before any blob is written, with the storage-full code 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, Dockerfile and compose.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 (attachFile sees staged.size, and the route's finally already drops the staged blob on a refusal), weave file attach and 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.mjs is 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 answered 507 storage-full with "This workspace holds 0.6 MB of files and can hold 1.0 MB, so blob2.bin (0.6 MB) was not attached", and GET /api/health carried fileBytes: 614400, fileLimitBytes: 1048576. Before the change neither field existed and both attaches answered 201.

Left for follow-up

  • The soft warning in the upload tile at 80% of the limit. That is client work on public/ surfaces this server batch did not touch; the number it needs now ships on health.
  • Resizing the production Railway volume, which Issue #1431 already calls an operator step.

🤖 Generated with Claude Code

…(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
@grunion-ai
grunion-ai merged commit 8248a22 into main Nov 20, 2026
17 checks passed
@grunion-ai
grunion-ai deleted the codex/weave-fix-1431-wf-11201602 branch November 20, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants