Skip to content

fix: skip deferred projection follow-ups during discovery - #25402

Merged
Git-on-my-level merged 4 commits into
mainfrom
lane/firestore-followup-due
Nov 15, 2026
Merged

Git-on-my-level merged 4 commits into
mainfrom
lane/firestore-followup-due

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Repeated incomplete projection follow-ups are skipped only after discovery has already read their rows. Add an independent durable next-attempt clock so the query excludes unchanged work across replicas and restarts. Existing receipt, privacy, ledger and completion transactions remain authoritative; targeted and owed recovery bypass discovery.

Only a validated incomplete attempt may defer its unchanged result preimage, within the existing attempt timeout. A fixed pass cutoff and independent keyset cursor prevent a growing tail from starving earlier work. Concurrent state or receipt changes win the transaction fence.

Rollout requires ready dev/prod indexes, unconditional clock writers deployed everywhere with old writers drained, and a separately admitted bounded resumable backfill. Legacy discovery remains until its versioned marker completes; the reader then activates without a new default-off flag. No production migration or activation has been performed. Release retains admission and deployment ownership.

Tuning: discovery page limit before: 100 rows; after: 100 rows. The discovery seed-probe limit before: 1 row; after: 1 row. Follow-up slots are unchanged. BATCH_PIPELINE_PROJECTION_FOLLOWUP_BACKOFF_SECONDS before: default 900 seconds, maximum 3600 seconds, kill 0; after: the same default 900, maximum 3600 and kill 0 for legacy process-local backoff. New durable deferral has an initial maximum of 60 seconds, bounded by min(60, configured ceiling), without escalation. The collection-budget declaration includes the one-time migration and throttled marker reads as planning bounds, not measured spend.

Verification: 662 selected unit tests passed through the normal push gate, including all 108 audio-outbox tests and the routing/repair cases exposed by CI. Forty-two real Firestore emulator tests passed with one skipped; canonical seven-file Firestore query/index guards881 tests passed; all41 local preflight checks and pinned enforced backend typecheck passed with zero errors. Independent Luna production-source reviews returned SHIP; the parent checked the formal protocol declaration and subsequent test-only corrections. Current full remote CI remains pending.

Native Postgres and simulation adapters implement the independent marker/query-clock contract without activating a backend migration. Routing fixture capture times stay current, and the open-stream audio test keeps its socket open through the original closure proof while shortening only test cleanup fallbacks inside the unchanged cleanup deadline.

Rollback: BATCH_PIPELINE_PROJECTION_FOLLOWUP_BACKOFF_SECONDS=0 restores legacy discovery. Before reverting to pre-clock writers, roll legacy readers first and prove due readers drained; do not silently reuse an old completion marker after such a downgrade. The runbook covers writer/index/backfill admission and net read/write/progress/latency/failure measurement for a complete post-overlap hour. No savings forecast is booked from the attributed follow-up pool.

Product invariants affected

none

Failure-Class: FC-query-filter-after-expensive-enrichment

UI-Evidence: none -- backend scheduling and operator tooling only.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 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-15T14:05:04.978807Z fa48060 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.

Keep the fake socket open through the existing pre-release seal assertions. Scope the production inline-finish and background-drain timeouts to 0.5 seconds during this test so their fallback fits its unchanged five-second cleanup deadline. Await the cancelled handler on failure. No production code, closure assertion, or CI budget change.

Failure-Class: none
@Git-on-my-level
Git-on-my-level merged commit b580a93 into main Nov 15, 2026
72 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/firestore-followup-due branch November 15, 2026 14:43
Git-on-my-level added a commit that referenced this pull request Nov 15, 2026
Published successor `98a87f93c8dd3801eb1489bdd5e2675252354d65`.
SCA-2280: compose async finish skipping with main's independently
stamped follow-up clock (#25402). Normal merge of main
`9104ef645e3cc51224e96d551a777b365b0c5e01` into the existing author
branch over `f5ca1bdccc99d2cf68f8ab368d679bc13d585dc6`.

The scoped Release ruling (SCA-2280
comment01a1e005-94de-78cc-8cb2-879e8998c21d) authorizes this exact
composition. Async state moves retain `projection_finish_due_at=-1` and
stamp `projection_followup_due_at` in the same write. Both
`exclude_async` and `followup_due_before` cross the
Firestore/Postgres/simulator interfaces and query drivers. Async
exclusion applies only to finish ordering; independent follow-up
discovery retains negative-finish receipts. The two clock orderings
remain mutually exclusive, main's mode-change cursor reset/cutoff
remains intact, and finish stripes still use finite seeds with the
infinite backoff-off ceiling. The follow-up-clock writer/backfill/marker
rollout retains its separate admission; this PR does not activate it.

Nine integration conflicts resolved by composing the contracts, not
choosing a whole side: shared state fields; Firestore, Postgres and
simulator paging; query-driver domains/pins; parity tests; discovery
modes/seed horizon. The two additional test-model facades retain both
options. Canonical main's current-clock upload fixture repairs are
included; f5's real terminal 20 assertion failures in the three
expired-capture fixtures remain recorded, not retried or waived. Main's
unrelated fixes are retained. All five reviewed
finish/classifier/control ASTs remain unchanged. No
privacy/custody/ledger, marker/writer-roster,
budget/timeout/assertion/skip change or third full review.

Local qualification: 1,213 tests across 17 isolated native files, 8
loopback Firestore tests (119.54s), normal commit/push hooks and 5
metadata checks passed; exact successor receipt is on SCA-2280. Fresh
terminal CI is required for this successor; historical heads' green
checks do not qualify it. The same serialized author-to-Release handoff
is retained, without a new operator, build hold, deploy or activation.

Async-policy persisted/ready receipts consume finish-page reads and
normally two additional job/result gets before the sweep skips
processing. Pinned policy ordinarily avoids another policy lookup; async
rows already skip session/privacy preparation. This cut removes that
page-plus-two-gets work, less migration/probe overhead; it does not
remove the whole privacy caller pool. Reuse the existing
`projection_finish_due_at=-1` clock sentinel: new async receipts stamp
it in their existing write; legacy receipts get a transactional
policy/state-fenced clock-only update. No new result field or Firestore
index. Privacy/custody, receipt state, sync finish processing and
independent follow-up completion retain their contracts. This corrected
source model is not measured production savings (cost-owner
comment01a1ddc7-d5c8-7659-8ba2-259adb9b0d91).

After the existing finish stamping marker completes, finish discovery
excludes negative clocks and uses a separate limit-one async probe to
keep the follow-up drain scheduled. With separate finish backoff
disabled and async skip enabled, clock ordering intentionally uses an
infinite ceiling after marker completion. Before completion, legacy
discovery remains active. Older readers still see negative clocks as
due, so mixed fleet/rollback retain former behavior.

Cost lead DESIGN: OK (November14 18:33Z), amended19:24Z:

Tuning: new: BATCH_PROJECTION_FINISH_CLASSIFY_PAGE_LIMIT initial 8
attempts/page, range0–16, pause0; shared cooldown20 seconds after the
last attempt. New async-only discovery probe limit: initial1 document.
Existing finish/assignment page sizes are unchanged. Previously legacy
classification had no separate bounded cap; the new cap bounds that
work. These are the only new numeric controls.

- `BATCH_PROJECTION_FINISH_CLASSIFY_PAGE_LIMIT=8`, accepted0–16;
malformed/out-of-range keeps8. Zero pauses classification. Shared
process budget refills20s after the last attempt, including failures;
overlapping pages share the cap without sleeping.
- `BATCH_PROJECTION_FINISH_ASYNC_SKIP_ENABLED=false` restores former
finish discovery, without reverse backfill. Main's separate
`BATCH_PROJECTION_FINISH_BACKOFF_ENABLED` remains default-off, false on
production integration/sync and forbidden on backend/backfill.
- Failed/contended classification is caught at the call, leaves the row
eligible and increments its dedicated counter without generic sweep
errors/deferral. No-op policy/state races increment neither counter.
- Label-free `omi_batch_projection_finish_classified_total` and
`omi_batch_projection_finish_classification_failures_total` are retained
in GMP and both scrape tests. Keep upstream ledger/allowance metric
unions.

At actual classifying process count P, cap8 gives ideal ceilings1440P
classifications/hour and8P synchronized incremental writes. Ordinary
writes and retries are additional; combined peak headroom is unverified.
Historical42-process/518k-stock sizing gives336 burst/16.8 per second
average/minimum8.6h; these are not current scope or stock measurements.
No cap increase in this PR or before one complete stable serving hour
and cost-owner authorization.

Binding07:38SCA2379 ruling (comment01a1de24-6151-7be1-accc-63e1abc2b3f4)
says mechanical shared repair ships WITHOUT ANOTHER REVIEW. No third
reviewer, selfSHIP or old-head approval carry. Existing Release
SCA2283/captain owns canonical admission, current-head recheck,
source-containing carrier/slot and runtime guards. Existing serialized
handoff is updated rather than duplicated. No hold/rebuild of ABC or
unilateral merge/deploy/cap increase. Original intervention
CLOSED10:18:30; source qualification does not renew its meter/timers or
establish serving/savings.

Measurement: cost owner's corrected native [03:00,04:00)UTC2026-11-15
baseline is502606 finish rows (SCA-2280
comment01a1dd90-c082-704e-ae07-8d13a34a00b3 and owning baseline.md/raw
snapshots). Obtain actual pre-rollout cohort and per-service/origin
scope. Historical800k/6M and92s/455s are not current gates; obtain
Quality/Release's reviewed matched-cohort latency/recovery receipt with
its actual metric definition. Positive-clock persisted/ready COUNT is an
unclassified-async upper bound including sync; negative-clock COUNT is
current marked backlog, not cumulative classifications. No
full-document/policy-join scan. Require complete scrape/reset coverage,
zero failures, progress/read reduction, healthy drain/age/latency/5xx
and combined write/burst evidence before cost-owner-authorized
acceleration. See
`backend/docs/runbooks/projection-finish-async-skip.md` and SCA-2280
readback attachment.

## Product invariants affected

none

Failure-Class: FC-query-filter-after-expensive-enrichment
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