recorder: never delete un-ingested tape — warn from 80%, single-oldest drop only at 95% as loud last resort (user directive); volume 10→25GB

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jaxperro
2026-07-19 16:00:20 -04:00
parent 77b2457523
commit b8c0734c5a
+15 -6
View File
@@ -63,16 +63,25 @@ class Tape:
os.remove(plain)
log(f"rotated {fam}_{cur[0]} ({cur[2]} rows)")
self.files[fam] = [hour, open(os.path.join(DIR, f"{fam}_{hour}.jsonl"), "a"), 0]
# disk guard: drop oldest closed segments past 85% usage
# disk policy (user directive 2026-07-19): NEVER delete tape the Mac
# hasn't downloaded — only the nightly ingest deletes, post-verified
# insert. The 25GB volume holds ~5 weeks un-pulled. Warn from 80%;
# only at >=95% (weeks of no ingest, disk about to kill the CURRENT
# tape too) drop the single oldest segment per rotation, loudly —
# losing the oldest hour beats the recorder crashing on a full disk
# and losing everything forward.
try:
st = os.statvfs(DIR)
while st.f_bavail / st.f_blocks < 0.15:
free = st.f_bavail / st.f_blocks
if free < 0.20:
log(f"⚠ tape volume {100*(1-free):.0f}% full — ingest has not "
"run in a long while; check the Mac / daily pipeline")
if free < 0.05:
old = sorted(f for f in os.listdir(DIR) if f.endswith(".gz"))
if not old:
break
if old:
os.remove(os.path.join(DIR, old[0]))
log(f"disk guard dropped {old[0]}")
st = os.statvfs(DIR)
log(f"⚠⚠ TAPE LOSS: disk full — dropped oldest segment "
f"{old[0]} (last resort; fix the ingest!)")
except Exception:
pass