@elevasis/sdk 1.45.0 → 1.46.0

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 (38) hide show
  1. package/dist/cli.cjs +36046 -31587
  2. package/dist/index.d.ts +833 -391
  3. package/dist/index.js +59 -59
  4. package/dist/node/index.d.ts +0 -84
  5. package/dist/node/index.js +2 -2
  6. package/dist/test-utils/index.d.ts +859 -331
  7. package/dist/test-utils/index.js +166 -134
  8. package/dist/worker/index.d.ts +897 -324
  9. package/dist/worker/index.js +68 -35
  10. package/package.json +4 -4
  11. package/reference/_navigation.md +11 -2
  12. package/reference/_reference-manifest.json +42 -0
  13. package/reference/core/exports.mdx +2 -0
  14. package/reference/packages/core/src/business/README.md +4 -1
  15. package/reference/packages/core/src/content/README.md +19 -0
  16. package/reference/packages/core/src/organization-model/README.md +148 -149
  17. package/reference/packages/core/src/organization-model/readiness/README.md +42 -0
  18. package/reference/packages/ui/src/features/README.md +28 -28
  19. package/reference/rules/shared-types.md +21 -0
  20. package/reference/scaffold/core/organization-graph.mdx +2 -3
  21. package/reference/scaffold/core/organization-model.mdx +2 -6
  22. package/reference/scaffold/operations/propagation-pipeline.md +15 -16
  23. package/reference/scaffold/operations/scaffold-maintenance.md +3 -2
  24. package/reference/scaffold/operations/workflow-recipes.md +2 -2
  25. package/reference/scaffold/recipes/customize-crm-actions.md +5 -5
  26. package/reference/scaffold/recipes/extend-content.md +265 -0
  27. package/reference/scaffold/recipes/extend-lead-gen.md +14 -16
  28. package/reference/scaffold/recipes/index.md +4 -1
  29. package/reference/scaffold/reference/contracts.md +18 -55
  30. package/reference/scaffold/reference/feature-registry.md +3 -0
  31. package/reference/scaffold/reference/glossary.md +1 -1
  32. package/reference/scaffold/ui/customization.md +2 -2
  33. package/reference/scaffold/ui/feature-shell.mdx +1 -3
  34. package/reference/sdk/cli-management.mdx +90 -5
  35. package/reference/sdk/cli.mdx +90 -13
  36. package/reference/sdk/framework/agent.mdx +6 -0
  37. package/reference/sdk/platform-tools/adapters-platform.mdx +3 -1
  38. package/reference/ui/exports.mdx +1 -0
