Skip to content

C1 step 6: cut the production capture path over to the session owner - #14583

Merged
Git-on-my-level merged 64 commits into
mainfrom
task/msd-core-c1-production-cutover
Sep 18, 2026
Merged

Git-on-my-level merged 64 commits into
mainfrom
task/msd-core-c1-production-cutover

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What changed and why

C1 step 6, and the step that makes the previous five ship anything: the production capture
path now goes through the session owner.
Both main.dart arms construct capture through
composeProductionCaptureProvider, which builds a CaptureSessionOwner and passes it to
CaptureProvider. Until this commit every generation fence C1 built — connect coalescing,
codec fetch, keep-alive, location upload, the coordinator wake, the foreground-service intent,
the recovery wake — guarded a path production never took. Green tests on provider-gated code are
not the same as the code engaging.

The site count in the earlier PR bodies was wrong, and this corrects it. The "~90
construction sites" figure came from a naive CaptureProvider( substring scan, which also
matches composeCaptureProvider(, composeProductionCaptureProvider( and _TestCaptureProvider().
Counting word-boundary constructor calls instead:

Bucket Real sites
Shipped production 2 (main.dart create, and the update-null fallback)
Composition helpers 2
Constructor definition 1
Tests 89
Subclass / fake fixtures 5

So the shipped cutover is two call sites, not ninety. OWNERSHIP.md is corrected in the second
commit.

Why CaptureProvider() stays ownerless. Defaulting the owner on the bare constructor would
have been the half-cutover — two lifetimes in one process. It would also break the live
FGS-intent and singleton-escape contracts, because a default owner resolving
RecordingTransferCoordinator.instance and ForegroundUtil would start a foreground service
from streamRecording inside a widget test. The ownerless constructor is the test seam and it
stays.

Product invariants affected

INV-DATA-1

Cited on path: app/lib/main.dart matches the invariant's glob. Routing, Firebase configuration
and every network destination are untouched by this change — it swaps which object constructs
the capture provider, not where anything is sent. make preflight with the ID cited passes
22 of 22, including production-data-plane-routing.

How it was verified

Engagement is the two call sites, and the dead-code ratchet is a consequence rather than the
proof.
An earlier draft of this body claimed the ratchet "confirms the shipped binary now
reaches this code." The CI lane's adversarial review showed that is an overclaim, by reading the
checker: .github/scripts/check_dead_code.py's scan_flutter walks import / export / part
and does not care whether composeProductionCaptureProvider is ever called. Deleting the two
allowlist rows would have gone green on an unused import alone, with both main.dart arms still
saying CaptureProvider(...). Reachable is not executed.

What actually proves engagement here is that main.dart contains two live calls to the
composer, and the new source test asserts that count. The review counted them independently. The
allowlist deletion — capture_composition.dart and capture_session_owner.dart were annotated
"intentionally unreachable until App core implements composition; Remove on wiring" — is a true
consequence of the wiring, and it is worth recording, but it is not the evidence.
capture_lifetime.dart remains allowlisted as unreachable, which is honest: it is not yet wired.

TZ=UTC bash app/test.sh → 2173 passed (2172 before, +1 wiring test).
python3 scripts/check_spine_contracts.py → exit 0, 42 pending / 23 protected — unchanged, and
the three remaining C1 markers (adoption singleton ×2, keep-alive) are untouched.
make preflight → 22 of 22 with INV-DATA-1 cited, 74.30s.
dart format --line-length 120 --set-exit-if-changed over the 41 changed Dart files → exit 0.
app/AGENTS.md → 11227 bytes, unchanged.

No simulator, device, or production host was involved.

A contract gap this exposed, reported rather than papered over

No C1 spine contract has ever constructed the production owner. Every behavioral fence
builds through composeCaptureProvider with an injected owner. The one live contract that
touches the production function — C1 production composition refuses flutter test before resolving defaults — asserts only that it throws, and it cannot do more, because
OWNERSHIP.md requires the FLUTTER_TEST refusal to come first. That refusal is the seam
working as designed, but it means the production composition path is asserted by nothing.

Independently confirmed by review, with a recommendation not to hold this PR for it. The
only spine test naming the production composer catches its UnsupportedError and stops; the
refusal is the function's first statement, so the test cannot construct the production owner. The
non-spine capture_composition_test.dart source-scrapes the composer body, which is a tripwire on
text rather than execution. So the production composer is asserted only by a throw and a source
scrape, and that is the honest state of it.

The reviewer's judgement, which I accept: do not hold the cutover for this. CaptureSessionOwner's
constructor starts no work and RecordingTransferCoordinator.instance is a static final noop
singleton, so the first frame will not throw; closing the gap needs a non-FLUTTER_TEST lane, or
a seam letting tests construct the owner without resolving the foreground-service and coordinator
production defaults — and OWNERSHIP.md forbids mixing that into this PR. Holding would keep
every C1 fence off the shipped path for another night. The gap is recorded, not closed.

One loose end the review found, not fixed here: the getter comment still reads "Null on the
default production constructor", which is no longer true now that production uses the composer.

Failure class (fixes)

Failure-Class: none

🤖 Generated with Claude Code

Review in cubic

Git-on-my-level and others added 30 commits September 17, 2026 13:42
Add strict Python/Dart pending contracts and introducing-commit protection.
Reserve the live-session CLI, wire, ownership/attachment seams and failing
builder acceptance tests. Add live attribution before freezing evidence v1.

Verification:
- bash scripts/dev-harness/run-tests.sh: 287 passed, 7 existing skips,
  40 strict xfailed (24 pending V1 markers), Python 3.11.15.
- make preflight: 16 checks passed, using supported PYTHON selection.
- make mobile-verify fast --paths harness/session contract inputs with an
  absolute evidence directory: 20 executed, 20 passed, no failures/skips.
- bash app/test.sh: 2014 passed, 5 skipped, one unchanged UTC+7
  search_rank_grouping_test failure; affected baseline inputs match main.
- Real module CLI refusals exit 2 without traceback; regression covered.
- Dart SDK probe proves ext. prefix required; marker-removal formatter
  probe proves no incidental Dart diff.

Runtime is intentionally unimplemented. App UI must repair current invalid
VM extension names before live acceptance; unsupported journeys block.
Simulator/emulator latency and detached-process acceptance remain V1 work.
make setup installed hooks but full backend wheel sync stalled; isolated
Python 3.11 harness dependencies ran the owner checks without any skip flag.

Failure-Class: none
The check protects files under the spine roots and their registry, so it only
needs to run when those change. A repo-wide trigger would run it, and its
full-history requirement, on every unrelated contributor PR.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
V1 must refuse live journey execution until a shared executable adapter exists;
B1 addressability alone cannot attach Dart integration tests. Pure admission
contracts remain valid with injected supported IDs.

Verification: harness 287 passed, 7 skipped, 40 strict xfailed;
make preflight passed 20 checks.
C1 pending contracts specify recovery, foreground service, socket and session ownership; no existing runtime path changed. Verified UTC app suite (2041 passed), harness (287 passed, 7 skipped, 40 strict xfailed), 20 hermetic journeys, and 21 preflight checks.
Specify inventory revision coalescing without losing explicit retries, late location-upload/finalization fences, and zero legacy actor adoption checks. Existing protected tests are unchanged. UTC app: 2048 passed; harness: 287 passed, 7 skipped, 40 strict xfailed; preflight: 21 passed. Correction to earlier verification record: C1 selected 3 journeys, all passed, not 20. One intermediate unchanged baseline replay test returned zero restored WALs; the full final run passed and its exact failure is retained in .local/c1-app-final.log.
…lities

Coordinator turn-4 review authorizes the V1 fixture correction. Exact before/after digests pin the revised oracle; immutable revision records do not permit builder assertion edits. Active tests reject missing/tampered records and prove the fake machine response. Verification: full harness 289 passed, 7 skipped, 40 strict xfailed; UTC app 2020 passed; spine 24 pending/7 protected; make preflight 16 passed. No live device acceptance claimed.
Track retained marker occurrences rather than counts so retiring a second test cannot restore the first test's retired marker. The active regression covers this swap and legitimate continued retirement. Verification: full harness 290 passed, 7 skipped, 40 strict xfailed; spine 24 pending/7 protected; make preflight 16 passed. Dart sources unchanged after the earlier UTC app 2020-pass run.
…rges

A squash can introduce a corrected contract and its review records in the same commit. Absorb only the revision prefix ending at that introducing file's exact digest, preserving immutable records and later marker-only edits. Active temp-repo regression covers multiple corrections in one squash and rejects restoring old or altered assertions. Verification: harness 291 passed, 7 skipped, 40 strict xfailed; B1 make preflight 20 passed; final B1 journeys 20/20. Dart unchanged after UTC app 41 opt-in and 2051 ordinary passed.
Needed so capture-replay WAL reconstruction tests pass; main carries the
await-WAL-timer-Futures-before-settle fix.
Timers, streams, and owned cancels drain on close even when one
cancel fails. Close is idempotent and invalidates first, so a late
acquisition after close dies immediately.

Co-authored-by: Cursor <[email protected]>
A day-long capture session would pin one dead cancel closure per
once()/listen() that completed on its own. Release on fire, caller
cancel, and stream done so the bag only holds live work.

Co-authored-by: Cursor <[email protected]>
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]>
…ookkeeping

A second close() while the first is still draining must wait for the same completion, asFuture must untrack even after it replaces inner callbacks, and replacement data/error/done handlers must not run after close begins.

Co-authored-by: Cursor <[email protected]>
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]>
Keep-alive during an in-flight connect now joins one socket attempt, and
work started under generation N cannot publish after N+1. The explicit
conversation-open path forwards session geolocation the way production
already does, without changing default CaptureProvider() wiring.

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

