@company-semantics/contracts 9.1.0 → 9.2.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 (141) hide show
  1. package/package.json +4 -1
  2. package/src/__tests__/resource-keys.test.ts +30 -23
  3. package/src/admin/authz-simulate.ts +4 -4
  4. package/src/admin/direct-grants.ts +2 -2
  5. package/src/api/generated-spec-hash.ts +2 -2
  6. package/src/api/generated.ts +97 -0
  7. package/src/api/http/routes/ai-chat.ts +3 -3
  8. package/src/api/http/utils/resource-response.ts +5 -2
  9. package/src/api/index.ts +4 -4
  10. package/src/api/primitives.ts +6 -2
  11. package/src/auth/README.md +1 -0
  12. package/src/auth/index.ts +12 -5
  13. package/src/autotune.ts +5 -1
  14. package/src/billing/index.ts +1 -1
  15. package/src/billing/types.ts +1 -1
  16. package/src/chat/README.md +3 -0
  17. package/src/chat/__tests__/runtime-profile.test.ts +68 -48
  18. package/src/chat/index.ts +10 -4
  19. package/src/chat/runtime-profile.ts +25 -10
  20. package/src/chat/schemas.ts +49 -41
  21. package/src/chat/types.ts +48 -42
  22. package/src/ci-envelope/README.md +2 -0
  23. package/src/ci-envelope/__tests__/transitions.test.ts +56 -56
  24. package/src/ci-envelope/index.ts +2 -2
  25. package/src/ci-envelope/types.ts +20 -20
  26. package/src/ci-results/index.ts +2 -2
  27. package/src/ci-results/repo-ci-result.ts +15 -12
  28. package/src/compatibility.ts +6 -6
  29. package/src/content/index.ts +10 -4
  30. package/src/content/schemas.ts +42 -24
  31. package/src/dispatch/index.ts +18 -15
  32. package/src/email/__tests__/registry.test.ts +81 -77
  33. package/src/email/index.ts +3 -3
  34. package/src/email/registry.ts +25 -25
  35. package/src/email/types.ts +43 -43
  36. package/src/errors/index.ts +8 -8
  37. package/src/execution/__tests__/events.test.ts +42 -42
  38. package/src/execution/__tests__/lifecycle.test.ts +192 -190
  39. package/src/execution/__tests__/registry.test.ts +114 -114
  40. package/src/execution/audit-export.ts +4 -4
  41. package/src/execution/errors.ts +7 -7
  42. package/src/execution/event-metadata.ts +4 -4
  43. package/src/execution/events.ts +23 -21
  44. package/src/execution/expiry.ts +5 -5
  45. package/src/execution/hash-chain.ts +2 -2
  46. package/src/execution/index.ts +19 -28
  47. package/src/execution/kinds.ts +7 -7
  48. package/src/execution/lifecycle.ts +33 -33
  49. package/src/execution/registry.ts +63 -63
  50. package/src/execution/schemas.ts +31 -23
  51. package/src/execution/status.ts +45 -26
  52. package/src/execution/summary.ts +16 -17
  53. package/src/execution/timeline-ui.ts +9 -9
  54. package/src/execution/types.ts +31 -25
  55. package/src/generated/openapi-routes.ts +1 -0
  56. package/src/guards/config.ts +22 -18
  57. package/src/guards/index.ts +4 -4
  58. package/src/guards/types.ts +32 -24
  59. package/src/identity/__tests__/avatar.test.ts +68 -59
  60. package/src/identity/avatar.ts +8 -8
  61. package/src/identity/display-name.ts +3 -3
  62. package/src/identity/index.ts +8 -8
  63. package/src/identity/people-org-chart.ts +8 -4
  64. package/src/identity/schemas.ts +28 -18
  65. package/src/identity/types.ts +5 -5
  66. package/src/impersonation/index.ts +5 -5
  67. package/src/impersonation/schemas.ts +15 -9
  68. package/src/impersonation-events.ts +21 -21
  69. package/src/impersonation.ts +25 -24
  70. package/src/index.ts +118 -90
  71. package/src/interfaces/mcp/tools/help.ts +19 -19
  72. package/src/internal-admin.ts +6 -6
  73. package/src/mcp/README.md +2 -0
  74. package/src/mcp/__tests__/capability-graph.test.ts +290 -290
  75. package/src/mcp/capability-graph.ts +42 -40
  76. package/src/mcp/failure-context.ts +1 -3
  77. package/src/mcp/index.ts +57 -57
  78. package/src/mcp/resources.ts +9 -9
  79. package/src/meetings/index.ts +2 -2
  80. package/src/meetings/schemas.ts +51 -34
  81. package/src/message-parts/README.md +2 -0
  82. package/src/message-parts/__tests__/builder.test.ts +142 -142
  83. package/src/message-parts/__tests__/confirmation.test.ts +100 -86
  84. package/src/message-parts/__tests__/preview.test.ts +63 -63
  85. package/src/message-parts/__tests__/wire.test.ts +130 -124
  86. package/src/message-parts/builder.ts +23 -23
  87. package/src/message-parts/confirmation.ts +17 -14
  88. package/src/message-parts/execution.ts +7 -7
  89. package/src/message-parts/index.ts +10 -10
  90. package/src/message-parts/lifecycle.ts +25 -25
  91. package/src/message-parts/preview.ts +30 -30
  92. package/src/message-parts/types.ts +27 -27
  93. package/src/message-parts/wire.ts +24 -24
  94. package/src/mutations.ts +2 -2
  95. package/src/observability.ts +23 -11
  96. package/src/org/__tests__/org-units.test.ts +131 -96
  97. package/src/org/__tests__/tree-ordering.test.ts +57 -37
  98. package/src/org/__tests__/view-scopes.test.ts +40 -40
  99. package/src/org/domain.ts +9 -9
  100. package/src/org/index.ts +24 -21
  101. package/src/org/org-units.ts +34 -20
  102. package/src/org/schemas.ts +201 -127
  103. package/src/org/sharing.ts +17 -13
  104. package/src/org/tree-ordering.ts +3 -1
  105. package/src/org/types.ts +54 -47
  106. package/src/org/view-scopes.ts +9 -9
  107. package/src/permissions/access-levels.ts +7 -2
  108. package/src/permissions/access-source.ts +6 -6
  109. package/src/permissions/index.ts +5 -5
  110. package/src/permissions/orgchart-roles.ts +7 -7
  111. package/src/permissions/permission-introspection.ts +7 -5
  112. package/src/permissions/share-api.ts +19 -9
  113. package/src/pressure.ts +4 -4
  114. package/src/queryIntent.ts +21 -21
  115. package/src/ralph/__tests__/prd-groups.test.ts +159 -159
  116. package/src/ralph/__tests__/prd.test.ts +30 -30
  117. package/src/ralph/index.ts +3 -8
  118. package/src/ralph/prd.ts +33 -33
  119. package/src/ralph/progress.ts +1 -1
  120. package/src/rate-limit/README.md +4 -4
  121. package/src/rate-limit/index.ts +3 -3
  122. package/src/requests.ts +36 -8
  123. package/src/resource-keys.ts +207 -124
  124. package/src/resource-registry.ts +5 -5
  125. package/src/route-builder.ts +3 -3
  126. package/src/safe-mode.ts +2 -2
  127. package/src/security/index.ts +4 -4
  128. package/src/security/org-secrets.ts +13 -9
  129. package/src/security/secret.ts +3 -3
  130. package/src/sse.ts +3 -1
  131. package/src/system/README.md +3 -0
  132. package/src/system/capabilities.ts +22 -23
  133. package/src/system/diagram.ts +45 -45
  134. package/src/system/index.ts +14 -14
  135. package/src/tiers.ts +1 -1
  136. package/src/timeouts.ts +1 -1
  137. package/src/tracing.ts +30 -30
  138. package/src/types/analytics.ts +2 -2
  139. package/src/usage/README.md +3 -0
  140. package/src/usage/execution-types.ts +69 -69
  141. package/src/usage/types.ts +7 -3
