Skip to content

fix(mobile): resolve Mind Map owner by identity, not names - #22845

Merged
kodjima33 merged 1 commit into
mainfrom
fix/memory-graph-owner-identity
Oct 20, 2026
Merged

kodjima33 merged 1 commit into
mainfrom
fix/memory-graph-owner-identity

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Use one identity boundary for Mind Map recovery and drawing. Recognize the reserved canonical user ID and the existing explicit legacy owner signals; profile names and labels are presentation only.
  • Select the owner deterministically, favoring canonical user, and remap only proven owner aliases. Preserve distinct people, concepts, edge direction/labels and the bounded canvas.
  • Add production-widget, API recovery, identity-unit and rendered refresh regressions. Document the pipeline and live-verification checklist.

Refs #20578. Follow-up to the identity collision findings on #21311; this does not automatically close either item and is not a deployment request.

Contract and remaining evidence

backend/models/memory_promotion.py:canonical_graph_entity_id reserves user; named entities have distinct ent_* IDs. The legacy extractor in backend/utils/llm/knowledge_graph.py emits labels without proving account-owner identity. Tests therefore must not treat a matching display name as an identity assertion. The earlier label-set expectation and the name-only owner-recovery fixture are migrated to this authoritative contract, not simply weakened.

This is a shared primitive rather than a new source-scraping check. The regression tests execute the real widget and HTTP adapter and run in the existing Flutter suite. The rendered scenario also runs in the existing visual-audit smoke suite.

An ambiguous historical name-only node is deliberately kept distinct. Maintainers still need to inspect the affected #20578 payload privately and verify the owner mapping/relaunch on the affected build. No customer data was accessed, rewritten, rebuilt or deleted for these fixtures.

Verification

  • Before the production fix: TZ=UTC bash app/test.sh test/widgets/memory_graph_owner_identity_test.dart ran 138 protected contracts successfully, then all 8 new widget regressions failed against unchanged production code on main 5482752833b3.
  • After the fix: TZ=UTC flutter test --no-pub test/widgets/memory_graph_owner_identity_test.dart test/widgets/memory_graph_empty_state_test.dart test/utils/memory_graph_identity_test.dart test/unit/knowledge_graph_read_test.dart passed all 64 tests, including a final post-commit rerun.
  • bash app/scripts/analyze_ratchet.sh: passed, no new analyzer errors/lint debt.
  • OMI_PR_BODY_FILE=/private/tmp/omi-owner-identity-pr-body.md make preflight and final post-commit scripts/pr-preflight --pr-body-file /private/tmp/omi-owner-identity-pr-body.md: all 26 selected checks passed in both runs.
  • TZ=UTC bash app/scripts/visual_audit.sh --head WORKTREE --only memories-mind-map-distinct-identities --out /private/tmp/omi-owner-identity-visual: passed. Inspected both rendered frames: owner, same-name people and I stay distinct before and after tapping Refresh.
  • TZ=UTC make mobile-verify ARGS='fast --paths app/lib/utils/memory_graph_identity.dart app/lib/pages/memories/widgets/memory_graph_page.dart app/lib/backend/http/api/knowledge_graph_api.dart': selected all 6 seeded journeys via the fail-closed full-suite fallback; 23 tests passed, 0 failed/skipped. Receipt: /var/folders/42/1hgpqdd93c9760xd6rhq4brw0000gn/T/mobile_verify_hgw3r4ue/verify-receipt.json.
  • TZ=UTC bash app/test.sh: passed. Protected opt-in spine: 138 passed. Full ordinary app suite (including the new widget/API/identity regressions and rendered smoke scenario): 6,773 passed, 18 skipped, 0 failed.
  • Normal git push pre-push gate passed, including app-client OpenAPI compatibility and pinned Dart formatting. Native platform compiles and hosted CI remain separate evidence; no check was bypassed.

Evidence is synthetic/hermetic and exercises production widgets and HTTP boundaries. No physical-device, native-build or affected-account verification is claimed. The original PR head 890cc2f separately failed the three review probes (full-name person in both orders and a concept named I). Screenshots and logs are retained locally, not committed.

Product invariants affected

INV-MEM-1

Failure-Class: none

