feat(core): materialize managed attachments for v2 sessions - #46175
Open
safzanpirani wants to merge 1 commit into
Open
feat(core): materialize managed attachments for v2 sessions#46175safzanpirani wants to merge 1 commit into
safzanpirani wants to merge 1 commit into
Conversation
This was referenced Aug 29, 2026
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.
Issue for this PR
Closes #46173
Type of change
What does this PR do?
PR 1 of 3 from the plan in #46173: the path-only backend flow. Adds a managed per-session attachment store in core (streaming writes with an exclusive temp file + atomic rename, cross-platform filename sanitization, MIME sniffing, sha256, 25MiB/100MiB/1GiB quotas reserved under a semaphore, 24h unbound GC), a streaming multipart
POST /api/session/:sessionID/attachmentroute on the v2 session group with typed 413/not-found errors, managed-URI validation at prompt admission (cross-session references fail closed), and lowering that emits one text part with the absolute path so tools can operate on the file. No native media promotion and no app wiring yet — those are PRs 2 and 3. The generated client intentionally omits the multipart route until the PR 3 adapter.Known limitation, marked with a TODO in the store: quota locking is process-local; two server processes sharing one data dir could jointly exceed the global cap.
How did you verify your code works?
packages/core:bun test test/attachment-store.test.ts test/session-runner-message.test.ts— 17 pass (traversal/hostile names incl. bidi and Windows device aliases, internal-name collision, symlink swap, concurrent cross-session global quota race, 20MiB streaming test that asserts the first chunk reaches disk before the producer releases the rest, GC expiry, path-only lowering shape).bun typecheckclean.packages/opencode:bun test test/server/httpapi-v2-attachment.test.ts— 5 pass: real multipart upload through the running server, upload→prompt admission, cross-session rejection, typed 413, chunked body without Content-Length, mid-body abort with partial cleanup, uppercase-scheme URI rejection.packages/client:bun run generate(no hand edits to generated files) andbun test.Screenshots / recordings
Not a UI change.
Checklist