package/src/org/domain.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  * INVARIANT: Only ONE org may have status='verified' for any domain globally.
14
14
  * @see ADR-BE-070 (revoked status removed — domains are hard-deleted instead)
15
15
  */
16
- export type DomainStatus = 'pending' | 'verified';
16
+ export type DomainStatus = "pending" | "verified";
17
17
 
18
18
  /**
19
19
  * Method used to verify domain ownership.
@@ -21,7 +21,7 @@ export type DomainStatus = 'pending' | 'verified';
21
21
  * - 'email': Email-based verification (reserved for future)
22
22
  * - 'idp': IdP-based verification via SAML/OIDC (reserved for future)
23
23
  */
24
- export type DomainVerificationMethod = 'dns_txt' | 'email' | 'idp';
24
+ export type DomainVerificationMethod = "dns_txt" | "email" | "idp";
25
25
 
26
26
  /**
27
27
  * Organization domain claim and verification status.
@@ -58,12 +58,12 @@ export interface OrgDomain {
58
58
  */
59
59
  export type Phase4AuditAction =
60
60
  // Domain lifecycle
61
- | 'org.domain.claimed'
62
- | 'org.domain.verified'
63
- | 'org.domain.deleted'
61
+ | "org.domain.claimed"
62
+ | "org.domain.verified"
63
+ | "org.domain.deleted"
64
64
  // Auth policy enforcement
