Skip to content

harden(app): forward capture composition seams into CaptureProvider (defaults kept) - #14367

Closed
Git-on-my-level wants to merge 10 commits into
task/msd-core-c1-lifetimefrom
task/msd-core-c1-composition
Closed

Git-on-my-level wants to merge 10 commits into
task/msd-core-c1-lifetimefrom
task/msd-core-c1-composition

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

What changed and why

C1 cut (2): composeCaptureProvider now forwards every seam CaptureController already accepts (WAL, mic, batch flag, auth, clock, scheduling, connectivity, preferences, BLE listeners, socket open, location, codec, mic permission, telemetry, segment store) through CaptureProvider's super. constructor. Production no-argument defaults stay, including CaptureConnectivityBoundary.production(). composeProductionCaptureProvider refuses FLUTTER_TEST (process env or --dart-define) before resolving any singleton, and still does not construct ConnectivityService. owner and ensureDeviceConnection remain on CaptureDependencies for later cuts. main.dart's two ProxyProvider arms are untouched.

Stacked on #14361 (task/msd-core-c1-lifetime). CaptureBleListeners / CaptureSocketOpen moved to capture_seams.dart so composition can construct a provider without a composition↔controller import cycle.

capture_controller.dart stays at 2710 lines. Custom STT polling helpers moved to stt_mode_resolver.dart to pay for the new fields. The file is not dart-format-clean at HEAD (dart format of HEAD alone is 2711 lines / ~169-line reflow); this PR does not reflow it.

Product invariants affected

none

How it was verified

Not exercised as a live device recording session. Production construction is unchanged: main.dart still calls CaptureProvider(...) directly, and no-argument defaults remain.

Commands run:

  • python3 scripts/check_spine_contracts.py — 47 pending markers; 17 protected files. Diff of app/test/spine/c1_composition_test.dart is only the two pendingContract('C1'); lines removed from the FLUTTER_TEST-refuse and construct-with-every-seam tests. ABA codec and keepalive markers stay (those need CaptureSessionOwner generation / join; runContract swallows their failures while pending).
  • python3 scripts/check_mobile_boundaries.py --config app/contracts/capture/boundary-baseline.json — 63 changed paths; 0 errors.
  • TZ=UTC flutter test test/spine/c1_composition_test.dart test/services/capture/capture_composition_test.dart — 7 passed.
  • TZ=UTC bash app/test.sh — exit 0 (1020+ tests).
  • make mobile-verify ARGS="fast --paths app/lib/services/capture/capture_controller.dart app/lib/providers/capture_provider.dart" — executed 20, passed 20, failed 0. capture_provider.dart is outside the capture-wal path rule so the selector used the full-suite fallback; j5_capture_interruption_reconnect ran and passed.
  • OMI_PR_BODY_FILE=.local/pr-body-c1-composition.md make preflight — 21 checks passed in 274.56s.

capture_controller.dart touched line ranges (working-tree, no format reflow):

  • 90–91: _bleListeners / _openSocketOverride fields
  • 160–162: customSttBufferingDuration delegates to extracted helpers
  • 220–222: constructor params preferences / bleListeners / openSocket
  • 238–239: initializer stores those overrides
  • 241: mute restore reads injected preferences (default still SharedPreferencesUtil())
  • 245–247: BLE add via injected listeners or BleBridge.instance
  • 804–823: openConversationSocket uses _openSocketOverride else ServiceManager (production still passes geolocation)
  • 1594–1596: BLE remove via injected listeners or BleBridge.instance

CaptureConnectivityBoundary.production() remains the no-argument connectivity default (line 234). _startAndroidLocationForegroundTask stays.

Tests

Spine app/test/spine/c1_composition_test.dart (markers retired, not re-edited): production composer refuses under FLUTTER_TEST before resolving defaults; composeCaptureProvider constructs with every seam and no initialized globals.

Builder regressions in app/test/services/capture/capture_composition_test.dart:

  • composeCaptureProvider source-routes wal/mic/auth/clock/scheduling/connectivity/prefs/ble/socket, and CaptureProvider has matching super. params (the helper existed in cut 1 and was not forwarded)
  • injected CaptureConnectivityBoundary(isConnected: false) is what the constructed provider uses — not ConnectivityService
  • composeProductionCaptureProvider throws UnsupportedError containing FLUTTER_TEST, and its source contains neither ConnectivityService, .production(), nor https://api.omi.me/v1/health

Not migrated: the ~90 existing test constructions that still use no-argument defaults.

Failure class (fixes)

No fix: commits. This is a harden: composition cut with production defaults kept.

Failure-Class: none


Part of the mobile self-driving program (App core lane, C1 step 2). Stacked on #14361, which is stacked on #14327. Implemented by Cursor Grok 4.6 against tests written by Codex. Coordinator: owner/device-lookup are on the aggregate but not forwarded yet; ABA and keepalive spine tests stay pending until generation/join land.