Untracking a callback is not the same as teardown completing; close now waits
for in-flight own/subscription cancels without running them a second time.

Co-authored-by: Cursor <[email protected]>
Git-on-my-level and others added 22 commits September 18, 2026 07:41
Conflict resolution dropped trailing commas while keeping a split layout the formatter will not emit. Let dart format rewrite those 14 files; no semantic change.

Co-authored-by: Cursor <[email protected]>
Both main.dart construction arms now go through composeProductionCaptureProvider,
so C1 fences sit on the path the shipped app actually takes.

Co-authored-by: Cursor <[email protected]>
…HIP.md

The remaining test/fixture constructor is the obstacle, not a 122-site count
from substring matches against composeCaptureProvider.

Co-authored-by: Cursor <[email protected]>
#14327 landed the C1 contract on main, so its files collide add/add with this
builder branch. Resolution, per file:

- app/test/spine/c1_lifetime_test.dart, c1_lifetime_drain_test.dart: kept this
  branch's copies. They differ from main only by the removal of four
  pendingContract('C1') lines, which is the one edit a builder may make there.
  Taking main's would restore retired markers, which the mechanism forbids.
- app/lib/services/capture/capture_lifetime.dart: kept this branch's copy. Main
  carries the 25-line contract skeleton; this is the 244-line implementation of
  it.
