Skip to content

fix(aws-control): read a "null" version id as unprovable in retention ownership - #17990

Merged
cruisercohen merged 1 commit into
mainfrom
fix/aws-control-retention-12394
Oct 8, 2026
Merged

cruisercohen merged 1 commit into
mainfrom
fix/aws-control-retention-12394

Conversation

@cruisercohen

Copy link
Copy Markdown
Contributor

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_ours whether 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

What changed (motivation → approach → change)

A version id is only worth comparing when it identifies one version. _current_version_is_ours (in backup_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's versionId through _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_ours return 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:

  • a recorded "null" against a current "null" row returns False (the suspended-versioning collision);
  • a provable recorded id against a current "null" row returns False (the other side of the comparison);
  • a provable, matching current version is still ours (the control, so the routing cannot refuse a legitimate match).

Determinism: the three are pure in-process calls on a hand-built row (no clock, port, network or sleep); they pass under -n 2 and under shuffled order. Bug caught: with the production hunk reverted, test_a_null_recorded_id_from_suspended_versioning_is_not_ours fails (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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

… 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
@cruisercohen
cruisercohen requested a review from a team as a code owner October 8, 2026 03:56
@cruisercohen
cruisercohen enabled auto-merge (squash) October 8, 2026 03:56
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision cb949aa6b8b3cd268cbb381acee525acf3774ea4 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — 🟡 CONCERNS

Design-level review of cb949aa6b8b3cd268cbb381acee525acf3774ea4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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

  • Retention stops for good on suspended-versioning buckets, and the reported reason is wrong. The fix itself is right: deleting version "null" would erase a co-writer's object. But on these buckets every archive this install uploads is also recorded as "null". Its key is then never in live, so newest_key not in live trips on every run. The sweep is skipped and audited failed with "the archive this run uploaded is not the current version of its key", which is false when the cause is the bucket's versioning state. Archives pile up with no limit, and the operator is told about a co-writer collision that may not exist. The unclaimed floor also misses these keys, because unclaimed = [key for key in by_key if not our_versions.get(key, "")] only counts empty ids. The description says the change "never widens" what counts as ours, but it doesn't say that the whole sweep now stops on these buckets.
    Clears when: the description admits that retention stops on suspended-versioning buckets, and either the skip reason names unprovable ("null") version ids, or unclaimed uses _is_provable_version_id so these keys show up in the floor.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of cb949aa6b8b3cd268cbb381acee525acf3774ea4 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

After this change, keys recorded as "null" show up in neither live nor unclaimed, because retention.py:950 still only checks for an empty id. Is that silence in the audit intended?

What this change ships

Inventory (3 items) — 3 justified

Intent: 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).

  1. A recorded "null" version id no longer counts as proof that a key is ours. Such keys hold no keep slot and the sweep never deletes them. — justified
  2. A current version reporting "null" no longer matches any record, so a co-writer's overwrite stops passing as our archive. — justified
  3. Three unit tests covering both sides of the comparison plus a control case that still matches. — justified

[FIRST-PRINCIPLES-REVIEWED] cb949aa

Description read

[DESCRIPTION-READ] 45b0974583f30cd8a7a3088da46f79906af74f709e3f45a217ef6b0727cf02f0

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed cb949aa6b8b3cd268cbb381acee525acf3774ea4 — this comment is updated in place on each push.

Review details

Advisory only, nothing blocks: a recorded "null" version id now counts as neither live nor unclaimed.

FINDING — src/kiro_crew/apps/builtins/aws_control/backend/backup_parts/retention.py:408 — On a bucket with versioning suspended, put-object records "null", and uploaded_versions keeps it because any non-empty string passes. _current_version_is_ours now returns False for that id, so the key leaves live. But unclaimed = [key for key in by_key if not our_versions.get(key, "")] (line 950) only matches a missing id, so these bytes, which can never be reclaimed, are left out of unclaimed/unclaimedBytes and out of the persisted floor. On top of that, every nightly run is audited failed with the false reason "the archive this run uploaded is not the current version of its key" (line 979). → Fix: build unclaimed with not _is_provable_version_id(our_versions.get(key, "")). Give the skip its own reason (unprovable or suspended versioning) when the recorded id for newest_key is unprovable.

[OPUS-REVIEWED] cb949aa

Verdict parsed from the review's SHA-scoped output markers for commit cb949aa6b8b3cd268cbb381acee525acf3774ea4.

False positive or not applicable? A repository writer can comment:
/ai-review override fable cb949aa6b8b3cd268cbb381acee525acf3774ea4: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of cb949aa6b8b3cd268cbb381acee525acf3774ea4 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] cb949aa

False positive or not applicable? A repository writer can comment:
/ai-review override gpt cb949aa6b8b3cd268cbb381acee525acf3774ea4: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 8, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

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 _is_provable_version_id before the comparison, and the three tests pin both sides plus a control. The Design CONCERNS and the Opus advisory on head cb949aa are real, though, and have no disposition. I confirmed both. On such a bucket every archive this install uploads is also recorded as "null", so newest_key not in live (retention.py:977) trips on every run. Retention then never runs, and each night is audited failed with the false reason "the archive this run uploaded is not the current version of its key" (retention.py:984). Meanwhile unclaimed (retention.py:950) checks only for an empty id, so these keys also drop out of the unclaimed bytes and the floor. Suggested fix: build unclaimed with not _is_provable_version_id(our_versions.get(key, "")), give the skip its own reason when the recorded id for newest_key is unprovable, and say in the description that retention stops on these buckets. HOLD because this is the data-deletion path and the concerns are unanswered. Auto-merge is armed, so a maintainer should look before it lands. — crew-pr-reviewer

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cruisercohen
cruisercohen merged commit 70cc5ee into main Oct 8, 2026
146 of 148 checks passed
@cruisercohen
cruisercohen deleted the fix/aws-control-retention-12394 branch October 8, 2026 21:54
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws-control: retention reads a suspended-versioning "null" version id as proof an archive is ours

3 participants