Repository navigation
feat(observability): add bounded audio silence census - #25026
Git-on-my-level wants to merge 9 commits into
Conversation
Failure-Class: none
Codex Review Summary: ❌ FailedThis 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: 42fc1fe2e4
ℹ️ 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".
| self.record_pending.refresh(now, lambda: record_pending(store.client, store.namespace, now)) | ||
| self.nojob.refresh(now, lambda: nojob(store.client, store.namespace)) | ||
| if kill_switch('AUDIO_SILENCE_CENSUS_ENABLED', log=False): | ||
| self.audio_silence.refresh(now, lambda: audio_silence_sample(store.client, store.namespace, now)) |
There was a problem hiding this comment.
Keep the census off the queue-metrics sampling critical path
When all three source pages saturate, this synchronous call can hold up the worker's queue-metrics sampler for longer than its freshness window. Exercising sample() with 300 distinct users per source produces 2,400 sequential aggregation RPCs; even 30 ms per RPC exceeds 60 seconds, and there is no overall deadline. backend/diarizer/batch_pipeline_runtime.py::supervise awaits this refresh before scheduling another sample, while backend/charts/batch-pipeline-worker/prometheus-adapter-rules.yaml rejects queue and sampler observations older than 60 seconds. Consequently, a saturated census can make autoscaling signals unavailable, particularly when replicas start together; the HTTP metrics caller also waits for the entire census. Run it independently of the queue sampler, or impose a short overall deadline that returns a partial observation.
AGENTS.md reference: backend/AGENTS.md:L275-L275
Useful? React with 👍 / 👎.
| client.collection('sync_reprocess_outbox') | ||
| .where(filter=FieldFilter('first_pending_at', '>=', after)) | ||
| .where(filter=FieldFilter('first_pending_at', '<=', current)) |
There was a problem hiding this comment.
Exclude settled outbox receipts before sampling the page
When a first summary completes, FirestoreEnrichmentOutbox.ack() in backend/database/outbox_firestore.py retains a dormant receipt with uid=None and its original first_pending_at. This query includes those normal receipts, and remember(None) marks the entire census partial. A single recently settled receipt therefore prevents a complete observation even when every source fits within its page; 300 receipts can also consume the entire outbox page and hide actual user evidence. This is reproducible with one dormant receipt and no other rows: the sampler returns partial=True. Exclude settled receipts in the indexed source query rather than treating their intentionally cleared identifiers as incomplete evidence.
Useful? React with 👍 / 👎.
Firestore auto-serves same-direction field+__name__ single-field composites, so the outbox and batch-job window declarations were redundant and failed test_firestore_index_config. Collection-group single-field scans are not auto-served, so the conversation window now pages newest-first and declares the real opposite-direction composite. Failure-Class: FC-redundant-single-field-composite-index
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7df513509
ℹ️ 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".
| its baseline; its runbook query is `max by (state, source) | ||
| (omi_audio_silence_census) and on() (omi_audio_silence_census_partial == 0)`. |
There was a problem hiding this comment.
Filter partial observations before aggregating replicas
When one observer has a complete sample and another has a partial sample, this query still includes the partial observer's counts: max by (state, source) removes replica identity before and on() checks whether any observer reports partial == 0. Consequently, the documented complete-only query can return values from an incomplete observation. Match each census series to its own observer's partial marker before applying max by (state, source) so a complete replica cannot validate another replica's partial counts.
Useful? React with 👍 / 👎.
Co-authored-by: multica-agent <[email protected]>
Co-authored-by: multica-agent <[email protected]>
…-luna/1e721eb6e5b5 # Conflicts: # .github/firestore-collection-budgets.json # backend/config/flag_budget.json # backend/config/policy/kill_switches.py # backend/tests/unit/test_flag_budget.py # backend/utils/batch_pipeline/metrics.py # config/deployment-setting-classification.json # config/feature-flags.yaml
…-luna/1e721eb6e5b5
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Hey @Git-on-my-level 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
What / why
Add
omi_audio_silence_census{state,source}, a read-only 24-hour census of unique users with:stateis closed toapp_active_no_audio,app_active_with_audio,audio_no_app_activity;sourceis closed toomi,desktop,other, for at most nine series. UIDs are held transiently for deduplication. The sampler fetches the completerecord_upload_sessionsmap to test presence, so its keys and lease metadata also enter worker memory transiently; neither UIDs nor session metadata are labels or log text. A user's source is the latest observed source-bearing row. Batch jobs count as app and audio evidence; upload/received conversation stamps and recentsync_reprocess_outboxrows count as audio evidence.The sampler rides the existing lifecycle observation in
QueueMetrics._refreshon the batch/pusher metrics path, once per six hours per observer. No Cloud Run service, scheduler, account mutation, GCS listing, or unindexed collection-group scan is added.Each run reads at most 300 indexed rows from each source. Full pages are partial. A shared five-second deadline bounds the sample; each Firestore RPC receives a timeout capped by the remaining time (at most ten seconds) and can leave a partial lower-bound sample. Candidate
COUNT(1)existence aggregations fill only missing app/audio evidence. The hard 4,000-read budget includes returned documents, one unit per capped source-page query (its single index-entry batch or minimum empty-query charge), and each existence aggregation limited to one match. The sampler reserves these units before issuing queries and stops withpartial=1when the budget is exhausted. Unseen upload-session maps make no-audio classification impossible, so those users are omitted rather than reported as false silence. Under saturation, source attribution is also only for the latest source-bearing row actually read; users with no source-bearing row fold toother.omi_audio_silence_census_partial=1marks all counts as lower bounds on source saturation, unclassifiable evidence, or budget exhaustion; read exceptions preserve prior values and freshness.Product invariants
None. Observation only: no API, product behavior, audio custody, admission, repair, or user lifecycle mutation.
Tuning
new: 3metric families, at mostnew: 9census series plus partial/freshness).new: 21600seconds per observer.new: 300rows per source, three sources, indexed and key-name ordered.new: COUNT(1)only when a source page could hide relevant stamps.new: 4000accounted reads per observer run, including returned documents, each capped source-page query charge, and one-matchCOUNT(1)checks; the sampler reserves charges before reads and stops withpartial=1. Zero-before-first-sample and exception paths retain no fabricated healthy value.dormant == false, followed byuidandfirst_pending_at, matching the per-UID fallback query. The single-field outbox and batch-job windows are auto-served and are deliberately not declared. The composite indexes must be READY before deploying the emitter. No production access or index apply was performed.metric-inventory.prod.json; the runbook query inlifecycle-alarms.mdnow excludes observations older than 12 hours before taking the replicamax(two six-hour sampling cycles). Replica values aggregate withmax, neversum, so pods do not multiply the census.New states / exits
These are rolling observations, not persisted lifecycle phases:
app_active_no_audio: exits when batch-job, received-audio, upload-session, or outbox evidence appears, when app activity ages out, or when evidence becomes incomplete and the user is unclassified.app_active_with_audio: exits when activity/audio evidence ages out; becomesaudio_no_app_activityif only app activity ages out.audio_no_app_activity: exits when conversation/batch activity appears or audio evidence ages out.Disable/rollback exit:
AUDIO_SILENCE_CENSUS_ENABLED=falsestops subsequent reads and leaves previous observations to age out.Verification
acaff7390a671dbb213a2c1bbcc6109b99f516b9: bounded pre-push gate passed, including all 51 manifest checks, Firestore index guard, typecheck (0 errors), 1,992 backend unit tests, 7 real PromQL scenarios, and pinned formatting.Tests
Coverage includes user deduplication, three-state/nine-series classification, latest-observed-source attribution, bounded candidate joins, unseen upload-session refusal, hard budget exhaustion, six-hour cadence, and false-kill-switch behavior. Firestore driver setup exercises prod/dev query shapes and candidate aggregation branches. The final regressions also cover dormant outbox rows, retained verified classifications at deadline/budget boundaries, and freshness filtering in the runbook query.
UI-Evidence
none -- backend change only.
Failure-Class
Failure-Class: none
Rollback
Set
AUDIO_SILENCE_CENSUS_ENABLED=false. This stops future census reads without affecting capture, audio custody, admission, repair, or user data. Existing gauges age out; remove the emitter if immediate disappearance is required. Merge rollback does not provision indexes; any prebuilt additive indexes require the normal separate human cleanup decision.