@atolis-hq/wake 0.4.104 → 0.4.105

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 (84) hide show
  1. package/dist/src/activities/agent/agent-activity.js +3 -0
  2. package/dist/src/activities/contracts/activity.d.ts +16 -0
  3. package/dist/src/bootstrap/config/root-schema.d.ts +16 -0
  4. package/dist/src/bootstrap/delegation-authority.js +17 -0
  5. package/dist/src/bootstrap/surface-api-delivery.js +25 -0
  6. package/dist/src/bootstrap/version.js +1 -1
  7. package/dist/src/control-plane/application/activation-scheduler-ports.d.ts +3 -1
  8. package/dist/src/control-plane/application/advance-once-dispatch.js +4 -2
  9. package/dist/src/execution/application/candidate-workspaces.d.ts +13 -0
  10. package/dist/src/execution/application/candidate-workspaces.js +75 -0
  11. package/dist/src/execution/application/execution-service.js +27 -11
  12. package/dist/src/execution/application/run-lifecycle.js +1 -0
  13. package/dist/src/execution/contracts/candidate.d.ts +31 -0
  14. package/dist/src/execution/contracts/candidate.js +40 -0
  15. package/dist/src/execution/contracts/commands.d.ts +2 -0
  16. package/dist/src/execution/contracts/events.d.ts +11 -0
  17. package/dist/src/execution/contracts/events.js +2 -0
  18. package/dist/src/execution/contracts/repository-assignment.d.ts +5 -0
  19. package/dist/src/execution/contracts/repository-assignment.js +8 -0
  20. package/dist/src/execution/contracts/views.d.ts +2 -0
  21. package/dist/src/execution/contracts/vocabulary.d.ts +5 -0
  22. package/dist/src/execution/contracts/vocabulary.js +4 -0
  23. package/dist/src/execution/contracts/workspace.d.ts +6 -0
  24. package/dist/src/execution/index.d.ts +1 -0
  25. package/dist/src/execution/index.js +1 -0
  26. package/dist/src/execution/infrastructure/workspace/git-source.d.ts +2 -2
  27. package/dist/src/execution/infrastructure/workspace/git-source.js +18 -1
  28. package/dist/src/execution/infrastructure/workspace/git-workspace.d.ts +2 -4
  29. package/dist/src/execution/infrastructure/workspace/git-workspace.js +12 -1
  30. package/dist/src/orchestration/application/delegated-work.d.ts +5 -0
  31. package/dist/src/orchestration/application/delegated-work.js +10 -0
  32. package/dist/src/orchestration/application/delegation-commands.d.ts +13 -0
  33. package/dist/src/orchestration/application/delivery-coordinator.d.ts +279 -0
  34. package/dist/src/orchestration/application/delivery-coordinator.js +213 -0
  35. package/dist/src/orchestration/application/delivery-facts-reader.d.ts +9 -0
  36. package/dist/src/orchestration/application/delivery-facts-reader.js +46 -0
  37. package/dist/src/orchestration/application/delivery-preparation.d.ts +15 -0
  38. package/dist/src/orchestration/application/delivery-preparation.js +100 -0
  39. package/dist/src/orchestration/application/delivery-sources.d.ts +10 -0
  40. package/dist/src/orchestration/application/delivery-sources.js +41 -0
  41. package/dist/src/orchestration/application/orchestration-repository.d.ts +3 -1
  42. package/dist/src/orchestration/application/orchestration-repository.js +10 -1
  43. package/dist/src/orchestration/application/orchestration-service.d.ts +268 -0
  44. package/dist/src/orchestration/application/orchestration-service.js +33 -4
  45. package/dist/src/orchestration/contracts/config.d.ts +16 -0
  46. package/dist/src/orchestration/contracts/config.js +7 -1
  47. package/dist/src/orchestration/contracts/delegation-ports.d.ts +4 -0
  48. package/dist/src/orchestration/contracts/delegation.d.ts +13 -1
  49. package/dist/src/orchestration/contracts/delegation.js +5 -0
  50. package/dist/src/orchestration/contracts/delivery-ports.d.ts +9 -0
  51. package/dist/src/orchestration/contracts/delivery-ports.js +1 -0
  52. package/dist/src/orchestration/contracts/delivery.d.ts +252 -0
  53. package/dist/src/orchestration/contracts/delivery.js +134 -0
  54. package/dist/src/orchestration/contracts/event-decoder.js +13 -1
  55. package/dist/src/orchestration/contracts/event-factory.js +6 -0
  56. package/dist/src/orchestration/contracts/events.d.ts +8 -0
  57. package/dist/src/orchestration/contracts/events.js +3 -0
  58. package/dist/src/orchestration/contracts/views.d.ts +3 -0
  59. package/dist/src/orchestration/contracts/vocabulary.d.ts +47 -0
  60. package/dist/src/orchestration/contracts/vocabulary.js +43 -0
  61. package/dist/src/orchestration/domain/compiler.js +2 -0
  62. package/dist/src/orchestration/domain/delivery-candidate.d.ts +9 -0
  63. package/dist/src/orchestration/domain/delivery-candidate.js +92 -0
  64. package/dist/src/orchestration/domain/delivery-facts.d.ts +83 -0
  65. package/dist/src/orchestration/domain/delivery-facts.js +34 -0
  66. package/dist/src/orchestration/domain/delivery-qa.d.ts +32 -0
  67. package/dist/src/orchestration/domain/delivery-qa.js +77 -0
  68. package/dist/src/orchestration/domain/delivery-replacement.d.ts +9 -0
  69. package/dist/src/orchestration/domain/delivery-replacement.js +54 -0
  70. package/dist/src/orchestration/domain/delivery-selection.d.ts +17 -0
  71. package/dist/src/orchestration/domain/delivery-selection.js +132 -0
  72. package/dist/src/orchestration/domain/delivery-workflow-policy.d.ts +4 -0
  73. package/dist/src/orchestration/domain/delivery-workflow-policy.js +13 -0
  74. package/dist/src/orchestration/domain/operator-retry-policy.js +24 -13
  75. package/dist/src/orchestration/domain/workflow-instance-events.d.ts +1 -0
  76. package/dist/src/orchestration/domain/workflow-instance-events.js +11 -0
  77. package/dist/src/orchestration/index.d.ts +2 -0
  78. package/dist/src/orchestration/index.js +1 -0
  79. package/dist/src/surfaces/api/contracts/work.d.ts +16 -0
  80. package/dist/src/surfaces/mcp/delegation.js +32 -1
  81. package/dist/src/surfaces/web-assets/assets/index-BfhxlN_h.js +1192 -0
  82. package/dist/src/surfaces/web-assets/index.html +1 -1
  83. package/package.json +1 -1
  84. package/dist/src/surfaces/web-assets/assets/index-C5R-aWzH.js +0 -1192