UI-Evidence: none -- identity/data handling only, no layout/style changes. Local production-widget rendered evidence is /private/tmp/omi-owner-identity-visual/after/ (loaded/refreshed frames); the same scenario executes in the regular visual-audit smoke suite.

View guided diff Turn on auto-fix

Use one shared ID/type boundary for graph recovery and drawing. Prefer the
reserved canonical user endpoint deterministically, keep distinct named
people and concepts, and remap only explicit legacy owner aliases. Retain
bounded rendering, edge direction/labels, paging and session fences.

Refs #20578 and #21311. Ambiguous historical named nodes still need private
payload/owner-mapping verification; this does not close the customer issue.

Verification: 8 new widget regressions failed against unchanged main before
the fix. Full app/test.sh passed 138 protected contracts and 6773 ordinary
tests (18 skipped). Seeded journeys passed all 23 tests across 6 journeys.
Analyzer ratchet and 26 local preflight gates passed. Synthetic rendered
loaded/refresh frames inspected; no physical-device/account evidence claimed.

Failure-Class: none
@aryanorastar aryanorastar added the flutter flutter work label Oct 20, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-20T11:22:24.667685Z e9b0cc2 PR opened
ℹ️ 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.

@Git-on-my-level

Copy link
Copy Markdown
Member

Verdict: the production change is correct, tight, and well-tested — no blocking issues.

  • app/lib/utils/memory_graph_identity.dart — identity is now proven only by the reserved id user, the legacy user-node anchor, or explicit node_type: user; labels and the profile given-name no longer establish ownership. memoryGraphPrimaryOwnerId is deterministic and order-independent (user > user-node > lexicographically first typed legacy). This matches the backend contract I checked (backend/models/memory_promotion.py:canonical_graph_entity_id reserves user and mints distinct ent_* ids).
  • app/lib/backend/http/api/knowledge_graph_api.dart:78 — the owner-only recovery gate is identity-based, so a node that merely shares the owner's name can no longer trigger canonical recovery (previously that could hide real name-matching people as "owner-only"). Dropping the ownerGivenName seam simplifies the surface.
  • app/lib/pages/memories/widgets/memory_graph_page.dart:481-531 — alias remapping is computed from allNodes before the 200-node canvas bound, so an alias outside the visible page keeps its edges on the anchor; only proven owner records are remapped and addUniqueEdge drops resulting self-loops/duplicates. Edge direction and labels preserved.
  • Tests — memory_graph_identity_test.dart (identity matrix incl. blank ids and order-independence), memory_graph_owner_identity_test.dart (real ent_* backend ids, both input orders), knowledge_graph_read_test.dart (recovery matrix incl. name-only non-recovery), memory_graph_empty_state_test.dart updated to drop the retired label-set expectation, plus the visual-audit scenario in integration_test/visual_audit/scenarios/memories.dart. Good coverage; I could not execute the suite locally (no dart toolchain on the review host) and relied on the green Dart Analyze & Tests run on this head.
  • app/docs/memory-graph-identity.md — verified against the code and backend model; accurate, including the honest caveat that this does not close Mobile Memory Graph shows separate owner-like nodes labeled with given name and literal user #20578. app/AGENTS.md swap of a generic test bullet for the contract pointer is fine; note the generic "test state machine logic via minimal abstractions" hint is gone from the playbook.
  • Changelog fragment present.

UX: people who share your name (or are labeled "I"/"me") now stay separate nodes instead of collapsing into your owner node; name-only legacy "owner" projections render as content instead of silently triggering recovery. Performance: no added queries or passes; remap is O(n) over nodes.

USER IMPACT: Mind Map no longer merges distinct people into your center node just because they share your name — they stay separate, and your own node is anchored by identity.

Remaining for a maintainer: the affected #20578 payload should be verified on a live build before that issue is closed (the PR checklist flags this too). Nothing else material outstanding.


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

@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.

Trusted contributor (aryanorastar), scoped mobile identity-collision fix with contract tests; confidence 4/5 (root cause, fix(mobile) title, CI green, tests added) — diff size is the only failing criterion. mergeStateStatus clean.

@kodjima33
kodjima33 merged commit 29a1232 into main Oct 20, 2026
53 of 54 checks passed
@kodjima33
kodjima33 deleted the fix/memory-graph-owner-identity branch October 20, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants