Skip to content

fix(mobile): recover empty Mind Map through canonical memory reads - #22078

Merged
aryanorastar merged 5 commits into
mainfrom
fix/mobile-empty-mind-map-recovery
Oct 19, 2026
Merged

aryanorastar merged 5 commits into
mainfrom
fix/mobile-empty-mind-map-recovery

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Mobile Mind Map can show an empty screen because the compatibility graph omits saved-memory catalog records and later canonical pages. Read the canonical catalog when the compatibility view is empty or owner-only, keep memories without relationships readable, and provide Refresh / Show More without attempting the rejected canonical rebuild. Existing nonempty compatibility/shared graphs remain visible, including the projection proposed in #12878.

Canonical pages remain revision-fenced and session-bound. Stale cursors restart at page one, late refresh responses cannot replace newer data, label changes render, backend/session changes and rejected authorization clear old data, and failed ordinary refreshes preserve same-session content. Expired cursors discard the invalidated revision before retry, including if that retry fails. The canvas keeps a 200-entity bound and fitted small maps retain readable labels. Catalog records remain separate from graph entities and never create relationships. Onboarding skips the legacy mutation after a successful canonical read. Initial compatibility failures stop without a second expensive graph read; each read retains zero transport retries. The loopback regression fixture uses a stable backend override and the existing token-I/O seam so session fencing remains enabled.

The backend adds an absence-only response header so a genuinely new account can show an empty state while an unreadable canonical revision remains a retryable failure. The existing HTTP status/body stay compatible.

Refs #20481, #20463. Complements #20744; this PR is independent of #12878's broader macOS/account-wide rebuild work. It does not assert that affected accounts have eligible Long-term memories or that missing assertions/data have been repaired.

Validation

  • Canonical backend service/FastAPI route suite: 17 passed.
  • Final focused Flutter HTTP/error/widget/layout suites: 49 passed, including real loopback HTTP gateway retry bounds, authorization/backend changes, stale cursor restart failure, label refresh, viewport fitting and bounded large pages.
  • Visual audit passed: empty, saved-memory catalog, and later-page graph states. Inspected captures; recovered graphs now fit the viewport with readable, separated labels.
  • Focused analyzer reported no errors/warnings (pre-existing informational lints remain).
  • App-client schema inventory: 13 passed; explicit endpoint URLs retain contract discovery while requests stay pinned to their backend.
  • Normal pre-push gate passed without skip flags on 2d70dcd229: all 41 shared preflight checks, backend typecheck (0 errors), runtime-image source closure, selected backend tests, OpenAPI compatibility, generated Dart/Swift/TypeScript models, Flutter build_runner and Dart formatting. The final Mobile App Checks run passed, including the analyzer ratchet, regular Flutter suite, generated files and Mobile Release Eligibility. Native compile/emulator and seeded-journey jobs were not selected for this Dart-only diff; physical-device/store verification remains pending.

Commands: cd app && flutter test --no-pub test/unit/http_pool_manager_retry_test.dart test/unit/knowledge_graph_read_test.dart test/unit/knowledge_graph_error_message_test.dart test/widgets/memory_graph_empty_state_test.dart test/widgets/memory_graph_fit_to_bounds_test.dart; cd backend && .venv/bin/python -m pytest tests/unit/test_knowledge_graph_canonical_pagination.py -q (includes the FastAPI request path) and separately tests/unit/test_app_client_schema_inventory.py -q. Focused flutter analyze --no-pub --no-fatal-infos covered the changed API, graph/catalog widgets, identity helper and tests.

The backend CI run passed five unit shards and the slow guardrails on its first attempt. Shard 1 passed its assertions but hit an unrelated CPU timing guard (test_capture_evidence_admission.py: 1.03s against 1.00s); all four tests in that file also passed locally under the unchanged 1.00s limit. Only failed jobs were retried on the same commit, with no budget or allowlist changes.

Release and customer verification

Merge, deploy the backend absence header first, then release iOS and Android. Retest on physical phones with affected accounts: open Mind Map, verify saved memories or relationships, load more, refresh/reopen, and confirm onboarding no longer attempts a canonical rebuild. If still empty, privately check memory eligibility, processing and assertion state. No customer account or production records were accessed.

Public store release evidence checked 2026-10-18: App Store iOS 1.0.558+ notes and Google Play notes (updated October 15) both explicitly list the canonical knowledge-graph 409 onboarding fix from #20744. This supports public release on both platforms. The exact Android binary/source SHA and rollout coverage have not been verified through Codemagic; the available login has no Omi workspace access. Release of that error handling does not establish that an affected account has a populated map.

