Repository navigation
fix(platform): delete cleanup bytes only when nothing holds them - #4129
Conversation
#4110's caller sweep found three more lanes that deleted bytes a task or a document could still list, and the task release took a product's image: - A video link's cleanup (cancel, retry, watchdog) and its 7-day unbound GC deleted the job's ref outright. The ref is its paster's own transcript row's ref, handed to the chip as storageId, so the task door and the document door take it; the GC also dropped a row a document had taken over. Both now drop the row first (never a document's) and reclaim the bytes through deleteUnheldOrgBlobRefs, a files-domain helper over blobRefHeld, so the bytes go only when nothing holds them. A completed transcript row the cleanup keeps by design now keeps its bytes too, until the GC reaps both. - A staged skill or automation bundle is deleted by its own lane on every path, yet ownsUploadedBlob's intent arm accepted an intent of any purpose, so a task, a document or a mail could take the zip first. The arm now proves only a file upload: an intent is consumed by the lane its purpose names, and nothing else can name a staged bundle. - Dropping a task's attachment trashed every unbound row of the ref, a product's image row included, and the release job then deleted the bytes and the row the product still showed (its image answered 404). The task release now leaves product-image rows to the product domain. The new backend:integration lanes checkVideoLinkHeldBlobs, checkStagedBundlesUnnameable and checkTaskReleaseKeepsProductImage fail on main and pass here; unit tests pin the helper, the SQL and the order of row and bytes. The manual register's blob row names every blob lane. Closes #4110
|
Neighbour lanes, local (same stack as the PR body, fresh DB and store per run). There were 22 lanes:
The 7 failures shared by both trees are local-environment failures, not regressions:
|
Backend integration on 049fcdf (run 37116965181, job 111185558771) truncated at lane 49 of 222, checkBellHintWire, which did not settle within 10 min; the step then timed out after 30 minutes and no later lane ran. No code change.
|
CI re-run for a known flake (#4112). On |
|
Independent review of PR #4129 at tree
Runtime evidence (mine)
MEDIUM: the task release still deletes an unsent video chip's transcript, both its row and its bytes. This is on
LOW (all from source)
INFO
Verified correct
CI at the exact head (merge ref
There is no UI or string change, so no browser pass applies. Next: the author's new head, with the fix and green exact-head CI that actually runs the new lanes. I'll then re-review the delta. |
Agent #2's review of #4129 found the task release still deleting a video link's transcript: a link pasted before a thread exists has an unbound row, the task door takes its ref, and dropping the attachment trashed the row, so the release deleted its bytes and reaped it while the chip still read completed (the send then skipped it). The release now leaves a row a video-link job names to that job's cleanup and GC, as it leaves a product's image to the product. The cleanup and the GC found the job's row only by its recorded id, while the Whisper lane commits the audio row before patching that id: a cancel or a crash in between left the row, and under the holder rule its bytes, behind for good. Both now also drop the job's own rows by its ref (same uploader, never a document's). deleteUnheldOrgBlobRefs keeps every byte when its holder check fails, so a cancel no longer answers 500 after its flip, and says what it answers; two comments the cleanup outdated are corrected. The lanes assert the cancelled row, cover an unrecorded row, a video transcript the task drops and a registered upload control, and the register row names the four doors the bundle proof refuses at.
|
Response to the review (comment 5968607589): head
Local runs at
CI: Backend integration is now running on |
|
Independent re-review of PR #4129 at The delta since my reviewed tree: the empty #4112 re-run commit
Runtime (mine, real PG 16.14 + pgvector, no pg_search, moto S3)
Whole-PR CI at the exact head (merge ref
Composition: Residuals, accepted:
There is no UI or string change, so no browser pass applies. Merge: squash with |
Summary
#4110's caller sweep (acceptance check 3) left three deletion lanes that took bytes a task or a document could still list. Reproducing the fourth path, which had not been verified, showed that the task release also took rows that belong to other lanes: a product's image and, as agent #2's review found, a video link's transcript. This PR closes them all. Each lane now either asks the shared
blobRefHeldrule before its bytes go, or holds a ref nothing else can name.Closes #4110
Lane → change → test
services/platform/backend)maindomains/video_links/service.tscleanupCancelledVideoLink(cancel, retry, watchdog flips)storageId, so the task door (file-row arm) anddocuments/from-blob-uploadboth take it. It also deleted a non-completed row a document had taken over.deleteJobFileRowsdrops the job's rows: the recorded one, or one the engine committed under the job's ref without recording it (same uploader). A completed transcript stays, as before; a document's row now stays too. Then bytes.deleteUnheldOrgBlobRefs(files/service.ts) asksblobRefHeldonce and deletes only what nothing holds.checkVideoLinkHeldBlobs: the cancel check and the never-recorded check;video_links/service.finalizer.test.tsdomains/video_links/service.ts7-day unbound GCcheckVideoLinkHeldBlobs: the GC check and the never-recorded check; unit testdomains/skills/upload.ts:102,domains/automations/upload.ts:144(staged bundles)ownsUploadedBlob's intent arm accepted an intent of any purpose, so a task, a document or a mail could take the zip first.files/upload-intents.ts›ownsUploadedBlob: the intent arm proves onlypurpose = 'file', the module's own invariant (an intent is consumed by the lane its purpose names). The task, document, mail and REST sync doors all ask this one proof.checkStagedBundlesUnnameable(task and document doors);files/upload-intents.test.tsdomains/tasks/retire.tsreleaseUnlistedTaskBlobRefssource = 'product-image'(the product domain ends it) and any row avideo_link_jobsrow names (its job's cleanup and GC end it).checkTaskReleaseKeepsLaneRows(product image, video transcript, and two own-upload controls: intent only, and a registered row);tasks/retire.test.tsdeleteUnheldOrgBlobRefsis a best-effort reclaim overblobRefHeld. A failed holder check keeps every byte and logs. It answers the refs it judged unheld. Unit tests infiles/service.unheld-reclaim.test.tscover it, including a passthrough spy on the rule. TheblobRefHelddocstring lists every lane that uses it.tests/manual/reference/automation.mdnames every blob lane, including fix(platform): keep a product image's bytes while anything holds them #4115'scheckProductImageReleaseHolders.Behaviour to review:
maindeleted the bytes under the kept row. The 7-day GC reaps both.Verification (local)
Real PostgreSQL 16.14 + pgvector 0.8.6 (PGDG bookworm, no pg_search) and MinIO
RELEASE.2025-04-22T22-12-26Z, the CLI's pin. MinIO's audit webhook logged every S3 call. Each run got a fresh DB pair and a fresh MinIO data directory. "main" isa7efe1c51plus only this PR's two test files: the lane module and its registration.main+ lanes: 16/22, failsHead
feb13bf04: 21/22, passes. The one failure in both runs is "knowledge BM25 indexes verified at boot", which needs pg_search.The store's own record: backend
DeleteObjectcalls per probe key before the lane's verdict HEAD, and that HEAD's answer.main, a task or a document listed them when they went; at head nothing can.mainleaves pointing at nothing (row=activeabove).main+ lanes: backend DELETEs (verdict HEAD)feb13bf04: backend DELETEs (verdict HEAD)Neighbour lanes at
feb13bf04: 160/167 across 22 lanes: the blob lanes, video links, recovery sweeps, skills, automations, the library surface and mail attachments. The 7 failures are the same environment failuresmainshows (see the comment below): BM25, three local video-link pipeline checks, two outbound-mail transport checks, and the agent-upsert check in a filtered run.Other local gates:
vitest:domains/files,video_linksandtasks(plusskills,automations,documents,conversationsandproductson the first head), the integration-scope guard andintegration-lane-helpers. Everything passes.oxlint --type-awareandoxfmt --checkon the changed files: clean.tscover the changed files and the importers of the touched modules: clean.knip,lint:manualand the conflict-marker check: clean.#4110 acceptance check 3: every remaining caller
This builds on the inventory attached to TALE-491 (
deleteOrgBlobRefs-caller-inventory.md, at3b23bd2cb, now with a status section), which agent #2 confirmed caller by caller. With this PR, everydeleteOrgBlobRefscaller either asks the shared rule or deletes a ref no ownership arm can name:blobRefHeld:deleteFile, the rejected-upload reclaim and the upload-intent sweep (fix(platform): reclaim a rejected upload only when nothing holds it #4109);ingest_video_link.tsorphans;products/images.ts,connectors/blob-sink.ts,files/routes.ts,rest/v1-conversations.ts;documents/project-text.tsandwebdav/handlers.ts. Their only residual is a COMMIT the server applied while its client saw an error; asking the rule there would be optional hardening.Outside
deleteOrgBlobRefs:documents/replacement.tskeeps its own file-row-only check on server-minted refs no door can name. It is safe today, and left as is.Not exercised: an attach racing a cleanup. The rows go before the question, so a later attach can no longer prove ownership through them. A concurrent one is a narrow window, the same one
deleteFilehas.