Recorder correctness checklist
Distilled from the adversarial review of the first (Python) recorder implementation. Every item below is a real defect that was found. Any implementation (the Rust recorder, and later the API) must satisfy these by construction.
ffmpeg / segmenting
- fMP4 flags must reach the inner mp4 muxer. With
-f segment -segment_format mp4, pass-segment_format_options movflags=+frag_keyframe+empty_moov+default_base_moof+global_sidx. A top-level-movflagsis applied to the segment muxer and silently ignored → non-fragmented MP4s (moov written at close) that are unplayable if the process is killed mid-segment.+global_sidxwrites a segment-index box that Android's ExoPlayer (FragmentedMp4Extractor) requires to build a seekableSeekMap; without it recorded playback on Android cannot seek (everyseekTocollapses to 0). It stays a-c copyremux (~176 B/segment, written at finalize) and is crash-safe: a segment killed mid-write is byte-identical with or without the flag (the sidx lands only when the muxer finalizes). Guarded byapps/android/.../SidxSeekTest.kt(a real-fixture Media3 extractor test). - Segments start on keyframes and are independently seekable:
-c copy(zero re-encode),-segment_atclocktime 1,-reset_timestamps 1. - Precise timestamps: derive
start_tsfrom the strftime-encoded filename (clock-aligned; the filename==UTC contract is enforced by theTZ=UTCpin on the ffmpeg child process itself — the container may legitimately run an operator timezone, so never rely on container-level UTC; see the 2026-07-03 TZ incident), setend_ts= next segment'sstart_ts(contiguous),duration = end - start. Do not use wall-clock at the moment a log line is observed. Final segment at shutdown: use file mtime (or start + segment_seconds). - Don't depend on log verbosity for segment detection. Prefer
-segment_list pipe:/ a segment-list file (muxer-reported boundaries). If scraping stderr, note the "Opening … for writing" line is emitted at verbose level, log-scraping is fragile.
subprocess safety
- Never deadlock on child pipes. Any ffmpeg child whose stdout you read for frames MUST have its stderr drained concurrently (or routed to null). A full ~64 KB stderr pipe blocks ffmpeg → blocks your reader forever → the NVDEC session + VRAM leak indefinitely (and starve the shared GPU). In tokio: read stdout and stderr in separate tasks, or send the unused stream to null.
- Clean shutdown actively kills the child (SIGTERM/kill), don't wait for it to emit
output. A
-c copystream on a quiet camera emits nothing for long stretches; relying on log cadence to notice a stop request makes shutdown hang. Use task cancellation + child.kill(); target a few seconds, ideally instant.
storage lifecycle (data-loss class)
- Live-retention deletion MUST skip archive-enabled cameras/segments. The archiver owns deletion of those (after a verified copy). Otherwise the frequent retention tick deletes aged segments before the (cron) archive job runs → permanent data loss.
- Archive move ordering (crash-safe): copy → verify (size/checksum) → update index row
(
storage_id,stage='archive',path) → delete source. A reader always sees old-or-new, never half-moved. - Startup reconciliation scans BOTH live AND archive storage. An interrupted archive move leaves a verified copy in archive with no row (orphan), only an archive scan reclaims it. Also delete dangling rows (row → missing file).
- Retention deletes file THEN row, so a crash never leaves a row pointing at a missing file.
GPU / isolation (must not break the shared host)
- Cap concurrent NVDEC decode sessions with a global semaphore (env-configurable,
e.g.
MAX_GPU_DECODE_SESSIONS). When exhausted, fall back to CPU decode. Prevents VRAM exhaustion that would starve other GPU workloads sharing the host. A hardware backend that cannot decode must also lose the camera, not the reconnect loop.MOTION_HWACCEL=autois resolved by a RUNTIME probe (ffmpeg must actually create the device), never by "was cuda compiled in" — the bundled ffmpeg answers yes on every host, so the build-time check selected cuda on GPU-less machines (issue #479). And whatever backend was selected, a motion ffmpeg that exits having decoded ZERO frames — with a known hw-init signature, or repeatedly — latches that camera to CPU decode for the worker's lifetime, so the EOF/reconnect watchdog stops relaunching the same failing flags forever. Fail-open (item 19) is what keeps footage safe while this plays out; the latch is what makes detection come BACK instead of staying down until an operator notices. - Recording is
-c copy(zero decode). Motion runs on the SUB stream only. Streams come from Crumb's own embedded go2rtc restreamer (run by the recorder), not an external one. Recording must not depend on the api being up: the recorder creates any missing recording stream (main +_sub) in its own go2rtc before and while recording (stream_registry.rs), create-only, from the samecrumb_common::go2rtc_streamsbuilder the api uses. Never let it re-PUT/PATCHan existing stream, that is the api's job.
DB / seed
- Seed is idempotent.
storagesneedsUNIQUE(name)(+ON CONFLICT) or a query-first guard; otherwise re-running seed (entrypoint runs it every start) inserts duplicate storage rows → nondeterministic storage selection. - Config reload fires only on actual change (compare a version/hash) and must not needlessly rebuild the motion ring buffer (which drops buffered pre-motion segments).
motion
- Frame-diff pipeline: downscale → grayscale → blur → absdiff vs previous → threshold →
count changed pixels. Dynamic sensitivity (default) auto-calibrates from recent stats;
manual uses a fixed threshold. Apply
motion_maskpolygons. EmitMotionSignal(camera_id, started_at, stopped_at, peak_score). Keep the motion-source interface generic (Frigate-MQTT seam later, do not build it). - In Rust, do the frame-diff natively on the grayscale bytes ffmpeg emits
(
-vf scale=…,format=gray→ operate on&[u8]). No OpenCV dependency.
motion-mode RAM cache (persist-on-motion; docs/MOTION-RECORDING.md)
- Persist ordering is copy → fsync file → fsync containing dir → index row → delete cache file, the same crash-safe shape as the archive move (#8), applied to the tmpfs-cache→disk path instead of the live→archive path. A reader (including reconcile) must always see old-or-new, never a segment that's "moved" but unindexed.
- A crash between copy and index is an ORPHAN, not a loss. The persisted
.mp4exists on disk with nosegmentsrow yet, reconcile's existing orphan-adoption scan (the same one that adopts a live-write orphan today) must pick these up on the next pass, same as any other unindexed file under the media root. Do not add a second, parallel "recover motion-persisted orphans" path, one reconciler, one set of rules. - Fail-open is an invariant, not a fallback heuristic. The instant a camera's motion
detector is judged unhealthy (stalled sub-stream, dead decoder, any state where the
recorder can no longer produce a trustworthy keep/discard verdict), that camera MUST
persist every segment to disk, same as Continuous mode, until detection is verified
healthy again, and a health alert must fire for the duration. "Detector state unknown"
always resolves to "keep everything," never to "keep nothing" or "keep last-known verdict."
The same invariant applies one level below the detector: if the tmpfs RAM cache itself
can't be used (cache dir path rejected, or
create_dir_allfails, e.g. the tmpfs mounted root-owned instead ofmode: 01777, so the recorder's non-root uid 1001 getsEACCES; a real prod incident, seedocs/MOTION-RECORDING.md), the camera falls back to direct-to-storage the same way and now ALSO raises a health alert (motion_cache_unavailable, migration0040_motion_cache_unavailable_alert.sql) so the condition is loud instead of a silent 11-hour "why is this camera recording everything" surprise. The fallback itself is unchanged and safe, footage is never lost, only the disk-saving benefit of Motion mode is temporarily suspended, this item only requires that it also be visible. Fail-open must also END on its own. Every way a motion session ends closes the event it has open: the pixel frame session (analyse_frame_stream) emits the synthetic STOP for an in-progress event on the watchdog and read-error exits too, not only on cancel/EOF. Before, the frame-stall watchdogreturned past that STOP: a camera reboot is a big scene change (START) followed by a dead stream (stall), the detector reconnected and went healthy again, but the stranded START stayed open in the recording task'sMotionUnion(no time-based expiry, item 25), pinning the buffer in Recording. Three production Motion-mode cameras kept every segment for 18 days that way until a restart rebuilt their workers. Guarded byframe_stall_then_resume_recovers_in_process_and_closes_the_event. Separately, a session that stays connected but never reaches a verdict (warm-up never completing, or a duplicate-frame "long GOP" window) keeps feeding the frame watchdogs; the stuck-session guard (StuckSessionGuard) ends it after 120 s, doubling per consecutive stuck session up to 30 min. While a source stays unhealthy itsmotion_detector_unhealthyalert re-fires every 4 h (UNHEALTHY_REALERT_INTERVAL_SECS), stopping on RECOVERED or when the worker that owns the episode is torn down. - Spill never drops a buffered segment. If the tmpfs cache nears its configured size
(
MOTION_CACHE_TMPFS_BYTES), the correct response is to persist the OLDEST buffered segments to disk (freeing cache space the same way a normal keep-verdict would), never to evict/delete a cached segment that hasn't been through a keep/discard decision. Cache pressure is allowed to change when a segment is written; it must never change whether it survives. The same holds when a keep verdict's copy into storage FAILS (EIO, EROFS, ENOSPC): the cache file is the only copy, so it goes into a per-camera, process-wide retry queue (recording.rspersist_cached_or_queue), is retried on later segment boundaries with backoff (5 s doubling to 5 min) for as long as the file exists, and is part of the R1 reconnect sweep's keep-set, so neither an ffmpeg reconnect nor a worker respawn can delete it (audit R8). Only a cache file that has already vanished is given up on, with an error log and astorage_persist_failedevent for that segment. Guarded byfailed_persist_survives_the_reconnect_sweep_and_is_retried. - The RAM cache is not a durability boundary for anything already persisted. Once a
segment has cleared the ordering in #17 it is on disk and indexed, a crash, container
restart, or tmpfs wipe afterward must not be able to touch it. Only segments still
sitting in the ring buffer (not yet triggered into a keep verdict) are at risk on an
unclean shutdown, and that risk is bounded by
motion_pre_secondsby construction.
absolute max-retention cap (data-minimization ceiling)
- The per-policy
max_retention_dayscap is a HARD CEILING that deliberately overrides item 7's stage/archive scoping, and that is correct, not a bug. The per-tier live sweep skipsarchive_enabledcameras and touches onlystage=live(item 7: the archiver owns their deletion). The absolute cap has the opposite requirement: footage older than the operator-configured ceiling must be removed whether or not it was archived and regardless of stage, or the operator's stated retention limit is violated. Soarchive::max_retention_sweepqueries BOTH stages and does not exclude archiving cameras. It is still bound by every OTHER footage-safety rule: OFF by default (NULL⇒ no-op, so an existing install is never surprise-pruned); file-then-row deletion (item 10) via the sharedNotFound-tolerant helper; serialized onARCHIVE_GUARDso it can never delete a segment mid archive-move (item 8); skips segments under an active protected bookmark (a human pin outranks the automatic cap); and batch-limited so first enabling a short cap converges over ticks instead of one mass delete. When set it can only remove footage sooner than the other knobs would, never keep it longer.
declared tracks must carry decodable packets, on every client (audio-integrity)
-
A recorded segment MUST contain decodable media PACKETS for every track it declares — and those packets must be decodable AND sample-continuous on EVERY client, not just desktop. The recorder ALWAYS re-encodes audio (when
record_audio):-af aresample=async=1:first_pts=0 -c:a aac -ar 48000(audio_segmenter_args; docs/DECISIONS.md 2026-07-13, superseding the 2026-07-12 copy-when-safe split). This guards two failure modes that a bit-exact-c:a copycould not:- Sample-continuity (the reason for the 2026-07-13 change). A copy
preserves the camera's audio timeline verbatim; cheap camera audio clocks
drift ~1 %, so the container timestamps promise more time than the AAC frames
deliver (~32 ms/segment). ExoPlayer's
DefaultAudioSinkrequires sample-continuous audio and, once accumulated drift crosses ~200 ms, throwsUnexpectedDiscontinuityException; since the audio renderer is the master clock the position lurches and playback wedges (silent audio, stalled video) — a 48 kHz copy plays silent on Android.aresample=async=1resamples onto a strictly continuous lattice (fills genuine gaps with silence, preserving A/V alignment): measured 0/192 discontinuous frames after vs 61/62 before. A plain re-encode WITHOUTaresamplestill left 75/187 (it inherits the jittery input frame PTS), soaresample=asyncis load-bearing, not decorative. - Cross-client playability. Re-encoding to a universal 48 kHz AAC also
covers cameras whose native rate (64/88.2/96 kHz) Android's hardware/
c2decoders reject outright (MediaCodecInfo: NoSupport [sampleRate.support, 64000]→ silent). One re-encode fixes both.
No
-copyinkf:aany more: it only mattered for the-c copykeyframe gate (RTP-AAC is never key-flagged → a bare copy declared a zero-packet track). The re-encode decodes from PCM, so there is no keyframe gate. Video always stays a bit-exact copy (the audio args override only audio; they do NOT touch the fMP4 crash-safety flags, item 1). The export path is separate:services/api/src/export.rsstill-c:a copys — now against a clean re-encoded source for new footage (so exports of new footage inherit the good timeline for free); normalizing export itself remains a follow-up for copy-path-era footage. Detector:audio_segmenter_argsis unit-tested (always AAC/48 k/aresamplewhen recording,-anotherwise); any integration check should assert bothnb_read_packets > 0AND uniform audio packet deltas. - Sample-continuity (the reason for the 2026-07-13 change). A copy
preserves the camera's audio timeline verbatim; cheap camera audio clocks
drift ~1 %, so the container timestamps promise more time than the AAC frames
deliver (~32 ms/segment). ExoPlayer's
free-space floor (ENOSPC safety valve)
-
The floor keys off free space AVAILABLE to the recorder, and its response must actually FREE bytes. Read
statvfsf_bavail/f_frsize, NOTf_bfree(which includes the ext4 root reserve the non-root recorder cannot use, so the valve would never fire). When the floor is in deficit, an archive-move that lands on the SAME filesystem as the deficit disk frees nothing — on the default compose layout that let the disk fill to 100% and ENOSPC-halt recording. So the deficit path DELETES the oldest live segment (a narrow, loud exception to item 7, in the spirit of item 22) when — and only when — the segment's storage shares the archive filesystem AND the deficit filesystem (st_devidentity); a segment on any other disk falls through to the normal footage-preserving move. Oldest-first, protected bookmarks excluded, file-then-row (10), serialized onARCHIVE_GUARD(8), and apremature_rolloverevent fires so the loss is visible. Seedocs/DECISIONS.md(2026-07-12).The same rescue also applies when archive moves are failing for a systemic reason (archive disk full or read-only, or the destination is not confirmed, item 35): while the live floor is in deficit, the oldest live segment ON THE DEFICIT FILESYSTEM is deleted instead of breaking out of the loop, and
storage_unwritablefires. Cap-only pressure still never deletes un-archived footage. The ARCHIVE filesystem has its own floor (archive_floor_sweep, globalMIN_FREE_*thresholds) that rolls the oldest unprotected archive footage over before the cron move runs, so a full archive disk cannot wedge the live tier. With archiving OFF, floor eviction only considers and only credits footage on the deficit filesystem; footage on other disks is left to the byte cap. Byte caps compare against UNPROTECTED bytes (protected footage is never evictable, so counting it made the cap delete every new segment), and a cap-driven delete never touches footage younger than one hour. Seedocs/DECISIONS.md(2026-10-08).
fail-open across every seam (extends item 19)
- Fail-open state survives reconnect and stays consistent through an unhealthy
window.
MotionBuffer/MotionUnion/pending_signalsare worker-lifetime (carried across an ffmpeg reconnect; the R1 cache sweep spares carried pre-roll via a keep-set; a flip-guard blocks a cache/storage-flavour self-copy-truncate), so a reconnect mid-event never drops the tail. Through a frozen window the union is kept in sync — edges fold, the newest is stashed and replayed on thaw, and a replayed STOP onto an Idle buffer entersPostBufferso a full event inside the window keeps its post-roll. Do NOT add a blind time-basedMotionUnionexpiry: it cannot tell a lost STOP from a genuinely-long event and on a multi-source camera would discard footage a healthy source is still asserting (the wedge is covered footage-safe by the loss-debt fail-open + source supervision instead). - A detector is HEALTHY only when it can produce a keep/discard verdict. The
Frigate source reports healthy on a GRANTED MQTT SubAck, never on ConnAck (a
denied subscription is "healthy forever, zero events"); the pixel detector only
after warm-up; a panicked source task is supervised and immediately reads
unhealthy → fail-open; a
MotionSignaldropped on a full channel flips the source to fail-open via an interposed health watch (never silently lost). Unhealthy is not the same as alert-worthy. A source the camera's configuration makes permanently incapable of a verdict — today, a pixel source on a camera with no sub-stream (item 12: motion runs on the SUB stream only) — stays unhealthy, so fail-open recording and the console's degraded-motion badge behave exactly as they do for a fault; but no startup unhealthy-alert timer is armed for it, or it pages on every recorder start forever about a camera working exactly as configured (issue #523). The specific cause (NO_SUB_STREAM_REASON) is shared verbatim by the decode-statusfallback_reason, the recorder log, and the persistedmotion_health_reason, so those surfaces cannot disagree.
stall watchdog & boot reap
- The segment-receipt stall watchdog is anchored to the last received segment,
not a per-
select!-iteration timeout. A co-scheduled telemetry tick shorter than the timeout must not be able to rebuild/reset the deadline every loop — that left a half-open stream recording nothing indefinitely. It is a dedicated select arm onsleep_until(last_segment_at + timeout). - Boot index-reap skips only a GENUINE in-progress build. An INVALID index is
dropped so a later
CREATE INDEX IF NOT EXISTSrebuilds it; on a lock timeout, re-checkpg_stat_progress_create_indexfor that index — skip a real manualCREATE INDEX CONCURRENTLY, but RETRY transient/foreign contention rather than permanently skipping (which would silently leave a broken catalog entry).
quarantine (review-then-purge)
- The quarantine prune ages by quarantine-ENTRY time, and only ever deletes
inside
_quarantine/.quarantine_filestamps mtime to NOW on arrival (a same-fs rename would otherwise preserve the RECORDING-time mtime, silently shrinking the review window toretention − age-at-entry, clamped at zero — issue #277: a deleted camera's history was orphaned, quarantined, and purged within one reconcile pass). The prune deletes only regular files, inside the canonicalized_quarantine/subtree, strictly older thanquarantine_retention_dayscounted from entry;0disables it; the orphan walk (reconcile::orphan_pass) never descends_quarantine/.-rNcollision-loser files are exempt at any age — they are real footage ratified "never deleted" (2026-07-14 decision); quarantine is their terminal parking spot and deleting them stays a manual operator action.
policy model & seeding (2026-07-19 audit)
- Policy membership is TOTAL. Every camera holds a
NOT NULL, FK'dpolicy_id(RESTRICT — a referenced policy cannot be deleted); the boot shim may only ever re-add the NOT NULL constraint, never drop it; the deviation-reaper deletes only unreferenced non-default rows; exactly oneis_defaultpolicy row exists while cameras exist. - The default-policy seed is idempotent under concurrency.
ensure_default_policymust stay safe for simultaneous api + recorder boots (WHERE NOT EXISTS+ bareON CONFLICT DO NOTHINGspanning both unique indexes); a name collision degrades to a loud no-op, never a second default.
storage migration ("Change storage" drain)
- Phase discipline: the unguarded copy phase never mutates the DB and never deletes or modifies any file it did not itself create. Only the guarded flip (+ post-flip source delete) touches existing state, and the flip is conditional on the expected from-storage. When from/to resolve to the SAME file (duplicate rows for one path, symlinked roots), the drain flips the row in place and touches no files (issue #276 — the failure-arm cleanup once unlinked the only copy).
shared reconcile gates
- The sub-floor (512 B) and in-flight (2× segment-length mtime) gates precede every reconcile mutation and every live-path index insert, and live as shared constants — never two drifting copies. Any new reconcile/adoption path must route through the same gates.
the segment index is footage metadata, and it is not reconstructible
-
Reconcile may not prune a storage's segment index until it has CONFIRMED that storage, and a mass-missing pass halts itself. "The file is missing" is only evidence that the row is a lie if we are looking at the right disk. A storage root that is PRESENT but EMPTY — an fstab
noautodisk that never mounted, a dropped network mount, a bind source Docker auto-created after a host path moved — makes EVERY row on that storage look dangling, and the unguarded pass deleted the whole index in one sweep (issue #504). The bytes survive;has_motion, motion bboxes, stage/stream labels, durations and clip/bookmark linkage do not, and re-adoption after a remount is rate-limited and comes back withhas_motion = falseand no bbox. Note the orphan pass'smetadata(storage_root).is_err()check does NOT cover this: the root stats fine, it is just empty. Two independent layers, both failing toward skip-and-alarm, never toward delete:- Marker. The recorder writes
<storage_root>/.crumb-storagewhen it can positively confirm a storage — from the recording path (index_segment) only AFTER a real ≥floor segment is fsync'd on disk AND committed to the index under that root, AND (audit R9) only if the storage has no indexed segments from before this recorder process started, or at least one of its newest such segments is present under the root (confirm_and_write_storage_marker). Without that second condition, a disk that failed to mount was confirmed by the very first segment recorded onto its empty mountpoint. A refused root is re-checked at most once a minute. And from a boot/heal pass that requires at least one of the storage's newest INDEXED segment files to really be present under the root. Both writers share ONE rule: a marker means a real indexed segment is present. It is deliberately NOT written at directory-creation time —create_dir_allsucceeding proves only that SOME directory was writable, so a bare unmounted mountpoint (Docker auto-creates an empty bind source) would earn a FALSE marker before any footage exists, defeating this guard in exactly the scenario it is for (the v0.2.0 re-audit defect). It is never invented for a root that holds none of its indexed segments (the unmounted shape), nor for a storage with no indexed segments at all (indistinguishable from an empty foreign directory). The dangling pass deletes NOTHING on a storage whose marker is absent. The marker rides on the storage, so an unmounted disk cannot present one. - Circuit breaker. Even with a marker (stale marker, repointed path),
deletions for a storage stop once more than
DANGLING_BREAKER_MIN_MISSING(100) of its rows AND more thanDANGLING_BREAKER_MISSING_PCT(50 %) of its checked rows are missing in one pass. It is evaluated BEFORE every delete, so the loss is bounded at 100 rows per storage, and the trip latches for the process lifetime (a timer-driven reconcile would otherwise drain the index 100 rows per pass). Both conditions must hold, so a small storage an operator emptied, or a large one mid-eviction, still prunes exactly as before.
Both raise the existing
storage_unwritablesystem event so the condition is loud rather than silent. Consequence to accept: a disk whose footage was genuinely deleted wholesale stops being pruned until an operator re-creates the marker file (an empty file is enough) — stale rows are visible and fixable, a deleted index is neither. Guarded byreconcile::tests::dangling_pass_skips_storage_without_marker,dangling_breaker_bounds_deletions_on_mass_missing,dangling_pass_deletes_genuine_dangling_rows_on_a_confirmed_storageandstorage_marker_is_seeded_only_when_the_storage_is_confirmable; the recording-path writer's confirmable timing (and the danger of a false marker at directory-creation time) byrecording_path_marker_written_only_after_a_committed_segmentanda_false_marker_below_the_breaker_floor_prunes_the_whole_small_index. Seedocs/DECISIONS.md(2026-08-06, and the 2026-08-07 follow-up) for the rejected mountpoint heuristics and why the marker is written post-commit. - Marker. The recorder writes
storage roots own their footage (2026-10-08)
-
No storage's footage may be touched through another storage's root, and a storage's folder may not move out from under its index. Segment rows are keyed by
(storage, path relative to the root), so a file is only recognisable as indexed from its own root.- The orphan walk stays in its own lane. It never descends into a
directory that is another storage's root (compared on canonical paths),
never adopts or quarantines a file under one, and only ever considers the
recorder's own
<camera uuid>/...layout: a top-level folder that is not a camera UUID, or an.mp4directly in the root, is left alone (OrphanOutcome::Foreign), never quarantined. Before this, a storage at the media root (or an archive inside the live folder) made the walk move every nested file to_quarantine/, and the prune deleted it two weeks later. A file whose name cannot be parsed is quarantined only after an exact lookup confirms no row references it. - The api refuses overlapping roots. Creating or repointing a storage at
a folder that equals, contains, or lies inside another storage's folder is
a
409(canonical comparison, so a symlink cannot hide it). - The api refuses to repoint a storage that holds segments. Rows are relative to the root, so a path edit hides every recording and invites the sweeps to delete their rows. Moving footage is the "Change storage" drain's job (item 32). A path that only differs lexically is not a change.
- Bounded memory. The orphan walk compares one directory at a time
against that camera's rows in that directory's timestamp range (chunks of
ORPHAN_LOOKUP_CHUNK); it never builds a set of every indexed path, and all of a pass's filesystem calls share oneFsPacerbudget. The marker, breaker, in-flight and sub-floor gates are unchanged.
Guarded by
reconcile::tests::nested_storage_footage_is_never_quarantined_by_an_outer_root,try_index_orphan_treats_non_camera_layout_as_foreign,unparseable_name_is_quarantined_only_when_no_row_references_it,chunked_orphan_walk_recognises_every_indexed_file, and the api'sstorage_path_overlap_testsplus thestorage_path_guardintegration suite. - The orphan walk stays in its own lane. It never descends into a
directory that is another storage's root (compared on canonical paths),
never adopts or quarantines a file under one, and only ever considers the
recorder's own
-
The retention and eviction sweeps obey the same storage confirmation, and nothing writes footage into an unconfirmed destination. Every "file is missing, so delete the row" decision in
archive.rs(live and archive retention, size eviction, max-retention, the archive floor) goes throughDanglingGuard: the row is KEPT unless the segment's storage root carries the marker, its reconcile breaker is not latched, and the sweep has not seen a mass-missing pattern on that root (same 100-row / 50 % shape, latched for the process lifetime). A missing file never credits a free-space deficit. Archive moves (cron and eviction) and the "Change storage" drain refuse a destination whose root lacks the marker while footage is indexed under its path (an unmounted disk), raisestorage_unwritable, and keep the source; a destination with no indexed history is accepted and gets its marker after the first committed move. The live retention sweep applies each camera's own retention cutoff in SQL, so a long-retention camera cannot fill the oldest-first batch and stall a shorter one. Guarded by thesize_eviction_integrationtestseviction_keeps_dangling_rows_on_unconfirmed_storage,unconfirmed_archive_destination_is_never_written,change_storage_drain_refuses_unconfirmed_target,live_retention_enforces_each_cameras_own_window,floor_eviction_archive_off_only_deletes_on_the_low_disk,protected_bytes_do_not_drive_cap_eviction_of_new_footage,archive_floor_rolls_oldest_archive_footage_overandfailing_archive_moves_do_not_wedge_the_live_floor.