@@ -1,149 +1,148 @@
1
- # Organization Model
2
-
3
- The organization model is the published semantic contract that maps a tenant's System hierarchy, shell navigation, business semantics, resource governance, and graph bindings.
4
-
5
- Use this module when resolving or validating an organization's contract before wiring UI shells, routing, system gates, or domain-specific capability checks.
6
-
7
- ## Published Exports
8
-
9
- The public entry point exposes:
10
-
11
- - `OrganizationModelSchema`
12
- - `DEFAULT_ORGANIZATION_MODEL`
13
- - `defineOrganizationModel`
14
- - `resolveOrganizationModel`
15
- - `createFoundationOrganizationModel`
16
- - node ID and System helper types
17
- - `OrganizationModel` and supporting domain types
18
-
19
- Import it from the published subpath:
20
-
21
- ```ts
22
- import {
23
- DEFAULT_ORGANIZATION_MODEL,
24
- createFoundationOrganizationModel,
25
- defineOrganizationModel,
26
- resolveOrganizationModel,
27
- type OrganizationModel
28
- } from '@elevasis/core/organization-model'
29
- ```
30
-
31
- ## Contract Shape
32
-
33
- The model is versioned and currently validates against `version: 1`.
34
-
35
- Top-level fields:
36
-
37
- - `version`
38
- - `domainMetadata`
39
- - `branding`
40
- - `navigation`
41
- - `sales`
42
- - `prospecting`
43
- - `projects`
44
- - `identity`
45
- - `customers`
46
- - `offerings`
47
- - `roles`
48
- - `goals`
49
- - `systems`
50
- - `resources`
51
- - `capabilities`
52
- - `policies`
53
- - `statuses`
54
- - `knowledge`
55
-
56
- The pure collection domains are id-keyed maps: `systems`, `roles`, `goals`, `customers`, `offerings`, `resources`, `capabilities`, `policies`, and `statuses`. The map key must match the entry `id`. Entries carry `order` for deterministic ordered views; use `listDomain(record)` when order matters.
57
-
58
- Resource identity is authored in `resources`. Runtime workflows, agents, integrations, and scripts import those descriptors, derive `resourceId` and kind from them, and attach executable behavior in operations code.
59
-
60
- ## System Set
61
-
62
- System hierarchy is authored as an id-keyed `systems` map. Dotted IDs and `parentSystemId` define parent/child relationships:
63
-
64
- ```ts
65
- systems: {
66
- dashboard: { id: 'dashboard', order: 10, label: 'Dashboard', lifecycle: 'active' },
67
- sales: { id: 'sales', order: 20, label: 'Sales', lifecycle: 'active' },
68
- clients: { id: 'clients', order: 30, label: 'Clients', lifecycle: 'active' },
69
- projects: { id: 'projects', order: 40, label: 'Projects', lifecycle: 'active' }
70
- }
71
- ```
72
-
73
- Systems describe semantic ownership, hierarchy, lifecycle, access, and governance. Sidebar presentation is authored separately under `navigation.sidebar`; UI-backed Systems may still provide `ui.path` for route matching during the migration, but they do not author composed surface lists. Lifecycle values such as `active`, `beta`, `deprecated`, and `archived` replace the old feature enabled/dev-only split.
74
-
75
- ## Sidebar Navigation
76
-
77
- Shell navigation is authored as a recursive sidebar tree:
78
-
79
- ```ts
80
- navigation: {
81
- sidebar: {
82
- primary: {
83
- dashboard: {
84
- type: 'surface',
85
- order: 10,
86
- label: 'Dashboard',
87
- path: '/',
88
- surfaceType: 'dashboard',
89
- targets: { systems: ['dashboard'] }
90
- },
91
- business: {
92
- type: 'group',
93
- order: 20,
94
- label: 'Business',
95
- children: {
96
- clients: {
97
- type: 'surface',
98
- order: 20,
99
- label: 'Clients',
100
- path: '/clients',
101
- surfaceType: 'list',
102
- targets: { systems: ['clients'] }
103
- }
104
- }
105
- }
106
- },
107
- bottom: {}
108
- }
109
- }
110
- ```
111
-
112
- Routeable sidebar leaves are projected into flat semantic surface DTOs by `projectOrganizationSurfaces(model)`. Do not author top-level `surfaces` or `navigationGroups` fields on `OrganizationModel`.
113
-
114
- ## Graph IDs
115
-
116
- Cross-collection links use kind-prefixed IDs:
117
-
118
- - `system:sales.crm`
119
- - `integration:instantly`
120
- - `resource:lead-import`
121
- - `action:operations.queue.review`
122
-
123
- ## Resource Descriptors
124
-
125
- The OM Resources domain is governance-only. Descriptors declare canonical `id`, required `systemPath`, governance `status`, and optional role ownership. `DeploymentSpec` remains the runtime/deploy assembly around those descriptors, not a second resource identity catalog.
126
-
127
- ## Resolution Semantics
128
-
129
- - `defineOrganizationModel()` is a typed helper.
130
- - `resolveOrganizationModel()` deep-merges a partial override into the default model, then validates it.
131
- - `createFoundationOrganizationModel()` resolves the canonical model and returns UI-facing helper outputs.
132
- - Plain objects merge recursively.
133
- - Id-keyed domain maps merge additively by key.
134
- - Arrays replace the default value.
135
- - Missing fields fall back to `DEFAULT_ORGANIZATION_MODEL`.
136
-
137
- ## Referential Integrity
138
-
139
- - System IDs must be unique.
140
- - Child System IDs require valid ancestors or `parentSystemId` links.
141
- - Systems with UI provide `ui.path`.
142
- - Systems, resources, roles, knowledge nodes, and goals must resolve their declared cross-references.
143
-
144
- ## Practical Guidance
145
-
146
- - Use `resolveOrganizationModel()` when you need a runtime-safe model.
147
- - Use `defineOrganizationModel()` when authoring static overrides.
148
- - Keep System IDs stable because shell routing, gating, breadcrumbs, and docs depend on them.
149
- - Put resource identity and governance in `resources`; attach executable behavior in operations.
1
+ # Organization Model
2
+
3
+ The organization model is the published semantic contract that maps a tenant's System hierarchy, shell navigation, business semantics, resource governance, and graph bindings.
4
+
5
+ Use this module when resolving or validating an organization's contract before wiring UI shells, routing, system gates, or domain-specific capability checks.
6
+
7
+ ## Published Exports
8
+
9
+ The public entry point exposes:
10
+
11
+ - `OrganizationModelSchema`
12
+ - `DEFAULT_ORGANIZATION_MODEL`
13
+ - `defineOrganizationModel`
14
+ - `resolveOrganizationModel`
15
+ - `createFoundationOrganizationModel`
16
+ - node ID and System helper types
17
+ - `OrganizationModel` and supporting domain types
18
+
19
+ Import it from the published subpath:
20
+
21
+ ```ts
22
+ import {
23
+ DEFAULT_ORGANIZATION_MODEL,
24
+ createFoundationOrganizationModel,
25
+ defineOrganizationModel,
26
+ resolveOrganizationModel,
27
+ type OrganizationModel
28
+ } from '@elevasis/core/organization-model'
29
+ ```
30
+
31
+ ## Contract Shape
32
+
33
+ The model is versioned and currently validates against `version: 1`.
34
+
35
+ Top-level fields:
36
+
37
+ - `version`
38
+ - `domainMetadata`
39
+ - `branding`
40
+ - `navigation`
41
+ - `sales`
42
+ - `prospecting`
43
+ - `projects`
44
+ - `identity`
45
+ - `customers`
46
+ - `offerings`
47
+ - `roles`
48
+ - `goals`
49
+ - `systems`
50
+ - `resources`
51
+ - `capabilities`
52
+ - `statuses`
53
+ - `knowledge`
54
+
55
+ The pure collection domains are id-keyed maps: `systems`, `roles`, `goals`, `customers`, `offerings`, `resources`, `capabilities`, and `statuses`. The map key must match the entry `id`. Entries carry `order` for deterministic ordered views; use `listDomain(record)` when order matters.
56
+
57
+ Resource identity is authored in `resources`. Runtime workflows, agents, integrations, and scripts import those descriptors, derive `resourceId` and kind from them, and attach executable behavior in operations code.
58
+
59
+ ## System Set
60
+
61
+ System hierarchy is authored as an id-keyed `systems` map. Dotted IDs and `parentSystemId` define parent/child relationships:
62
+
63
+ ```ts
64
+ systems: {
65
+ dashboard: { id: 'dashboard', order: 10, label: 'Dashboard', lifecycle: 'active' },
66
+ sales: { id: 'sales', order: 20, label: 'Sales', lifecycle: 'active' },
67
+ clients: { id: 'clients', order: 30, label: 'Clients', lifecycle: 'active' },
68
+ projects: { id: 'projects', order: 40, label: 'Projects', lifecycle: 'active' }
69
+ }
70
+ ```
71
+
72
+ Systems describe semantic ownership, hierarchy, lifecycle, access, and governance. Sidebar presentation is authored separately under `navigation.sidebar`; UI-backed Systems may still provide `ui.path` for route matching during the migration, but they do not author composed surface lists. Lifecycle values such as `active`, `beta`, `deprecated`, and `archived` replace the old feature enabled/dev-only split.
73
+
74
+ ## Sidebar Navigation
75
+
76
+ Shell navigation is authored as a recursive sidebar tree:
77
+
78
+ ```ts
79
+ navigation: {
80
+ sidebar: {
81
+ primary: {
82
+ dashboard: {
83
+ type: 'surface',
84
+ order: 10,
85
+ label: 'Dashboard',
86
+ path: '/',
87
+ surfaceType: 'dashboard',
88
+ targets: { systems: ['dashboard'] }
89
+ },
90
+ business: {
91
+ type: 'group',
92
+ order: 20,
93
+ label: 'Business',
94
+ children: {
95
+ clients: {
96
+ type: 'surface',
97
+ order: 20,
98
+ label: 'Clients',
99
+ path: '/clients',
100
+ surfaceType: 'list',
101
+ targets: { systems: ['clients'] }
102
+ }
103
+ }
104
+ }
105
+ },
106
+ bottom: {}
107
+ }
108
+ }
109
+ ```
110
+
111
+ Routeable sidebar leaves are projected into flat semantic surface DTOs by `projectOrganizationSurfaces(model)`. Do not author top-level `surfaces` or `navigationGroups` fields on `OrganizationModel`.
112
+
113
+ ## Graph IDs
114
+
115
+ Cross-collection links use kind-prefixed IDs:
116
+
117
+ - `system:sales.crm`
118
+ - `integration:instantly`
119
+ - `resource:lead-import`
120
+ - `action:operations.queue.review`
121
+
122
+ ## Resource Descriptors
123
+
124
+ The OM Resources domain is governance-only. Descriptors declare canonical `id`, required `systemPath`, governance `status`, and optional role ownership. `DeploymentSpec` remains the runtime/deploy assembly around those descriptors, not a second resource identity catalog.
125
+
126
+ ## Resolution Semantics
127
+
128
+ - `defineOrganizationModel()` is a typed helper.
129
+ - `resolveOrganizationModel()` deep-merges a partial override into the default model, then validates it.
130
+ - `createFoundationOrganizationModel()` resolves the canonical model and returns UI-facing helper outputs.
131
+ - Plain objects merge recursively.
132
+ - Id-keyed domain maps merge additively by key.
133
+ - Arrays replace the default value.
134
+ - Missing fields fall back to `DEFAULT_ORGANIZATION_MODEL`.
135
+
136
+ ## Referential Integrity
137
+
138
+ - System IDs must be unique.
139
+ - Child System IDs require valid ancestors or `parentSystemId` links.
140
+ - Systems with UI provide `ui.path`.
141
+ - Systems, resources, roles, knowledge nodes, and goals must resolve their declared cross-references.
142
+
143
+ ## Practical Guidance
144
+
145
+ - Use `resolveOrganizationModel()` when you need a runtime-safe model.
146
+ - Use `defineOrganizationModel()` when authoring static overrides.
147
+ - Keep System IDs stable because shell routing, gating, breadcrumbs, and docs depend on them.
148
+ - Put resource identity and governance in `resources`; attach executable behavior in operations.
@@ -0,0 +1,42 @@
1
+ # System Interface Readiness
2
+
3
+ The readiness engine answers one question: is a given System's declared interface actually usable, or is something in the tenant's organization model missing or malformed? `computeInterfaceReadiness` produces a structured result rather than a boolean, so a caller can report which family of issue blocked the interface instead of failing opaquely.
4
+
5
+ Use this module when gating an API surface on a System's adoption state, or when registering a readiness profile that carries real structural validation logic.
6
+
7
+ ## Two registration functions, and only one of them validates
8
+
9
+ This is the distinction that most often gets it wrong, so it is worth stating plainly:
10
+
11
+ - **`registerBuiltInReadinessProfile`** (this module) registers a profile **with a validator**. It is the extension point that makes `isBuiltInReadinessProfile` return true.
12
+ - **`registerReadinessProfile`** (in `../domains/systems`) only acknowledges a custom profile id. It registers no validator, writes `kind: 'custom'`, and can **never** make a profile resolve as built-in.
13
+
14
+ Calling the second one and expecting the first one's effect is a silent no-op — declaring a readiness contract on the System remains mandatory. Only `registerBuiltInReadinessProfile` changes what validation runs.
15
+
16
+ ## Published Exports
17
+
18
+ ```ts
19
+ import {
20
+ computeInterfaceReadiness,
21
+ registerBuiltInReadinessProfile,
22
+ getBuiltInReadinessProfile,
23
+ registerReadinessInterfaceMarker,
24
+ resolveReadinessInterfaceMarker,
25
+ SystemInterfaceReadinessError,
26
+ type SystemInterfaceReadinessIssue,
27
+ type SystemInterfaceReadinessIssueFamily,
28
+ type SystemInterfaceReadinessRequest,
29
+ type SystemInterfaceReadinessResult,
30
+ type ReadinessProfileRegistration,
31
+ type ReadinessProfileValidator,
32
+ type ReadinessOntologyIndex,
33
+ type ReadinessInterfaceMarkerResolver,
34
+ type SystemInterfaceMarker
35
+ } from '@elevasis/core/organization-model/readiness'
36
+ ```
37
+
38
+ This subpath exists so the extension point can be reached without pulling in the rest of `@elevasis/core`. It points at the same module workspace consumers import, deliberately — the two surfaces cannot drift apart.
39
+
40
+ ## Layering constraint
41
+
42
+ Nothing under `readiness/` may import from `business/**`. The engine is generic; the lead-gen and CRM profile validators are registered **into** it by `business/acquisition` at module load, never the other way around. Adding a `business/` import here inverts the dependency the extraction exists to enforce.
@@ -1,28 +1,28 @@
1
- # Features
2
-
3
- Feature subpaths package complete shell-level UI flows for downstream apps.
4
-
5
- ## Published Feature Surfaces
6
-
7
- - `./features/auth`
8
- - `./features/crm`
9
- - `./features/dashboard`
10
- - `./features/delivery`
11
- - `./features/lead-gen`
12
- - `./features/operations`
13
- - `./features/monitoring`
14
- - `./features/seo`
15
- - `./features/settings`
16
-
17
- ## What They Contain
18
-
19
- - Route shells and page-level components
20
- - Sidebars and feature-specific navigation
21
- - Feature manifests for registry consumers
22
- - Feature-specific hooks and shared constants
23
-
24
- ## Notes
25
-
26
- - These surfaces are meant for app composition, not for low-level design-system primitives.
27
- - Some feature exports are also re-exported through `./components` for convenience in legacy or mixed consumers.
28
-
1
+ # Features
2
+
3
+ Feature subpaths package complete shell-level UI flows for downstream apps.
4
+
5
+ ## Published Feature Surfaces
6
+
7
+ - `./features/auth`
8
+ - `./features/content`
9
+ - `./features/crm`
10
+ - `./features/dashboard`
11
+ - `./features/delivery`
12
+ - `./features/lead-gen`
13
+ - `./features/operations`
14
+ - `./features/monitoring`
15
+ - `./features/seo`
16
+ - `./features/settings`
17
+
18
+ ## What They Contain
19
+
20
+ - Route shells and page-level components
21
+ - Sidebars and feature-specific navigation
22
+ - Feature manifests for registry consumers
23
+ - Feature-specific hooks and shared constants
24
+
25
+ ## Notes
26
+
27
+ - These surfaces are meant for app composition, not for low-level design-system primitives.
28
+ - Some feature exports are also re-exported through `./components` for convenience in legacy or mixed consumers.
@@ -27,6 +27,27 @@ Keep this as a standalone rule because it autoloads only for `core/types/**` edi
27
27
  - Browser APIs or Node-specific APIs
