Repository navigation
fix(core): delete blobs a week after they were written - #65671
Conversation
There was a problem hiding this comment.
The change works. I ran the updated video-generation.test.ts against the base code and it fails because the job's blobs are still there after 8 days. With this PR it passes. The video-generation and tool-video-generate tests pass with core's test script, and tsc in core is clean. Removing blobs is safe in the cleanup path: blobs.remove ignores errors and a missing file, and only completed jobs have blobs to remove.
Public API: only behaviour and docs on experimental endpoints. GET /api/experimental/generate/video/:id now keeps a finished job for 7 days instead of 24 h, and the experimental.generate.video.get description in the OpenAPI spec says so. Blobs of completed video jobs, read through GET /api/experimental/blob/:id, are now deleted after 7 days instead of being kept for good. A client that keeps a blob ID longer than a week now gets 404. Since these endpoints are marked experimental, that seems acceptable.
One concern, inline: the test now takes ~18s, up from ~4s.
packages/core/test/video-generation.test.ts:111: Because this runs inside a live app,TestClock.adjust("8 days")fires every 5-second poll in between, about 138k ticks. The test now takes ~18s locally, up from ~4s on base. That's past Bun's 5s default and about 60% of core's 30s script timeout, so slower CI runners could time out. You can make it fast by advancing the clock while no poller is running. Close the second app, then doyield* TestClock.adjust("8 days"), then check deletion in a freshapp(dir, state). I tried this locally: the file runs in ~2.3s and still passes.
There was a problem hiding this comment.
My earlier point is addressed: the video test is back to its base version and no longer steps through 8 days of polls. The new commits look sound.
I ran blob-store, video-generation and tool-video-generate in core and they pass. With the cleanup call taken out, the new blob-store.test.ts fails, so it checks the fix. tsc in core is clean. The cleanup reuses FileRetention.cleanup and only touches blob_* files. This file blob store is used only for generated videos, and video records expire after 24 h, so they never point at a deleted blob.
Public API: only the experimental.blob.get description changes, from "kept until removed" to "deleted a week after it was stored". GET /api/experimental/blob/:id now returns 404 for blobs older than 7 days. The endpoint is experimental, so this is acceptable. No new concerns.
Issue for this PR
None.
Type of change
What does this PR do?
Blobs are no longer kept forever. The blob store now deletes each blob a week after it was written, whatever stored it, the same way tool output already cleans up its files. Video job records keep their 24-hour lifetime.
Nothing ever removed a blob before, and every video the agent tool made is stored twice (blob plus the copy in the project), so
<data>/blobsonly grew. With video headed for on-by-default that adds up quickly.The store owns the lifetime rather than the video jobs, so it also catches blobs no job accounts for: a download interrupted mid-write, or a record that couldn't be read. On start and then hourly,
BlobStorelists<data>/blobs/blob_*and removes files older thanRETENTION(7 days) with the existingFileRetention.cleanup, by modification time.Trade-off: a client that kept a blob ID gets 404 from
GET /api/experimental/blob/:idafter a week. Copies the agent tool saved into a project are untouched. The blob route's description says so.How did you verify your code works?
blob-store.test.ts: a blob whose file is older than a week is gone after the store starts, and a fresh one stays. It fails without the cleanup.video-generationandtool-video-generatetests in core, andvideo-generate.test.tsin server, pass.bun run checkat the root, andtscin core.Screenshots / recordings
None.
Checklist
Added by the opencode bot (AI-generated).
Public API: blobs served by the experimental blob endpoint are now deleted 7 days after they were written, instead of being kept for good (description of experimental.blob.get updated)