Product invariants affected

  • INV-MEM-1: existing memory tiers and eligibility remain unchanged.
  • INV-MEM-4: read-only client recovery; no new promotion or graph mutation authority.

Failure-Class: FC-derived-state-gate-without-legacy-source-path

The canonical presence/absence probe must preserve the compatibility path for unprovisioned accounts while rejecting unreadable state as empty. Backend route and mobile HTTP/widget tests guard both sides.

UI evidence

Mobile Mind Map catalog

Recovered graph canvas

Empty map refresh

@aryanorastar
aryanorastar marked this pull request as ready for review October 18, 2026 03:47
@cubic-dev-ai

cubic-dev-ai Bot commented Oct 18, 2026

Copy link
Copy Markdown

Auto-fix isn't included in your plan ↗

Upgrade to Team

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict: this is a strong, well-scoped recovery change — reads-only on the client, an additive backend signal, and unusually thorough regression coverage; I'm leaving merge sign-off to a human maintainer because it bundles a mobile data-display change, a backend contract addition, and new agent-facing docs in one PR.

Findings (all changed files reviewed):

  • app/lib/backend/http/api/knowledge_graph_api.dart — the recovery ordering is correct: the canonical read happens only after a successful 200 compatibility read whose nodes are all owner nodes (nodes.any((node) => !memoryGraphIsUserNode(...)) gate); a failed 401/403/5xx compatibility read throws without a second expensive request (covered by 'failed compatibility read ... does not issue a canonical recovery request'). Session and backend fencing via AuthService.captureSessionSnapshot plus the _owner_generation/_backend_origin checks in mergeKnowledgeGraphPages is the right cross-account safety shape, and the 401/403 mapping to KnowledgeGraphSessionChanged clears stale content.
  • app/lib/pages/memories/widgets/memory_graph_page.dart — the _loadGeneration counter correctly drops late responses (verified by the 'late empty response cannot overwrite a newer graph' widget test), the KnowledgeGraphCursorExpired branch clears the invalidated revision before restarting even when the restart fails, and _populateGraph's take(200) keeps the quadratic force simulation bounded.
  • app/lib/utils/memory_graph_identity.dart — extracting the shared owner-node predicate fixes the read/renderer divergence where duplicate owner labels could hide saved memories.
  • backend/routers/knowledge_graph.py — additive X-Omi-Knowledge-Graph-State: unestablished header on the existing 503 only for the missing_state_head reason; I verified missing_state_head is a real V3AccountGenerationFailureReason value on main and the released status/body are unchanged. Matching on str(exc) is string-coupled but the values are stable wire reasons.
  • app/docs/mind-map-recovery.md — the doc's technical claims match the diff everywhere I checked. Note it is written partly to steer future coding agents (verification checklist including unchecked 'Merge, deploy...'), and it contains no repo policy or workflow instructions — but maintainers should decide whether another single-topic note in app/docs/ (18 files there now) is the right home.
  • Remaining files: misc_wire.g.dart (generated-style DTO for the canonical response), backend/scripts/dart_model_groups.py (one-line model registration), app/lib/pages/onboarding/wrapper.dart (canonical guard before the legacy prebuild mutation — correct), memory_graph_catalog.dart (read-only catalog list widget), http_pool_manager_retry_test.dart (harness swap to Env.overrideApiBaseUrl + real token gateway is a net isolation improvement), the new widget/unit test suites, visual-audit scenarios, and the .agent-artifacts evidence set — all consistent with the above.

Security: no new auth surface, no mutation endpoint is called from any read/refresh/pagination path (verified — no rebuild/delete), and all reads are session-fenced. Performance: one extra canonical GET only on empty/owner-only views, zero transport retries, 200-entity bound preserved. UX: saved memories become readable with Show More/Refresh; blast radius is the Mind Map screen plus onboarding prebuild — a regression here mis-displays or empties maps for affected accounts.

USER IMPACT: users whose Mind Map showed nothing despite saved memories will now see those memories (with Show More), can refresh safely without rebuilding data, and genuinely new accounts get a real empty state instead of an error.

Still wanted before merge: (1) on-device verification with an affected account — the checklist item is unchecked for a reason; (2) deployment ordering: ship the backend header before the mobile release, as the doc itself notes; (3) a maintainer call on consolidating this doc with the existing app/docs recovery notes.

