Skip to content

perf(flags): stop PostHog flag requests in every client - #24386

Closed
Git-on-my-level wants to merge 12 commits into
mainfrom
lane/flags-cut
Closed

Git-on-my-level wants to merge 12 commits into
mainfrom
lane/flags-cut

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What changed and why

Cut billed PostHog flag HTTP traffic from new mobile, macOS and web builds. Flags now answer only from Omi's store, with existing caller defaults for absent keys; event capture and mobile replay remain in PostHog. Disable startup preloads and explicit SDK reloads, remove the Flutter /decide fetch and every SDK-cache fallback, and suppress implicit native SDK identify/reset flag requests in SDK-scoped transports. Unused SDK surveys stay disabled (the app has no PosthogObserver survey surface), avoiding native survey UI during the first setup. No rollback flag: rollback is the prior client build or a corrected Omi rule.

Dependency / release gate: stacks #24370 at ba60f92dd9eb17d05e131c0e0ecb18c74a3f97c7, merged into this branch without changing its branch or PR. That draft fixes trial paywall / pocket onboarding arms in code and stays Coordinator-owned pending Nik (kodjima33). Either PR can merge first with a merge commit. Do not release this cut before Nik's gate and David/Nik's chat/replay targeting ruling plus the approved store rules below. This PR performs no PostHog/store write, upstream merge, release or deploy.

Product invariants affected

none

How it was verified

  • Flutter adapter regression tests pass: only Omi reload/read, missing keys, failed refresh retaining the same-account snapshot, account reset and late-response rejection; event capture still reaches the SDK channel with flag preload disabled.
  • Web bun run check: typecheck, 6 smoke tests, 160 test files / 909 tests pass, including Omi-only flags and preserved capture/identify.
  • Expanded mobile suite: 90 tests pass, covering adapter/identity, chat gates and settings, replay, analytics flags, trial paywall and Pocket onboarding. Personas: 13 tests pass, executing its real bootstrap snippet with capture/identify queued and flags disabled.
  • Android :app:testDevDebugUnitTest --tests com.friend.ios.analytics.PostHogFlagRequestBlockerTest: BUILD SUCCESSFUL, both config/transport tests pass after compiling native app and plugin code.
  • Full iOS application build/device request capture was not run locally. The iOS bootstrap was reviewed against the resolved SDK source; Dart setup/channel and shared Swift SDK transport behavior are covered by the focused suites.
  • Final Flutter flag/chat/replay subset after the last setup/attribution change: 22 tests pass, including the resolved SDK-version contract.
  • Full macOS test-target compilation on the host's Xcode 27.2 (27B52) fails in unchanged TranscriptionFinalizationStateMachineTests.swift:12 and UnsyncedTaskCreateHTTPTests.swift:63 (URLProtocol subclasses inherit an unavailable Sendable conformance). Production app targets compiled/linked before the test-target failure. CI pins Xcode 26.6. All six affected tests pass in an isolated package against symlinked production store/transport sources and the exact PostHog 3.65.0 SDK; only unrelated app dependencies are stubbed. The real SDK sends an analytics batch while zero flag requests reach downstream transport. No tests are skipped in the full target.
  • make preflight: 65 checks pass. PR metadata preflight: 5 checks pass. The complete bounded push hook also passes, including generated-output checks, desktop flow lint and macOS production compilation.
  • Hosted CI: blocked on UI author approval. The account-scoped path policy includes the stacked UI files and requires Nik (kodjima33) to comment /approve-ui 7cad5adf998f8711fb8806eb3e2b0a5b70e8ecd8 on this PR. UI-Evidence: none does not waive that exact-head human approval. Remaining build/test workflows are running; local passes above are separate from hosted CI.
  • Independent Luna read-only review through agentctl: ready to open for review; not release-approved. Same-user cache invalidation and Android SDK attribution findings were independently verified and fixed. The fixed fix(app): fix the trial paywall and Pocket onboarding arms in code #24370 arms remain inside the requested dependency boundary. Native bootstrap, request-path and final iOS attribution deltas were reviewed with no concrete defect found. Operational targeting/UID approval and native/full-CI evidence remain gates.
  • Read-only production flag configuration inspected using ro-prod (no account records). Seven existing client rules plus backend proactivity_v2 are present in based-hardware / omi-flags; the serving backend revision reports this target. PostHog billing/flag definitions read through the existing program helper only, without exposing credentials or person targeting values.

Tests

screen-task-jev-gate.yaml states Omi-only authority and a hermetic SDK request-path/capture step. posthog_adapter_flags_test.dart, chat_apps_gate_test.dart, posthogFlags.test.ts, omiFlags.test.ts, PostHogFlagRequestBlockerTests.swift, PostHogFlagRequestBlockerTest.kt, personas posthog-config.test.mjs. Native transport tests exercise local /flags and /decide answers and pass capture/replay/config paths through; Swift also drives real SDK identify/reset/reload and capture.

UI evidence

UI-Evidence: none -- This cut changes flag authority and SDK transport, with no view/layout/copy edits. Approved store rules preserve the chat UI's current Telegram / David-only private-channel split; replay targeting changes recording eligibility. The trial/Pocket UI decision and its evidence belong to dependency #24370 and Nik's gate.

Flag inventory and value after the cut

"Unchanged" assumes the seven existing client rules are available; unknown keys retain caller defaults. Failed mobile/macOS refreshes keep only the same-account last-good in-memory snapshot. Account changes clear it. Web fails closed on failure/timeout. Pending writes are not assumed to have happened.

