Skip to content

SCA-4753: fleet offline-sync backlog snapshot (Phase 1) - #26683

Closed
Git-on-my-level wants to merge 3 commits into
mainfrom
lane/sca4753-fleet-p1
Closed

Git-on-my-level wants to merge 3 commits into
mainfrom
lane/sca4753-fleet-p1

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What changed and why

SCA-4753 Phase 1: fleet-wide offline-sync backlog metrics. Today the backlog (audio waiting on the Omi, on the phone, and uploaded but not yet settled) is visible only in one person's Sync details sheet. This sends one numbers-only snapshot per app installation per UTC hour to the existing POST /v1/telemetry/fleet route and puts p50/p95/p99, over-1 h / over-6 h shares, coverage, per-build regression and the SCA-4532 drain holdout comparison on the Omi Core Features "Offline sync backlog" row. Pipeline owner gave DESIGN: OK for Phase 1 implementation and a limited pilot on SCA-4753 (2026-11-27 09:10Z).

Server (backend/)

  • telemetry/fleet_registry.json: five sync_backlog_* families (audio on Omi / on phone / awaiting server, oldest phone age, oldest awaiting-server age), four pendant_ring_* families, and eight fleet-native counters (ring snapshot, dropped increased, full, transfer started/abandoned/completed, unread hidden). New families are ios|android only.
  • Closed cohort label (on_ge_3_0_20|holdout_ge_3_0_20|other) on ring items, validated against label_sets; labeled events export as omi_client_labeled_events_total from the existing collector (no _created children).
  • Per-build rollups for the oldest phone age and phone audio (…_by_build_bucket_total{platform,build_band,le} at 1 h / 6 h / +Inf). build_band comes from the existing X-App-Build/X-App-Version headers; app_version stays discarded.
  • release_build_band: per-platform floor plus a per-process cap, replacing the Phase 0 allowlist in utils/sync/capture_end.py. That allowlist (1367–1520) matched none of the builds phones sent on 2026-11-28 (iOS 1597–1650, Android 1500/1651), so the Phase 0 by-build panel showed only older.
  • deploy/cloud_run_gmp_sidecar.yaml: sample limit 15,000 → 20,000. Backend peaked at 14,397 post-relabel samples per instance on 2026-11-28 (ro-prod GMP max_over_time(scrape_samples_post_metric_relabeling[1d])); this PR adds up to 1,100 worst-case series, and over the limit GMP drops the instance's whole scrape. Ingestion is billed per sample emitted, not by the ceiling.

App (app/)

  • services/telemetry/fleet_backlog_telemetry.dart: builds the snapshot from the same pending rows as the Sync details sheet. Empty queues are 0; a non-empty queue with no plausible time, or an unknown pendant inventory, is omitted (unknown, never 0). The hour is consumed before the request and never replayed; executeApi gains optional retries/retryServerErrors pass-throughs so this beacon sends once. Honors the analytics opt-out. Pilot: beta builds by default; flag mobile-fleet-backlog-telemetry disabled stops every channel, enabled widens to store builds.
  • services/telemetry/pendant_ring_observer.dart: ring fill, read share, net drain and foreground-backlog drain, drops and fullness from fresh ring INFO readings only (never the displayed on-device amount, which has shown 0 s with ~500k unread packets). Hooks: INFO reads/notifications in omi_connection.dart, transfer passes in ring_storage_sync.dart.
  • providers/sync_provider.dart: attaches the snapshot after the recording inventory loads.

Cost and data: no Firestore, GCS or Redis reads or writes beyond the route's existing per-UID rate-limit key; at most one request per installation-hour (route budget 12/h/UID). No IDs, content or free text.

Rollback: flag mobile-fleet-backlog-telemetry off stops all sends; server-side, revert this PR (registry additions are additive and unused by older apps).

