CIS490/tools
max 8d2d0d2e99 prune+receiver: preserve index ownership and add a backfill helper (closes #13)
Root cause of #13 (PUT 500s on first ship, retries return already-present):
my earlier prune-tool session ran as root and rewrote the live index via
os.replace(), which drops the original ownership/mode. The new file was
root:root and the cis490 service user couldn't append to it. Every fresh
PUT 500'd on _append_index after the tarball had already landed via
os.replace, so retries always saw "already-present" and never recovered
the missing index row.

Two fixes:

- tools/prune_episodes.py: snapshot the index's stat before the rename
  and restore uid/gid/mode after. Best-effort chown so non-root prune
  runs (where chown would EPERM) still succeed; non-root callers
  matched the original owner anyway.

- tools/index_backfill.py: new tool. Walks episodes/<host>/*.tar.zst,
  computes sha256+size, and appends rows for episodes missing from
  the index. Preserves "backfilled: true" so trainers can distinguish
  reconstructed rows. Always opens the index in append mode (never
  replaces), so it cannot reproduce the ownership bug it's recovering
  from.

Regression test: tests/test_prune.py::test_archive_preserves_index_mode.

Operator note for the live receiver: ran the chown fix manually
(chown cis490:cis490 /var/lib/cis490/index.jsonl) and ran the
backfill once to recover 140 elliott-thinkpad rows that 500'd before
the chown landed.
2026-04-30 16:36:05 -05:00
..
build_cidata.py Collectors 2/4/5 + fleet runner + sample manifest + Tier-3 setup scripts 2026-04-30 00:02:27 -05:00
cis490_doctor.py fix: three install-time bugs found during first lab-host bring-up on k-gamingcom 2026-04-30 15:05:00 -06:00
fetch_sample.py Close out the open issues: bridge pcap wiring, perf collector, Tier-4 2026-04-30 00:17:49 -05:00
index_backfill.py prune+receiver: preserve index ownership and add a backfill helper (closes #13) 2026-04-30 16:36:05 -05:00
index_reader.py Close out the deployment-readiness gaps 2026-04-30 00:31:55 -05:00
load_mimic.py Synthetic envelope demo: phase-driven load mimic + plotter 2026-04-28 23:53:20 -06:00
plot_envelope.py Close out the deployment-readiness gaps 2026-04-30 00:31:55 -05:00
prune_episodes.py prune+receiver: preserve index ownership and add a backfill helper (closes #13) 2026-04-30 16:36:05 -05:00
run_envelope_demo.py Synthetic envelope demo: phase-driven load mimic + plotter 2026-04-28 23:53:20 -06:00
run_fleet.py fleet: rotate exploit modules per (host, slot, ep); Tier 3 by default 2026-04-30 02:22:49 -05:00
run_real_vm_demo.py runners: take savevm baseline-v1 after boot so revert_at_* actually works 2026-04-30 02:37:05 -05:00
run_tier3_demo.py runners: take savevm baseline-v1 after boot so revert_at_* actually works 2026-04-30 02:37:05 -05:00
show_envelope.sh Interactive envelope plot via WebAgg (browser-based) 2026-04-29 00:06:22 -06:00
vm_load_controller.py workload audit trail: meta.sample + per-phase events + pre-kill probe 2026-04-30 02:12:34 -05:00
vm_serial.py Tier 2: real Alpine VM, real workload, real envelope 2026-04-29 08:38:53 -06:00