Human review needed: a maintainer should sign off on the additive 503-header contract (positive-absence semantics) and the placement of the new agent-facing doc before this merges.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added needs-maintainer-review Needs a human maintainer to sign off before merge flutter flutter work labels Oct 18, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

1093-line / 19-file change adding a new Mind Map recovery path + canonical-catalog read capability; reads as a new capability more than a narrow fix (unsure->treat as feature per policy default). Has tests but size+scope -> approve-only, not merge.

@aryanorastar
aryanorastar merged commit 01ed5fe into main Oct 19, 2026
78 of 81 checks passed
@aryanorastar
aryanorastar deleted the fix/mobile-empty-mind-map-recovery branch October 19, 2026 12:05
kodjima33 pushed a commit that referenced this pull request Oct 20, 2026
… toast (#22714)

MemoryGraphPage reloads silently on every app resume. #22078 rewrote
its catch block and dropped the old `if (!silent)` guard, so a resume
refresh that fails while a map is loaded now shows "Couldn't load
knowledge graph · Try again". The Memories tab stays alive in Home's
IndexedStack, so the toast appears on whatever tab is open, usually
Home. Background refreshes now keep the current map quietly again; a
refresh the person starts still reports the failure.
aryanorastar added a commit that referenced this pull request Oct 26, 2026
Onboarding still treated a failed Mind Map read as an empty legacy
account and sent a rebuild POST. This could turn a canonical read
outage, invalid response or replaced account session into an
unnecessary/rejected mutation. The optional prebuild now stops on read
failure; the normal map view retains its read/retry path.

The orchestration moves from the widget to
`KnowledgeGraphApi.prebuildForOnboarding`, which uses the existing
production reader, rebuild and polling owners. Successful canonical
reads and populated compatibility maps never rebuild. A positively
absent canonical account can still use legacy rebuild; 409 remains
terminal and a queued legacy rebuild retains bounded stability polling.
No server guard, memory promotion, storage, auth policy or wire schema
changes.

Refs #20481. The issue discussion by julio23jaz-dotcom also identified
this catch-and-rebuild path. Builds on merged #20744 and #22078; #12878
is closed unmerged and is not a dependency. This finishes the reproduced
failed-read onboarding gap, not a claim about every affected account's
current graph.

## Verification

- Six regressions fail after a behavior-preserving extraction of the
original catch-and-rebuild method; seven successful/legacy scenarios
still pass. With the fix, all 13 pass through the real HTTP client
against loopback (synthetic responses and the existing local auth
gateway; no live identity provider).
- Focused graph/API/widget/identity suite: 88 passed.
- Analyzer ratchet: passed. Direct analysis reports only the existing
`avoid_print` in unchanged stability polling; no new diagnostic.
- Final diff reviewed; all 27 local manifest checks and the bounded
pre-push gate passed. The local history-dependent 90-day class ratchet
explicitly skipped on the shallow checkout; CI runs with full history.
Exact-head CI remains pending; stays draft.
- `make mobile-verify ARGS="fast --paths
app/lib/backend/http/api/knowledge_graph_api.dart
app/lib/pages/onboarding/wrapper.dart"`: both selected hermetic journeys
passed (9 checks; source `43866f9f0032844e08902aa01f41ce390cc6ef14`,
clean).

The loopback flow exercises the entire changed orchestration boundary,
including parsing, read failures, account replacement, no-write
outcomes, terminal conflict and successful legacy polling. No UI layout,
native or hardware behavior changes; no physical-device test is needed
for this boundary.

## Failure class

Failure-Class: new

`FC-failed-probe-permits-mutating-recovery`: a failed probe was caught
and reinterpreted as permission to mutate. Why isn't this a shared
primitive instead? It is: the API owner now holds the prebuild flow, and
its loopback contract tests are the reusable prevention artifact rather
than a widget-specific source check.

## Release and customer follow-up

Merge and release the mobile update on iOS/Android. No additional
backend deployment is required for this incremental fix. Existing
canonical-read backend support from #22078 remains required and was
previously verified deployed. Keep support tracking open until the
affected users confirm their map loads and remains available after
refresh/reopen on the released build. No customer data, assignment,
deployment or account mutation was performed.

UI-Evidence: none

The widget only delegates its existing optional background request; no
visible control or layout changes.

## Product invariants affected

none; canonical read/mutation and promotion authority are preserved
(INV-MEM-1, INV-MEM-4).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work needs-maintainer-review Needs a human maintainer to sign off before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants