@atolis-hq/wake 0.4.77 → 0.4.79
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 +2 -2
- package/dist/src/bootstrap/config/root-schema.d.ts +18 -0
- 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 +2 -1
- package/dist/src/control-plane/application/advance-once-dispatch.d.ts +2 -1
- package/dist/src/control-plane/application/advance-once-dispatch.js +7 -0
- package/dist/src/control-plane/domain/dispatch-policy.d.ts +6 -0
- package/dist/src/control-plane/domain/dispatch-policy.js +4 -1
- 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.d.ts +4 -5
- package/dist/src/orchestration/application/advance-workflow.js +6 -6
- package/dist/src/orchestration/application/orchestration-service.d.ts +4 -6
- package/dist/src/orchestration/application/orchestration-service.js +3 -3
- package/dist/src/orchestration/application/pending-activations.d.ts +13 -0
- package/dist/src/orchestration/application/pending-activations.js +32 -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 +24 -1
- package/dist/src/orchestration/contracts/config.d.ts +43 -1
- package/dist/src/orchestration/contracts/config.js +9 -1
- package/dist/src/orchestration/contracts/event-decoder.d.ts +6 -0
- package/dist/src/orchestration/contracts/event-decoder.js +7 -1
- package/dist/src/orchestration/contracts/events.d.ts +2 -0
- package/dist/src/orchestration/contracts/views.d.ts +1 -0
- package/dist/src/orchestration/domain/compiler.js +4 -13
- package/dist/src/orchestration/domain/decision-events.d.ts +1 -0
- package/dist/src/orchestration/domain/decision-events.js +1 -0
- package/dist/src/orchestration/domain/dispatch-priority.d.ts +9 -0
- package/dist/src/orchestration/domain/dispatch-priority.js +16 -0
- package/dist/src/orchestration/domain/resource-transition-compiler.js +1 -0
- package/dist/src/orchestration/domain/runner-quota-retry-policy.js +1 -0
- package/dist/src/orchestration/domain/signal-policy.d.ts +2 -0
- package/dist/src/orchestration/domain/signal-policy.js +10 -4
- package/dist/src/orchestration/domain/transition-target.d.ts +4 -0
- package/dist/src/orchestration/domain/transition-target.js +14 -0
- package/dist/src/orchestration/domain/transition.d.ts +1 -1
- package/dist/src/orchestration/domain/transition.js +4 -3
- package/dist/src/orchestration/domain/workflow-graph.d.ts +8 -0
- package/dist/src/orchestration/domain/workflow-graph.js +41 -0
- package/dist/src/orchestration/domain/workflow-instance-events.js +1 -0
- package/dist/src/orchestration/index.d.ts +3 -0
- package/dist/src/orchestration/index.js +3 -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',
|
|
@@ -6,7 +6,7 @@ import { createConversationService } from '../conversations/index.js';
|
|
|
6
6
|
import { ExecutionCancellationReason, GitWorkspaceProvider, RecoveryService, TranscriptStore, createExecutionService, createLocalProcessInspector, createRunnerMemoryProfileDecorator, } from '../execution/index.js';
|
|
7
7
|
import { createGitHubAgentContextReader, gitHubProviderDefinition, resolveGitHubResourceUrl, } from '../integrations/github/index.js';
|
|
8
8
|
import { SystemClock, UlidIdGenerator } from '../kernel/index.js';
|
|
9
|
-
import { compileWorkflow, createOrchestrationService } from '../orchestration/index.js';
|
|
9
|
+
import { compileWorkflow, createAgentActivityClassifier, createOrchestrationService, } from '../orchestration/index.js';
|
|
10
10
|
import { createResourceLookup, createResourceService, resourceId, } from '../resources/index.js';
|
|
11
11
|
import { createWorkService } from '../work/index.js';
|
|
12
12
|
import { createFileActivationSchedulerSerialiser } from './activation-scheduler-serialiser.js';
|
|
@@ -58,7 +58,7 @@ export async function createCompositionRoot(wakeRoot, options = {}) {
|
|
|
58
58
|
name,
|
|
59
59
|
compileWorkflow(name, definition, activities, Object.keys(config.orchestration.workflows)),
|
|
60
60
|
]));
|
|
61
|
-
const orchestration = createOrchestrationService(journal, work, definitions, projections);
|
|
61
|
+
const orchestration = createOrchestrationService(journal, work, definitions, projections, createAgentActivityClassifier(activities));
|
|
62
62
|
const workspaces = new GitWorkspaceProvider(paths.workspacesRoot, {
|
|
63
63
|
async cloneLocator(id) {
|
|
64
64
|
const resource = await resources.get(resourceId(id));
|
|
@@ -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<{
|
|
@@ -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.79";
|
|
128
128
|
/** The registry-installable version used by packaged sandbox images. */
|
|
129
129
|
export const wakePackageVersion = packageVersion(defaultRepoRoot) ?? wakeVersion;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CommandContext } from '@atolis-hq/eventing';
|
|
2
2
|
import type { ExecutionFailureCode, RunView, WorkspaceRecovery } from '../../execution/index.js';
|
|
3
3
|
import type { IdGenerator } from '../../kernel/index.js';
|
|
4
|
-
import type { ActivityActivationView, WorkflowInstanceView } from '../../orchestration/index.js';
|
|
4
|
+
import type { ActivityActivationView, PendingActivationPriority, WorkflowInstanceView } from '../../orchestration/index.js';
|
|
5
5
|
import type { ResourceService } from '../../resources/index.js';
|
|
6
6
|
import type { WorkStatus } from '../../work/index.js';
|
|
7
7
|
import type { DispatchPolicy } from '../domain/dispatch-policy.js';
|
|
@@ -10,6 +10,7 @@ export interface OrchestrationPort {
|
|
|
10
10
|
listPendingActivations(workItemId?: string): Promise<readonly {
|
|
11
11
|
workflow: WorkflowInstanceView;
|
|
12
12
|
activation: ActivityActivationView;
|
|
13
|
+
priority?: PendingActivationPriority;
|
|
13
14
|
}[]>;
|
|
14
15
|
listWaiting(): Promise<readonly (WorkflowInstanceView | null)[]>;
|
|
15
16
|
get?(workflowInstanceId: string): Promise<WorkflowInstanceView | null>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CommandContext } from '@atolis-hq/eventing';
|
|
2
2
|
import { type ActivityOutcome } from '../../activities/index.js';
|
|
3
|
-
import type { ActivityActivationView, WorkflowInstanceView } from '../../orchestration/index.js';
|
|
3
|
+
import type { ActivityActivationView, PendingActivationPriority, WorkflowInstanceView } from '../../orchestration/index.js';
|
|
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';
|
|
@@ -24,6 +24,7 @@ export interface DispatchLoopContext {
|
|
|
24
24
|
interface PendingActivation {
|
|
25
25
|
readonly workflow: WorkflowInstanceView;
|
|
26
26
|
readonly activation: ActivityActivationView;
|
|
27
|
+
readonly priority?: PendingActivationPriority | undefined;
|
|
27
28
|
}
|
|
28
29
|
export declare function advancementWasDurablyApplied(orchestration: OrchestrationPort, workflowInstanceId: WorkflowInstanceView['workflowInstanceId'], activationId: ActivityActivationView['activationId']): Promise<boolean>;
|
|
29
30
|
export declare function isolatedWorkflowReason(error: unknown): string;
|
|
@@ -3,6 +3,12 @@ import { ActivationClaimConflictError, isActiveRunStatus, NoEligibleRunnerError,
|
|
|
3
3
|
import { WorkflowStatus } from '../../orchestration/index.js';
|
|
4
4
|
import { canDispatchWorkItem, readOpenWorkItemIds, } from '../domain/open-work-policy.js';
|
|
5
5
|
import { isExecutionFailureTerminal } from './execution-reconciliation.js';
|
|
6
|
+
// Ports without priority (older fakes) rank neutrally and fall back to oldest-first.
|
|
7
|
+
const neutralPriority = {
|
|
8
|
+
remainingAgentSteps: 0,
|
|
9
|
+
watchDriven: false,
|
|
10
|
+
retried: false,
|
|
11
|
+
};
|
|
6
12
|
export async function advancementWasDurablyApplied(orchestration, workflowInstanceId, activationId) {
|
|
7
13
|
const current = await orchestration.get?.(workflowInstanceId);
|
|
8
14
|
return (current !== undefined && current !== null && current.acceptedOutcomes.includes(activationId));
|
|
@@ -83,6 +89,7 @@ export async function runDispatchLoop(pending, ctx) {
|
|
|
83
89
|
workItemId: item.workflow.workItemId,
|
|
84
90
|
activationId: item.activation.activationId,
|
|
85
91
|
requestedPosition,
|
|
92
|
+
priority: item.priority ?? neutralPriority,
|
|
86
93
|
hasActiveRun: dispatchedIds.has(item.activation.activationId) ||
|
|
87
94
|
activeActivationIds.has(item.activation.activationId) ||
|
|
88
95
|
branchActiveWorkflowIds.has(item.workflow.workflowInstanceId),
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
export interface DispatchPriority {
|
|
2
|
+
readonly remainingAgentSteps: number;
|
|
3
|
+
readonly watchDriven: boolean;
|
|
4
|
+
readonly retried: boolean;
|
|
5
|
+
}
|
|
1
6
|
export interface DispatchCandidate {
|
|
2
7
|
readonly workItemId: string;
|
|
3
8
|
readonly activationId: string;
|
|
4
9
|
readonly requestedPosition: number;
|
|
10
|
+
readonly priority: DispatchPriority;
|
|
5
11
|
readonly hasActiveRun: boolean;
|
|
6
12
|
readonly cancelled: boolean;
|
|
7
13
|
}
|
|
@@ -8,7 +8,10 @@ export class DispatchPolicy {
|
|
|
8
8
|
return [];
|
|
9
9
|
return [...candidates]
|
|
10
10
|
.filter((candidate) => !candidate.cancelled && !candidate.hasActiveRun)
|
|
11
|
-
.sort((left, right) => left.
|
|
11
|
+
.sort((left, right) => left.priority.remainingAgentSteps - right.priority.remainingAgentSteps ||
|
|
12
|
+
Number(right.priority.watchDriven) - Number(left.priority.watchDriven) ||
|
|
13
|
+
Number(right.priority.retried) - Number(left.priority.retried) ||
|
|
14
|
+
left.requestedPosition - right.requestedPosition ||
|
|
12
15
|
left.activationId.localeCompare(right.activationId))
|
|
13
16
|
.slice(0, this.options.maxDispatches);
|
|
14
17
|
}
|
|
@@ -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;
|
|
@@ -2,13 +2,14 @@ import { defineEventProcessor, EventActorKind, EventProcessorCategory, EventProc
|
|
|
2
2
|
import { BuiltInActivityName } from '../../activities/index.js';
|
|
3
3
|
import { conversationIdForWorkItem, ConversationOriginKind, } from '../../conversations/index.js';
|
|
4
4
|
import { RunStatus } from '../../execution/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import { OrchestrationEventType, OrchestrationStreamKind, selectWorkflowOrchestrationEvent, } from '../../orchestration/index.js';
|
|
6
6
|
import { BuiltInResourceKind, ResourceCorrelationRole, resourceStream, } from '../../resources/index.js';
|
|
7
7
|
import { ReplyTarget } from '../contracts/reply-routing.js';
|
|
8
8
|
import { createDeliveryIntentEventData } from '../delivery/contracts/event-factory.js';
|
|
9
9
|
import { DeliveryIntentEventType } from '../delivery/contracts/intents.js';
|
|
10
10
|
import { defaultReplyPublication, selectReplyTarget, } from '../github/application/reply-target-selector.js';
|
|
11
11
|
import { projectTerminalAgentRunReport } from './terminal-agent-run-report.js';
|
|
12
|
+
import { agentRunReportInput, mergeWaitComment } from './agent-run-publication-report.js';
|
|
12
13
|
/** Projects terminal agent runs into one durable outbound intent per configured resource. */
|
|
13
14
|
export class AgentRunPublicationReactor {
|
|
14
15
|
dependencies;
|
|
@@ -24,7 +25,8 @@ export class AgentRunPublicationReactor {
|
|
|
24
25
|
select(event) {
|
|
25
26
|
const outcome = selectWorkflowOrchestrationEvent(event);
|
|
26
27
|
return outcome?.event.eventType === OrchestrationEventType.ActivityOutcomeAccepted ||
|
|
27
|
-
outcome?.event.eventType === OrchestrationEventType.ActivityExecutionFailed
|
|
28
|
+
outcome?.event.eventType === OrchestrationEventType.ActivityExecutionFailed ||
|
|
29
|
+
outcome?.event.eventType === OrchestrationEventType.SignalWaitStarted
|
|
28
30
|
? outcome
|
|
29
31
|
: null;
|
|
30
32
|
},
|
|
@@ -32,6 +34,10 @@ export class AgentRunPublicationReactor {
|
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
36
|
async react(outcome) {
|
|
37
|
+
if (outcome.event.eventType === OrchestrationEventType.SignalWaitStarted) {
|
|
38
|
+
await this.publishMergeWait(outcome);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
35
41
|
if (outcome.event.eventType === OrchestrationEventType.ActivityOutcomeAccepted) {
|
|
36
42
|
await this.publishAcceptedOutcome(outcome.stream.id, outcome.event.payload.activationId, outcome.recordedAt, outcome.event.eventId, outcome.event.correlationId);
|
|
37
43
|
return;
|
|
@@ -57,7 +63,7 @@ export class AgentRunPublicationReactor {
|
|
|
57
63
|
if (workflow === undefined)
|
|
58
64
|
return;
|
|
59
65
|
const stage = await this.stageForActivation(workflow.workflowInstanceId, run.activationId);
|
|
60
|
-
const report = projectTerminalAgentRunReport(
|
|
66
|
+
const report = projectTerminalAgentRunReport(agentRunReportInput(run, stage, workflow, allWorkflows));
|
|
61
67
|
if (report === null)
|
|
62
68
|
return;
|
|
63
69
|
await this.recordConversationEntry(workflow.workItemId, run.runId, report.displayBody, stage, occurredAt, correlationId);
|
|
@@ -99,6 +105,46 @@ export class AgentRunPublicationReactor {
|
|
|
99
105
|
/* idempotency is the deterministic run event id */
|
|
100
106
|
}
|
|
101
107
|
}
|
|
108
|
+
async publishMergeWait(event) {
|
|
109
|
+
const workflow = (await this.dependencies.orchestration.listAll()).find((view) => view.workflowInstanceId === event.stream.id);
|
|
110
|
+
const body = mergeWaitComment(workflow);
|
|
111
|
+
if (workflow?.pendingActivation === undefined || body === undefined)
|
|
112
|
+
return;
|
|
113
|
+
// A replayed older wait event must not publish guidance for a newer wait.
|
|
114
|
+
if (event.event.eventType === OrchestrationEventType.SignalWaitStarted &&
|
|
115
|
+
event.event.payload.signalKind !== workflow.waitingFor?.signalKind)
|
|
116
|
+
return;
|
|
117
|
+
const replies = this.dependencies.replies ?? defaultReplyPublication;
|
|
118
|
+
const target = selectReplyTarget({ stage: workflow.currentStage, outcome: 'DONE' }, replies.rules, replies.default);
|
|
119
|
+
if (target === ReplyTarget.None)
|
|
120
|
+
return;
|
|
121
|
+
const resource = await this.resourceForTarget(workflow.workItemId, target);
|
|
122
|
+
if (resource === undefined)
|
|
123
|
+
return;
|
|
124
|
+
const stream = resourceStream(resource.resourceId);
|
|
125
|
+
const facts = await this.dependencies.journal.readStream(stream);
|
|
126
|
+
const eventId = `merge-wait:${event.event.eventId}`;
|
|
127
|
+
if (facts.some((fact) => fact.event.eventId === eventId))
|
|
128
|
+
return;
|
|
129
|
+
await this.dependencies.journal.appendToStream(stream, facts.length, [
|
|
130
|
+
createDeliveryIntentEventData({
|
|
131
|
+
eventId,
|
|
132
|
+
eventType: DeliveryIntentEventType.ReplyPublishRequested,
|
|
133
|
+
occurredAt: event.recordedAt,
|
|
134
|
+
correlationId: event.event.correlationId,
|
|
135
|
+
causationId: event.event.eventId,
|
|
136
|
+
actor: { kind: EventActorKind.Integration, id: 'agent-run-publication' },
|
|
137
|
+
source: { kind: EventSourceKind.Internal, id: 'agent-run-publication' },
|
|
138
|
+
payload: {
|
|
139
|
+
workflowInstanceId: workflow.workflowInstanceId,
|
|
140
|
+
activationId: workflow.pendingActivation.activationId,
|
|
141
|
+
resourceId: resource.resourceId,
|
|
142
|
+
body,
|
|
143
|
+
publicationOnly: true,
|
|
144
|
+
},
|
|
145
|
+
}),
|
|
146
|
+
]);
|
|
147
|
+
}
|
|
102
148
|
async recordConversationEntry(workItemId, runId, body, stage, occurredAt, correlationId) {
|
|
103
149
|
const conversations = this.dependencies.conversations;
|
|
104
150
|
if (conversations === undefined)
|
|
@@ -153,25 +199,3 @@ export class AgentRunPublicationReactor {
|
|
|
153
199
|
return undefined;
|
|
154
200
|
}
|
|
155
201
|
}
|
|
156
|
-
function reportInput(run, stage, workflow, allWorkflows) {
|
|
157
|
-
const watchGateVerdict = watchGateVerdictFor(run, workflow, allWorkflows);
|
|
158
|
-
const isWaiting = workflow.waitingFor !== undefined &&
|
|
159
|
-
isApprovalAwaitingSignalKind(workflow.waitingFor.signalKind);
|
|
160
|
-
return {
|
|
161
|
-
run,
|
|
162
|
-
...(stage === undefined ? {} : { stage }),
|
|
163
|
-
...(isWaiting ? { awaitingApproval: true } : {}),
|
|
164
|
-
...(watchGateVerdict === undefined ? {} : { watchGateVerdict }),
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
function watchGateVerdictFor(run, workflow, allWorkflows) {
|
|
168
|
-
if (run.agent?.outcome !== 'DONE' && run.agent?.outcome !== 'REJECTED')
|
|
169
|
-
return undefined;
|
|
170
|
-
if (workflow.parentWorkflowInstanceId === undefined || workflow.watchId === undefined)
|
|
171
|
-
return undefined;
|
|
172
|
-
const parent = allWorkflows.find((value) => value.workflowInstanceId === workflow.parentWorkflowInstanceId);
|
|
173
|
-
if (parent?.waitingFor?.signalKind !== WatchGateVerdictSignal)
|
|
174
|
-
return undefined;
|
|
175
|
-
const namesThisWatch = parent.waitingFor.from?.some((entry) => entry.kind === ApprovalAuthorityKind.Watch && entry.watch === workflow.watchId);
|
|
176
|
-
return namesThisWatch === true ? { runId: run.runId } : undefined;
|
|
177
|
-
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type WorkflowInstanceView } from '../../orchestration/index.js';
|
|
2
|
+
import { type projectTerminalAgentRunReport, type TerminalRun } from './terminal-agent-run-report.js';
|
|
3
|
+
/** The comment to post when a merge stage starts waiting, or undefined when no hint applies. */
|
|
4
|
+
export declare function mergeWaitComment(workflow: WorkflowInstanceView | undefined): string | undefined;
|
|
5
|
+
export declare function agentRunReportInput(run: TerminalRun, stage: string | undefined, workflow: WorkflowInstanceView, allWorkflows: readonly WorkflowInstanceView[]): Parameters<typeof projectTerminalAgentRunReport>[0];
|
|
6
|
+
export declare function isMergePublicationWait(workflow: WorkflowInstanceView | undefined): workflow is WorkflowInstanceView & {
|
|
7
|
+
readonly pendingActivation: NonNullable<WorkflowInstanceView['pendingActivation']>;
|
|
8
|
+
};
|
|
9
|
+
/** An approved wait at the merge stage is resumed by /approved. */
|
|
10
|
+
export declare function isMergeStageApproval(workflow: WorkflowInstanceView): boolean;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { BuiltInActivityName } from '../../activities/index.js';
|
|
2
|
+
import { ApprovalAuthorityKind, ApprovedSignal, isApprovalAwaitingSignalKind, isPolicyBlockedMergeWait, ResourceTransitionSignal, WatchGateVerdictSignal, WorkflowStatus, } from '../../orchestration/index.js';
|
|
3
|
+
import { MergeStageApprovalGuidance, MergeWaitGuidance, } from './terminal-agent-run-report.js';
|
|
4
|
+
/** The comment to post when a merge stage starts waiting, or undefined when no hint applies. */
|
|
5
|
+
export function mergeWaitComment(workflow) {
|
|
6
|
+
if (workflow === undefined)
|
|
7
|
+
return undefined;
|
|
8
|
+
if (isMergePublicationWait(workflow))
|
|
9
|
+
return `**Wake: Awaiting merge**\n\n${MergeWaitGuidance}`;
|
|
10
|
+
const waiting = workflow.status === WorkflowStatus.Waiting && workflow.parentWorkflowInstanceId === undefined;
|
|
11
|
+
return waiting && isMergeStageApproval(workflow)
|
|
12
|
+
? `**Wake: Awaiting approval**\n\n${MergeStageApprovalGuidance}`
|
|
13
|
+
: undefined;
|
|
14
|
+
}
|
|
15
|
+
export function agentRunReportInput(run, stage, workflow, allWorkflows) {
|
|
16
|
+
const watchGateVerdict = watchGateVerdictFor(run, workflow, allWorkflows);
|
|
17
|
+
const isWaiting = workflow.waitingFor !== undefined &&
|
|
18
|
+
isApprovalAwaitingSignalKind(workflow.waitingFor.signalKind);
|
|
19
|
+
const isMergeWait = isMergePublicationWait(workflow);
|
|
20
|
+
return {
|
|
21
|
+
run,
|
|
22
|
+
...(stage === undefined ? {} : { stage }),
|
|
23
|
+
...(isWaiting ? { awaitingApproval: true } : {}),
|
|
24
|
+
...(isMergeWait ? { awaitingMerge: true } : {}),
|
|
25
|
+
...(isMergeStageApproval(workflow) ? { mergeStageApproval: true } : {}),
|
|
26
|
+
...(watchGateVerdict === undefined ? {} : { watchGateVerdict }),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function isMergePublicationWait(workflow) {
|
|
30
|
+
return (workflow?.status === WorkflowStatus.Waiting &&
|
|
31
|
+
workflow.parentWorkflowInstanceId === undefined &&
|
|
32
|
+
workflow.waitingFor !== undefined &&
|
|
33
|
+
workflow.waitingFor.intentEventId === undefined &&
|
|
34
|
+
workflow.pendingActivation?.activity === BuiltInActivityName.PullRequestMerge &&
|
|
35
|
+
(workflow.waitingFor.signalKind === ResourceTransitionSignal ||
|
|
36
|
+
isPolicyBlockedMergeWait(workflow)));
|
|
37
|
+
}
|
|
38
|
+
/** An approved wait at the merge stage is resumed by /approved. */
|
|
39
|
+
export function isMergeStageApproval(workflow) {
|
|
40
|
+
return (workflow.waitingFor?.signalKind === ApprovedSignal &&
|
|
41
|
+
workflow.pendingActivation?.activity === BuiltInActivityName.PullRequestMerge);
|
|
42
|
+
}
|
|
43
|
+
function watchGateVerdictFor(run, workflow, allWorkflows) {
|
|
44
|
+
if (run.agent?.outcome !== 'DONE' && run.agent?.outcome !== 'REJECTED')
|
|
45
|
+
return undefined;
|
|
46
|
+
if (workflow.parentWorkflowInstanceId === undefined || workflow.watchId === undefined)
|
|
47
|
+
return undefined;
|
|
48
|
+
const parent = allWorkflows.find((value) => value.workflowInstanceId === workflow.parentWorkflowInstanceId);
|
|
49
|
+
if (parent?.waitingFor?.signalKind !== WatchGateVerdictSignal)
|
|
50
|
+
return undefined;
|
|
51
|
+
const namesThisWatch = parent.waitingFor.from?.some((entry) => entry.kind === ApprovalAuthorityKind.Watch && entry.watch === workflow.watchId);
|
|
52
|
+
return namesThisWatch === true ? { runId: run.runId } : undefined;
|
|
53
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { AgentRunPublicationReport } from '../delivery/contracts/intents.js';
|
|
2
|
+
export declare const MergeWaitGuidance = "Wake is waiting for the primary pull request to merge. Resolve and merge it in the provider; explicit conflicts use the pinned workflow repair policy, and closed unmerged pull requests block the work.";
|
|
3
|
+
export declare const MergeStageApprovalGuidance = "An authorized independent reviewer can reply with /approved to continue. Approval of your own work is not permitted.";
|
|
2
4
|
export interface TerminalRunAgentResult {
|
|
3
5
|
readonly outcome: 'DONE' | 'REJECTED' | 'BLOCKED' | 'FAILED' | 'NEEDS_CLARIFICATION';
|
|
4
6
|
readonly displayBody: string;
|
|
@@ -27,6 +29,8 @@ export declare function projectTerminalAgentRunReport(input: {
|
|
|
27
29
|
readonly run: TerminalRun;
|
|
28
30
|
readonly stage?: string;
|
|
29
31
|
readonly awaitingApproval?: boolean;
|
|
32
|
+
readonly awaitingMerge?: boolean;
|
|
33
|
+
readonly mergeStageApproval?: boolean;
|
|
30
34
|
readonly watchGateVerdict?: {
|
|
31
35
|
readonly runId: string;
|
|
32
36
|
};
|