Availability change: there is no persisted SDK-cache fallback on a cold offline/store-unavailable launch. Those clients temporarily use caller defaults even if an old PostHog disk cache held another value: the stable lossless-sync 10% cohort and mobile onboarding-rating 100% rule wait for an Omi response, while unknown watch-copy state conservatively keeps recovery copies. Warm same-account failures retain Omi answers. The store remains the only authority; no new polling or SDK escape hatch is introduced.

Client Flag read Value after cut / who changes
Mobile clients_refactor false when absent; unchanged (absent in PostHog/store)
Mobile clients_from_segments_chunks false when absent; unchanged
Mobile custody_capture_committed_release false when absent; unchanged
Mobile mobile-capture-recovery-v1 false when absent; unchanged
Mobile saved-pendant-reconnect-kill false when absent; reconnect remains on, unchanged
Mobile summary-generation-v2 false when absent; unchanged
Mobile mobile-plan-storefront false when absent; unchanged
Mobile mobile-contextual-upsells false when absent; unchanged
Mobile mobile-on-device-overflow false when absent; unchanged
Mobile mobile-speech-analyzer-disabled false when absent; newer engine allowed, unchanged
Mobile mobile-local-preview-disabled false when absent; preview allowed, unchanged
Mobile mobile-wal-delta-index-off false when absent; delta index allowed, unchanged
Mobile watch_copy_dedupe_off existing Omi 0% => false; unchanged. Unknown => true at caller, conservatively retaining recovery copies
Mobile onboarding-setup-rating-prompt existing Omi 100% => true; unchanged
Mobile mobile_store_review_tuning absent payload => 5s reading / 30d cooldown; unchanged
Mobile mobile-chat-apps absent today => off until proposed Telegram 100% rule; then Telegram for everyone. Public payload cannot expose private channels
Mobile mobile-chat-apps-all-channels new, absent => false; proposed 0% + David UID allowlist, existing all-channels payload. Restores David's iMessage entry only after rule approval
Mobile mobile-session-replay absent today => off for everyone until proposed 5% + internal UID allowlist. Email-targeted / newly paired people outside that set lose replay; existing 5% bucket remains stable
Mobile (exposure only) paywall-variant no flag read: fixed trial from #24370; exposure analytics retained. Live PostHog currently trial 100%; same arm, pending Nik
Mobile (exposure only) onboarding-variant no flag read: fixed pocket from #24370; exposure analytics retained. Live PostHog currently pocket 100%; same arm, pending Nik
Mobile (dead) onboarding-webview never read; no store rule or behavior change
macOS clients_refactor absent => false; unchanged
macOS clients_from_segments_chunks absent => false; unchanged
macOS clients_boundary_evidence absent => false; unchanged
macOS client_telemetry_transport_shadow absent => false; unchanged
macOS client_telemetry_posthog_retirement absent => false; capture remains on, unchanged
macOS desktop-rating-prompt-disabled existing Omi 0% => false; rating remains enabled, unchanged
macOS free-tier-kill-switch-v1 existing Omi 0% => false; local capability stays enabled, unchanged; direct SDK bypass removed
macOS negative_feedback_remediation_kill existing Omi 0% => false; remediation stays enabled, unchanged
macOS screen_activity_lossless_sync existing Omi 10%; same key/UID SHA-1 bucket as PostHog. Stable same cohort; bundle-specific Beta/dev overrides unchanged
macOS screen_activity_lossless_sync_kill existing Omi 0% => false; unchanged
macOS screen_task_jev_gate absent => on; unchanged for new builds (live PostHog enables app_build >= 12552 or unset). Only explicit false kills. No store write needed; old <=12551 installations keep their old behavior until upgraded. Backend admission and consent remain separate authorities
macOS desktop-plan-storefront absent => false; unchanged
macOS desktop-contextual-upsells absent => false; unchanged
Web app web-plan-storefront absent => false; unchanged
Web app web-contextual-upsells absent => false; unchanged
Personas none disable SDK flag loading; capture/identify queue preserved
Windows/Linux and web frontend/admin none direct capture or aggregate query paths only; no flag SDK/request to cut

Exact pending store changes (not executed)

Target: projects/based-hardware/databases/omi-flags, collection omi_flags. Use backend/scripts/omi_flags.py, which copies registry surfaces and adds version/timestamp/actor plus the atomic audit/meta write. No --mirror-posthog. The three keys are currently absent, so no allow/deny lists need clearing.

Key Exact rule fields
mobile-chat-apps active: true, rollout_percentage: 100, variant: "telegram", payload: "{\"telegram\":{\"provider\":\"telegram\",\"address\":\"omi_chat_bot\"}}", allow_uids: [], deny_uids: [], surfaces: ["mobile"]
mobile-chat-apps-all-channels active: true, rollout_percentage: 0, variant: "all-channels", payload: exact current mobile-chat-apps PostHog all-channels payload, allow_uids: [DAVID_UID], deny_uids: [], surfaces: ["mobile"]
mobile-session-replay active: true, rollout_percentage: 5, variant: null, payload: null, allow_uids: APPROVED_INTERNAL_UIDS, deny_uids: [], surfaces: ["mobile"]