28
28
  - Implementation logic -- types and constants only
29
29
 
30
+ ## Organization Model Vocabulary Is Not a Shared Constant
31
+
32
+ "Shared constants" above means values with no home in the Organization Model. It does **not** mean model vocabulary. Stage keys, step ids, action keys, catalog entries, pipeline states, and enumerations like employee-size ranges are **model-owned**, and copying them into `core/types/` is architecturally excluded — not merely discouraged.
33
+
34
+ The reason is ownership: every project owns its own Organization Model, so a TypeScript constant can only ever encode one project's vocabulary. It cannot be shared substrate, and it silently diverges the moment the model changes, with no gate comparing the two. The platform ruled this out for itself as well and deleted its own copy of this mirror; do not reintroduce the pattern here.
35
+
36
+ Read the vocabulary from the resolved model instead — the catalog helpers and config hooks exist for exactly this.
37
+
38
+ ### The four-place contract
39
+
40
+ One build-step id has to be spelled identically in four places, and **nothing compares them**:
41
+
42
+ | Place | What it holds |
43
+ | ------------------------------ | ---------------------------------------------- |
44
+ | the workflow contract | the step id the handler dispatches on |
45
+ | the OM `template-step` catalog | the same id as a catalog entry |
46
+ | the resource ontology bindings | the actions and catalogs the resource declares |
47
+ | the UI action keys | the key the surface invokes |
48
+
49
+ A mismatch is not a type error. It surfaces at runtime as a step that never matches or an action that never fires, which is why the id is worth checking against all four before authoring downstream of it.
50
+
30
51
  ## Schema Convention
