Repository navigation
fix(aws-control): read a "null" version id as unprovable in retention ownership - #17990
Conversation
… ownership _current_version_is_ours decides whether a key's current version is the archive this install wrote, and the retention sweep (a delete) uses that answer to grant keep slots and to run at all. It ended in a string equality after guarding only an empty recorded id. S3 gives the id "null" to every object written while the bucket's versioning is SUSPENDED, and an overwrite there replaces that version rather than adding one. So a co-writer's overwrite of a shared key is also "null", and two "null" ids compared equal reported a foreign object as ours. Route both the recorded id and the current row's versionId through _is_provable_version_id (added by #12381, already used on both sides of the nightly skip), which is false for "" and for "null". An unprovable id on either side now reads as not-ours, the fail-closed direction. Closes #12394 Refs #12381 Refs #12159
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS On a suspended-versioning bucket, retention now never runs, and the audit gives a misleading reason. The PR doesn't mention this. Watch
[DESIGN-REVIEWED] cb949aa Description read[DESCRIPTION-READ] a9806b429034d891dca35c8e3e09f8ff6b3b159914bacabb0b3f8ff89db6cfbe 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 After this change, keys recorded as What this change shipsInventory (3 items) — 3 justifiedIntent: stop the retention sweep from mistaking another install's object for this install's own archive when the bucket's versioning is suspended. This is a FIX (#12394).
[FIRST-PRINCIPLES-REVIEWED] cb949aa Description read[DESCRIPTION-READ] 45b0974583f30cd8a7a3088da46f79906af74f709e3f45a217ef6b0727cf02f0 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsAdvisory only, nothing blocks: a recorded FINDING — src/kiro_crew/apps/builtins/aws_control/backend/backup_parts/retention.py:408 — On a bucket with versioning suspended, [OPUS-REVIEWED] cb949aa 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: |
|
This stops the retention sweep from treating a co-writer's object as our archive on a bucket whose versioning is suspended. Under suspended versioning both sides report versionId "null". The core fix is right and fails closed: both ids now go through |
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed: both sides of the version-id comparison now go through _is_provable_version_id, so two "null" ids can't pass a foreign object as ours. Tests cover both sides plus the control. LGTM.
Problem / Motivation
Goal: Stop the aws-control retention sweep from treating a co-writer's object as this install's own archive when the drive's versioning is suspended.
The retention sweep is a delete. It asks
_current_version_is_ourswhether a key's current version is the archive this install wrote, and uses that answer to decide whether a key may hold a keep slot and whether the sweep may run. That check ended in a plain string equality, guarding only an empty recorded id. S3 gives the id"null"to every object written to a key while the bucket's versioning is suspended, so a recorded"null"and a co-writer's overwrite are both"null"and compared equal — the foreign object read as ours.Why it matters
The drive is reachable by more than one install by design, and suspended versioning is an operator-side bucket state the product does not control. When the sweep reads a foreign object as ours, it can proceed on and count keep slots for a key it never wrote, so what retention retires is decided partly by another install's object.
Not a goal
"null"means or how_is_provable_version_idclassifies it — that was settled by feat(aws-control): stop the nightly re-uploading a tree that has not changed #12381.What changed (motivation → approach → change)
A version id is only worth comparing when it identifies one version.
_current_version_is_ours(inbackup_parts/retention.py) only guarded an empty recorded id, so a"null"id — which names something but not one thing — slipped through and two unrelated"null"ids compared equal. The fix routes both the recorded id and the current row'sversionIdthrough_is_provable_version_id(added by #12381, already used on both sides of the nightly skip's own comparison), which is false for""and for"null". An unprovable id on either side now reads as not-ours, the fail-closed direction, so a foreign"null"object can no longer pass as our archive.Backwards compatibility
Compatible: the change only makes
_current_version_is_oursreturn False in more cases (an unprovable id on either side), narrowing which keys retention treats as ours — it never widens them, so no key kept today stops being kept and nothing a caller relies on changes shape.Removes nothing: no path, record, key or public function is hidden, deleted or renamed; this is a one-function predicate tightening with no reader-facing surface removed.
Tests
Added three cases to
test_aws_control_backup_retention.py, beside the existing empty-recorded case:"null"against a current"null"row returns False (the suspended-versioning collision);"null"row returns False (the other side of the comparison);Determinism: the three are pure in-process calls on a hand-built row (no clock, port, network or sleep); they pass under
-n 2and under shuffled order. Bug caught: with the production hunk reverted,test_a_null_recorded_id_from_suspended_versioning_is_not_oursfails (two"null"ids compare equal); with the fix it passes.Manual verification
N/A — unit coverage sufficient; the behaviour is a pure predicate with no I/O or UI.
Screenshots / video
N/A — no user-visible frontend surface is touched (backend aws-control retention logic only).
Related Issues
Closes #12394
Pattern harvest
Rule candidate: review-prompt
Pattern: a value that names "something but not one thing" (the suspended-versioning
"null"id) used in a string-equality identity check — guard it with the same provability predicate on BOTH sides, not just the empty case, and convert every caller of such a predicate when one caller is converted.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)