Skip to content

harden(app): capture ownership and seams contract (C1) - #14327

Merged
Git-on-my-level merged 31 commits into
mainfrom
task/msd-spine-a-seams
Sep 18, 2026
Merged

Git-on-my-level merged 31 commits into
mainfrom
task/msd-spine-a-seams

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

Revise C1's ownership and rollout contract from the consuming App core review. Capture wraps the existing configured coordinator; C2 owns the remaining wake migration and App UI owns Home FGS. Cutover explicitly replaces both main.dart constructor arms after existing tests migrate. Remove AnalyticsManager from the aggregate, narrow BLE to listener operations, and require autonomous keepalive reconnect through the real provider. No hot file or runtime behavior is changed.

The reported compile failure is incorrect: pinned Dart accepts noSuchMethod interface fakes. Both cited files analyzed cleanly before revision; a deliberately invalid pending contract exits 1 during loading. Keep explicit preferences/store types because capture uses dozens of preferences beyond mute; strict fakes reject unexpected calls. The pending wrapper already only accepts assertions and UnimplementedError.

Product invariants affected

none

How it was verified

UTC full app suite: 2043 passed (.local/t5-c1-app-final.log). Harness: 291 passed, 7 skipped, 44 strict xfailed. Spine: 51 pending / 17 protected. Fast capture journey: 3 executed / 3 passed (.local/t5-c1-journeys/verify-receipt.json). Preflight: .local/t5-c1-preflight-final.log. Initial edit accidentally removed two closing parentheses; the full suite correctly rejected that compile/load failure. Repaired, all C1 files analyzed cleanly and the full suite reran green; no pending marker hid it. New boundary tests pass. Actual commit 0768ab4 replay passes with device_provider singleton reads growing 43 to 48, because that file is not adopted (.local/t5-c1-real-commit-replay.log). Adopted regression and new-file debt remain red. No simulator, production host, default-controller probe or implemented capture ownership is claimed.

Final delivery: make preflight passed 21 checks after merge and contributor-doc updates; .local/t5-c1-preflight-final-docs.log. Complete command/result index: .local/t5-verification.md.

Tests

Reviewed spine records pin scope corrections and keepalive positive control; one generation primitive test replaces seven duplicate labels, while distinct production-path tests remain. Both original and revised composition files compile. Ratchet applies only explicit adopted file/rule pairs and new files; inventory does not imply adoption. Tests cover legacy growth, adopted regression, new files and actionable diagnostics.

Failure class (fixes)

Failure-Class: none

Review risks:

  1. Existing SyncProvider configuration must target the exact coordinator injected into capture until C2 closes the global ownership loop.
  2. Production constructor migration spans roughly 90 test call sites; final safety closure depends on the atomic last cut.
  3. Lexical scans cannot prove transitive ownership; capture_* extractions and real-provider races must be reviewed together. Existing STT policy/cache adapters keep their own migration scope.

Part of the mobile self-driving program (Spine A). Designed by Codex gpt-6-astra; revised after a buildability review by the lane that will build on it.

🤖 Generated with Claude Code


Update 2026-09-18 — contract revision after the first builder reviews

Strengthen capture contracts against the first implementations: concurrent disposal must join, completed subscriptions must untrack through asFuture, and replacement/error callbacks must stop when closing begins. The real composed provider must retain its injected preferences after construction.

Scope this PR inherited when its parent merged