31
52
 
32
53
  Define Zod schemas first, then infer the type:
@@ -35,7 +35,6 @@ Node kinds:
35
35
  - `event`
36
36
  - `resource`
37
37
  - `knowledge`
38
- - `policy`
39
38
  - `stage`
40
39
  - `customer-segment`
41
40
  - `offering`
@@ -72,7 +71,7 @@ Edge kinds:
72
71
 
73
72
  System nodes come from the id-keyed `OrganizationModel.systems` map. Their graph IDs use `system:<id>`, such as `system:sales.crm`.
74
73
 
75
- Resource, action, entity, policy, navigation, and ontology catalog edges are derived from canonical OM maps:
74
+ Resource, action, entity, navigation, and ontology catalog edges are derived from canonical OM maps:
76
75
 
77
76
  ```ts
78
77
  // ResourceEntry.systemPath => system -> resource contains
@@ -101,7 +100,7 @@ interface BuildOrganizationGraphInput {
101
100
 
102
101
  1. Reads Organization Model Systems and derives `system:*` nodes.
103
102
  2. Reads OM resources, including workflow, agent, integration, and script resources, as `resource` nodes.
104
- 3. Emits derived graph links from System, Resource, Action, Entity, Policy, Agent invocation, Knowledge, navigation, and ontology catalog contracts.
103
+ 3. Emits derived graph links from System, Resource, Action, Entity, Agent invocation, Knowledge, navigation, and ontology catalog contracts.
105
104
  4. Bridges Command View runtime topology into resource nodes and relationship edges.
106
105
  5. Returns a renderer-agnostic DTO.
107
106
 
@@ -43,10 +43,9 @@ Top-level fields on `OrganizationModel`:
43
43
  - `topology`
44
44
  - `actions`
45
45
  - `entities`
46
- - `policies`
47
46
  - `knowledge`
48
47
 
49
- The pure collection domains are id-keyed maps: `systems`, `roles`, `goals`, `clients`, `customers`, `offerings`, `resources`, `actions`, `entities`, `policies`, and `knowledge`. `ontology` is an `OntologyScope` object (not an id-keyed map at the top level) and `topology` is a relationships record. The map key must match the entry `id` for id-keyed domains. Entries carry `order` for deterministic ordered views; use `listDomain(record)` when order matters. `sales`, `prospecting`, `projects`, and `statuses` were removed from the top-level contract; do not author against them.
48
+ The pure collection domains are id-keyed maps: `systems`, `roles`, `goals`, `clients`, `customers`, `offerings`, `resources`, `actions`, `entities`, and `knowledge`. `ontology` is an `OntologyScope` object (not an id-keyed map at the top level) and `topology` is a relationships record. The map key must match the entry `id` for id-keyed domains. Entries carry `order` for deterministic ordered views; use `listDomain(record)` when order matters. `sales`, `prospecting`, `projects`, `statuses`, and `policies` were removed from the top-level contract; do not author against them.
50
49
 
51
50
  Resource identity is authored inside `OrganizationModel.resources`. Runtime workflows, agents, integrations, and scripts import those descriptors, derive `resourceId` and kind from them, and attach executable behavior in operations code.
52
51
 
@@ -74,11 +73,9 @@ Authored fields:
74
73
  - `parentSystemId`
75
74
  - `ui`
76
75
  - `lifecycle`
77
- - `requiresAdmin`
78
76
  - `responsibleRoleId`
79
77
  - `governedByKnowledge`
80
78
  - `actions`
81
- - `policies`
82
79
  - `drivesGoals`
83
80
  - `apiInterface`
84
81
  - `config`
@@ -169,7 +166,7 @@ export const resourceDescriptors = defineResources({
169
166
  },
170
167
  codeRefs: [
171
168
  {
172
- path: 'packages/elevasis-operations/src/sales/prospecting/scrape/apollo-import.ts',
169
+ path: 'packages/elevasis/operations/src/sales/prospecting/scrape/apollo-import.ts',
173
170
  role: 'entrypoint',
174
171
  symbol: 'lgnApolloImportWorkflow'
175
172
  }
@@ -195,7 +192,6 @@ The model keeps business semantics in named domains:
195
192
  - `actions` -- stable business verbs exposed or consumed by systems
196
193
  - `entities` -- durable business nouns and their semantic links
197
194
  - `resources` -- governance-only workflow, agent, integration, and script descriptors
198
- - `policies` -- operational governance rules over systems, actions, resources, and roles
199
195
  - `knowledge` -- playbooks, strategies, references, and graph-governing links
200
196
 
201
197
  System-local operational catalogs live under `System.ontology.catalogTypes`, including pipeline, stage, template, template-step, status-flow, and status records. System-local settings live in `System.config`. The legacy compound and status domains should not be used for new authoring.
@@ -31,19 +31,18 @@ Layer 3: Sync Verification (pnpm sync:verify)
31
31
 
32
32
  ## Layer 1: Source Generation
33
33
 
34
- `pnpm scaffold:sync` is the meta-script that regenerates all derived documentation and validates the output. It chains seven sub-scripts:
34
+ `pnpm scaffold:sync` is the meta-script that regenerates all derived documentation and validates the output. It chains six sub-scripts:
35
35
 
36
- | Script | Input | Output |
37
- | ---------------------- | --------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
38
- | `scaffold:generate` | Scaffold contract and feature-registry sources | `packages/core/src/reference/_generated/**`, `packages/ui/src/scaffold/_generated/feature-registry.md` |
39
- | `knowledge:generate` | Elevasis core knowledge nodes and UI knowledge body sources | Generated knowledge nodes and UI knowledge bodies |
40
- | `gen:sdk-catalog` | SDK catalog source definitions | SDK catalog artifacts |
41
- | `gen:sdk-adapters` | SDK adapter definitions | SDK adapter artifacts |
42
- | `copy-docs` | SDK docs, package-owned reference docs, scaffold docs, and `_template/.claude` config | `packages/sdk/reference/**` copied docs and scaffold reference bundle |
43
- | `sdk-ref:generate` | SDK manifest and navigation sources | `packages/sdk/reference/_reference-manifest.json`, `packages/sdk/reference/_navigation.md` |
44
- | `sdk-ref:check` | Generated SDK reference artifacts | Freshness validation for `packages/sdk/reference/_reference-manifest.json` and `_navigation.md` |
36
+ | Script | Input | Output |
37
+ | -------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
38
+ | `scaffold:generate` | Scaffold contract and feature-registry sources | `packages/core/src/reference/_generated/**`, `packages/ui/src/scaffold/_generated/feature-registry.md` |
39
+ | `knowledge:generate` | Elevasis core knowledge nodes and UI knowledge body sources | Generated knowledge nodes and UI knowledge bodies |
40
+ | `gen:sdk-catalog` | SDK catalog source definitions | SDK catalog artifacts |
41
+ | `gen:sdk-adapters` | SDK adapter definitions | SDK adapter artifacts |
42
+ | `copy-docs` | SDK docs, package-owned reference docs, scaffold docs, and `_template/.claude` config | `packages/sdk/reference/**` copied docs, `_reference-manifest.json`, and `_navigation.md` |
43
+ | `sdk-ref:check` | Generated SDK reference artifacts | Freshness validation for `packages/sdk/reference/_reference-manifest.json` and `_navigation.md` |
45
44
 
46
- The final `sdk-ref:check` step validates that the reference artifacts are consistent. Exit 1 if drifted.
45
+ `copy-docs` (`packages/sdk/scripts/copy-reference-docs.mjs`) atomically regenerates `_reference-manifest.json` and `_navigation.md` itself as its own Phase 5, via the same `buildAllArtifacts()`/`writeArtifacts()` functions the standalone `sdk-ref:generate` script runs -- so there is no separate `sdk-ref:generate` step in this chain; running it again after `copy-docs` would just recompute an identical result. The final `sdk-ref:check` step validates that the reference artifacts are consistent. Exit 1 if drifted.
47
46
 
48
47
  ### Trigger Points
49
48
 
@@ -63,12 +62,12 @@ Drift is healed at the moment it would otherwise leak downstream. This is cheape
63
62
  `/external sync` now treats the scaffold registry as the execution contract rather than relying on tier prose alone.
64
63
  The canonical ownership vocabulary is:
65
64
 
66
- | Category | Strategy examples | Meaning |
67
- | ------------- | --------------------------------- | ------------------------------------------------------------------- |
68
- | `replace` | `replace-all` | Template-managed surface; copy from template baseline |
65
+ | Category | Strategy examples | Meaning |
66
+ | ------------- | ------------------------------------------ | ------------------------------------------------------------------- |
67
+ | `replace` | `replace-all` | Template-managed surface; copy from template baseline |
69
68
  | `merge` | `merge-baseline`, `preserve-on-divergence` | Merge-aware surface; preserve project customizations where required |
70
- | `never-touch` | `verify-only` | Project-owned surface; planner may report drift but never writes |
71
- | `generated` | `generated-freshness` | Generated surface; verify/regen instead of copying |
69
+ | `never-touch` | `verify-only` | Project-owned surface; planner may report drift but never writes |
70
+ | `generated` | `generated-freshness` | Generated surface; verify/regen instead of copying |
72
71
 
73
72
  Current command helpers:
74
73
 
@@ -100,12 +100,13 @@ Generated files should never be edited manually. If the output is wrong, fix the
100
100
 
101
101
  ## SDK Build Pipeline (Reference Copy)
102
102
 
103
- `packages/sdk/scripts/copy-reference-docs.mjs` runs during `pnpm --filter @elevasis/sdk build` and has four phases:
103
+ `packages/sdk/scripts/copy-reference-docs.mjs` runs during `pnpm --filter @elevasis/sdk build` (and as the `copy-docs` root script) and has five phases:
104
104
 
105
105
  1. **Phase 1:** Copies SDK public docs from `apps/docs/content/docs/sdk/` with link rewriting and MDX escape stripping
106
106
  2. **Phase 2:** Copies package-owned reference docs declared in reference manifests
107
107
  3. **Phase 3:** Copies scaffold docs from co-located package sources using the `SCAFFOLD_COPIES` map
108
- 4. **Phase 4:** Copies `external/_template/.claude` into `packages/sdk/reference/claude-config` for tenant-facing agent configuration
108
+ 4. **Phase 4:** Generates a pointer doc (`claude-config.md`) to the tenant's own `.claude/` config instead of bundling it wholesale
109
+ 5. **Phase 5 (F14):** Atomically regenerates `_reference-manifest.json` and `_navigation.md` via the same `buildAllArtifacts()`/`writeArtifacts()` functions the standalone `sdk-ref:generate` script runs -- this happens after the wipe-and-recopy above because the orphan-reachability check inside `buildAllArtifacts()` walks the output directory. This closes the window where `packages/sdk/reference/` could sit without those two files between a `copy-docs` run and a separate `sdk-ref:generate` run, so a chain that already runs `copy-docs` never needs a following `sdk-ref:generate` step -- it would just recompute an identical result.
109
110
 
110
111
  The output lands in `packages/sdk/reference/` which is included in the npm package's `files` array. External projects access it via `operations/node_modules/@elevasis/sdk/reference/`.
111
112
 
@@ -409,10 +409,10 @@ pnpm elevasis-sdk exec Elevasis/email-notification --async --input '{...}'
409
409
  pnpm elevasis-sdk execution Elevasis/email-notification <executionId>
410
410
  ```
411
411
 
412
- The `--prod` flag targets `https://api.elevasis.io` and goes **before** the command:
412
+ The `--prod` flag targets `https://api.elevasis.io` and goes **after** the command name -- the SDK CLI parses it as a per-command Commander option, not a global flag (`.claude/rules/cli-cwd-invariant.md`):
413
413
 
414
414
  ```bash
415
- pnpm elevasis-sdk --prod exec Elevasis/email-notification --input '{...}'
415
+ pnpm elevasis-sdk exec Elevasis/email-notification --prod --input '{...}'
416
416
  ```
417
417
 
418
418
  ---
@@ -84,7 +84,7 @@ These wrap existing `LeadService` logic -- they are extraction, not new business
84
84
 
85
85
  Deploy a workflow with the same `workflowId` as the default action you want to replace. The resource registry resolves your project-owned workflow first.
86
86
 
87
- The canonical transition workflow (see `packages/elevasis-operations/src/sales/crm/actions/move-to-proposal.ts` for the deployed reference):
87
+ The canonical transition workflow (see `packages/elevasis/operations/src/sales/crm/actions/move-to-proposal.ts` for the deployed reference):
88
88
 
89
89
  <!-- doc-snippet:skip: illustrative excerpt -- `resourceDescriptors` names the project's own resource-descriptors export, and `../shared/action-workflow-schemas.js` is a project-local sibling file -->
90
90
 
@@ -220,7 +220,7 @@ This controls the shared `DealDetailPage` and `DealDrawer` action row.
220
220
 
221
221
  For a brand-new action key that calls a project-owned workflow, define the workflow first.
222
222
 
223
- If the action sends email, writes to another channel, or otherwise touches a customer, use `acqDb.recordDealActivity` inside the workflow handler to append an audit entry to the deal's `activity_log`. For an advanced Instantly-thread-aware variant that prefers in-thread replies and falls back to fresh outbound, see the canonical CRM action examples in `packages/elevasis-operations/src/sales/crm/actions/`.
223
+ If the action sends email, writes to another channel, or otherwise touches a customer, use `acqDb.recordDealActivity` inside the workflow handler to append an audit entry to the deal's `activity_log`. For an advanced Instantly-thread-aware variant that prefers in-thread replies and falls back to fresh outbound, see the canonical CRM action examples in `packages/elevasis/operations/src/sales/crm/actions/`.
224
224
 
225
225
  ### Define the Workflow Contract
226
226
 
@@ -420,12 +420,12 @@ export function CustomDealPage({ dealId }: { dealId: string }) {
420
420
 
421
421
  ## CRM State-Key Source of Truth
422
422
 
423
- CRM `stage_key` and `state_key` values are tenant/runtime data. In the Elevasis workspace, the canonical CRM pipeline definition lives in `@repo/elevasis-core/organization-model` and is authored into the `sales.crm:catalog/crm.pipeline` ontology catalog on the canonical organization model. Published `@elevasis/core` keeps only generic `StatefulPipelineDefinition` types/helpers and transport schemas.
423
+ CRM `stage_key` and `state_key` values are tenant/runtime data. In the Elevasis workspace, the canonical CRM pipeline definition lives in `@repo/elevasis-core/sales` and is authored into the `sales.crm:catalog/crm.pipeline` ontology catalog on the canonical organization model. Published `@elevasis/core` keeps only generic `StatefulPipelineDefinition` types/helpers and transport schemas.
424
424
 
425
- Within the Elevasis monorepo, import the tenant pipeline data from `@repo/elevasis-core/organization-model` and the generic `getValidStatesForStage` helper from `@repo/core/organization-model`:
425
+ Within the Elevasis monorepo, import the tenant pipeline data from `@repo/elevasis-core/sales` and the generic `getValidStatesForStage` helper from `@repo/core/organization-model`:
426
426
 
427
427
  ```ts
428
- import { CRM_PIPELINE_DEFINITION, CRM_DISCOVERY_REPLIED_STATE } from '@repo/elevasis-core/organization-model'
428
+ import { CRM_PIPELINE_DEFINITION, CRM_DISCOVERY_REPLIED_STATE } from '@repo/elevasis-core/sales'
429
429
  import { getValidStatesForStage } from '@repo/core/organization-model'
430
430
 
431
431
  const validStates = getValidStatesForStage(CRM_PIPELINE_DEFINITION, 'interested')