65
- | 'org.auth_policy.enforced'
66
- | 'org.auth_policy.override_used' // Emergency SSO bypass succeeded
67
- | 'org.auth_policy.override_attempted' // Emergency SSO bypass denied (incident review)
65
+ | "org.auth_policy.enforced"
66
+ | "org.auth_policy.override_used" // Emergency SSO bypass succeeded
67
+ | "org.auth_policy.override_attempted" // Emergency SSO bypass denied (incident review)
68
68
  // Multi-org context
69
- | 'user.active_org.switched';
69
+ | "user.active_org.switched";
package/src/org/index.ts CHANGED
@@ -68,9 +68,12 @@ export type {
68
68
  IdentityTrustLevel,
69
69
  TransferEligibilityResult,
70
70
  TransferMemberEligibility,
71
- } from './types';
71
+ } from "./types";
72
72
 
73
- export { TRANSFER_RESPONSIBILITIES, IDENTITY_TRUST_LEVEL_LABELS } from './types';
73
+ export {
74
+ TRANSFER_RESPONSIBILITIES,
75
+ IDENTITY_TRUST_LEVEL_LABELS,
76
+ } from "./types";
74
77
 
75
78
  // Domain types (Phase 4)
76
79
  export type {
@@ -78,15 +81,15 @@ export type {
78
81
  DomainVerificationMethod,
79
82
  OrgDomain,
80
83
  Phase4AuditAction,
81
- } from './domain';
84
+ } from "./domain";
82
85
 
83
86
  // View authorization scopes (Phase 5 - ADR-APP-013)
84
- export type { AuthorizableView } from './view-scopes';
85
- export { VIEW_SCOPE_MAP, getViewScope } from './view-scopes';
87
+ export type { AuthorizableView } from "./view-scopes";
88
+ export { VIEW_SCOPE_MAP, getViewScope } from "./view-scopes";
86
89
 
87
90
  // Canonical OrgUnit tree ordering (PRD-00506)
88
- export type { TreeOrderableNode } from './tree-ordering';
89
- export { orderTreeNodes } from './tree-ordering';
91
+ export type { TreeOrderableNode } from "./tree-ordering";
92
+ export { orderTreeNodes } from "./tree-ordering";
90
93
 
91
94
  // Company.md domain types (PRD-00173)
92
95
  export type {
@@ -103,7 +106,7 @@ export type {
103
106
  CompanyMdDocRelations,
104
107
  CompanyMdDoc,
105
108
  CompanyMdContextBankItem,
106
- } from './company-md';
109
+ } from "./company-md";
107
110
 
108
111
  // Sharing and ACL types (PRD-00306)
109
112
  export type {
@@ -117,7 +120,7 @@ export type {
117
120
  AccessExplanation,
118
121
  ShareState,
119
122
  PermissionAuditEntry,
120
- } from './sharing';
123
+ } from "./sharing";
121
124
 
122
125
  // Workspace response schemas (PRD-00445)
123
126
  export {
@@ -145,7 +148,7 @@ export {
145
148
  LeaveOrgResponseSchema,
146
149
  ScopeCheckResponseSchema,
147
150
  ScopeCheckBatchResponseSchema,
148
- } from './schemas';
151
+ } from "./schemas";
149
152
  export type {
150
153
  WorkspaceAccessResponse,
151
154
  WorkspaceOverview as WorkspaceOverviewDto,
@@ -167,7 +170,7 @@ export type {
167
170
  LeaveOrgResponse,
168
171
  ScopeCheckResponse,
169
172
  ScopeCheckBatchResponse,
170
- } from './schemas';
173
+ } from "./schemas";
171
174
 
172
175
  // Org lifecycle response schemas (PRD-00446)
