[Canon] Per-graph permissions (read, use, approve) and default grant review

Abierto
#6,723 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
24/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
sql, typescript

Línea de trabajo

Start by reading plans/canon-master-plan.md Workstream 5 and the referenced SearchScopePermissionResolver.ts to understand the existing permission model. The issue identifies GraphEngine.ts, CanonGraphEngine.ts, the graph entity servers, Explorer, and the v6.2.x graph migration as affected areas, and calls for a separate plan covering schema, resolution, enforcement, caching, and Explorer updates. Done means per-graph Read, Use, and Approve access is enforced across the listed entry points, with the default grants and caching reviewed; the open design questions need resolution first.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

canon

What should Canon do that it does not do today?
Add per-graph permissions (Read, Use, Approve) modeled on MJ: Search Scope Permissions (SearchScopePermissionResolver), and review/tighten today's wide default grants across all MJ: Graph* entities so callers, agents, skills, and graph stewards can only read, traverse, or approve graphs they are authorized for.

Who needs it, and what goes wrong without it?
Today graph access is binary across the whole instance: Graph: Approve Edges is global across every graph, and every node/edge read relies solely on row-level permissions of the referenced target entities. In multi-tenant or multi-domain hosts (such as Betty hosting one Canon graph per customer organization alongside platform graphs):

  • A customer org admin cannot be granted permission to approve concepts or edges in their own organization's graph without handing them global Graph: Approve Edges across every tenant's graph.
  • GraphEngine has no graph-level Read or Use check before traversing a graph (Subgraph), running an agent/skill against it, or loading it in Explorer — so an organization's graph metadata or unanchored concepts/edges can be inspected or traversed across domain boundaries unless the host builds custom middleware.
  • migrations/v6/V202611022300__v6.2.x__Semantic_Graph_And_Graph_Concepts.sql seeds wide default Allow grants: UI (E0AFCCEC-6A37-EF11-86D4-000D3A4E707E) holds unfiltered CanRead = 1 on MJ: Graphs, MJ: Graph Concepts, MJ: Graph Edges, MJ: Graph Types, MJ: Graph Concept Types, MJ: Graph Authority Tiers, MJ: Graph Edge Types, MJ: Graph Edge Type Endpoints, and MJ: Graph Edge Providers, while Developer (DEAFCCEC-...) and Integration (DFAFCCEC-...) hold unfiltered 1/1/1/1; and GraphEngine.Config() (packages/MJCoreEntities/src/graph/GraphEngine.ts:241-250) bulk-caches all eight tables with CacheLocal: true in every browser and server process.

Which layer does it touch?

  • Governed data slices (alternate base views, queries)
  • Concepts and authority (graph concepts, edges, tiers)
  • Agent guardrails (canonical notes)
  • Executable procedures (skills, actions, workflows)
  • Schema (a new type, status, tier, edge type or column)

What existing work is it related to?

  • plans/canon-master-plan.md — Workstream 5 (5b)
  • Workstream 5a (MJGraphConceptEntityServer + GraphEngine.CanUserApproveGraph)
  • packages/SearchEngine/src/permissions/SearchScopePermissionResolver.ts (reference permission-resolver model)
  • migrations/v6/V202611022300__v6.2.x__Semantic_Graph_And_Graph_Concepts.sql (default grants)
  • packages/MJCoreEntities/src/graph/GraphEngine.ts & packages/MJCoreEntities/src/engines/CanonGraphEngine.ts

Rough size
Large (needs its own plan / schema migration + resolver + engine + Explorer updates).


Design Sketch

1. Schema & Permission Model (MJ: Graph Permissions)

Mirror __mj.SearchScopePermission cleanly (decided at monthly review + schema review before migration):

  • __mj.GraphPermission (MJ: Graph Permissions):
    • ID uniqueidentifier NOT NULL PK
    • GraphID uniqueidentifier NOT NULL FK -> __mj.Graph(ID)
    • UserID uniqueidentifier NULL FK -> __mj.User(ID) and RoleID uniqueidentifier NULL FK -> __mj.Role(ID) with CK_GraphPermission_Principal requiring (UserID IS NOT NULL AND RoleID IS NULL) OR (UserID IS NULL AND RoleID IS NOT NULL) (matching SearchScopePermission, unless denied explicitly)
    • PermissionLevel nvarchar(20) NOT NULL CHECK (PermissionLevel IN ('None', 'Read', 'Use', 'Approve')) (Approve > Use > Read > None; 'None' is an explicit deny overriding role grants for that graph/principal)
    • PrimaryScopeRecordID nvarchar(450) NULL + StartsAt datetimeoffset NULL / EndsAt datetimeoffset NULL for optional tenant/org scoping and time-boxed grants (matching MJSearchScopePermission)
  • Agent, Skill & Host RunScope Alignment (matching AIAgent.SearchScopeAccess / AISkill.SearchScopeAccess / RunActionParams.RunScope.SearchScopeIDs):
    • Add AIAgent.GraphAccess nvarchar(20) NULL CHECK IN ('None', 'Assigned', 'All') (NULL behaves as 'None' or explicit default decision at review), join entity MJ: AI Agent Graphs, and sibling AISkill.GraphAccess / MJ: AI Skill Graphs.
    • Support RunActionParams.RunScope.GraphIDs?: readonly string[] so a host (e.g., workspace/tenant/channel) can narrow which graphs an agent run may reach without ever widening past the calling user's own GraphPermission.
