LearnNewsExamplesServices
Frontmatter
id10310
titlefeat(memory-core): Implement sharedEntity flag for Graph Node RLS bypass
stateClosed
labels[]
assignees[]
createdAtApr 25, 2026, 1:32 AM
updatedAtApr 25, 2026, 6:49 AM
githubUrlhttps://github.com/neomjs/neo/issues/10310
authorneo-gemini-pro
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtApr 25, 2026, 6:49 AM

feat(memory-core): Implement sharedEntity flag for Graph Node RLS bypass

neo-gemini-pro
neo-gemini-pro commented on Apr 25, 2026, 1:32 AM

Subsystem

Memory Core (GraphService / SQLite Storage)

Description

Context: In PR #10308, we fixed cross-process message retrieval (A2A Mailbox) by explicitly setting userId: null for MESSAGE nodes. This bypasses the Row-Level Security (RLS) in SQLite.loadNodeVicinitySync (user_id = ? OR user_id IS NULL).

Problem: Using userId: null is an implicit wildcard bypass. It obscures the provenance of who actually created the node, forcing us to rely purely on edges (like SENDER) to determine the original author. This breaks the expected contract that userId tracks node authorship in multi-tenant environments.

Proposal: Introduce an explicit sharedEntity: true boolean flag in the Graph Node schema properties. Modify the SQLite RLS layer to check user_id = ? OR json_extract(properties, '$.sharedEntity') = 1. Retain the actual author's ID in the user_id column for accurate provenance tracking.

The Architectural "Why"

  • Provenance Integrity: Nodes should inherently record who spawned them. userId: null destroys this metadata.
  • Explicit Security Intent: A sharedEntity property explicitly signals that a node is meant to be visible across isolation boundaries, making security audits straightforward.
  • Future-proofing: Multi-tenant memory architectures need explicit permission models, not wildcard hacks.

Avoided Traps

  • Performance Hit: Be cautious with json_extract in the WHERE clause if the graph grows large. We may need to index the sharedEntity extraction or add a dedicated column to the SQLite nodes table instead of storing it inside properties if performance degrades.
  • Retroactive Migration: Do not write heavy migrations for existing MESSAGE nodes. Just treat user_id IS NULL as a legacy fallback for sharedEntity: true alongside the new flag.

Definition of Done

  • Schema definition for sharedEntity on Graph Nodes is added and documented.
  • SQLite.mjs backend query logic is updated to support sharedEntity.
  • MailboxService.mjs is refactored to set sharedEntity: true and populate userId properly, rather than setting userId: null.
  • Ensure unit tests cover cross-tenant visibility of shared entities.
tobiu referenced in commit e8b5930 - "feat(memory-core): Implement sharedEntity flag for Graph Node RLS bypass (#10310) (#10325) on Apr 25, 2026, 6:49 AM
tobiu closed this issue on Apr 25, 2026, 6:49 AM