@atolis-hq/wake 0.4.104 → 0.4.106
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.
- package/dist/src/activities/agent/agent-activity.js +10 -0
- package/dist/src/activities/contracts/activity.d.ts +28 -0
- package/dist/src/activities/contracts/event-schema.d.ts +314 -8
- package/dist/src/activities/contracts/event-schema.js +20 -2
- package/dist/src/activities/contracts/events.d.ts +10 -0
- package/dist/src/activities/contracts/vocabulary.d.ts +2 -0
- package/dist/src/activities/contracts/vocabulary.js +2 -0
- package/dist/src/activities/index.d.ts +2 -0
- package/dist/src/activities/index.js +2 -0
- package/dist/src/activities/pr/activity-support.d.ts +1 -1
- package/dist/src/activities/pr/activity-support.js +10 -0
- package/dist/src/activities/pr/application.js +8 -1
- package/dist/src/activities/pr/approve.d.ts +2 -1
- package/dist/src/activities/pr/approve.js +33 -11
- package/dist/src/activities/pr/check-evidence.d.ts +10 -0
- package/dist/src/activities/pr/check-evidence.js +16 -0
- package/dist/src/activities/pr/contracts.d.ts +14 -0
- package/dist/src/activities/pr/event-data.js +5 -1
- package/dist/src/activities/pr/merge.d.ts +2 -1
- package/dist/src/activities/pr/merge.js +54 -38
- package/dist/src/activities/pr/parent-scope.d.ts +65 -0
- package/dist/src/activities/pr/parent-scope.js +24 -0
- package/dist/src/activities/pr/parent-target.d.ts +45 -0
- package/dist/src/activities/pr/parent-target.js +59 -0
- package/dist/src/activities/pr/projection.js +10 -2
- package/dist/src/activities/pr/vocabulary.d.ts +8 -0
- package/dist/src/activities/pr/vocabulary.js +8 -0
- package/dist/src/bootstrap/activity-registry.d.ts +2 -2
- package/dist/src/bootstrap/activity-registry.js +3 -3
- package/dist/src/bootstrap/composition-root.js +11 -2
- package/dist/src/bootstrap/config/root-schema.d.ts +22 -0
- package/dist/src/bootstrap/delegation-authority.js +17 -0
- package/dist/src/bootstrap/delivery-integration.d.ts +9 -0
- package/dist/src/bootstrap/delivery-integration.js +46 -0
- package/dist/src/bootstrap/surface-api-delivery.js +52 -0
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/control-plane/application/activation-scheduler-ports.d.ts +5 -1
- package/dist/src/control-plane/application/advance-once-dispatch.js +12 -6
- package/dist/src/execution/application/candidate-workspaces.d.ts +13 -0
- package/dist/src/execution/application/candidate-workspaces.js +75 -0
- package/dist/src/execution/application/execution-service.js +37 -11
- package/dist/src/execution/application/maintenance-workspaces.d.ts +17 -0
- package/dist/src/execution/application/maintenance-workspaces.js +84 -0
- package/dist/src/execution/application/run-lifecycle.js +2 -0
- package/dist/src/execution/contracts/candidate.d.ts +31 -0
- package/dist/src/execution/contracts/candidate.js +40 -0
- package/dist/src/execution/contracts/commands.d.ts +4 -0
- package/dist/src/execution/contracts/events.d.ts +24 -0
- package/dist/src/execution/contracts/events.js +4 -0
- package/dist/src/execution/contracts/maintenance.d.ts +36 -0
- package/dist/src/execution/contracts/maintenance.js +44 -0
- package/dist/src/execution/contracts/repository-assignment.d.ts +5 -0
- package/dist/src/execution/contracts/repository-assignment.js +8 -0
- package/dist/src/execution/contracts/views.d.ts +4 -0
- package/dist/src/execution/contracts/vocabulary.d.ts +5 -0
- package/dist/src/execution/contracts/vocabulary.js +4 -0
- package/dist/src/execution/contracts/workspace.d.ts +8 -0
- package/dist/src/execution/index.d.ts +2 -0
- package/dist/src/execution/index.js +2 -0
- package/dist/src/execution/infrastructure/workspace/git-source.d.ts +2 -2
- package/dist/src/execution/infrastructure/workspace/git-source.js +18 -1
- package/dist/src/execution/infrastructure/workspace/git-workspace.d.ts +2 -4
- package/dist/src/execution/infrastructure/workspace/git-workspace.js +12 -1
- package/dist/src/integrations/application/delegation-outputs.js +1 -1
- package/dist/src/integrations/application/delivery-integration-verification.d.ts +13 -0
- package/dist/src/integrations/application/delivery-integration-verification.js +68 -0
- package/dist/src/integrations/delivery/application/delivery-projector.js +3 -0
- package/dist/src/integrations/delivery/application/merged-delivery-evidence.js +9 -1
- package/dist/src/integrations/delivery/contracts/views.d.ts +2 -0
- package/dist/src/integrations/fake/external-source.d.ts +5 -2
- package/dist/src/integrations/fake/external-source.js +12 -2
- package/dist/src/integrations/fake/inbound-translator.js +7 -2
- package/dist/src/integrations/fake/provider.d.ts +17 -0
- package/dist/src/integrations/fake/provider.js +18 -2
- package/dist/src/integrations/github/application/pull-request-translation.js +2 -0
- package/dist/src/integrations/github/contracts/events.d.ts +3 -1
- package/dist/src/integrations/github/contracts/events.js +3 -1
- package/dist/src/integrations/github/contracts/payloads.d.ts +23 -0
- package/dist/src/integrations/github/infrastructure/check-execution.d.ts +9 -0
- package/dist/src/integrations/github/infrastructure/check-execution.js +68 -0
- package/dist/src/integrations/github/infrastructure/checkout-revision.d.ts +2 -0
- package/dist/src/integrations/github/infrastructure/checkout-revision.js +23 -0
- package/dist/src/integrations/github/infrastructure/client.d.ts +2 -0
- package/dist/src/integrations/github/infrastructure/client.js +4 -0
- package/dist/src/integrations/github/infrastructure/pr-check-subject.d.ts +7 -0
- package/dist/src/integrations/github/infrastructure/pr-check-subject.js +77 -0
- package/dist/src/integrations/github/infrastructure/pr-evidence.d.ts +6 -3
- package/dist/src/integrations/github/infrastructure/pr-evidence.js +1 -1
- package/dist/src/integrations/github/infrastructure/pr-source.d.ts +3 -5
- package/dist/src/integrations/github/infrastructure/pr-source.js +11 -1
- package/dist/src/integrations/github/infrastructure/workflow-run-evidence.d.ts +5 -0
- package/dist/src/integrations/github/infrastructure/workflow-run-evidence.js +22 -0
- package/dist/src/integrations/index.d.ts +1 -0
- package/dist/src/integrations/index.js +1 -0
- package/dist/src/orchestration/application/delegated-work.d.ts +5 -0
- package/dist/src/orchestration/application/delegated-work.js +10 -0
- package/dist/src/orchestration/application/delegation-commands.d.ts +16 -0
- package/dist/src/orchestration/application/delivery-coordinator.d.ts +348 -0
- package/dist/src/orchestration/application/delivery-coordinator.js +239 -0
- package/dist/src/orchestration/application/delivery-facts-reader.d.ts +9 -0
- package/dist/src/orchestration/application/delivery-facts-reader.js +47 -0
- package/dist/src/orchestration/application/delivery-integration-reader.d.ts +9 -0
- package/dist/src/orchestration/application/delivery-integration-reader.js +23 -0
- package/dist/src/orchestration/application/delivery-integration-service.d.ts +50 -0
- package/dist/src/orchestration/application/delivery-integration-service.js +228 -0
- package/dist/src/orchestration/application/delivery-preparation.d.ts +16 -0
- package/dist/src/orchestration/application/delivery-preparation.js +105 -0
- package/dist/src/orchestration/application/delivery-sources.d.ts +10 -0
- package/dist/src/orchestration/application/delivery-sources.js +41 -0
- package/dist/src/orchestration/application/orchestration-repository.d.ts +3 -1
- package/dist/src/orchestration/application/orchestration-repository.js +10 -1
- package/dist/src/orchestration/application/orchestration-service.d.ts +341 -2
- package/dist/src/orchestration/application/orchestration-service.js +86 -4
- package/dist/src/orchestration/contracts/config.d.ts +22 -0
- package/dist/src/orchestration/contracts/config.js +13 -1
- package/dist/src/orchestration/contracts/delegation-ports.d.ts +4 -0
- package/dist/src/orchestration/contracts/delegation.d.ts +13 -1
- package/dist/src/orchestration/contracts/delegation.js +5 -0
- package/dist/src/orchestration/contracts/delivery-ports.d.ts +53 -0
- package/dist/src/orchestration/contracts/delivery-ports.js +1 -0
- package/dist/src/orchestration/contracts/delivery.d.ts +310 -0
- package/dist/src/orchestration/contracts/delivery.js +186 -0
- package/dist/src/orchestration/contracts/event-decoder.js +14 -1
- package/dist/src/orchestration/contracts/event-factory.js +8 -0
- package/dist/src/orchestration/contracts/events.d.ts +10 -0
- package/dist/src/orchestration/contracts/events.js +4 -0
- package/dist/src/orchestration/contracts/views.d.ts +3 -0
- package/dist/src/orchestration/contracts/vocabulary.d.ts +90 -0
- package/dist/src/orchestration/contracts/vocabulary.js +82 -0
- package/dist/src/orchestration/domain/compile-diagnostics.d.ts +1 -1
- package/dist/src/orchestration/domain/compile-diagnostics.js +5 -0
- package/dist/src/orchestration/domain/compiler.js +2 -0
- package/dist/src/orchestration/domain/delivery-candidate.d.ts +9 -0
- package/dist/src/orchestration/domain/delivery-candidate.js +105 -0
- package/dist/src/orchestration/domain/delivery-facts.d.ts +89 -0
- package/dist/src/orchestration/domain/delivery-facts.js +66 -0
- package/dist/src/orchestration/domain/delivery-integration-policy.d.ts +7 -0
- package/dist/src/orchestration/domain/delivery-integration-policy.js +15 -0
- package/dist/src/orchestration/domain/delivery-integration.d.ts +54 -0
- package/dist/src/orchestration/domain/delivery-integration.js +144 -0
- package/dist/src/orchestration/domain/delivery-qa.d.ts +33 -0
- package/dist/src/orchestration/domain/delivery-qa.js +97 -0
- package/dist/src/orchestration/domain/delivery-replacement.d.ts +9 -0
- package/dist/src/orchestration/domain/delivery-replacement.js +54 -0
- package/dist/src/orchestration/domain/delivery-selection.d.ts +17 -0
- package/dist/src/orchestration/domain/delivery-selection.js +132 -0
- package/dist/src/orchestration/domain/delivery-workflow-policy.d.ts +6 -0
- package/dist/src/orchestration/domain/delivery-workflow-policy.js +32 -0
- package/dist/src/orchestration/domain/operator-retry-policy.js +24 -13
- package/dist/src/orchestration/domain/workflow-instance-events.d.ts +1 -0
- package/dist/src/orchestration/domain/workflow-instance-events.js +12 -0
- package/dist/src/orchestration/index.d.ts +3 -0
- package/dist/src/orchestration/index.js +1 -0
- package/dist/src/surfaces/api/contracts/transport-values.js +1 -0
- package/dist/src/surfaces/api/contracts/work.d.ts +42 -0
- package/dist/src/surfaces/api/presenters/execution.js +1 -0
- package/dist/src/surfaces/mcp/delegation.js +36 -1
- package/dist/src/surfaces/web-assets/assets/index-ih1h3dxC.js +1192 -0
- package/dist/src/surfaces/web-assets/index.html +1 -1
- package/package.json +1 -1
- package/dist/src/surfaces/web-assets/assets/index-C5R-aWzH.js +0 -1192
|
@@ -0,0 +1,186 @@
|
|
|
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, MaintenanceKind, 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
|
+
/**
|
|
96
|
+
* The exact change subjects this candidate was built from. Maintenance that replaces any of
|
|
97
|
+
* them makes the candidate, and QA of it, historical rather than current.
|
|
98
|
+
*/
|
|
99
|
+
subjects: z
|
|
100
|
+
.array(z
|
|
101
|
+
.object({
|
|
102
|
+
childWorkItemId: brandedStringSchema(workItemId),
|
|
103
|
+
outputName: z.string().min(1),
|
|
104
|
+
revision,
|
|
105
|
+
pullRequestBase: z.string().min(1),
|
|
106
|
+
baseRevision: z.string().min(1).optional(),
|
|
107
|
+
})
|
|
108
|
+
.strict())
|
|
109
|
+
.optional(),
|
|
110
|
+
/** Non-change outputs (plans, evidence) the candidate was selected with. */
|
|
111
|
+
context: z.array(deliveryOutputKeySchema),
|
|
112
|
+
criteria: z.array(z.string().min(1)),
|
|
113
|
+
recipe: z.string().min(1).optional(),
|
|
114
|
+
})
|
|
115
|
+
.strict();
|
|
116
|
+
export const deliveryQaCommandSchema = z
|
|
117
|
+
.object({
|
|
118
|
+
qaId: z.string().regex(/^[a-z0-9][a-z0-9-]{0,62}$/),
|
|
119
|
+
candidateId: z.string().min(1),
|
|
120
|
+
verdict: z.enum(QaVerdict),
|
|
121
|
+
/** The exact revision per repository the QA run checked; must equal the candidate's set. */
|
|
122
|
+
revisions: z.array(z.object({ resourceId: z.string().min(1), revision }).strict()).min(1),
|
|
123
|
+
environment: z
|
|
124
|
+
.object({ recipe: z.string().min(1).optional(), available: z.boolean() })
|
|
125
|
+
.strict(),
|
|
126
|
+
findings: z.array(z.string().trim().min(1)).default([]),
|
|
127
|
+
evidence: z
|
|
128
|
+
.array(z
|
|
129
|
+
.object({ workItemId: brandedStringSchema(workItemId), revisionId: z.string().min(1) })
|
|
130
|
+
.strict())
|
|
131
|
+
.optional(),
|
|
132
|
+
})
|
|
133
|
+
.strict();
|
|
134
|
+
export const deliveryQaSchema = deliveryQaCommandSchema
|
|
135
|
+
.extend({
|
|
136
|
+
/** Set when this failure used the last descendant slot: the parent must escalate. */
|
|
137
|
+
exhausted: z.boolean().optional(),
|
|
138
|
+
runId: z.string().min(1).optional(),
|
|
139
|
+
activationId: z.string().min(1).optional(),
|
|
140
|
+
})
|
|
141
|
+
.strict();
|
|
142
|
+
const subjectState = z
|
|
143
|
+
.object({
|
|
144
|
+
revision,
|
|
145
|
+
pullRequestBase: z.string().min(1),
|
|
146
|
+
baseRevision: z.string().min(1).optional(),
|
|
147
|
+
})
|
|
148
|
+
.strict();
|
|
149
|
+
/** Agent input: what it did to one selected change, for Wake to verify against the provider. */
|
|
150
|
+
export const deliveryMaintenanceCommandSchema = z
|
|
151
|
+
.object({
|
|
152
|
+
maintenanceId: z.string().regex(/^[a-z0-9][a-z0-9-]{0,62}$/),
|
|
153
|
+
target: deliveryOutputKeySchema,
|
|
154
|
+
kind: z.enum(MaintenanceKind),
|
|
155
|
+
/** The head the agent started from; it must be the target's current subject. */
|
|
156
|
+
expectedRevision: revision,
|
|
157
|
+
/** The resulting head and pull request base the agent published. */
|
|
158
|
+
revision,
|
|
159
|
+
pullRequestBase: z.string().min(1),
|
|
160
|
+
})
|
|
161
|
+
.strict();
|
|
162
|
+
/**
|
|
163
|
+
* An immutable new subject for a selected change. The earlier subject, its reviews, checks and
|
|
164
|
+
* QA stay historical; the PR keeps its original owner and the producer is the maintaining Run.
|
|
165
|
+
*/
|
|
166
|
+
export const deliveryMaintenanceSchema = z
|
|
167
|
+
.object({
|
|
168
|
+
maintenanceId: z.string().min(1),
|
|
169
|
+
target: deliveryOutputKeySchema,
|
|
170
|
+
kind: z.enum(MaintenanceKind),
|
|
171
|
+
resourceId: z.string().min(1),
|
|
172
|
+
repositoryResourceId: z.string().min(1),
|
|
173
|
+
previous: subjectState,
|
|
174
|
+
current: subjectState.extend({ baseRevision: z.string().min(1).optional() }).strict(),
|
|
175
|
+
recordedAt: z.string().datetime({ offset: true }).optional(),
|
|
176
|
+
producer: z.object({ runId: z.string().min(1), activationId: z.string().min(1) }).strict(),
|
|
177
|
+
})
|
|
178
|
+
.strict();
|
|
179
|
+
export class DeliveryRejectionError extends Error {
|
|
180
|
+
code;
|
|
181
|
+
constructor(code, message) {
|
|
182
|
+
super(message);
|
|
183
|
+
this.code = code;
|
|
184
|
+
this.name = 'DeliveryRejectionError';
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -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, deliveryMaintenanceSchema, 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,10 @@ 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),
|
|
235
|
+
[OrchestrationEventType.DeliveryMaintenanceRecorded]: workflowEnvelope(OrchestrationEventType.DeliveryMaintenanceRecorded, deliveryMaintenanceSchema),
|
|
231
236
|
[OrchestrationEventType.DelegationReserved]: workflowEnvelope(OrchestrationEventType.DelegationReserved, delegationReservationSchema),
|
|
232
237
|
[OrchestrationEventType.DelegationRegistered]: workflowEnvelope(OrchestrationEventType.DelegationRegistered, z.object({ cohortId: z.string().min(1) }).strict()),
|
|
233
238
|
[OrchestrationEventType.DelegationResultSelected]: workflowEnvelope(OrchestrationEventType.DelegationResultSelected, delegationResultSchema),
|
|
@@ -324,7 +329,15 @@ const eventSchemas = {
|
|
|
324
329
|
[OrchestrationEventType.RepeatCounted]: workflowEnvelope(OrchestrationEventType.RepeatCounted, z.object({ routeId: z.string().min(1), count: z.number().int().positive() }).strict()),
|
|
325
330
|
[OrchestrationEventType.RetryCounted]: workflowEnvelope(OrchestrationEventType.RetryCounted, z.object({ retryKey: z.string().min(1), count: z.number().int().positive() }).strict()),
|
|
326
331
|
[OrchestrationEventType.InstanceCompleted]: workflowEnvelope(OrchestrationEventType.InstanceCompleted, emptySchema),
|
|
327
|
-
[OrchestrationEventType.InstanceBlocked]: workflowEnvelope(OrchestrationEventType.InstanceBlocked, z
|
|
332
|
+
[OrchestrationEventType.InstanceBlocked]: workflowEnvelope(OrchestrationEventType.InstanceBlocked, z
|
|
333
|
+
.object({
|
|
334
|
+
reason: z.string(),
|
|
335
|
+
deliveryGate: z
|
|
336
|
+
.object({ retryStage: brandedStringSchema(stageName) })
|
|
337
|
+
.strict()
|
|
338
|
+
.optional(),
|
|
339
|
+
})
|
|
340
|
+
.strict()),
|
|
328
341
|
[OrchestrationEventType.OperatorRetryRequested]: workflowEnvelope(OrchestrationEventType.OperatorRetryRequested, z
|
|
329
342
|
.object({
|
|
330
343
|
activationId: brandedStringSchema(activationId),
|
|
@@ -18,6 +18,14 @@ 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);
|
|
27
|
+
case OrchestrationEventType.DeliveryMaintenanceRecorded:
|
|
28
|
+
return createEventData(input);
|
|
21
29
|
case OrchestrationEventType.DelegationReserved:
|
|
22
30
|
return createEventData(input);
|
|
23
31
|
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, DeliveryMaintenance, 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,10 @@ 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";
|
|
27
|
+
readonly DeliveryMaintenanceRecorded: "orchestration.delivery-maintenance-recorded";
|
|
23
28
|
readonly WorkflowDefinitionRegistered: "orchestration.workflow-definition-registered";
|
|
24
29
|
readonly InstanceStarted: "orchestration.instance-started";
|
|
25
30
|
readonly StageEntered: "orchestration.stage-entered";
|
|
@@ -88,6 +93,10 @@ export interface OrchestrationEventPayloads {
|
|
|
88
93
|
readonly cohortId: string;
|
|
89
94
|
readonly reason: string;
|
|
90
95
|
};
|
|
96
|
+
readonly [OrchestrationEventType.DeliverySelectionRevised]: DeliverySelection;
|
|
97
|
+
readonly [OrchestrationEventType.DeliveryCandidateRecorded]: DeliveryCandidate;
|
|
98
|
+
readonly [OrchestrationEventType.DeliveryQaRecorded]: DeliveryQa;
|
|
99
|
+
readonly [OrchestrationEventType.DeliveryMaintenanceRecorded]: DeliveryMaintenance;
|
|
91
100
|
readonly [OrchestrationEventType.DelegationReserved]: DelegationReservation;
|
|
92
101
|
readonly [OrchestrationEventType.DelegationRegistered]: {
|
|
93
102
|
readonly cohortId: string;
|
|
@@ -167,6 +176,7 @@ export interface OrchestrationEventPayloads {
|
|
|
167
176
|
readonly [OrchestrationEventType.InstanceCompleted]: Readonly<Record<never, never>>;
|
|
168
177
|
readonly [OrchestrationEventType.InstanceBlocked]: {
|
|
169
178
|
readonly reason: string;
|
|
179
|
+
readonly deliveryGate?: DeliveryCompletionBlock['deliveryGate'];
|
|
170
180
|
};
|
|
171
181
|
readonly [OrchestrationEventType.OperatorRetryRequested]: {
|
|
172
182
|
readonly activationId: ActivationId;
|
|
@@ -13,6 +13,10 @@ 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',
|
|
19
|
+
DeliveryMaintenanceRecorded: 'orchestration.delivery-maintenance-recorded',
|
|
16
20
|
WorkflowDefinitionRegistered: 'orchestration.workflow-definition-registered',
|
|
17
21
|
InstanceStarted: 'orchestration.instance-started',
|
|
18
22
|
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>>;
|
|
@@ -84,6 +84,8 @@ export declare const DelegationConflictCode: {
|
|
|
84
84
|
readonly WaitCycle: "wait-cycle";
|
|
85
85
|
readonly StalePlan: "stale-plan";
|
|
86
86
|
readonly AttentionOpen: "attention-open";
|
|
87
|
+
readonly ReplacementUnsupported: "replacement-unsupported";
|
|
88
|
+
readonly ReplacementInvalid: "replacement-invalid";
|
|
87
89
|
};
|
|
88
90
|
export type DelegationConflictCode = ValueOf<typeof DelegationConflictCode>;
|
|
89
91
|
export declare const PrerequisiteBlockCode: {
|
|
@@ -95,3 +97,91 @@ export declare const PrerequisiteBlockCode: {
|
|
|
95
97
|
readonly Blocked: "prerequisite-blocked";
|
|
96
98
|
};
|
|
97
99
|
export type PrerequisiteBlockCode = ValueOf<typeof PrerequisiteBlockCode>;
|
|
100
|
+
export declare const DeliveryRejection: {
|
|
101
|
+
/** The submitted revision is not the current one; re-inspect before retrying. */
|
|
102
|
+
readonly StaleSelection: "stale-selection";
|
|
103
|
+
/** An original required assignment has no qualifying output or authorized replacement. */
|
|
104
|
+
readonly UncoveredRequirement: "uncovered-requirement";
|
|
105
|
+
readonly UnknownRequirement: "unknown-requirement";
|
|
106
|
+
/** The named output is not a qualifying result of the claimed child. */
|
|
107
|
+
readonly OutputMismatch: "output-mismatch";
|
|
108
|
+
/** A replacement did not name the output currently selected, or is not criteria-preserving. */
|
|
109
|
+
readonly ReplacementConflict: "replacement-conflict";
|
|
110
|
+
/** The selection still contains results whose upstream input was replaced. */
|
|
111
|
+
readonly StaleOutput: "stale-output";
|
|
112
|
+
readonly NoSelection: "no-selection";
|
|
113
|
+
readonly CandidateCoverage: "candidate-coverage";
|
|
114
|
+
/** A retained ref is missing, outside the delivery namespace, or no longer at its recorded commit. */
|
|
115
|
+
readonly SourceUnavailable: "source-unavailable";
|
|
116
|
+
readonly UnknownCandidate: "unknown-candidate";
|
|
117
|
+
/** QA named revisions other than the candidate's exact set. */
|
|
118
|
+
readonly RevisionMismatch: "revision-mismatch";
|
|
119
|
+
readonly InvalidVerdict: "invalid-verdict";
|
|
120
|
+
/** An identity was reused for different content. */
|
|
121
|
+
readonly Conflict: "identity-conflict";
|
|
122
|
+
/** Maintenance named a target that is not a selected, unmerged change. */
|
|
123
|
+
readonly NotMaintainable: "not-maintainable";
|
|
124
|
+
/** Maintenance did not start from the target's current subject, or the provider disagrees. */
|
|
125
|
+
readonly MaintenanceMismatch: "maintenance-mismatch";
|
|
126
|
+
/** An earlier writer of the target is unresolved; reconcile it before another writes. */
|
|
127
|
+
readonly AmbiguousWriter: "ambiguous-writer";
|
|
128
|
+
};
|
|
129
|
+
export type DeliveryRejection = ValueOf<typeof DeliveryRejection>;
|
|
130
|
+
export declare const QaVerdict: {
|
|
131
|
+
readonly Pass: "pass";
|
|
132
|
+
readonly Fail: "fail";
|
|
133
|
+
/** The environment or a source was unavailable; never a pass. */
|
|
134
|
+
readonly Blocked: "blocked";
|
|
135
|
+
};
|
|
136
|
+
export type QaVerdict = ValueOf<typeof QaVerdict>;
|
|
137
|
+
export declare const CandidateSourceKind: {
|
|
138
|
+
/** The selected output revision is itself the tip (a single change or an intentional stack). */
|
|
139
|
+
readonly Output: "output";
|
|
140
|
+
/** An agent-assembled commit published under the delivery's retained ref namespace. */
|
|
141
|
+
readonly RetainedRef: "retained-ref";
|
|
142
|
+
};
|
|
143
|
+
export type CandidateSourceKind = ValueOf<typeof CandidateSourceKind>;
|
|
144
|
+
export declare const DeliveryCompletion: {
|
|
145
|
+
/** The parent may finish once the current candidate has an effective QA pass. */
|
|
146
|
+
readonly QaApproved: "qa-approved";
|
|
147
|
+
/** The parent additionally needs every selected change merged through governed integration. */
|
|
148
|
+
readonly MergeRequired: "merge-required";
|
|
149
|
+
};
|
|
150
|
+
export type DeliveryCompletion = ValueOf<typeof DeliveryCompletion>;
|
|
151
|
+
/** What an agent did to a selected change so it can integrate; each records a new subject. */
|
|
152
|
+
export declare const MaintenanceKind: {
|
|
153
|
+
readonly Retarget: "retarget";
|
|
154
|
+
readonly Rebase: "rebase";
|
|
155
|
+
readonly Resolve: "resolve-conflicts";
|
|
156
|
+
};
|
|
157
|
+
export type MaintenanceKind = ValueOf<typeof MaintenanceKind>;
|
|
158
|
+
/** Where a selected change stands in governed integration, derived from actual provider state. */
|
|
159
|
+
export declare const IntegrationState: {
|
|
160
|
+
readonly Merged: "integrated";
|
|
161
|
+
readonly Ready: "ready-to-integrate";
|
|
162
|
+
readonly AwaitingLowerLayer: "awaiting-lower-layer";
|
|
163
|
+
readonly MaintenanceRequired: "maintenance-required";
|
|
164
|
+
readonly Closed: "closed-unmerged";
|
|
165
|
+
readonly Held: "held";
|
|
166
|
+
readonly Unobserved: "unobserved";
|
|
167
|
+
};
|
|
168
|
+
export type IntegrationState = ValueOf<typeof IntegrationState>;
|
|
169
|
+
export declare const MaintenanceReason: {
|
|
170
|
+
/** A lower layer merged, so the change still targets a branch that no longer carries the stack. */
|
|
171
|
+
readonly Retarget: "retarget";
|
|
172
|
+
readonly Conflict: "merge-conflict";
|
|
173
|
+
/** The provider head is not the recorded subject: another writer changed the branch. */
|
|
174
|
+
readonly HeadMoved: "head-moved";
|
|
175
|
+
/** The base moved for a reason outside the delivery, so the tested combination is unproven. */
|
|
176
|
+
readonly BaseMoved: "base-moved";
|
|
177
|
+
};
|
|
178
|
+
export type MaintenanceReason = ValueOf<typeof MaintenanceReason>;
|
|
179
|
+
/** How the integration base changed since the subject was recorded. */
|
|
180
|
+
export declare const BaseMovement: {
|
|
181
|
+
readonly None: "none";
|
|
182
|
+
/** A selected change merged; the QA candidate already contained it. */
|
|
183
|
+
readonly PlannedProgress: "planned-progress";
|
|
184
|
+
/** Nothing in the delivery explains it; it is never credited as progress. */
|
|
185
|
+
readonly Unrelated: "unrelated";
|
|
186
|
+
};
|
|
187
|
+
export type BaseMovement = ValueOf<typeof BaseMovement>;
|
|
@@ -75,6 +75,8 @@ export const DelegationConflictCode = defineClosedVocabulary({
|
|
|
75
75
|
WaitCycle: 'wait-cycle',
|
|
76
76
|
StalePlan: 'stale-plan',
|
|
77
77
|
AttentionOpen: 'attention-open',
|
|
78
|
+
ReplacementUnsupported: 'replacement-unsupported',
|
|
79
|
+
ReplacementInvalid: 'replacement-invalid',
|
|
78
80
|
});
|
|
79
81
|
export const PrerequisiteBlockCode = defineClosedVocabulary({
|
|
80
82
|
Waiting: 'prerequisite-waiting',
|
|
@@ -84,3 +86,83 @@ export const PrerequisiteBlockCode = defineClosedVocabulary({
|
|
|
84
86
|
Cycle: 'prerequisite-cycle',
|
|
85
87
|
Blocked: 'prerequisite-blocked',
|
|
86
88
|
});
|
|
89
|
+
export const DeliveryRejection = defineClosedVocabulary({
|
|
90
|
+
/** The submitted revision is not the current one; re-inspect before retrying. */
|
|
91
|
+
StaleSelection: 'stale-selection',
|
|
92
|
+
/** An original required assignment has no qualifying output or authorized replacement. */
|
|
93
|
+
UncoveredRequirement: 'uncovered-requirement',
|
|
94
|
+
UnknownRequirement: 'unknown-requirement',
|
|
95
|
+
/** The named output is not a qualifying result of the claimed child. */
|
|
96
|
+
OutputMismatch: 'output-mismatch',
|
|
97
|
+
/** A replacement did not name the output currently selected, or is not criteria-preserving. */
|
|
98
|
+
ReplacementConflict: 'replacement-conflict',
|
|
99
|
+
/** The selection still contains results whose upstream input was replaced. */
|
|
100
|
+
StaleOutput: 'stale-output',
|
|
101
|
+
NoSelection: 'no-selection',
|
|
102
|
+
CandidateCoverage: 'candidate-coverage',
|
|
103
|
+
/** A retained ref is missing, outside the delivery namespace, or no longer at its recorded commit. */
|
|
104
|
+
SourceUnavailable: 'source-unavailable',
|
|
105
|
+
UnknownCandidate: 'unknown-candidate',
|
|
106
|
+
/** QA named revisions other than the candidate's exact set. */
|
|
107
|
+
RevisionMismatch: 'revision-mismatch',
|
|
108
|
+
InvalidVerdict: 'invalid-verdict',
|
|
109
|
+
/** An identity was reused for different content. */
|
|
110
|
+
Conflict: 'identity-conflict',
|
|
111
|
+
/** Maintenance named a target that is not a selected, unmerged change. */
|
|
112
|
+
NotMaintainable: 'not-maintainable',
|
|
113
|
+
/** Maintenance did not start from the target's current subject, or the provider disagrees. */
|
|
114
|
+
MaintenanceMismatch: 'maintenance-mismatch',
|
|
115
|
+
/** An earlier writer of the target is unresolved; reconcile it before another writes. */
|
|
116
|
+
AmbiguousWriter: 'ambiguous-writer',
|
|
117
|
+
});
|
|
118
|
+
export const QaVerdict = defineClosedVocabulary({
|
|
119
|
+
Pass: 'pass',
|
|
120
|
+
Fail: 'fail',
|
|
121
|
+
/** The environment or a source was unavailable; never a pass. */
|
|
122
|
+
Blocked: 'blocked',
|
|
123
|
+
});
|
|
124
|
+
export const CandidateSourceKind = defineClosedVocabulary({
|
|
125
|
+
/** The selected output revision is itself the tip (a single change or an intentional stack). */
|
|
126
|
+
Output: 'output',
|
|
127
|
+
/** An agent-assembled commit published under the delivery's retained ref namespace. */
|
|
128
|
+
RetainedRef: 'retained-ref',
|
|
129
|
+
});
|
|
130
|
+
export const DeliveryCompletion = defineClosedVocabulary({
|
|
131
|
+
/** The parent may finish once the current candidate has an effective QA pass. */
|
|
132
|
+
QaApproved: 'qa-approved',
|
|
133
|
+
/** The parent additionally needs every selected change merged through governed integration. */
|
|
134
|
+
MergeRequired: 'merge-required',
|
|
135
|
+
});
|
|
136
|
+
/** What an agent did to a selected change so it can integrate; each records a new subject. */
|
|
137
|
+
export const MaintenanceKind = defineClosedVocabulary({
|
|
138
|
+
Retarget: 'retarget',
|
|
139
|
+
Rebase: 'rebase',
|
|
140
|
+
Resolve: 'resolve-conflicts',
|
|
141
|
+
});
|
|
142
|
+
/** Where a selected change stands in governed integration, derived from actual provider state. */
|
|
143
|
+
export const IntegrationState = defineClosedVocabulary({
|
|
144
|
+
Merged: 'integrated',
|
|
145
|
+
Ready: 'ready-to-integrate',
|
|
146
|
+
AwaitingLowerLayer: 'awaiting-lower-layer',
|
|
147
|
+
MaintenanceRequired: 'maintenance-required',
|
|
148
|
+
Closed: 'closed-unmerged',
|
|
149
|
+
Held: 'held',
|
|
150
|
+
Unobserved: 'unobserved',
|
|
151
|
+
});
|
|
152
|
+
export const MaintenanceReason = defineClosedVocabulary({
|
|
153
|
+
/** A lower layer merged, so the change still targets a branch that no longer carries the stack. */
|
|
154
|
+
Retarget: 'retarget',
|
|
155
|
+
Conflict: 'merge-conflict',
|
|
156
|
+
/** The provider head is not the recorded subject: another writer changed the branch. */
|
|
157
|
+
HeadMoved: 'head-moved',
|
|
158
|
+
/** The base moved for a reason outside the delivery, so the tested combination is unproven. */
|
|
159
|
+
BaseMoved: 'base-moved',
|
|
160
|
+
});
|
|
161
|
+
/** How the integration base changed since the subject was recorded. */
|
|
162
|
+
export const BaseMovement = defineClosedVocabulary({
|
|
163
|
+
None: 'none',
|
|
164
|
+
/** A selected change merged; the QA candidate already contained it. */
|
|
165
|
+
PlannedProgress: 'planned-progress',
|
|
166
|
+
/** Nothing in the delivery explains it; it is never credited as progress. */
|
|
167
|
+
Unrelated: 'unrelated',
|
|
168
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ActivityRegistry } from '../../activities/index.js';
|
|
2
2
|
import type { CompiledStage } from '../contracts/config.js';
|
|
3
3
|
import type { StageName } from '../contracts/identifiers.js';
|
|
4
4
|
export interface WorkflowCompileDiagnostic {
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { ActivityOutcomeKind } from '../../activities/index.js';
|
|
2
|
+
const hasDeliveryScope = (stage) => typeof stage.with === 'object' && stage.with !== null && 'scope' in stage.with;
|
|
1
3
|
export function reportUnroutedOutcomes(workflow, stages, activities, report) {
|
|
2
4
|
for (const [stage, configured] of Object.entries(stages)) {
|
|
3
5
|
for (const outcome of activities.describe(configured.activity).outcomeKinds) {
|
|
4
6
|
if (Object.hasOwn(configured.on, outcome))
|
|
5
7
|
continue;
|
|
8
|
+
// Only a parent delivery scope can finish with nothing left to integrate.
|
|
9
|
+
if (outcome === ActivityOutcomeKind.Integrated && !hasDeliveryScope(configured))
|
|
10
|
+
continue;
|
|
6
11
|
report({
|
|
7
12
|
workflow,
|
|
8
13
|
stage,
|
|
@@ -5,6 +5,7 @@ import { ApprovalAuthorityKind, TransitionTargetKind } from '../contracts/vocabu
|
|
|
5
5
|
import { defaultApprovalAwait } from './approval-defaults.js';
|
|
6
6
|
import { compileCommands } from './command-compiler.js';
|
|
7
7
|
import { reportUnroutedOutcomes } from './compile-diagnostics.js';
|
|
8
|
+
import { assertDeliveryQa } from './delivery-workflow-policy.js';
|
|
8
9
|
import { compileResourceTransitions } from './resource-transition-compiler.js';
|
|
9
10
|
import { compileTarget, isReservedRouteTarget, isReservedTerminalTarget, } from './transition-target.js';
|
|
10
11
|
import { assertCyclesBounded, assertReachable, remainingAgentSteps } from './workflow-graph.js';
|
|
@@ -24,6 +25,7 @@ export function compileWorkflow(name, input, activities, knownWorkflowNames = [n
|
|
|
24
25
|
const compiledEntry = stageName(entry);
|
|
25
26
|
const declaredWatchIds = new Set((config.watches ?? []).map((watch) => watch.id));
|
|
26
27
|
const stages = compileStages(compiledName, config.stages, activities, declaredWatchIds);
|
|
28
|
+
assertDeliveryQa(config, stages, activities);
|
|
27
29
|
const commands = compileCommands(config, activities);
|
|
28
30
|
const watches = compileWatches(config, rawStageNames, knownWorkflowNames);
|
|
29
31
|
assertReachable(compiledEntry, stages);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DeliveryCandidate, DeliveryCandidateCommand } from '../contracts/delivery.js';
|
|
2
|
+
import { type DeliveryFacts } from './delivery-facts.js';
|
|
3
|
+
export interface CandidatePlan {
|
|
4
|
+
readonly candidate: DeliveryCandidate;
|
|
5
|
+
}
|
|
6
|
+
/** The namespace a delivery's candidate refs must live in; no automatic deletion is performed. */
|
|
7
|
+
export declare const retainedRefPrefix: (root: string, candidateId: string) => string;
|
|
8
|
+
/** Shapes the candidate manifest from the current selection; source verification is separate. */
|
|
9
|
+
export declare function planCandidate(facts: DeliveryFacts, command: DeliveryCandidateCommand, root: string): CandidatePlan;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { CandidateSourceKind, DeliveryRejection } from '../contracts/vocabulary.js';
|
|
3
|
+
import { currentSelection, isChange, outputKey, reject, requirements, } from './delivery-facts.js';
|
|
4
|
+
import { staleEntries } from './delivery-selection.js';
|
|
5
|
+
const sameKeys = (left, right) => isDeepStrictEqual(left.map(outputKey).sort(), right.map(outputKey).sort());
|
|
6
|
+
/** The namespace a delivery's candidate refs must live in; no automatic deletion is performed. */
|
|
7
|
+
export const retainedRefPrefix = (root, candidateId) => `refs/wake/delivery/${root}/${candidateId}/`;
|
|
8
|
+
/** Shapes the candidate manifest from the current selection; source verification is separate. */
|
|
9
|
+
export function planCandidate(facts, command, root) {
|
|
10
|
+
const current = currentSelection(facts);
|
|
11
|
+
if (current === undefined)
|
|
12
|
+
throw reject(DeliveryRejection.NoSelection, 'Record a delivery selection first');
|
|
13
|
+
if (command.selectionRevision !== current.revision)
|
|
14
|
+
throw reject(DeliveryRejection.StaleSelection, `Selection is at revision ${current.revision}, not ${command.selectionRevision}`);
|
|
15
|
+
const stale = staleEntries(facts);
|
|
16
|
+
if (stale.size > 0)
|
|
17
|
+
throw reject(DeliveryRejection.StaleOutput, `Replace or reverify stale results first: ${[...stale].join(', ')}`);
|
|
18
|
+
const byRepository = new Map();
|
|
19
|
+
for (const entry of current.entries.filter((candidate) => isChange(candidate.output))) {
|
|
20
|
+
const { repositoryResourceId } = entry.output.reference;
|
|
21
|
+
byRepository.set(repositoryResourceId, [
|
|
22
|
+
...(byRepository.get(repositoryResourceId) ?? []),
|
|
23
|
+
entry,
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
26
|
+
const requested = command.repositories.map((entry) => entry.resourceId);
|
|
27
|
+
if (new Set(requested).size !== requested.length ||
|
|
28
|
+
!isDeepStrictEqual([...requested].sort(), [...byRepository.keys()].sort()))
|
|
29
|
+
throw reject(DeliveryRejection.CandidateCoverage, 'The candidate must name exactly the repositories of the selected changes, once each');
|
|
30
|
+
const repositories = command.repositories.map((request) => repositoryOf(request, byRepository.get(request.resourceId) ?? [], root, command.candidateId));
|
|
31
|
+
return {
|
|
32
|
+
candidate: {
|
|
33
|
+
candidateId: command.candidateId,
|
|
34
|
+
selectionRevision: current.revision,
|
|
35
|
+
repositories: repositories.sort((a, b) => a.resourceId.localeCompare(b.resourceId)),
|
|
36
|
+
subjects: current.entries.flatMap((entry) => isChange(entry.output)
|
|
37
|
+
? [
|
|
38
|
+
{
|
|
39
|
+
childWorkItemId: entry.childWorkItemId,
|
|
40
|
+
outputName: entry.output.name,
|
|
41
|
+
revision: entry.output.reference.revision,
|
|
42
|
+
pullRequestBase: entry.output.reference.pullRequestBase,
|
|
43
|
+
...(entry.output.reference.baseRevision === undefined
|
|
44
|
+
? {}
|
|
45
|
+
: { baseRevision: entry.output.reference.baseRevision }),
|
|
46
|
+
},
|
|
47
|
+
]
|
|
48
|
+
: []),
|
|
49
|
+
context: current.entries
|
|
50
|
+
.filter((entry) => !isChange(entry.output))
|
|
51
|
+
.map((entry) => ({
|
|
52
|
+
childWorkItemId: entry.childWorkItemId,
|
|
53
|
+
outputName: entry.output.name,
|
|
54
|
+
})),
|
|
55
|
+
criteria: [
|
|
56
|
+
...new Set(requirements(facts.reservations).flatMap((requirement) => requirement.criteria)),
|
|
57
|
+
],
|
|
58
|
+
...(command.recipe === undefined ? {} : { recipe: command.recipe }),
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function repositoryOf(request, entries, root, candidateId) {
|
|
63
|
+
const expected = entries.map((entry) => ({
|
|
64
|
+
childWorkItemId: entry.childWorkItemId,
|
|
65
|
+
outputName: entry.output.name,
|
|
66
|
+
}));
|
|
67
|
+
const source = request.source;
|
|
68
|
+
if (source.kind === CandidateSourceKind.Output) {
|
|
69
|
+
if (!sameKeys([source.tip, ...(source.includes ?? [])], expected))
|
|
70
|
+
throw reject(DeliveryRejection.CandidateCoverage, `Candidate for ${request.resourceId} must account for every selected change in it; independent changes need an assembled retained ref`);
|
|
71
|
+
const tip = entries.find((entry) => outputKey(source.tip) === outputKey(keyOf(entry)));
|
|
72
|
+
if (tip === undefined)
|
|
73
|
+
throw reject(DeliveryRejection.CandidateCoverage, 'The tip is not a selected change');
|
|
74
|
+
const reference = tip.output.reference;
|
|
75
|
+
return {
|
|
76
|
+
resourceId: request.resourceId,
|
|
77
|
+
revision: reference.revision,
|
|
78
|
+
pullRequestBase: reference.pullRequestBase,
|
|
79
|
+
source: { kind: CandidateSourceKind.Output, tip: source.tip },
|
|
80
|
+
contributions: expected,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (!sameKeys(source.contributions, expected))
|
|
84
|
+
throw reject(DeliveryRejection.CandidateCoverage, `Assembly for ${request.resourceId} must declare every selected change in it`);
|
|
85
|
+
assertRetainedRef(source.ref, retainedRefPrefix(root, candidateId));
|
|
86
|
+
const bases = entries.map((entry) => entry.output.reference.pullRequestBase);
|
|
87
|
+
return {
|
|
88
|
+
resourceId: request.resourceId,
|
|
89
|
+
revision: source.revision,
|
|
90
|
+
pullRequestBase: [...bases].sort()[0],
|
|
91
|
+
source: { kind: CandidateSourceKind.RetainedRef, ref: source.ref },
|
|
92
|
+
contributions: expected,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const keyOf = (entry) => ({
|
|
96
|
+
childWorkItemId: entry.childWorkItemId,
|
|
97
|
+
outputName: entry.output.name,
|
|
98
|
+
});
|
|
99
|
+
function assertRetainedRef(ref, prefix) {
|
|
100
|
+
if (!ref.startsWith(prefix) ||
|
|
101
|
+
ref.length === prefix.length ||
|
|
102
|
+
!/^[A-Za-z0-9._/-]+$/.test(ref) ||
|
|
103
|
+
ref.includes('..'))
|
|
104
|
+
throw reject(DeliveryRejection.SourceUnavailable, `Retained refs must live under ${prefix}`);
|
|
105
|
+
}
|