@elevasis/core 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/index.d.ts +69 -159
  2. package/dist/index.js +324 -613
  3. package/dist/organization-model/index.d.ts +69 -159
  4. package/dist/organization-model/index.js +324 -613
  5. package/dist/test-utils/index.d.ts +192 -45
  6. package/dist/test-utils/index.js +260 -600
  7. package/package.json +1 -1
  8. package/src/__tests__/template-core-compatibility.test.ts +73 -91
  9. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +94 -182
  10. package/src/auth/multi-tenancy/index.ts +20 -17
  11. package/src/auth/multi-tenancy/memberships/api-schemas.ts +142 -126
  12. package/src/auth/multi-tenancy/memberships/index.ts +26 -22
  13. package/src/auth/multi-tenancy/permissions.test.ts +42 -0
  14. package/src/auth/multi-tenancy/permissions.ts +104 -0
  15. package/src/organization-model/README.md +102 -97
  16. package/src/organization-model/__tests__/defaults.test.ts +19 -6
  17. package/src/organization-model/__tests__/domains/resource-mappings.test.ts +24 -93
  18. package/src/organization-model/__tests__/graph.test.ts +82 -894
  19. package/src/organization-model/__tests__/resolve.test.ts +59 -690
  20. package/src/organization-model/__tests__/schema.test.ts +83 -407
  21. package/src/organization-model/contracts.ts +4 -3
  22. package/src/organization-model/defaults.ts +277 -141
  23. package/src/organization-model/domains/features.ts +31 -22
  24. package/src/organization-model/domains/navigation.ts +27 -20
  25. package/src/organization-model/foundation.ts +42 -54
  26. package/src/organization-model/graph/build.ts +42 -217
  27. package/src/organization-model/graph/index.ts +4 -4
  28. package/src/organization-model/graph/link.ts +10 -0
  29. package/src/organization-model/graph/schema.ts +21 -16
  30. package/src/organization-model/graph/types.ts +10 -10
  31. package/src/organization-model/helpers.ts +74 -0
  32. package/src/organization-model/index.ts +7 -7
  33. package/src/organization-model/organization-graph.mdx +89 -272
  34. package/src/organization-model/organization-model.mdx +152 -320
  35. package/src/organization-model/published.ts +20 -19
  36. package/src/organization-model/resolve.ts +8 -33
  37. package/src/organization-model/schema.ts +63 -205
  38. package/src/organization-model/types.ts +12 -11
  39. package/src/platform/constants/versions.ts +3 -3
  40. package/src/platform/registry/__tests__/command-view.test.ts +6 -5
  41. package/src/platform/registry/__tests__/resource-link.test.ts +30 -0
  42. package/src/platform/registry/__tests__/resource-registry.integration.test.ts +15 -15
  43. package/src/platform/registry/command-view.ts +10 -12
  44. package/src/platform/registry/index.ts +93 -93
  45. package/src/platform/registry/resource-link.ts +32 -0
  46. package/src/platform/registry/resource-registry.ts +917 -876
  47. package/src/platform/registry/serialization.ts +56 -73
  48. package/src/platform/registry/serialized-types.ts +17 -12
  49. package/src/platform/registry/types.ts +14 -43
  50. package/src/reference/_generated/contracts.md +94 -182
  51. package/src/reference/glossary.md +71 -105
  52. package/src/scaffold-registry/__tests__/index.test.ts +125 -1
  53. package/src/scaffold-registry/__tests__/schema.test.ts +48 -20
  54. package/src/scaffold-registry/index.ts +236 -188
  55. package/src/scaffold-registry/schema.ts +47 -22
  56. package/src/supabase/database.types.ts +2880 -2719
  57. package/src/test-utils/fixtures/memberships.ts +82 -80
  58. package/src/platform/registry/domains.ts +0 -165