173
176
  export {
@@ -179,7 +182,7 @@ export {
179
182
  OrgDeletionStatusSchema,
180
183
  OwnershipTransferResponseSchema,
181
184
  OwnershipTransferPreviewSchema,
182
- } from './schemas';
185
+ } from "./schemas";
183
186
  export type {
184
187
  InviteResponse,
185
188
  InviteListResponse,
@@ -189,7 +192,7 @@ export type {
189
192
  OrgDeletionStatus,
190
193
  OwnershipTransferResponse,
191
194
  OwnershipTransferPreview,
192
- } from './schemas';
195
+ } from "./schemas";
193
196
 
194
197
  // Org-ops response schemas (PRD-00449)
195
198
  export {
@@ -197,13 +200,13 @@ export {
197
200
  AcknowledgeSystemEventResponseSchema,
198
201
  OrgBudgetConfigSchema,
199
202
  OrgUsageResponseSchema,
200
- } from './schemas';
203
+ } from "./schemas";
201
204
  export type {
202
205
  OrgSystemEventsList,
203
206
  AcknowledgeSystemEventResponse,
204
207
  OrgBudgetConfig,
205
208
  OrgUsageResponse,
206
- } from './schemas';
209
+ } from "./schemas";
207
210
 
208
211
  // OrgUnit canonical model (ADR-BE-120)
209
212
  export type {
@@ -216,8 +219,8 @@ export type {
216
219
  OrgUnitMembershipSource,
217
220
  OrgUnitErrorCode,
218
221
  OrgTreeResponse,
219
- } from './org-units';
220
- export { ORG_UNITS_ROUTES } from './org-units';
222
+ } from "./org-units";
223
+ export { ORG_UNITS_ROUTES } from "./org-units";
221
224
  export {
222
225
  OrgUnitClassificationSchema,
223
226
  OrgUnitSyncModeSchema,
@@ -248,7 +251,7 @@ export {
248
251
  ListOrgUnitPermissionsResponseSchema,
249
252
  UpdateOrgUnitRequestSchema,
250
253
  UpdateOrgUnitResponseSchema,
251
- } from './schemas';
254
+ } from "./schemas";
252
255
  export type {
253
256
  UnitMembershipRole,
254
257
  OrgUnit,
@@ -271,7 +274,7 @@ export type {
271
274
  ListOrgUnitPermissionsResponse,
272
275
  UpdateOrgUnitRequest,
273
276
  UpdateOrgUnitResponse,
274
- } from './schemas';
277
+ } from "./schemas";
275
278
 
276
279
  // Authority & Delegation vocabulary
277
280
  export {
@@ -292,7 +295,7 @@ export {
292
295
  FieldCapabilitySchema,
293
296
  ActionCapabilitySchema,
294
297
  CapabilitiesResponseSchema,
295
- } from './schemas';
298
+ } from "./schemas";
296
299
  export type {
297
300
  AuthoritySource,
298
301
  AuthorityOrigin,
@@ -310,4 +313,4 @@ export type {
310
313
  FieldCapability,
311
314
  ActionCapability,
312
315
  CapabilitiesResponse,
313
- } from './schemas';
316
+ } from "./schemas";
@@ -22,25 +22,39 @@
22
22
  */
23
23
 
24
24
  /** Semantic classification — projection-only, never drives traversal. */
25
- export type OrgUnitClassification = 'execution_unit' | 'org_container' | 'custom';
25
+ export type OrgUnitClassification =
26
+ | "execution_unit"
27
+ | "org_container"
28
+ | "custom";
26
29
 
27
30
  /** External directory reconciliation policy for a unit. */
28
- export type OrgUnitSyncMode = 'manual_only' | 'synced_readonly' | 'synced_with_overrides';
31
+ export type OrgUnitSyncMode =
32
+ | "manual_only"
33
+ | "synced_readonly"
34
+ | "synced_with_overrides";
29
35
 
30
36
  /** Default visibility inherited by new docs under this unit. */
31
- export type OrgUnitVisibility = 'public' | 'private' | 'restricted';
37
+ export type OrgUnitVisibility = "public" | "private" | "restricted";
32
38
 
33
39
  /** Edge classification for `org_unit_relationships`. Graph-only; never structural. */
34
- export type OrgUnitRelationshipType = 'collaborates_with' | 'reports_to' | 'depends_on' | 'custom';
40
+ export type OrgUnitRelationshipType =
41
+ | "collaborates_with"
42
+ | "reports_to"
43
+ | "depends_on"
44
+ | "custom";
35
45
 
