Repository navigation
feat(storage-lifecycle): a named retention control counts only when explicitly verified - #24357
Conversation
…xplicitly verified A hold naming a control with control_verified missing or null was treated as bounded; it now fails closed. No live impact: the contract sets false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
2 issues found across 2 files
Confidence score: 3/5
- In
backend/scripts/retention_contract.py, a hold missing bothcontrolandcontrol_verifiedis treated as bounded, so a 30-day staging Delete can pass despite the 8-day floor. Treat missing control fields as unbounded. - The module-level retention summary in
backend/scripts/retention_contract.pydoesn’t describe the fail-closed behavior for missing, null, or other non-Truevalues. Update it to match the branch.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/scripts/retention_contract.py">
<violation number="1" location="backend/scripts/retention_contract.py:32">
P1: The gate is keyed on the presence of `control` or `control_verified`, so a hold that drops both fields is treated as bounded. With the 2 h alarm hold reduced to an 8-day floor, a 30-day staging Delete then passes, which is the outcome this PR is meant to prevent. Make the default fail closed for any hold that is not explicitly marked as control-free, and add a test that removes both keys.</violation>
<violation number="2" location="backend/scripts/retention_contract.py:32">
P3: Update the module-level retention summary to match this fail-closed branch: it still describes only `control_verified false`, while missing, null, and other non-`True` values now make a referenced control unbounded.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| return hold.get('control_verified') is False or (hold.get('ruling') == 'pending' and not accept_pending) | ||
| """Not yet a bound: the hold names a control that is not explicitly verified (missing or null fails closed), or | ||
| the ruling is pending. accept_pending asks "would a pending ruling fit?"; it never waives an unverified control.""" | ||
| unverified = ('control' in hold or 'control_verified' in hold) and hold.get('control_verified') is not True |
There was a problem hiding this comment.
P1: The gate is keyed on the presence of control or control_verified, so a hold that drops both fields is treated as bounded. With the 2 h alarm hold reduced to an 8-day floor, a 30-day staging Delete then passes, which is the outcome this PR is meant to prevent. Make the default fail closed for any hold that is not explicitly marked as control-free, and add a test that removes both keys.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/scripts/retention_contract.py, line 32:
<comment>The gate is keyed on the presence of `control` or `control_verified`, so a hold that drops both fields is treated as bounded. With the 2 h alarm hold reduced to an 8-day floor, a 30-day staging Delete then passes, which is the outcome this PR is meant to prevent. Make the default fail closed for any hold that is not explicitly marked as control-free, and add a test that removes both keys.</comment>
<file context>
@@ -27,9 +27,10 @@ def load(path: Path = CONTRACT_PATH) -> dict[str, Any]:
- return hold.get('control_verified') is False or (hold.get('ruling') == 'pending' and not accept_pending)
+ """Not yet a bound: the hold names a control that is not explicitly verified (missing or null fails closed), or
+ the ruling is pending. accept_pending asks "would a pending ruling fit?"; it never waives an unverified control."""
+ unverified = ('control' in hold or 'control_verified' in hold) and hold.get('control_verified') is not True
+ return unverified or (hold.get('ruling') == 'pending' and not accept_pending)
</file context>
| return hold.get('control_verified') is False or (hold.get('ruling') == 'pending' and not accept_pending) | ||
| """Not yet a bound: the hold names a control that is not explicitly verified (missing or null fails closed), or | ||
| the ruling is pending. accept_pending asks "would a pending ruling fit?"; it never waives an unverified control.""" | ||
| unverified = ('control' in hold or 'control_verified' in hold) and hold.get('control_verified') is not True |
There was a problem hiding this comment.
P3: Update the module-level retention summary to match this fail-closed branch: it still describes only control_verified false, while missing, null, and other non-True values now make a referenced control unbounded.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/scripts/retention_contract.py, line 32:
<comment>Update the module-level retention summary to match this fail-closed branch: it still describes only `control_verified false`, while missing, null, and other non-`True` values now make a referenced control unbounded.</comment>
<file context>
@@ -27,9 +27,10 @@ def load(path: Path = CONTRACT_PATH) -> dict[str, Any]:
- return hold.get('control_verified') is False or (hold.get('ruling') == 'pending' and not accept_pending)
+ """Not yet a bound: the hold names a control that is not explicitly verified (missing or null fails closed), or
+ the ruling is pending. accept_pending asks "would a pending ruling fit?"; it never waives an unverified control."""
+ unverified = ('control' in hold or 'control_verified' in hold) and hold.get('control_verified') is not True
+ return unverified or (hold.get('ruling') == 'pending' and not accept_pending)
</file context>
Summary
Follow-up to #24349. A retention hold that names a control (for example
batch_finalization_alarm's stuck-unit alarm) now counts as bounded only whencontrol_verifiedis explicitlytrue. If the field is missing,nullor any other value, the check fails closed. Luna found this fail-open on the workspace copy of the same logic.There is no live impact today: the checked-in contract sets
control_verified: falseexplicitly. This change stops a future edit from silently dropping the field and turning batch staging's 30-day Delete into a pass.Changes
backend/scripts/retention_contract.py:_pending()treats a hold withcontrolorcontrol_verifiedas unverified unlesscontrol_verified is True.backend/tests/unit/test_retention_contract.py: covers a missing field,null,"yes"and1(all unbounded), andtrue(8 d floor).Verification
backend/test.shwithBACKEND_UNIT_TEST_FILE_LIST=test_retention_contract.pyandtest_sync_staging_lifecycle_guard.py: 26 + 27 passed, run throughbin/omi-heavywith no ambient credentials.Product invariants affected
none
Risk / rollout
No deploy, flag, IAM or data change. Operator-run gate only. Rollback: revert.
🤖 Generated with Claude Code