Repository navigation
perf(batch): defer speculative native projection audio reads - #25791
Merged
Merged
Conversation
Git-on-my-level
marked this pull request as ready for review
November 19, 2026 16:26
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: 5856f1ad76
ℹ️ 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".
Git-on-my-level
added a commit
that referenced
this pull request
Nov 19, 2026
## Summary Generate port task drafts when a merged Python PR changes finalization or batch behavior. The map covers all 34 finalization and 41 batch runtime Python sources cited by the [landed contracts](#25802), plus imported family policy and implementation. The [scope document](https://github.com/BasedHardware/omi/blob/9554967bf78fab4d18b1504a7ef19b31e46141af/backend-go/docs/port-map-scope.md) records the boundaries and exclusions. The PR branch includes `main` at contracts merge `97b4059861a7`. The batch map includes the projection kill-switch defaults introduced upstream in #25791. The Backend Go Checks workflow runs the Python suite when these files change in a PR. On each main push, it walks the pushed first-parent merge commits, looks up their merged main PRs, and checks the complete paginated file list against GitHub's `changed_files` count before drafting. The CLI also rejects duplicate filenames in a counted input and uses both sides of renames. The job prints JSON and uses read-only permissions. Tracker writes are outside this change. [Commit-to-PR API](https://docs.github.com/en/rest/commits/commits#list-pull-requests-associated-with-a-commit) · [PR files API](https://docs.github.com/en/rest/pulls/pulls#list-pull-requests-files) ## Verification - Nine focused tests exercise family matching, renames, duplicate or truncated file lists, malformed inputs, task text, existence of every mapped file, and coverage of the checked-in batch contract. Run `python3 -m unittest discover -s .github/scripts -p test_go_port_tasks.py -v`. - `actionlint .github/workflows/backend-go-checks.yml` passed. Ran the workflow's push steps locally over three real first-parent merges and verified Go test selection on Go and Python-only ranges. - `cd backend-go && TEST_FIRESTORE_REQUIRED=1 make check` passed with Postgres 16 and the Firestore emulator. - Compared both map families to every runtime Python citation in the landed contracts. Replaying merged PR #25791 also matched the new batch projection kill switch. - Repository preflight and `gh pr checks 25810 --watch` passed at head `9554967bf7`. Local preflight skipped the 90-day failure-class ratchet because the checkout is shallow. [Backend Go Checks](https://github.com/BasedHardware/omi/actions/runs/44627579785) ## Product invariants affected none ## Examples from merged PRs ```bash count=$(gh api "repos/BasedHardware/omi/pulls/$PR" --jq .changed_files) gh api --paginate --slurp "repos/BasedHardware/omi/pulls/$PR/files?per_page=100" | jq 'add' | python3 .github/scripts/go_port_tasks.py --pr "$PR" --changed-files "$count" ``` ### PR #25771 ```json [ { "family": "finalization", "title": "Port Python PR #25771 to Go finalization", "body": "Python PR [#25771](#25771) changed `backend/database/conversations.py`, `backend/models/conversation.py`, `backend/utils/conversations/process_conversation.py`, `backend/utils/conversations/render.py`, `backend/utils/conversations/v3/policy.py`. Review the merged diff and port any behavior changes to the Go finalization family under `backend-go/`. Add or update parity coverage for the changed behavior, or record why the Go port needs no change.", "matched_paths": [ "backend/database/conversations.py", "backend/models/conversation.py", "backend/utils/conversations/process_conversation.py", "backend/utils/conversations/render.py", "backend/utils/conversations/v3/policy.py" ] } ] ``` ### PR #25755 ```json [ { "family": "finalization", "title": "Port Python PR #25755 to Go finalization", "body": "Python PR [#25755](#25755) changed `backend/config/merge_before_processing.py`, `backend/models/conversation.py`, `backend/models/structured.py`, `backend/utils/conversations/deterministic_minimum.py`, `backend/utils/conversations/empty_structure_minimum.py`, `backend/utils/conversations/fragment_visibility.py`, `backend/utils/conversations/historical_minimum.py`, `backend/utils/conversations/home_titles.py`, `backend/utils/conversations/merge_conversations.py`, `backend/utils/conversations/process_conversation.py`, `backend/utils/conversations/processing_trigger.py`, `backend/utils/conversations/relevance_salience.py`, `backend/utils/conversations/summary_delivery.py`, `backend/utils/conversations/sync_hold_completion.py`, `backend/utils/episodes/member_notes.py`, `backend/utils/llm/notes_short_clip_policy.py`. Review the merged diff and port any behavior changes to the Go finalization family under `backend-go/`. Add or update parity coverage for the changed behavior, or record why the Go port needs no change.", "matched_paths": [ "backend/config/merge_before_processing.py", "backend/models/conversation.py", "backend/models/structured.py", "backend/utils/conversations/deterministic_minimum.py", "backend/utils/conversations/empty_structure_minimum.py", "backend/utils/conversations/fragment_visibility.py", "backend/utils/conversations/historical_minimum.py", "backend/utils/conversations/home_titles.py", "backend/utils/conversations/merge_conversations.py", "backend/utils/conversations/process_conversation.py", "backend/utils/conversations/processing_trigger.py", "backend/utils/conversations/relevance_salience.py", "backend/utils/conversations/summary_delivery.py", "backend/utils/conversations/sync_hold_completion.py", "backend/utils/episodes/member_notes.py", "backend/utils/llm/notes_short_clip_policy.py" ] } ] ``` ### PR #25686 ```json [ { "family": "finalization", "title": "Port Python PR #25686 to Go finalization", "body": "Python PR [#25686](#25686) changed `backend/utils/conversations/lifecycle.py`, `backend/utils/conversations/process_conversation.py`, `backend/utils/conversations/v3/policy.py`, `backend/utils/conversations/v3/service.py`, `backend/utils/conversations/v3/triggers.py`. Review the merged diff and port any behavior changes to the Go finalization family under `backend-go/`. Add or update parity coverage for the changed behavior, or record why the Go port needs no change.", "matched_paths": [ "backend/utils/conversations/lifecycle.py", "backend/utils/conversations/process_conversation.py", "backend/utils/conversations/v3/policy.py", "backend/utils/conversations/v3/service.py", "backend/utils/conversations/v3/triggers.py" ] } ] ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Design
DESIGN: Defer speculative native-record audio materialization until projection assignment needs the authenticated intake context. Owner-chain read-ahead continues to fetch immutable job bindings and result artifacts. The existing assignment path requests the staging artifact and source verification on the storage executor. The owner walk waits only for its remaining step budget and can resume a pending read on the next step without another fetch. One unconsumed prefetch avoids one staging audio-artifact read and the corresponding source metadata and payload GETs. An assigned unit still performs the required verification. No storage or database writes are added.
BATCH_PIPELINE_DEFER_NATIVE_PROJECTION_AUDIO_PREFETCH_ENABLEDis on by default. Set it tofalseto restore read-ahead.DESIGN: OK from David on Nov 19, with the fixed-outcome counter, custody and rollback tests, and exact-head CI and full review gates.
Batch custody
The native-record branch only defers work. It keeps authenticated staging, source generation and digest checks, frame and range validation, owner and conversation binding, authorization, and the live privacy and deletion transaction checks for every assignment. It makes no receipt, retention, or deletion decisions from the prefetched result. Native and non-native legacy inputs continue through the same on-demand loaders whenever assignment needs audio. The design adds no shared audio cache and changes no mixed-version data contracts.
Production readback
Compare complete UTC hours before and after serving. Match projection completions and check owner-chain advancement and backlog age. In
backend-integration, compareincrease(omi_private_sync_object_get_total{reader="batch_source",kind="payload"}[1h])againststorage_googleapis_com:api_request_countandstorage_googleapis_com:network_sent_bytes_counton private-syncReadObject. Adjust for overlapping rollout changes. Tracksum by (outcome)(increase(omi_batch_projection_native_audio_prefetch_total{service_name="backend-integration"}[1h]))in both modes. Its only label isoutcome, withstarted,consumed, andabandoned. Use abandoned candidates alongside the direct GET and byte counters to size savings. A candidate may settle in a later scrape window. Historical abandoned candidates and source reads per candidate are unmeasured. The before/after test is fewer payload GETs and bytes per comparable completed audio-hour with stable owner-chain progress.Nov 2 to Nov 16, bucket-wide bytes per completed audio-hour rose from 1.016 to 2.338 GB, while completed hours rose 7.20×. Cloud Run integration Google-network receive traffic per completed hour rose from 2.058 to 2.128 GB across the same days. Those numerators include other activity. They cannot measure waste from a single path. Aggregate production reads were through
ro-prod.INV-MEM-4. Authorization and actual source verification still run before any assignment that consumes the recording. The focused tests exercise real assignment through the encrypted staging and generation-pinned source reader with fake object storage. They cover successful assignment, staging tamper, source digest mismatch, privacy revocation during source IO, eager rollback, and accounting for blocked and closed work. 210 focused tests passed through
omi-heavyon the updated implementation, including a delayed read that yields at the step boundary and resumes the same task. Five loopback Firestore emulator tests passed against replay, privacy holds and deletion during multipart projection. The branch also includes current main’s projection obligation changes in #25724.Panel
review-20261119t144713-f96bfound that an inline deferred read could exceed the owner-drain budget. The storage-executor future now follows the same turn across bounded step waits. The background-task inventory records why interrupting that read-only work is safe. 6 inventory tests and the 8 focused native prefetch cases passed.Panel
review-20261119t151207-4579identified a missing exact metric in the shared Cloud Run collector keep rule. The collector now retains that name. A matched served collector revision is required for readback on backend-integration. The scraper rule and eager-failure fallback tests passed in the 126-test targeted run.Final panel
review-20261119t154350-2f61returned SHIP on head5856f1ad769d6b71cccb4d15cc39b8a3ca1cc558with both reviewers. Transient failures of the assignment-owned deferred read retain the durable obligation for a later bounded retry. Eager rollback keeps its original same-step fallback after a failed speculative load.Line-Count-Exception: backend/utils/batch_pipeline/projection.py | 1914 -> 1933 | Bound deferred read waits and account for the lifecycle at the assignment and owner-walk decision boundaries.
Failure-Class: FC-metric-dropped-by-scrape-allowlist
Gauntlet contention follow-up
On
760390a1, the local two-worker scenario timed out with the native prefetch switch on and completed in 26.5 seconds with it off. Both arms verified non-native bindings and recorded zero native prefetches. The failing transaction wasmark_enrichmenton a non-native unit. Firestore aborted its commit and the SDK exhausted five attempts. The assignment context read is already outside that transaction.The test-only change sets
SYNC_ASSIGNMENT_CONTENTION_RETRY_ENABLED=truein the gauntlet's serving fixture, matching the serving backend-integration configuration verified throughro-prod. The existing bounded wrapper retries explicit contention with fresh transactions and jitter. With this setting and native deferral on, the local batch gauntlet passed all ten scenarios, including the two-worker case in 36.8 seconds. The fixture keeps its original timeout, custody assertions, and worker concurrency.