Skip to content

docs(batch): held/dead-letter state table and ownership rule - #24753

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/lccontract
Nov 6, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/lccontract

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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

  • Via bin/omi-heavy, new consistency test + lifecycle writer/invariant suites: 1,909 passed, 75 expected failures (declared lifecycle gaps).
  • Final combined run: 1,909 passed, 75 xfailed in 91.73s; the fourth contract test pins retained-shape text.
  • make preflight on final commit: 36 checks passed in 233.17s. Initial run invalidated by a concurrent commit; rerun against a stable tree passed.
  • scripts/pr-preflight --suggest: no locked invariant citations or fix-class declaration required. Full --pr-body-file run passed 35 checks; final metadata-only validation passed.
  • Normal pre-push hook: PASSED (shared preflight, type check with 0 errors, seven selected backend test files, format and release-contract checks); normal push succeeded. No bypass, custom cap or force.
  • Required Grok review via agentctl-portable and cursor-delegation: first review exec-jewel-inmate-quick-hurt-live-desert found a misplaced finalization budget requeue and writer/test gaps. Corrected leased-to-queued budgeting, privacy/retry/receipt writer citations and retained-shape doc assertions; follow-up exec-couple-burger-west-despair-day-boat: no remaining actionable findings. Both reviews were local read-only Grok through agentctl.

No merge/deploy requested or performed.

View guided diff Turn on auto-fix

@chatgpt-codex-connector

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

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 ✅ Completed 2026-11-06T06:00:26.312513Z 92f5b8d 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.

@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 2 files

Confidence score: 4/5

  • backend/tests/unit/test_batch_held_contract.py can 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 a model.expr value.
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)

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

@Git-on-my-level
Git-on-my-level merged commit 088e1b3 into main Nov 6, 2026
64 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/lccontract branch November 6, 2026 06:16
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