Repository navigation
fix(daemon): keep a recording downloadable when its lease ends - #3955
Conversation
Lease-end teardown finished an active recording but dropped the completion, so a remote caller's export stayed in the daemon temp directory with no artifact id: the client's later record stop failed with the lease gone and the files leaked. - 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, with the standard delete-after-download and 15-minute expiry. If registration fails, it deletes the files. A failed finish keeps its forced cleanup and registers nothing. - The /artifacts inventory carries an optional public sessionName so clients sharing a tenant can find their own recording. - trackDownloadableArtifact returns the entry that already tracks a file for the same tenant unchanged, so a record stop replay serves the same ids instead of two ids racing to delete one file. - record stop artifacts are built in one place for the reply and the teardown. Lease-end half of callstack#2281.
There was a problem hiding this comment.
All reported issues were addressed across 14 files
Reply to a comment to ask cubic a question or push back. It learns from your replies.
View guided diff | Re-trigger cubic
- session-teardown.ts imports the retention module only when the session holds a lease, so the daemon entry keeps its merge-base eager closure (eager-closure-budgets, which failed the Coverage job). - The registration-failure rollback removes each file best-effort, so one failed removal does not leak the rest. - The unleased-teardown test also checks the tenant inventory. - Docs: ADR 0007 names close as a teardown that keeps the recording, ADR 0024 scopes forced cleanup to the teardown finish, and the remote-proxy sessionName wording matches the contract.
|
At c1a4477 one code fix is needed before merge, and the Coverage failure needs a look. The Coverage job ( Not blocking, and fine to take or leave: On the open inline threads: the one on I read the code only and did not run the new tests or |
|
The PR is ready at 3f2fddc. The rollback concern from the earlier review (#3955 (comment)) and the Coverage failure are both fixed: the delta removes the static import of leased-recording-retention.ts that tripped the daemon eager-closure budget, and all 14 checks pass at this commit. There are no conflicts. Not blocking: the new private removeBestEffort in packages/daemon/src/sessions/leased-recording-retention.ts:61 repeats the one in artifact-tracking.ts:357, and its rollback cannot run because trackDownloadableArtifact has no throwing path (artifact-tracking.ts:99-122), so you could drop the try/catch or export the shared helper. The caller in session-teardown.ts:208 also checks ref.session.lease before the dynamic import, and retainLeasedSessionRecording checks it again at leased-recording-retention.ts:26, so one of the two could go. Take or leave both. The cubic-dev-ai threads no longer apply and can be resolved. Fixed at this commit: the tenant inventory assertion (#3955 (comment)), the ADR 0024 cleanup scope (#3955 (comment)), the per-rmSync try/catch (#3955 (comment)), the remote-proxy.md wording (#3955 (comment)), the session-tenant-scope.ts comment (#3955 (comment)) and the ADR 0007 wording (#3955 (comment)). Benign: teardown holds the live recording handle and the rollback is unreachable (#3955 (comment)), and retention runs on every teardown of a leased session, so "close" in the changeset is accurate (#3955 (comment)). I read the code only and did not run the tests locally. No test drives the lease sweeper or the close command end to end. |
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 stopfails (UNAUTHORIZED) and the files leak. This is the lease-end half of #2281 (ADR 0024 rule 1).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 /artifactsentries gain an optionalsessionName(additive).trackDownloadableArtifactreturns the existing entry for a file the same tenant already has, so arecord stopreplay serves the same ids.14 files. Possible follow-up: an
artifacts download <id>CLI command (HTTP clients can alreadyGET /artifacts/<id>).Validation
3f2fddcf8:pnpm check:affected --run --head 3f2fddcf8passed (exactCommit: true): format, lint, typecheck, layering, fallow, build, vitest-related, daemon-wire-compat, command-docs, docs-links, docs-prose.c1a44778coneager-closure-budgets(teardown statically imported the retention module).3f2fddcf8loads it on demand; the budget test passes locally.3f2fddcf8.