2. Replaceable GraphPermissionResolver (@RegisterClass Extension Point)

Follow the exact lesson captured in SearchScopePermissionResolver.ts:35:

  • Ship GraphPermissionResolver (BaseSingleton<GraphPermissionResolver> registered via @RegisterClass or DI lookup on @memberjunction/core-entities-server) evaluating a fail-closed decision tree for { User, GraphID, Agent, Skill, PrimaryScopeRecordID, HostAssignedGraphIDs }:
    1. Direct UserID grant (explicit 'None' denies regardless of role grants)
    2. Role grant across User.UserRoles (Approve > Use > Read; explicit 'None' overrides lower grants unless higher explicit user allow — pin exact deny-wins precedence matching SearchScopePermissionResolver)
    3. Agent / Skill GraphAccess ('None' rejects; 'Assigned' requires listing; 'All' acts only as fallback/intersection, never overriding an explicit 'None')
    4. Default 'NoGrant' -> denied (Allowed: false, Level: 'None')
  • Make GraphPermissionResolver subclassable via @RegisterClass so multi-tenant hosts (e.g., Betty using betty.Graph.OrganizationID + BCAuthorizationEngine org-admin tier) resolve Approve for an org admin on their own org's graph directly from host tenant/entitlement state without duplicating per-user permission rows.
3. Enforcement Seams
  • Read (Level >= 'Read'): Graph metadata, concepts, edges, and Explorer visualization (SemanticGraphExplorerComponent) refuse or withhold graphs where the caller lacks Read. Add RLS/PreRunView alignment or entity-server read enforcement rather than relying solely on client filtering.
  • Use (Level >= 'Use'): GraphEngine.Subgraph, CanonGraphEngine.FindConcepts / CanonContext / ExplainConcept / ExplainEntity, and graph tools/actions (Get Graph Context, Resolve Concepts, Find Graph Path, Explain Concept) filter candidate graphs to those where [caller, ...AudienceReaders] all hold Use.
  • Approve (Level === 'Approve'): Update MJGraphConceptEntityServer (5a) and MJGraphEdgeEntityServer so approval/deprecation/rejection/governed-edits succeed if the caller holds Graph: Approve Edges (global platform steward / Owner override) OR GraphPermissionResolver.CanApproveGraph(user, graphID, provider) returns Approve (except inside GRAPH_PIPELINE_EDGE_APPROVAL_OPERATION creates). Explorer (SemanticGraphExplorerComponent.CanApproveSelectedGraph) queries/checks the selected graph's effective permission rather than only checking the global authorization.
4. Default Grant & Caching Audit (V202611022300 & GraphEngine.Config())

Audit and plan backward-compatible tightening in the migration + code:

  • Reference catalogs (MJ: Graph Types, MJ: Graph Concept Types, MJ: Graph Authority Tiers, MJ: Graph Edge Types, MJ: Graph Edge Type Endpoints): static global vocabularies; UI CanRead = 1 is benign.
  • Instance / Tenant-bearing entities (MJ: Graphs, MJ: Graph Concepts, MJ: Graph Edges, MJ: Graph Edge Providers): today UI holds unfiltered CanRead = 1 on all four, allowing direct RunView against /graphql by any UI user to read all rows across every graph! Add documented RLS filters (RowLevelSecurityFilter) or graph-permission-aware server read scoping (MJGraph*EntityServer / ProviderBase hook) so direct RunView respects GraphPermission (Read) even outside GraphEngine.
  • GraphEngine.Config() (CacheLocal: true): Stop unconditionally caching the entire MJ: Graph Concepts table (CacheLocal: true) in every browser client; load OnDemand graphs' concepts server-side/per-graph and cache only public/permitted Preload graphs ("MJ Canon"), keyed appropriately.
5. Open Questions for Dec 3 Canon Review
  1. Should UI continue having read access to "MJ Canon" by default via a seeded GraphPermission row on "MJ Canon" for the UI role (Level = 'Use'), while newly created graphs default to private (NoGrant)?
  2. Should Graph: Approve Edges remain as the global platform steward override alongside per-graph Approve, or be deprecated once MJ: Graph Permissions ships?
  3. When SearchScope + Graph are paired in an agent run, should AISkill.SearchScopeAccess and AISkill.GraphAccess share one RunScope check pattern?
Lenguaje dominante
TSQL
Estrellas
32
Forks
7
Merge medio
1 d 16 h
PR fusionados (30 d)
504

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de MemberJunction/MJ

Todos los issues de MemberJunction/MJ

Issues similares

Más issues de Security

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.