DAVID_UID and APPROVED_INTERNAL_UIDS are unresolved operator inputs, not runnable placeholders or invented identities. The limit on production account access prevents resolving emails to UIDs in this lane. The existing private-channel payload is configuration, not a new endpoint. David/Nik must approve these exact rules and supply the UID list before a writer prepares its reviewed CLI plan. The store cannot express property targeting or per-group variants; no claim of exact replay cohort parity. Do not write paywall/onboarding arms or screen_task_jev_gate; do not recreate absent 0% kill switches just to retain false defaults.

The cut itself ships on, without a new gate. The separate private-channel key is the requested real-risk boundary preventing exposure of unreleased channel endpoints; it is a persistent explicit allowlist, not a delayed public rollout. Replay proposal keeps 5% plus internal users; Nik owns expansion only after clean stored-frame fidelity, slow-frame/crash metrics and replay-budget checks, by the existing 2026-11-25 review deadline.

Billing / reachable saving (read-only)

The helper's feature_flags usage reports Oct 30 139,199, Oct 31 866,324, Nov 1 419,889 requests: 475,137/day mean. 866K is not the run rate. Read-only billing API snapshot on 2026-11-02: 25,492,050 requests / $841.90 posted (usage and tier charges can post asynchronously).

The account's actual graduated tiers are first 1M free; 1–2M $0.0001; 2–10M $0.000045; 10–50M $0.000025; above 50M $0.00001. At the rounded 475K/day baseline, 30 days = 14.25M and $566.25/month (31 days $578.13): $100 + $360 + $106.25. The earlier 19.8M / $705 matches this curve. $25/M is only the current marginal tier, not a flat total-bill rate. Pricing.

Attribution is an estimate from activity, not billing attribution: releasable macOS ~30K/day plus mobile <100K/day and small web volume. Full adoption of this PR reaches roughly 30K–130K/day plus web, or $22.50–$97.50/month plus web at 30 days ($23.25–$100.75 at 31). It cannot remove most old-build traffic via a new release. No saving has been realized by this unshipped PR; backend requests remain separate. A separately approved $0 feature-flags billing cap could remove the remaining future flag charge after the free allocation (it cannot undo already-posted spend) (up to the full $566–$578/month baseline), but it changes legacy/backend flag availability and is not part of this release saving.

Can a PostHog-side control reach old macOS builds?

Billing limit: yes for spend, not a reliable client kill. PostHog documents an organization-wide per-product cap, shared across projects. Over-limit flag evaluations return quota-limited defaults; the cap prevents charges above the configured amount. It does not stop HTTP polling and affects old mobile experiments / other projects too. The shared server pipeline returns the quota response before its billing-record step; the limit response contains no evaluated flags, so those blocked requests are not recorded as billable evaluations. /decide and /flags share PostHog's flag handler, including quota handling; build 12551 actually sends /flags/?v=2. No setting was changed. Limits, flag quota response.

Pinned-source caveat: tag v0.12.551+12551-macos pins PostHog iOS 3.65.0 (33145b13ffa1135623e6a2624e29234288a52258). Its PostHogRemoteConfig.swift explicitly retains cached flags when quotaLimited contains feature_flags; it does not simply empty them as the generic docs suggest. Cached screen_task_jev_gate=false remains off (slow reload), cached true remains on. With genuinely empty valid flags or no cache, ScreenTaskFeature and the direct ScreenTaskFreshFlagResponse treat missing/quota-limited flags as on; backend admission remains required, and the 30-second on-path can continue issuing requests (unbilled after the cap). Active old tags v0.12.505+12505-macos and v0.12.541+12541-macos also pin that exact SDK revision; 12505 likewise hard-codes the cloud host and preloads flags. Very old tags/SDKs may differ; this is not an assertion about every historic build. SDK source, old client.

Owned proxy: no for the inspected old build. Its PostHogManager hard-codes https://us.i.posthog.com; there is no Omi-controlled proxy/host setting to cut off. A cap requires a separate David-approved operation and assessment of legacy cached/default behavior after Nik's migration gate. The inspected backend is still OMI_FLAGS_SOURCE=dual, which serves PostHog (not Omi) for proactivity_v2; quota-empty/error answers therefore deny that backend feature after its cache expires. Move and verify server authority separately before considering a cap.

Failure class (fixes)

Failure-Class: none

🤖 Generated with Claude Code

Git-on-my-level and others added 10 commits November 2, 2026 15:32
Both experiment flags already serve one arm at 100%. Reading them is what
blocks the release that stops clients loading flags from PostHog.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Disable PostHog flag preloads, explicit and implicit requests while preserving event capture and mobile replay. Keep missing-key defaults and account-bound snapshots; prepare the pending chat and replay store migration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preserve the Coordinator-owned #24370 fixed trial and Pocket arms and make their exposure-only role explicit for new builds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The app has no PosthogObserver survey surface. Disable SDK surveys in Dart and the first native setup so the transport bootstrap cannot install native survey UI in place of Flutter delegation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Normalize trailing slashes in the request-path recorder; pinned SDK capture uses /batch and flag requests use /flags. Exercise both forms of flags and decide locally.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use the established killSwitchFlag constant convention so the registry checker tracks this Omi-only read after the SDK bypass is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the retired PostHog fallback expectation and add a hermetic SDK request-path step covering the new transport while verifying analytics batch delivery.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PostHog snapshots its SDK context during setup. Seed Flutter attribution before native initialization and pin the declared version to pubspec.lock with a regression test.

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

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-02T13:07:36.901368Z
We couldn’t complete this review. Comment @codex review to try again.
7cad5ad 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment /approve-ui 7cad5adf998f8711fb8806eb3e2b0a5b70e8ecd8. Each new head needs a fresh approval. To withdraw it, comment /reject-ui <full head SHA>. Non-UI work and unrelated access are unaffected.