Its parent (#14310, the pending-contract mechanism and the V1 live-session contract)
squash-merged, so that branch's PR is closed while the architect's later work on the same
stack continued. Three things therefore ride on this PR rather than on their own:

Coordinator verification of the mechanism, independent of the architect: with the branch
checked out, commenting out one pendingContract( marker in a protected file is rejected
(only pending-marker removal allowed plus retired markers cannot be restored, exit 1),
and adding a contracts/spine/revisions/099-*.json that authorizes that same edit is
rejected as an invalid spine revision record (exit 1). Clean tree exits 0 at 68 pending
markers and 22 protected files, matching the architect's report. test_spine_mechanism.py
is 9 passed.

How the revision was verified

Five adversarial tests against the exact lifetime implementation all failed for the reported reasons (.local/t7-lifetime-reproduction-v2.log and .local/t7-c1-terminal-reproduction.log). Composition preference loss was source-verified. Final TZ=UTC bash app/test.sh: 2093 passed; full harness: 311 passed, 7 skipped, 59 strict xfailed; spine: 68 pending, 22 protected; make preflight: 21 passed. Final logs .local/t7-c1-app-delivery.log, .local/t7-c1-integrated-harness.log, .local/t7-c1-spine-delivery.log and .local/t7-c1-integrated-preflight-final.log. Actual integration of the coordinator's older-parent squash is covered; the pinned-correction scope regression is fixed on V1 and merged here. No default CaptureController, devices, or production connections.

Tests

New protected c1_lifetime_review_test.dart, c1_lifetime_terminal_test.dart and c1_composition_review_test.dart remain pending; lifetime skeleton adds only matching signatures. Existing oracle assertions and implementation behavior remain unchanged.

Git-on-my-level and others added 17 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.
Use the actual PR base and immutable exact scaffolding snapshots to reject mixed revision/implementation diffs. Exercise a real squash and child merge. Correct local_dev wire spelling from the simulator RPC and add adversarial V1 conformance oracles after reviewing the first broker.

Verification: UTC app 2064 passed; full harness 303 passed, 7 skipped, 55 strict xfailed; spine 37 pending/9 protected; preflight 16 checks passed. Isolated reviewed-broker probes failed 9/9 as documented in the conformance report. No real app/device launch.
# Conflicts:
#	.github/checks-manifest.yaml
#	contracts/spine/files.json
…ge orders

Keep exact oracle digests and immutable revision records. Traverse full reachable history and match revision payloads by digest. Shared runner metadata requires direct fail-fast suite invocation instead of pinning shared file bytes. Both new regressions fail on the old checker. UTC app 2064 passed; final harness 306 passed, 7 skipped, 59 strict xfailed; spine 39 pending/10 protected; preflight 16 passed. No protected oracle bytes or legacy scope pins changed.
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review September 17, 2026 20:14
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Marked ready — the mechanism defect that blocked this is fixed and verified

Pushed at c840d90a68. Hygiene is green in real CI on this SHA, which is the check that
was failing, and there are zero failures across the run.

What changed: this PR's spine-contracts check was failing only on GitHub's pull_request
merge ref, because actions/checkout builds that ref with the base as first parent and the
check followed first-parent history to resolve a pinned revision. The same mechanism separately
blocked #14315 by hash-pinning app/test.sh, which an unrelated PR had legitimately changed.
One root cause: the mechanism pinned bytes and history of files the spine does not own.

The fix declares app/test.sh's required invocations in contracts/spine/runners.json
instead of hashing it, and resolves revisions across all reachable history rather than
first-parent. The script can now be edited freely and the check fails only if it stops running
the spine suites with the required flags.

Coordinator verification, independent of the architect and run on all four contract branches:
the check gives exit 0 on the branch head, on a branch-first merge, and on a base-first
merge
— identical verdicts, so parent order no longer changes the answer. Then the adversarial
case was re-run, because a guard that stops false-failing by checking less is not a fix: a clean
tree passes at 68 pending markers and 22 protected files, commenting out one pendingContract(
marker is still rejected (only pending-marker removal allowed, retired markers cannot be restored), and a self-authored contracts/spine/revisions/099-*.json authorizing that same
edit is still rejected as an invalid spine revision record. test_spine_mechanism.py passes.

Also on this PR, and disclosed in its body: because #14310 squash-merged, the architect's later
work on that stack has no PR of its own, so the revision-mechanism fix, the V1 conformance
oracle and the three C1 review oracles all ride here.

Merging this unblocks four builder PRs — #14361, #14367, #14375 and #14394 — which have had
no CI at all, since a stacked PR runs nothing until its parent merges. Note that #14361 and
#14367 carry required changes from the architect's conformance review, and those fixes are now
pushed.

🤖 Generated with Claude Code

Keep assertion and stub failures as strict expected failures in both languages. Pending green establishes an unmet executed contract, not correctness of its oracle. Compile/load and unexpected runtime errors still fail.

Verified: UTC app suite 2099 passed; harness 313 passed, 7 skipped, 65 strict xfailed; spine check 78 pending / 27 protected; make preflight 21 passed.
Add six V1 cases for lease rolls during readiness, malformed readiness, cached readiness after negotiation errors, and authorization-header leakage. Add six C1 cases for explicit cancellation drains, socket publication/drain races, synchronous stop invalidation and generation-scoped persistence fingerprints.

Existing protected files and markers remain untouched. Expose only the builder-existing CaptureOwned.release skeleton signature.

Verified: UTC app suite 2099 passed; harness 313 passed, 7 skipped, 65 strict xfailed; spine 78 pending / 27 protected; Dart analysis clean; make preflight 21 passed. All twelve new cases reject the pinned builder implementations in ignored probes. Review and commands: .local/conformance-review-t10.md, .local/t10-verification.md.
@mintlify

mintlify Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
omi 🟢 Ready View Preview Sep 17, 2026, 11:04 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

Preserve C1 oracles and pending semantics; adopt main's authorized revision mechanism and exact V1 renderings. UTC app suite: 2147 passed. Harness: 335 passed, 7 skipped, 65 strict xfailed.
@Git-on-my-level
Git-on-my-level merged commit f45685e into main Sep 18, 2026
38 checks passed
@Git-on-my-level
Git-on-my-level deleted the task/msd-spine-a-seams branch September 18, 2026 03:03
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
#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]>
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
#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]>
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
Three conflicts, all genuine unions rather than a side to pick:

- contracts/spine/files.json: main added 17 C1 oracle entries via #14327, this
  branch adds 3 C7 entries, and neither side's are on the other. Unioned to 30;
  both belong, since the C1 oracles are live on main and the C7 ones are this
  contract's own.
- .github/checks-manifest.yaml: unioned to 226 unique ids — this branch's
  mobile-event-registry plus main's capture-ownership-boundaries and
  mobile-boundary-check-tests.
- app/AGENTS.md: each side deliberately deleted one base line and added a
  pointer row. Honoured both deletions and both additions, which also happens to
  be the smallest result: 11271 of the 11411 budget.

Worth recording because it nearly went wrong: my resolver appended the two
main-only manifest blocks at end-of-file, which put them inside the trailing
'exempt:' key instead of 'checks:'. The ids were present as text and absent from
the parsed checks list, so two checks would have been silently dropped. Moved
them into the list and verified by parsing: 226 unique ids, all three named
checks present, 'exempt' intact.

Co-Authored-By: Claude Opus 5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
…listener is cancelled on dispose (#14361)

* harden(dev-harness): define V1 live-session and V8 spine contracts

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

* harden(dev-harness): scope the spine-contracts check to spine paths

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]>

* docs(dev-harness): clarify the live journey adapter boundary

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.

* harden(app): define capture ownership and seam contracts

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.

* harden(app): close capture adoption and late-completion contract gaps

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.

* harden(dev-harness): pin reviewed spine revisions and align B0 capabilities

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.

* harden(dev-harness): preserve marker retirement across spine revisions

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.

* harden(dev-harness): retain corrected spine oracles through squash merges

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.

* test(dev-harness): revise live session acceptance after builder review

* test(app): scope capture ownership adoption and exercise real effects

* test(dev-harness): bind machine fixture to actual child identity

* test(app): keep capture adoption scoped to ownership extractions

* docs: align capture contributor guidance with staged adoption

* harden(app): implement CaptureLifetime resource bag

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]>

* harden(app): untrack CaptureLifetime resources on fire and cancel

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]>

* harden(app): join in-flight CaptureLifetime close and keep terminal bookkeeping

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]>

* harden(app): join explicit CaptureLifetime cancellation until it finishes

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]>

* docs(app): record that CaptureLifetime close joins in-flight cancellation

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

* test(app): register the CaptureLifetime drain spine file

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

* chore(app): restore memories/page.dart to origin/main after merge format

The merge-forward pre-commit hook reindented main's file and tripped INV-MEM-1 on a formatter-only diff. Lifetime does not own that page.

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

* chore(app): restore dart format on merge-forward trailing-comma splits

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]>

* harden(app): retire the five satisfied C1 lifetime pending markers

#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]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Cursor <[email protected]>
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
…defaults kept) (#14529)

* harden(dev-harness): define V1 live-session and V8 spine contracts

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

* harden(dev-harness): scope the spine-contracts check to spine paths

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]>

* docs(dev-harness): clarify the live journey adapter boundary

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.

* harden(app): define capture ownership and seam contracts

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.

* harden(app): close capture adoption and late-completion contract gaps

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.

* harden(dev-harness): pin reviewed spine revisions and align B0 capabilities

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.

* harden(dev-harness): preserve marker retirement across spine revisions

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.

* harden(dev-harness): retain corrected spine oracles through squash merges

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.

* test(dev-harness): revise live session acceptance after builder review

* test(app): scope capture ownership adoption and exercise real effects

* test(dev-harness): bind machine fixture to actual child identity

* test(app): keep capture adoption scoped to ownership extractions

* docs: align capture contributor guidance with staged adoption

* harden(app): implement CaptureLifetime resource bag

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]>

* harden(app): untrack CaptureLifetime resources on fire and cancel

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]>

* harden(app): forward capture composition seams into CaptureProvider

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(app): prove capture composition routes seams and refuses FLUTTER_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]>

* style(app): apply dart format to capture_controller.dart

Formatting only; required by the pre-push dart format gate.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* harden(app): join in-flight CaptureLifetime close and keep terminal bookkeeping

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]>

* harden(app): keep injected capture preferences after construction

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]>

* harden(app): join explicit CaptureLifetime cancellation until it finishes

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]>

* docs(app): record that CaptureLifetime close joins in-flight cancellation

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

* test(app): register the CaptureLifetime drain spine file

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

* chore(app): restore memories/page.dart to origin/main after merge format

The merge-forward pre-commit hook reindented main's file and tripped INV-MEM-1 on a formatter-only diff. Lifetime does not own that page.

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

* chore(app): restore dart format on merge-forward trailing-comma splits

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]>

* harden(app): retire the five satisfied C1 lifetime pending markers

#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]>

* harden(app): retire the satisfied C1 composition pending marker

The 'C1 injected preferences remain authoritative after construction'
contract now passes against the merged base; CI 'Run analyzer ratchet'
flags its pendingContract marker as an XPASS. Drop the stale marker so
the contract asserts unconditionally again.

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Cursor <[email protected]>
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
…ureLifetime (#14549)

* harden(dev-harness): define V1 live-session and V8 spine contracts

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

* harden(dev-harness): scope the spine-contracts check to spine paths

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]>

* docs(dev-harness): clarify the live journey adapter boundary

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.

* harden(app): define capture ownership and seam contracts

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.

* harden(app): close capture adoption and late-completion contract gaps

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.

* harden(dev-harness): pin reviewed spine revisions and align B0 capabilities

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.

* harden(dev-harness): preserve marker retirement across spine revisions

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.

* harden(dev-harness): retain corrected spine oracles through squash merges

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.

* test(dev-harness): revise live session acceptance after builder review

* test(app): scope capture ownership adoption and exercise real effects

* test(dev-harness): bind machine fixture to actual child identity

* test(app): keep capture adoption scoped to ownership extractions

* docs: align capture contributor guidance with staged adoption

* harden(app): implement CaptureLifetime resource bag

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]>

* harden(app): untrack CaptureLifetime resources on fire and cancel

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]>

* harden(app): forward capture composition seams into CaptureProvider

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(app): prove capture composition routes seams and refuses FLUTTER_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]>

* style(app): apply dart format to capture_controller.dart

Formatting only; required by the pre-push dart format gate.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* harden(app): restore capture mute and custom-STT buffering comments

Those comments record why-knowledge this file breaks without: mute must
survive process death so streamDeviceRecording can re-apply it, and custom
STT buffering is surfaced so the UI shows offline instead of Listening.
Pay for the lines by extracting BleBridgeCaptureListeners.

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

* harden(app): route capture timers, streams and listeners through CaptureLifetime

Wrap the injected scheduler in CaptureLifetime so once/periodic, connectivity
listen, BLE finalized/stream subscriptions, and the live-segment listener
cancel on dispose. close() now drains every sync cancel before returning so
void dispose() stays synchronous. Extract image-chunk emission so the
controller shrinks.

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

* test(app): prove dispose cancels the leaked voice-command timeout

The only CaptureController timer that dispose did not cancel was the
15s voice-command timeout (the class of 05c43c0). After dispose,
advancing fake time leaves no pending timers. Also lock close() to
cancel every owned timer before the caller awaits.

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

* style(app): apply dart format to capture_controller.dart

Formatting only; required by the pre-push dart format gate.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* harden(app): join in-flight CaptureLifetime close and keep terminal bookkeeping

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]>

* harden(app): keep injected capture preferences after construction

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]>

* harden(app): join explicit CaptureLifetime cancellation until it finishes

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]>

* docs(app): record that CaptureLifetime close joins in-flight cancellation

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

* test(app): register the CaptureLifetime drain spine file

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

* chore(app): restore memories/page.dart to origin/main after merge format

The merge-forward pre-commit hook reindented main's file and tripped INV-MEM-1 on a formatter-only diff. Lifetime does not own that page.

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

* chore(app): restore dart format on merge-forward trailing-comma splits

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]>

* harden(app): retire the five satisfied C1 lifetime pending markers

#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]>

* fix(app): cancel the keep-alive periodic synchronously on dispose

dispose() previously only cancelled the keep-alive periodic through the
lifetime release, which runs behind the async drain. Tests that assert
the no-pending-timers invariant immediately after dispose() saw the 15s
periodic still pending. Cancel it synchronously in dispose() before
unawaited(lifetime.close()); the drain's release stays idempotent
(Timer.cancel on an already-cancelled timer is a no-op).

Captured in the chain-1 merge-forward: CI on 97a0282 failed
capture_provider_test 'shows reconnecting warning when socket closes
during phone mic recording' with the pending-timer assertion. Full
capture + provider suites green locally (118 passed).

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Cursor <[email protected]>
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
…#14550)

* harden(dev-harness): define V1 live-session and V8 spine contracts

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

* harden(dev-harness): scope the spine-contracts check to spine paths

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]>

* docs(dev-harness): clarify the live journey adapter boundary

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.

* harden(app): define capture ownership and seam contracts

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.

* harden(app): close capture adoption and late-completion contract gaps

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.

* harden(dev-harness): pin reviewed spine revisions and align B0 capabilities

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.

* harden(dev-harness): preserve marker retirement across spine revisions

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.

* harden(dev-harness): retain corrected spine oracles through squash merges

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.

* test(dev-harness): revise live session acceptance after builder review

* test(app): scope capture ownership adoption and exercise real effects

* test(dev-harness): bind machine fixture to actual child identity

* test(app): keep capture adoption scoped to ownership extractions

* docs: align capture contributor guidance with staged adoption

* harden(app): implement CaptureLifetime resource bag

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]>

* harden(app): untrack CaptureLifetime resources on fire and cancel

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]>

* harden(app): forward capture composition seams into CaptureProvider

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(app): prove capture composition routes seams and refuses FLUTTER_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]>

* style(app): apply dart format to capture_controller.dart

Formatting only; required by the pre-push dart format gate.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* harden(app): join in-flight CaptureLifetime close and keep terminal bookkeeping

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]>

* harden(app): keep injected capture preferences after construction

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]>

* harden(app): own capture connect/reconnect and session generation

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]>

* harden(app): join explicit CaptureLifetime cancellation until it finishes

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]>

* docs(app): record that CaptureLifetime close joins in-flight cancellation

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

* harden(app): fence capture publication to the admitted generation

Admission already captured generation; publication after every await now
keeps that original operation generation. Stop invalidates in-flight work
before WAL teardown, and a skipped persist cannot occupy the fingerprint.

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

* test(app): register the CaptureLifetime drain spine file

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

* test(app): register capture publication-fence spine files

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

* chore(app): restore memories/page.dart to origin/main after merge format

The merge-forward pre-commit hook reindented main's file and tripped INV-MEM-1 on a formatter-only diff. Lifetime does not own that page.

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

* chore(app): restore dart format on merge-forward trailing-comma splits

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]>

* harden(app): retire the five satisfied C1 lifetime pending markers

#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]>

* fix(app): restore spine original wrapping after merge format

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]>

* fix(app): keep c1_lifetime_review_test.dart at the spine original

pre-commit dart format rewrapped this protected original. Restore the
lifetime bytes; spine allows pending-marker removal only.

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

* fix(app): drop unused CaptureProvider import after composition merge

composeCaptureProvider is the seam; the provider import is leftover.

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

* style(app): format the two analytics files the socket merge left non-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]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Cursor <[email protected]>
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
…owner (#14575)

* harden(dev-harness): define V1 live-session and V8 spine contracts

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

* harden(dev-harness): scope the spine-contracts check to spine paths

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]>

* docs(dev-harness): clarify the live journey adapter boundary

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.

* harden(app): define capture ownership and seam contracts

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.

* harden(app): close capture adoption and late-completion contract gaps

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.

* harden(dev-harness): pin reviewed spine revisions and align B0 capabilities

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.

* harden(dev-harness): preserve marker retirement across spine revisions

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.

* harden(dev-harness): retain corrected spine oracles through squash merges

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.

* test(dev-harness): revise live session acceptance after builder review

* test(app): scope capture ownership adoption and exercise real effects

* test(dev-harness): bind machine fixture to actual child identity

* test(app): keep capture adoption scoped to ownership extractions

* docs: align capture contributor guidance with staged adoption

* harden(app): implement CaptureLifetime resource bag

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]>

* harden(app): untrack CaptureLifetime resources on fire and cancel

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]>

* harden(app): forward capture composition seams into CaptureProvider

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(app): prove capture composition routes seams and refuses FLUTTER_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]>

* style(app): apply dart format to capture_controller.dart

Formatting only; required by the pre-push dart format gate.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* harden(app): join in-flight CaptureLifetime close and keep terminal bookkeeping

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]>

* harden(app): keep injected capture preferences after construction

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]>

* harden(app): own capture connect/reconnect and session generation

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]>

* harden(app): join explicit CaptureLifetime cancellation until it finishes

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]>

* docs(app): record that CaptureLifetime close joins in-flight cancellation

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

* harden(app): fence capture publication to the admitted generation

Admission already captured generation; publication after every await now
keeps that original operation generation. Stop invalidates in-flight work
before WAL teardown, and a skipped persist cannot occupy the fingerprint.

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

* test(app): register the CaptureLifetime drain spine file

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

* test(app): register capture publication-fence spine files

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

* harden(app): fence FGS intent and recovery wakes at the session owner

A stop racing an in-flight start settles once; concurrent recovery
requests join one drain. Stale finalize cannot wake a later session.

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

* chore(app): restore memories/page.dart to origin/main after merge format

The merge-forward pre-commit hook reindented main's file and tripped INV-MEM-1 on a formatter-only diff. Lifetime does not own that page.

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

* chore(app): restore dart format on merge-forward trailing-comma splits

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]>

* harden(app): retire the five satisfied C1 lifetime pending markers

#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]>

* fix(app): restore spine original wrapping after merge format

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]>

* fix(app): keep c1_lifetime_review_test.dart at the spine original

pre-commit dart format rewrapped this protected original. Restore the
lifetime bytes; spine allows pending-marker removal only.

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

* fix(app): drop unused CaptureProvider import after composition merge

composeCaptureProvider is the seam; the provider import is leftover.

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

* style(app): format the two analytics files the socket merge left non-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]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Cursor <[email protected]>
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
…14583)

* harden(dev-harness): define V1 live-session and V8 spine contracts

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

* harden(dev-harness): scope the spine-contracts check to spine paths

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]>

* docs(dev-harness): clarify the live journey adapter boundary

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.

* harden(app): define capture ownership and seam contracts

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.

* harden(app): close capture adoption and late-completion contract gaps

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.

* harden(dev-harness): pin reviewed spine revisions and align B0 capabilities

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.

* harden(dev-harness): preserve marker retirement across spine revisions

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.

* harden(dev-harness): retain corrected spine oracles through squash merges

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.

* test(dev-harness): revise live session acceptance after builder review

* test(app): scope capture ownership adoption and exercise real effects

* test(dev-harness): bind machine fixture to actual child identity

* test(app): keep capture adoption scoped to ownership extractions

* docs: align capture contributor guidance with staged adoption

* harden(app): implement CaptureLifetime resource bag

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]>

* harden(app): untrack CaptureLifetime resources on fire and cancel

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]>

* harden(app): forward capture composition seams into CaptureProvider

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(app): prove capture composition routes seams and refuses FLUTTER_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]>

* style(app): apply dart format to capture_controller.dart

Formatting only; required by the pre-push dart format gate.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* harden(app): join in-flight CaptureLifetime close and keep terminal bookkeeping

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]>

* harden(app): keep injected capture preferences after construction

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]>

* harden(app): own capture connect/reconnect and session generation

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]>

* harden(app): join explicit CaptureLifetime cancellation until it finishes

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]>

* docs(app): record that CaptureLifetime close joins in-flight cancellation

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

* harden(app): fence capture publication to the admitted generation

Admission already captured generation; publication after every await now
keeps that original operation generation. Stop invalidates in-flight work
before WAL teardown, and a skipped persist cannot occupy the fingerprint.

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

* test(app): register the CaptureLifetime drain spine file

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

* test(app): register capture publication-fence spine files

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

* harden(app): fence FGS intent and recovery wakes at the session owner

A stop racing an in-flight start settles once; concurrent recovery
requests join one drain. Stale finalize cannot wake a later session.

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

* chore(app): restore memories/page.dart to origin/main after merge format

The merge-forward pre-commit hook reindented main's file and tripped INV-MEM-1 on a formatter-only diff. Lifetime does not own that page.

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

* chore(app): restore dart format on merge-forward trailing-comma splits

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]>

* harden(app): cut production capture over to the session owner

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]>

* docs(app): drop the inflated CaptureProvider() site count from OWNERSHIP.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]>

* harden(app): retire the five satisfied C1 lifetime pending markers

#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]>

* fix(app): restore spine original wrapping after merge format

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]>

* fix(app): keep c1_lifetime_review_test.dart at the spine original

pre-commit dart format rewrapped this protected original. Restore the
lifetime bytes; spine allows pending-marker removal only.

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

* fix(app): drop unused CaptureProvider import after composition merge

composeCaptureProvider is the seam; the provider import is leftover.

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

* style(app): format the two analytics files the socket merge left non-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]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Cursor <[email protected]>
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
…te (#14589)

* harden(dev-harness): define V1 live-session and V8 spine contracts

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

* harden(dev-harness): scope the spine-contracts check to spine paths

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]>

* docs(dev-harness): clarify the live journey adapter boundary

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.

* harden(app): define capture ownership and seam contracts

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.

* harden(app): close capture adoption and late-completion contract gaps

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.

* harden(dev-harness): pin reviewed spine revisions and align B0 capabilities

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.

* harden(dev-harness): preserve marker retirement across spine revisions

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.

* harden(dev-harness): retain corrected spine oracles through squash merges

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.

* test(dev-harness): revise live session acceptance after builder review

* test(app): scope capture ownership adoption and exercise real effects

* test(dev-harness): bind machine fixture to actual child identity

* test(app): keep capture adoption scoped to ownership extractions

* docs: align capture contributor guidance with staged adoption

* harden(app): implement CaptureLifetime resource bag

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]>

* harden(app): untrack CaptureLifetime resources on fire and cancel

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]>

