fix: bind upload ownership and shared staging capacity
Closed as superseded by #5344 on the 0.22 remediation line. Continue review and implementation there. Historical validation below remains attributed to its original commits; closure does not claim the replacements are merge-ready.
Summary
Use one staging budget for legacy uploads, resumable uploads, and retained artifacts. Keep each reservation charged until its staging directory is removed. The first ticket close owns removal and the daemon logs the first deferred cleanup. Stacked on #5278.
Before / after
- Failed removal left capacity charged after the upload entry expired. The shared cleanup path retries until removal succeeds or the directory is absent.
- Legacy file uploads stream with chunked framing, and the daemon charges bytes as they arrive. Prepared bundle archives retain fixed-length framing.
- Preflight, finalize, and legacy capacity refusals preserve
UPLOAD_CAPACITY_EXCEEDEDand retriable classification.
Validation
At 0cd48fbd30, all five upload patches match e3ba3f57bc by range-diff after rebasing onto #5278 fe6452bc3f. Hosted checks are running. At e3ba3f57bc, all 19 hosted checks passed.
At ad64964df7, 19 hosted checks completed without failures. All 23 tests in packages/daemon/src/server/__tests__/resumable-upload.test.ts passed. The mocked rollback failure exercises an initial removal and a scheduled retry. At 024f263a10, 51 wire and mutation tests passed after the upload header types and control-request mutation were updated. The emitted headers and protocol 4 are unchanged by that update.
At c125cd3375, an Android emulator installed an 87 MB APK through a remote proxy lease. This receipt predates the current stack.
20313d1e5a passed merge-tree. CI pending.