@atolis-hq/wake 0.4.76 → 0.4.78
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/contracts/event-schema.d.ts +30 -0
- package/dist/src/activities/contracts/event-schema.js +8 -2
- package/dist/src/activities/contracts/events.d.ts +3 -1
- package/dist/src/activities/pr/application.js +6 -3
- package/dist/src/activities/pr/contracts.d.ts +3 -1
- package/dist/src/activities/pr/event-data.js +4 -1
- package/dist/src/activities/pr/projection.js +4 -1
- package/dist/src/activities/pr/vocabulary.d.ts +6 -0
- package/dist/src/activities/pr/vocabulary.js +5 -0
- package/dist/src/bootstrap/composition-root.js +1 -0
- package/dist/src/bootstrap/config/root-schema.d.ts +19 -0
- package/dist/src/bootstrap/initialise.js +1 -0
- package/dist/src/bootstrap/integration-runtime.js +8 -1
- package/dist/src/bootstrap/resource-transition-evidence.js +20 -14
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/control-plane/application/activation-scheduler-ports.d.ts +1 -0
- package/dist/src/control-plane/application/activation-scheduler.js +4 -0
- package/dist/src/control-plane/application/advance-once-dispatch.d.ts +5 -0
- package/dist/src/control-plane/application/advance-once-dispatch.js +11 -1
- package/dist/src/control-plane/contracts/config.d.ts +2 -0
- package/dist/src/control-plane/contracts/config.js +2 -0
- package/dist/src/control-plane/domain/open-work-policy.d.ts +12 -0
- package/dist/src/control-plane/domain/open-work-policy.js +35 -0
- package/dist/src/control-plane/index.d.ts +1 -0
- package/dist/src/control-plane/index.js +1 -0
- package/dist/src/integrations/application/agent-run-publication-reactor.d.ts +1 -0
- package/dist/src/integrations/application/agent-run-publication-reactor.js +49 -25
- package/dist/src/integrations/application/agent-run-publication-report.d.ts +10 -0
- package/dist/src/integrations/application/agent-run-publication-report.js +53 -0
- package/dist/src/integrations/application/terminal-agent-run-report.d.ts +4 -0
- package/dist/src/integrations/application/terminal-agent-run-report.js +4 -0
- package/dist/src/integrations/delivery/contracts/intents.d.ts +2 -0
- package/dist/src/integrations/delivery/contracts/intents.js +2 -0
- package/dist/src/integrations/github/application/agent-run-comment.d.ts +2 -0
- package/dist/src/integrations/github/application/agent-run-comment.js +26 -5
- package/dist/src/integrations/github/application/pull-request-translation.js +1 -0
- package/dist/src/integrations/github/contracts/events.d.ts +2 -1
- package/dist/src/integrations/github/contracts/events.js +8 -1
- package/dist/src/integrations/github/contracts/payloads.d.ts +1 -0
- package/dist/src/integrations/github/infrastructure/client-reads.d.ts +18 -6
- package/dist/src/integrations/github/infrastructure/client-reads.js +6 -1
- package/dist/src/integrations/github/infrastructure/client.d.ts +18 -6
- package/dist/src/integrations/github/infrastructure/consecutive-pr-observations.d.ts +4 -0
- package/dist/src/integrations/github/infrastructure/consecutive-pr-observations.js +33 -0
- package/dist/src/integrations/github/infrastructure/pr-source.js +6 -1
- package/dist/src/integrations/github/infrastructure/source.d.ts +6 -2
- package/dist/src/integrations/github/infrastructure/source.js +9 -9
- package/dist/src/integrations/github/provider.js +1 -0
- package/dist/src/orchestration/application/advance-workflow.js +1 -0
- package/dist/src/orchestration/application/policy-blocked-merge-recovery.d.ts +5 -0
- package/dist/src/orchestration/application/policy-blocked-merge-recovery.js +108 -21
- package/dist/src/orchestration/application/pull-request-transition-evidence.js +22 -1
- package/dist/src/orchestration/application/resource-transition-evidence.d.ts +6 -1
- package/dist/src/orchestration/application/resource-transition-matching.d.ts +5 -0
- package/dist/src/orchestration/application/resource-transition-matching.js +23 -1
- package/dist/src/orchestration/contracts/config.d.ts +42 -1
- package/dist/src/orchestration/contracts/config.js +9 -1
- package/dist/src/orchestration/contracts/event-decoder.d.ts +5 -0
- package/dist/src/orchestration/contracts/event-decoder.js +6 -1
- package/dist/src/orchestration/contracts/views.d.ts +2 -0
- package/dist/src/orchestration/domain/resource-transition-compiler.js +1 -0
- package/dist/src/orchestration/domain/workflow-instance-events.d.ts +1 -0
- package/dist/src/orchestration/domain/workflow-instance-events.js +2 -0
- package/dist/src/orchestration/domain/workflow-instance.js +9 -1
- package/dist/src/orchestration/index.d.ts +1 -0
- package/dist/src/orchestration/index.js +1 -0
- package/package.json +1 -1
|
@@ -120,6 +120,11 @@ export declare function createResourceFactDraftSchemas(eventTypes: ActivityEvent
|
|
|
120
120
|
closed: "closed";
|
|
121
121
|
merged: "merged";
|
|
122
122
|
}>;
|
|
123
|
+
mergeability: z.ZodOptional<z.ZodEnum<{
|
|
124
|
+
unknown: "unknown";
|
|
125
|
+
clean: "clean";
|
|
126
|
+
conflicting: "conflicting";
|
|
127
|
+
}>>;
|
|
123
128
|
headRevision: z.ZodString;
|
|
124
129
|
baseRevision: z.ZodString;
|
|
125
130
|
checks: z.ZodEnum<{
|
|
@@ -187,6 +192,11 @@ export declare function createResourceFactDraftSchemas(eventTypes: ActivityEvent
|
|
|
187
192
|
closed: "closed";
|
|
188
193
|
merged: "merged";
|
|
189
194
|
}>;
|
|
195
|
+
mergeability: z.ZodOptional<z.ZodEnum<{
|
|
196
|
+
unknown: "unknown";
|
|
197
|
+
clean: "clean";
|
|
198
|
+
conflicting: "conflicting";
|
|
199
|
+
}>>;
|
|
190
200
|
}, z.core.$strict>;
|
|
191
201
|
}, z.core.$strict>, z.ZodObject<{
|
|
192
202
|
eventId: z.ZodPipe<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<import("@atolis-hq/eventing").EventId, string>>>;
|
|
@@ -615,6 +625,11 @@ export declare function createActivityEventSchemas(eventTypes: ActivityEventType
|
|
|
615
625
|
closed: "closed";
|
|
616
626
|
merged: "merged";
|
|
617
627
|
}>;
|
|
628
|
+
mergeability: z.ZodOptional<z.ZodEnum<{
|
|
629
|
+
unknown: "unknown";
|
|
630
|
+
clean: "clean";
|
|
631
|
+
conflicting: "conflicting";
|
|
632
|
+
}>>;
|
|
618
633
|
headRevision: z.ZodString;
|
|
619
634
|
baseRevision: z.ZodString;
|
|
620
635
|
checks: z.ZodEnum<{
|
|
@@ -682,6 +697,11 @@ export declare function createActivityEventSchemas(eventTypes: ActivityEventType
|
|
|
682
697
|
closed: "closed";
|
|
683
698
|
merged: "merged";
|
|
684
699
|
}>;
|
|
700
|
+
mergeability: z.ZodOptional<z.ZodEnum<{
|
|
701
|
+
unknown: "unknown";
|
|
702
|
+
clean: "clean";
|
|
703
|
+
conflicting: "conflicting";
|
|
704
|
+
}>>;
|
|
685
705
|
}, z.core.$strict>;
|
|
686
706
|
}, z.core.$strict>, z.ZodObject<{
|
|
687
707
|
eventId: z.ZodPipe<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<import("@atolis-hq/eventing").EventId, string>>>;
|
|
@@ -2123,6 +2143,11 @@ export declare function createActivityEventSchemas(eventTypes: ActivityEventType
|
|
|
2123
2143
|
closed: "closed";
|
|
2124
2144
|
merged: "merged";
|
|
2125
2145
|
}>;
|
|
2146
|
+
mergeability: z.ZodOptional<z.ZodEnum<{
|
|
2147
|
+
unknown: "unknown";
|
|
2148
|
+
clean: "clean";
|
|
2149
|
+
conflicting: "conflicting";
|
|
2150
|
+
}>>;
|
|
2126
2151
|
headRevision: z.ZodString;
|
|
2127
2152
|
baseRevision: z.ZodString;
|
|
2128
2153
|
checks: z.ZodEnum<{
|
|
@@ -2190,6 +2215,11 @@ export declare function createActivityEventSchemas(eventTypes: ActivityEventType
|
|
|
2190
2215
|
closed: "closed";
|
|
2191
2216
|
merged: "merged";
|
|
2192
2217
|
}>;
|
|
2218
|
+
mergeability: z.ZodOptional<z.ZodEnum<{
|
|
2219
|
+
unknown: "unknown";
|
|
2220
|
+
clean: "clean";
|
|
2221
|
+
conflicting: "conflicting";
|
|
2222
|
+
}>>;
|
|
2193
2223
|
}, z.core.$strict>;
|
|
2194
2224
|
}, z.core.$strict>, z.ZodObject<{
|
|
2195
2225
|
eventId: z.ZodPipe<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<import("@atolis-hq/eventing").EventId, string>>>;
|
|
@@ -4,7 +4,7 @@ import { eventDataSchema, eventEnvelopeSchema } from '@atolis-hq/eventing';
|
|
|
4
4
|
import { brandedStringSchema } from '../../kernel/index.js';
|
|
5
5
|
import { ResourceStreamKind, resourceId } from '../../resources/index.js';
|
|
6
6
|
import { WorkStreamKind, workItemId } from '../../work/index.js';
|
|
7
|
-
import { MergeMethod, PullRequestCheckState, PullRequestDenialCode, PullRequestState, } from '../pr/vocabulary.js';
|
|
7
|
+
import { MergeMethod, PullRequestCheckState, PullRequestDenialCode, PullRequestMergeability, PullRequestState, } from '../pr/vocabulary.js';
|
|
8
8
|
import { ReviewActorKind } from '../review/contracts.js';
|
|
9
9
|
import { legacyClaimPayload, newClaimPayload, normalizeLegacyFact, } from './decision-claim-schema.js';
|
|
10
10
|
import { decisionClaimDataIdentity, decisionClaimIdentity, resourcePayloadIdentity, } from './event-integrity.js';
|
|
@@ -125,6 +125,11 @@ export const deniedOutcomeSchema = z
|
|
|
125
125
|
.strict(),
|
|
126
126
|
})
|
|
127
127
|
.strict();
|
|
128
|
+
const mergeabilitySchema = z.enum([
|
|
129
|
+
PullRequestMergeability.Unknown,
|
|
130
|
+
PullRequestMergeability.Mergeable,
|
|
131
|
+
PullRequestMergeability.Conflicting,
|
|
132
|
+
]);
|
|
128
133
|
export function createResourceFactDraftSchemas(eventTypes) {
|
|
129
134
|
return [
|
|
130
135
|
resourceFactDraft(eventTypes.IssueCompleteRequested, z
|
|
@@ -139,6 +144,7 @@ export function createResourceFactDraftSchemas(eventTypes) {
|
|
|
139
144
|
.object({
|
|
140
145
|
workItemId: workItemIdSchema,
|
|
141
146
|
state: stateSchema,
|
|
147
|
+
mergeability: mergeabilitySchema.optional(),
|
|
142
148
|
headRevision: z.string(),
|
|
143
149
|
baseRevision: z.string(),
|
|
144
150
|
checks: checksSchema,
|
|
@@ -152,7 +158,7 @@ export function createResourceFactDraftSchemas(eventTypes) {
|
|
|
152
158
|
changedFiles: z.array(z.string()).optional(),
|
|
153
159
|
})
|
|
154
160
|
.strict()),
|
|
155
|
-
resourceFactDraft(eventTypes.PrStateChanged, z.object({ state: stateSchema }).strict()),
|
|
161
|
+
resourceFactDraft(eventTypes.PrStateChanged, z.object({ state: stateSchema, mergeability: mergeabilitySchema.optional() }).strict()),
|
|
156
162
|
resourceFactDraft(eventTypes.PrChecksChanged, z.object({ checks: checksSchema }).strict()),
|
|
157
163
|
resourceFactDraft(eventTypes.PrReviewAccepted, reviewSchema),
|
|
158
164
|
resourceFactDraft(eventTypes.ReviewAcceptanceSignalRecorded, z
|
|
@@ -2,7 +2,7 @@ import { type EventData, type EventDataUnion, type EventEnvelope, type EventUnio
|
|
|
2
2
|
import { type ResourceId, type ResourceStreamRef } from '../../resources/index.js';
|
|
3
3
|
import { type WorkItemId, type WorkItemStreamRef } from '../../work/index.js';
|
|
4
4
|
import type { PullRequestActivityOutcome, PullRequestTarget } from '../pr/contracts.js';
|
|
5
|
-
import type { MergeMethod, PullRequestCheckState, PullRequestDenialCode, PullRequestState } from '../pr/vocabulary.js';
|
|
5
|
+
import type { MergeMethod, PullRequestCheckState, PullRequestDenialCode, PullRequestMergeability, PullRequestState } from '../pr/vocabulary.js';
|
|
6
6
|
import type { ReviewActorKind } from '../review/contracts.js';
|
|
7
7
|
import type { ActivationId } from './identifiers.js';
|
|
8
8
|
import { type ActivityDecisionStreamRef, type PullRequestDecisionAction } from './streams.js';
|
|
@@ -27,6 +27,7 @@ export declare const ActivityEventType: {
|
|
|
27
27
|
};
|
|
28
28
|
export type ActivityEventTypes = typeof ActivityEventType;
|
|
29
29
|
export interface PullRequestDiscoveredPayload {
|
|
30
|
+
readonly mergeability?: PullRequestMergeability | undefined;
|
|
30
31
|
readonly workItemId: WorkItemId;
|
|
31
32
|
readonly state: typeof PullRequestState.Open | typeof PullRequestState.Closed | typeof PullRequestState.Merged;
|
|
32
33
|
readonly headRevision: string;
|
|
@@ -104,6 +105,7 @@ export interface ActivityEventPayloads {
|
|
|
104
105
|
};
|
|
105
106
|
readonly [ActivityEventType.PrStateChanged]: {
|
|
106
107
|
readonly state: PullRequestDiscoveredPayload['state'];
|
|
108
|
+
readonly mergeability?: PullRequestMergeability | undefined;
|
|
107
109
|
};
|
|
108
110
|
readonly [ActivityEventType.PrChecksChanged]: {
|
|
109
111
|
readonly checks: PullRequestDiscoveredPayload['checks'];
|
|
@@ -82,10 +82,13 @@ class JournalPullRequestService {
|
|
|
82
82
|
return decidePullRequestAuthority(await this.authorityInput(workItemId), options);
|
|
83
83
|
}
|
|
84
84
|
async appendObservationChanges(current, command, context) {
|
|
85
|
-
|
|
86
|
-
current.baseRevision !== command.baseRevision
|
|
85
|
+
const revisionHasChanged = current.headRevision !== command.headRevision ||
|
|
86
|
+
current.baseRevision !== command.baseRevision;
|
|
87
|
+
if (revisionHasChanged)
|
|
87
88
|
await this.append(command.resourceId, revisionChanged(command, context));
|
|
88
|
-
if (current.state !== command.state
|
|
89
|
+
if (current.state !== command.state ||
|
|
90
|
+
current.mergeability !== command.mergeability ||
|
|
91
|
+
(revisionHasChanged && command.mergeability !== undefined))
|
|
89
92
|
await this.append(command.resourceId, stateChanged(command, context));
|
|
90
93
|
if (current.checks !== command.checks)
|
|
91
94
|
await this.append(command.resourceId, checksChanged(command, context));
|
|
@@ -3,7 +3,7 @@ import type { WorkItemId, WorkItemView } from '../../work/index.js';
|
|
|
3
3
|
import type { ActivityFailureCode, ActivityOutcomeKind, ActivityResourceRole } from '../contracts/vocabulary.js';
|
|
4
4
|
import type { ReviewActorKind, ReviewerAuthorizationEvidence } from '../review/contracts.js';
|
|
5
5
|
import type { MergePolicyDetails } from './merge-policy-denial.js';
|
|
6
|
-
import type { MergeMethod, PullRequestCheckState, PullRequestDenialCode, PullRequestState } from './vocabulary.js';
|
|
6
|
+
import type { MergeMethod, PullRequestCheckState, PullRequestDenialCode, PullRequestMergeability, PullRequestState } from './vocabulary.js';
|
|
7
7
|
export interface PullRequestView {
|
|
8
8
|
readonly resourceId: ResourceId;
|
|
9
9
|
readonly workItemId: WorkItemId;
|
|
@@ -11,6 +11,7 @@ export interface PullRequestView {
|
|
|
11
11
|
readonly headRevision: string;
|
|
12
12
|
readonly baseRevision: string;
|
|
13
13
|
readonly checks: PullRequestCheckState;
|
|
14
|
+
readonly mergeability?: PullRequestMergeability | undefined;
|
|
14
15
|
readonly acceptedReview?: {
|
|
15
16
|
readonly revision: string;
|
|
16
17
|
readonly actorId: string;
|
|
@@ -25,6 +26,7 @@ export interface ObservePullRequest {
|
|
|
25
26
|
readonly headRevision: string;
|
|
26
27
|
readonly baseRevision: string;
|
|
27
28
|
readonly checks: PullRequestView['checks'];
|
|
29
|
+
readonly mergeability?: PullRequestMergeability | undefined;
|
|
28
30
|
readonly changedFiles?: readonly string[] | undefined;
|
|
29
31
|
}
|
|
30
32
|
export interface AcceptReviewSignal {
|
|
@@ -14,7 +14,10 @@ export const revisionChanged = (command, context) => fact({
|
|
|
14
14
|
});
|
|
15
15
|
export const stateChanged = (command, context) => fact({
|
|
16
16
|
...metadata(ActivityEventType.PrStateChanged, context),
|
|
17
|
-
payload: {
|
|
17
|
+
payload: {
|
|
18
|
+
state: command.state,
|
|
19
|
+
...(command.mergeability === undefined ? {} : { mergeability: command.mergeability }),
|
|
20
|
+
},
|
|
18
21
|
});
|
|
19
22
|
export const checksChanged = (command, context) => fact({
|
|
20
23
|
...metadata(ActivityEventType.PrChecksChanged, context),
|
|
@@ -44,6 +44,7 @@ function clearRevisionEvidence(view) {
|
|
|
44
44
|
const copy = { ...view };
|
|
45
45
|
delete copy.acceptedReview;
|
|
46
46
|
delete copy.changedFiles;
|
|
47
|
+
delete copy.mergeability;
|
|
47
48
|
return copy;
|
|
48
49
|
}
|
|
49
50
|
function projectPullRequest(previous, data, resourceId) {
|
|
@@ -53,7 +54,9 @@ function projectPullRequest(previous, data, resourceId) {
|
|
|
53
54
|
case ActivityEventType.PrRevisionChanged:
|
|
54
55
|
return previous === null ? previous : { ...clearRevisionEvidence(previous), ...data.payload };
|
|
55
56
|
case ActivityEventType.PrStateChanged:
|
|
56
|
-
return previous === null
|
|
57
|
+
return previous === null
|
|
58
|
+
? previous
|
|
59
|
+
: { ...previous, state: data.payload.state, mergeability: data.payload.mergeability };
|
|
57
60
|
case ActivityEventType.PrChecksChanged:
|
|
58
61
|
return previous === null ? previous : { ...previous, checks: data.payload.checks };
|
|
59
62
|
case ActivityEventType.PrReviewAccepted:
|
|
@@ -5,6 +5,12 @@ export declare const PullRequestState: {
|
|
|
5
5
|
readonly Merged: "merged";
|
|
6
6
|
};
|
|
7
7
|
export type PullRequestState = ValueOf<typeof PullRequestState>;
|
|
8
|
+
export declare const PullRequestMergeability: {
|
|
9
|
+
readonly Unknown: "unknown";
|
|
10
|
+
readonly Mergeable: "clean";
|
|
11
|
+
readonly Conflicting: "conflicting";
|
|
12
|
+
};
|
|
13
|
+
export type PullRequestMergeability = ValueOf<typeof PullRequestMergeability>;
|
|
8
14
|
export declare const PullRequestCheckState: {
|
|
9
15
|
readonly Unknown: "unknown";
|
|
10
16
|
readonly Pending: "pending";
|
|
@@ -4,6 +4,11 @@ export const PullRequestState = defineClosedVocabulary({
|
|
|
4
4
|
Closed: 'closed',
|
|
5
5
|
Merged: 'merged',
|
|
6
6
|
});
|
|
7
|
+
export const PullRequestMergeability = defineClosedVocabulary({
|
|
8
|
+
Unknown: 'unknown',
|
|
9
|
+
Mergeable: 'clean',
|
|
10
|
+
Conflicting: 'conflicting',
|
|
11
|
+
});
|
|
7
12
|
export const PullRequestCheckState = defineClosedVocabulary({
|
|
8
13
|
Unknown: 'unknown',
|
|
9
14
|
Pending: 'pending',
|
|
@@ -142,6 +142,7 @@ export async function createCompositionRoot(wakeRoot, options = {}) {
|
|
|
142
142
|
ids,
|
|
143
143
|
dispatchPolicy: new DispatchPolicy({ maxDispatches: config.controlPlane.maxDispatches }),
|
|
144
144
|
maxConcurrentRuns: config.controlPlane.maxConcurrentRuns,
|
|
145
|
+
maxOpenWorkItems: config.controlPlane.maxOpenWorkItems ?? null,
|
|
145
146
|
maxDispatches: config.controlPlane.maxDispatches,
|
|
146
147
|
schedulerSerialiser: createFileActivationSchedulerSerialiser(paths.dataRoot),
|
|
147
148
|
isDispatchPaused: isRuntimePaused,
|
|
@@ -79,6 +79,15 @@ declare const orchestrationConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
79
79
|
}, z.core.$strict>>;
|
|
80
80
|
}, z.core.$strict>]>>>;
|
|
81
81
|
resourceTransitions: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
82
|
+
events: z.ZodTuple<[z.ZodLiteral<"pr.state-changed">], null>;
|
|
83
|
+
where: z.ZodObject<{
|
|
84
|
+
mergeability: z.ZodLiteral<"conflicting">;
|
|
85
|
+
}, z.core.$strict>;
|
|
86
|
+
then: z.ZodString;
|
|
87
|
+
retry: z.ZodObject<{
|
|
88
|
+
max: z.ZodNumber;
|
|
89
|
+
}, z.core.$strict>;
|
|
90
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
82
91
|
events: z.ZodTuple<[z.ZodLiteral<"pr.review-accepted">], null>;
|
|
83
92
|
then: z.ZodOptional<z.ZodString>;
|
|
84
93
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -226,6 +235,15 @@ export declare const rootConfigSchema: z.ZodObject<{
|
|
|
226
235
|
}, z.core.$strict>>;
|
|
227
236
|
}, z.core.$strict>]>>>;
|
|
228
237
|
resourceTransitions: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
238
|
+
events: z.ZodTuple<[z.ZodLiteral<"pr.state-changed">], null>;
|
|
239
|
+
where: z.ZodObject<{
|
|
240
|
+
mergeability: z.ZodLiteral<"conflicting">;
|
|
241
|
+
}, z.core.$strict>;
|
|
242
|
+
then: z.ZodString;
|
|
243
|
+
retry: z.ZodObject<{
|
|
244
|
+
max: z.ZodNumber;
|
|
245
|
+
}, z.core.$strict>;
|
|
246
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
229
247
|
events: z.ZodTuple<[z.ZodLiteral<"pr.review-accepted">], null>;
|
|
230
248
|
then: z.ZodOptional<z.ZodString>;
|
|
231
249
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -338,6 +356,7 @@ export declare const rootConfigSchema: z.ZodObject<{
|
|
|
338
356
|
controlPlane: z.ZodDefault<z.ZodObject<{
|
|
339
357
|
maxDispatches: z.ZodDefault<z.ZodNumber>;
|
|
340
358
|
maxConcurrentRuns: z.ZodDefault<z.ZodNumber>;
|
|
359
|
+
maxOpenWorkItems: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
341
360
|
triggers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
342
361
|
id: z.ZodString;
|
|
343
362
|
workflow: z.ZodString;
|
|
@@ -43,6 +43,7 @@ orchestration:
|
|
|
43
43
|
# Independent workflow invocations need an explicit event and/or UTC cron source.
|
|
44
44
|
# Activity prompts define their tasks. No triggers are enabled by default.
|
|
45
45
|
controlPlane:
|
|
46
|
+
maxOpenWorkItems: null # Unlimited; set a positive integer to finish open work first.
|
|
46
47
|
triggers: []
|
|
47
48
|
|
|
48
49
|
# External providers Wake correlates inbound work with. Empty until you
|
|
@@ -3,7 +3,7 @@ import { withFileLock } from '@atolis-hq/eventing-filesystem';
|
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { ActivityExecutionKind, activityName, } from '../activities/index.js';
|
|
6
|
-
import { ControlEventType, ControlStreamKind, TriggerService, createDurableRunnerIneligibility, createIntakePipeline, createRunnerPipeline, createTriggerReactor, createWorkCancellationPolicy, selectControlEvent, triggerInvocationProjection, triggerInvocationStream, } from '../control-plane/index.js';
|
|
6
|
+
import { ControlEventType, ControlStreamKind, TriggerService, createDurableRunnerIneligibility, createIntakePipeline, createRunnerPipeline, createTriggerReactor, createWorkCancellationPolicy, hasOpenWorkCapacity, readOpenWorkItemIds, selectControlEvent, triggerInvocationProjection, triggerInvocationStream, } from '../control-plane/index.js';
|
|
7
7
|
import { ConversationOriginKind, workItemIdForConversation } from '../conversations/index.js';
|
|
8
8
|
import { ExecutionStreamKind, NoEligibleRunnerError, RunRepository, createRuntimeMemoryProfile, decodeActivationExecutionEvent, isActiveRunStatus, isRunStream, runId, } from '../execution/index.js';
|
|
9
9
|
import { AgentRunPublicationReactor, ArtifactRegistrationReactor, DeliveryOutcomeReactor, DeliveryService, IntegrationStreamKind, PollService, ProviderRegistry, deliveryProjectionDefinitions, fakeProviderDefinition, publishConversationCommandFeedback, } from '../integrations/index.js';
|
|
@@ -123,6 +123,8 @@ export async function composeIntegrationRuntime(input) {
|
|
|
123
123
|
const active = (await input.execution.list()).filter((run) => isActiveRunStatus(run.status));
|
|
124
124
|
if (active.length >= input.config.controlPlane.maxConcurrentRuns)
|
|
125
125
|
return false;
|
|
126
|
+
if (!(await openWorkCapacityAvailable()))
|
|
127
|
+
return false;
|
|
126
128
|
const workflow = input.config.orchestration.workflows[trigger.workflow];
|
|
127
129
|
const stage = workflow.stages[workflow.entry ?? Object.keys(workflow.stages)[0]];
|
|
128
130
|
const pool = stage.execution?.runnerPool ?? input.config.execution.defaultRunnerPool;
|
|
@@ -147,6 +149,11 @@ export async function composeIntegrationRuntime(input) {
|
|
|
147
149
|
orchestration: input.orchestration,
|
|
148
150
|
now: () => input.clock.now().toISOString(),
|
|
149
151
|
});
|
|
152
|
+
async function openWorkCapacityAvailable() {
|
|
153
|
+
const limit = input.config.controlPlane.maxOpenWorkItems ?? null;
|
|
154
|
+
return (limit === null ||
|
|
155
|
+
hasOpenWorkCapacity(await readOpenWorkItemIds(await input.orchestration.listAll(), input.work), limit));
|
|
156
|
+
}
|
|
150
157
|
const triggerReactors = input.config.controlPlane.triggers.map((config) => createTriggerReactor(triggers, config, decodeCanonicalEvent));
|
|
151
158
|
// Registration starts at the current journal boundary; historical facts are not sources.
|
|
152
159
|
const registrationSchema = z.object({ position: z.number().int().nonnegative() }).strict();
|
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
import { ResourceCorrelationRole } from '../resources/index.js';
|
|
2
2
|
export function createCapabilityResourceTransitionEvidence(input) {
|
|
3
3
|
const registrationFor = (capabilities) => input.policies.find((registration) => registration.capabilities.some((capability) => capabilities.includes(capability)));
|
|
4
|
+
const policyFor = async (workItemId) => {
|
|
5
|
+
const correlations = await input.resources.correlationsForWork(workItemId);
|
|
6
|
+
const primaries = correlations.filter(({ role }) => role === ResourceCorrelationRole.Primary);
|
|
7
|
+
const registrations = [];
|
|
8
|
+
for (const primary of primaries) {
|
|
9
|
+
const resource = await input.resources.get(primary.resourceId);
|
|
10
|
+
if (resource === null)
|
|
11
|
+
continue;
|
|
12
|
+
const registration = registrationFor(resource.capabilities);
|
|
13
|
+
if (registration !== undefined)
|
|
14
|
+
registrations.push(registration);
|
|
15
|
+
}
|
|
16
|
+
return registrations.length === 1 ? registrations[0].policy : null;
|
|
17
|
+
};
|
|
4
18
|
return {
|
|
19
|
+
async mergeWaitState(workItemId) {
|
|
20
|
+
const policy = await policyFor(workItemId);
|
|
21
|
+
return (await policy?.mergeWaitState?.(workItemId)) ?? null;
|
|
22
|
+
},
|
|
5
23
|
triggers: [...new Set(input.policies.flatMap(({ policy }) => policy.triggers))],
|
|
6
24
|
async resolve(evidence) {
|
|
7
25
|
// A work item may hold several primary correlations (e.g. its
|
|
8
26
|
// originating issue and an implementation PR). Only the correlation
|
|
9
27
|
// whose resource matches a registered policy's capabilities is
|
|
10
28
|
// relevant here; the rest drop out rather than blocking resolution.
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const registrations = [];
|
|
14
|
-
for (const primary of primaries) {
|
|
15
|
-
const resource = await input.resources.get(primary.resourceId);
|
|
16
|
-
if (resource === null)
|
|
17
|
-
continue;
|
|
18
|
-
const registration = registrationFor(resource.capabilities);
|
|
19
|
-
if (registration !== undefined)
|
|
20
|
-
registrations.push(registration);
|
|
21
|
-
}
|
|
22
|
-
if (registrations.length !== 1)
|
|
23
|
-
return null;
|
|
24
|
-
return registrations[0].policy.resolve(evidence);
|
|
29
|
+
const policy = await policyFor(evidence.workItemId);
|
|
30
|
+
return (await policy?.resolve(evidence)) ?? null;
|
|
25
31
|
},
|
|
26
32
|
};
|
|
27
33
|
}
|
|
@@ -124,6 +124,6 @@ export function resolveWakeVersion(options = {}) {
|
|
|
124
124
|
return `g${headHash.slice(0, 7)}`;
|
|
125
125
|
return '0.1.0-dev';
|
|
126
126
|
}
|
|
127
|
-
export const wakeVersion = "v0.4.
|
|
127
|
+
export const wakeVersion = "v0.4.78";
|
|
128
128
|
/** The registry-installable version used by packaged sandbox images. */
|
|
129
129
|
export const wakePackageVersion = packageVersion(defaultRepoRoot) ?? wakeVersion;
|
|
@@ -70,6 +70,7 @@ export interface ActivationSchedulerDependencies {
|
|
|
70
70
|
readonly closedWorkItemIds?: () => Promise<readonly string[]>;
|
|
71
71
|
readonly dispatchPolicy?: DispatchPolicy;
|
|
72
72
|
readonly maxConcurrentRuns?: number;
|
|
73
|
+
readonly maxOpenWorkItems?: number | null;
|
|
73
74
|
readonly maxDispatches?: number;
|
|
74
75
|
readonly schedulerSerialiser?: ActivationSchedulerSerialiser;
|
|
75
76
|
}
|
|
@@ -167,6 +167,8 @@ export function createActivationScheduler(orchestration, execution, resources, c
|
|
|
167
167
|
resources,
|
|
168
168
|
dispatchPolicy,
|
|
169
169
|
maxConcurrentRuns,
|
|
170
|
+
maxOpenWorkItems: dependencies.maxOpenWorkItems ?? null,
|
|
171
|
+
work: dependencies.work,
|
|
170
172
|
maxDispatches,
|
|
171
173
|
runnerIneligibility,
|
|
172
174
|
isDispatchPaused,
|
|
@@ -187,6 +189,8 @@ export function createActivationScheduler(orchestration, execution, resources, c
|
|
|
187
189
|
resources,
|
|
188
190
|
dispatchPolicy,
|
|
189
191
|
maxConcurrentRuns,
|
|
192
|
+
maxOpenWorkItems: dependencies.maxOpenWorkItems ?? null,
|
|
193
|
+
work: dependencies.work,
|
|
190
194
|
maxDispatches,
|
|
191
195
|
runnerIneligibility,
|
|
192
196
|
isDispatchPaused,
|
|
@@ -4,6 +4,7 @@ import type { ActivityActivationView, WorkflowInstanceView } from '../../orchest
|
|
|
4
4
|
import type { ResourceService } from '../../resources/index.js';
|
|
5
5
|
import type { AdvanceResult } from '../contracts/views.js';
|
|
6
6
|
import type { DispatchPolicy } from '../domain/dispatch-policy.js';
|
|
7
|
+
import { type WorkAvailability } from '../domain/open-work-policy.js';
|
|
7
8
|
import type { ExecutionPort, OrchestrationPort } from './activation-scheduler-ports.js';
|
|
8
9
|
export interface DispatchLoopContext {
|
|
9
10
|
readonly orchestration: OrchestrationPort;
|
|
@@ -12,6 +13,10 @@ export interface DispatchLoopContext {
|
|
|
12
13
|
readonly dispatchPolicy: DispatchPolicy;
|
|
13
14
|
readonly maxConcurrentRuns: number;
|
|
14
15
|
readonly maxDispatches: number;
|
|
16
|
+
readonly maxOpenWorkItems: number | null;
|
|
17
|
+
readonly work: {
|
|
18
|
+
get(id: string): Promise<WorkAvailability | null>;
|
|
19
|
+
} | undefined;
|
|
15
20
|
readonly runnerIneligibility: () => Promise<ReadonlySet<string>>;
|
|
16
21
|
readonly isDispatchPaused: () => Promise<boolean>;
|
|
17
22
|
readonly commandContext: (cause: string) => CommandContext;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ActivityFailureCode, ActivityOutcomeKind, } from '../../activities/index.js';
|
|
2
2
|
import { ActivationClaimConflictError, isActiveRunStatus, NoEligibleRunnerError, RunStatus, WorkspaceMode, } from '../../execution/index.js';
|
|
3
3
|
import { WorkflowStatus } from '../../orchestration/index.js';
|
|
4
|
+
import { canDispatchWorkItem, readOpenWorkItemIds, } from '../domain/open-work-policy.js';
|
|
4
5
|
import { isExecutionFailureTerminal } from './execution-reconciliation.js';
|
|
5
6
|
export async function advancementWasDurablyApplied(orchestration, workflowInstanceId, activationId) {
|
|
6
7
|
const current = await orchestration.get?.(workflowInstanceId);
|
|
@@ -55,6 +56,7 @@ export function reportUnappliedRunnerQuotaRetry(result, input) {
|
|
|
55
56
|
export async function runDispatchLoop(pending, ctx) {
|
|
56
57
|
const dispatched = [];
|
|
57
58
|
const dispatchedIds = new Set();
|
|
59
|
+
const startedWorkflowIds = new Set();
|
|
58
60
|
const isolatedIds = new Set();
|
|
59
61
|
let isolated;
|
|
60
62
|
let stopReason;
|
|
@@ -68,8 +70,15 @@ export async function runDispatchLoop(pending, ctx) {
|
|
|
68
70
|
stopReason = { kind: 'no-work' };
|
|
69
71
|
break;
|
|
70
72
|
}
|
|
73
|
+
// Legacy test ports may omit listAll; production supplies the journal-backed inventory.
|
|
74
|
+
const open = ctx.maxOpenWorkItems === null
|
|
75
|
+
? new Set()
|
|
76
|
+
: await readOpenWorkItemIds(((await ctx.orchestration.listAll?.()) ?? pending.map((item) => item.workflow)).map((workflow) => startedWorkflowIds.has(workflow.workflowInstanceId)
|
|
77
|
+
? { ...workflow, hasStartedActivation: true }
|
|
78
|
+
: workflow), ctx.work);
|
|
71
79
|
const selectedCandidate = ctx.dispatchPolicy.select(pending
|
|
72
|
-
.filter((item) => !isolatedIds.has(item.workflow.workflowInstanceId)
|
|
80
|
+
.filter((item) => !isolatedIds.has(item.workflow.workflowInstanceId) &&
|
|
81
|
+
canDispatchWorkItem(item.workflow.workItemId, open, ctx.maxOpenWorkItems))
|
|
73
82
|
.map((item, requestedPosition) => ({
|
|
74
83
|
workItemId: item.workflow.workItemId,
|
|
75
84
|
activationId: item.activation.activationId,
|
|
@@ -102,6 +111,7 @@ export async function runDispatchLoop(pending, ctx) {
|
|
|
102
111
|
break;
|
|
103
112
|
}
|
|
104
113
|
await ctx.orchestration.markActivationStarted(selected.workflow.workflowInstanceId, selected.activation.activationId, ctx.commandContext(selected.activation.activationId));
|
|
114
|
+
startedWorkflowIds.add(selected.workflow.workflowInstanceId);
|
|
105
115
|
const correlated = await ctx.resources.correlationsForWork(selected.workflow.workItemId);
|
|
106
116
|
const resourceViews = (await Promise.all(correlated.map((entry) => ctx.resources.get(entry.resourceId)))).filter((resource) => resource !== null);
|
|
107
117
|
const run = await ctx.execution.attempt(selected.activation, {
|
|
@@ -14,6 +14,7 @@ export interface TriggerConfig {
|
|
|
14
14
|
export interface ControlPlaneConfig {
|
|
15
15
|
readonly maxDispatches: number;
|
|
16
16
|
readonly maxConcurrentRuns: number;
|
|
17
|
+
readonly maxOpenWorkItems?: number | null;
|
|
17
18
|
readonly triggers: readonly TriggerConfig[];
|
|
18
19
|
readonly resident?: {
|
|
19
20
|
readonly pollBackoffMs: number;
|
|
@@ -23,6 +24,7 @@ export interface ControlPlaneConfig {
|
|
|
23
24
|
export declare const controlPlaneConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
24
25
|
maxDispatches: z.ZodDefault<z.ZodNumber>;
|
|
25
26
|
maxConcurrentRuns: z.ZodDefault<z.ZodNumber>;
|
|
27
|
+
maxOpenWorkItems: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
26
28
|
triggers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
27
29
|
id: z.ZodString;
|
|
28
30
|
workflow: z.ZodString;
|
|
@@ -42,6 +42,7 @@ export const controlPlaneConfigSchema = z
|
|
|
42
42
|
.object({
|
|
43
43
|
maxDispatches: z.number().int().positive().default(1),
|
|
44
44
|
maxConcurrentRuns: z.number().int().positive().default(1),
|
|
45
|
+
maxOpenWorkItems: z.number().int().positive().nullable().default(null),
|
|
45
46
|
triggers: z.array(triggerSchema).default([]),
|
|
46
47
|
resident: z
|
|
47
48
|
.object({
|
|
@@ -58,6 +59,7 @@ export const controlPlaneConfigSchema = z
|
|
|
58
59
|
.default({
|
|
59
60
|
maxDispatches: 1,
|
|
60
61
|
maxConcurrentRuns: 1,
|
|
62
|
+
maxOpenWorkItems: null,
|
|
61
63
|
triggers: [],
|
|
62
64
|
resident: { pollBackoffMs: 1000 },
|
|
63
65
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type WorkflowInstanceView } from '../../orchestration/index.js';
|
|
2
|
+
export interface WorkAvailability {
|
|
3
|
+
readonly frozen?: boolean;
|
|
4
|
+
readonly deleted?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** Distinct started items with any nonterminal workflow, including waiting children. */
|
|
7
|
+
export declare function deriveOpenWorkItemIds(workflows: readonly WorkflowInstanceView[], unavailable?: ReadonlySet<string>): ReadonlySet<string>;
|
|
8
|
+
export declare function hasOpenWorkCapacity(open: ReadonlySet<string>, limit: number | null): boolean;
|
|
9
|
+
export declare function canDispatchWorkItem(workItemId: string, open: ReadonlySet<string>, limit: number | null): boolean;
|
|
10
|
+
export declare function readOpenWorkItemIds(workflows: readonly WorkflowInstanceView[], work?: {
|
|
11
|
+
get(id: string): Promise<WorkAvailability | null>;
|
|
12
|
+
}): Promise<ReadonlySet<string>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ActivityActivationStatus, WorkflowStatus, } from '../../orchestration/index.js';
|
|
2
|
+
/** Distinct started items with any nonterminal workflow, including waiting children. */
|
|
3
|
+
export function deriveOpenWorkItemIds(workflows, unavailable = new Set()) {
|
|
4
|
+
const started = new Set();
|
|
5
|
+
const unfinished = new Set();
|
|
6
|
+
for (const workflow of workflows) {
|
|
7
|
+
if (unavailable.has(workflow.workItemId))
|
|
8
|
+
continue;
|
|
9
|
+
if (workflow.hasStartedActivation === true ||
|
|
10
|
+
workflow.acceptedOutcomes.length > 0 ||
|
|
11
|
+
(workflow.pendingActivation !== undefined &&
|
|
12
|
+
workflow.pendingActivation.status !== ActivityActivationStatus.Pending))
|
|
13
|
+
started.add(workflow.workItemId);
|
|
14
|
+
if (workflow.status !== WorkflowStatus.Completed &&
|
|
15
|
+
workflow.status !== WorkflowStatus.Superseded)
|
|
16
|
+
unfinished.add(workflow.workItemId);
|
|
17
|
+
}
|
|
18
|
+
return new Set([...started].filter((id) => unfinished.has(id)));
|
|
19
|
+
}
|
|
20
|
+
export function hasOpenWorkCapacity(open, limit) {
|
|
21
|
+
return limit === null || open.size < limit;
|
|
22
|
+
}
|
|
23
|
+
export function canDispatchWorkItem(workItemId, open, limit) {
|
|
24
|
+
return open.has(workItemId) || hasOpenWorkCapacity(open, limit);
|
|
25
|
+
}
|
|
26
|
+
export async function readOpenWorkItemIds(workflows, work) {
|
|
27
|
+
const open = deriveOpenWorkItemIds(workflows);
|
|
28
|
+
const unavailable = new Set();
|
|
29
|
+
await Promise.all([...open].map(async (id) => {
|
|
30
|
+
const item = await work?.get(id);
|
|
31
|
+
if (item?.frozen === true || item?.deleted === true)
|
|
32
|
+
unavailable.add(id);
|
|
33
|
+
}));
|
|
34
|
+
return new Set([...open].filter((id) => !unavailable.has(id)));
|
|
35
|
+
}
|
|
@@ -26,3 +26,4 @@ export * from './infrastructure/resident-host.js';
|
|
|
26
26
|
export * from './infrastructure/tick-host.js';
|
|
27
27
|
export * from './application/trigger-invocation-projection.js';
|
|
28
28
|
export * from './application/trigger-projection.js';
|
|
29
|
+
export * from './domain/open-work-policy.js';
|
|
@@ -25,3 +25,4 @@ export * from './infrastructure/resident-host.js';
|
|
|
25
25
|
export * from './infrastructure/tick-host.js';
|
|
26
26
|
export * from './application/trigger-invocation-projection.js';
|
|
27
27
|
export * from './application/trigger-projection.js';
|
|
28
|
+
export * from './domain/open-work-policy.js';
|
|
@@ -19,6 +19,7 @@ export declare class AgentRunPublicationReactor {
|
|
|
19
19
|
react(outcome: NonNullable<ReturnType<typeof selectWorkflowOrchestrationEvent>>): Promise<void>;
|
|
20
20
|
private publishAcceptedOutcome;
|
|
21
21
|
private publish;
|
|
22
|
+
private publishMergeWait;
|
|
22
23
|
private recordConversationEntry;
|
|
23
24
|
private resourceForTarget;
|
|
24
25
|
private stageForActivation;
|