Skip to content

Expire restorable capped projection holds behind a dark switch - #24916

Merged
Git-on-my-level merged 8 commits into
mainfrom
lane/backlog-release-wedge
Nov 8, 2026
Merged

Git-on-my-level merged 8 commits into
mainfrom
lane/backlog-release-wedge

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Requested by David

Summary

Fixes a wedge on the projection release path. A restorable quarantine_held row that reaches MAX_RELEASE_ATTEMPTS=3 was never released and never expired, so it stayed forever. Measured on 2026-11-08: about 44% of a 120-row assignment_held sample and about 15% of a 400-row quarantine_held sample sat at the attempt cap with no automatic exit.

The fix routes that branch through the existing one-time expiry CAS (_expire_assignment). It saves the capped count, resets attempts to zero once, and waits for the nightly redrive. It never releases in the same pass.

Dark by default. Behind BATCH_PIPELINE_PROJECTION_RESTORABLE_CAP_EXPIRY_ENABLED, default OFF. With the switch OFF, behaviour is identical to origin/main.

Safety

  • Cap semantics unchanged: MAX_RELEASE_ATTEMPTS stays 3. The requeue cap (PR fix(batch,sync): explicit backlog state machine with owners, deadlines and attempt budgets #24893) is not touched.
  • With the switch ON, ordinary transactions refuse any row carrying an expiry stamp, including the other scan leg. Only the nightly redrive (dead_before strictly after the marker) releases a marked row.
  • Privacy fence: projection_privacy_refusal and any non-empty privacy_reason on the summary or any part refuse release and expiry before any write.
  • Persisted multipart suffix rows and open operator intents are excluded from expiry.
  • Existing not-restorable expiry is unchanged origin behaviour, per the contract (CONTRACT.md around line 282).
  • Flag is registered in kill_switches.py, flag_budget.json, config/feature-flags.yaml, and the generated registry doc.

Verification

Failure-Class: none

  • test_batch_pipeline_projection_release.py: 215 passed. Flag-budget test: 24 passed. Unit policy: 82 passed. New cases each under 0.5 s.
  • make preflight: 41 checks passed. Typecheck: 0 errors.
  • Reviews (two fresh Luna reviews at 718cd64cf6, GLM flash blocked by a host timeout): both APPROVE, no findings.
  • Earlier blocking findings, all fixed: a same-scan re-release through the second leg (round 1), and a privacy-marked multipart hold reaching the expiry CAS (round 2).

Not verified: CI, production behaviour, integration with newer origin/main. No deploy: enabling the switch is a prod flag flip and waits for David's morning gate.

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Route opted-in restorable holds at the existing release cap through the same one-time deadline and expiry CAS as unrestorable holds. Preserve all eligibility fences, retained state, and cap semantics; never release during the expiry pass.

Failure-Class: FC-state-deadline-without-reader-exit
When the dark restorable-cap expiry switch is on, refuse ordinary release transactions carrying an expiry stamp. This fences the jobs scan leg and later ordinary passes after the results leg resets attempts. Preserve OFF behavior and all existing nightly eligibility and cutoff checks.

Failure-Class: FC-state-deadline-without-reader-exit
With the dark restorable-cap expiry switch enabled, refuse summary or part privacy markers before release, gate-failure expiry, or capped expiry can write. Preserve flag-off behavior and all cap semantics. Cover summary, quarantined and ready part markers, explicit refusal, nightly redrive, and one-time non-privacy expiry.

Failure-Class: FC-state-deadline-without-reader-exit
@Git-on-my-level Git-on-my-level self-assigned this Nov 8, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T12:55:12.749087Z ecc1203 New commits
ℹ️ 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.

…wedge

# Conflicts:
#	backend/config/policy/kill_switches.py
#	backend/tests/unit/test_batch_pipeline_projection_release.py
#	config/feature-flags.yaml

@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.

1 issue found across 9 files

Confidence score: 3/5

  • With the flag on, this guard in backend/database/batch_pipeline_projection_release.py blocks normal-pass release for every expired row, so restorable non-capped holds wait until the nightly redrive. Limit the guard to the same-pass cross-leg case.

You’re at about 98% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].

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/database/batch_pipeline_projection_release.py">

<violation number="1" location="backend/database/batch_pipeline_projection_release.py:193">
P2: This guard blocks normal-pass release of every expired row when the flag is on, not only capped ones. Restorable non-capped expired holds now wait for the nightly redrive. Limit the guard to the same-pass cross-leg case, or to capped rows, so the flag changes only what the PR describes.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

# may already have expired this row and reset its attempt count.
if (
dead_before is None
and entry.get('held_expired_at') is not None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This guard blocks normal-pass release of every expired row when the flag is on, not only capped ones. Restorable non-capped expired holds now wait for the nightly redrive. Limit the guard to the same-pass cross-leg case, or to capped rows, so the flag changes only what the PR describes.

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/database/batch_pipeline_projection_release.py, line 193:

<comment>This guard blocks normal-pass release of every expired row when the flag is on, not only capped ones. Restorable non-capped expired holds now wait for the nightly redrive. Limit the guard to the same-pass cross-leg case, or to capped rows, so the flag changes only what the PR describes.</comment>

<file context>
@@ -185,8 +186,24 @@ def release(self, segment_id: str, now: float, *, dead_before: float | None = No
+            # may already have expired this row and reset its attempt count.
+            if (
+                dead_before is None
+                and entry.get('held_expired_at') is not None
+                and projection_restorable_cap_expiry_enabled()
+            ):
</file context>

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3500d661d2

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +308 to +311
if projection_restorable_cap_expiry_enabled():
# Use the same deadline/one-time CAS as unrestorable holds;
# any release must wait for a later pass after the reset.
return self._expire_assignment(transaction, segment_id, entry, now, expired, attempts)

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 Badge Add the required pipeline lifecycle change note

This changes the conversation projection lifecycle by allowing capped, restorable holds to expire and later re-enter assignment, but the commit does not include the pipeline change note required by backend/AGENTS.md. The changed-file inventory and a search of backend/docs/listen_pusher_pipeline/changes/ confirm that this switch has no corresponding note. Add a dated note describing the capped-hold transition, default-off rollout, nightly redrive fence, and verification evidence; updating the batch contract and flag registry does not replace that required lifecycle record.

AGENTS.md reference: backend/AGENTS.md:L164-L164

Useful? React with 👍 / 👎.

…wedge

# Conflicts:
#	config/feature-flags.yaml
With the cap-expiry flag on, the privacy guard returned before ghost
classification, so refused rows never reached ghost_classified or
ghost_skipped_*. Return the same classification and age bucket the
gate-failure branch uses. The tuple is read-only: no release, expiry or
settle.

Failure-Class: none
@Git-on-my-level
Git-on-my-level merged commit 0dc944b into main Nov 8, 2026
67 of 70 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/backlog-release-wedge branch November 8, 2026 13:28
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