* harden(app): forward capture composition seams into CaptureProvider

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(app): prove capture composition routes seams and refuses FLUTTER_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]>

* style(app): apply dart format to capture_controller.dart

Formatting only; required by the pre-push dart format gate.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* harden(app): join in-flight CaptureLifetime close and keep terminal bookkeeping

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]>

* harden(app): keep injected capture preferences after construction

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]>

* harden(app): own capture connect/reconnect and session generation

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]>

* harden(app): join explicit CaptureLifetime cancellation until it finishes

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]>

* docs(app): record that CaptureLifetime close joins in-flight cancellation

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

* harden(app): fence capture publication to the admitted generation

Admission already captured generation; publication after every await now
keeps that original operation generation. Stop invalidates in-flight work
before WAL teardown, and a skipped persist cannot occupy the fingerprint.

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

* test(app): register the CaptureLifetime drain spine file

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

* test(app): register capture publication-fence spine files

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

* harden(app): fence FGS intent and recovery wakes at the session owner

A stop racing an in-flight start settles once; concurrent recovery
requests join one drain. Stale finalize cannot wake a later session.

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

* chore(app): restore memories/page.dart to origin/main after merge format

The merge-forward pre-commit hook reindented main's file and tripped INV-MEM-1 on a formatter-only diff. Lifetime does not own that page.

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

* chore(app): restore dart format on merge-forward trailing-comma splits

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]>

* harden(app): cut production capture over to the session owner

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]>

* docs(app): drop the inflated CaptureProvider() site count from OWNERSHIP.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]>

* harden(app): reconnect keepalive when transcription is not ready

onClosed already clears readiness; keepalive was treating a still-connected
transport as healthy and cancelling, so a tick never reopened. Dispose now
closes the session owner so published sockets drain.

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

* harden(app): retire the five satisfied C1 lifetime pending markers

#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]>

* fix(app): restore spine original wrapping after merge format

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]>

* fix(app): keep c1_lifetime_review_test.dart at the spine original

pre-commit dart format rewrapped this protected original. Restore the
lifetime bytes; spine allows pending-marker removal only.

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

* fix(app): drop unused CaptureProvider import after composition merge

composeCaptureProvider is the seam; the provider import is leftover.

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

* style(app): format the two analytics files the socket merge left non-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]>

* chore(app): apply canonical dart format to merge-forward touched files

Follow-up formatting for the merge-forward: the previous merge commit's blobs were formatted by an older-style pass; this applies the pinned 3.44.5 formatter's canonical output to the 9 files the branch touches. No behavior change.

* test(app): retire the satisfied C1 keepalive-join pending marker

With the readiness-based keepalive trigger re-applied on the merged
base, the contract 'real provider joins keepalive reconnect and disposes
all newly scheduled timers' passes; its pendingContract('C1') marker is
stale and is removed (XPASS remedy).

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Cursor <[email protected]>
summersmile1984 added a commit to summersmile1984/omi that referenced this pull request Sep 26, 2026
Upstream's capture ratchet (scripts/check_mobile_boundaries.py) drifted
against its own code: C1 (BasedHardware#14327) recorded singleton-reads 2, then
BasedHardware#14529/BasedHardware#14549/BasedHardware#14550 grew app/lib/services/capture/capture_seams.dart to
4 without updating the record, so the check fails at upstream/main itself
for any diff touching the file. This restates already-merged upstream
code with the check's own designed remedy (baseline records reviewed
debt; only adopted keys and the frozen rules are immutable).

Known limitation, recorded deliberately: for this sync push the file does
not exist at merge-base(origin/main, HEAD), so the check limits new
files to zero regardless of baseline and stays red once; after the sync
lands on origin/main, previous=4 and baseline 4 makes the steady-state
run green (baseline 2 would stay red forever).

Registered as T1 in dev/unified-main/upstream-touch-allowlist.yaml with a
PROPOSED upstream PR to carry the same line.

Evidence: check_mobile_boundaries now reports only the structural
new-file error (unchanged); check-upstream-touch --aggregate exit 0 with
both allowlist entries within budget after this commit.

Failure-Class: none
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