@company-semantics/contracts 9.0.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 +6 -3
  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 +2 -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 +69 -56
  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 +31 -21
  101. package/src/org/org-units.ts +34 -20
  102. package/src/org/schemas.ts +261 -124
  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
@@ -23,10 +23,10 @@
23
23
  * 2. EXECUTION_KINDS registry in registry.ts
24
24
  */
25
25
  export type ExecutionKind =
26
- | 'integration.connect'
27
- | 'integration.disconnect'
28
- | 'profile.update'
29
- | 'slack.send'
30
- | 'data.ingest'
31
- | 'data.scope'
32
- | 'system.cleanup'
26
+ | "integration.connect"
27
+ | "integration.disconnect"
28
+ | "profile.update"
29
+ | "slack.send"
30
+ | "data.ingest"
31
+ | "data.scope"
32
+ | "system.cleanup";
@@ -1,13 +1,13 @@
1
- import type { ExecutionState } from './status';
1
+ import type { ExecutionState } from "./status";
2
2
 
3
- export type ExecutionIntent = 'confirm' | 'reject';
3
+ export type ExecutionIntent = "confirm" | "reject";
4
4
 
5
5
  export type LifecycleDecision =
6
- | 'approve'
7
- | 'already_confirmed'
8
- | 'awaiting_approval'
9
- | 'expired'
10
- | 'conflict';
6
+ | "approve"
7
+ | "already_confirmed"
8
+ | "awaiting_approval"
9
+ | "expired"
10
+ | "conflict";
11
11
 
12
12
  type DecisionTable = Record<
13
13
  ExecutionIntent,
@@ -16,34 +16,34 @@ type DecisionTable = Record<
16
16
 
17
17
  export const LIFECYCLE_DECISIONS: DecisionTable = {
18
18
  confirm: {
19
- pending_confirmation: 'approve',
20
- expired: 'expired',
21
- cancelled: 'conflict',
22
- blocked_pending_approval: 'awaiting_approval',
23
- ready: 'already_confirmed',
24
- executing: 'already_confirmed',
25
- completed: 'already_confirmed',
26
- completed_with_rollbacks: 'already_confirmed',
27
- failed_retryable: 'conflict',
28
- failed_exhausted: 'conflict',
29
- failed_terminal: 'conflict',
30
- failed_with_partial_execution: 'conflict',
31
- undone: 'conflict',
19
+ pending_confirmation: "approve",
20
+ expired: "expired",
21
+ cancelled: "conflict",
22
+ blocked_pending_approval: "awaiting_approval",
23
+ ready: "already_confirmed",
24
+ executing: "already_confirmed",
25
+ completed: "already_confirmed",
26
+ completed_with_rollbacks: "already_confirmed",
27
+ failed_retryable: "conflict",
28
+ failed_exhausted: "conflict",
29
+ failed_terminal: "conflict",
30
+ failed_with_partial_execution: "conflict",
31
+ undone: "conflict",
32
32
  },
33
33
  reject: {
34
- pending_confirmation: 'approve',
35
- expired: 'expired',
36
- cancelled: 'conflict',
37
- blocked_pending_approval: 'conflict',
38
- ready: 'conflict',
39
- executing: 'conflict',
40
- completed: 'conflict',
41
- completed_with_rollbacks: 'conflict',
42
- failed_retryable: 'conflict',
43
- failed_exhausted: 'conflict',
44
- failed_terminal: 'conflict',
45
- failed_with_partial_execution: 'conflict',
46
- undone: 'conflict',
34
+ pending_confirmation: "approve",
35
+ expired: "expired",
36
+ cancelled: "conflict",
37
+ blocked_pending_approval: "conflict",
38
+ ready: "conflict",
39
+ executing: "conflict",
40
+ completed: "conflict",
41
+ completed_with_rollbacks: "conflict",
42
+ failed_retryable: "conflict",
43
+ failed_exhausted: "conflict",
44
+ failed_terminal: "conflict",
45
+ failed_with_partial_execution: "conflict",
46
+ undone: "conflict",
47
47
  },
48
48
  };
49
49
 
@@ -12,8 +12,8 @@
12
12
  * @see ADR-CONT-029 for design rationale
13
13
  */
14
14
 
