Repository navigation
cold-store-reaper: enforce upload hard stop + budget (#938), stop persisting access token (#940), retention verified (#939) - #988
Conversation
…ess token (#940) #938: extract status_data's ledger/meta accounting into _upload_accounting() and refuse in upload()/put_backup() via _check_upload_limits() before any bytes move, when the transfer would cross daily_upload_hard_stop_bytes (rolling-24h ledger uploads + this transfer) or project_budget_bytes (verified cold bytes + this transfer). Errors name the limit, current usage, and refused size. #940: access_token() keeps the token in memory only (re-derived from the refresh token in credentials.json); save_state() writes 0600 via _write_private_json and strips any legacy access_token key; init() creates state.json privately too.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 11 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 078977691f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| acct = self._upload_accounting(conn) | ||
| up_24h = acct["uploads_24h_bytes"] | ||
| hard_stop = acct["daily_upload_hard_stop_bytes"] | ||
| if up_24h + nbytes > hard_stop: |
There was a problem hiding this comment.
Account for uploaded bytes even when verification fails
If Drive accepts a bundle's payload but the subsequent metadata GET fails (for example, with HTTP 503), upload() raises before recording any upload bytes in the ledger. Retrying starts a fresh upload, while this check still sees unchanged usage, so two 400 GB attempts can both pass the 700 GB daily hard stop. A mocked reproduction with a 100-byte limit allowed two 60-byte uploads and left the ledger at zero. Account for transferred bytes independently of successful verification so failed attempts cannot bypass the new guardrail.
Useful? React with 👍 / 👎.
Summary
Closes out the three repo-health issues filed against cold-store-reaper v1/v2 (Drew approved 2026-10-26).
#938 — upload hard stop + project budget now enforced
statusused for display is extracted intoColdStore._upload_accounting()(rolling-24htransfer_ledgerupload bytes, verified cold bytes = sum of verified bundles,daily_upload_hard_stop_bytes/project_budget_bytesfrommeta).status_data()now consumes it too — one implementation, so readout and enforcement can never disagree._check_upload_limits(conn, nbytes, what)raisesColdStoreErrornaming the limit, the current usage, and the refused size whenuploads_24h + nbytes > hard_stoporcold_bytes + nbytes > budget.upload()(after the already-verified early return, before the bundle is markeduploading) and input_backup()(before the folder lookup, so a refusal causes zero Drive writes). Note: contrary to the issue-era assumption, no write path enforced the limits — the bundle path included — so the shared helper is new, not a duplicate.#940 — access token no longer persisted
access_token()keeps the token (and its expiry) in memory only, re-deriving it from the refresh token incredentials.json(0600) when missing/expiring. Nothing about the token touchesstate.json.save_state()now writes via_write_private_json(0600) and strips any legacyaccess_tokenkey a pre-fix state file may hold;init()createsstate.jsonprivately as well. The now-unused plain_write_jsonhelper is removed.state.jsonaccurately: mode 600, folder IDs + D1 pointers, no tokens.#939 — retention verified, no code gap
prune-backups(v3, PR #965) already implements every acceptance point: 30 daily / 12 weekly / 12 monthly per DB as the union of newest-per-day/week/month over the folder listing, decisions driven by the dated filenames (never the wall clock, unparseable names never pruned), trash viafiles.update {trashed: true}(never delete), dry-run by default, onetransfer_ledgerrow per trashed file, covered by fake-Drive tests (TestPruneBackups: plan, apply, 400-file long history, all-DBs), wired intoscripts/nightly-backup.shstep 3, and the README retention section already documents the enforced behavior. The issue will be closed with a comment citing PR #965 and the first live nightly run (2026-10-26, two superseded D1 exports trashed under this policy).Tests
55 tests, OK (1 pre-existing skip = node worker-decoder): 49 prior + 6 new.
TestUploadLimits: upload refused at the daily stop with zero Drive writes (no session/file/folder; bundle stayssealed); upload refused when the rolling ledger alone crosses the stop;put-backuprefused at the project budget before any Drive contact; just-under-limit upload + put-backup succeed.TestStateHygiene: afteraccess_token()+ensure_folders(), state.json bytes contain no token material, noaccess_tokenkey, mode is 0600; a legacy state carrying a token is purged on the next save.Refs #938, #940, #939.
Need help on this PR? Tag
@codesmith-botwith what you need.