Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
docs: record upload durability design and native release gates
Richie McIlroy06922cad960d
diff --git a/scripts/recording-reliability.md b/scripts/recording-reliability.mdindex 587915264..61eae183a 100644--- a/scripts/recording-reliability.md+++ b/scripts/recording-reliability.md@@ -1,6 +1,6 @@# Recording reliability: research, design and verification-Research date: 2026-08-30. Source baseline: official `cap-v0.5.9`, `c6b83804d2e9fa8757b75268e573b8ff113141bb`. Audited candidate: `526dc80bf5429f7729b66d0291802b65cfeb48c7`, PR #2172. This document distinguishes design requirements from implemented behavior and measured results. It is not a release approval.+Research dates: 2026-08-30–31. Source baseline: official `cap-v0.5.9`, `c6b83804d2e9fa8757b75268e573b8ff113141bb`. Initial audited candidate: `526dc80bf5429f7729b66d0291802b65cfeb48c7`, PR #2172; subsequent branch hardening is described below. This document distinguishes design requirements from implemented behavior and measured results. It is not a release approval.## Decision@@ -22,19 +22,19 @@ FFmpeg also documents that fragmented MP4 remains decodable after interrupted wr## Source audit findings-| Risk | Current behavior at the audited candidate | Required change |-| --- | --- | --- |-| Canonical metadata can become empty or partial | `RecordingMeta::save_for_project` truncates and writes the existing JSON file. A write failure can make raw media undiscoverable to ordinary recovery. This also exists in 0.5.9. | Serialize first; write and sync a unique sibling temporary file; atomically replace the canonical file. Preserve the original on every pre-publication failure. Keep the schema unchanged. |-| An incomplete Instant upload can be accepted | Tauri can complete a manifest after exhausting retries for some segments, provided some video uploaded. Its caller can then run upload-complete actions and local auto-deletion. | Withhold completion while any segment or upload task failed. Preserve the resumable upload identity and local media. Include failed audio/init segments, short reads and worker failures. |-| GPUI can strand retry information | A transient failure can replace a resumable upload variant with `Failed`; GPUI has no equivalent comprehensive startup resume scan. | Keep retry identity and failure information independently; reconcile outstanding uploads on startup and network/auth recovery. Do not solve this by retrying forever inside Stop. |-| Stop includes cloud work in GPUI | `ActiveRecording::stop` awaits segment completion, thumbnail upload or full-file upload, and cleanup. | Finish capture and local publication first. Run cloud work under a managed persistent queue; report uploading/retry state separately. |-| Queue admission is treated as completed upload | `/api/upload/recording-complete` can acknowledge queued or already-processing work before final mux verification. | Distinguish accepted, processing and verified remote-ready. Only verified final readiness can permit local retention cleanup. |-| Live upload completion lacks a complete capture-success contract | A received-event inventory cannot identify an event never emitted. Live Tauri completion can race recorder failure, and historical Instant metadata does not always retain requested audio intent. | Bind final publication to successful capture/local finalization and a persisted expected inventory. Do not infer missing historical audio intent from a nullable sample rate. |-| Aborting an upload is not the same as joining its workers | External cancellation of a parent uploader can leave independently spawned children running. | Own cancellation and join child work before claiming quiescence or deleting media; a normal-path drain alone does not prove cancellation safety. |-| Publication durability is incompletely specified | Recovery syncs files and journals, but its multi-file rename transaction does not consistently persist parent-directory changes. | Define ordered platform-specific durability operations and test interruption/reordering at each transition before claiming power-loss safety. |-| Some Windows checkpoint flushes use read-only handles | Fragment helpers open files for reading before `sync_all`, sometimes only logging or discarding failure. Windows requires write access for `FlushFileBuffers`. | Use a supported writable handle at the writer boundary and propagate a failed required checkpoint. Native Windows verification is required. |-| Successful encoder completion is not universal device quiescence | Some macOS/non-Windows source stop errors or timeouts are logged; a clean output token does not prove every device/preview writer has exited. | Preserve generation/ownership checks and explicit quiescence acknowledgement. Do not use the existing token to bypass all source protection. |-| Normal Stop repeatedly reads/copies the entire recording | Studio performs four full input snapshots, a private copy, remux/validation and publication; Instant also copies and scans. | First remove only provably redundant work. A later read-only-source finalizer must leave original fragments unchanged until commit. |+| Risk | Current behavior at the audited candidate | Required change |+| ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |+| Canonical metadata can become empty or partial | `RecordingMeta::save_for_project` truncates and writes the existing JSON file. A write failure can make raw media undiscoverable to ordinary recovery. This also exists in 0.5.9. | Serialize first; write and sync a unique sibling temporary file; atomically replace the canonical file. Preserve the original on every pre-publication failure. Keep the schema unchanged. |+| An incomplete Instant upload can be accepted | Tauri can complete a manifest after exhausting retries for some segments, provided some video uploaded. Its caller can then run upload-complete actions and local auto-deletion. | Withhold completion while any segment or upload task failed. Preserve the resumable upload identity and local media. Include failed audio/init segments, short reads and worker failures. |+| GPUI can strand retry information | A transient failure can replace a resumable upload variant with `Failed`; GPUI has no equivalent comprehensive startup resume scan. | Keep retry identity and failure information independently; reconcile outstanding uploads on startup and network/auth recovery. Do not solve this by retrying forever inside Stop. |+| Stop includes cloud work in GPUI | `ActiveRecording::stop` awaits segment completion, thumbnail upload or full-file upload, and cleanup. | Finish capture and local publication first. Run cloud work under a managed persistent queue; report uploading/retry state separately. |+| Queue admission is treated as completed upload | `/api/upload/recording-complete` can acknowledge queued or already-processing work before final mux verification. | Distinguish accepted, processing and verified remote-ready. Only verified final readiness can permit local retention cleanup. |+| Live upload completion lacks a complete capture-success contract | A received-event inventory cannot identify an event never emitted. Live Tauri completion can race recorder failure, and historical Instant metadata does not always retain requested audio intent. | Bind final publication to successful capture/local finalization and a persisted expected inventory. Do not infer missing historical audio intent from a nullable sample rate. |+| Aborting an upload is not the same as joining its workers | External cancellation of a parent uploader can leave independently spawned children running. | Own cancellation and join child work before claiming quiescence or deleting media; a normal-path drain alone does not prove cancellation safety. |+| Publication durability is incompletely specified | Recovery syncs files and journals, but its multi-file rename transaction does not consistently persist parent-directory changes. | Define ordered platform-specific durability operations and test interruption/reordering at each transition before claiming power-loss safety. |+| Some Windows checkpoint flushes use read-only handles | Fragment helpers open files for reading before `sync_all`, sometimes only logging or discarding failure. Windows requires write access for `FlushFileBuffers`. | Use a supported writable handle at the writer boundary and propagate a failed required checkpoint. Native Windows verification is required. |+| Successful encoder completion is not universal device quiescence | Some macOS/non-Windows source stop errors or timeouts are logged; a clean output token does not prove every device/preview writer has exited. | Preserve generation/ownership checks and explicit quiescence acknowledgement. Do not use the existing token to bypass all source protection. |+| Normal Stop repeatedly reads/copies the entire recording | Studio performs four full input snapshots, a private copy, remux/validation and publication; Instant also copies and scans. | First remove only provably redundant work. A later read-only-source finalizer must leave original fragments unchanged until commit. |Relevant source seams: `crates/project/src/meta.rs`; `crates/recording/src/recovery.rs`; `crates/recording/src/fragmentation/mod.rs`; `crates/enc-ffmpeg/src/mux/{fragment_manifest,segmented_stream,dash_audio,segmented_audio}.rs`; `apps/desktop/src-tauri/src/{recording,upload}.rs`; `apps/desktop-gpui/src/{recording,upload,session}.rs`; `apps/web/app/api/upload/[...route]/recording-complete.ts`.@@ -110,29 +110,37 @@ Run the same assertion schema on all three OSes. A VM proves its guest capture aThe decode oracle preserves the demuxer timebase and passes every frame through. FFmpeg's default output encoder timebase can round distinct input timestamps together when writing to a null sink; a synthetic monotonic-timestamp fixture reproduced that false error. Input packet decode timestamps are therefore checked independently, while reordered presentation timestamps and audio preroll remain valid. Decode errors are still failures, and each file's initial hash is retained even when verification fails. [FFmpeg timestamp options](https://ffmpeg.org/ffmpeg.html#Advanced-options).-| Scenario family | Required evidence |-| --- | --- |-| Clean Instant and Studio | Start/stop events, complete local metadata, expected tracks, duration/cadence, full decode, project validation |-| Pause/resume and repeated Stop | Ordered transitions, no double completion/deletion, no unexpected gaps, stable media identity |-| Camera/mic/system audio combinations | Exact requested track inventory, visible camera content, audible stimulus, independent A/V onset and drift |-| App or muxer crash during recording | Complete fragments retained; fresh-process recovery; decoded recovered duration accounts for the last committed fragment |-| Crash during local publication | Inject at each rename/checkpoint; old or new generation remains recoverable, with no false Complete |-| Low space/write failure | Scoped ENOSPC/EIO injection or disposable bounded filesystem; no filling the user's disk; originals retained |-| Sleep, device loss and permission loss | Visible degradation/failure, controlled stop, recoverable data, no frozen success state |-| Offline/timeout/expired credentials | Local save unaffected; upload remains retryable across restart; no local auto-deletion |-| Failed or truncated segment | No final manifest acknowledgement or completion action until the entire required inventory is verified |-| Lost multipart-complete response | Same remote object/job reconciled; no duplicate video or abandoned local state |-| Server mux failure | No remote-ready claim; local media retained; retry produces a verified playable final object |-| Upload and application restart | Durable queue reconstructs work and resumes without re-recording |-| Studio editor and export | Editor reveals/focuses; seeks/playback work; exported output fully decodes with requested media |-| Old 0.5.9 projects | Original bytes unchanged; valid legacy omissions remain supported; editing/export match baseline |-| Long/load/thermal runs | Stable memory and storage growth, measured drops, bounded Stop latency, no recording-length-dependent redundant work |-| Cleanup and retention | Only the owned completed generation is removed after remote verification; cleanup failure does not negate save success |+| Scenario family | Required evidence |+| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |+| Clean Instant and Studio | Start/stop events, complete local metadata, expected tracks, duration/cadence, full decode, project validation |+| Pause/resume and repeated Stop | Ordered transitions, no double completion/deletion, no unexpected gaps, stable media identity |+| Camera/mic/system audio combinations | Exact requested track inventory, visible camera content, audible stimulus, independent A/V onset and drift |+| App or muxer crash during recording | Complete fragments retained; fresh-process recovery; decoded recovered duration accounts for the last committed fragment |+| Crash during local publication | Inject at each rename/checkpoint; old or new generation remains recoverable, with no false Complete |+| Low space/write failure | Scoped ENOSPC/EIO injection or disposable bounded filesystem; no filling the user's disk; originals retained |+| Sleep, device loss and permission loss | Visible degradation/failure, controlled stop, recoverable data, no frozen success state |+| Offline/timeout/expired credentials | Local save unaffected; upload remains retryable across restart; no local auto-deletion |+| Failed or truncated segment | No final manifest acknowledgement or completion action until the entire required inventory is verified |+| Lost multipart-complete response | Same remote object/job reconciled; no duplicate video or abandoned local state |+| Server mux failure | No remote-ready claim; local media retained; retry produces a verified playable final object |+| Upload and application restart | Durable queue reconstructs work and resumes without re-recording |+| Studio editor and export | Editor reveals/focuses; seeks/playback work; exported output fully decodes with requested media |+| Old 0.5.9 projects | Original bytes unchanged; valid legacy omissions remain supported; editing/export match baseline |+| Long/load/thermal runs | Stable memory and storage growth, measured drops, bounded Stop latency, no recording-length-dependent redundant work |+| Cleanup and retention | Only the owned completed generation is removed after remote verification; cleanup failure does not negate save success |Record exact source/build identity, OS/filesystem, requested inputs, fixture identity, timing boundaries, all assertions, skipped reasons and cleanup ownership. Compare candidate and 0.5.9 in alternating orders with the same workload; use enough repetitions to expose variance. Do not impose an arbitrary threshold after seeing a result. Physical power failure, physical device disconnect and prolonged workloads need their own explicit runs.## Implementation and release gates-First changes are deliberately bounded: atomic recording metadata replacement with Windows open-reader support, fail-closed Tauri segment completion, validated restart inventories, exact multipart retry reads, one redundant clean-Studio scan removed, and a common local recording oracle. They do not implement the entire lifecycle described above. In particular, background GPUI upload/restart reconciliation, final-object-based deletion, filesystem durability ordering and strict performance parity remain separate work until verified.+The initial changes protect atomic recording metadata replacement with Windows open-reader support, Tauri segment completion, restart inventories and exact multipart retry reads. They remove one redundant clean-Studio scan and add the common local recording oracle.++Further hardening separates local completion from background transfer in GPUI and Tauri. Persistent upload ledgers retain the video identity, capture intent, verification request and retry state across application restarts. An operating-system lock shared by both applications prevents concurrent ownership of the same project; cancellation and cleanup must preserve ownership until their child work has finished. Authentication requests stay bound to the account and server that own the recording. These changes do not replace capture adapters, codecs or the recording container.++The versioned completion contract distinguishes queued or processing work from a verified upload. Local retention cleanup requires a full remote decode, required audio coverage, the expected final manifest or MP4 upload identity, and a matching current storage object. The media server pins reads to the identity returned by the actual successful upload, checks it before and after decoding, and retains a bounded verification deadline independently of earlier mux work. Google Drive uses its file ID and monotonic version; S3 uses its opaque ETag, without assuming that ETags are content hashes. Failed webhook delivery can be reconciled through the same validated completion handler. This requires the matching web and media-server deployment before the new desktop cleanup contract can succeed.++CLI upload APIs currently acknowledge transfer or processing rather than producing that verified receipt. Upload-dependent automation therefore retains local recordings when verification is unavailable, including after an upload failure or an unverified `UploadCompleted` event. Other automation actions can continue. This is a safety guard, not evidence that CLI cloud completion has the same verified queue as the desktop applications.++Production package builds and focused tests remain separate from native acceptance. Real 0.5.9 baseline runs have exposed environment or existing behavior limits: fixed PulseAudio buffer negotiation on Linux, absent Windows CLI window enumeration without process DPI awareness, variable physical webcam cadence, and a microphone fixture that was too quiet. Preserve those observations and compare equivalent workloads; do not silently reduce acceptance thresholds or label infrastructure readiness as a Cap pass. Background retry, complete GUI coverage, editing/export, crash recovery and strict performance parity still require final-build evidence.Before release: all required native scenarios must pass on the final source/build; every false-success/data-loss finding must be fixed; 0.5.9 projects and supported recording combinations must remain compatible; performance comparisons must meet the agreed parity requirement; and a fresh independent/Greptile review must cover the final changes. A review score or green CI job cannot replace missing native or cloud evidence.