- contracts/spine/files.json: took main's. Main has 27 entries and this branch
  20, with zero entries unique to the branch, so main is a strict superset and
  taking ours would have dropped seven registry entries #14327 just landed.
- .github/checks-manifest.yaml: took main's. Identical 225 check ids on both
  sides; the only difference was two blank lines.

Verified after resolution: spine checker exit 0 at 74 pending markers and 27
protected files, formatter 0 changed, app/AGENTS.md 11227 of 11411.

Co-Authored-By: Claude Opus 5 <[email protected]>
#14327 landed c1_lifetime_review_test.dart and c1_lifetime_terminal_test.dart
on main with pendingContract('C1') still set. The behaviour they pin was
already implemented on this branch by f04ec71 and acdc197, so after the
merge-forward all five executed green and the contract harness failed them as
XPASS ("remove the pending marker") rather than as unmet contracts. No
implementation change is required, and none is made here; only the five stale
markers are removed, which is the one edit the spine protection allows.

What each contract pins, and the capture_lifetime.dart behaviour that
satisfies it:

- concurrent close joins outstanding cancellation: a second close() used to
  hand back a fresh completed future and report teardown finished while the
  first drain was still awaiting an own() cancel. close() now short-circuits
  only on _closeFinished and otherwise returns the memoised _closing future,
  so every caller joins the same drain.
