carlos / platform Public

reviews: Astra brief and findings for log-retention-knobs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 625c0f9567247bd499dea44a24a9397dc0b0b7fe parent dfc9c8b
2 files changed, +25 −0
  • docs/superpowers/reviews/CODEX-FINDINGS-log-retention-knobs.md +11 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-log-retention-knobs.md +14 −0

CI failed — run details

diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-log-retention-knobs.md b/docs/superpowers/reviews/CODEX-FINDINGS-log-retention-knobs.md
new file mode 100644
index 000000000..167898f2c
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-log-retention-knobs.md
@@ -0,0 +1,11 @@
+No material runtime correctness bug found in `fddc42f1`. Two findings:
+
+1. **P2 risk — repeated writes to an existing hour are untested.** [internal/host/logretention_test.go:166](/home/paulca/amadan.net/carlos/platform-log-retention-knobs/internal/host/logretention_test.go:166). The own-write test flushes once into a new hour. Changing `wrote` from `+=` to `=` would still pass, but repeated flushes would then discard previously counted bytes, allowing the cap to be exceeded until the daily walk. Outage recovery into an already-counted old hour is also untested. **Fix:** flush multiple distinct chunks into an existing hour, including records timestamped before the current hour; assert exact totals and oldest-first deletion. Exercise both shipping families. Invariant: every successful write contributes exactly once.
+
+2. **P3 nit — “cost no longer grows with retention” overstates the improvement.** [internal/host/logretention.go:8](/home/paulca/amadan.net/carlos/platform-log-retention-knobs/internal/host/logretention.go:8). Ordinary passes make one `ListDirs` call plus one `List` per deleted hour, but those calls paginate. The daily walk also remains proportional to retained hours: 2,160 populated hours require 2,160 sizing calls daily, averaging 90 per hour before pagination and deletions. The counter tests measure interface calls, not storage requests. **Fix:** describe the improvement as eliminating hourly sizing walks; distinguish interface calls from requests and account for the daily walk.
+
+Static inspection found matching hour-prefix semantics across S3Store, DirStore, PrefixStore and the fleet door. Sorting, default age handling, current-hour eviction and box isolation remain consistent with the previous implementation.
+
+The requested targeted tests **could not start** because the read-only sandbox prevented Go from creating its build directory. No files were edited.
+
+**READY AFTER FIXES**
\ No newline at end of file
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-log-retention-knobs.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-log-retention-knobs.md
new file mode 100644
index 000000000..58fdd7762
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-log-retention-knobs.md
@@ -0,0 +1,14 @@
+Review commit fddc42f1 on branch log-retention-knobs in the carlos/platform repo (your working directory). `git show fddc42f1` is the whole change. Read-only review: do not edit files. Leave GOCACHE unset if you run go; run only targeted tests (go test ./internal/host/ -run 'TestLogRetention|TestPrune|TestLogship|TestErrship' -count=1).
+
+Context: boxes ship app logs (and errors) as gzipped chunks into the bucket at apps/<sqid>/<app>/{logs,errors}/<box>/<hour>/<seq>-<size>... Each box prunes only its own subtree hourly. Retention was hard-coded 7 days / 50 MiB per app per box. This commit:
+1. Adds host.env settings CARLOS_LOG_RETENTION_DAYS and CARLOS_LOG_RETENTION_MB (or off), defaults unchanged, refused values logged and defaulted (internal/host/logretention.go).
+2. Replaces chunkPrune (which LISTed every hour dir every pass) with pruneLedger: walks once per process and once per 24 h, adds the flush's own writes via ledger.wrote, LISTs only hours it deletes.
+
+Look for correctness bugs, specifically:
+- Can the ledger under-count so the byte cap is exceeded beyond a day's drift, or over-count so it deletes hours it should keep? Consider: chunks whose hour (HourOf(recs[0].TS)) is an old hour after a bucket outage; a Put that fails but lands; process restarts; the hour dir key derivation in wrote (key[:LastIndexByte('/')+1]) vs what ListDirs returns for S3Store, DirStore, a PrefixStore and the edge store-door store a fleet box uses; ListDirs pagination/ordering.
+- Behaviour equivalence with the old chunkPrune at default settings (age floor, byte-cap ordering, current hour, other boxes' subtrees untouched).
+- Any path where a refused setting or a bad value could stop the agent or silently change behaviour.
+- Whether the tests would catch a broken implementation.
+- Request cost: is the steady state really one ListDirs per app per hour plus one List per deleted hour?
+
+Output: a numbered list of findings, each with severity (P1 bug / P2 risk / P3 nit), file:line, a concrete failure scenario, and a suggested fix. Say plainly if you find nothing material. Keep it under 600 words.