@cubic-dev-ai cubic-dev-ai 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.

23 issues found across 38 files

Confidence score: 3/5

  • LocalCapabilityRemoteKill.swift no longer enforces the free-tier emergency stop on cold start or after an account reset until a /v1/flags fetch succeeds. Preserve a fallback that covers those periods.
  • screen-task-jev-gate.yaml and its blocker tests don't prove the gate ignores PostHog or that replay and remote config pass through. Add SDK-level assertions for those behaviors.
  • app/build.gradle uses a floating PostHog version range, so builds can pick an SDK version that posthog_flutter 5.28.0 wasn't tested with. Pin the matching native version.
  • The changelog fragments for ChatAppsGate and the paywall/onboarding changes are marked kind: none despite user-visible behavior changes. Update them to the appropriate user-facing change kind.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/android/app/build.gradle">

<violation number="1" location="app/android/app/build.gradle:61">
P2: This configuration-time lookup has no null guards, so a missing `.flutter-plugins-dependencies` or `posthog_flutter` entry fails the whole Gradle configuration with an unhelpful NPE. Add an explicit check with a clear `GradleException` message when the plugin or version line is not found.</violation>

<violation number="2" location="app/android/app/build.gradle:187">
P2: The posthog-android dependency uses a floating range `[3.51.0,4.0.0]`, so builds can silently pick a newer SDK than the one `posthog_flutter` 5.28.0 was tested with. Pin it to the exact native version that matches the Flutter plugin, and bump it deliberately with the plugin.</violation>
</file>

<file name="app/test/unit/onboarding_variant_gate_test.dart">

<violation number="1" location="app/test/unit/onboarding_variant_gate_test.dart:10">
P2: This assertion does not verify the PR’s core no-flag-read guarantee. Add an observable flag-access seam or request-count assertion so a PostHog read cannot regress unnoticed.</violation>
</file>

<file name="desktop/macos/e2e/flows/screen-task-jev-gate.yaml">

<violation number="1" location="desktop/macos/e2e/flows/screen-task-jev-gate.yaml:41">
P2: S1b can pass without proving that PostHog is ignored: it never sets a conflicting PostHog value or asserts zero `/flags`/`/decide` traffic. Make the fixture return false and assert the gate remains enabled with no downstream flag request.</violation>

<violation number="2" location="desktop/macos/e2e/flows/screen-task-jev-gate.yaml:45">
P2: S1c requires replay and remote-config pass-through, but `PostHogFlagRequestBlockerTests` only drives identify/reset/reload/capture; its non-flag checks call `canInit` directly. Add SDK calls and downstream assertions for those paths, or remove them from this flow’s coverage claim.

(Based on your team's feedback about requiring E2E flows to exercise claimed paths.)</violation>
</file>

<file name="app/changelog/unreleased/20261102-omi-flag-authority.json">

<violation number="1" location="app/changelog/unreleased/20261102-omi-flag-authority.json:1">
P2: This file declares `kind: none`, but the PR changes what chat-app channels users see. `ChatAppsGate` now exposes only Telegram on the public `mobile-chat-apps` key, so iMessage and WhatsApp need the new `mobile-chat-apps-all-channels` flag. The existing WhatsApp fragment promises users WhatsApp connects once it is enabled, so this change needs a user-facing fragment or an explicit reason why it is not user-visible.</violation>
</file>

<file name="web/app/src/lib/__tests__/posthogFlags.test.ts">

<violation number="1" location="web/app/src/lib/__tests__/posthogFlags.test.ts:43">
P2: This test can pass when `PostHogManager` omits reads or queries the wrong flag key. Assert four calls and each key so the test verifies Omi is actually the source for every result.</violation>
</file>

<file name="app/test/unit/chat_apps_gate_test.dart">

<violation number="1" location="app/test/unit/chat_apps_gate_test.dart:22">
P2: `readFlag: (_) async => true` makes this test pass regardless of which flag `read` queries, so it cannot catch a regression that treats the public `mobile-chat-apps` flag as the private all-channels gate. Return true only for `ChatAppsGate.allChannelsFlag`; the first test already covers the public-key path.</violation>
</file>

<file name="app/test/unit/paywall_experiment_test.dart">

<violation number="1" location="app/test/unit/paywall_experiment_test.dart:10">
P2: This test does not verify the no-flag-read contract it claims to cover. Add an analytics/flag-reader spy or another injectable seam and assert that neither variant nor payload is requested.</violation>
</file>

<file name="backend/docs/runbooks/omi-flags.md">

<violation number="1" location="backend/docs/runbooks/omi-flags.md:24">
P3: The rewrite drops the server-side absent behavior. Under `OMI_FLAGS_SOURCE=omi`, a key with no rule should resolve to its registry fail value, but the runbook now only describes client defaults. Restore that sentence so operators know what `proactivity_v2` does during rollout.</violation>
</file>

<file name="desktop/macos/Desktop/Sources/LocalInference/LocalCapabilityRemoteKill.swift">

<violation number="1" location="desktop/macos/Desktop/Sources/LocalInference/LocalCapabilityRemoteKill.swift:7">
P3: The ARCHITECTURE.md paragraph on `free-tier-kill-switch-v1` still says the kill reads only the SDK cache and that the SDK refresh owns latency. Update it to say the kill reads `OmiFlagStore`, refreshed on identify and the 30-minute tick.</violation>

<violation number="2" location="desktop/macos/Desktop/Sources/LocalInference/LocalCapabilityRemoteKill.swift:7">
P2: With the SDK-cache fallback removed, the free-tier emergency stop is not enforced from cold start until the first successful `/v1/flags` fetch, and after any account reset. The kill was previously honored from the persisted PostHog cache in that window. Confirm this fail-open window is accepted for an ops cost-stop before merging.</violation>
</file>

<file name="app/changelog/unreleased/fixed-paywall-onboarding-arms.json">

<violation number="1" location="app/changelog/unreleased/fixed-paywall-onboarding-arms.json:1">
P2: This fragment is `kind: none`, which says there is no user-visible change. The code now shows the trial paywall and Pocket onboarding unconditionally, where before any flag failure fell back to control. Use a user-facing `change` entry, or confirm that no user can reach the control path today.</violation>
</file>

<file name="config/feature-flags.yaml">

<violation number="1" location="config/feature-flags.yaml:335">
P2: This row is recorded as a settled `keep` decision, but the notes and PR say it is an unapproved proposal. Set `decision` to `pending` and `terminal` to `undecided`, and add a `review_by` like the other pending rows, until David/Nik approve it.</violation>

<violation number="2" location="config/feature-flags.yaml:610">
P2: The replay flag now documents a proposed 5% cohort, but its rollout ramp still jumps from internal identities to 20% and 50%. Add the 5% cohort to `ramp.cohorts` (then regenerate the registry), or change the proposal text to match the intended ramp.</violation>
</file>

<file name="app/lib/pages/paywall/paywall_router.dart">

<violation number="1" location="app/lib/pages/paywall/paywall_router.dart:32">
P3: With the `await` removed, nothing async runs between the `usage` read and these guards. The `context.mounted` check and the repeated `showSubscriptionUI` check can no longer fire, so delete them.</violation>
</file>

<file name="desktop/macos/Desktop/Tests/PostHogFlagRequestBlockerTests.swift">

<violation number="1" location="desktop/macos/Desktop/Tests/PostHogFlagRequestBlockerTests.swift:25">
P2: This expectation is fulfilled by the first analytics batch, not specifically by the batch caused by `capture("flags-cut-capture")`. If identify/reset or persisted SDK work emits a batch first, the await returns before the capture flush is observed and the test can pass without proving capture still reaches the network; arm a fresh post-setup expectation or assert a batch count increase after the capture flush.</violation>
</file>

<file name="desktop/macos/Desktop/Sources/OmiFlagStore.swift">

<violation number="1" location="desktop/macos/Desktop/Sources/OmiFlagStore.swift:12">
P3: This comment omits the 5-minute poll in `RatingPromptManager` that also calls `reloadFeatureFlags()` while the prompt is visible. Add that cadence or drop the enumeration so the comment matches the actual refresh sources.</violation>

<violation number="2" location="desktop/macos/Desktop/Sources/OmiFlagStore.swift:47">
P3: The new in-flight guard and the `reset()` notification have no test coverage. Add a test that calls `reset()` with flags present and asserts `featureFlagsDidLoad` posts, and one that checks a second `refresh()` at the same generation is suppressed while the first is in flight.</violation>
</file>

<file name="app/lib/services/experiments/session_replay_gate.dart">

<violation number="1" location="app/lib/services/experiments/session_replay_gate.dart:6">
P3: This comment says the internal UIDs are already approved, but replay targeting remains pending approval and real UID inputs. Describe the UID cohort as pending so this gate is not presented as release-authorized.</violation>
</file>

<file name="app/lib/services/experiments/chat_apps_gate.dart">

<violation number="1" location="app/lib/services/experiments/chat_apps_gate.dart:109">
P2: This new allowlist read breaks the existing `messaging_channels_provider_test.dart` test, which still expects the public flag to be used for both reads. Update that test to cover the false/public and true/all-channels branches and their new key sequences.</violation>
</file>

<file name="web/personas-open-source/src/app/layout.tsx">

<violation number="1" location="web/personas-open-source/src/app/layout.tsx:62">
P2: `advanced_disable_feature_flags` disables evaluation but keeps PostHog’s `/flags` request active. Use `advanced_disable_flags: true` so the persona build makes no PostHog flags request.</violation>
</file>

<file name="web/app/src/lib/analytics/posthog.ts">

<violation number="1" location="web/app/src/lib/analytics/posthog.ts:19">
P2: `advanced_disable_feature_flags` disables evaluation but keeps PostHog’s `/flags` request active. Use `advanced_disable_flags: true` so the web app makes no PostHog flags request.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

// Match the Flutter plugin's SDK attribution in our first native setup.
// Read the resolved package, so dependency upgrades cannot silently stale it.
def flutterPlugins = new groovy.json.JsonSlurper().parse(rootProject.file('../.flutter-plugins-dependencies'))
def posthogPlugin = flutterPlugins.plugins.android.find { it.name == 'posthog_flutter' }

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: This configuration-time lookup has no null guards, so a missing .flutter-plugins-dependencies or posthog_flutter entry fails the whole Gradle configuration with an unhelpful NPE. Add an explicit check with a clear GradleException message when the plugin or version line is not found.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/android/app/build.gradle, line 61:

<comment>This configuration-time lookup has no null guards, so a missing `.flutter-plugins-dependencies` or `posthog_flutter` entry fails the whole Gradle configuration with an unhelpful NPE. Add an explicit check with a clear `GradleException` message when the plugin or version line is not found.</comment>

<file context>
@@ -55,6 +55,13 @@ kotlin {
+// Match the Flutter plugin's SDK attribution in our first native setup.
+// Read the resolved package, so dependency upgrades cannot silently stale it.
+def flutterPlugins = new groovy.json.JsonSlurper().parse(rootProject.file('../.flutter-plugins-dependencies'))
+def posthogPlugin = flutterPlugins.plugins.android.find { it.name == 'posthog_flutter' }
+def posthogFlutterVersion = new File(posthogPlugin.path, 'pubspec.yaml').readLines()
+        .find { it.startsWith('version:') }.split(':', 2)[1].trim()
</file context>

androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.posthog:posthog-android:[3.51.0,4.0.0]'

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: The posthog-android dependency uses a floating range [3.51.0,4.0.0], so builds can silently pick a newer SDK than the one posthog_flutter 5.28.0 was tested with. Pin it to the exact native version that matches the Flutter plugin, and bump it deliberately with the plugin.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/android/app/build.gradle, line 187:

<comment>The posthog-android dependency uses a floating range `[3.51.0,4.0.0]`, so builds can silently pick a newer SDK than the one `posthog_flutter` 5.28.0 was tested with. Pin it to the exact native version that matches the Flutter plugin, and bump it deliberately with the plugin.</comment>

<file context>
@@ -176,6 +184,7 @@ dependencies {
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
     implementation 'androidx.multidex:multidex:2.0.1'
     implementation 'com.squareup.okhttp3:okhttp:4.12.0'
+    implementation 'com.posthog:posthog-android:[3.51.0,4.0.0]'
     implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
     implementation 'io.intercom.android:intercom-sdk:latest.release'
</file context>
Suggested change
implementation 'com.posthog:posthog-android:[3.51.0,4.0.0]'
implementation 'com.posthog:posthog-android:3.51.0'


test('flag key is the registered PostHog key', () {
test('readers get pocket without any flag read; the key stays registered', () {
expect(OnboardingVariantGate.arm, OnboardingArm.pocket);

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: This assertion does not verify the PR’s core no-flag-read guarantee. Add an observable flag-access seam or request-count assertion so a PostHog read cannot regress unnoticed.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/test/unit/onboarding_variant_gate_test.dart, line 10:

<comment>This assertion does not verify the PR’s core no-flag-read guarantee. Add an observable flag-access seam or request-count assertion so a PostHog read cannot regress unnoticed.</comment>

<file context>
@@ -1,16 +1,13 @@
-
-  test('flag key is the registered PostHog key', () {
+  test('readers get pocket without any flag read; the key stays registered', () {
+    expect(OnboardingVariantGate.arm, OnboardingArm.pocket);
     expect(OnboardingVariantGate.enabledFlag, 'onboarding-variant');
     expect(OnboardingVariantGate.debugOverride, isNull);
</file context>


- id: S1c
name: SDK identity changes cannot fetch flags and analytics still captures
do: "Run the hermetic PostHogFlagRequestBlockerTests with its SDK-scoped URLProtocol fixture (posthog.invalid, no production host or account). Verify both /flags and /decide path forms are answered locally with empty flags. Drive SDK identify, reset and reload; assert the downstream fixture records zero flag paths and receives the analytics /batch request. The same fixture must pass capture, replay and remote-config paths through. Record this unit evidence separately from live named-bundle acceptance; no production analytics request is permitted for this probe."

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: S1c requires replay and remote-config pass-through, but PostHogFlagRequestBlockerTests only drives identify/reset/reload/capture; its non-flag checks call canInit directly. Add SDK calls and downstream assertions for those paths, or remove them from this flow’s coverage claim.

(Based on your team's feedback about requiring E2E flows to exercise claimed paths.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/macos/e2e/flows/screen-task-jev-gate.yaml, line 45:

<comment>S1c requires replay and remote-config pass-through, but `PostHogFlagRequestBlockerTests` only drives identify/reset/reload/capture; its non-flag checks call `canInit` directly. Add SDK calls and downstream assertions for those paths, or remove them from this flow’s coverage claim.

(Based on your team's feedback about requiring E2E flows to exercise claimed paths.) </comment>

<file context>
@@ -33,11 +34,15 @@ preconditions:
+
+  - id: S1c
+    name: SDK identity changes cannot fetch flags and analytics still captures
+    do: "Run the hermetic PostHogFlagRequestBlockerTests with its SDK-scoped URLProtocol fixture (posthog.invalid, no production host or account). Verify both /flags and /decide path forms are answered locally with empty flags. Drive SDK identify, reset and reload; assert the downstream fixture records zero flag paths and receives the analytics /batch request. The same fixture must pass capture, replay and remote-config paths through. Record this unit evidence separately from live named-bundle acceptance; no production analytics request is permitted for this probe."
 
   - id: S2
</file context>

name: An Omi flag-store rule answers ahead of PostHog
do: "With the synthetic backend serving GET /v1/flags?surface=macos as {screen_task_jev_gate: enabled=false} while the PostHog fixture keeps it true, relaunch and verify the gate does not run (the Omi answer wins). Serve an empty flags list and verify the PostHog value decides again after the next reload. Sign out and in as another synthetic account and verify the first account's Omi answers are gone before the new fetch lands."
name: Only the Omi flag-store rule can answer
do: "With the synthetic backend serving GET /v1/flags?surface=macos as {screen_task_jev_gate: enabled=false} relaunch and verify the gate does not run. Serve an empty flags list and verify the gate defaults on after the next successful refresh, without consulting PostHog. A failed refresh keeps the same-account Omi answer. Sign out and in as another synthetic account and verify the first account's Omi answers are gone before the new fetch lands."

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: S1b can pass without proving that PostHog is ignored: it never sets a conflicting PostHog value or asserts zero /flags//decide traffic. Make the fixture return false and assert the gate remains enabled with no downstream flag request.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/macos/e2e/flows/screen-task-jev-gate.yaml, line 41:

<comment>S1b can pass without proving that PostHog is ignored: it never sets a conflicting PostHog value or asserts zero `/flags`/`/decide` traffic. Make the fixture return false and assert the gate remains enabled with no downstream flag request.</comment>

<file context>
@@ -33,11 +34,15 @@ preconditions:
-    name: An Omi flag-store rule answers ahead of PostHog
-    do: "With the synthetic backend serving GET /v1/flags?surface=macos as {screen_task_jev_gate: enabled=false} while the PostHog fixture keeps it true, relaunch and verify the gate does not run (the Omi answer wins). Serve an empty flags list and verify the PostHog value decides again after the next reload. Sign out and in as another synthetic account and verify the first account's Omi answers are gone before the new fetch lands."
+    name: Only the Omi flag-store rule can answer
+    do: "With the synthetic backend serving GET /v1/flags?surface=macos as {screen_task_jev_gate: enabled=false} relaunch and verify the gate does not run. Serve an empty flags list and verify the gate defaults on after the next successful refresh, without consulting PostHog. A failed refresh keeps the same-account Omi answer. Sign out and in as another synthetic account and verify the first account's Omi answers are gone before the new fetch lands."
+
+  - id: S1c
</file context>
Suggested change
do: "With the synthetic backend serving GET /v1/flags?surface=macos as {screen_task_jev_gate: enabled=false} relaunch and verify the gate does not run. Serve an empty flags list and verify the gate defaults on after the next successful refresh, without consulting PostHog. A failed refresh keeps the same-account Omi answer. Sign out and in as another synthetic account and verify the first account's Omi answers are gone before the new fetch lands."
do: "With the synthetic backend serving GET /v1/flags?surface=macos as {screen_task_jev_gate: enabled=false} relaunch and verify the gate does not run. Serve an empty flags list while the conflicting PostHog fixture returns false, then verify the gate defaults on after the next successful refresh and the downstream fixture records zero /flags and /decide requests. A failed refresh keeps the same-account Omi answer. Sign out and in as another synthetic account and verify the first account's Omi answers are gone before the new fetch lands."


static var isDisabled: Bool {
resolve(OmiFlagStore.shared.value(key) ?? PostHogSDK.shared.getFeatureFlag(key, sendFeatureFlagEvent: false))
resolve(OmiFlagStore.shared.value(killSwitchFlag))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The ARCHITECTURE.md paragraph on free-tier-kill-switch-v1 still says the kill reads only the SDK cache and that the SDK refresh owns latency. Update it to say the kill reads OmiFlagStore, refreshed on identify and the 30-minute tick.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/macos/Desktop/Sources/LocalInference/LocalCapabilityRemoteKill.swift, line 7:

<comment>The ARCHITECTURE.md paragraph on `free-tier-kill-switch-v1` still says the kill reads only the SDK cache and that the SDK refresh owns latency. Update it to say the kill reads `OmiFlagStore`, refreshed on identify and the 30-minute tick.</comment>

<file context>
@@ -1,12 +1,10 @@
 
   static var isDisabled: Bool {
-    resolve(OmiFlagStore.shared.value(key) ?? PostHogSDK.shared.getFeatureFlag(key, sendFeatureFlagEvent: false))
+    resolve(OmiFlagStore.shared.value(killSwitchFlag))
   }
 
</file context>

Comment on lines +32 to 34
final resolved = config ?? PaywallExperiment.current;
if (!context.mounted) return false;
if (!context.read<UsageProvider>().showSubscriptionUI) return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: With the await removed, nothing async runs between the usage read and these guards. The context.mounted check and the repeated showSubscriptionUI check can no longer fire, so delete them.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/pages/paywall/paywall_router.dart, line 32:

<comment>With the `await` removed, nothing async runs between the `usage` read and these guards. The `context.mounted` check and the repeated `showSubscriptionUI` check can no longer fire, so delete them.</comment>

<file context>
@@ -30,7 +29,7 @@ abstract final class PaywallRouter {
     if (!usage.showSubscriptionUI) return false;
     if (usage.subscription?.subscription.plan.isPaid == true) return false;
-    final resolved = config ?? await PaywallExperiment.resolve();
+    final resolved = config ?? PaywallExperiment.current;
     if (!context.mounted) return false;
     if (!context.read<UsageProvider>().showSubscriptionUI) return false;
</file context>
Suggested change
final resolved = config ?? PaywallExperiment.current;
if (!context.mounted) return false;
if (!context.read<UsageProvider>().showSubscriptionUI) return false;
final resolved = config ?? PaywallExperiment.current;

/// identify and the 30-minute screen-task reload), so this adds one backend call per
/// PostHog reload and no PostHog requests. Docs: `backend/docs/runbooks/omi-flags.md`.
/// The only client flag authority. Missing keys are nil so callers retain their
/// existing defaults. Refreshes ride identify and the 30-minute screen-task tick;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This comment omits the 5-minute poll in RatingPromptManager that also calls reloadFeatureFlags() while the prompt is visible. Add that cadence or drop the enumeration so the comment matches the actual refresh sources.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/macos/Desktop/Sources/OmiFlagStore.swift, line 12:

<comment>This comment omits the 5-minute poll in `RatingPromptManager` that also calls `reloadFeatureFlags()` while the prompt is visible. Add that cadence or drop the enumeration so the comment matches the actual refresh sources.</comment>

<file context>
@@ -8,20 +8,16 @@ struct OmiFlag: Sendable, Equatable {
-/// identify and the 30-minute screen-task reload), so this adds one backend call per
-/// PostHog reload and no PostHog requests. Docs: `backend/docs/runbooks/omi-flags.md`.
+/// The only client flag authority. Missing keys are nil so callers retain their
+/// existing defaults. Refreshes ride identify and the 30-minute screen-task tick;
+/// failures keep the last answer for this account.
 final class OmiFlagStore: @unchecked Sendable {
</file context>
Suggested change
/// existing defaults. Refreshes ride identify and the 30-minute screen-task tick;
/// existing defaults. Refreshes ride identify, the 30-minute screen-task tick, and the rating-prompt poll;

flags = [:]
return changed
}
if changed {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The new in-flight guard and the reset() notification have no test coverage. Add a test that calls reset() with flags present and asserts featureFlagsDidLoad posts, and one that checks a second refresh() at the same generation is suppressed while the first is in flight.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/macos/Desktop/Sources/OmiFlagStore.swift, line 47:

<comment>The new in-flight guard and the `reset()` notification have no test coverage. Add a test that calls `reset()` with flags present and asserts `featureFlagsDidLoad` posts, and one that checks a second `refresh()` at the same generation is suppressed while the first is in flight.</comment>

<file context>
@@ -42,9 +38,16 @@ final class OmiFlagStore: @unchecked Sendable {
       flags = [:]
+      return changed
+    }
+    if changed {
+      Task { @MainActor in
+        NotificationCenter.default.post(name: PostHogManager.featureFlagsDidLoad, object: nil)
</file context>

/// `lib/utils/analytics/session_replay.dart` acts on it). Lifecycle: rollout; owner: nik; default off.
abstract final class SessionReplayGate {
/// PostHog flag key (project 302298). Registered in `config/feature-flags.yaml`.
/// Omi store boolean: proposed 5% plus approved internal UIDs; no client-side targeting.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This comment says the internal UIDs are already approved, but replay targeting remains pending approval and real UID inputs. Describe the UID cohort as pending so this gate is not presented as release-authorized.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/services/experiments/session_replay_gate.dart, line 6:

<comment>This comment says the internal UIDs are already approved, but replay targeting remains pending approval and real UID inputs. Describe the UID cohort as pending so this gate is not presented as release-authorized.</comment>

<file context>
@@ -3,7 +3,7 @@ import 'package:flutter/foundation.dart';
 /// `lib/utils/analytics/session_replay.dart` acts on it). Lifecycle: rollout; owner: nik; default off.
 abstract final class SessionReplayGate {
-  /// PostHog flag key (project 302298). Registered in `config/feature-flags.yaml`.
+  /// Omi store boolean: proposed 5% plus approved internal UIDs; no client-side targeting.
   static const enabledFlag = 'mobile-session-replay';
 
</file context>
Suggested change
/// Omi store boolean: proposed 5% plus approved internal UIDs; no client-side targeting.
/// Omi store boolean: proposed 5% plus an internal UID list pending approval; no client-side targeting.

Git-on-my-level and others added 2 commits November 4, 2026 11:29
…t build

Read the public mobile-chat-apps switch before the private all-channels key
so the allowlist alone can never turn the surface on, and update the gate and
provider key-sequence assertions to the new read order.

Drop the two redundant URLProtocol @unchecked Sendable conformances that the
pinned toolchain rejects as already unavailable, and satisfy the blocker
capture expectation only when the decoded batch carries the requested event.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment /approve-ui cb012dcbdfbb5ac35780c6af42098811f15992ed. Each new head needs a fresh approval. To withdraw it, comment /reject-ui <full head SHA>. Non-UI work and unrelated access are unaffected.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Folded into the survivor #24485 (head d6ab3673d9e40b3612856348e40704f7663501d6, branch lane/action-reminders-1103) and closed in its favor — nothing merged to main from here.

What carried over: the Omi-store flag authority across Android (OmiPostHogSetup + flag-request blocker + tests), iOS (OmiPostHogSetup, pbxproj), macOS (OmiFlagStore, PostHogFlagRequestBlocker, LocalCapabilityRemoteKill and their tests), the posthog adapter/analytics-manager changes, chat-apps/session-replay gating, and the mobile-chat-apps-all-channels registry row (restored explicitly — it was dropped in an auto-merge and the registry check caught it).

Union resolutions in config/feature-flags.yaml: main's newer SERVER_BATCH_ONLY_AUTO_LANGUAGE_PERCENT wording (mobile/web cohorts) was kept, and this PR's mobile-session-replay Omi-store row won over main's older client-evaluated row. The paywall/onboarding files this PR touched were also carried by #24370; both versions are reconciled in the survivor.

@github-actions

github-actions Bot commented Nov 4, 2026

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