15
- import type { ExecutionKind } from './kinds'
16
- import type { ExecutionKindDefinition } from './types'
15
+ import type { ExecutionKind } from "./kinds";
16
+ import type { ExecutionKindDefinition } from "./types";
17
17
 
18
18
  // =============================================================================
19
19
  // Registry
@@ -33,18 +33,18 @@ import type { ExecutionKindDefinition } from './types'
33
33
  * 4. Add explanation template
34
34
  */
35
35
  export const EXECUTION_KINDS = {
36
- 'integration.connect': {
37
- kind: 'integration.connect',
38
- domain: 'integration',
36
+ "integration.connect": {
37
+ kind: "integration.connect",
38
+ domain: "integration",
39
39
  display: {
40
- label: 'Connect Slack',
41
- pastTenseLabel: 'Slack connected',
42
- icon: 'plug',
40
+ label: "Connect Slack",
41
+ pastTenseLabel: "Slack connected",
42
+ icon: "plug",
43
43
  },
44
44
  governance: {
45
- visibility: 'admin',
45
+ visibility: "admin",
46
46
  requiresAdmin: true,
47
- reversibleBy: 'integration.disconnect',
47
+ reversibleBy: "integration.disconnect",
48
48
  },
49
49
  ui: {
50
50
  showInAdmin: true,
@@ -52,19 +52,19 @@ export const EXECUTION_KINDS = {
52
52
  confirmBeforeRun: false,
53
53
  },
54
54
  explanation: {
55
- templateId: 'integration.connect',
55
+ templateId: "integration.connect",
56
56
  },
57
57
  },
58
- 'integration.disconnect': {
59
- kind: 'integration.disconnect',
60
- domain: 'integration',
58
+ "integration.disconnect": {
59
+ kind: "integration.disconnect",
60
+ domain: "integration",
61
61
  display: {
62
- label: 'Disconnect Slack',
63
- pastTenseLabel: 'Slack disconnected',
64
- icon: 'unlink',
62
+ label: "Disconnect Slack",
63
+ pastTenseLabel: "Slack disconnected",
64
+ icon: "unlink",
65
65
  },
66
66
  governance: {
67
- visibility: 'admin',
67
+ visibility: "admin",
68
68
  requiresAdmin: true,
69
69
  },
70
70
  ui: {
@@ -73,19 +73,19 @@ export const EXECUTION_KINDS = {
73
73
  confirmBeforeRun: true,
74
74
  },
75
75
  explanation: {
76
- templateId: 'integration.disconnect',
76
+ templateId: "integration.disconnect",
77
77
  },
78
78
  },
79
- 'profile.update': {
80
- kind: 'profile.update',
81
- domain: 'profile',
79
+ "profile.update": {
80
+ kind: "profile.update",
81
+ domain: "profile",
82
82
  display: {
83
- label: 'Update Profile',
84
- pastTenseLabel: 'Profile updated',
85
- icon: 'pencil',
83
+ label: "Update Profile",
84
+ pastTenseLabel: "Profile updated",
85
+ icon: "pencil",
86
86
  },
87
87
  governance: {
88
- visibility: 'user',
88
+ visibility: "user",
89
89
  requiresAdmin: false,
90
90
  },
91
91
  ui: {
@@ -94,19 +94,19 @@ export const EXECUTION_KINDS = {
94
94
  confirmBeforeRun: true,
95
95
  },
96
96
  explanation: {
97
- templateId: 'profile.update',
97
+ templateId: "profile.update",
98
98
  },
99
99
  },
100
- 'slack.send': {
101
- kind: 'slack.send',
102
- domain: 'communication',
100
+ "slack.send": {
101
+ kind: "slack.send",
102
+ domain: "communication",
103
103
  display: {
104
- label: 'Send Slack Message',
105
- pastTenseLabel: 'Slack message sent',
106
- icon: 'send',
104
+ label: "Send Slack Message",
105
+ pastTenseLabel: "Slack message sent",
106
+ icon: "send",
107
107
  },
108
108
  governance: {
109
- visibility: 'user',
109
+ visibility: "user",
110
110
  requiresAdmin: false,
111
111
  },
112
112
  ui: {
@@ -115,19 +115,19 @@ export const EXECUTION_KINDS = {
115
115
  confirmBeforeRun: true,
116
116
  },
117
117
  explanation: {
118
- templateId: 'slack.send',
118
+ templateId: "slack.send",
119
119
  },
120
120
  },
121
- 'data.ingest': {
122
- kind: 'data.ingest',
123
- domain: 'data',
121
+ "data.ingest": {
122
+ kind: "data.ingest",
123
+ domain: "data",
124
124
  display: {
125
- label: 'Import Channel',
126
- pastTenseLabel: 'Channel imported',
127
- icon: 'send',
125
+ label: "Import Channel",
126
+ pastTenseLabel: "Channel imported",
127
+ icon: "send",
128
128
  },
129
129
  governance: {
130
- visibility: 'user',
130
+ visibility: "user",
131
131
  requiresAdmin: false,
132
132
  },
133
133
  ui: {
@@ -136,19 +136,19 @@ export const EXECUTION_KINDS = {
136
136
  confirmBeforeRun: true,
137
137
  },
138
138
  explanation: {
139
- templateId: 'data-ingest',
139
+ templateId: "data-ingest",
140
140
  },
141
141
  },
142
- 'data.scope': {
143
- kind: 'data.scope',
144
- domain: 'data',
142
+ "data.scope": {
143
+ kind: "data.scope",
144
+ domain: "data",
145
145
  display: {
146
- label: 'Update Channel Scope',
147
- pastTenseLabel: 'Channel scope updated',
148
- icon: 'pencil',
146
+ label: "Update Channel Scope",
147
+ pastTenseLabel: "Channel scope updated",
148
+ icon: "pencil",
149
149
  },
150
150
  governance: {
151
- visibility: 'admin',
151
+ visibility: "admin",
152
152
  requiresAdmin: true,
153
153
  },
154
154
  ui: {
@@ -157,19 +157,19 @@ export const EXECUTION_KINDS = {
157
157
  confirmBeforeRun: true,
158
158
  },
159
159
  explanation: {
160
- templateId: 'data-scope',
160
+ templateId: "data-scope",
161
161
  },
162
162
  },
163
- 'system.cleanup': {
164
- kind: 'system.cleanup',
165
- domain: 'system',
163
+ "system.cleanup": {
164
+ kind: "system.cleanup",
165
+ domain: "system",
166
166
  display: {
167
- label: 'Cleanup Connections',
168
- pastTenseLabel: 'Connections cleaned up',
169
- icon: 'unlink',
167
+ label: "Cleanup Connections",
168
+ pastTenseLabel: "Connections cleaned up",
169
+ icon: "unlink",
170
170
  },
171
171
  governance: {
172
- visibility: 'admin',
172
+ visibility: "admin",
173
173
  requiresAdmin: true,
174
174
  },
175
175
  ui: {
@@ -178,10 +178,10 @@ export const EXECUTION_KINDS = {
178
178
  confirmBeforeRun: true,
179
179
  },
180
180
  explanation: {
181
- templateId: 'system-cleanup',
181
+ templateId: "system-cleanup",
182
182
  },
183
183
  },
184
- } as const satisfies Record<ExecutionKind, ExecutionKindDefinition>
184
+ } as const satisfies Record<ExecutionKind, ExecutionKindDefinition>;
185
185
 
186
186
  // =============================================================================
187
187
  // Registry Helpers
@@ -192,9 +192,9 @@ export const EXECUTION_KINDS = {
192
192
  * Returns the definition for a given execution kind.
193
193
  */
194
194
  export function getExecutionKindDefinition(
195
- kind: ExecutionKind
195
+ kind: ExecutionKind,
196
196
  ): ExecutionKindDefinition {
197
- return EXECUTION_KINDS[kind]
197
+ return EXECUTION_KINDS[kind];
198
198
  }
199
199
 
200
200
  /**
@@ -202,5 +202,5 @@ export function getExecutionKindDefinition(
202
202
  * Use at API boundaries to reject unknown kinds.
203
203
  */
204
204
  export function isValidExecutionKind(kind: string): kind is ExecutionKind {
205
- return kind in EXECUTION_KINDS
205
+ return kind in EXECUTION_KINDS;
206
206
  }
@@ -7,7 +7,7 @@
7
7
  * @see ADR-CONT-029 for design rationale
8
8
  */
9
9
 
10
- import { z } from 'zod'
10
+ import { z } from "zod";
11
11
 
12
12
  // =============================================================================
13
13
  // Execution Summary
@@ -16,13 +16,13 @@ import { z } from 'zod'
16
16
  export const ExecutionSummarySchema = z.object({
17
17
  executionId: z.string().uuid(),
18
18
  kind: z.string(),
19
- status: z.enum(['pending', 'succeeded', 'failed']),
19
+ status: z.enum(["pending", "succeeded", "failed"]),
20
20
  decidedAt: z.string().datetime({ offset: true }),
21
21
  completedAt: z.string().datetime({ offset: true }).optional(),
22
22
  target: z.object({ type: z.string() }),
23
- })
23
+ });
24
24
 
25
- export type ExecutionSummaryResponse = z.infer<typeof ExecutionSummarySchema>
25
+ export type ExecutionSummaryResponse = z.infer<typeof ExecutionSummarySchema>;
26
26
 
27
27
  // =============================================================================
28
28
  // Execution List Response
@@ -32,9 +32,9 @@ export const ExecutionListResponseSchema = z.object({
32
32
  executions: z.array(ExecutionSummarySchema),
33
33
  nextCursor: z.string().nullable().optional(),
34
34
  hasMore: z.boolean().optional(),
35
- })
35
+ });
36
36
 
37
- export type ExecutionListResponse = z.infer<typeof ExecutionListResponseSchema>
37
+ export type ExecutionListResponse = z.infer<typeof ExecutionListResponseSchema>;
38
38
 
39
39
  // =============================================================================
40
40
  // Timeline Event
@@ -45,7 +45,7 @@ const TimelineRelatedIdsSchema = z.object({
45
45
  artifactId: z.string().optional(),
46
46
  rollbackId: z.string().optional(),
47
47
  provenanceIds: z.array(z.string()).optional(),
48
- })
48
+ });
49
49
 
50
50
  export const TimelineEventSchema = z.object({
51
51
  eventId: z.string(),
@@ -56,10 +56,10 @@ export const TimelineEventSchema = z.object({
56
56
  summary: z.string(),
57
57
  details: z.record(z.string(), z.unknown()).optional(),
58
58
  relatedIds: TimelineRelatedIdsSchema.optional(),
59
- visibilityLevel: z.enum(['system', 'oversight', 'org_admin', 'user']),
60
- })
59
+ visibilityLevel: z.enum(["system", "oversight", "org_admin", "user"]),
60
+ });
61
61
 
62
- export type TimelineEvent = z.infer<typeof TimelineEventSchema>
62
+ export type TimelineEvent = z.infer<typeof TimelineEventSchema>;
63
63
 
64
64
  // =============================================================================
65
65
  // Execution Timeline Response
@@ -67,9 +67,11 @@ export type TimelineEvent = z.infer<typeof TimelineEventSchema>
67
67
 
68
68
  export const ExecutionTimelineResponseSchema = z.object({
69
69
  events: z.array(TimelineEventSchema),
70
- })
70
+ });
71
71
 
72
- export type ExecutionTimelineResponse = z.infer<typeof ExecutionTimelineResponseSchema>
72
+ export type ExecutionTimelineResponse = z.infer<
73
+ typeof ExecutionTimelineResponseSchema
74
+ >;
73
75
 
74
76
  // =============================================================================
75
77
  // Execution Lifecycle Responses
@@ -77,26 +79,32 @@ export type ExecutionTimelineResponse = z.infer<typeof ExecutionTimelineResponse
77
79
 
78
80
  export const ConfirmExecutionResponseSchema = z.object({
79
81
  status: z.enum([
80
- 'executing',
81
- 'blocked_pending_approval',
82
- 'already_confirmed',
83
- 'awaiting_approval',
82
+ "executing",
83
+ "blocked_pending_approval",
84
+ "already_confirmed",
85
+ "awaiting_approval",
84
86
  ]),
85
87
  code: z.string().optional(),
86
88
  executionId: z.string().optional(),
87
- })
89
+ });
88
90
 
89
- export type ConfirmExecutionResponse = z.infer<typeof ConfirmExecutionResponseSchema>
91
+ export type ConfirmExecutionResponse = z.infer<
92
+ typeof ConfirmExecutionResponseSchema
93
+ >;
90
94
 
91
95
  export const RejectExecutionResponseSchema = z.object({
92
- status: z.literal('cancelled'),
93
- })
96
+ status: z.literal("cancelled"),
97
+ });
94
98
 
95
- export type RejectExecutionResponse = z.infer<typeof RejectExecutionResponseSchema>
99
+ export type RejectExecutionResponse = z.infer<
100
+ typeof RejectExecutionResponseSchema
101
+ >;
96
102
 
97
103
  export const StartExecutionResponseSchema = z.object({
98
104
  executionId: z.string().uuid(),
99
105
  redirectUrl: z.string().optional(),
100
- })
106
+ });
101
107
 
