Skip to content

TakeSession.finish: run the body without self, on a snapshot (#652, part A, 2 of 3) - #775

Merged
Skeyelab merged 3 commits into
mainfrom
stop-snapshot
Oct 16, 2026
Merged

Skeyelab merged 3 commits into
mainfrom
stop-snapshot

Conversation

@Skeyelab

Copy link
Copy Markdown
Member

Part A of #652, step 2 of 3 (A1 #765 merged). A pure refactor: finish() stays synchronous with the same signature, but its body is now a nonisolated static func finish(_:) on a FinishInput snapshot (capture, copies, standby, metadata, levels, stop timeout), and finish() writes the updated metadata back. coverage, gaps, writeMetadata, collectDropouts and persistGaps became nonisolated statics; the instance methods the mid-Take code uses are one-line wrappers over them, so nothing mid-Take changed and nothing is duplicated. Recorder is untouched.

What did not change: the order of operations (stop capturing, request stop on every writer, one deadline, wait, stand-in bookkeeping, dropouts, levels, Take.json writes skipping Copies Stop gave up on, Gaps) and every file written. A3 (async stopTake, behind an availability rule) will call the static function on a detached task.

Tests: a refactor, so the existing suites are the net. swift test --filter Recording: 1037 tests in 145 suites passed (4 known issues); VERIFY_QUICK=1 ./scripts/verify.sh passed. No new test (the behavior is the same); no red run, since nothing changes.

Code Reviewer: a faithful refactor, no blockers. It listed A3 hazards, which are in my A3 plan, not here: the snapshot must be taken after the last accumulate, after Recorder drops the session and cancels the destination checks (a late attachDrive or stand-in would be missing from it), with nothing changing on the session until the metadata is written back (now written in the FinishInput doc comment). TakeWriter and StandInSink are @unchecked Sendable, as before.

Device only (Eric, internal build): this is the end of the real-time path (ADR 0002). Record and Stop a Take on a real iPhone, with and without a Drive, and check the Stems finalize and Take.json (Gaps, Dropouts, levels) is complete. Checked by tests only.

https://claude.ai/code/session_01YSHtEHRvQvHpyXAjjbcmVq

finish() copies what it needs into FinishInput and calls the new nonisolated
static finish(_:), then writes the updated metadata back. Same signature,
same order of operations, same results for every caller.

coverage, gaps, writeMetadata, collectDropouts and persistGaps became
nonisolated statics taking the copies, standby and metadata; the instance
methods the mid-Take code uses are now one-line wrappers over them, so
tick, join, rejoin and stand-in are unchanged and nothing is duplicated.

Assisted-by: Claude Code:claude-sonnet-5-5
Claude-Session: https://claude.ai/code/session_01YSHtEHRvQvHpyXAjjbcmVq
@Skeyelab
Skeyelab enabled auto-merge (squash) October 16, 2026 06:17
@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...howRecorderKit/Sources/Recording/TakeSession.swift 96.15% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Skeyelab
Skeyelab merged commit 33c2b4e into main Oct 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant