Skip to content

perf(mobile): keep history-sized work off the UI isolate + INV-PERF-1 guard - #21517

Merged
Git-on-my-level merged 10 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/mobile-perf
Oct 14, 2026
Merged

Git-on-my-level merged 10 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/mobile-perf

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

What changed and why

The mobile app stutters intermittently: scrolling, page transitions and taps lag, mostly while recordings sync, during long recordings, and after reopening the app. An audit found that work which grows with the user's history ran on the UI isolate, and that root proxy-provider hooks re-notified on every upstream change. This PR fixes the largest causes. It also adds a guard (INV-PERF-1) and regression tests so the same shapes fail CI instead of coming back.

Performance fixes (app/lib)

  • WAL index save (utils/wal_file_manager.dart):
    • Before, every save read and jsonDecoded the whole old index just to validate it, then re-encoded the whole new index on the UI isolate.
    • Saves queued back-to-back now collapse into the newest snapshot. The final file is identical, because each caller passes a full snapshot and the last write wins either way.
    • When saves collapse, the newest replaced snapshot is written as the backup, which is what serial writes left. Otherwise the backup copy skips re-decoding when the file still matches what this process wrote (length + mtime), and validates as before.
    • Indexes of 200+ entries encode on a background isolate.
  • Notify cascades:
    • CaptureController.updateExternalActions no longer notifies when the adapter wraps the same four providers (ProviderCaptureExternalActions ==).
    • DeviceProvider.setProviders no longer notifies when its references are unchanged.
    • Previously, every chat token or conversation refresh re-notified Capture and then Device, and every transcript segment re-notified Device.
  • Live transcript mirror:
    • CaptureProvider._persistLiveSegments ran on every capture notify and built a string from the whole transcript each time. It now checks a cheap key first: list identity, length, segmentsPhotosVersion and owner token.
    • LocalSegmentStore hashes and encodes sessions of 150+ segments on a background isolate. The digest is unchanged, and a test pins that.
  • Resume path:
    • Conversation list bodies of 64 KB or more are parsed on a background isolate (parseConversationListBody).
    • The offline conversation cache is encoded in the background (SharedPreferencesUtil.cacheConversations), behind a generation guard. That guard is also bumped by clear(), so an in-flight write cannot restore a signed-out account's cache.
    • LocalRecordingsProvider.refresh lists the documents directory asynchronously instead of with listSync. When scans overlap, only the newest one rewrites the owners file (rechecked right before the rename) or publishes its results.
  • Lists and visuals:
    • The memories list filters once per build instead of once per row.
    • Voice dictation's 60 Hz tick drives a dedicated waveformTick instead of notifying the provider, so the whole chat composer no longer rebuilds 60 times a second.
  • New shared helper: utils/off_ui_isolate.dart. Work runs inline below a size threshold and in Isolate.run above it. Tests assert there is no silent fallback to the UI isolate (offUiIsolateFallbacks == 0).

