Public: anyone can read this; the crew can change it.
One BlobStore: promote src/snapshot/store.ts to a shared module with streaming, range reads and presigned URLs #16638
Check · Review · Land · Live done — Landed and live in production.
I merged main into the branch and pushed it. The 109 backup, snapshot, drill, mirror, restore and blob test files pass: 709 pass, 0 fail. tsc --noEmit is clean for the blob, snapshot, backups, destination and drill files.
shipped production is serving it deploy 964a8fe
2 earlier comments
I merged main into the branch and pushed it. The 109 backup, snapshot, drill, mirror, restore and blob test files pass: 709 pass, 0 fail. tsc --noEmit is clean for the blob, snapshot, backups, destination and drill files. It still reports errors elsewhere (missing happy-dom and @vscode/ripgrep modules, latin1 encoding types). I did not run the full suite, because the forge runs it on the push.
What the merge did
- Thirteen files conflicted. Almost all were the import-path change from
snapshot/store.tstoblob/store.ts, so I tookmain's version of each and re-applied the path change. src/snapshot/store.tshad been edited onmainwhile this branch moved it. I appliedmain's edits tosrc/blob/store.ts, so it keeps both sides:- from
main: the line meter, put aborts at the deadline, a retry deadline that follows the measured line, and the remake spec; - from this branch:
BlobStorewith streamed puts, byte ranges, presigned URLs and the storage-class hint.
- from
put's third argument is now either anAbortSignalorPutOptions, andPutOptionsgainedsignal.main's snapshot-code callers and test stores passed a bare signal, and that still works.- On S3, a plain put goes through the presigned
fetchso it can be aborted. A put with a storage class or content type goes throughclient.write, which sends that header but cannot be aborted. That deadline still bounds it. src/snapshot/line.tsmoved tosrc/blob/line.ts, because the store imports it.- In
test/snapshot-put-abort.test.tsI changed only how the test reads the signal, to match the new type. Intest/blob-store.test.tsI replaced anas nevercast that the gate refuses withas unknown as PresignRequest.
Cleanup: bun scripts/gate.ts --fix had rewrapped comments in about 1,500 files this pull doesn't own, and the earlier path rewrite had changed fixture strings in test/check-tiers.test.ts. I restored all of those from main and re-applied only the import changes, so the diff against main is now 122 files.
Gate warnings still open
- The "both doors" and "look pages" rules would still refuse this pull. I answered them with
No door:andNo look:lines in commit messages, plus aTry:line naming something to open on the preview. The gate may not accept those as written. - The gate also flags a
gatehelper intest/blob-store.test.tsas near-identical to one intest/snapshot-store.test.ts. I left it.
To try it: run bun test on the blob and snapshot test files, or open the Backups page on the preview.
🤖 Generated with Claude Code
src/snapshot/store.ts is now src/blob/store.ts, with a BlobStore beside the small Store shape snapshots use. I did not do the "finished run logs and attachments archive to it" part of the issue (see "Not done" below). I couldn't run the full suite here, so the rest rests on the forge's check.
What changed
- Move: every importer, old and new, points at
src/blob/store.ts. - Rebuilt on current main: main had changed the store since this branch was cut: an abort signal on
put, the line meter, remake specs, and a put through a presigned URL. I re-landed the move andBlobStoreon that file. BlobStoreadds:putof aBlob, which streams from disk and can be retried.putStream, for a body of unknown length: multipart on a bucket, temp-and-rename in a directory.size,getRange, andgetStreamwith an optional range.presignfor GET and PUT, signed locally, 1 s to 7 days. A directory has none.- A storage-class hint:
hotsends nothing,infrequentisSTANDARD_IA,archiveisDEEP_ARCHIVE.
- Retries and checks:
withRetrieskeeps aBlobStoreaBlobStore. Keys, ranges and presign requests are checked at the boundary. putsignature:put(key, body, signal?, options?). Main's(key, body, signal)calls andsnapshot-put-abort.test.tsare untouched, and the class and type ride in the fourth argument.- Default put: it is still main's presigned
fetchPUT, so snapshots send the same request as before. A put that asks for a class or type goes through the S3 client, because Bun puts the class in the query string and I could not confirm buckets honour that. That path can't be aborted, so a deadline abandons it instead. - Docs:
docs/BLOBS.mdand aCLAUDE.mdpointer. - Reused:
lineMeter/measuredDeadlineMs,durationWordsands3Where, all already in main's store. No new function repeats an existing one.
An earlier push of this branch. The fork already held an earlier merge of this branch, built on an older main, with put taking options or a signal as one union argument and an edit to snapshot-put-abort.test.ts. I merged it with my tree standing, so history stays linear and nothing was forced. That tree drops its test edit and its union signature. Say if you would rather have that shape.
Tests
- Passing:
bun x tsc --noEmitis clean andbun scripts/gate.tshas no failing rule (notes only: comment width, one duplicate-looking test helper). The 99 tests acrossblob-store,blob-store-s3,check-tiers,snapshot-put-abortandsnapshot-uploadspass. - S3 on the wire: the real
Bun.S3Clientruns against a fake bucket on loopback. - Changed expectation: the default-put wire test no longer expects a content type. It now asserts a PUT with no storage class.
- Not run: the full suite,
bun scripts/fast.tsreturned "diff too broad" with exit 2, and the sandbox runs no unix-socket suites. Nothing outside the changed files was run, so the forge's check is the full run. - Before the rebase:
snapshot-destination.test.tsfailed twice on the branch while it was still on the old base, and it failed the same way on that base itself (five-second connection test, no refresh meta). It passed after rebuilding on current main.
Not done
- Finished run logs and attachments don't archive to the store yet. That is the second half of the issue's description. The steward note scoped this pull to the promotion, with everything else in #4481 waiting on it.
- No page, terminal screen or setting uses the new methods yet, so
BlobStoreis reachable only throughs3StoreanddirStore. The gate's "both doors" rule is waived in the commit withNo door:.
Try it: bun test test/blob-store.test.ts test/blob-store-s3.test.ts test/snapshot-store.test.ts. On the preview, open /settings/security/controls and confirm the destination and its encryption line read as before. Only import paths changed in that page.
Local main in this clone is far behind origin/main, and the working tree can't be written at src/.mcp.json and src/web/.mcp.json. So I rebuilt and tested the merge in a scratch clone and pushed that.
🤖 Generated with Claude Code
Six of the eight failures were the move to src/blob/store.ts leaving other files pointing at the old path, and I've fixed those. The five test files that covered them now pass (66 tests), and bun x tsc --noEmit is clean. The gate exits 0 but prints a note that test/blob-store.test.ts and test/snapshot-store.test.ts are 0.81 alike. That is a note, not a failure, and I left it. I did not run the rest of the suite here.
- Stale paths in three tests:
test/outbound-sweep.test.ts,test/timers-named.test.tsandtest/recovery-doc.test.tsstill namedsrc/snapshot/store.ts. They now namesrc/blob/store.ts, so the presigned-PUT fetch and the timeout timer are listed against the new file and the S3 variables are read from it. - Docs index:
docs/BLOBS.mdwas on no index. I linked it fromdocs/REFERENCE.mdunder "Where the rest is" and gave it a line inDOC_LINES(src/view/doc_sections.ts), in the internals section. - Not fixed — "two processes on one data directory…":
test/overlap.test.tsis also red on main at 6166a7c, so the check did not count it against this pull. It still fails here and I did not touch it. - Not fixed — "a clone past its deadline…":
test/machine-rc.test.tspasses on a rerun, so it looks flaky. I changed nothing for it.
To try it, run bun test test/outbound-sweep.test.ts test/timers-named.test.ts test/recovery-doc.test.ts test/docs-link.test.ts test/readme-front-door.test.ts.
No high findings. This is a move plus a library, and no page, terminal screen or route is added. Because of that, the web and terminal doors, the design principles and README placement do not apply. Keys, ranges and presign requests are validated at the boundary, and a presigned URL carries only its signature, never the secret. The default put is unchanged from main. Follow-ups, none blocking:
- Medium:
putStreamand the class/type put throughclient.writehave no abort or deadline. A stalled bucket would hold them open. Give them one before the first caller lands. - Low:
dirStore.at()still carries its own..check besidecheckKey, and the S3get,listanddeleteskipcheckKey. Use one key check. - Low:
test/blob-store.test.tshas agatehelper near-identical to the one intest/snapshot-store.test.ts. Share it. size,getRange,getStream,presignandputStreamhave no caller yet, so they are exercised only by their own tests. The run-log and attachment archiving that would use them is correctly left to the next step of #4481.
I merged
maininto the branch and pushed it. The 109 backup, snapshot, drill, mirror, restore and blob test files pass: 709 pass, 0 fail.tsc --noEmitis clean for the blob, snapshot, backups, destination and drill files. It still reports errors elsewhere (missinghappy-domand@vscode/ripgrepmodules,latin1encoding types). I did not run the full suite, because the forge runs it on the push.What the merge did
snapshot/store.tstoblob/store.ts, so I tookmain's version of each and re-applied the path change.src/snapshot/store.tshad been edited onmainwhile this branch moved it. I appliedmain's edits tosrc/blob/store.ts, so it keeps both sides:main: the line meter, put aborts at the deadline, a retry deadline that follows the measured line, and the remake spec;BlobStorewith streamed puts, byte ranges, presigned URLs and the storage-class hint.put's third argument is now either anAbortSignalorPutOptions, andPutOptionsgainedsignal.main's snapshot-code callers and test stores passed a bare signal, and that still works.fetchso it can be aborted. A put with a storage class or content type goes throughclient.write, which sends that header but cannot be aborted. That deadline still bounds it.src/snapshot/line.tsmoved tosrc/blob/line.ts, because the store imports it.test/snapshot-put-abort.test.tsI changed only how the test reads the signal, to match the new type. Intest/blob-store.test.tsI replaced anas nevercast that the gate refuses withas unknown as PresignRequest.Cleanup:
bun scripts/gate.ts --fixhad rewrapped comments in about 1,500 files this pull doesn't own, and the earlier path rewrite had changed fixture strings intest/check-tiers.test.ts. I restored all of those frommainand re-applied only the import changes, so the diff againstmainis now 122 files.Gate warnings still open
No door:andNo look:lines in commit messages, plus aTry:line naming something to open on the preview. The gate may not accept those as written.gatehelper intest/blob-store.test.tsas near-identical to one intest/snapshot-store.test.ts. I left it.To try it: run
bun teston the blob and snapshot test files, or open the Backups page on the preview.🤖 Generated with Claude Code
Continues #16638