Skip to content

ci(firestore-budget): skip virtualenvs and site-packages when scanning - #25186

Merged
Git-on-my-level merged 2 commits into
mainfrom
lane/ci-firestore-venv-1113
Nov 13, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
lane/ci-firestore-venv-1113

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What

.github/scripts/check_firestore_collection_budget.py: _excluded() now skips .venv, .openapi-venv, venv and site-packages paths. Two tests added in test_check_firestore_collection_budget.py (exclusion pinned, product code still scanned).

Why

Since cb0a7c18d2e5 / cc464977d26d (2026-11-13) the pre-push check firestore-collection-budget fails closed on computed collection names and scans every backend/**/*.py, including the worktree's own backend/.venv and backend/.openapi-venv. Those hold Firestore's client library (google/cloud/firestore_v1/*, fake_firestore, langchain_community), which the check reports as "computed collection name" sites, so any backend push from a worktree with the required venv is rejected (the env doctor also refuses symlinked venvs, so there is no clean workaround). Found while pushing two backend PRs; filed as SCA-1882.

Verification

python3 .github/scripts/test_check_firestore_collection_budget.py: 45 tests OK (2 new). The push gate for this PR itself ran with the fixed script from a worktree that owns a real backend/.venv.

Failure-Class: none

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

The guard scanned backend/.venv and backend/.openapi-venv, so Firestore's own
client library was reported as computed collection names and every backend push
from a worktree with the required venv was rejected.

Co-Authored-By: Claude Sonnet 5.5 <[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-13T10:33:25.628719Z 5431929 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.

Review: excluding any venv or site-packages component could hide product code.
Skip exactly backend/.venv and backend/.openapi-venv; tests pin look-alike product
directories as still scanned.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 0cccb69 into main Nov 13, 2026
47 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/ci-firestore-venv-1113 branch November 13, 2026 10:40
Git-on-my-level added a commit that referenced this pull request Nov 13, 2026
main fixed the collection-budget virtualenv scan itself (#25186); take
its version of the check and its test.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 13, 2026
## What

Provider-route batch units (languages Parakeet cannot serve; Japanese is
about 85% of them) are transcribed and then never merged, so no
conversation is projected from them. This makes them full members of the
ordered merge the GPU route already uses.

Measured in production on 2026-11-13 (job metadata only):

- 1,677,658 units were `result_ready` with `merge_pending` set; 98% of a
3,000-row sample were provider-route.
- Of provider units settled 6 hours, 1 day, 3 days and 6 days earlier,
97–100% were still unmerged.
- Japanese units admitted since 5 Nov: about 4% committed.

## Why they did not merge

1. Nothing woke the owner's merge when a provider unit settled. The GPU
pump drains the owner after each publication; `ProviderSttStage._finish`
settled and returned. The only discovery left was the maintenance page
of the 100 oldest `result_ready` rows, and two owners filled it.
2. Provider settle wrote no `ready_at`. The head-wait probe orders by
`ready_at`, so a ready provider row could never commit past an unready
head.
3. Provider admission wrote no `fresh_capture`, so fresh-first could not
apply.

## Change

Behind one kill switch,
`BATCH_PIPELINE_PROVIDER_MERGE_MEMBERSHIP_ENABLED` (on unless `false`):

- Provider admission stamps `fresh_capture` with the rule GPU admission
uses.
- Provider settle stamps `ready_at` on a result.
- The merge counts a provider row with no `fresh_capture` (admitted
before the stamp) as catch-up, so an owner's fresh rows commit ahead of
that backlog and the backlog follows under the existing depth hold.
- The serving route wakes one coalesced owner drain after a delivery
that settles a unit or ends it terminally
(`utils/batch_pipeline/provider_drain.py`,
`Serving.drain_settled_async`). Per owner per process: one drain after 2
s, one after the head wait; a settle during that round buys exactly one
more round. At most 4 drains run at once per process. Past 4,096 live
wake tasks an owner waits its turn; no request is dropped. Wake tasks
are tracked background tasks.
- A provider row settled before the `ready_at` stamp waits from its
intent's `settled_at`: when the `ready_at` probe finds no waiter, the
merge reads the owner's earliest ready row once (one extra query per
blocked drain), so those rows can also pass an unready head after the
head wait.

Unchanged: the commit body, late marking, log chain, privacy fence and
projection order. No row skips the head wait or the catch-up depth hold.
The wake is an in-memory hint; if the process stops first, the owner is
drained by its next settle or the maintenance page, as today.

Details:
`backend/docs/listen_pusher_pipeline/changes/2026-11-13-provider-merge-membership.md`.

## Rollout

Ships on. Rollback: set the switch to `false` on `backend-integration`
(and wherever the merge runs). Rows stamped while it was on keep their
fields and stay eligible for the existing head wait and fresh-first;
nothing needs undoing.

Watch after deploy:

- Share of provider units settled one hour earlier that are `committed`
(about 0% now; should pass 90% for fresh units).
- Projection pending and fresh GPU-route time to episode: must stay
flat.
- `firestore_transaction_contention operation=batch_pipeline_store ...
outcome=exhausted`.
- `event=batch_provider_drain outcome=queued|retry`.

Known effect: owners who are active now will also start draining their
already-transcribed backlog, paced by the catch-up depth hold (16 rows
awaiting projection per owner). Owners with a backlog and no new settles
are not woken by this change.

## Tuning disclosure

No existing value changes. New knobs in
`utils/batch_pipeline/provider_drain.py`:

- DRAIN_DELAY_SECONDS new: 2 (seconds before the first drain of a round)
- HEAD_WAIT_MARGIN_SECONDS new: 2 (seconds added to the head wait before
the second drain)
- DRAIN_CONCURRENCY new: 4 (drains at once per process)
- MAX_OWNERS new: 4096 (live wake tasks per process; further owners
queue)

No new pipeline state.

## Background-task ratchet

The owner wake is a tracked background task that outlives its request,
so it adds one entry to
`tests/unit/fixtures/background_task_baseline.json`. Why losing it at
SIGKILL is safe: it holds no obligation. The settled row is already
durable as `result_ready`; the wake only asks the merge to commit it,
and a lost wake delays that owner until its next settle or the
maintenance page, which was the only path before this change. Awaiting
it in the request would hold a `provider-stt` queue slot through the 60
s head wait. A request-backed owner-wake task is the durable replacement
once a queue for it exists.

## Review

Independent exact-head review (Luna), two rounds:

- Round 1 on `e3f20ba`: FIX, three should-fix, no blockers. All
addressed (unstamped rows and the head wait, the owner bound no longer
drops, tracked background tasks).
- Round 2 on `5b09fad`: no remaining merge, projection-chain,
duplicate-commit or drain issue. Its one finding was in a CI-check
commit this branch no longer carries (main fixed that check in #25186
and this branch takes main's version).
- The reviewer re-ran the production counts read-only at 2026-11-13
10:31-10:34Z: 1,727,953 `result_ready` with `merge_pending`; of units
settled 1 h to 6 days earlier, 97-100% still `result_ready`.

## Product invariants affected

none

## Failure class (fixes)

Failure-Class: FC-bounded-discovery-pinned-by-blocked-page

The 100-row oldest-first `result_ready` page was filled by two owners'
blocked rows, and provider units had no other route to the merge. This
change gives them the per-owner wake the GPU route has; it does not
change the page itself.

## 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_batch_pipeline_merge_fresh_first.py tests/unit/test_batch_pipeline_merge_head_wait.py \
  tests/unit/test_batch_pipeline_recovered_release.py tests/unit/test_pipeline_characterization.py -q
```

New: `tests/unit/test_batch_provider_merge_membership.py` (29 tests)
covers both stamps and the switch-off shape, the head wait and
fresh-first on provider rows through the real admission, settle and
merge transactions, the unstamped-backlog classification, the coalescer
(burst, re-request during a round, owner bound, failure, concurrency),
the delivery hook, and `drain_settled_async`.

Two golden traces (`provider_stt_ja`, `provider_stt_unsupported`) gain
the `fresh_capture` field on provider jobs and nothing else.

Not tested here: live behaviour against Firestore, and the effect on
maintenance load of more owners holding `merge_holds` markers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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