36
46
  /** Edge role — refines the collaboration nature on a graph edge. */
37
- export type OrgUnitRelationshipRole = 'owner' | 'participant' | 'supporting';
47
+ export type OrgUnitRelationshipRole = "owner" | "participant" | "supporting";
38
48
 
39
49
  /** Active/pending/removed lifecycle for a unit membership. */
40
- export type OrgUnitMembershipStatus = 'active' | 'pending' | 'removed';
50
+ export type OrgUnitMembershipStatus = "active" | "pending" | "removed";
41
51
 
42
52
  /** External directory origin of a membership row. */
43
- export type OrgUnitMembershipSource = 'manual' | 'google_groups' | 'scim' | 'hris';
53
+ export type OrgUnitMembershipSource =
54
+ | "manual"
55
+ | "google_groups"
56
+ | "scim"
57
+ | "hris";
44
58
 
45
59
  /**
46
60
  * Canonical route path constants for the `/api/org-units` surface.
@@ -57,8 +71,8 @@ export type OrgUnitMembershipSource = 'manual' | 'google_groups' | 'scim' | 'hri
57
71
  * into `/api/org-units/tree` without changing the response shape.
58
72
  */
59
73
  export const ORG_UNITS_ROUTES = {
60
- list: '/api/org-units',
61
- tree: '/api/org-units/tree',
74
+ list: "/api/org-units",
75
+ tree: "/api/org-units/tree",
62
76
  byId: (unitId: string) => `/api/org-units/${unitId}`,
63
77
  children: (unitId: string) => `/api/org-units/${unitId}/children`,
64
78
  ancestors: (unitId: string) => `/api/org-units/${unitId}/ancestors`,
@@ -82,7 +96,7 @@ export const ORG_UNITS_ROUTES = {
82
96
  * / `OrgUnitTreeResponse`. This alias gives consumers the shorter
83
97
  * `OrgTreeResponse` name used by `GET /api/org-units/tree`.
84
98
  */
85
- export type { OrgUnitTreeResponse as OrgTreeResponse } from './schemas';
99
+ export type { OrgUnitTreeResponse as OrgTreeResponse } from "./schemas";
86
100
 
87
101
  /**
88
102
  * Error codes returned by `POST /api/org-units/:id/reparent` and related
@@ -90,22 +104,22 @@ export type { OrgUnitTreeResponse as OrgTreeResponse } from './schemas';
90
104
  */
91
105
  export type OrgUnitErrorCode =
92
106
  /** newParent.path contains unit.path — would create a cycle. */
93
- | 'CYCLE_BLOCKED'
107
+ | "CYCLE_BLOCKED"
94
108
  /** Reparent would push subtree above depth 5. */
95
- | 'DEPTH_EXCEEDED'
109
+ | "DEPTH_EXCEEDED"
96
110
  /** Target parent is archived; reparenting into archived subtrees is forbidden. */
97
- | 'TARGET_ARCHIVED'
111
+ | "TARGET_ARCHIVED"
98
112
  /** Attempted to set `parent_id` on a level-1 root unit. */
99
- | 'ROOT_HAS_NO_PARENT'
113
+ | "ROOT_HAS_NO_PARENT"
100
114
  /** Parent is archived on create. */
101
- | 'PARENT_ARCHIVED'
115
+ | "PARENT_ARCHIVED"
102
116
  /** Slug already taken under the target parent. */
103
- | 'SLUG_TAKEN'
117
+ | "SLUG_TAKEN"
104
118
  /** Attempted to reparent across orgs (or create with mismatched orgId). */
105
- | 'CROSS_ORG_REPARENT'
119
+ | "CROSS_ORG_REPARENT"
106
120
  /** Reorder: computed order_key collided with an existing sibling; client should re-fetch neighbors and retry. */
107
- | 'ORDERKEY_CONFLICT'
121
+ | "ORDERKEY_CONFLICT"
108
122
  /** Reorder: prev or next sibling id does not resolve to a live unit. */
109
- | 'SIBLING_NOT_FOUND'
123
+ | "SIBLING_NOT_FOUND"
110
124
  /** Reorder: prev or next sibling belongs to a different parent than the moving unit. */
111
- | 'SIBLINGS_DIFFERENT_PARENT';
125
+ | "SIBLINGS_DIFFERENT_PARENT";