Repository navigation
fix(aws-control): report the last retention sweep's result - #19783
Conversation
…s read
A retention sweep ends in one of several terminal states -- retention off or
its setting unreadable, authorization refused, an untrusted listing,
authorization withdrawn before deletion, the keep count withdrawn mid-sweep,
cleanup failed, a declined sessions sweep, or a normal finish -- and every one
of them reached only the SEL audit event and a log line. GET
/backup/{account} served the configured keep count and nothing about whether
any sweep had acted on it, so a sweep refused every night looked identical to
a working one.
Persist the last sweep's ending per kind under retention_last_sweep in
backup.json and serve it as retentionLastSweep:
{kind: {result, skipped, retired, versions, at}}. result is successful,
refused or failed, split the way the audit event splits them (a credential
failure at a gate is failed, a gate decision is refused); skipped is the
sweep's own fixed reason text, never an exception message; retired and
versions are the audit event's counts; at is taken under the state lock, so
the record a reader sees is never older than the one it replaced. Unlike
retentionUnclaimed it is written on every
terminal path, the refusing ones included, and a later sweep replaces the
kind's record, so a success never outlives the refusals after it. The write
is best-effort and never fails the backup, like the recorders beside it.
Fixes #12491
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that [DESIGN-REVIEWED] 3ca5fdf Description read[DESCRIPTION-READ] fea3a231a1ac2ca903d5450ccef856296e81b39b1775c8875c392f65d94271da That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Before merge, confirm #12491 asks for an HTTP-only field. Nothing in the repo reads What this change shipsInventory (8 items) — 8 justifiedIntent: let an operator see from the backup status read whether each kind's retention sweep is actually working or refused every night. It is framed as a FIX, but it is an ADDITION that closes the observability gap #12491 reports.
[FIRST-PRINCIPLES-REVIEWED] 3ca5fdf Description read[DESCRIPTION-READ] 1ac6e96f85b8cba22e9c2736fe79f60da413eed86e457016a1ee292c13e6124a That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
|
|
|
c936b12 to
4dd311e
Compare
|
|
4dd311e to
1a783d6
Compare
|
|
…s with the audit The overtaken-recorder test compared two live clock reads strictly, which two reads in one Windows clock tick cannot satisfy; it now reads a pinned clock that advances one second per read. The declined sessions sweep's audit payload keeps skipped empty as before; only the published last-sweep record carries the reason. The already-filed check for gate refusals is written once and shared by the audit helper and the published record. The gate's teardown refusal, the one it files as failed, is told apart by its own named text, so it is published as failed while an access decision made during a shutdown is still published as refused.
1a783d6 to
3ca5fdf
Compare
|
self-added: yes
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (9 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: the aws-control retention sweep now records how each kind's last sweep ended (successful, refused or failed) and the backup status read serves it, so a sweep refused every night no longer looks like a working one. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/system-specs/modules/aws-control.md.
Problem / Motivation
Goal: The aws-control backup status read says how each kind's last retention sweep ended, refusals included, so a sweep refused every night no longer looks identical to a working one.
A retention sweep can end in several terminal states: retention off or its setting unreadable, authorization refused, a listing it would not trust, authorization withdrawn before deletion, the keep count withdrawn mid-sweep, cleanup failed, or a declined sessions sweep. Each one reaches only the SEL audit event and a log line.
GET /backup/{account}serves the configuredretentionKeepand nothing about whether any sweep acted on it. A successful sweep cannot say what it retired either.Why it matters
An operator enables retention, the S3 bill does not fall, and nothing in the app says why. Authorization withdrawn and cleanup failed are both states an operator can fix once they know about them, and today they are invisible from the endpoint where retention is configured.
Not a goal
retentionKeep,retentionUnclaimedandretentionUnrecorded.What changed (motivation → approach → change)
The status read now carries
retentionLastSweep: per kind, how the last sweep ended.resultsuccessful,refused(an authorization gate decided against it) orfailed(anything else, including a credential error at a gate)skippedretired,versionsatEvery terminal state reached only the audit trail because nothing wrote a record on those paths. The precedent for a fix already exists:
retentionUnclaimedpersists a stamped per-kind record inbackup.jsonand serves it from the same read.The sweep in
backup_parts/retention.pynow calls one best-effort recorder,_record_last_sweep, on every terminal path. The sessions decline inbackup.pycalls it too. Unlike the unclaimed pair, it writes on the refusing paths, because the refusal is the fact worth publishing. Therefused/failedsplit is the audit event's own, so the two never disagree about one ending. A later sweep replaces the kind's record, so a success never outlives the refusals after it. The stamp is taken under the state lock, so the record a reader sees is never older than the one it replaced. A failed write never fails the backup.routes.pyserves the record, anddocs/system-specs/modules/aws-control.mddocuments it.Backwards compatibility
Compatible: one new key in the state document and one new field on the status read. Existing fields, audit events and sweep behaviour are unchanged, and an install with no record reads
{}.Removes nothing: the diff only adds a record, a reader and a response field.
Tests
test_aws_control_backup_retention.py: every terminal state publishes itsresultandskipped, including retention off, an unusable count, both authorization gates (a gate decision vs. a credential error), an untrusted listing, the count withdrawn, switched off or garbled mid-sweep, cleanup failed, and a half-finished purge with its erased count. Also covered: a refusal replacing an earlier success, per-kind isolation, absence before any sweep, a corrupted record, a failed state write, and a recorder overtaken at the lock.test_aws_control_backup.py: a declined sessions sweep replaces a stale success.test_aws_control_routes.py: the status read servesretentionLastSweepbesideretentionKeep, per account, on the unpolled half.test_aws_control_backup_composition_contract.py: the new names on the facade.Each recorder call site was removed one at a time, and each removal turns at least one of these tests red.
Manual verification
N/A — unit coverage sufficient: the change is a state write and a read of local state, and every terminal path is driven through the fake drive.
Related Issues
Fixes #12491
Pattern harvest
Rule candidate: review-prompt
Pattern: a terminal outcome of a background operation, a refusal above all, written only to the audit log and logs and never to the status read where that operation is configured
Checklist