102
- export type StartExecutionResponse = z.infer<typeof StartExecutionResponseSchema>
108
+ export type StartExecutionResponse = z.infer<
109
+ typeof StartExecutionResponseSchema
110
+ >;
@@ -55,32 +55,43 @@
55
55
  * Retry events must include retryAttempt in metadata.
56
56
  */
57
57
  export type ExecutionState =
58
- | 'pending_confirmation'
59
- | 'blocked_pending_approval'
60
- | 'ready'
61
- | 'executing'
62
- | 'completed'
63
- | 'completed_with_rollbacks'
64
- | 'failed_retryable'
65
- | 'failed_exhausted'
66
- | 'failed_terminal'
67
- | 'failed_with_partial_execution'
68
- | 'cancelled'
69
- | 'expired'
70
- | 'undone';
58
+ | "pending_confirmation"
59
+ | "blocked_pending_approval"
60
+ | "ready"
61
+ | "executing"
62
+ | "completed"
63
+ | "completed_with_rollbacks"
64
+ | "failed_retryable"
65
+ | "failed_exhausted"
66
+ | "failed_terminal"
67
+ | "failed_with_partial_execution"
68
+ | "cancelled"
69
+ | "expired"
70
+ | "undone";
71
71
 
72
- export const VALID_TRANSITIONS: Record<ExecutionState, readonly ExecutionState[]> = {
73
- pending_confirmation: ['ready', 'blocked_pending_approval', 'cancelled', 'expired'],
74
- blocked_pending_approval: ['ready', 'cancelled', 'expired'],
75
- ready: ['executing'],
72
+ export const VALID_TRANSITIONS: Record<
73
+ ExecutionState,
74
+ readonly ExecutionState[]
75
+ > = {
76
+ pending_confirmation: [
77
+ "ready",
78
+ "blocked_pending_approval",
79
+ "cancelled",
80
+ "expired",
81
+ ],
82
+ blocked_pending_approval: ["ready", "cancelled", "expired"],
83
+ ready: ["executing"],
76
84
  executing: [
77
- 'completed', 'completed_with_rollbacks',
78
- 'failed_retryable', 'failed_terminal',
79
- 'failed_with_partial_execution', 'cancelled',
85
+ "completed",
86
+ "completed_with_rollbacks",
87
+ "failed_retryable",
88
+ "failed_terminal",
89
+ "failed_with_partial_execution",
90
+ "cancelled",
80
91
  ],
81
- completed: ['undone'],
92
+ completed: ["undone"],
82
93
  completed_with_rollbacks: [],
83
- failed_retryable: ['ready', 'failed_exhausted'],
94
+ failed_retryable: ["ready", "failed_exhausted"],
84
95
  failed_exhausted: [],
85
96
  failed_terminal: [],
86
97
  failed_with_partial_execution: [],
@@ -90,17 +101,25 @@ export const VALID_TRANSITIONS: Record<ExecutionState, readonly ExecutionState[]
90
101
  };
91
102
 
92
103
  export const TERMINAL_STATES: ReadonlySet<ExecutionState> = new Set(
93
- (Object.entries(VALID_TRANSITIONS) as [ExecutionState, readonly ExecutionState[]][])
104
+ (
105
+ Object.entries(VALID_TRANSITIONS) as [
106
+ ExecutionState,
107
+ readonly ExecutionState[],
108
+ ][]
109
+ )
94
110
  .filter(([, targets]) => targets.length === 0)
95
- .map(([state]) => state)
111
+ .map(([state]) => state),
96
112
  );
97
113
 
98
114
  export const EFFECTIVE_TERMINAL_STATES: ReadonlySet<ExecutionState> = new Set([
99
115
  ...TERMINAL_STATES,
100
- 'completed',
116
+ "completed",
101
117
  ]);
102
118
 
103
- export function assertValidTransition(from: ExecutionState, to: ExecutionState): void {
119
+ export function assertValidTransition(
120
+ from: ExecutionState,
121
+ to: ExecutionState,
122
+ ): void {
104
123
  if (!VALID_TRANSITIONS[from].includes(to)) {
105
124
  throw new Error(`Invalid execution state transition: ${from} -> ${to}`);
106
125
  }
@@ -13,8 +13,8 @@
13
13
  * @see ADR-CONT-029 for design rationale
14
14
  */
15
15
 
16
- import type { ExecutionKind } from './kinds'
17
- import type { ISO8601Timestamp } from './types'
16
+ import type { ExecutionKind } from "./kinds";
17
+ import type { ISO8601Timestamp } from "./types";
18
18
 
19
19
  // =============================================================================
20
20
  // Execution Target
@@ -24,8 +24,7 @@ import type { ISO8601Timestamp } from './types'
24
24
  * Target of an execution action.
25
25
  * Currently supports Slack integration; extensible for future integrations.
26
26
  */
27
- export type ExecutionTarget =
28
- | { type: 'slack'; workspaceId?: string }
27
+ export type ExecutionTarget = { type: "slack"; workspaceId?: string };
29
28
 
30
29
  // =============================================================================
31
30
  // Initiator
@@ -36,11 +35,11 @@ export type ExecutionTarget =
36
35
  */
37
36
  export interface ExecutionInitiator {
38
37
  /** Actor type (user or automated system) */
39
- actorType: 'user' | 'system'
38
+ actorType: "user" | "system";
40
39
  /** Actor identifier (userId or system identifier) */
41
- actorId: string
40
+ actorId: string;
42
41
  /** Human-readable name for display */
43
- displayName: string
42
+ displayName: string;
44
43
  }
45
44
 
46
45
  // =============================================================================
@@ -50,7 +49,7 @@ export interface ExecutionInitiator {
50
49
  /**
51
50
  * Status of an execution.
52
51
  */
53
- export type ExecutionStatus = 'pending' | 'succeeded' | 'failed'
52
+ export type ExecutionStatus = "pending" | "succeeded" | "failed";
54
53
 
55
54
  // =============================================================================
56
55
  // Execution Summary
@@ -69,33 +68,33 @@ export type ExecutionStatus = 'pending' | 'succeeded' | 'failed'
69
68
  */
70
69
  export interface ExecutionSummary {
71
70
  /** Unique execution identifier */
72
- executionId: string
71
+ executionId: string;
73
72
 
74
73
  /** Type of execution */
75
- kind: ExecutionKind
74
+ kind: ExecutionKind;
76
75
 
77
76
  /** What the execution targeted */
78
- target: ExecutionTarget
77
+ target: ExecutionTarget;
79
78
 
80
79
  /** Current status */
81
- status: ExecutionStatus
80
+ status: ExecutionStatus;
82
81
 
83
82
  /** Who initiated the execution */
84
- initiatedBy: ExecutionInitiator
83
+ initiatedBy: ExecutionInitiator;
85
84
 
86
85
  /** When the execution was initiated (decision point) */
87
- decidedAt: ISO8601Timestamp
86
+ decidedAt: ISO8601Timestamp;
88
87
 
89
88
  /** When the execution completed (if finished) */
90
- completedAt?: ISO8601Timestamp
89
+ completedAt?: ISO8601Timestamp;
91
90
 
92
91
  /**
93
92
  * Visibility level for this execution.
94
93
  * Derived from EXECUTION_KINDS[kind].governance.visibility.
95
94
  * Used for filtering in queries.
96
95
  */
97
- visibility: 'admin' | 'user'
96
+ visibility: "admin" | "user";
98
97
 
99
98
  /** Whether an explanation can be generated for this execution */
100
- explanationAvailable: boolean
99
+ explanationAvailable: boolean;
101
100
  }