Skip to content

SCA-2049: fix(batch): a provider upload within a day of capture is fresh - #25226

Merged
Git-on-my-level merged 3 commits into
mainfrom
lane/provider-fresh-lag
Nov 13, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
lane/provider-fresh-lag

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What

A provider-route upload admitted within a day of its capture is stamped fresh. Until now the bar was 10 minutes, shared with the GPU lane.

Why

Since the provider backlog hold (#25204), a provider row not stamped fresh does not commit, and it cannot commit in plain order because the owner's held rows sit in front of it. A provider recording that synced more than 10 minutes late was therefore transcribed and never delivered. #25204 stated this limit; it should have been treated as a blocker for closing the incident.

Measured in production on 2026-11-13 (job metadata and counts only), provider-route units admitted between 16:37Z and 17:13Z, after provider merge membership was switched back on:

  • 1,195 admitted. On time (lag 600 s or less): 1,028, all stamped fresh; 275 committed (26.8%), 184 projected. Japanese: 599, 236 committed.
  • Late: 167 (14%), all stamped not fresh; 0 committed, 0 projected. Japanese: 103, 0 committed. 150 of the 167 were transcribed and waiting.
  • Late by lag: 10–60 min 36, 1–24 h 67, over 24 h 64.

Change

  • backend/config/batch_pipeline.py: provider_fresh_capture_lag_seconds(), BATCH_PIPELINE_PROVIDER_FRESH_CAPTURE_LAG_SECONDS, default 86400, clamped to 600–86400.
  • backend/utils/batch_pipeline/provider_stt_admission.py: provider admission stamps fresh_capture against that setting. FRESH_CAPTURE_LAG_SECONDS (600) is untouched and the GPU lane (Scheduler.enqueue_in_transaction, GPU priority) still uses it.
  • New counter omi_batch_pipeline_provider_admissions_total{merge_class, lag} with merge_class in fresh, catch_up and lag in lt10m, lt1h, lt24h, ge24h, so a bulk late sync is visible. Counted per transaction attempt: a retried admission can count twice.

The merge is not changed. Rows already admitted are not reclassified: the stamp is written once, at admission.

Ships on

The code default is 86400; the environment setting is the override and the stop action. Deploy: backend-sync, where provider admission runs (image move, live settings kept).

Stop action: set BATCH_PIPELINE_PROVIDER_FRESH_CAPTURE_LAG_SECONDS=600 on backend-sync (new revision, previous one deleted so its instances stop). New admissions go back to the 10-minute bar; rows stamped meanwhile keep their stamp.

Must stay clean after deploy: enrichment 200s per minute on backend-integration; share of under-1h captures unprojected at 10–20 minutes. Expected: provider admissions with lag 10 min to 24 h stamped fresh, and committing.

Other readers of the stamp

For a provider row, fresh_capture is read by:

  • the merge: _catch_up and _backlog_held (class), and the fresh-first probe with its query (store.fresh_pending). A late provider row within a day now commits fresh-first, ahead of the held backlog, and is no longer subject to the catch-up depth hold.
  • projection_hold_policy.quarantines_assignment_conflict: a row stamped not-fresh is the backfill lane, anything else fresh, when deciding whether an assignment conflict that waits on another writer holds or keeps retrying (it matters only for captures at least six hours old). So that this does not change, a provider row stamped fresh with lag over the GPU bar (600 s) also carries late_upload: true, and the policy treats it as backfill, exactly as before this change. A test pins it.
  • test code only: testing/pipeline_sim/store.py (its fresh-pending query) and testing/batch_replay (labels captures).

No other code in backend/ reads the stamp. No reader changes vendor or compute cost: the unit is transcribed by the same provider either way. What changes is its merge class (fresh-first, no depth hold); conflict handling is kept as it was by the new late_upload field. Volume: about 14% of provider admissions are late, about 9% within a day.

Known limits

  • Fresh-first is not a guarantee for every owner shape. The fresh probe runs when the owner's head is a catch-up or held-backlog row. Behind a fresh GPU head that is not ready yet, a fresh provider row waits for that head in capture order, as on-time provider rows have since 16:37Z; the head wait cannot use a held backlog row to pass it. This existed before this change and is not altered here.
  • Uploads more than a day late stay catch-up and wait for the metered release (64 of the 167 measured).
  • Late rows already admitted stay held. A separate reviewed script will stamp the ones admitted since 2026-11-13T16:37:14Z within a day of capture; older ones wait for the metered release.
  • One owner's day-late bulk sync commits as fast as its units settle; the depth hold does not apply to fresh rows. The new counter is how that is seen.
  • The two provider golden traces admit late uploads and pin the catch-up path, so their config now sets the old 600 bar; the traces are unchanged.

Tuning disclosure

  • BATCH_PIPELINE_PROVIDER_FRESH_CAPTURE_LAG_SECONDS new: 86400 (600 = the previous bar, max 86400)

No new pipeline state (no new job state value, no new collection). One new boolean field on the provider job document, late_upload, written once at admission on late-but-fresh rows and read only by the assignment-conflict policy; the replay capture tool carries it.

Product invariants affected

none

Failure class (fixes)

Failure-Class: FC-backlog-release-shares-lane-with-fresh-work

Third fix in this class: the hold that stopped the unmetered release classified new late uploads as backlog.

Tests

cd backend
.venv/bin/python -m pytest tests/unit/test_batch_provider_merge_membership.py tests/unit/test_batch_provider_stt.py \
  tests/unit/test_pipeline_characterization.py tests/unit/test_batch_pipeline_scheduler.py \
  tests/unit/test_batch_pipeline_merge_fresh_first.py tests/unit/test_flag_budget.py -q

New in tests/unit/test_batch_provider_merge_membership.py: a provider upload two hours late and one exactly a day late are fresh, one second over a day is not; the setting at 600 restores the old bar, and its bounds; a late provider upload commits ahead of a held backlog and the backlog stays held; the GPU constant is still 600; the counter moves once per admission in each lag bucket. Two existing tests that used a two-hour-late upload as their catch-up case now use one more than a day late.

Not tested here: production behaviour, and whether the counter is scraped on backend-sync.

🤖 Generated with Claude Code

Git-on-my-level and others added 2 commits November 14, 2026 00:33
Since the provider backlog hold, a provider row not stamped fresh is not
delivered, and the 10-minute bar shared with the GPU lane classed every
late-synced provider upload as backlog (2026-11-13: 167 of 1,195 admissions,
none committed). Provider admission now has its own bar, default one day.

Failure-Class: FC-backlog-release-shares-lane-with-fresh-work

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Review of the provider fresh bar: stamping a 6-24 h late upload fresh also
moved it to the fresh side of the assignment-conflict policy, where a
conflict that waits on another writer retries instead of holding. A provider
row stamped fresh past the ten-minute bar now carries late_upload, and the
policy treats it as backfill, as before.

Failure-Class: FC-backlog-release-shares-lane-with-fresh-work

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 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-13T18:17:47.867819Z 4574dca 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.

Review round 2: the replay capture allowlist dropped the new job field, so a
replayed late provider upload took the fresh conflict lane while production
takes backfill. The capture now reads the field and labels the unit backfill.

Failure-Class: FC-backlog-release-shares-lane-with-fresh-work

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@Git-on-my-level Git-on-my-level changed the title fix(batch): a provider upload within a day of capture is fresh SCA-2049: fix(batch): a provider upload within a day of capture is fresh Nov 13, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Flake record (from the provider-STT drain owner session), not hidden: #25226 at head ac458cb is being merged past one failing check by the rollout lead's ruling (David's 2026-11-03 ruling: force-merge past flakes, fix flakes separately).

  • Check: Backend unit shard 2/8 (and the aggregate Backend unit suite). Run 43481408115, attempt 1 failed, attempt 2 (re-run of failed jobs) failed.
  • Attempt 2 failure: tests/unit/test_live_replay_provider_pairs.py::test_slow_consumer_full_ring_paced_budget_and_realtime_live_order[modulate-velma-2], assert 21.664000000000016 <= ((20 + (3 * 0.512)) + 0.001); 1 failed, 30 passed in that file. Attempt 1's log could not be read back, so the same test is likely but shown for one attempt only.
  • Same test failed on fix(batch): hold the provider backlog; owner wakes commit fresh provider rows only #25204 at two heads (33.97 s against a 21.5 s bound, passed on re-run). It is a wall-clock pacing bound in live replay; SCA-2049: fix(batch): a provider upload within a day of capture is fresh #25226 touches provider admission, the assignment-conflict policy and the replay capture tool, not live replay.
  • Everything else on that head: 39 success, 25 skipped.

@Git-on-my-level
Git-on-my-level merged commit 3d72cba into main Nov 13, 2026
77 of 81 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/provider-fresh-lag branch November 13, 2026 20:13
Git-on-my-level added a commit that referenced this pull request Nov 13, 2026
#25224 and #25226 each added a name; the merged file declared 277.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 14, 2026
…e reads past one page (#25243)

## What

Follow-up to #25213 and #25226. Three small things in the batch
pipeline, backend only. No store, query or index change, and no new
setting.

1. **Fresh-first pick reads the settle instant.** When an owner's
earliest pending fresh row is not ready, a later ready fresh row may
pass it after the head wait. That wait was measured only from
`ready_at`. It now uses `_ready_since`, which the head-wait path already
uses: `ready_at`, or for a provider row while provider merge membership
is on, `provider_intent.settled_at`.
2. **A full probe page with no ready row is logged.** `event=batch_merge
outcome=fresh_probe_full_no_ready`. The probe itself is unchanged (one
page of 32).
3. **Recent-discovery fallback is recorded.** The newest-commits read
added in #25213 swallowed a failed query. It now calls `record_fallback`
(`recent_discovery` to `main_cursor`). This was the valid P1 from the
automated review on #25213.

Also carries two docs-only commits for #25213's change note that were
written after it merged (wording about replicas, restarts and what the
main cursor guarantees), cherry-picked from the then-deleted branch.

## Why

Production, 2026-11-13, job metadata and counts only: 15 of 71 owners
with fresh provider units committed none of them. Each had a fresh unit
held on a rate-limited vendor at the front, and the ready fresh rows
behind it had no `ready_at` (settled while the stamp was off, or removed
by an operator script that day). The pick could never measure their
wait, so the probe returned nothing on every drain. 7,784 ready fresh
units were affected; they were released by restoring `ready_at` with a
reviewed operator script (7,375 rows written). This change removes the
dependency on that field for provider rows.

## Risk and cost

- Only fresh rows are eligible, as before: the pick returns only fresh
rows, and the transaction re-verifies that the picked row is pending,
ready and fresh behind a catch-up or held-backlog head, and that every
earlier row the probe returned is still unready. The held provider
backlog stays held (while
`BATCH_PIPELINE_PROVIDER_BACKLOG_RELEASE_ENABLED` is off, the default).
- Newly eligible: the pick takes the longest time any ready fresh row on
the probe page has been ready, and when that reaches the head wait it
commits the earliest ready row on the page (this shape is main's). The
change is which rows can supply that time: a ready fresh provider row
without `ready_at` now supplies its settle instant. So such a row can
now pass an unready earlier fresh row, and it can also make an earlier
ready fresh row on the same page eligible, including a GPU row that has
no `ready_at` of its own. That is the intent for provider rows. The
skipped unready row appends later as a late capture, as before.
- No extra reads. No new setting, index, job field, metric or pipeline
state. One warning log line per commit attempt that finds an owner's
first 32 pending fresh rows all unready. The line is not throttled:
every commit attempt that reaches the probe and finds such a page logs
it. An attempt that commits through the strict order does not reach the
probe.

## Known limits

- **Not in this PR: nothing re-offers an owner whose drain left ready
fresh rows waiting.** An owner drains when one of its units settles,
when maintenance finds one of its rows on the global ready page, or when
it carries a hold marker. Since the provider backlog hold the ready page
holds only held backlog rows and no marker is written for a held-backlog
head, so an owner that goes quiet with ready fresh rows inside the head
wait is not drained again (2026-11-13: 23 owners, about 3,400 rows). A
merge change for this was written and reviewed in this PR and then cut
by the rollout lead's ruling after repeated code findings; it goes to
its own PR. Until then an operator script re-offers such owners.

- A fresh unit held on a vendor still waits for the vendor.
- The probe still reads one page of 32. If an owner's first 32 pending
fresh rows are all unready, ready rows behind them are not seen; the new
log line reports it. An earlier version of this PR read further pages;
review found that a probe of several pages is not one consistent read,
and the rollout lead ruled to cut it. A pick that sees past one page,
made inside the transaction, is recorded as a requirement of the metered
release work.
- The probe is a hint read outside the transaction, on main and here
alike: a row it did not return that becomes ready between probe and
transaction can be passed by the picked row, and then commits on a later
drain as a late capture. Unchanged by this PR.
- A GPU row's own settle time is not read: only a provider row supplies
a settle instant. A ready GPU row without `ready_at` still cannot start
the wait by itself, but, as stated under Risk and cost, a later provider
row's settle instant can now make it the row picked.
- The settle instant is the provider intent's `settled_at`. A recovered
provider unit normally carries `ready_at` from recovery; if that were
removed, the pick could use an earlier attempt's settle instant and so
shorten the wait behind an unready row. The row must still be
`result_ready` to be picked.
- A persistent failure of the newest-commits read logs one fallback
warning per tick per instance, unthrottled.

## Deploy

backend-integration and the GPU batch worker, both of which run the
merge. Never roll either below f3902ec: older code releases the held
provider backlog through rows that carry `ready_at`. Off switch: none of
its own; `BATCH_PIPELINE_PROVIDER_MERGE_MEMBERSHIP_ENABLED=false`
removes the settle-instant fallback with the rest of membership.

Must stay clean after deploy: no non-fresh provider commits; share of
under-1h fresh captures unprojected at 10 to 20 minutes; `fallback`
events with `from_mode=recent_discovery` near zero;
`fresh_probe_full_no_ready` lines near zero.

## Tests

- `test_batch_provider_merge_membership.py`: the production shape end to
end (held backlog head, a fresh unit that never settles, ready fresh
rows without `ready_at`): nothing inside the wait, both ready rows after
it, backlog and held unit untouched. Fails without the fix. Also: a full
probe page with no ready row commits nothing and logs the line.
- `test_batch_terminal_poll_skip.py`: the pick uses the settle instant
for provider rows only and only with membership on.
- `test_batch_pipeline_projection_discovery.py`: the failed recent read
records the fallback.
- The tests added here do not sleep or read the wall clock.

Not tested here: production behaviour.

Failure-Class: FC-backlog-release-shares-lane-with-fresh-work

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Git-on-my-level added a commit that referenced this pull request Nov 14, 2026
)

## What changed and why

SCA-1994: the six served-provider age-boundary cases each parsed the
entire deployment YAML during their measured call. Run 43481408115
attempt 2 crossed the 1.00 s CPU cap on a slow runner even though all
assertions passed. Read that immutable config once in a module-scoped
fixture, then run the existing boundary assertions against its actual
value. This removes five redundant parses and keeps fixture preparation
outside the policy calls being measured.

This is a separate, one-file test correction from quarantine PR #25221.
All sweep-age tests stay in the fast lane. Product code, assertions, CPU
thresholds, allowlists, and deployed settings are unchanged. The
explicit `now` remains deterministic; a fake clock would not remove YAML
parsing cost.

## Product invariants affected

none

## How it was verified

- Before: all 56 tests passed locally in 2.01 s, with the six affected
call phases taking 0.24–0.28 s and exceeding the 0.10 s advisory target.
- After: all 56 tests passed locally in 0.68 s with the existing 0.10 s
advisory / 1.00 s hard CPU thresholds. One config fixture setup took
0.26 s; affected call phases were below 0.005 s.
- All six affected cases also passed with a temporary stricter
`BACKEND_FAST_UNIT_FAIL_SECONDS=0.1` and
`BACKEND_FAST_UNIT_WARN_SECONDS=0.05`. No threshold configuration is
changed by this PR.
- `OMI_PR_BODY_FILE=../sweep-age-pr-body.md make preflight`: all 36
checks passed.
- `scripts/pr-preflight --metadata-only --pr-body-file
../sweep-age-pr-body.md`: all four checks passed.

## Tests

The existing six age-boundary cases and full 56-test file exercise the
change. The fixture still reads the checked-in deployment manifest and
enforces the unique-setting assertion; policy boundary assertions are
unchanged.

## UI evidence

UI-Evidence: none -- test-only correction.

## Failure class (fixes)

Failure-Class: none

This corrects redundant test preparation rather than production timing
or policy behavior.

## Release boundary

Review-ready test correction only. No production writes, deployment, or
release-queue entry while SCA-1894 remains open. This PR does not grant
a waiver for #25226.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/25236?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/25236?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25236&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
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