Repository navigation
docs(batch): held/dead-letter state table and ownership rule - #24753
Conversation
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. |
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 4/5
backend/tests/unit/test_batch_held_contract.pycan pass even when an expiry metric appears only in alert annotations, leaving the PromQL contract unguarded. Parse the JSON and assert each expiry metric appears in amodel.exprvalue.
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/tests/unit/test_batch_held_contract.py">
<violation number="1" location="backend/tests/unit/test_batch_held_contract.py:113">
P2: This assertion can pass when a required metric appears only in alert annotations, not in any PromQL expression. Parse the JSON and assert each expiry metric occurs in a `model.expr` value so the guard detects an unwired alert.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| } | ||
| assert expiry <= metrics, 'Keep all retained-expiry metric families in the contract' | ||
| alert = (BACKEND / 'charts/monitoring/alerts/batch-held-dead-letter.json').read_text() | ||
| assert all(re.search(rf'\b{metric}\b', alert) for metric in expiry) |
There was a problem hiding this comment.
P2: This assertion can pass when a required metric appears only in alert annotations, not in any PromQL expression. Parse the JSON and assert each expiry metric occurs in a model.expr value so the guard detects an unwired alert.
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/tests/unit/test_batch_held_contract.py, line 113:
<comment>This assertion can pass when a required metric appears only in alert annotations, not in any PromQL expression. Parse the JSON and assert each expiry metric occurs in a `model.expr` value so the guard detects an unwired alert.</comment>
<file context>
@@ -0,0 +1,137 @@
+ }
+ assert expiry <= metrics, 'Keep all retained-expiry metric families in the contract'
+ alert = (BACKEND / 'charts/monitoring/alerts/batch-held-dead-letter.json').read_text()
+ assert all(re.search(rf'\b{metric}\b', alert) for metric in expiry)
+ assert 'batch_held_dead_letter' in (BACKEND / 'utils/batch_pipeline/held_dead_letter.py').read_text()
+
</file context>
Change
Projection and held state now have one owned contract before lifecycle phases 2, 4c and 5. Document the current batch, projection, finalization, record-audio custody and conversation state tables, including writers, deadlines, observability, switches and rollback gaps. Reserve terminal_family and follow-on work as PLANNED.
Pin the retained shapes from #24736 (b6b1539) and #24745 (3b09c0c): batch merge_pending=true preserves legacy dead-row re-drive; projection keeps quarantine_held and normalizes the capped release counter once. Only uicleanup may introduce another held/dead-letter shape through a CONTRACT.md PR (lead2 2f9297 / PA-1106-01). Dead-lettering never deletes retained content.
Correct the older Inputs and outputs description: successful recovery is recovery_state=recovered with state=result_ready, rather than "completed"; failed_held is a recovery outcome, not an absorbing batch state.
Add a small offline consistency test comparing table keys to the shared lifecycle inventory and checking documented flags against runtime literals/registry, metrics against source (including generated PhaseMetrics names), expiry metrics against the existing alert, and required retained-shape spellings in the contract. Existing dedicated 4a/4b runtime tests own CAS behavior. It uses the existing backend unit-test lane; no additional CI primitive or workflow is needed. It guards drift in the actual shapes whose pre-change recovery compatibility needed review fixes in #24736/#24745.
No runtime, deployment, GCP, or .github changes. Pre-existing Flutter worktree edits are excluded.
Validation
No merge/deploy requested or performed.