@@ -1,272 +1,89 @@
1
- ---
2
- title: Organization Graph
3
- description: Organization OS Graph layer documentation for the Cytoscape-based organization graph, derived from the organization model and bridged with Command View runtime topology through the shared feature provider.
4
- ---
5
-
6
- ## Overview
7
-
8
- Within Organization OS, the organization graph is the dedicated **Graph** layer. It treats the organization model as the top-level ontology and bridges in Command View runtime topology so one graph can support semantic exploration and operations-oriented tracing. Command View is now one lens over this shared graph, not a separate live graph renderer.
9
-
10
- Graph contracts live in `@repo/core` alongside the organization model. Rendering lives in `@repo/ui` with Cytoscape.js. The command-center route is a thin wrapper over the shared page.
11
-
12
- ## Status
13
-
14
- First implementation slices are live end-to-end. Command View now delegates to the graph through a command-view lens preset. Layout iteration on the one-panel graph + command surface is ongoing; graph contracts and provider bridge are stable.
15
-
16
- Graph types are intentionally **not** part of the published `@elevasis/core` surface yet. Graph adoption remains monorepo-first.
17
-
18
- ## Source of Truth
19
-
20
- - `packages/core/src/organization-model/graph/types.ts` -- node/edge DTO shapes
21
- - `packages/core/src/organization-model/graph/schema.ts` -- runtime validation
22
- - `packages/core/src/organization-model/graph/build.ts` -- `buildOrganizationGraph(...)` derivation
23
- - `packages/core/src/organization-model/__tests__/graph.test.ts` -- derivation and bridge tests
24
- - `packages/ui/src/features/operations/OrganizationGraphPage.tsx` -- shared Cytoscape page
25
- - `packages/ui/src/features/operations/CommandViewPage.tsx` -- command-view lens delegating to the graph
26
- - `packages/ui/src/features/operations/organization-graph/` -- filter helpers, detail-state helpers, path tracing, operational summary
27
- - `packages/ui/src/features/operations/manifest.ts` -- `organizationGraph.surfaceId = 'operations.organization-graph'`
28
- - `apps/command-center/src/routes/operations/organization-graph.index.tsx` -- route wrapper
29
-
30
- ## Product Jobs
31
-
32
- The graph helps users:
33
-
34
- - orient themselves in the organization model
35
- - discover how features, capabilities, surfaces, entities, resources, and workflows connect
36
- - trace upstream/downstream dependencies
37
- - understand ownership and implementation boundaries
38
- - assess blast radius before changing a workflow, agent, feature, or integration
39
- - operate across strategy, operations, and debugging through different lenses on the same graph
40
-
41
- The graph does not replace workflow editors, execution-run visualizers, or builder-style authoring canvases. React Flow remains the better fit for editor/execution visuals; Cytoscape fits the exploration-oriented ontology graph.
42
-
43
- ## Architecture
44
-
45
- ### Unified graph model
46
-
47
- The implementation uses one typed graph, not separate semantic and implementation taxonomies.
48
-
49
- - Node kinds: `organization`, `feature`, `surface`, `entity`, `capability`, `resource`
50
- - Edge kinds: `contains`, `references`, `exposes`, `maps_to`
51
- - `resource` nodes carry `resourceType` metadata: `workflow`, `agent`, `trigger`, `integration`, `external`, or `human_checkpoint`
52
- - `references` edges may also carry `relationshipType`: `triggers`, `uses`, or `approval`
53
-
54
- This means runtime topology is represented as bridged `resource` nodes plus relationship metadata on shared edge types, rather than as a second disconnected edge/node vocabulary. `maps_to` is the main crossover edge: the builder emits it from organization-model resource mappings, and the UI presence helpers also treat it as topology-facing when classifying which non-resource nodes participate in runtime-adjacent views.
55
-
56
- ### Compatibility rules with the organization model
57
-
58
- - `OrganizationModelSchema` is the source of truth for semantic structure. The graph does not introduce a second ontology.
59
- - Graph node IDs and references reuse organization-model IDs wherever those IDs already exist.
60
- - `surface` nodes derive from `organizationModel.navigation.surfaces`; graph routing respects surface `path` and `defaultSurfaceId`.
61
- - Feature gating and labels respect `organizationModel.features.enabled` and `.labels`.
62
- - Implementation-resource bridging prefers `organizationModel.resourceMappings`.
63
- - Semantic grouping now comes from the unified `organizationModel.features` array. The builder no longer emits separate `domain` nodes.
64
- - Command View resource `domains` metadata is currently bridged onto `feature` references, not onto a distinct domain-node layer.
65
- - The 2026-04-20 reality-domain expansion (identity, customers, offerings, roles, goals, statuses, operations, techStack) does not introduce new graph node kinds. Those domains are model-layer data; they are not independently represented as graph nodes. They can be surfaced as metadata on the organization root node when a consumer needs to expose them through a graph lens.
66
- - Graph defaults remain valid when produced by `resolveOrganizationModel()`.
67
- - If the graph needs a concept the model cannot express, extend the model first.
68
-
69
- ### Shared DTO
70
-
71
- ```ts
72
- type OrganizationGraphNodeKind =
73
- | 'organization'
74
- | 'feature'
75
- | 'surface'
76
- | 'entity'
77
- | 'capability'
78
- | 'resource'
79
-
80
- type OrganizationGraphEdgeKind = 'contains' | 'references' | 'exposes' | 'maps_to'
81
-
82
- interface OrganizationGraph {
83
- version: 1
84
- organizationModelVersion: OrganizationModel['version']
85
- nodes: OrganizationGraphNode[]
86
- edges: OrganizationGraphEdge[]
87
- }
88
- ```
89
-
90
- `OrganizationGraphNode` also includes optional `sourceId`, `description`, `enabled`, `featureId`, `surfaceType`, and `resourceType`. `OrganizationGraphEdge` includes optional `label` and `relationshipType`.
91
-
92
- ### Build pipeline
93
-
94
- ```ts
95
- interface BuildOrganizationGraphInput {
96
- organizationModel: OrganizationModel
97
- commandViewData?: CommandViewData
98
- }
99
- ```
100
-
101
- `buildOrganizationGraph` accepts optional topology input so the semantic graph still renders when operational bridging is sparse. The derivation flow is additive and upsert-oriented:
102
-
103
- 1. Resolve the active organization model.
104
- 2. Derive semantic nodes and edges from features, surfaces, entities, capabilities, and resource mappings.
105
- 3. Upsert bridged runtime resources from Command View data into shared `resource` nodes.
106
- 4. Bridge Command View runtime topology onto the same DTO as `references` edges between `resource` nodes, using `relationshipType` for runtime relationship labels.
107
- 5. Hand the resulting graph to UI-level lensing, filtering, and Cytoscape projection.
108
-
109
- Keeping assembly outside the renderer keeps graph semantics testable without UI and prevents Cytoscape concepts from leaking into business logic.
110
-
111
- ### Ownership split
112
-
113
- - `@repo/core` owns normalized node/edge types, schemas, and build/derivation helpers.
114
- - `@repo/ui` owns Cytoscape element conversion, layout presets, selection state, path tracing, viewport mechanics, detail panels, and presentation helpers.
115
- - `apps/command-center` owns route wiring and page-level integration.
116
-
117
- ## Interaction Model
118
-
119
- ### Lenses
120
-
121
- The graph ships with two lens presets in UI code:
122
-
123
- - `default` -- title "Organization Graph", initial mode `map`, no preset filters
124
- - `command-view` -- title "Command View", initial mode `trace`, filters preset to `nodeKinds: ['resource']` and `topologyPresence: 'topology-only'`
125
-
126
- Lenses do not change the core DTO. They configure how the shared graph is initially presented.
127
-
128
- The command-view preset is intentionally narrow. It starts from topology-focused `resource` nodes so runtime traces stay readable, even though the underlying graph still contains semantic nodes and bridge edges.
129
-
130
- ### Modes
131
-
132
- - **Map mode** -- clustered for broad graph orientation
133
- - **Trace mode** -- directed layout that privileges path readability
134
- - **Impact mode** -- centered radial/concentric layout around the current focus
135
-
136
- Layouts are deterministic presets, not unconstrained force simulation:
137
-
138
- - `map` uses Cytoscape `cose`
139
- - `trace` uses directed `breadthfirst`
140
- - `impact` uses degree-based `concentric`
141
-
142
- ### Interactions
143
-
144
- Primary set in the current shared page:
145
-
146
- - click node for detail panel
147
- - click edge for relationship meaning
148
- - switch mode
149
- - highlight shortest directed paths between two visible nodes in trace mode
150
- - filter by node kind, topology presence, and free-text search
151
-
152
- Deferred: freeform node placement, collaborative annotations, graph editing/authoring, arbitrary canvas drawing.
153
-
154
- ### Filtering
155
-
156
- The filter state lives in `useOrganizationGraphFilters()` and the toolbar UI in `OrganizationGraphFilterToolbar`.
157
-
158
- Filter inputs:
159
-
160
- - `search`
161
- - `nodeKinds`
162
- - `topologyPresence: 'all' | 'semantic-only' | 'topology-only'`
163
-
164
- Presence is derived per node in UI helpers:
165
-
166
- - `resource` nodes are `topology-only`
167
- - non-resource nodes with only semantic edges are `semantic-only`
168
- - non-resource nodes with `maps_to` edges or runtime relationship edges alongside semantic edges are treated as `bridge` nodes internally
169
-
170
- `bridge` is an internal classification used by the filtering helpers. The public filter control only exposes `all`, `semantic-only`, and `topology-only`, so bridge nodes appear when presence is `all`.
171
-
172
- Search matches node IDs, labels, descriptions, source IDs, feature IDs, surface/resource types, edge labels, edge kinds, and `relationshipType`.
173
-
174
- The page applies `useDeferredValue()` to the active filters so graph search stays responsive while typing.
175
-
176
- ### Path tracing
177
-
178
- The visible Cytoscape surface projects a **filtered** shared graph DTO rather than rendering the full graph unconditionally. Path tracing resolves and highlights directed paths inside the current visible projection, so filtering and tracing stay coherent.
179
-
180
- Renderer-agnostic helpers under `packages/ui/src/features/operations/organization-graph/path-tracing/` implement shortest-path logic independent of Cytoscape.
181
-
182
- ## Provider Integration
183
-
184
- The graph is exposed through `ElevasisFeaturesProvider` rather than as app-local glue:
185
-
186
- - `FeatureModule.organizationGraph.surfaceId` declares a manifest's bridge point.
187
- - `operationsManifest` declares `organizationGraph.surfaceId = 'operations.organization-graph'`.
188
- - The provider resolves that against `organizationModel.navigation.surfaces` and exposes the result as `organizationGraph` in context.
189
- - Shared UI/operations code stays manifest-driven while remaining aware of semantic organization topology.
190
-
191
- This provider bridge resolves the canonical shared graph surface, not a Command View-specific surface. Command View still has its own navigation surface (`operations.command-view`), but the live page delegates into the shared graph renderer.
192
-
193
- ## Command View Integration
194
-
195
- `CommandViewPage` now delegates to `OrganizationGraphPage` through a command-view lens preset. The shared page adds command-view operational context through:
196
-
197
- - command-view summary cards rendered in `OrganizationGraphPage`
198
- - selection-aware resource and human-checkpoint summaries inside the shared graph detail panel
199
- - follow-up actions for recent executions and pending tasks inside the detail panel
200
- - dedicated command-view sidebar content alongside the shared graph controls
201
-
202
- Operational summary and drill-down derivation is covered by tests under `packages/ui/src/features/operations/organization-graph/__tests__/`.
203
-
204
- The detail experience is shared through `OrganizationGraphDetailPanel`, which can render both semantic context and command-view-specific follow-up sections.
205
-
206
- Keep the current seam explicit:
207
-
208
- - The graph canvas, selection model, path tracing, shared filters, and detail panel all live in `OrganizationGraphPage`.
209
- - `OperationsSidebarMiddle` still renders `CommandViewSidebarContent` for `/operations/command-view`.
210
- - That sidebar remains a companion operational panel with some legacy store/filter assumptions and is not the source of truth for the shared graph's filter state.
211
- - Older React Flow Command View code still exists in the repo, but it is no longer the live renderer for the current Command View route.
212
-
213
- ## Cytoscape Responsibility Split
214
-
215
- Cytoscape owns:
216
-
217
- - element rendering
218
- - compound/group visualization
219
- - neighborhood traversal and selection state
220
- - path highlighting
221
- - collapsed/expanded cluster behavior
222
- - layout execution
223
- - viewport mechanics (pan, zoom, fit, focus)
224
-
225
- React owns:
226
-
227
- - mode switching
228
- - side panels and inspectors
229
- - filter toolbar search and trace controls
230
- - route state and deep-linking
231
- - server data fetching
232
-
233
- ## Package Boundary
234
-
235
- - `packages/ui/package.json` declares Cytoscape on the published UI surface.
236
- - `packages/ui/tsup.config.ts` and `packages/ui/rollup.dts.config.mjs` keep Cytoscape **externalized** for publish output.
237
- - Graph DTO types, schemas, and builders live in monorepo `@repo/core` organization-model modules.
238
- - Cytoscape rendering, lens presets, filtering helpers, and detail/runtime presentation live in `@repo/ui`.
239
- - The published `@elevasis/core` wrapper still exposes only the narrow organization-model API; this graph contract should be treated as monorepo-internal for now.
240
-
241
- ## Theming
242
-
243
- The shared Cytoscape page reads CSS custom properties at runtime via `window.getComputedStyle(document.documentElement)`. Nodes, edges, overlays, and glass panels stay aligned with the active UI theme instead of relying on a fixed graph-only palette.
244
-
245
- ## Cytoscape States
246
-
247
- The renderer applies CSS-class-style state markers to highlight context and traces:
248
-
249
- - `.is-faded`
250
- - `.is-context`
251
- - `.is-selected`
252
- - `.is-connected`
253
- - `.is-trace-node`
254
- - `.is-trace-endpoint`
255
- - `.is-trace-edge`
256
-
257
- These classes drive neighborhood focus, selection emphasis, and trace-path highlighting without changing the underlying DTO.
258
-
259
- ## Migration Guardrails
260
-
261
- - Do not move canonical graph interfaces into `packages/ui`.
262
- - Do not redefine organization-model semantics in app-local graph config.
263
- - Do not make the graph contract depend on Cytoscape-specific types.
264
- - Existing Command View relationships bridge into `relationshipType = triggers | uses | approval` -- do not overload those operational labels with new semantic meaning.
265
-
266
- ## Verification
267
-
268
- - `pnpm --filter @repo/core test -- organization-model graph`
269
- - `pnpm --filter @repo/ui test -- commandViewDrillDown commandViewOperationalSummary organizationGraphDetail`
270
- - `pnpm --filter @repo/ui build`
271
- - `pnpm --filter @repo/ui build:publish`
272
- - `pnpm --filter command-center build`
1
+ ---
2
+ title: Organization Graph
3
+ description: Organization OS graph layer documentation for the organization graph derived from flat Organization Model features and resource metadata links.
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ The organization graph treats the organization model as the top-level ontology and bridges in Command View runtime topology. Command View is a lens over the shared graph, not a separate semantic model.
9
+
10
+ Graph contracts live in `@repo/core`; rendering lives in `@repo/ui`.
11
+
12
+ ## Source of Truth
13
+
14
+ - `packages/core/src/organization-model/graph/types.ts`
15
+ - `packages/core/src/organization-model/graph/schema.ts`
16
+ - `packages/core/src/organization-model/graph/build.ts`
17
+ - `packages/core/src/organization-model/graph/link.ts`
18
+ - `packages/core/src/organization-model/__tests__/graph.test.ts`
19
+ - `packages/ui/src/features/operations/OrganizationGraphPage.tsx`
20
+ - `packages/ui/src/features/operations/organization-graph/`
21
+
22
+ ## Model
23
+
24
+ Node kinds:
25
+
26
+ - `organization`
27
+ - `feature`
28
+ - `entity`
29
+ - `capability`
30
+ - `resource`
31
+ - `integration`
32
+
33
+ Edge kinds:
34
+
35
+ - `contains`
36
+ - `references`
37
+ - `exposes`
38
+ - `maps_to`
39
+ - `operates-on`
40
+ - `uses`
41
+
42
+ Feature nodes come from the flat `OrganizationModel.features` array. Their graph IDs use `feature:<id>`, such as `feature:sales.crm`.
43
+
44
+ Resource edges come from resource metadata:
45
+
46
+ ```ts
47
+ links: [
48
+ { nodeId: 'feature:sales.lead-gen', kind: 'operates-on' },
49
+ { nodeId: 'integration:instantly', kind: 'uses' }
50
+ ]
51
+ ```
52
+
53
+ ## Build Pipeline
54
+
55
+ ```ts
56
+ interface BuildOrganizationGraphInput {
57
+ organizationModel: OrganizationModel
58
+ commandViewData?: CommandViewData
59
+ }
60
+ ```
61
+
62
+ `buildOrganizationGraph`:
63
+
64
+ 1. Reads flat Organization Model features and derives `feature:*` nodes.
65
+ 2. Reads entities, capabilities, integrations, and resources.
66
+ 3. Emits authored graph links from resource/entity/capability metadata.
67
+ 4. Bridges Command View runtime topology into resource nodes and relationship edges.
68
+ 5. Returns a renderer-agnostic DTO.
69
+
70
+ ## Lenses
71
+
72
+ UI lenses change presentation, not data:
73
+
74
+ - `default` -- broad map view.
75
+ - `command-view` -- operations-focused trace view.
76
+
77
+ ## Package Boundary
78
+
79
+ - `@repo/core` owns graph DTOs, schemas, and build helpers.
80
+ - `@repo/ui` owns Cytoscape conversion, filtering, path tracing, panels, and presentation.
81
+ - `apps/command-center` owns route wiring.
82
+
83
+ ## Verification
84
+
85
+ ```bash
86
+ pnpm --filter @repo/core test -- organization-model graph
87
+ pnpm --filter @repo/ui test -- organizationGraph
88
+ pnpm --filter command-center build
89
+ ```