Part of the mobile self-driving program (App core lane, second C1 PR). Stacked on #14361. Implemented by Cursor cursor-grok-4.6-high against tests written by Codex gpt-6-astra. Coordinator verification on the head: the only edits to protected spine tests are two pending-marker removals (spine check passes, 47 pending); the composition spine test and the 5 builder tests pass (7 total). I read the capture_controller.dart diff: production defaults are all retained (preferences ?? SharedPreferencesUtil(), the BleBridge.instance listener fallback, the ServiceManager socket fallback), so behavior is unchanged when nothing is injected; the file stays at 2,710 lines. Two explanatory comments were dropped to hold the line count (why a persisted device mute is restored; why the custom-STT polling socket surfaces buffering state); they will be restored in the next step rather than lost.

🤖 Generated with Claude Code

Review in cubic

Git-on-my-level and others added 3 commits September 17, 2026 23:34
composeCaptureProvider now passes WAL, mic, auth, clock, scheduling,
connectivity, preferences, BLE, and socket through CaptureProvider into
CaptureController. Production no-argument defaults stay;
composeProductionCaptureProvider refuses FLUTTER_TEST before any singleton.

Co-authored-by: Cursor <[email protected]>
…_TEST

Builder tests lock the cut-1 lazy passes: openSocket/WAL/mic must actually
be forwarded, and the production composer cannot construct ConnectivityService
with the health URL under test. Retires only the two composition spine
markers this cut satisfies.

Co-authored-by: Cursor <[email protected]>
Formatting only; required by the pre-push dart format gate.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Architect conformance review: conforms, with required changes

Reviewed at c4e02b14879c5dc3f87bbed49610f539a2c52c8d. The two retired markers legitimately
cover test-mode production refusal and isolated construction with BLE/connectivity teardown.
Keeping the defaults, and leaving owner and device lookup to later cuts, matches the agreed
sequence — this cut is not expected to be whole-C1 adoption.

Required change: app/lib/services/capture/capture_controller.dart:241 uses the injected
preferences once and then discards them
; :409 and later accesses still read the global
singleton. So the named explicit path is not actually an isolated preference seam after
construction. Store the supplied preferences and route those reads and writes through them,
retaining the default for ordinary construction during the migration. The new protected
c1_composition_review_test.dart (pending on #14327) asks the real composed provider to read
a changing injected batchMuted without initializing global preferences.

Scope note, not a defect in this PR: the architect's own socket seam omits geolocation while
the old production call includes it (capture_controller.dart:801–821). That does not change
the current default production path in this cut, but the explicit path must preserve it
before production cutover — carry it with the existing location/socket migration and its
real-provider test.

Two honesty notes from the review, worth reading before you respond:

  • This finding is source-verified only. Unlike the lifetime review, the architect did not run
    this whole branch or construct its default controller.
  • Do not infer data parity from the added source-string forwarding assertions; those are
    static tripwires, not behavioral coverage.
  • No null-fallback bug is claimed for Future<Socket?>: a non-null future resolving to null
    does not evaluate the fallback expression.

Store the supplied SharedPreferencesUtil and route later reads and writes through it so batchMuted and the rest of the seam are not the global singleton, while ordinary construction still defaults.

Co-authored-by: Cursor <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Architect conformance review, round 2: conforms

Reviewed at f1bac3b9951e78acbcbc914e374a244037e84454. No required changes. This is the first
builder PR in the capture stack to pass clean.

The required preference fix is present and behavioral, not cosmetic: _preferences is retained
at capture_controller.dart:92 and :241, and subsequent accesses including offlineMuted at
:411 go through it. All four composition tests pass, and the review distinguishes them
honestly — one is explicitly a static forwarding tripwire, while the changing-preference
assertion executes the real composed provider with injected connectivity and preferences.

Two things the review confirms are allowed rather than overlooked: keeping production defaults
during the staged migration is the agreed sequence, so this is not final default-removal or
global-ownership acceptance; and geolocation belongs to the next cut, which is where it landed
(#14394).

It also records, so nobody mistakes it for a defect here, that this PR sits on an older
CaptureLifetime parent — a coordinator-managed merge-forward, not a conformance problem in
this PR. And it confirms that writing equivalent implementation-side tests, rather than reaching
into spine files that are not on this branch, was the correct choice; no spine-file edit is
requested.

🤖 Generated with Claude Code

@Git-on-my-level
Git-on-my-level deleted the branch task/msd-core-c1-lifetime September 18, 2026 08:07
@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!

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Auto-closed when base branch was deleted after its parent squash-merged. Head unchanged at 53d9c8b13; continued as #14529 targeting main.

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