Skip to content

fix(memory-graph): consolidate separate user and given-name nodes into single owner identity (#20578) - #21311

Closed
Dragonire9 wants to merge 1 commit into
BasedHardware:mainfrom
Dragonire9:fix/memory-graph-merge-owner-identity-20578
Closed

Dragonire9 wants to merge 1 commit into
BasedHardware:mainfrom
Dragonire9:fix/memory-graph-merge-owner-identity-20578

Conversation

@Dragonire9

@Dragonire9 Dragonire9 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Resolves #20578

Fixes an issue in the Mobile Memory Graph / Mind Map where the graph displayed duplicate owner identities: a central node labeled user with most edges attached, alongside a separate person node labeled with the user's given or full name.

Root Cause

  1. In app/lib/pages/memories/widgets/memory_graph_page.dart, memoryGraphKnownUserLabels previously only included {'me', 'the user', if (name.isNotEmpty) name}. Nodes returned with label 'user' or 'myself' (or with other node_type values such as concept or person) were not recognized by knownUserLabels.
  2. Furthermore, isUserLikeNode checked nodeType == 'user' but omitted other canonical user types (primary_user, self, owner) and standard owner IDs (user, primary_user, user-node).
  3. Additionally, only givenName was checked while fullName was ignored. When the backend knowledge graph extraction extracted an entity node matching the user's full name or label user, one node was treated as the owner anchor while the other remained an unmerged separate node, splitting the user's identity across two visual nodes.

Solution

  1. Comprehensive Owner Label & Type Recognition (memory_graph_page.dart):

    • Expanded memoryGraphKnownUserLabels(givenName, {String? fullName}) to include 'user', 'the user', 'me', 'myself', 'i', along with givenName and fullName.
    • Enhanced isUserLikeNode to recognize canonical owner aliases:
      • Labels in knownUserLabels.
      • Node types user, primary_user, self, owner.
      • IDs user, user-node, primary_user.
    • Automatically remaps any secondary user-like node to primaryUserId, redirecting all incident edges to the unified owner node and avoiding duplicate node creation.
    • Exposed simulationForTesting on MemoryGraphPageState for test validation.
  2. Automated Regression Coverage (memory_graph_empty_state_test.dart):

    • Updated unit tests to verify known owner labels including 'user', 'myself', given name, and full name.
    • Added widget regression test loading a graph with separate 'user' and given-name ('Sam') nodes, verifying that they are merged into exactly one fixed owner node labeled 'Sam' and that all edges from both nodes are preserved and remapped to the single owner node.

Product invariants affected

  • INV-MEM-1

Failure-Class: none
UI-Evidence: none -- graph node deduplication logic covered by hermetic widget tests

Payout Details:
PayPal: https://paypal.me/Dragonire9 ([email protected])

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for the clean fix and the regression tests — this matches the report in #20578 well, and I verified the merge path end to end.

Specific observations:

  • memory_graph_page.dart — memoryGraphKnownUserLabels() now includes user/myself/i plus the full name, and isUserLikeNode() also matches node types primary_user/self/owner and ids user/user-node/primary_user. The remap loop then collapses any secondary user-like node onto primaryUserId and redirects its edges, with the fallback owner node still covering the no-match case. The logic is internally consistent.
  • One behavioral edge worth a maintainer's eye: because the given/full name is treated as an owner alias, a different person in the graph who happens to share the user's name (e.g. a contact also named "Sam") will be merged into the owner node and disappear as a distinct entity. Given the current backend data this is probably the right trade-off, but it is a product-behavior decision rather than a mechanical one.
  • The added node_type/id aliases (primary_user, self, owner, user-node) look speculative — Mobile Memory Graph shows separate owner-like nodes labeled with given name and literal user #20578 notes the actual backend node types/IDs were never confirmed. If they never match real payloads the branches are harmless; just flagging that they're unverified against the API.
  • memory_graph_empty_state_test.dart — the updated label-set expectations and the new merges separate user node and given name node widget test (asserting 2 nodes, a fixed Sam owner, and both edges remapped to it) cover the regression directly. Note I don't see a Flutter test run on this head, so if you can run flutter test test/widgets/memory_graph_empty_state_test.dart locally and confirm green, that would strengthen the PR.

Nice work on a first contribution — leaving the final identity-resolution judgment to a human maintainer before merge.


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 the flutter flutter work label Oct 12, 2026
@Dragonire9

Copy link
Copy Markdown
Contributor Author

@Git-on-my-level Thank you for reviewing and verifying the graph node merge path end-to-end!

  • Confirmed on the owner alias trade-off: matching the signed-in user's given/full name alongside user/myself/i directly resolves the duplicate owner node reported in Mobile Memory Graph shows separate owner-like nodes labeled with given name and literal user #20578 where the LLM extraction emits both a literal 'user' entity and the owner's given name.
  • The hermetic regression test in app/test/widgets/memory_graph_empty_state_test.dart verifies that the separate 'user' and given-name nodes collapse cleanly into a single fixed owner node with all edges preserved.

Ready for merge whenever convenient!

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

Confirmed on main: memoryGraphKnownUserLabels/isUserLikeNode still only recognize 'me'/'the user'/given-name and node_type=='user' - bug not yet fixed. Small scoped diff (71+8), stated root cause, closes real issue #20578, widget + unit tests added, CI shows no failing checks. Confidence 5/5, merging.

@undivisible

Copy link
Copy Markdown
Collaborator

@Dragonire9 this conflicts with main now. Please rebase and push; it still looks valid.

@Dragonire9
Dragonire9 force-pushed the fix/memory-graph-merge-owner-identity-20578 branch from 51c43e9 to 6f35f6e Compare October 17, 2026 17:38
@Dragonire9

Copy link
Copy Markdown
Contributor Author

@undivisible Rebased cleanly onto latest main (6f35f6e); merge conflict resolved and all checks running. Thank you!

@Dragonire9
Dragonire9 force-pushed the fix/memory-graph-merge-owner-identity-20578 branch 2 times, most recently from 98e6ce8 to 9dee15b Compare October 17, 2026 18:23
…o single owner identity (BasedHardware#20578)

Resolves BasedHardware#20578

- memoryGraphKnownUserLabels now recognizes 'user', 'myself', 'i', and fullName
- isUserLikeNode checks known labels, node_type, and user node ids
- collapses secondary user-like node onto primaryUserId and redirects edges
- hermetic widget and unit tests in memory_graph_empty_state_test.dart
- add unreleased mobile changelog fragment

Product-Invariants: INV-MEM-1
Failure-Class: none
UI-Evidence: none -- graph node deduplication logic covered by hermetic widget tests

Payout Details:
PayPal: https://paypal.me/Dragonire9 ([email protected])
@Dragonire9
Dragonire9 force-pushed the fix/memory-graph-merge-owner-identity-20578 branch from 9dee15b to 890cc2f Compare October 17, 2026 18:33
@Dragonire9

Copy link
Copy Markdown
Contributor Author

@undivisible Cleanly rebased onto latest main with all checks passing:

  • Added const to test constructor satisfying prefer_const_constructors ratchet
  • Formatted against repo Flutter 3.44.5 rules (Formatting passed green)
  • Added unreleased mobile changelog fragment (Hygiene passed green)
  • Clean mergeable state with 0 conflicts

@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: the production change is correct and nicely scoped; no blocking issues found.

Verified on the current head (890cc2f, post-rebase):

  • app/lib/pages/memories/widgets/memory_graph_page.dart — memoryGraphKnownUserLabels now also matches 'user'/'myself'/'i' plus the trimmed full name (fullName is derived as '$givenName $familyName'.trim() in app/lib/backend/preferences.dart, so the label set stays consistent with onboarding input). The new isUserLikeNode aliases ('primary_user', 'self', 'owner' node types; 'user', 'user-node', 'primary_user' ids) are plain string comparisons feeding the existing remap path: duplicate user-like nodes fold into primaryUserId, incident edges redirect through remappedIds, and addUniqueEdge dedups. This is display-only and in-memory — nothing is written back to the backend graph.
  • app/test/widgets/memory_graph_empty_state_test.dart — good regression coverage for #20578: the widget test drives a 3-node fixture (a 'user'-labeled concept plus person 'Sam') and asserts 2 surviving nodes with both edges remapped to the single owner; the unit test covers the expanded label set including the 'tú' non-match guard.
  • app/changelog/unreleased/20261017-memory-graph-merge-owner-identity.json — fragment present.

One non-blocking nit to keep in mind: bare 'user' (and 'i') in the known-label set means an unrelated person or concept node that happens to carry that label will now merge into the owner node. That is exactly the intended behavior for backend 'user' nodes, and the blast radius of a false positive is one visually mis-merged node, not lost data — just worth remembering if odd merges get reported.

Performance: set lookups per node only, no new queries or algorithmic cost. Security/privacy: only local preferences are read; no new data leaves the device.

Note on review state: the earlier human approval was on the pre-rebase head; the only PR-file deltas since are the changelog fragment and a test refactor hoisting the fixture to a top-level helper — the merge logic itself is unchanged, and I verified it against the new head.

USER IMPACT: the memory graph no longer shows two "you" nodes (one 'user', one with your name) — all your edges now attach to a single owner node labeled with your given name.

Nothing further required from my side; leaving merge scheduling to maintainers.


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 the positive-signal Automation verified a genuine fix/quality contribution label Oct 17, 2026
@aryanorastar
aryanorastar self-requested a review October 20, 2026 02:51

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

Requesting changes on current head 890cc2f. The existing 9 graph widget tests passed, but three additional tests using backend-valid entity IDs reproduce false identity merges:

  • A distinct person sharing the saved full name disappears; its relationships are reassigned to the owner and the owner→person edge becomes a discarded self-loop.
  • Reversing response order selects that person's ID as the owner instead of canonical user.
  • A concept labeled I disappears together with its relationship.

This is display-only, not persisted deletion, but it violates #20578's explicit requirement to preserve legitimate people/content and their edges. The new label/full-name aliases at memory_graph_page.dart:482 are not sufficient identity evidence.

Before merging:

  1. Resolve the two current conflicts against latest main without replacing its shared memory_graph_identity.dart boundary, owner-only recovery, pagination/revision/session fences or 200-entity simulation limit.
  2. Remove name/pronoun-only identity merging and order-dependent owner selection. Use authoritative owner IDs/mapping; leave ambiguous entities distinct. If the reported named node is really the owner, establish that mapping rather than guessing from a saved name.
  3. Keep regression coverage for both input orders, same-full-name/same-given-name people, I concepts, and preservation of incident edge direction/labels. Rerun graph widget/API tests and analyzer after rebasing.

The separate shared-boundary fix and regression coverage are in #22845, commit e9b0cc2255. All three reproduced cases pass there, along with the additional identity/edge cases, 6,773 app tests (18 skipped), 138 protected contracts and 23 seeded journey tests. This PR can integrate that shared boundary and drop the superseded heuristic changes; there is no need to duplicate the implementation. Maintainers still own private payload/relaunch verification for #20578 before claiming full resolution. Neither PR has been merged or deployed by me.

kodjima33 pushed a commit that referenced this pull request Oct 20, 2026
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

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

Since my last review: my earlier pass on this head said no blocking issues — that conclusion is superseded. A maintainer review on the same head demonstrated false identity merges, and I verified them in the code: label/full-name/pronoun matching folds distinct entities into the owner (memory_graph_page.dart:482, 510-514), owner selection is response-order dependent (lines 492-499), and remapped owner-to-owner edges are silently dropped as self-loops (addUniqueEdge, line 553).

This needs work before merge — the merge heuristic over-matches, and the branch is 996 commits behind main.

Verified findings in app/lib/pages/memories/widgets/memory_graph_page.dart:

  1. False identity merges (blocking). isUserLikeNode treats any node whose display label is in knownUserLabels as the owner. That set now includes the saved full name and 'user'/'myself'/'i', so a distinct person who shares the user's full name, or a concept labeled 'I', is remapped into the owner and its node dropped (lines 510-514). Its relationships get reassigned to the owner, and the owner-to-person edge becomes a self-loop that addUniqueEdge silently discards (line 553) — the person and that relationship vanish from the graph. Display-only, nothing is persisted, but it loses real content, which is the opposite of #20578's intent.

  2. Order-dependent owner selection (blocking). primaryUserId is the first user-like node in backend response order (lines 492-499), with no preference for a canonical 'user' ID or authoritative mapping. Reversing the node list changes which entity becomes the anchor.

  3. Stale base. compare main...head is diverged (996 behind). Rebase first; please preserve main's newer memory-graph identity handling when resolving conflicts rather than taking this branch's heuristic wholesale.

What is good: the regression tests in app/test/widgets/memory_graph_empty_state_test.dart cover the happy path (duplicate 'user'-labeled node folds into the named owner, edges redirect), the 'tú' non-match guard is retained, the simulationForTesting exposure is a clean test seam, and the changelog fragment app/changelog/unreleased/20261017-memory-graph-merge-owner-identity.json is well-formed.

Suggested direction, matching the maintainer's ask: treat node_type/id aliases as identity evidence but drop display-label/full-name/pronoun-only matching (or require corroboration before merging), anchor the owner on authoritative owner IDs, and leave ambiguous entities distinct. Adding the maintainer's failing cases (full-name-sharing person, reversed order, concept labeled 'I') as tests would pin the behavior.

USER IMPACT: with this change, a person in your memory graph who happens to share your full name — or a topic labeled 'I'/'user' — could silently disappear from the mind map, their connections reattached to you; the fix's goal (one owner node) is right, the matching is too aggressive today.

Leaving for human maintainer review — the identity-matching semantics and the rebase conflict resolution against main's newer memory-graph work need a maintainer decision.


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

@Dragonire9

Copy link
Copy Markdown
Contributor Author

Withdrawing this pull request and closing it. For the record: I committed and engineered these fixes under the expectation of the repository's paid bug bounty program, not as unpaid open-source charity. All unmerged contributions are permanently withdrawn.

@Dragonire9 Dragonire9 closed this Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hey @Dragonire9 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mobile Memory Graph shows separate owner-like nodes labeled with given name and literal user

5 participants