- asFuture preserves completion untracking: _inner.asFuture replaces the
  subscription's done handler, so the listen-time drop() never ran and the
  registration outlived its future. _LifetimeSubscription.asFuture now chains
  whenComplete(_drop).
- C1 asFuture error completion releases its registration: the same path on the
  error completion - whenComplete(_drop) untracks on throw as well as on done.
- replaced callbacks and errors stay closed while cancellation drains: a
  handler installed through onData/onError after listen bypassed the closed
  guard and could still fire while close() was blocked on an earlier release.
  Those wrappers now consult _isClosed() before forwarding.
- C1 original and replacement done callbacks respect closing: both the
  listen-time onDone wrapper and an onDone replacement now drop() the
  registration but return without calling the owner once _closed is set.

Verified in this worktree at app/: flutter test 2161 passed, 0 failed.
scripts/check_spine_contracts.py exit 0, 69 pending markers (was 74),
27 protected files.

Co-Authored-By: Claude Opus 5 <[email protected]>
…ket-generation

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

# Conflicts:
#	app/test/spine/c1_persistence_fingerprint_test.dart
#	app/test/spine/c1_socket_drain_test.dart
#	app/test/spine/c1_stop_generation_test.dart
The merge commit's dart format rewrapped c1_lifetime_review_test.dart.
Spine originals may only drop pending markers, so restore the lifetime
bytes.

Co-authored-by: Cursor <[email protected]>
pre-commit dart format rewrapped this protected original. Restore the
lifetime bytes; spine allows pending-marker removal only.

Co-authored-by: Cursor <[email protected]>
composeCaptureProvider is the seam; the provider import is leftover.

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

These entered at this commit's parent merge. The merge resolution needed
OMI_SKIP_DART_FORMAT=1 so the pre-commit hook could not rewrite a digest-pinned
spine oracle (c1_lifetime_review_test.dart) — but that skip is all-or-nothing, so
it also left analytics_manager.dart and omi_double_tap_goldens_test.dart
unformatted, and they rode up the rest of the C1 chain.

Formatter only, no semantic change. origin/main formats both paths with 0
changed, so this is the merge-collateral class, not new content.

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

Copy link
Copy Markdown
Member Author

Merge-forward complete. The real CaptureSessionOwner (coordinator-backed, Android-gated FGS start, both-platform stop) is constructed in composeProductionCaptureProvider in capture_composition.dart — called from both main.dart ChangeNotifierProxyProvider4 arms — replacing the UnimplementedError stub. Everything else (lifetime, seams, stt-mode resolver, controller machinery) matches main wholesale; spine untouched. Tests: capture + provider suites 132 passed. Audit: diff vs main is exactly this PR's 5 owned files. New head: f88814449d. No ratchet exception needed.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Capture-path cutover consistent with C1 series and no abuse signal; held at approve-only per standing Git-on-my-level flag (never merged), DIRTY needs manual rebase.

@Git-on-my-level
Git-on-my-level merged commit d62f115 into main Sep 18, 2026
39 checks passed
@Git-on-my-level
Git-on-my-level deleted the task/msd-core-c1-production-cutover branch September 18, 2026 14:52
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Chain 1 (C1 capture ownership) is complete. With #14589 (keepalive on transcription readiness) merged after this cutover, the entire capture-ownership stack — CaptureLifetime, composition seams, disposal routing, socket generation, FGS/recovery-wake fences, the production cutover, and readiness-based keepalive — is live on the path the app takes. Production capture is no longer running with a null owner.

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.

2 participants