Skip to content

feat(storage-lifecycle): a named retention control counts only when explicitly verified - #24357

Merged
Git-on-my-level merged 1 commit into
mainfrom
deployfacts/retention-control-verified
Nov 2, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
deployfacts/retention-control-verified

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

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 when control_verified is explicitly true. If the field is missing, null or 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: false explicitly. 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 with control or control_verified as unverified unless control_verified is True.
  • backend/tests/unit/test_retention_contract.py: covers a missing field, null, "yes" and 1 (all unbounded), and true (8 d floor).

Verification

backend/test.sh with BACKEND_UNIT_TEST_FILE_LIST = test_retention_contract.py and test_sync_staging_lifecycle_guard.py: 26 + 27 passed, run through bin/omi-heavy with 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

View guided diff Turn on auto-fix

…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]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-02T06:53:17.329785Z
We couldn’t complete this review. Comment @codex review to try again.
d05f80f PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 2 files

Confidence score: 3/5

  • In backend/scripts/retention_contract.py, a hold missing both control and control_verified is 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.py doesn’t describe the fail-closed behavior for missing, null, or other non-True values. 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>

@Git-on-my-level
Git-on-my-level merged commit d146aa0 into main Nov 2, 2026
65 checks passed
@Git-on-my-level
Git-on-my-level deleted the deployfacts/retention-control-verified branch November 2, 2026 07:07
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.

1 participant