exlab_wizard.sync.cleanup#

Cleanup safety interlocks. Backend Spec §7.1.6.

The cleanup reaper deletes local files only when all of the following hold for a job:

  1. verify_passes >= nas_cleanup.min_verify_passes (default 2).

  2. Hours since the most recent verified_at >= min_age_hours (default 24).

  3. The remote NAS path is reachable (the caller passes the result of a remote stat as remote_stat_ok).

  4. No active validation_overrides revocation (tombstone) has been written within the last min_age_hours – a revoked override re-blocks sync, so we don’t want to delete locally if the run is now blocked.

This module is the pure interlock evaluator. The reaper itself lives in exlab_wizard.sync.nas_client; it consults this helper before issuing a delete.

Functions

cleanup_interlocks_satisfied(*, job, ...)

Evaluate every §7.1.6 interlock; return True iff all pass.

has_recent_revocation(overrides, *, now_utc, ...)

Return True if any tombstone was recorded within min_age_hours.

exlab_wizard.sync.cleanup.cleanup_interlocks_satisfied(*, job, run_path, now_utc, config, overrides_active, remote_stat_ok)[source]#

Evaluate every §7.1.6 interlock; return True iff all pass.

Logs a debug entry naming the failing interlock when one fails so the operator can see why a job stayed in CLEANUP_ELIGIBLE.

The run_path parameter is accepted (but currently unused) so callers can pass the run directory through unchanged; future interlocks (e.g., size-on-disk threshold) may consult it.

Parameters:
Return type:

bool

exlab_wizard.sync.cleanup.has_recent_revocation(overrides, *, now_utc, min_age_hours)[source]#

Return True if any tombstone was recorded within min_age_hours.

A tombstone is an override-list entry with revoked: True. The timestamp is read from recorded_at; entries with a missing or malformed timestamp are treated as recent (fail-safe: we’d rather block cleanup than delete files for a run that may be re-gated).

Parameters:
Return type:

bool