Regression infrastructure

  • .github/scripts/check_mobile_ui_isolate.py, wired in checks-manifest.yaml as mobile-ui-isolate plus -tests. It has two parts:
    • A per-file no-increase ratchet (the INV-UI-3 shape) on: sync dart:io, JSON in providers, timers faster than 100 ms, blur, network images without a decode size, and shrinkWrap: true lists.
    • A history-json-on-ui rule: JSON in the WAL index, live transcript, conversation list and preferences modules must sit inside offUiIsolate, so removing the wrapper fails CI.
    • An absolute check that every proxy update hook named in app/lib/main.dart returns early on an identical/== test before notifyListeners(). A hook whose declaration the check cannot read also fails. ConversationDetailProvider.setProviders is allowed with a reason: the open detail page derives its conversation from upstream state.
  • product/invariants/mobile-ui-isolate.md (INV-PERF-1, proposed per PRODUCT.md's seven-day rule; the guard runs in CI regardless) and app/docs/performance.md. The doc covers the causes, the rules, the guards, and how to measure. It also lists the known remaining candidates: the chat sheet's persistent full-screen blur (a UX-contract D1 decision), SD-card sync refreshing the WAL list per chunk, and the batch buffer's once-per-second fsync.

Product invariants affected

  • INV-CAP-1: touches services/capture/capture_controller.dart (notify guard only) and local_segment_store.dart (where the hash/encode runs). Neither changes when the phone consumes pendant audio. The WAL index changes keep last-write-wins and the validated backup, so no WAL entry can be dropped from the index. Covered by the existing torn-write and recovery tests and the new save tests.
  • INV-MEM-1: capture_provider.dart matched by path. No memory tier behaviour changes.
  • INV-PERF-1: new invariant, introduced here as proposed.

How it was verified

All on macOS (Apple Silicon), Flutter 3.44.5 (the CI version), with hermetic inputs as in CI.

  • bash test.sh (full app suite, at the final commit): 5680 passed, 21 skipped, 0 failed

  • bash scripts/analyze_ratchet.sh: passed.

  • python3 .github/scripts/test_check_mobile_ui_isolate.py: 39 tests OK.

  • check_mobile_ui_isolate.py --changed-files … --base <merge-base>: OK, and --graph: OK.

  • check_mobile_ux_contract.py: OK.

  • Red proofs (new tests run against the unfixed code):

    • Repeated proxy updates notified 50 of 50 times (now 0).
    • 200 transcript-neutral capture notifies did 80,000 segment reads on a 400-segment transcript (now 0).
    • Back-to-back WAL saves did not coalesce.
    • A sign-out during a background cache write restored the old cache.
  • Host interaction harness (tool/perf_harness.sh, one run each on the same machine, so indicative only):

    Scenario p90 frame time, ms jank frames
    home 30.4 → 25.6 47 → 26
    detail 49.5 → 30.0 64 → 33
    memories 15.6 → 8.7 9 → 6
    chat 53.9 → 33.9 7 → 4

    Host timings are machine-dependent, and two of the harness's own budgets already fail on unmodified main on this machine. Rebuild counts vary a few percent between runs. That is why the harness is documented as a measurement tool and not wired as a CI gate.

  • Not verified: on-device frame timing (profile build plus DevTools during a real sync). The raster-bound chat blur was not changed.

Review follow-ups

  • Codex (3 comments, all fixed):
    • Collapsed saves now keep the superseded snapshot as the backup.
    • Braced if (…) { return; } guards are accepted.
    • Hooks without a readable declaration fail.
  • Cursor Grok (read-only review via agentctl, all fixed):
    • Closed the remaining recordings-scan race.
    • The guard now catches removed offUiIsolate wrappers and null-only guards.
    • Removed the ResizeImage false positive.
    • Strengthened the replaced-caller save test.
  • Codex rounds 2–3 (all fixed):
    • A guard must be the return's own identical/== condition on the injected values.
    • Comments that mention offUiIsolate( no longer exempt JSON calls.
    • A failing superseded-snapshot backup can't block the index write.
    • The transcript key is dropped when no capture session is active.
    • INV-PERF-1 is now proposed.

Tests

  • app/test/perf/notify_amplification_test.dart: proxy hooks don't re-notify, and capture notifies don't walk the transcript.
  • app/test/perf/conversation_list_off_ui_test.dart: off-isolate parse/encode parity, stale writes, and sign-out.
  • app/test/unit/wal_file_manager_save_cost_test.dart: coalescing, off-isolate encode, backup re-validation.
  • app/test/unit/voice_recorder_mic_contention_test.dart: the waveform ticks without provider notifies.
  • app/test/unit/local_segment_store_test.dart: off-isolate digest parity.

Line-count exceptions

Line-Count-Exception: app/lib/backend/preferences.dart | 1514 -> 1538 | background conversation cache write with its generation guard (sign-out safety)
Line-Count-Exception: app/lib/pages/conversation_detail/conversation_detail_provider.dart | 1514 -> 1518 | documented INV-PERF-1 allow on the one proxy hook that must notify
Line-Count-Exception: app/lib/providers/conversation_provider.dart | 2119 -> 2121 | log failures of the now-async cache write
Line-Count-Exception: app/lib/providers/device_provider.dart | 1594 -> 1598 | early return in the proxy update hook
Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 4437 -> 4443 | early return in the proxy update hook

UI evidence

UI-Evidence: none -- no visual change; the memories list and voice waveform render the same, only their rebuild scope changed

Failure-Class: none

New guards (only when adding a check or ratchet)

The ratchet would have flagged the defects fixed here when they landed:

The provider-graph check catches the unconditional notifyListeners() in updateExternalActions / setProviders. It is a check, not a shared primitive, because the cost lives in how ordinary provider and file code is written. The primitive part (offUiIsolate) is what the check points people to.

🤖 Generated with Claude Code

View guided diff

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T20:52:06.645218Z b49a5e9 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d531732b5b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

static Future<bool> saveWals(List<Wal> wals) {
final queued = _queued;
if (queued != null) {
queued.wals = wals;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Retain the superseded WAL snapshot as a backup

When two or more saves are queued before the pool callback starts, replacing queued.wals means every earlier snapshot is skipped completely. On a fresh install, for example, two back-to-back saves now write only the second snapshot and create no wals_backup.json, whereas the previous serialized writes left the first snapshot as the validated backup; if the current index is unreadable on the next loadWals(), non-mobile-batch WALs from that batch can therefore disappear from the loaded index. Preserve the newest superseded full snapshot as the backup (or persist one intermediate snapshot) before completing the coalesced callers.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 7450af2: when saves collapse, the newest superseded snapshot is written as the backup (what serial writes left). Test: collapsed saves keep the newest superseded snapshot as the backup, which fails on the previous commit.

Comment on lines +254 to +258
if token == "{":
depth += 1
elif token == "}":
depth -= 1
elif depth == 0:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Accept returns in braced proxy guards

When a correctly guarded hook uses the ordinary Dart form if (unchanged) { return; }, the { raises depth, so the return is ignored and the absolute provider-graph check reports a violation. This makes CI reject a valid no-change guard (or encourages an allow comment that disables the protection); distinguish nested function/closure bodies from control-flow blocks and add a braced-guard test.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 7450af2: returns inside if/loop/try blocks count while closures don't; hooks may be declared without a return type; a hook named in main.dart with no readable declaration now fails; the guard must be an identical/== test. Covered in test_check_mobile_ui_isolate.py.


def hook_violations(name: str, sources: dict[str, str]) -> list[str]:
"""Declarations of [name] that notify with no early return before the first notify."""
declaration = re.compile(rf"\b(?:void|Future<void>|FutureOr<void>)\s+{re.escape(name)}\s*\(")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject proxy hooks whose declarations are not parsed

If a new previous?..hook(...) method omits its return type (valid Dart here because always_declare_return_types is disabled), this declaration regex never matches it, and check_provider_graph() treats the resulting empty violation list as success. An unguarded notifyListeners() can therefore bypass the advertised absolute check; accept inferred-return declarations or report an error whenever a hook found in main.dart has no matched declaration.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 7450af2: returns inside if/loop/try blocks count while closures don't; hooks may be declared without a return type; a hook named in main.dart with no readable declaration now fails; the guard must be an identical/== test. Covered in test_check_mobile_ui_isolate.py.

Git-on-my-level and others added 2 commits October 14, 2026 13:35
…ed proxy guards

Addresses review on BasedHardware#21517: collapsed saves now leave the newest superseded
snapshot as the backup (what serial writes left), the provider-graph check
counts returns inside if/loop blocks but not closures, and a hook whose
declaration cannot be read fails instead of passing vacuously.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…k save test

- Recordings scan rechecks its generation right before the owners rename and
  before publishing; a superseded scan neither writes nor notifies.
- New history-json-on-ui rule: JSON in the WAL index, live transcript,
  conversation list and preferences modules must sit inside offUiIsolate, so
  removing the wrapper fails the ratchet. JSON is inlined into those closures.
- Proxy hooks must guard on identical/== (a null check is not an unchanged
  guard); ResizeImage(NetworkImage(...)) counts as sized.
- The replaced-caller WAL test now uses a non-superset newest snapshot and
  asserts the backup is the replaced one.

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7450af2993

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


def _compares_before(body: str, limit: int) -> bool:
"""The early return must test for "unchanged" (identity or equality), not only for null."""
return re.search(r"\bidentical\s*\(|==(?!\s*null\b)", body[:limit]) is not None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Tie proxy-hook returns to their equality guards

When a proxy hook has any equality check before its first notification and any unrelated conditional return, _compares_before and _top_level_return_before independently succeed, so the absolute graph check accepts a hook that still notifies for unchanged inputs. For example, if (foo == p) log(...); if (disposed) return; ... notifyListeners(); currently produces no violation; associate the return condition with the identical/== test rather than searching the whole prefix independently.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 15e1e7c: the early return must now be the branch of an if whose own condition is an identical/== test (null checks excluded), so an unrelated equality check plus an unrelated return no longer passes. Tests: test_an_unrelated_return_does_not_borrow_an_equality_check, test_compound_unchanged_guard_passes.

…condition

Addresses Codex review on BasedHardware#21517: an unrelated equality check next to an
unrelated conditional return no longer satisfies the provider-graph check.

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15e1e7ca27

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread product/invariants/mobile-ui-isolate.md Outdated
@@ -0,0 +1,65 @@
# INV-PERF-1: The mobile UI isolate stays free for frames

**Status:** locked

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep the new invariant proposed for seven days

This commit introduces both INV-PERF-1 and its guard but marks the invariant locked immediately. The root AGENTS.md route for product behavior points to PRODUCT.md, whose lines 80-82 require a new or changed product rule to remain proposed until its behavior and guard have been unchanged for seven days; locking it in the introducing commit bypasses that ratification period, so this status should remain proposed for now.

AGENTS.md reference: AGENTS.md:L17-L17

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in eff6049: INV-PERF-1 is now proposed (README index updated). The guard still runs in CI from checks-manifest.yaml, since status doesn't control enforcement.

sessionId: sessionId,
ownerGeneration: ownerToken?.generation,
ownerIdentity: ownerToken?.identity,
segments: segments,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear the transcript key when capture ends

When capture teardown has already cleared both activeCaptureSessionId and activeRecordingId before _resetStateVariables() notifies (for example, a processing event arriving after recording telemetry completes), _persistLiveSegments returns before replacing this key. Because the new key strongly retains the prior segments list, an entire long transcript object graph then remains live until another capture session updates the key or the provider is disposed; clear _lastSeenSegmentsKey on the no-session path or avoid storing the list itself.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in eff6049: _persistLiveSegments clears _lastSeenSegmentsKey on the no-session path, so the last capture's transcript isn't retained.

Comment thread app/lib/utils/wal_file_manager.dart Outdated
Comment on lines +177 to +178
await backupTmp.writeAsString(await _encodeIndex(superseded), flush: true);
await backupTmp.rename(_walBackupFile!.path);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Continue the main save when backup creation fails

When at least two save calls collapse and the backup temp/target is unwritable or corrupt while wals.json is still writable, this superseded-snapshot branch throws before the newest index is written. The ordinary _createBackup() path deliberately catches FileSystemException/FormatException and proceeds, so coalescing unexpectedly turns a best-effort backup failure into a failed main save and can leave WAL additions or deletions stale on disk; apply the same failure isolation here.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in eff6049: the superseded-snapshot backup is best-effort (FileSystemException logged) like _createBackup. Test: a failing superseded backup never blocks the index write (fails without the fix).


def _outside_off_ui_isolate(text: str, match: re.Match[str]) -> bool:
"""False when the match sits inside an `offUiIsolate(...)` call's arguments."""
for call in re.finditer(r"\boffUiIsolate\s*(?:<[^>(]*>)?\s*\(", text[: match.start()]):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Mask comments before locating off-isolate wrappers

The final implementation still reports zero history-json-on-ui hits when a comment or string before an unwrapped JSON call contains offUiIsolate(: this search scans raw source, and _call_args treats the unmatched fake call as enclosing the later jsonEncode. Thus a wrapper removal can pass the new guard merely because nearby documentation names the helper; mask comments and strings before finding candidate calls (while preserving offsets) and add that regression case.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in eff6049: wrapper lookup now runs on comment/string-masked source with real paren matching. Test: test_a_comment_naming_the_wrapper_does_not_exempt_json.

return all(stack)


UNCHANGED_TEST = re.compile(r"\bidentical\s*\(|==(?!\s*null\b)")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require guards to compare injected state

The final implementation still accepts an unrelated guard such as if (disposed == true) return; because this regex matches any non-null equality, and hook_violations then reports no problem. When disposed is false, identical injected providers still reach notifyListeners() on every upstream update, so the absolute graph check is bypassed; require the equality/identical expression to compare the hook parameters with the stored backing references.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in eff6049: the guard condition must name a hook parameter or a local computed from one. if (disposed == true) return; now fails (test_a_guard_on_unrelated_state_fails), and the capture hook's next == externalActions still passes.

- INV-PERF-1 stays proposed (PRODUCT.md seven-day rule); the guard runs regardless.
- CaptureProvider drops its transcript key when no capture session is active.
- A failing superseded-snapshot backup no longer blocks the index write.
- history-json-on-ui masks comments/strings before finding offUiIsolate wrappers.
- Proxy-hook guards must compare a parameter (or a local derived from one).

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eff6049a50

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (rec != null) list.add(rec);
}
bool current() => generation == _scanGeneration;
if (!current()) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Trigger auto-upload after the winning scan

When a second refresh starts before the constructor's initial scan finishes (for example, the deferred Conversations-page refresh while a long batch recording is still being duration-scanned), this early return completes the initial future. The constructor's refresh().then(_maybeAutoUpload) then runs against the old/empty _recordings, while the winning Home/Conversations refresh does not invoke _maybeAutoUpload; on an already-online connection the broadcast provides no initial true, so audio_omibatchphoneauto_* files can remain unuploaded until connectivity changes. Trigger auto-upload after the winning scan publishes, or make superseded refresh callers wait for that scan.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 391d3a4: the constructor no longer chains auto-upload/reconcile on its own refresh future; they run once after the first scan that was not superseded (_afterFirstPublishedScan), so they always see published recordings. Covered by the existing recordings, auto-upload and sync-poll-storm suites (full app suite 5681 pass); no provider-level auto-upload harness exists to add a dedicated red test.


# ── provider graph ────────────────────────────────────────────────────────────

PROXY_HOOK_CALL = re.compile(r"\bprevious\s*[?!]?\.\.\s*(\w+)\s*\(")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scan ordinary proxy update calls too

When a proxy update uses the ordinary block form previous?.setFoo(value); return previous ?? Foo();, this regex finds no hook because it recognizes only cascade calls such as previous?..setFoo(...). Since main.dart still contains other cascade hooks, the no-hooks failsafe does not fire, so a newly added unguarded setFoo can notify on every upstream update while this absolute graph check passes; parse the ChangeNotifierProxyProvider update bodies (or reject unrecognized calls) and add a block-form regression case.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 391d3a4: PROXY_HOOK_CALL now also matches block-form updates (previous?.hook(...), previous!.hook(...)). Test: test_block_form_update_calls_are_hooks.

- Initial auto-upload and job reconcile run after the first scan that was not
  superseded, so a refresh started meanwhile cannot leave them on stale state.
- The provider-graph check also reads block-form updates (previous?.hook(...)).

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 391d3a4bde

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

} on ArgumentError {
// A captured value was not sendable. Correctness beats latency, but tests
// assert this stays at zero so the work does not silently move back.
offUiIsolateFallbacks++;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Emit production telemetry for the isolate fallback

When a large call captures an unsendable object, Isolate.run raises ArgumentError and this branch silently reruns the whole JSON/hash operation on the UI isolate. The only signal is an @visibleForTesting process counter, so a device-only payload can reintroduce the stutter this helper is meant to prevent without any production evidence; emit the existing bounded mobile recordFallback event before retrying inline, as required for mode-changing fail-open paths.

AGENTS.md reference: AGENTS.md:L20-L20

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 981380f: the fallback branch now calls the shared mobile recordFallback (fallback_triggered, reason error, outcome degraded) before rerunning inline.

Comment on lines +344 to +345
if not any(re.search(rf"\b{re.escape(name)}\b", condition) for name in injected):
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require equality against the stored provider

Fresh evidence beyond the fixed unrelated-state case: if (p == fallbackProvider) return; passes this check because it contains == and merely mentions injected p. When the stored field already equals p but p != fallbackProvider, that hook still reaches notifyListeners() on every upstream update, so the advertised absolute provider-graph check can be bypassed; inspect the equality operands and require the injected or derived value to be compared with the stored backing reference.

AGENTS.md reference: AGENTS.md:L17-L17

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 981380f: the guard condition must name both an injected value (parameter or local derived from one) and a stored field the hook assigns. if (p == fallbackProvider) return; now fails (test_comparing_the_parameter_with_something_else_fails).



def proxy_hooks(main_text: str) -> list[str]:
return sorted(set(PROXY_HOOK_CALL.findall(main_text)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Mask comments before collecting proxy hooks

proxy_hooks() runs PROXY_HOOK_CALL against raw main.dart, so a comment or string such as // previous?.setFoo() is added as a real hook; check_provider_graph() then cannot find its declaration and fails every app/lib change. This makes harmless documentation in the provider wiring block CI, so pass comment/string-masked source to the extractor as the rest of this parser already does.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 981380f: proxy_hooks() runs on comment/string-masked main.dart (test_commented_out_update_calls_are_not_hooks).

- offUiIsolate reports its UI-isolate fallback through recordFallback.
- Proxy-hook guards must compare the injected value with the stored field.
- Hook extraction ignores comments and strings in main.dart.

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 981380fc93

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/lib/providers/capture_provider.dart Outdated
Comment on lines 70 to 72
if (key == _lastSeenSegmentsKey) return;
_lastSeenSegmentsKey = key;
final fingerprint = segments

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Move transcript fingerprinting off the UI isolate

When a live transcript gains or updates a segment, segmentsPhotosVersion changes, so this new key does not take the early return and the listener immediately maps and joins the entire transcript into fingerprint synchronously. Long captures therefore still incur O(transcript text) work on the UI isolate for every transcript event—the specific stutter this change aims to remove—even though the later hashing and JSON encoding are isolated; move the fingerprint work to offUiIsolate or replace it with an incremental cheap content version.

AGENTS.md reference: app/AGENTS.md:L4-L4

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in b49a5e9: the per-event full-transcript fingerprint is gone. The change key already detects edits, and a write queued for the same owner generation takes the latest transcript when it runs, so a burst of segment events costs one snapshot per completed write. New test a burst of transcript events costs one snapshot per write: 50 events on a 400-segment transcript read 42,550 segments before and <1,350 now. Capture spine/persistence contracts unchanged.

start, end = _line_bounds(text, match.start())
line = text[start:end]
column = match.start() - start
if _in_comment(line, column) or _in_string(line, column):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scan executable Dart string interpolations

When a Dart string interpolation contains executable code such as ${file.readAsStringSync()} or ${jsonEncode(history)}, _in_string classifies the whole literal as string content and this branch drops the match; count_hits returns zero for both shapes. Those expressions do execute on the UI isolate, so an app/lib change can add exactly the synchronous I/O or history-sized JSON this CI ratchet promises to reject; mask only non-interpolated string content and add an interpolation regression case.

AGENTS.md reference: AGENTS.md:L17-L17

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in b49a5e9: matches inside ${...} interpolations now count as code (test_interpolated_code_counts); plain string text still doesn't.

- Live transcript mirror: drop the per-event full-transcript fingerprint; a
  queued write takes the latest transcript, so a burst of segment events costs
  one snapshot per completed write (red-proof: 42,550 -> <1,350 reads for 50
  events on a 400-segment transcript).
- Guard counts executable code inside ${...} string interpolations.

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b49a5e92a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

try {
final backupTmp = File('${_walBackupFile!.path}.tmp');
await backupTmp.writeAsString(await _encodeIndex(superseded), flush: true);
await backupTmp.rename(_walBackupFile!.path);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the superseded WAL across an interrupted replacement

Fresh evidence beyond the earlier backup fix is that loadWals() still accepts a valid main index before looking at the backup. When A is on disk and queued B/C saves collapse, this branch renames B into the backup and then spends time encoding/writing C; if the process dies (or C fails) between the two renames, restart loads valid A and ignores newer B, whereas serialized saves had made B the main file before starting C. Non-mobile-batch WAL additions or deletions from B can therefore be lost; persist B as the crash-safe main first or make loading select the newest valid snapshot.

Useful? React with 👍 / 👎.

Comment on lines +87 to +89
final currentSession = activeCaptureSessionId ?? activeRecordingId;
if (currentSession == null) return;
await localSegmentStore.replaceSession(currentSession, List.of(segments));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep coalesced segment writes bound to their session

When a transcript update queues behind an in-flight write and ConversationProcessingStartedEvent invokes _resetStateVariables() before this callback runs, the owner token remains current but activeCaptureSessionId and segments have been cleared or replaced; the callback therefore skips the queued update or writes the new empty/session state instead of the old session's final segments. The previous code captured sessionId and pending at enqueue time, and the capture ownership contract requires issued durable writes to remain bound to their original session, so coalesce only within a session and retain that session's list reference until it is persisted.

AGENTS.md reference: app/AGENTS.md:L108-L108

Useful? React with 👍 / 👎.

# ── provider graph ────────────────────────────────────────────────────────────

# `previous?..hook(...)` (cascade) and `previous?.hook(...); return previous;` (block form).
PROXY_HOOK_CALL = re.compile(r"\bprevious\s*[?!]?\.\.?\s*(\w+)\s*\(")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Discover proxy hooks independent of parameter names

When a ChangeNotifierProxyProvider update names its third callback argument notifier or old rather than previous (legal Dart), this regex extracts no hook. Since main.dart already contains other matches, the no-hooks failsafe does not fire, so notifier?.setFoo(...) can call an unguarded notifying method while the advertised absolute provider-graph check passes; derive the receiver name from each update callback or parse those bodies rather than hard-coding previous.

AGENTS.md reference: AGENTS.md:L17-L17

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 8d3e18c into BasedHardware:main Oct 14, 2026
37 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/mobile-perf branch October 14, 2026 21:03
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