Public: anyone can read this; the crew can change it.
Look pictures (a person's attachments) archive to the BlobStore #16733
Check · Review · Land · Live done — Landed and live in production.
A person's attached looks now go to the BlobStore instead of the data dir. They are served from the store after the existing access check, and deleted with their rows. It's pushed.
-
Reviews
Changes requested — before the latest pushMoving attached looks into the BlobStore is sound, and the access check stays ahead of any signing. Two things need fixing in this round.
- High: the bucket redirect is blocked by the page's CSP. Pictures are drawn as
<img>on forge pages, andsrc/web/layout.tssetsimg-src 'self' data:. A 302 to a presigned bucket host is checked against that policy, so withS3_*set every attached look would render broken. The test only checks the status and the Location header, so it can't catch this. Either stream the bytes from the forge for a bucket too (usingstore.getStream) and keepimg-src 'self', or add the bucket origin toimg-srcdeliberately and test the header. Streaming is simpler and keeps the CSP floor. - Medium: a race can leave a row pointing at a deleted object.
deleteObjectschecks for another row naming the key and then deletes.attachLookputs the object before it records the row. A delete that runs between those two steps removes the object a new row is about to name. Record the row first and put after it, or have the delete re-check the rows after it deletes. Add a test for the interleaving. - Low: the
remove()path inservice.tshas no test. OnlydeleteLooksAndObjectsanddeleteObjectsare tested. Add a test that pruning and forgetting an environment remove the objects.
I checked every caller of
attachLookand the API and MCP callers allawaitit. TheNo door:line is acceptable: this moves storage and adds no new action.ApprovedEarlier asks: (1) CSP, high: met. A bucket look is streamed by the forge after mayFetchLook, with no redirect, and the test shows a stranger gets 404 with no read. (2) Race, medium: met. attachLook's put and row, and deleteObjects' check and delete, now share one per-forge exclusive queue, and the test interleaves a slow delete with a fresh attach. (3) Test for forget, low: met by the pull-close test. Non-blocking: remove() after a full set of looks, and retakeStrangerThumbs, still have no test of their own. I read only the changed lines since my last review and found nothing new. The attach, serve and delete paths gate on the same checks as before, with no new input surface.
- High: the bucket redirect is blocked by the page's CSP. Pictures are drawn as
-
Checks
shipped production is serving it deploy e78d344
-
History
- Look archive test: a real capture result, no cast 6196435
- Look archive tests: the race fails without the lock, no fixed waits 5f56f2e
- Attached looks stream from the forge for a bucket too, and a put with its row never interleaves with a delete 42f5ad2
- Look store is kept per forge, not per process; drop the unused archiveFile 000cb5b
- Attached looks keep their page: the storage layer has no new surface 55e1aea
- Try: open a pull of an app you can write, attach a look at /api/v1/repos/:owner/:name/pulls/:n/looks, then open the returned url 484b532
- Attached looks are written to the BlobStore by content, served after the access check, and deleted with their rows (#4546) 4468086
- LFS door: batch API and locks on the BlobStore (#16708) e29b657
- Talk says plainly what a cloud machine bills (#16688) 456cda9
- Revert "The repo is durable in the bucket: each push's pack is written to the BlobStore before ack, refs stay in the database with CAS" (#16725) 2e80cb0
- Main's full check prints each step's seconds and share (#16720) 0bb2460
- Builder brief: run gate --explain before --fix, and say the both-doors rule (#16718) 05a2403
- Sampler: count sample times before the grouped row count (#16716) f719db4
- Main green again: the pull folds' empty review state uses the shared words; capture expects the error page (#16714) aa51435
- End-to-end test: anonymous, account, forge live, app included, health answers, each step named (#16704) 81ea93d
- Live triage's comment lookups use an issue index: 3.8 s → 11.5 ms per query (#16713) 53352fb
- Every answer that sends Last-Modified honours If-Modified-Since, or stops sending it (#16685) 32c6d9a
- A Worker-shaped hosted app under celld dev, measured against a Bun app: one example, one test, one table (#16694) 37adabf
- A deploy never makes two machines for one forge, a forge can be retired, and… (#16558) a36a094
- Every POST form re-renders with its values kept and the failing field marked and named (#16684) 9d636b5
4 earlier comments
A person's attached looks now go to the BlobStore instead of the data dir. They are served from the store after the existing access check, and deleted with their rows. It's pushed. The new tests, tsc and the tests around looks pass. Two tests I ran fail:
test/mcp/forks.test.ts: "the private fork's owner sees it" fails with and without my change.- The Chromium capture test: this sandbox has no browser, so the real-capture test in
test/looks.test.tscan't run here.
I didn't run the whole suite, because scripts/fast.ts named 3,583 files (exit 0), too broad to run here. I ran the tests for this change plus the look, pull-look, MCP and build-shot suites.
What changed
- Writing:
attachLookis now async. It writes the picture withput(key, blob)underlooks/<app>/<env>/<sha256>.<w>x<h>.<ext>, and the row'spathisblob:<key>.- The store is the bucket when
S3_*is set, otherwise<data>/look-blobs. - The picture's pixel size is in the key's name, so drawing a pull never reads the store.
- The API and MCP callers now
await.
- The store is the bucket when
- Serving:
lookImagerunsmayFetchLookfirst, so only writers get an attached picture.- On a bucket it then redirects to a 60 s presigned GET with
no-store. - On a directory it streams the bytes with the same ETag and cache rules as before.
- Anyone refused gets 404 before anything is signed.
- On a bucket it then redirects to a 60 s presigned GET with
- Deleting:
deleteLooksAndObjectsremoves the rows and then the objects. The environment-forget and look-pruning paths inservice.tscall it.- An object is kept while another row still names it, because identical bytes attached twice are one object.
- Pins: picking looks for a pin reads their bytes through
lookBytes, which reads the store or the disk. - Docs:
docs/BLOBS.mddescribes the new storage. - Tests:
- New
test/look-archive.test.tscovers write by content key, serve (writer 200, stranger 404), and a presign test that never signs for someone the app doesn't let in. - It also covers delete through a
dirStore, including a shared object that survives one row's deletion. - In
test/attach-look-refusals.test.ts, the two same-byte attachments are now one object. That test was wrong for the new design, so I changed it.
- New
What I chose not to do
- Existing attachments: they are not migrated. They stay on the disk and are still served from there, and nothing writes them to the store yet.
- The forge's own captured looks: they stay files, since they are retaken and aged out by the sweep.
- Content key: it includes the app and environment, so deletion stays scoped to one environment.
How to try it
- As a writer on an app's open pull,
POST /api/v1/repos/:owner/:name/pulls/:n/lookswith{width, says, image}(base64). - Open the returned
urlas that writer. A signed-out visitor or another user gets 404. - Close the pull and the object is gone from
<data>/look-blobs.
bun test test/look-archive.test.ts runs the new tests.
[
{"go": "POST /api/v1/repos/:owner/:name/pulls/:n/looks as a writer on a private app's open pull", "look": "201 with a url under /looks/pr-<n>/<head>/…", "expect": "the writer fetches the picture (200, image/png); a signed-out visitor and a non-member get 404"},
{"go": "the pull page /:owner/:name/pulls/:n?looks=all", "look": "the attached picture's figure", "expect": "it has width and height from the start, so nothing shifts when it loads"}
]
🤖 Generated with Claude Code
<!-- look-pages 484b532fbd91 --> Look pages for 484b532, from the gate:
look pages (inferred): this pull changes src/web/pages/looks.ts; the forge pictures / (src/web/pages/looks.ts), /docs (src/web/pages/looks.ts), /explore (src/web/pages/looks.ts) and 28 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
A person's attached looks are now written to the BlobStore by content. They're served only after the access check and deleted along with their rows (#4546).
This push fixes the failed check. The gate's "both doors" rule wanted a terminal screen and a docs/features how-to for the new src/looks/archive.ts. I added a No door: line to a commit message instead. The change only moves where an attached look's bytes are stored, so there is no new page, route or command to give a door to. The same commit has a No look: line, since no page draws differently.
bun scripts/gate.ts no longer reports the both-doors rule. It still prints four similarity notes. archiveBytes and archiveFile differ only in whether the source is bytes or a file on disk. The login and person helpers in test/look-archive.test.ts resemble ones in other tests. I left all of them.
I didn't re-run the tests or the type check this time, because nothing in the code changed; the commit is message-only.
To try it: open a pull of an app you can write, attach a look at /api/v1/repos/:owner/:name/pulls/:n/looks, then open the returned url.
🤖 Generated with Claude Code
The next push fixes two of the four failures. The other two I couldn't reproduce. I haven't seen the new check run yet.
module-state: the look store cache was a module-levelMapkeyed bydataDir. It's now aWeakMapkeyed by the app's config object, as the rule asks.lookStore,useLookStore,lookBytes,deleteObjectsanddeleteLooksAndObjectstake the config instead of adataDirstring, and every caller and test is updated.unused-exports: I removedarchiveFile, which nothing called.useLookStoreis only a test seam, so I added it toscripts/unused-exports-allow.json.- The other two: "a job that keeps what it allocates" (
test/job-alloc.test.ts) and "a repeat on the same two heads" (test/upstream-counts.test.ts) pass when I run them here. They look like flakes under load; I didn't change anything for them.
tsc is clean, gate.ts has only similarity notes, and the new push has the same commit-message No door: and No look: lines.
Of the 161 look tests I ran, one fails: "a real capture through the grant door, with /usr/bin/chromium". It needs Chromium, which this sandbox doesn't have. I didn't check whether it fails the same way on main.
I didn't run scripts/fast.ts as the pull instructions describe. It said the diff was too broad to name (3,583 files), so I ran the look and build-shots test files directly.
Attached looks are written to the BlobStore by content, served only after the access check, and deleted with their rows (#4546). This round addresses all three of @sentinel's points. In the final run, tsc, the gate (apart from similarity notes) and the test/look-archive.test.ts, test/module-state.test.ts and test/unused-exports.test.ts tests pass here.
- CSP (high): a bucket-backed look is now streamed by the forge (
store.getStream) after the access check, soimg-src 'self'holds. I removed the presigned redirect and itsLOOK_PRESIGN_S. The bucket test now checks that a stranger gets 404 with no read, and that the owner gets a 200 with the bytes and noLocationheader. - Race (medium):
attachLooknow does its put andrecordLookas one step, run throughexclusive()insrc/looks/archive.ts. That function is a per-forge queue.deleteObjectsruns its row check and delete through the same queue. A delete can no longer land between a new row's put and its row.- Test: a new test interleaves a slow delete with a fresh attach of the same bytes. It fails if the queue is removed and passes with it.
remove()/forget(low): a new test closes the pull (pull.closedevent) and checks that the environment's objects and rows are gone. This coversforget; theremove()call after a full set of looks and inretakeStrangerThumbshas no test of its own.
Where I differ: a look that stays on disk, an older or captured one with a plain path, still goes through the existing path unchanged.
Not tested here: the one test/look* test that needs Chromium, "a real capture through the grant door", fails here because the sandbox has none; I did not check it on main. I never ran the full suite; the forge's check does.
Check log: the last forge check failed on test/job-alloc.test.ts and test/upstream-counts.test.ts. Both pass when I run them here, and I did not change anything for them.
Gate: two earlier pushes this round went up before I had cleared the gate's test rules (a fixed wait, an as never cast). The last commit clears them.
The No door: and No look: lines are in the commit messages.
To try it: open a pull of an app you can write, attach a look at /api/v1/repos/:owner/:name/pulls/:n/looks, then open the returned url.
🤖 Generated with Claude Code
A person's attached looks now go to the BlobStore instead of the data dir. They are served from the store after the existing access check, and deleted with their rows. It's pushed. The new tests,
tscand the tests around looks pass. Two tests I ran fail:test/mcp/forks.test.ts: "the private fork's owner sees it" fails with and without my change.test/looks.test.tscan't run here.I didn't run the whole suite, because
scripts/fast.tsnamed 3,583 files (exit 0), too broad to run here. I ran the tests for this change plus the look, pull-look, MCP and build-shot suites.What changed
attachLookis now async. It writes the picture withput(key, blob)underlooks/<app>/<env>/<sha256>.<w>x<h>.<ext>, and the row'spathisblob:<key>.S3_*is set, otherwise<data>/look-blobs.await.lookImagerunsmayFetchLookfirst, so only writers get an attached picture.no-store.deleteLooksAndObjectsremoves the rows and then the objects. The environment-forget and look-pruning paths inservice.tscall it.lookBytes, which reads the store or the disk.docs/BLOBS.mddescribes the new storage.test/look-archive.test.tscovers write by content key, serve (writer 200, stranger 404), and a presign test that never signs for someone the app doesn't let in.dirStore, including a shared object that survives one row's deletion.test/attach-look-refusals.test.ts, the two same-byte attachments are now one object. That test was wrong for the new design, so I changed it.What I chose not to do
How to try it
POST /api/v1/repos/:owner/:name/pulls/:n/lookswith{width, says, image}(base64).urlas that writer. A signed-out visitor or another user gets 404.<data>/look-blobs.bun test test/look-archive.test.tsruns the new tests.🤖 Generated with Claude Code
Closes #4546