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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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.

Notes

shipped production is serving it deploy 1919ee3

opened this

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.ts to blob/store.ts, so I took main's version of each and re-applied the path change.
  • src/snapshot/store.ts had been edited on main while this branch moved it. I applied main's edits to src/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: BlobStore with streamed puts, byte ranges, presigned URLs and the storage-class hint.
  • put's third argument is now either an AbortSignal or PutOptions, and PutOptions gained signal. 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 fetch so it can be aborted. A put with a storage class or content type goes through client.write, which sends that header but cannot be aborted. That deadline still bounds it.
  • src/snapshot/line.ts moved to src/blob/line.ts, because the store imports it.
  • In test/snapshot-put-abort.test.ts I changed only how the test reads the signal, to match the new type. In test/blob-store.test.ts I replaced an as never cast that the gate refuses with as 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: and No look: lines in commit messages, plus a Try: line naming something to open on the preview. The gate may not accept those as written.
  • The gate also flags a gate helper in test/blob-store.test.ts as near-identical to one in test/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

Continues #16638

2 earlier comments
commented

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.ts to blob/store.ts, so I took main's version of each and re-applied the path change.
  • src/snapshot/store.ts had been edited on main while this branch moved it. I applied main's edits to src/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: BlobStore with streamed puts, byte ranges, presigned URLs and the storage-class hint.
  • put's third argument is now either an AbortSignal or PutOptions, and PutOptions gained signal. 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 fetch so it can be aborted. A put with a storage class or content type goes through client.write, which sends that header but cannot be aborted. That deadline still bounds it.
  • src/snapshot/line.ts moved to src/blob/line.ts, because the store imports it.
  • In test/snapshot-put-abort.test.ts I changed only how the test reads the signal, to match the new type. In test/blob-store.test.ts I replaced an as never cast that the gate refuses with as 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: and No look: lines in commit messages, plus a Try: line naming something to open on the preview. The gate may not accept those as written.
  • The gate also flags a gate helper in test/blob-store.test.ts as near-identical to one in test/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

commented

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 and BlobStore on that file.
  • BlobStore adds:
    • put of a Blob, 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, and getStream with an optional range.
    • presign for GET and PUT, signed locally, 1 s to 7 days. A directory has none.
    • A storage-class hint: hot sends nothing, infrequent is STANDARD_IA, archive is DEEP_ARCHIVE.
  • Retries and checks: withRetries keeps a BlobStore a BlobStore. Keys, ranges and presign requests are checked at the boundary.
  • put signature: put(key, body, signal?, options?). Main's (key, body, signal) calls and snapshot-put-abort.test.ts are untouched, and the class and type ride in the fourth argument.
  • Default put: it is still main's presigned fetch PUT, 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.md and a CLAUDE.md pointer.
  • Reused: lineMeter/measuredDeadlineMs, durationWords and s3Where, 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 --noEmit is clean and bun scripts/gate.ts has no failing rule (notes only: comment width, one duplicate-looking test helper). The 99 tests across blob-store, blob-store-s3, check-tiers, snapshot-put-abort and snapshot-uploads pass.
  • S3 on the wire: the real Bun.S3Client runs 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.ts returned "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.ts failed 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 BlobStore is reachable only through s3Store and dirStore. The gate's "both doors" rule is waived in the commit with No 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

commented

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.ts and test/recovery-doc.test.ts still named src/snapshot/store.ts. They now name src/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.md was on no index. I linked it from docs/REFERENCE.md under "Where the rest is" and gave it a line in DOC_LINES (src/view/doc_sections.ts), in the internals section.
  • Not fixed — "two processes on one data directory…": test/overlap.test.ts is 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.ts passes 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.

Approved

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: putStream and the class/type put through client.write have 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 beside checkKey, and the S3 get, list and delete skip checkKey. Use one key check.
  • Low: test/blob-store.test.ts has a gate helper near-identical to the one in test/snapshot-store.test.ts. Share it.
  • size, getRange, getStream, presign and putStream have 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.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs