fix(daemon): keep a recording downloadable when its lease ends

Merged
AL
7h ago
+482-28

Summary

When a lease ends while a remote recording runs, teardown finishes the recording but drops the result. The export stays in the daemon's temp directory with no artifact id, so the client's later record stop fails (UNAUTHORIZED) and the files leak. This is the lease-end half of #2281 (ADR 0024 rule 1).

  • A leased session's teardown (lease expiry, release, or close) registers a committed remote-temp export and its telemetry as downloadable artifacts of the lease's tenant: delete after download, 15-minute expiry. If registration fails, it deletes the files. A failed finish keeps its forced cleanup.
  • GET /artifacts entries gain an optional sessionName (additive).
  • trackDownloadableArtifact returns the existing entry for a file the same tenant already has, so a record stop replay serves the same ids.
  • Local mode is unchanged.

14 files. Possible follow-up: an artifacts download <id> CLI command (HTTP clients can already GET /artifacts/<id>).

Validation

  • Head 3f2fddcf8: pnpm check:affected --run --head 3f2fddcf8 passed (exactCommit: true): format, lint, typecheck, layering, fallow, build, vitest-related, daemon-wire-compat, command-docs, docs-links, docs-prose.
  • New tests fail without the fix: 4 fail with the retention call disabled, and the replay test fails without the duplicate-id fix.
  • Coverage failed at c1a44778c on eager-closure-budgets (teardown statically imported the retention module). 3f2fddcf8 loads it on demand; the budget test passes locally.
  • CI still owes: Integration Tests, Coverage, Apple/Linux smoke at 3f2fddcf8.
  • No device run; the change is daemon artifact registration, not device behaviour.