@@ -220,6 +220,14 @@ export declare const delegationPolicySchema: z.ZodObject<{
220
220
  maxDepth: z.ZodNumber;
221
221
  maxDescendants: z.ZodNumber;
222
222
  maxConcurrentRuns: z.ZodNumber;
223
+ completion: z.ZodOptional<z.ZodEnum<{
224
+ readonly QaApproved: "qa-approved";
225
+ readonly MergeRequired: "merge-required";
226
+ }>>;
227
+ qa: z.ZodOptional<z.ZodObject<{
228
+ stage: z.ZodString;
229
+ recipe: z.ZodOptional<z.ZodString>;
230
+ }, z.core.$strict>>;
223
231
  }, z.core.$strict>;
224
232
  export type DelegationPolicy = z.infer<typeof delegationPolicySchema>;
225
233
  export declare const workflowDefinitionConfigSchema: z.ZodObject<{
@@ -230,6 +238,14 @@ export declare const workflowDefinitionConfigSchema: z.ZodObject<{
230
238
  maxDepth: z.ZodNumber;
231
239
  maxDescendants: z.ZodNumber;
232
240
  maxConcurrentRuns: z.ZodNumber;
241
+ completion: z.ZodOptional<z.ZodEnum<{
242
+ readonly QaApproved: "qa-approved";
243
+ readonly MergeRequired: "merge-required";
244
+ }>>;
245
+ qa: z.ZodOptional<z.ZodObject<{
246
+ stage: z.ZodString;
247
+ recipe: z.ZodOptional<z.ZodString>;
248
+ }, z.core.$strict>>;
233
249
  }, z.core.$strict>>;
234
250
  commands: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
235
251
  activity: z.ZodString;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { ApprovalAuthorityKind, ConversationSurfaceCapability, WorkflowStatus, } from './vocabulary.js';
2
+ import { ApprovalAuthorityKind, ConversationSurfaceCapability, DeliveryCompletion, WorkflowStatus, } from './vocabulary.js';
3
3
  import { ActivityEventType, PullRequestCheckState, PullRequestDenialCode, PullRequestMergeability, PullRequestState, } from '../../activities/index.js';
4
4
  import { WorkspaceMode } from '../../execution/index.js';
5
5
  import { MatchMode } from '../../kernel/index.js';
@@ -158,6 +158,12 @@ export const delegationPolicySchema = z
158
158
  maxDepth: z.number().int().positive(),
159
159
  maxDescendants: z.number().int().positive(),
160
160
  maxConcurrentRuns: z.number().int().positive(),
161
+ /** Final gate for the parent: QA approval alone (default) or QA plus governed integration. */
162
+ completion: z.enum(DeliveryCompletion).optional(),
163
+ qa: z
164
+ .object({ stage: identifier, recipe: z.string().trim().min(1).optional() })
165
+ .strict()
166
+ .optional(),
161
167
  })
162
168
  .strict();
163
169
  export const workflowDefinitionConfigSchema = z
@@ -15,6 +15,10 @@ export interface DelegationArtifacts {
15
15
  qualifyingOutputs(child: WorkflowInstanceView, outputs: DelegatedAssignment['outputs']): Promise<DelegationResult['outputs'] | null>;
16
16
  }
