fix(daemon): cancel artifact preparation and refresh failed builds

Merged
TH
1d ago
+633-141

Summary

Follow up on #4165: directory archives count inventory and download waiters together, so a client disconnect preserves another caller's build. Cleanup/expiry now aborts an inventory-only build once no active download remains, retaining its source until tar settles and then removing it from inventory.

Share typed HTTP disconnect handling across downloads, human-control and RPC; retain observable completion/retry coverage and the maintainer ledger rationales. Thirteen files changed; scope includes the requested helper consumers. Re-registration ownership is unchanged.

Validation

  • Base 47d1ac7e0a76b1c35690b0d3b126b6a05257c2a4 plus final resource tests: 2 failed/17 passed (cleanup and expiry left tar un-aborted); fixed: 19 passed.
  • Tested head 9e4deaeb4d816fb00023755c5006295839bee11e: 99 focused tests passed (57 functional + 42 wire). Mutations detect missing abort, wrong expiry reason and stale cache reuse. Live inventory-only cleanup confirms process exit, deferred deletion, empty listing and 404/RESOURCE_EXPIRED.
  • pnpm format, pnpm check:quick, and foreground affected gate passed. Receipt run-KWPr58: exact commit, unchanged checkout; 17,019 unit passed/1 skipped and 304 related passed.
  • The ledger expiry sentence is verified by the fix; no digest changed. Cubic/Sentinel threads have replies and are resolved.
  • Hosted CI, Coverage, Integration Tests and Apple / Smoke Tests remain GitHub obligations. New-head checks/reviews pending; no known unresolved local defect.

Regression, mutation and live evidence.