Verification

  • Backend, m1 lane worktree via omi-heavy: pytest tests/unit/test_fleet_telemetry.py test_sync_capture_end.py test_product_metrics.py test_monitoring_dashboard_query_budget.py test_monitoring_gmp_shadow.py test_core_feature_headline_contract.py test_critical_failure_alerts.py test_desktop_message_quota_router.py → 210 passed, 1 skipped.
  • App: bash app/test.sh test/services/telemetry/fleet_backlog_telemetry_test.dart test/unit/offline_processing_display_test.dart test/unit/wal_derived_views_test.dart → spine 138 passed, focused 30 passed.
  • generate_fleet_schema.py --check and the GMP query inventory regenerate identically.
  • Not yet measured: pilot scrape size, reporting coverage and auth/rate-limit load in production; those are the SCA-4753 pilot readback before wider rollout. Alert thresholds wait for the seven-day baseline.

Product invariants affected

  • INV-CAP-1 — observation only: the ring observer and transfer-pass counters read INFO and pass outcomes; no drain, custody, unsubscribe or fencing behavior changes.

Line-Count-Exception: app/lib/providers/sync_provider.dart | 1712 -> 1756 | SCA-4753 snapshot wiring reads this provider's private inventory state
Line-Count-Exception: app/lib/services/devices/connectors/omi_connection.dart | 1622 -> 1628 | observer hooks at the existing INFO read and notify sites
Line-Count-Exception: app/lib/services/wals/ring_storage_sync.dart | 1731 -> 1736 | transfer-pass outcome hooks in syncAll

UI-Evidence: none -- no UI changes; telemetry and Grafana dashboard JSON only

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Git-on-my-level and others added 3 commits November 28, 2026 21:52
Server: registry families for the hourly backlog snapshot (seconds waiting
on the Omi, on the phone, awaiting settlement, and oldest ages) and the
pendant ring measures, with a closed SCA-4532 cohort label, mobile-only
platforms, and per-build rollups for regression tracking. Build bands use
per-platform floors and a per-process cap instead of the Phase 0 allowlist,
which matched none of the builds phones sent. Backend GMP sample cap
15,000 -> 20,000: backend already peaked at 14,397 and over the cap GMP
drops the whole instance scrape.

App: one snapshot per installation per UTC hour on POST /v1/telemetry/fleet,
numbers and closed labels only, analytics opt-out honored, beta pilot with
remote stop flag mobile-fleet-backlog-telemetry. Ring numbers come from
fresh INFO readings only.

Dashboard: Phase 1 panels in the Omi Core Features backlog row.

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

chatgpt-codex-connector Bot commented Nov 29, 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-29T03:46:17.776218Z a6b080d 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6b080d70e

ℹ️ 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".

Comment on lines +861 to +863
_fleetInventoryLoaded = true;
_phoneBacklogPresent = SyncPipelineAmounts.fromPending(derivedWals.pendingWork).waitingOnPhoneSeconds > 0;
if (_fleetAttached) unawaited(FleetBacklogTelemetry.instance.maybeSend());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wait for WAL readiness before consuming the first snapshot

On a cold start where disk recovery is still running, _refreshWals() can finish with an empty inventory: LocalWalSyncImpl.getAllWals() returns the current in-memory list without awaiting walReady. The readiness wait occurs later in _attachTransferCoordinator(), but these lines already allow telemetry to consume the hour and report zero backlog. Once the actual inventory loads, the hourly deduplication prevents correcting that observation, biasing backlog metrics toward zero precisely on installations with slow recovery. Await the phone's readiness and refresh its inventory before marking fleet inputs as loaded.

Useful? React with 👍 / 👎.

_ring = ring ?? PendantRingObserver.instance;

static final FleetBacklogTelemetry instance = FleetBacklogTelemetry();
static const flag = 'mobile-fleet-backlog-telemetry';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Register the telemetry flag so operators can control the pilot

The new mobile-fleet-backlog-telemetry key is absent from config/feature-flags.yaml (confirmed by repository-wide search). The documented store writer explicitly permits only registered keys: backend/scripts/omi_flags.py:68–73 rejects others with not a kind: posthog flag in config/feature-flags.yaml. Consequently, operators cannot use the supported writer to disable beta reporting or enable stable reporting, despite this flag being the advertised rollout and rollback control. Add a mobile-scoped registry entry alongside the reader.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

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:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

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!

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