17
17
  export interface DelegationAuthority {
18
+ assertQaCaller?(caller: DelegationCaller, candidateId: string, selectionRevision: number, revisions: readonly {
19
+ resourceId: string;
20
+ revision: string;
21
+ }[]): Promise<void>;
18
22
  assertCaller(caller: DelegationCaller, parent: WorkflowInstanceView): Promise<void>;
19
23
  repositories(parent: WorkflowInstanceView): Promise<readonly string[]>;
20
24
  /**
@@ -56,6 +56,10 @@ export declare const delegatedAssignmentSchema: z.ZodObject<{
56
56
  }>;
57
57
  useAsBase: z.ZodOptional<z.ZodBoolean>;
58
58
  }, z.core.$strict>>>;
59
+ replaces: z.ZodOptional<z.ZodObject<{
60
+ cohortId: z.ZodString;
61
+ assignmentId: z.ZodString;
62
+ }, z.core.$strict>>;
59
63
  outputs: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
60
64
  name: z.ZodString;
61
65
  path: z.ZodString;
@@ -81,8 +85,8 @@ export declare const delegationSubmissionSchema: z.ZodObject<{
81
85
  workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
82
86
  revisionId: z.ZodString;
83
87
  }, z.core.$strict>>;
84
- assignmentId: z.ZodString;
85
88
  criteria: z.ZodArray<z.ZodString>;
89
+ assignmentId: z.ZodString;
86
90
  workflowName: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").WorkflowName, string>>;
87
91
  repositoryResourceIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
88
92
  prerequisites: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -97,6 +101,10 @@ export declare const delegationSubmissionSchema: z.ZodObject<{
97
101
  }>;
98
102
  useAsBase: z.ZodOptional<z.ZodBoolean>;
99
103
  }, z.core.$strict>>>;
104
+ replaces: z.ZodOptional<z.ZodObject<{
105
+ cohortId: z.ZodString;
106
+ assignmentId: z.ZodString;
107
+ }, z.core.$strict>>;
100
108
  outputs: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
101
109
  name: z.ZodString;
102
110
  path: z.ZodString;
@@ -145,6 +153,10 @@ export declare const delegationReservationSchema: z.ZodObject<{
145
153
  }>;
146
154
  useAsBase: z.ZodOptional<z.ZodBoolean>;
147
155
  }, z.core.$strict>>>;
156
+ replaces: z.ZodOptional<z.ZodObject<{
157
+ cohortId: z.ZodString;
158
+ assignmentId: z.ZodString;
159
+ }, z.core.$strict>>;
148
160
  outputs: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
149
161
  name: z.ZodString;
150
162
  path: z.ZodString;
@@ -41,6 +41,11 @@ export const delegatedAssignmentSchema = z
41
41
  context: z.array(delegationRevisionReferenceSchema),
42
42
  repository: repositoryAssignmentRequestSchema.optional(),
43
43
  prerequisites: z.array(delegationPrerequisiteSchema).optional(),
44
+ /** Names the original required assignment this corrective child replaces. */
45
+ replaces: z
46
+ .object({ cohortId: z.string().min(1), assignmentId: z.string().min(1) })
47
+ .strict()
48
+ .optional(),
44
49
  outputs: z
45
50
  .array(z.union([
46
51
  z.object({ name: z.string().min(1), path: z.string().min(1) }).strict(),
@@ -0,0 +1,9 @@
1
+ import type { CompiledWorkflow } from './config.js';
2
+ import type { DelegationAuthority, DelegationRepositories } from './delegation-ports.js';
3
+ import type { WorkflowInstanceView } from './views.js';
4
+ export interface DeliveryDependencies {
5
+ readonly authority: DelegationAuthority;
6
+ /** Resolves a repository source through the parent's own repository authority. */
7
+ readonly repositories?: DelegationRepositories | undefined;
8
+ readonly definitionFor: (parent: WorkflowInstanceView) => Promise<CompiledWorkflow>;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,252 @@
1
+ import { z } from 'zod';
2
+ import type { StageName } from './identifiers.js';
3
+ import { type DeliveryRejection } from './vocabulary.js';
4
+ export declare const deliveryOutputKeySchema: z.ZodObject<{
5
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
6
+ outputName: z.ZodString;
7
+ }, z.core.$strict>;
8
+ export type DeliveryOutputKey = z.infer<typeof deliveryOutputKeySchema>;
9
+ export declare const deliverySelectionEntrySchema: z.ZodObject<{
10
+ cohortId: z.ZodString;
11
+ assignmentId: z.ZodString;
12
+ output: z.ZodObject<{
13
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
14
+ outputName: z.ZodString;
15
+ }, z.core.$strict>;
16
+ replaces: z.ZodOptional<z.ZodObject<{
17
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
18
+ outputName: z.ZodString;
19
+ }, z.core.$strict>>;
20
+ }, z.core.$strict>;
21
+ /** Agent input: the complete current selection, so an omitted requirement cannot be waived. */
22
+ export declare const deliverySelectionCommandSchema: z.ZodObject<{
23
+ requestId: z.ZodString;
24
+ expectedRevision: z.ZodNumber;
25
+ entries: z.ZodArray<z.ZodObject<{
26
+ cohortId: z.ZodString;
27
+ assignmentId: z.ZodString;
28
+ output: z.ZodObject<{
29
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
30
+ outputName: z.ZodString;
31
+ }, z.core.$strict>;
32
+ replaces: z.ZodOptional<z.ZodObject<{
33
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
34
+ outputName: z.ZodString;
35
+ }, z.core.$strict>>;
36
+ }, z.core.$strict>>;
37
+ }, z.core.$strict>;
38
+ export type DeliverySelectionCommand = z.infer<typeof deliverySelectionCommandSchema>;
39
+ export declare const selectedEntrySchema: z.ZodObject<{
40
+ cohortId: z.ZodString;
41
+ assignmentId: z.ZodString;
42
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
43
+ output: z.ZodObject<{
44
+ name: z.ZodString;
45
+ reference: z.ZodUnion<readonly [z.ZodObject<{
46
+ workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
47
+ revisionId: z.ZodString;
48
+ }, z.core.$strict>, z.ZodObject<{
49
+ workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
50
+ resourceId: z.ZodString;
51
+ repositoryResourceId: z.ZodString;
52
+ revision: z.ZodString;
53
+ branch: z.ZodString;
54
+ pullRequestBase: z.ZodString;
55
+ runId: z.ZodString;
56
+ baseRevision: z.ZodOptional<z.ZodString>;
57
+ merged: z.ZodOptional<z.ZodLiteral<true>>;
58
+ }, z.core.$strict>]>;
59
+ }, z.core.$strict>;
60
+ replaces: z.ZodOptional<z.ZodObject<{
61
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
62
+ outputName: z.ZodString;
63
+ }, z.core.$strict>>;
64
+ }, z.core.$strict>;
65
+ export type SelectedEntry = z.infer<typeof selectedEntrySchema>;
66
+ export declare const deliverySelectionSchema: z.ZodObject<{
67
+ requestId: z.ZodString;
68
+ revision: z.ZodNumber;
69
+ entries: z.ZodArray<z.ZodObject<{
70
+ cohortId: z.ZodString;
71
+ assignmentId: z.ZodString;
72
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
73
+ output: z.ZodObject<{
74
+ name: z.ZodString;
75
+ reference: z.ZodUnion<readonly [z.ZodObject<{
76
+ workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
77
+ revisionId: z.ZodString;
78
+ }, z.core.$strict>, z.ZodObject<{
79
+ workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
80
+ resourceId: z.ZodString;
81
+ repositoryResourceId: z.ZodString;
82
+ revision: z.ZodString;
83
+ branch: z.ZodString;
84
+ pullRequestBase: z.ZodString;
85
+ runId: z.ZodString;
86
+ baseRevision: z.ZodOptional<z.ZodString>;
87
+ merged: z.ZodOptional<z.ZodLiteral<true>>;
88
+ }, z.core.$strict>]>;
89
+ }, z.core.$strict>;
90
+ replaces: z.ZodOptional<z.ZodObject<{
91
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
92
+ outputName: z.ZodString;
93
+ }, z.core.$strict>>;
94
+ }, z.core.$strict>>;
95
+ }, z.core.$strict>;
96
+ export type DeliverySelection = z.infer<typeof deliverySelectionSchema>;
97
+ export declare const candidateSourceInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
98
+ kind: z.ZodLiteral<"output">;
99
+ tip: z.ZodObject<{
100
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
101
+ outputName: z.ZodString;
102
+ }, z.core.$strict>;
103
+ includes: z.ZodOptional<z.ZodArray<z.ZodObject<{
104
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
105
+ outputName: z.ZodString;
106
+ }, z.core.$strict>>>;
107
+ }, z.core.$strict>, z.ZodObject<{
108
+ kind: z.ZodLiteral<"retained-ref">;
109
+ ref: z.ZodString;
110
+ revision: z.ZodString;
111
+ contributions: z.ZodArray<z.ZodObject<{
112
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
113
+ outputName: z.ZodString;
114
+ }, z.core.$strict>>;
115
+ }, z.core.$strict>], "kind">;
116
+ export declare const deliveryCandidateCommandSchema: z.ZodObject<{
117
+ candidateId: z.ZodString;
118
+ selectionRevision: z.ZodNumber;
119
+ repositories: z.ZodArray<z.ZodObject<{
120
+ resourceId: z.ZodString;
121
+ source: z.ZodDiscriminatedUnion<[z.ZodObject<{
122
+ kind: z.ZodLiteral<"output">;
123
+ tip: z.ZodObject<{
124
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
125
+ outputName: z.ZodString;
126
+ }, z.core.$strict>;
127
+ includes: z.ZodOptional<z.ZodArray<z.ZodObject<{
128
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
129
+ outputName: z.ZodString;
130
+ }, z.core.$strict>>>;
131
+ }, z.core.$strict>, z.ZodObject<{
132
+ kind: z.ZodLiteral<"retained-ref">;
133
+ ref: z.ZodString;
134
+ revision: z.ZodString;
135
+ contributions: z.ZodArray<z.ZodObject<{
136
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
137
+ outputName: z.ZodString;
138
+ }, z.core.$strict>>;
139
+ }, z.core.$strict>], "kind">;
140
+ }, z.core.$strict>>;
141
+ recipe: z.ZodOptional<z.ZodString>;
142
+ }, z.core.$strict>;
143
+ export type DeliveryCandidateCommand = z.infer<typeof deliveryCandidateCommandSchema>;
144
+ export declare const candidateRepositorySchema: z.ZodObject<{
145
+ resourceId: z.ZodString;
146
+ revision: z.ZodString;
147
+ pullRequestBase: z.ZodString;
148
+ source: z.ZodUnion<readonly [z.ZodObject<{
149
+ kind: z.ZodLiteral<"output">;
150
+ tip: z.ZodObject<{
151
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
152
+ outputName: z.ZodString;
153
+ }, z.core.$strict>;
154
+ }, z.core.$strict>, z.ZodObject<{
155
+ kind: z.ZodLiteral<"retained-ref">;
156
+ ref: z.ZodString;
157
+ }, z.core.$strict>]>;
158
+ contributions: z.ZodArray<z.ZodObject<{
159
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
160
+ outputName: z.ZodString;
161
+ }, z.core.$strict>>;
162
+ }, z.core.$strict>;
163
+ export declare const deliveryCandidateSchema: z.ZodObject<{
164
+ candidateId: z.ZodString;
165
+ selectionRevision: z.ZodNumber;
166
+ repositories: z.ZodArray<z.ZodObject<{
167
+ resourceId: z.ZodString;
168
+ revision: z.ZodString;
169
+ pullRequestBase: z.ZodString;
170
+ source: z.ZodUnion<readonly [z.ZodObject<{
171
+ kind: z.ZodLiteral<"output">;
172
+ tip: z.ZodObject<{
173
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
174
+ outputName: z.ZodString;
175
+ }, z.core.$strict>;
176
+ }, z.core.$strict>, z.ZodObject<{
177
+ kind: z.ZodLiteral<"retained-ref">;
178
+ ref: z.ZodString;
179
+ }, z.core.$strict>]>;
180
+ contributions: z.ZodArray<z.ZodObject<{
181
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
182
+ outputName: z.ZodString;
183
+ }, z.core.$strict>>;
184
+ }, z.core.$strict>>;
185
+ context: z.ZodArray<z.ZodObject<{
186
+ childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
187
+ outputName: z.ZodString;
188
+ }, z.core.$strict>>;
189
+ criteria: z.ZodArray<z.ZodString>;
190
+ recipe: z.ZodOptional<z.ZodString>;
191
+ }, z.core.$strict>;
192
+ export type DeliveryCandidate = z.infer<typeof deliveryCandidateSchema>;
193
+ export declare const deliveryQaCommandSchema: z.ZodObject<{
194
+ qaId: z.ZodString;
195
+ candidateId: z.ZodString;
196
+ verdict: z.ZodEnum<{
197
+ readonly Pass: "pass";
198
+ readonly Fail: "fail";
199
+ readonly Blocked: "blocked";
200
+ }>;
201
+ revisions: z.ZodArray<z.ZodObject<{
202
+ resourceId: z.ZodString;
203
+ revision: z.ZodString;
204
+ }, z.core.$strict>>;
205
+ environment: z.ZodObject<{
206
+ recipe: z.ZodOptional<z.ZodString>;
207
+ available: z.ZodBoolean;
208
+ }, z.core.$strict>;
209
+ findings: z.ZodDefault<z.ZodArray<z.ZodString>>;
210
+ evidence: z.ZodOptional<z.ZodArray<z.ZodObject<{
211
+ workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
212
+ revisionId: z.ZodString;
213
+ }, z.core.$strict>>>;
214
+ }, z.core.$strict>;
215
+ export type DeliveryQaCommand = z.infer<typeof deliveryQaCommandSchema>;
216
+ export declare const deliveryQaSchema: z.ZodObject<{
217
+ qaId: z.ZodString;
218
+ candidateId: z.ZodString;
219
+ verdict: z.ZodEnum<{
220
+ readonly Pass: "pass";
221
+ readonly Fail: "fail";
222
+ readonly Blocked: "blocked";
223
+ }>;
224
+ revisions: z.ZodArray<z.ZodObject<{
225
+ resourceId: z.ZodString;
226
+ revision: z.ZodString;
227
+ }, z.core.$strict>>;
228
+ environment: z.ZodObject<{
229
+ recipe: z.ZodOptional<z.ZodString>;
230
+ available: z.ZodBoolean;
231
+ }, z.core.$strict>;
232
+ findings: z.ZodDefault<z.ZodArray<z.ZodString>>;
233
+ evidence: z.ZodOptional<z.ZodArray<z.ZodObject<{
234
+ workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
235
+ revisionId: z.ZodString;
236
+ }, z.core.$strict>>>;
237
+ exhausted: z.ZodOptional<z.ZodBoolean>;
238
+ runId: z.ZodOptional<z.ZodString>;
239
+ activationId: z.ZodOptional<z.ZodString>;
240
+ }, z.core.$strict>;
241
+ export type DeliveryQa = z.infer<typeof deliveryQaSchema>;
242
+ /** A final delivery gate can be reassessed through ordinary operator retry. */
243
+ export interface DeliveryCompletionBlock {
244
+ readonly reason: string;
245
+ readonly deliveryGate: {
246
+ readonly retryStage: StageName;
247
+ };
248
+ }
249
+ export declare class DeliveryRejectionError extends Error {
250
+ readonly code: DeliveryRejection;
251
+ constructor(code: DeliveryRejection, message: string);
252
+ }
@@ -0,0 +1,134 @@
1
+ import { z } from 'zod';
2
+ import { brandedStringSchema } from '../../kernel/index.js';
3
+ import { workItemId } from '../../work/index.js';
4
+ import { delegationResultSchema } from './delegation.js';
5
+ import { CandidateSourceKind, QaVerdict } from './vocabulary.js';
6
+ const revision = z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i);
7
+ export const deliveryOutputKeySchema = z
8
+ .object({ childWorkItemId: brandedStringSchema(workItemId), outputName: z.string().min(1) })
9
+ .strict();
10
+ export const deliverySelectionEntrySchema = z
11
+ .object({
12
+ /** The original required assignment this entry covers. */
13
+ cohortId: z.string().min(1),
14
+ assignmentId: z.string().min(1),
15
+ output: deliveryOutputKeySchema,
16
+ /** Required exactly when the output is from a replacement; the output selected until now. */
17
+ replaces: deliveryOutputKeySchema.optional(),
18
+ })
19
+ .strict();
20
+ /** Agent input: the complete current selection, so an omitted requirement cannot be waived. */
21
+ export const deliverySelectionCommandSchema = z
22
+ .object({
23
+ requestId: z.string().min(1),
24
+ expectedRevision: z.number().int().nonnegative(),
25
+ entries: z.array(deliverySelectionEntrySchema).min(1),
26
+ })
27
+ .strict();
28
+ const deliveryOutputSchema = delegationResultSchema.shape.outputs.element;
29
+ export const selectedEntrySchema = z
30
+ .object({
31
+ cohortId: z.string().min(1),
32
+ assignmentId: z.string().min(1),
33
+ childWorkItemId: brandedStringSchema(workItemId),
34
+ output: deliveryOutputSchema,
35
+ replaces: deliveryOutputKeySchema.optional(),
36
+ })
37
+ .strict();
38
+ export const deliverySelectionSchema = z
39
+ .object({
40
+ requestId: z.string().min(1),
41
+ revision: z.number().int().positive(),
42
+ entries: z.array(selectedEntrySchema).min(1),
43
+ })
44
+ .strict();
45
+ export const candidateSourceInputSchema = z.discriminatedUnion('kind', [
46
+ z
47
+ .object({
48
+ kind: z.literal(CandidateSourceKind.Output),
49
+ /** The tip; `includes` declares the other selected outputs of an intentional stack. */
50
+ tip: deliveryOutputKeySchema,
51
+ includes: z.array(deliveryOutputKeySchema).optional(),
52
+ })
53
+ .strict(),
54
+ z
55
+ .object({
56
+ kind: z.literal(CandidateSourceKind.RetainedRef),
57
+ ref: z.string().min(1),
58
+ revision,
59
+ contributions: z.array(deliveryOutputKeySchema).min(1),
60
+ })
61
+ .strict(),
62
+ ]);
63
+ export const deliveryCandidateCommandSchema = z
64
+ .object({
65
+ candidateId: z.string().regex(/^[a-z0-9][a-z0-9-]{0,62}$/),
66
+ selectionRevision: z.number().int().positive(),
67
+ repositories: z
68
+ .array(z.object({ resourceId: z.string().min(1), source: candidateSourceInputSchema }).strict())
69
+ .min(1),
70
+ /** The configured environment and test recipe QA must follow. */
71
+ recipe: z.string().trim().min(1).optional(),
72
+ })
73
+ .strict();
74
+ export const candidateRepositorySchema = z
75
+ .object({
76
+ resourceId: z.string().min(1),
77
+ revision,
78
+ pullRequestBase: z.string().min(1),
79
+ source: z.union([
80
+ z
81
+ .object({ kind: z.literal(CandidateSourceKind.Output), tip: deliveryOutputKeySchema })
82
+ .strict(),
83
+ z
84
+ .object({ kind: z.literal(CandidateSourceKind.RetainedRef), ref: z.string().min(1) })
85
+ .strict(),
86
+ ]),
87
+ contributions: z.array(deliveryOutputKeySchema).min(1),
88
+ })
89
+ .strict();
90
+ export const deliveryCandidateSchema = z
91
+ .object({
92
+ candidateId: z.string().min(1),
93
+ selectionRevision: z.number().int().positive(),
94
+ repositories: z.array(candidateRepositorySchema).min(1),
95
+ /** Non-change outputs (plans, evidence) the candidate was selected with. */
96
+ context: z.array(deliveryOutputKeySchema),
97
+ criteria: z.array(z.string().min(1)),
98
+ recipe: z.string().min(1).optional(),
99
+ })
100
+ .strict();
101
+ export const deliveryQaCommandSchema = z
102
+ .object({
103
+ qaId: z.string().regex(/^[a-z0-9][a-z0-9-]{0,62}$/),
104
+ candidateId: z.string().min(1),
105
+ verdict: z.enum(QaVerdict),
106
+ /** The exact revision per repository the QA run checked; must equal the candidate's set. */
107
+ revisions: z.array(z.object({ resourceId: z.string().min(1), revision }).strict()).min(1),
108
+ environment: z
109
+ .object({ recipe: z.string().min(1).optional(), available: z.boolean() })
110
+ .strict(),
111
+ findings: z.array(z.string().trim().min(1)).default([]),
112
+ evidence: z
113
+ .array(z
114
+ .object({ workItemId: brandedStringSchema(workItemId), revisionId: z.string().min(1) })
115
+ .strict())
116
+ .optional(),
117
+ })
118
+ .strict();
119
+ export const deliveryQaSchema = deliveryQaCommandSchema
120
+ .extend({
121
+ /** Set when this failure used the last descendant slot: the parent must escalate. */
122
+ exhausted: z.boolean().optional(),
123
+ runId: z.string().min(1).optional(),
124
+ activationId: z.string().min(1).optional(),
125
+ })
126
+ .strict();
127
+ export class DeliveryRejectionError extends Error {
128
+ code;
129
+ constructor(code, message) {
130
+ super(message);
131
+ this.code = code;
132
+ this.name = 'DeliveryRejectionError';
133
+ }
134
+ }
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable max-lines */
2
2
  import { z } from 'zod';
3
3
  import { delegationAttentionRequestSchema, delegationAttentionResolvedSchema, delegationAttentionResponseSchema, delegationInputsSchema, delegationJoinSchema, delegationReservationSchema, delegationResultSchema, delegationWaitSchema, } from './delegation.js';
4
+ import { deliveryCandidateSchema, deliveryQaSchema, deliverySelectionSchema } from './delivery.js';
4
5
  import { eventDataSchema, eventEnvelopeSchema } from '@atolis-hq/eventing';
5
6
  import { activationId, ActivityEventType, activityName, ActivityOutcomeKind, PullRequestCheckState, PullRequestMergeability, PullRequestState, } from '../../activities/index.js';
6
7
  import { WorkspaceMode } from '../../execution/index.js';
@@ -228,6 +229,9 @@ const eventSchemas = {
228
229
  [OrchestrationEventType.DelegationAttentionResolved]: workflowEnvelope(OrchestrationEventType.DelegationAttentionResolved, delegationAttentionResolvedSchema),
229
230
  [OrchestrationEventType.DelegationFailed]: workflowEnvelope(OrchestrationEventType.DelegationFailed, z.object({ cohortId: z.string().min(1), reason: z.string().min(1) }).strict()),
230
231
  [OrchestrationEventType.DelegationReconciliationFailed]: workflowEnvelope(OrchestrationEventType.DelegationReconciliationFailed, z.object({ cohortId: z.string().min(1), reason: z.string().min(1) }).strict()),
232
+ [OrchestrationEventType.DeliverySelectionRevised]: workflowEnvelope(OrchestrationEventType.DeliverySelectionRevised, deliverySelectionSchema),
233
+ [OrchestrationEventType.DeliveryCandidateRecorded]: workflowEnvelope(OrchestrationEventType.DeliveryCandidateRecorded, deliveryCandidateSchema),
234
+ [OrchestrationEventType.DeliveryQaRecorded]: workflowEnvelope(OrchestrationEventType.DeliveryQaRecorded, deliveryQaSchema),
231
235
  [OrchestrationEventType.DelegationReserved]: workflowEnvelope(OrchestrationEventType.DelegationReserved, delegationReservationSchema),
232
236
  [OrchestrationEventType.DelegationRegistered]: workflowEnvelope(OrchestrationEventType.DelegationRegistered, z.object({ cohortId: z.string().min(1) }).strict()),
233
237
  [OrchestrationEventType.DelegationResultSelected]: workflowEnvelope(OrchestrationEventType.DelegationResultSelected, delegationResultSchema),
@@ -324,7 +328,15 @@ const eventSchemas = {
324
328
  [OrchestrationEventType.RepeatCounted]: workflowEnvelope(OrchestrationEventType.RepeatCounted, z.object({ routeId: z.string().min(1), count: z.number().int().positive() }).strict()),
325
329
  [OrchestrationEventType.RetryCounted]: workflowEnvelope(OrchestrationEventType.RetryCounted, z.object({ retryKey: z.string().min(1), count: z.number().int().positive() }).strict()),
326
330
  [OrchestrationEventType.InstanceCompleted]: workflowEnvelope(OrchestrationEventType.InstanceCompleted, emptySchema),
327
- [OrchestrationEventType.InstanceBlocked]: workflowEnvelope(OrchestrationEventType.InstanceBlocked, z.object({ reason: z.string() }).strict()),
331
+ [OrchestrationEventType.InstanceBlocked]: workflowEnvelope(OrchestrationEventType.InstanceBlocked, z
332
+ .object({
333
+ reason: z.string(),
334
+ deliveryGate: z
335
+ .object({ retryStage: brandedStringSchema(stageName) })
336
+ .strict()
337
+ .optional(),
338
+ })
339
+ .strict()),
328
340
  [OrchestrationEventType.OperatorRetryRequested]: workflowEnvelope(OrchestrationEventType.OperatorRetryRequested, z
329
341
  .object({
330
342
  activationId: brandedStringSchema(activationId),
@@ -18,6 +18,12 @@ export function createOrchestrationEventData(input) {
18
18
  return createEventData(input);
19
19
  case OrchestrationEventType.DelegationAttentionResolved:
20
20
  return createEventData(input);
21
+ case OrchestrationEventType.DeliverySelectionRevised:
22
+ return createEventData(input);
23
+ case OrchestrationEventType.DeliveryCandidateRecorded:
24
+ return createEventData(input);
25
+ case OrchestrationEventType.DeliveryQaRecorded:
26
+ return createEventData(input);
21
27
  case OrchestrationEventType.DelegationReserved:
22
28
  return createEventData(input);
23
29
  case OrchestrationEventType.DelegationRegistered:
@@ -4,6 +4,7 @@ import type { WorkItemId } from '../../work/index.js';
4
4
  import type { OrchestrationWaitingActivityOutcome } from './activity-outcome.js';
5
5
  import type { ApprovalAuthority, CompiledResourceTransition, CompiledWorkflow, StageConfig, TransitionTarget } from './config.js';
6
6
  import type { DelegationAttentionRequest, DelegationAttentionResponse, DelegationInputs, DelegationReservation, DelegationResult } from './delegation.js';
7
+ import type { DeliveryCandidate, DeliveryCompletionBlock, DeliveryQa, DeliverySelection } from './delivery.js';
7
8
  import type { CommandName, OrchestrationGroupId, SignalName, StageName, WorkflowInstanceId, WorkflowName } from './identifiers.js';
8
9
  import type { ChildOrchestrationGroupStreamId, ChildOrchestrationGroupStreamRef, PrimaryOrchestrationGroupStreamRef, WorkflowDefinitionsStreamRef, WorkflowInstanceStreamRef } from './streams.js';
9
10
  export declare const OrchestrationEventType: {
@@ -20,6 +21,9 @@ export declare const OrchestrationEventType: {
20
21
  readonly DelegationAttentionResponded: "orchestration.delegation-attention-responded";
21
22
  readonly DelegationAttentionResolved: "orchestration.delegation-attention-resolved";
22
23
  readonly DelegationReconciliationFailed: "orchestration.delegation-reconciliation-failed";
24
+ readonly DeliverySelectionRevised: "orchestration.delivery-selection-revised";
25
+ readonly DeliveryCandidateRecorded: "orchestration.delivery-candidate-recorded";
26
+ readonly DeliveryQaRecorded: "orchestration.delivery-qa-recorded";
23
27
  readonly WorkflowDefinitionRegistered: "orchestration.workflow-definition-registered";
24
28
  readonly InstanceStarted: "orchestration.instance-started";
25
29
  readonly StageEntered: "orchestration.stage-entered";
@@ -88,6 +92,9 @@ export interface OrchestrationEventPayloads {
88
92
  readonly cohortId: string;
89
93
  readonly reason: string;
90
94
  };
95
+ readonly [OrchestrationEventType.DeliverySelectionRevised]: DeliverySelection;
96
+ readonly [OrchestrationEventType.DeliveryCandidateRecorded]: DeliveryCandidate;
97
+ readonly [OrchestrationEventType.DeliveryQaRecorded]: DeliveryQa;
91
98
  readonly [OrchestrationEventType.DelegationReserved]: DelegationReservation;
92
99
  readonly [OrchestrationEventType.DelegationRegistered]: {
93
100
  readonly cohortId: string;
@@ -167,6 +174,7 @@ export interface OrchestrationEventPayloads {
167
174
  readonly [OrchestrationEventType.InstanceCompleted]: Readonly<Record<never, never>>;
168
175
  readonly [OrchestrationEventType.InstanceBlocked]: {
169
176
  readonly reason: string;
177
+ readonly deliveryGate?: DeliveryCompletionBlock['deliveryGate'];
170
178
  };
171
179
  readonly [OrchestrationEventType.OperatorRetryRequested]: {
172
180
  readonly activationId: ActivationId;
@@ -13,6 +13,9 @@ export const OrchestrationEventType = {
13
13
  DelegationAttentionResponded: 'orchestration.delegation-attention-responded',
14
14
  DelegationAttentionResolved: 'orchestration.delegation-attention-resolved',
15
15
  DelegationReconciliationFailed: 'orchestration.delegation-reconciliation-failed',
16
+ DeliverySelectionRevised: 'orchestration.delivery-selection-revised',
17
+ DeliveryCandidateRecorded: 'orchestration.delivery-candidate-recorded',
18
+ DeliveryQaRecorded: 'orchestration.delivery-qa-recorded',
16
19
  WorkflowDefinitionRegistered: 'orchestration.workflow-definition-registered',
17
20
  InstanceStarted: 'orchestration.instance-started',
18
21
  StageEntered: 'orchestration.stage-entered',
@@ -66,6 +66,9 @@ export interface WorkflowInstanceView {
66
66
  };
67
67
  readonly status: WorkflowStatus;
68
68
  readonly blockReason?: string;
69
+ readonly deliveryGateBlock?: {
70
+ readonly retryStage: StageName;
71
+ };
69
72
  readonly currentStage: StageName;
70
73
  readonly pendingActivation?: ActivityActivationView;
71
74
  readonly repeatCounts: Readonly<Record<string, number>>;