Skip to content

fix(daemon): collect a suite recording its script closed early - #5428

Open
thymikee wants to merge 2 commits into
0.22from
t3/recording-artifact-proxy-repro
Open

thymikee wants to merge 2 commits into
0.22from
t3/recording-artifact-proxy-repro

Conversation

@thymikee

@thymikee thymikee commented Dec 6, 2026 •

Copy link
Copy Markdown
Member

Summary

A remote test --record-video whose script closes its own session delivers its recording (#5421).

Suite cleanup closes the attempt session it owns. A script that already ran close retires it inside the replay action, so cleanup found no live session and returned before collecting the export that close's teardown had committed: success: true, a test-artifacts download with no recording.mp4, no recordingArtifacts, no warning, and a valid MP4 left on the daemon host.

Cleanup now settles against the attempt's last pinned ref, which still names the session directory and the lifetime guarding that committed export. ADR 0024 ownership, expiry and lease scope are unchanged.

Before / after

  • Remote suite ending in close: base gave no recordingArtifacts and copiedArtifacts: screenshot.png. Head delivers recording.mp4 plus telemetry and names both ids.
  • Same command without close: unchanged, both files once.
  • Timeout, copy-failure and close-failure suites: unchanged refusal and warning.

Validation

Head 0d6d9e79cb, base 17aadacb13 (origin/0.22). Production +24/-8.

  • pnpm check:affected --run --base origin/0.22 --head 0d6d9e79cb: all runnable checks passed, exactCommit=true. Receipt .tmp/validation/run-oYrrM9/receipt.json.
  • The regression fails at base. At a33ad0d2ac, the expanded test verifies delivery of both the MP4 and telemetry. The test and typecheck passed.
  • Live: branch-built 0.22.0-dev daemon, proxy and client state dir; iPhone 17 Pro, iOS 27.0. The report was 27.2.

CI owns Coverage and device lanes.

A remote `test --record-video` whose script ends with `close` answered
`success: true` with no `recordingArtifacts`, and the attempt folder in the
`test-artifacts` download had no `recording.mp4`, while the MP4 stayed on the
daemon host.

That close retires the attempt session inside the replay action, so suite
cleanup resolved no session for the attempt and returned before collecting the
export its close had just committed. Cleanup now settles against the attempt's
last pinned ref, which still names the session directory and the lifetime the
committed export is guarded by, and the attempt keeps that ref instead of
overwriting it with an unresolvable pin.
@github-actions

github-actions Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.35 MB 5.35 MB +93 B
Package (unpacked) 5.35 MB 5.35 MB +93 B
Package (download) 1.64 MB 1.64 MB +17 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 12.3 ms 12.9 ms +0.6 ms
CLI --help 22.4 ms 22.4 ms +0.0 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@thymikee

thymikee commented Dec 6, 2026

Copy link
Copy Markdown
Member Author

The code in 0d6d9e7 looks ready: the replay cleanup now collects a suite recording that its script closed early, and the new unit test covers that route. Not blocking, and fine to take or leave: the closed.lifetime !== lifetime check at https://github.com/callstack/agent-device/blob/0d6d9e7/packages/daemon/src/sessions/handlers/session-replay-command.ts#L294 cannot fire, so reading settled(name) once at the top of cleanupSession and using that ref for both the lifetime and the collection would be simpler; and, as an adjacent pre-existing case, a script that runs close then open in one attempt makes collectSuiteRecordingOutputs consume its commit token at https://github.com/callstack/agent-device/blob/0d6d9e7/packages/daemon/src/sessions/recording-outputs.ts#L128 and then return an empty list on the lifetime mismatch with no warning, which a follow-up issue could cover. No conflicts. CI is still pending: the code jobs are in progress, and the Body rules failure came from a run that predates the body edit. Before merge, Body rules must pass on the current body and the code lanes must finish green. Not verified here: the live run is the author's report with no pasted output, and it ran on iOS 27.0 where the issue reported 27.2; whether a lease-expiry reap of the attempt session commits a suite token through the same teardown; and whether attempt session names are unique per suite and retry.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Dec 6, 2026
@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Dec 6, 2026
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of a33ad0d

No open findings.

Reviewed with this repository's own Sentinel configuration (202d13506363).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

thymikee commented Dec 6, 2026

Copy link
Copy Markdown
Member Author

This PR is ready at a33ad0d. The code looks correct, and the production route is unchanged since the earlier head, so the change is only the stronger test, which now checks the archived telemetry sidecar contents, the inventory type and the recording artifact id and client path. The 18 checks at this head show none failing, and there are no conflicts. Merge needs only the code lanes to stay green.

The open inline thread asking for telemetry sidecar assertions at #5428 (comment) is fixed at this head, so it can be resolved.

Not blocking, and each can be taken or left: closed.lifetime !== lifetime at https://github.com/callstack/agent-device/blob/a33ad0d/packages/daemon/src/sessions/handlers/session-replay-command.ts#L294 cannot fire, because the attempt ref does not change once the attempt stops running, so reading settled(name) once at the top of cleanupSession would cover both uses. A script that runs close then open in one attempt re-pins the ref to the new lifetime, so collectSuiteRecordingOutputs consumes the commit token at https://github.com/callstack/agent-device/blob/a33ad0d/packages/daemon/src/sessions/recording-outputs.ts#L128 and then returns nothing without a warning; this is older than the PR and could be a follow-up issue. The new test at https://github.com/callstack/agent-device/blob/a33ad0d/packages/daemon/src/sessions/handlers/session-replay-command-closed-session-recording.test.ts#L105 would still pass on a duplicate delivery of the same file, so asserting the length of recordingArtifacts (2) and of the matching inventory entries would tighten it.

Not verified here: the live run is the author's report on 0d6d9e7, with no pasted output, and it ran on iOS 27.0 where the issue reported 27.2. The tests were not run locally, and the base-failure property was judged from the code path, not from a base run. Whether a lease-expiry reap of the attempt session commits a suite token through the same teardown, and whether attempt session names are unique per suite and retry, were not traced.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Dec 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant