Repository navigation
fix(batch): fence ghost settling on the record target and wake settled projections - #24898
Conversation
Require the normal transaction-fresh restorable-target fence before ghost settlement, then hand settled ids to the existing bounded tail. Keep completion privacy fences and settle caps intact. Lead2 rulings 934856 and 12c359. Failure-Class: FC-bounded-discovery-pinned-by-blocked-page Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ct; re-pin driver registry Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 140d3a6647
ℹ️ 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".
| def release_page(*args, **kwargs): | ||
| counts, next_after, _ = release_page_settled(*args, **kwargs) | ||
| return counts, next_after |
There was a problem hiding this comment.
Migrate in-tree callers instead of retaining compatibility wrappers
The new release_page wrapper preserves the retired two-value API solely for in-tree test callers; release_scan_pass does the same. Root AGENTS.md explicitly requires migrating in-tree callers together rather than preserving retired APIs with compatibility wrappers. Update those callers to consume the settled-ID-returning functions and remove both wrappers, avoiding duplicate APIs and registry entries for the same operation.
AGENTS.md reference: AGENTS.md:L34-L34
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
4 issues found across 14 files
Confidence score: 4/5
- The failure-class declaration in
.github/failure-classes/FC-settle-path-skips-sibling-fence-and-wake.jsondoes not match the fix commit, so registry validation may not recognize the new definition. Declare the PR asFailure-Class: newand update the fix commit trailer. - The
release_scan_passandrelease_pageshims inbackend/database/batch_pipeline_projection_release.pyare retained only for tests, contrary toAGENTS.md. Migrate those callers to the settled APIs and remove the shims. - The flag inventory in
backend/utils/batch_pipeline/CONTRACT.mdomitsBATCH_PIPELINE_PROJECTION_GHOST_SETTLE_WAKE_ENABLED, leaving its default and read location undocumented. Add the inventory row. - The rationale in
backend/docs/listen_pusher_pipeline/changes/2026-11-08-ghost-settle-wake.mdcites Lead2 rulings that readers cannot resolve from the repo. Link the decision record or state the rationale directly.
You’re at about 97% 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/utils/batch_pipeline/CONTRACT.md">
<violation number="1" location="backend/utils/batch_pipeline/CONTRACT.md:315">
P2: Add a row for `BATCH_PIPELINE_PROJECTION_GHOST_SETTLE_WAKE_ENABLED` to the flag inventory table. The row should give default `true`, location `config/policy/kill_switches.py` read by `projection.py` follow-up wake, and the disabled behavior. The contract says this table is the complete switch inventory, so the wake switch is currently missing from it.</violation>
</file>
<file name="backend/docs/listen_pusher_pipeline/changes/2026-11-08-ghost-settle-wake.md">
<violation number="1" location="backend/docs/listen_pusher_pipeline/changes/2026-11-08-ghost-settle-wake.md:3">
P3: The rationale cites 'Lead2 ruling 934856' and 'Lead2 ruling 12c359', which a reader cannot resolve from the repo. Replace them with a link to the decision record or state the rationale directly.</violation>
</file>
<file name="backend/database/batch_pipeline_projection_release.py">
<violation number="1" location="backend/database/batch_pipeline_projection_release.py:495">
P2: `release_scan_pass` and `release_page` are kept as `*args, **kwargs` shims only for in-tree tests, which AGENTS.md disallows. Migrate those test callers to `release_scan_pass_settled` and `release_page_settled`, then delete both shims. A caller that still uses `release_scan_pass` silently loses the settled IDs, so the wake never fires.</violation>
</file>
<file name=".github/failure-classes/FC-settle-path-skips-sibling-fence-and-wake.json">
<violation number="1" location=".github/failure-classes/FC-settle-path-skips-sibling-fence-and-wake.json:3">
P3: The new failure-class definition is not the class declared by the fix commit. Declare this PR as `Failure-Class: new` and update the fix commit trailer accordingly; otherwise registry validation treats this added definition as an unauthorized instance-fix registry mutation.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| Receipts, parts, jobs, audio, attempt counters and watermarks stay intact. The | ||
| existing discovery/completion/publication/acknowledgement path rechecks its own | ||
| fences. This is never `held_expired`; nightly expiry does not settle ghosts. | ||
| `BATCH_PIPELINE_PROJECTION_GHOST_SETTLE_WAKE_ENABLED` (default true) hands settled ids to the existing bounded follow-up tail; false restores discovery-only scheduling, with completion privacy fences unchanged. |
There was a problem hiding this comment.
P2: Add a row for BATCH_PIPELINE_PROJECTION_GHOST_SETTLE_WAKE_ENABLED to the flag inventory table. The row should give default true, location config/policy/kill_switches.py read by projection.py follow-up wake, and the disabled behavior. The contract says this table is the complete switch inventory, so the wake switch is currently missing from it.
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/utils/batch_pipeline/CONTRACT.md, line 315:
<comment>Add a row for `BATCH_PIPELINE_PROJECTION_GHOST_SETTLE_WAKE_ENABLED` to the flag inventory table. The row should give default `true`, location `config/policy/kill_switches.py` read by `projection.py` follow-up wake, and the disabled behavior. The contract says this table is the complete switch inventory, so the wake switch is currently missing from it.</comment>
<file context>
@@ -304,12 +304,15 @@ part owes ordinary discovery, not held expiry. In the existing
Receipts, parts, jobs, audio, attempt counters and watermarks stay intact. The
existing discovery/completion/publication/acknowledgement path rechecks its own
fences. This is never `held_expired`; nightly expiry does not settle ghosts.
+`BATCH_PIPELINE_PROJECTION_GHOST_SETTLE_WAKE_ENABLED` (default true) hands settled ids to the existing bounded follow-up tail; false restores discovery-only scheduling, with completion privacy fences unchanged.
| Result field | Rule |
</file context>
| return counts, next_after, settled | ||
|
|
||
|
|
||
| def release_scan_pass(*args, **kwargs): |
There was a problem hiding this comment.
P2: release_scan_pass and release_page are kept as *args, **kwargs shims only for in-tree tests, which AGENTS.md disallows. Migrate those test callers to release_scan_pass_settled and release_page_settled, then delete both shims. A caller that still uses release_scan_pass silently loses the settled IDs, so the wake never fires.
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 495:
<comment>`release_scan_pass` and `release_page` are kept as `*args, **kwargs` shims only for in-tree tests, which AGENTS.md disallows. Migrate those test callers to `release_scan_pass_settled` and `release_page_settled`, then delete both shims. A caller that still uses `release_scan_pass` silently loses the settled IDs, so the wake never fires.</comment>
<file context>
@@ -476,6 +489,11 @@ def release_scan_pass(store, *, limit: int, after_id: str | None, now: float, de
+ return counts, next_after, settled
+
+
+def release_scan_pass(*args, **kwargs):
+ counts, next_after, _ = release_scan_pass_settled(*args, **kwargs)
return counts, next_after
</file context>
| @@ -0,0 +1,17 @@ | |||
| # Fence ghost settlement and wake settled projection rows | |||
|
|
|||
| Lead2 ruling 934856: successful ghost settles hand their segment ids to | |||
There was a problem hiding this comment.
P3: The rationale cites 'Lead2 ruling 934856' and 'Lead2 ruling 12c359', which a reader cannot resolve from the repo. Replace them with a link to the decision record or state the rationale directly.
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/docs/listen_pusher_pipeline/changes/2026-11-08-ghost-settle-wake.md, line 3:
<comment>The rationale cites 'Lead2 ruling 934856' and 'Lead2 ruling 12c359', which a reader cannot resolve from the repo. Replace them with a link to the decision record or state the rationale directly.</comment>
<file context>
@@ -0,0 +1,17 @@
+# Fence ghost settlement and wake settled projection rows
+
+Lead2 ruling 934856: successful ghost settles hand their segment ids to
+`Projector.owe_followups`, behind the current discovery page. The existing
+follow-up queue deduplicates owed ids and caps them at 256; overflow resets
</file context>
| @@ -0,0 +1,16 @@ | |||
| { | |||
| "schema_version": 1, | |||
| "id": "FC-settle-path-skips-sibling-fence-and-wake", | |||
There was a problem hiding this comment.
P3: The new failure-class definition is not the class declared by the fix commit. Declare this PR as Failure-Class: new and update the fix commit trailer accordingly; otherwise registry validation treats this added definition as an unauthorized instance-fix registry mutation.
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 .github/failure-classes/FC-settle-path-skips-sibling-fence-and-wake.json, line 3:
<comment>The new failure-class definition is not the class declared by the fix commit. Declare this PR as `Failure-Class: new` and update the fix commit trailer accordingly; otherwise registry validation treats this added definition as an unauthorized instance-fix registry mutation.</comment>
<file context>
@@ -0,0 +1,16 @@
+{
+ "schema_version": 1,
+ "id": "FC-settle-path-skips-sibling-fence-and-wake",
+ "violated_contract": "A repair path that flips a durable row into an eligible state must apply the same transaction-level eligibility fence as the normal release path, and must hand the row to the follow-up scheduler. Skipping the fence settles rows the normal path refuses; skipping the hand-off leaves the row waiting for a full discovery-cursor wrap over the backlog.",
+ "canonical_prevention": "Route every settle or release writer through one shared eligibility check, fail closed with a classified skip, and pass settled ids to the bounded tail channel behind a kill switch. Test per skip class and that completion fences still refuse deleted or privacy-blocked rows.",
</file context>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
What
Two changes to the ghost-settle release path (default OFF flag BATCH_PIPELINE_PROJECTION_GHOST_SETTLE_ENABLED, currently tripped OFF in prod):
_target_restorablefence the normal release applies. In window 2 about 29% of settled rows (no target 45, deleted 2, discarded 5, processing 1 of 185) were rows the normal release would have refused, and omi-pipeline reported owner-chainhead_errorstops (SyncAssignmentConflict LIVE_TARGET_NOT_PERSISTED). The settle transaction now calls_target_restorablebefore writing; new skip classtarget_not_restorable.Projector.owe_followups(bounded 256, behind the current discovery page). No committed_at re-stamp, no new index, no new job type. Kill switchBATCH_PIPELINE_PROJECTION_GHOST_SETTLE_WAKE_ENABLED(default on; only effective when ghost settle itself runs). Wake lost on process death falls back to cursor wrap.Safety
Completion fences re-run at completion time (source_deleted, conversation_deleted, BatchPrivacyBlocked); tests cover a deleted or privacy-blocked settled id being refused at completion and publishing nothing. Settle cap (16/pass), 24h floor and count_only unchanged.
release()otherwise untouched (open #24884 changes it; merge in either order).Tests
Release and follow-up unit tests (137 pass locally), Firestore driver tests for the new skip class and wake, registry consistency.
Rollback
BATCH_PIPELINE_PROJECTION_GHOST_SETTLE_WAKE_ENABLED=falsedisables the wake; the settle flag stays OFF.Failure-Class: new
Line-Count-Exception: backend/utils/batch_pipeline/projection.py | 1720 -> 1723 | three lines to hand settled ids to owe_followups behind the kill switch; the logic lives in the release module
🤖 Generated with Claude Code