@atolis-hq/wake 0.4.105 → 0.4.107
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 +7 -0
- package/dist/src/activities/contracts/activity.d.ts +12 -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 +31 -10
- 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 +12 -3
- package/dist/src/bootstrap/config/root-schema.d.ts +6 -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 +27 -0
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/control-plane/application/activation-scheduler-ports.d.ts +3 -1
- package/dist/src/control-plane/application/advance-once-dispatch.js +10 -6
- package/dist/src/conversations/application/conversation-repository.d.ts +1 -1
- package/dist/src/conversations/application/conversation-repository.js +3 -1
- package/dist/src/execution/application/execution-service.js +10 -0
- 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 +1 -0
- package/dist/src/execution/application/run-repository.js +27 -10
- package/dist/src/execution/contracts/commands.d.ts +2 -0
- package/dist/src/execution/contracts/events.d.ts +13 -0
- package/dist/src/execution/contracts/events.js +2 -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/views.d.ts +2 -0
- package/dist/src/execution/contracts/workspace.d.ts +2 -0
- package/dist/src/execution/index.d.ts +1 -0
- package/dist/src/execution/index.js +1 -0
- package/dist/src/integrations/application/artifact-registration-reactor.js +7 -14
- 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/application/latest-unresolved-artifacts.d.ts +3 -0
- package/dist/src/integrations/application/latest-unresolved-artifacts.js +16 -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/comment-history-reader.d.ts +1 -1
- package/dist/src/integrations/github/application/comment-history-reader.js +56 -39
- 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/node_modules/@atolis-hq/eventing/dist/index.d.ts +1 -1
- package/dist/src/node_modules/@atolis-hq/eventing/dist/index.d.ts.map +1 -1
- package/dist/src/node_modules/@atolis-hq/eventing/dist/index.js +1 -1
- package/dist/src/node_modules/@atolis-hq/eventing/dist/projections/projection-processor.d.ts +14 -0
- package/dist/src/node_modules/@atolis-hq/eventing/dist/projections/projection-processor.d.ts.map +1 -1
- package/dist/src/node_modules/@atolis-hq/eventing/dist/projections/projection-processor.js +31 -1
- package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/journal-view.d.ts +22 -0
- package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/journal-view.d.ts.map +1 -0
- package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/journal-view.js +60 -0
- package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.d.ts +2 -0
- package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.d.ts.map +1 -1
- package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.js +82 -15
- package/dist/src/orchestration/application/advance-workflow.js +7 -2
- package/dist/src/orchestration/application/deferred-signals.js +2 -6
- package/dist/src/orchestration/application/delegation-commands.d.ts +3 -0
- package/dist/src/orchestration/application/delivery-coordinator.d.ts +70 -1
- package/dist/src/orchestration/application/delivery-coordinator.js +31 -5
- package/dist/src/orchestration/application/delivery-facts-reader.js +1 -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 +1 -0
- package/dist/src/orchestration/application/delivery-preparation.js +7 -2
- package/dist/src/orchestration/application/orchestration-repository.d.ts +14 -9
- package/dist/src/orchestration/application/orchestration-repository.js +139 -64
- package/dist/src/orchestration/application/orchestration-service.d.ts +74 -3
- package/dist/src/orchestration/application/orchestration-service.js +55 -2
- package/dist/src/orchestration/contracts/config.d.ts +6 -0
- package/dist/src/orchestration/contracts/config.js +6 -0
- package/dist/src/orchestration/contracts/delivery-ports.d.ts +44 -0
- package/dist/src/orchestration/contracts/delivery.d.ts +58 -0
- package/dist/src/orchestration/contracts/delivery.js +53 -1
- package/dist/src/orchestration/contracts/event-decoder.js +2 -1
- package/dist/src/orchestration/contracts/event-factory.js +2 -0
- package/dist/src/orchestration/contracts/events.d.ts +3 -1
- package/dist/src/orchestration/contracts/events.js +1 -0
- package/dist/src/orchestration/contracts/vocabulary.d.ts +44 -1
- package/dist/src/orchestration/contracts/vocabulary.js +40 -1
- 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/delivery-candidate.js +13 -0
- package/dist/src/orchestration/domain/delivery-facts.d.ts +7 -1
- package/dist/src/orchestration/domain/delivery-facts.js +33 -1
- 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 +2 -1
- package/dist/src/orchestration/domain/delivery-qa.js +24 -4
- package/dist/src/orchestration/domain/delivery-workflow-policy.d.ts +3 -1
- package/dist/src/orchestration/domain/delivery-workflow-policy.js +19 -0
- package/dist/src/orchestration/domain/workflow-instance-events.js +1 -0
- package/dist/src/orchestration/index.d.ts +3 -2
- package/dist/src/orchestration/index.js +1 -1
- package/dist/src/resources/application/resource-lookup.d.ts +2 -1
- package/dist/src/resources/application/resource-lookup.js +3 -11
- package/dist/src/resources/application/resource-repository.js +10 -10
- package/dist/src/surfaces/api/contracts/transport-values.js +1 -0
- package/dist/src/surfaces/api/contracts/work.d.ts +26 -0
- package/dist/src/surfaces/api/presenters/execution.js +1 -0
- package/dist/src/surfaces/mcp/delegation.js +5 -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/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.d.ts +0 -16
- package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.d.ts.map +0 -1
- package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.js +0 -79
- package/dist/src/surfaces/web-assets/assets/index-BfhxlN_h.js +0 -1192
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { pullRequestCheckEvidenceSchema } from '../pr/check-evidence.js';
|
|
2
3
|
import { mergePolicyDetailsSchema } from '../pr/merge-policy-denial.js';
|
|
4
|
+
import { parentActionContextSchema } from '../pr/parent-scope.js';
|
|
3
5
|
import { eventDataSchema, eventEnvelopeSchema } from '@atolis-hq/eventing';
|
|
4
6
|
import { brandedStringSchema } from '../../kernel/index.js';
|
|
5
7
|
import { ResourceStreamKind, resourceId } from '../../resources/index.js';
|
|
@@ -59,6 +61,10 @@ const denialCodeSchema = z.enum([
|
|
|
59
61
|
PullRequestDenialCode.TooManyFilesChanged,
|
|
60
62
|
PullRequestDenialCode.BlockedPathChanged,
|
|
61
63
|
PullRequestDenialCode.ChangedFilesUnavailable,
|
|
64
|
+
PullRequestDenialCode.OutsideDelivery,
|
|
65
|
+
PullRequestDenialCode.DeliveryNotReady,
|
|
66
|
+
PullRequestDenialCode.TargetHeld,
|
|
67
|
+
PullRequestDenialCode.MaintenanceRequired,
|
|
62
68
|
]);
|
|
63
69
|
const denialSchema = z
|
|
64
70
|
.object({
|
|
@@ -88,6 +94,7 @@ const approveRequestedSchema = z
|
|
|
88
94
|
resourceId: resourceIdSchema,
|
|
89
95
|
revision: z.string(),
|
|
90
96
|
body: z.string().nullable(),
|
|
97
|
+
parent: parentActionContextSchema.optional(),
|
|
91
98
|
})
|
|
92
99
|
.strict();
|
|
93
100
|
const mergeRequestedSchema = z
|
|
@@ -100,6 +107,7 @@ const mergeRequestedSchema = z
|
|
|
100
107
|
method: z.enum([MergeMethod.Merge, MergeMethod.Squash, MergeMethod.Rebase]),
|
|
101
108
|
requireChecks: z.boolean(),
|
|
102
109
|
autoMerge: z.boolean().default(false),
|
|
110
|
+
parent: parentActionContextSchema.optional(),
|
|
103
111
|
})
|
|
104
112
|
.strict();
|
|
105
113
|
export const requestedOutcomeSchema = z
|
|
@@ -144,11 +152,13 @@ export function createResourceFactDraftSchemas(eventTypes) {
|
|
|
144
152
|
resourceFactDraft(eventTypes.PrDiscovered, z
|
|
145
153
|
.object({
|
|
146
154
|
workItemId: workItemIdSchema,
|
|
155
|
+
mergeRevision: z.string().min(1).optional(),
|
|
147
156
|
state: stateSchema,
|
|
148
157
|
mergeability: mergeabilitySchema.optional(),
|
|
149
158
|
headRevision: z.string(),
|
|
150
159
|
baseRevision: z.string(),
|
|
151
160
|
checks: checksSchema,
|
|
161
|
+
checkEvidence: pullRequestCheckEvidenceSchema.optional(),
|
|
152
162
|
changedFiles: z.array(z.string()).optional(),
|
|
153
163
|
})
|
|
154
164
|
.strict()),
|
|
@@ -159,8 +169,16 @@ export function createResourceFactDraftSchemas(eventTypes) {
|
|
|
159
169
|
changedFiles: z.array(z.string()).optional(),
|
|
160
170
|
})
|
|
161
171
|
.strict()),
|
|
162
|
-
resourceFactDraft(eventTypes.PrStateChanged, z
|
|
163
|
-
|
|
172
|
+
resourceFactDraft(eventTypes.PrStateChanged, z
|
|
173
|
+
.object({
|
|
174
|
+
state: stateSchema,
|
|
175
|
+
mergeability: mergeabilitySchema.optional(),
|
|
176
|
+
mergeRevision: z.string().min(1).optional(),
|
|
177
|
+
})
|
|
178
|
+
.strict()),
|
|
179
|
+
resourceFactDraft(eventTypes.PrChecksChanged, z
|
|
180
|
+
.object({ checks: checksSchema, checkEvidence: pullRequestCheckEvidenceSchema.optional() })
|
|
181
|
+
.strict()),
|
|
164
182
|
resourceFactDraft(eventTypes.PrReviewAccepted, reviewSchema),
|
|
165
183
|
resourceFactDraft(eventTypes.ReviewAcceptanceSignalRecorded, z
|
|
166
184
|
.object({
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type EventData, type EventDataUnion, type EventEnvelope, type EventUnion } from '@atolis-hq/eventing';
|
|
2
2
|
import { type ResourceId, type ResourceStreamRef } from '../../resources/index.js';
|
|
3
3
|
import { type WorkItemId, type WorkItemStreamRef } from '../../work/index.js';
|
|
4
|
+
import type { PullRequestCheckEvidence } from '../pr/check-evidence.js';
|
|
4
5
|
import type { PullRequestActivityOutcome, PullRequestTarget } from '../pr/contracts.js';
|
|
6
|
+
import type { ParentActionContext } from '../pr/parent-scope.js';
|
|
5
7
|
import type { MergeMethod, PullRequestCheckState, PullRequestDenialCode, PullRequestMergeability, PullRequestState } from '../pr/vocabulary.js';
|
|
6
8
|
import type { ReviewActorKind } from '../review/contracts.js';
|
|
7
9
|
import type { ActivationId } from './identifiers.js';
|
|
@@ -27,6 +29,8 @@ export declare const ActivityEventType: {
|
|
|
27
29
|
};
|
|
28
30
|
export type ActivityEventTypes = typeof ActivityEventType;
|
|
29
31
|
export interface PullRequestDiscoveredPayload {
|
|
32
|
+
readonly checkEvidence?: PullRequestCheckEvidence | undefined;
|
|
33
|
+
readonly mergeRevision?: string | undefined;
|
|
30
34
|
readonly mergeability?: PullRequestMergeability | undefined;
|
|
31
35
|
readonly workItemId: WorkItemId;
|
|
32
36
|
readonly state: typeof PullRequestState.Open | typeof PullRequestState.Closed | typeof PullRequestState.Merged;
|
|
@@ -56,6 +60,8 @@ export interface PullRequestApproveRequestedPayload {
|
|
|
56
60
|
readonly resourceId: ResourceId;
|
|
57
61
|
readonly revision: string;
|
|
58
62
|
readonly body: string | null;
|
|
63
|
+
/** Present when a parent delivery acts on a child-owned pull request. */
|
|
64
|
+
readonly parent?: ParentActionContext | undefined;
|
|
59
65
|
}
|
|
60
66
|
export interface PullRequestMergeRequestedPayload {
|
|
61
67
|
readonly idempotencyKey: string;
|
|
@@ -66,6 +72,8 @@ export interface PullRequestMergeRequestedPayload {
|
|
|
66
72
|
readonly method: typeof MergeMethod.Merge | typeof MergeMethod.Squash | typeof MergeMethod.Rebase;
|
|
67
73
|
readonly requireChecks: boolean;
|
|
68
74
|
readonly autoMerge: boolean;
|
|
75
|
+
/** Present when a parent delivery acts on a child-owned pull request. */
|
|
76
|
+
readonly parent?: ParentActionContext | undefined;
|
|
69
77
|
}
|
|
70
78
|
type RequestedOutcome = Extract<PullRequestActivityOutcome, {
|
|
71
79
|
readonly kind: typeof ActivityOutcomeKind.Waiting;
|
|
@@ -104,10 +112,12 @@ export interface ActivityEventPayloads {
|
|
|
104
112
|
readonly changedFiles?: readonly string[] | undefined;
|
|
105
113
|
};
|
|
106
114
|
readonly [ActivityEventType.PrStateChanged]: {
|
|
115
|
+
readonly mergeRevision?: string | undefined;
|
|
107
116
|
readonly state: PullRequestDiscoveredPayload['state'];
|
|
108
117
|
readonly mergeability?: PullRequestMergeability | undefined;
|
|
109
118
|
};
|
|
110
119
|
readonly [ActivityEventType.PrChecksChanged]: {
|
|
120
|
+
readonly checkEvidence?: PullRequestCheckEvidence | undefined;
|
|
111
121
|
readonly checks: PullRequestDiscoveredPayload['checks'];
|
|
112
122
|
};
|
|
113
123
|
readonly [ActivityEventType.PrReviewAccepted]: {
|
|
@@ -46,6 +46,8 @@ export declare const ActivityOutcomeKind: {
|
|
|
46
46
|
readonly Rejected: "rejected";
|
|
47
47
|
readonly Blocked: "blocked";
|
|
48
48
|
readonly Failed: "failed";
|
|
49
|
+
/** A parent delivery has nothing left to integrate: every selected change is merged. */
|
|
50
|
+
readonly Integrated: "integrated";
|
|
49
51
|
};
|
|
50
52
|
export type ActivityOutcomeKind = ValueOf<typeof ActivityOutcomeKind>;
|
|
51
53
|
export declare const ActivityRunnerTransportStatus: {
|
|
@@ -40,6 +40,8 @@ export const ActivityOutcomeKind = defineClosedVocabulary({
|
|
|
40
40
|
Rejected: 'rejected',
|
|
41
41
|
Blocked: 'blocked',
|
|
42
42
|
Failed: 'failed',
|
|
43
|
+
/** A parent delivery has nothing left to integrate: every selected change is merged. */
|
|
44
|
+
Integrated: 'integrated',
|
|
43
45
|
});
|
|
44
46
|
export const ActivityRunnerTransportStatus = defineClosedVocabulary({
|
|
45
47
|
Succeeded: 'succeeded',
|
|
@@ -14,6 +14,7 @@ export * from './pr/application.js';
|
|
|
14
14
|
export * from './pr/approve.js';
|
|
15
15
|
export * from './pr/contracts.js';
|
|
16
16
|
export * from './pr/merge-authority-gate.js';
|
|
17
|
+
export * from './pr/parent-scope.js';
|
|
17
18
|
export * from './pr/merge.js';
|
|
18
19
|
export * from './pr/policy.js';
|
|
19
20
|
export * from './pr/projection.js';
|
|
@@ -22,3 +23,4 @@ export * from './review/authorization.js';
|
|
|
22
23
|
export * from './review/contracts.js';
|
|
23
24
|
export * from './review/signals.js';
|
|
24
25
|
export * from './pr/merge-policy-denial.js';
|
|
26
|
+
export { pullRequestCheckEvidenceSchema, type PullRequestCheckEvidence, } from './pr/check-evidence.js';
|
|
@@ -14,6 +14,7 @@ export * from './pr/application.js';
|
|
|
14
14
|
export * from './pr/approve.js';
|
|
15
15
|
export * from './pr/contracts.js';
|
|
16
16
|
export * from './pr/merge-authority-gate.js';
|
|
17
|
+
export * from './pr/parent-scope.js';
|
|
17
18
|
export * from './pr/merge.js';
|
|
18
19
|
export * from './pr/policy.js';
|
|
19
20
|
export * from './pr/projection.js';
|
|
@@ -22,3 +23,4 @@ export * from './review/authorization.js';
|
|
|
22
23
|
export * from './review/contracts.js';
|
|
23
24
|
export * from './review/signals.js';
|
|
24
25
|
export * from './pr/merge-policy-denial.js';
|
|
26
|
+
export { pullRequestCheckEvidenceSchema, } from './pr/check-evidence.js';
|
|
@@ -11,7 +11,7 @@ export declare const pullRequestTargetSchema: z.ZodDefault<z.ZodUnion<readonly [
|
|
|
11
11
|
resourceId: z.ZodPipe<z.ZodString, z.ZodTransform<ResourceId, string>>;
|
|
12
12
|
}, z.core.$strict>]>>;
|
|
13
13
|
export declare const pullRequestOutcomeSchema: z.ZodType<PullRequestActivityOutcome>;
|
|
14
|
-
interface CandidateAudit {
|
|
14
|
+
export interface CandidateAudit {
|
|
15
15
|
readonly resourceId: ResourceId;
|
|
16
16
|
readonly revision: string | null;
|
|
17
17
|
}
|
|
@@ -25,6 +25,12 @@ export const pullRequestOutcomeSchema = z.union([
|
|
|
25
25
|
data: z.object({ deliveryEventId: z.string() }).strict(),
|
|
26
26
|
})
|
|
27
27
|
.strict(),
|
|
28
|
+
z
|
|
29
|
+
.object({
|
|
30
|
+
kind: z.literal(ActivityOutcomeKind.Integrated),
|
|
31
|
+
data: z.object({ complete: z.literal(true) }).strict(),
|
|
32
|
+
})
|
|
33
|
+
.strict(),
|
|
28
34
|
z
|
|
29
35
|
.object({
|
|
30
36
|
kind: z.literal(ActivityOutcomeKind.Blocked),
|
|
@@ -46,6 +52,10 @@ export const pullRequestOutcomeSchema = z.union([
|
|
|
46
52
|
PullRequestDenialCode.TooManyFilesChanged,
|
|
47
53
|
PullRequestDenialCode.BlockedPathChanged,
|
|
48
54
|
PullRequestDenialCode.ChangedFilesUnavailable,
|
|
55
|
+
PullRequestDenialCode.OutsideDelivery,
|
|
56
|
+
PullRequestDenialCode.DeliveryNotReady,
|
|
57
|
+
PullRequestDenialCode.TargetHeld,
|
|
58
|
+
PullRequestDenialCode.MaintenanceRequired,
|
|
49
59
|
]),
|
|
50
60
|
})
|
|
51
61
|
.strict(),
|
|
@@ -4,6 +4,7 @@ import { ActivityEventType, selectActivityEvent, } from '../contracts/events.js'
|
|
|
4
4
|
import { ActivityResourceRole } from '../contracts/vocabulary.js';
|
|
5
5
|
import { isReviewAuthorized } from '../review/authorization.js';
|
|
6
6
|
import { isPullRequestLikeResource } from './capability.js';
|
|
7
|
+
import { sameCheckEvidence } from './check-evidence.js';
|
|
7
8
|
import { checksChanged, discovered, mergeAuthorized, mergeDenied, reviewAcceptanceSignalRecorded, reviewAccepted, reviewChangesRequested, reviewRejected, revisionChanged, stateChanged, } from './event-data.js';
|
|
8
9
|
import { decidePullRequestAuthority } from './policy.js';
|
|
9
10
|
import { acceptedReviewSignalProjection, pullRequestProjection } from './projection.js';
|
|
@@ -33,6 +34,10 @@ class JournalPullRequestService {
|
|
|
33
34
|
throw new Error('Pull request lacks verified primary correlation');
|
|
34
35
|
if ((await this.work.get(command.workItemId)) === null)
|
|
35
36
|
throw new Error('Pull request WorkItem missing');
|
|
37
|
+
if (command.checkEvidence !== undefined &&
|
|
38
|
+
(command.checkEvidence.headRevision !== command.headRevision ||
|
|
39
|
+
command.checkEvidence.baseRevision !== command.baseRevision))
|
|
40
|
+
throw new Error('Check evidence must match the observed head and base');
|
|
36
41
|
const current = await this.get(command.resourceId);
|
|
37
42
|
if (current === null) {
|
|
38
43
|
await this.append(command.resourceId, discovered(command, context));
|
|
@@ -64,10 +69,10 @@ class JournalPullRequestService {
|
|
|
64
69
|
: reviewRejected(command.resourceId, rejection, context));
|
|
65
70
|
}
|
|
66
71
|
async authorizeMerge(workItemId, context) {
|
|
67
|
-
const
|
|
72
|
+
const input = await this.authorityInput(workItemId);
|
|
73
|
+
const prior = await this.priorMergeDecision(context.commandId, input, workItemId);
|
|
68
74
|
if (prior !== null)
|
|
69
75
|
return prior;
|
|
70
|
-
const input = await this.authorityInput(workItemId);
|
|
71
76
|
const decision = decidePullRequestAuthority(input);
|
|
72
77
|
if (decision.allowed) {
|
|
73
78
|
const stream = resourceStream(decision.resourceId);
|
|
@@ -87,10 +92,12 @@ class JournalPullRequestService {
|
|
|
87
92
|
if (revisionHasChanged)
|
|
88
93
|
await this.append(command.resourceId, revisionChanged(command, context));
|
|
89
94
|
if (current.state !== command.state ||
|
|
95
|
+
current.mergeRevision !== command.mergeRevision ||
|
|
90
96
|
current.mergeability !== command.mergeability ||
|
|
91
97
|
(revisionHasChanged && command.mergeability !== undefined))
|
|
92
98
|
await this.append(command.resourceId, stateChanged(command, context));
|
|
93
|
-
if (current.checks !== command.checks
|
|
99
|
+
if (current.checks !== command.checks ||
|
|
100
|
+
!sameCheckEvidence(current.checkEvidence, command.checkEvidence))
|
|
94
101
|
await this.append(command.resourceId, checksChanged(command, context));
|
|
95
102
|
}
|
|
96
103
|
async append(resourceId, event) {
|
|
@@ -101,13 +108,27 @@ class JournalPullRequestService {
|
|
|
101
108
|
const events = Array.isArray(event) ? event : [event];
|
|
102
109
|
await this.journal.appendToStream(stream, (await this.journal.readStream(stream)).length, events);
|
|
103
110
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
// Decisions are appended to the Work item's PR-like resource stream, or the
|
|
112
|
+
// Work item stream when it has none, with an event id derived from the
|
|
113
|
+
// command, so a replay is found by reading just those streams.
|
|
114
|
+
async priorMergeDecision(commandId, input, workItemId) {
|
|
115
|
+
const streams = [
|
|
116
|
+
workItemStream(workItemId),
|
|
117
|
+
...input.resources
|
|
118
|
+
.filter((entry) => isPullRequestLikeResource(entry.resource.capabilities))
|
|
119
|
+
.map((entry) => resourceStream(entry.resource.resourceId)),
|
|
120
|
+
];
|
|
121
|
+
const authorized = `${commandId}:${ActivityEventType.PrMergeAuthorized}`;
|
|
122
|
+
const denied = `${commandId}:${ActivityEventType.PrMergeDenied}`;
|
|
123
|
+
let decision = null;
|
|
124
|
+
for (const stream of streams)
|
|
125
|
+
for (const event of await this.journal.readStream(stream)) {
|
|
126
|
+
if (event.event.eventId === authorized)
|
|
127
|
+
return true;
|
|
128
|
+
if (event.event.eventId === denied)
|
|
129
|
+
decision = false;
|
|
130
|
+
}
|
|
131
|
+
return decision;
|
|
111
132
|
}
|
|
112
133
|
async hasVerifiedPrimaryCorrelation(command) {
|
|
113
134
|
const resource = await this.resources.get(command.resourceId);
|
|
@@ -4,4 +4,5 @@ import { BuiltInActivityName } from '../contracts/vocabulary.js';
|
|
|
4
4
|
import type { PullRequestService } from './application.js';
|
|
5
5
|
import type { PullRequestActivityOutcome, PullRequestApproveInput } from './contracts.js';
|
|
6
6
|
import { type IntentAppender } from './intent.js';
|
|
7
|
-
|
|
7
|
+
import { type ParentActionAuthorizer } from './parent-scope.js';
|
|
8
|
+
export declare function createPullRequestApproveActivity(journal: EventJournal, pullRequests: PullRequestService, appender?: IntentAppender, parentActions?: ParentActionAuthorizer): ActivityDefinition<typeof BuiltInActivityName.PullRequestApprove, PullRequestApproveInput, PullRequestActivityOutcome>;
|
|
@@ -3,19 +3,35 @@ import { ActivityOutcomeKind } from '../contracts/vocabulary.js';
|
|
|
3
3
|
import { BuiltInResourceCapability, resourceStream } from '../../resources/index.js';
|
|
4
4
|
import { workItemStream } from '../../work/index.js';
|
|
5
5
|
import { ActivityEventType } from '../contracts/events.js';
|
|
6
|
-
import { ActivityExecutionKind, BuiltInActivityName } from '../contracts/vocabulary.js';
|
|
7
|
-
import { pullRequestOutcomeSchema, pullRequestTargetSchema,
|
|
6
|
+
import { ActivityExecutionKind, ActivityResourceRole, BuiltInActivityName, } from '../contracts/vocabulary.js';
|
|
7
|
+
import { pullRequestOutcomeSchema, pullRequestTargetSchema, selectedDenialAudit, selectionDenialAudit, } from './activity-support.js';
|
|
8
8
|
import { claimAndCompleteDecision, completeDecisionClaim, readDecisionClaim, } from './decision-claim.js';
|
|
9
9
|
import { approveDenied, deliveryIntentRequested } from './event-data.js';
|
|
10
10
|
import { activityCommandContext, createJournalIntentAppender, } from './intent.js';
|
|
11
|
+
import { ParentActionKind, parentDeliveryScopeSchema, } from './parent-scope.js';
|
|
12
|
+
import { resolveActionResource, resolveParentTarget } from './parent-target.js';
|
|
11
13
|
import { decidePullRequestAuthority } from './policy.js';
|
|
12
14
|
const inputSchema = z
|
|
13
|
-
.object({
|
|
15
|
+
.object({
|
|
16
|
+
target: pullRequestTargetSchema,
|
|
17
|
+
body: z.string().optional(),
|
|
18
|
+
scope: parentDeliveryScopeSchema.optional(),
|
|
19
|
+
})
|
|
14
20
|
.strict()
|
|
15
|
-
.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
.superRefine((input, context) => {
|
|
22
|
+
if (input.scope !== undefined && input.target !== ActivityResourceRole.Primary)
|
|
23
|
+
context.addIssue({
|
|
24
|
+
code: 'custom',
|
|
25
|
+
path: ['target'],
|
|
26
|
+
message: 'A delivery scope selects its own target; it cannot be combined with target',
|
|
27
|
+
});
|
|
28
|
+
})
|
|
29
|
+
.transform((input) => ({
|
|
30
|
+
target: input.target,
|
|
31
|
+
...(input.body === undefined ? {} : { body: input.body }),
|
|
32
|
+
...(input.scope === undefined ? {} : { scope: input.scope }),
|
|
33
|
+
}));
|
|
34
|
+
export function createPullRequestApproveActivity(journal, pullRequests, appender = createJournalIntentAppender(journal), parentActions) {
|
|
19
35
|
return {
|
|
20
36
|
name: BuiltInActivityName.PullRequestApprove,
|
|
21
37
|
inputSchema,
|
|
@@ -25,21 +41,26 @@ export function createPullRequestApproveActivity(journal, pullRequests, appender
|
|
|
25
41
|
ActivityOutcomeKind.Done,
|
|
26
42
|
ActivityOutcomeKind.Blocked,
|
|
27
43
|
ActivityOutcomeKind.Failed,
|
|
44
|
+
ActivityOutcomeKind.Integrated,
|
|
28
45
|
],
|
|
29
46
|
resources: [],
|
|
30
47
|
executionKind: ActivityExecutionKind.Deterministic,
|
|
31
48
|
handler: {
|
|
32
|
-
execute: (invocation, context) => executeApproval(journal, pullRequests, appender, invocation, context),
|
|
49
|
+
execute: (invocation, context) => executeApproval(journal, pullRequests, appender, parentActions, invocation, context),
|
|
33
50
|
},
|
|
34
51
|
};
|
|
35
52
|
}
|
|
36
|
-
async function executeApproval(journal, pullRequests, appender, invocation, context) {
|
|
53
|
+
async function executeApproval(journal, pullRequests, appender, parentActions, invocation, context) {
|
|
37
54
|
const command = activityCommandContext(invocation.activationId, invocation.orchestrationGroupId, context.occurredAt);
|
|
38
55
|
const prior = await readDecisionClaim(journal, invocation.activationId, 'approve');
|
|
39
56
|
if (prior !== null)
|
|
40
57
|
return completeDecisionClaim(journal, appender, prior);
|
|
41
|
-
const
|
|
42
|
-
|
|
58
|
+
const parentTarget = await resolveParentTarget(parentActions, invocation, invocation.input.scope !== undefined, ParentActionKind.Approve);
|
|
59
|
+
if (parentTarget.kind === 'fully-integrated')
|
|
60
|
+
return { kind: ActivityOutcomeKind.Integrated, data: { complete: true } };
|
|
61
|
+
const scoped = parentTarget.kind === 'target' ? parentTarget : undefined;
|
|
62
|
+
const authority = await pullRequests.authorityInput(scoped?.context.ownerWorkItemId ?? invocation.workItemId);
|
|
63
|
+
const resource = resolveActionResource(parentTarget, authority, invocation, invocation.input.target, BuiltInResourceCapability.Approvable);
|
|
43
64
|
if (!resource.allowed) {
|
|
44
65
|
const factStream = workItemStream(invocation.workItemId);
|
|
45
66
|
const denial = approveDenied(resource.reason, command, {
|
|
@@ -77,6 +98,7 @@ async function executeApproval(journal, pullRequests, appender, invocation, cont
|
|
|
77
98
|
resourceId: decision.resourceId,
|
|
78
99
|
revision: decision.revision,
|
|
79
100
|
body: invocation.input.body ?? null,
|
|
101
|
+
...(scoped === undefined ? {} : { parent: scoped.context }),
|
|
80
102
|
}, command);
|
|
81
103
|
return claimAndCompleteDecision(journal, appender, invocation.activationId, 'approve', {
|
|
82
104
|
decisionKind: 'requested',
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Provider execution evidence for one exact head/base combination. */
|
|
3
|
+
export declare const pullRequestCheckEvidenceSchema: z.ZodObject<{
|
|
4
|
+
testedRevision: z.ZodOptional<z.ZodString>;
|
|
5
|
+
headRevision: z.ZodString;
|
|
6
|
+
baseRevision: z.ZodString;
|
|
7
|
+
startedAt: z.ZodString;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
export type PullRequestCheckEvidence = z.infer<typeof pullRequestCheckEvidenceSchema>;
|
|
10
|
+
export declare function sameCheckEvidence(a: PullRequestCheckEvidence | undefined, b: PullRequestCheckEvidence | undefined): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Provider execution evidence for one exact head/base combination. */
|
|
3
|
+
export const pullRequestCheckEvidenceSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
testedRevision: z.string().min(1).optional(),
|
|
6
|
+
headRevision: z.string().min(1),
|
|
7
|
+
baseRevision: z.string().min(1),
|
|
8
|
+
startedAt: z.string().datetime({ offset: true }),
|
|
9
|
+
})
|
|
10
|
+
.strict();
|
|
11
|
+
export function sameCheckEvidence(a, b) {
|
|
12
|
+
return (a?.testedRevision === b?.testedRevision &&
|
|
13
|
+
a?.headRevision === b?.headRevision &&
|
|
14
|
+
a?.baseRevision === b?.baseRevision &&
|
|
15
|
+
a?.startedAt === b?.startedAt);
|
|
16
|
+
}
|
|
@@ -2,7 +2,9 @@ import type { ResourceCorrelationView, ResourceId, ResourceView } from '../../re
|
|
|
2
2
|
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
|
+
import type { PullRequestCheckEvidence } from './check-evidence.js';
|
|
5
6
|
import type { MergePolicyDetails } from './merge-policy-denial.js';
|
|
7
|
+
import type { ParentDeliveryScope } from './parent-scope.js';
|
|
6
8
|
import type { MergeMethod, PullRequestCheckState, PullRequestDenialCode, PullRequestMergeability, PullRequestState } from './vocabulary.js';
|
|
7
9
|
export interface PullRequestView {
|
|
8
10
|
readonly resourceId: ResourceId;
|
|
@@ -10,6 +12,8 @@ export interface PullRequestView {
|
|
|
10
12
|
readonly state: PullRequestState;
|
|
11
13
|
readonly headRevision: string;
|
|
12
14
|
readonly baseRevision: string;
|
|
15
|
+
readonly mergeRevision?: string | undefined;
|
|
16
|
+
readonly checkEvidence?: PullRequestCheckEvidence | undefined;
|
|
13
17
|
readonly checks: PullRequestCheckState;
|
|
14
18
|
readonly mergeability?: PullRequestMergeability | undefined;
|
|
15
19
|
readonly acceptedReview?: {
|
|
@@ -25,6 +29,8 @@ export interface ObservePullRequest {
|
|
|
25
29
|
readonly state: PullRequestView['state'];
|
|
26
30
|
readonly headRevision: string;
|
|
27
31
|
readonly baseRevision: string;
|
|
32
|
+
readonly mergeRevision?: string | undefined;
|
|
33
|
+
readonly checkEvidence?: PullRequestCheckEvidence | undefined;
|
|
28
34
|
readonly checks: PullRequestView['checks'];
|
|
29
35
|
readonly mergeability?: PullRequestMergeability | undefined;
|
|
30
36
|
readonly changedFiles?: readonly string[] | undefined;
|
|
@@ -68,8 +74,11 @@ export interface PullRequestTargetInput {
|
|
|
68
74
|
}
|
|
69
75
|
export interface PullRequestApproveInput extends PullRequestTargetInput {
|
|
70
76
|
readonly body?: string;
|
|
77
|
+
/** Acts on the parent delivery's next planned child-owned pull request instead of the WorkItem's own. */
|
|
78
|
+
readonly scope?: ParentDeliveryScope | undefined;
|
|
71
79
|
}
|
|
72
80
|
export interface PullRequestMergeInput extends PullRequestTargetInput {
|
|
81
|
+
readonly scope?: ParentDeliveryScope | undefined;
|
|
73
82
|
readonly method: MergeMethod;
|
|
74
83
|
readonly requireChecks: boolean;
|
|
75
84
|
readonly requireApproval?: boolean | undefined;
|
|
@@ -88,6 +97,11 @@ export type PullRequestActivityOutcome = {
|
|
|
88
97
|
readonly data: {
|
|
89
98
|
readonly deliveryEventId: string;
|
|
90
99
|
};
|
|
100
|
+
} | {
|
|
101
|
+
readonly kind: typeof ActivityOutcomeKind.Integrated;
|
|
102
|
+
readonly data: {
|
|
103
|
+
readonly complete: true;
|
|
104
|
+
};
|
|
91
105
|
} | {
|
|
92
106
|
readonly kind: typeof ActivityOutcomeKind.Blocked;
|
|
93
107
|
readonly data: {
|
|
@@ -16,12 +16,16 @@ export const stateChanged = (command, context) => fact({
|
|
|
16
16
|
...metadata(ActivityEventType.PrStateChanged, context),
|
|
17
17
|
payload: {
|
|
18
18
|
state: command.state,
|
|
19
|
+
...(command.mergeRevision === undefined ? {} : { mergeRevision: command.mergeRevision }),
|
|
19
20
|
...(command.mergeability === undefined ? {} : { mergeability: command.mergeability }),
|
|
20
21
|
},
|
|
21
22
|
});
|
|
22
23
|
export const checksChanged = (command, context) => fact({
|
|
23
24
|
...metadata(ActivityEventType.PrChecksChanged, context),
|
|
24
|
-
payload: {
|
|
25
|
+
payload: {
|
|
26
|
+
checks: command.checks,
|
|
27
|
+
...(command.checkEvidence === undefined ? {} : { checkEvidence: command.checkEvidence }),
|
|
28
|
+
},
|
|
25
29
|
});
|
|
26
30
|
export const reviewAccepted = (command, context) => fact({
|
|
27
31
|
...metadata(ActivityEventType.PrReviewAccepted, context),
|
|
@@ -5,5 +5,6 @@ import { BuiltInActivityName } from '../contracts/vocabulary.js';
|
|
|
5
5
|
import type { PullRequestService } from './application.js';
|
|
6
6
|
import type { PullRequestActivityOutcome, PullRequestMergeInput } from './contracts.js';
|
|
7
7
|
import { type IntentAppender } from './intent.js';
|
|
8
|
+
import { type ParentActionAuthorizer } from './parent-scope.js';
|
|
8
9
|
export declare const pullRequestMergeInputSchema: z.ZodType<PullRequestMergeInput>;
|
|
9
|
-
export declare function createPullRequestMergeActivity(journal: EventJournal, pullRequests: PullRequestService, appender?: IntentAppender): ActivityDefinition<typeof BuiltInActivityName.PullRequestMerge, PullRequestMergeInput, PullRequestActivityOutcome>;
|
|
10
|
+
export declare function createPullRequestMergeActivity(journal: EventJournal, pullRequests: PullRequestService, appender?: IntentAppender, parentActions?: ParentActionAuthorizer): ActivityDefinition<typeof BuiltInActivityName.PullRequestMerge, PullRequestMergeInput, PullRequestActivityOutcome>;
|
|
@@ -2,18 +2,21 @@ import { z } from 'zod';
|
|
|
2
2
|
import { ActivityOutcomeKind } from '../contracts/vocabulary.js';
|
|
3
3
|
import { readMergePolicyDenial } from './merge-policy-denial.js';
|
|
4
4
|
import { MergeMethod } from './vocabulary.js';
|
|
5
|
-
import { BuiltInResourceCapability, resourceStream } from '../../resources/index.js';
|
|
5
|
+
import { BuiltInResourceCapability, resourceStream, } from '../../resources/index.js';
|
|
6
6
|
import { workItemStream } from '../../work/index.js';
|
|
7
7
|
import { ActivityEventType } from '../contracts/events.js';
|
|
8
|
-
import { ActivityExecutionKind, BuiltInActivityName } from '../contracts/vocabulary.js';
|
|
9
|
-
import { pullRequestOutcomeSchema, pullRequestTargetSchema,
|
|
8
|
+
import { ActivityExecutionKind, ActivityResourceRole, BuiltInActivityName, } from '../contracts/vocabulary.js';
|
|
9
|
+
import { pullRequestOutcomeSchema, pullRequestTargetSchema, selectedDenialAudit, selectionDenialAudit, } from './activity-support.js';
|
|
10
10
|
import { claimAndCompleteDecision, completeDecisionClaim, readDecisionClaim, } from './decision-claim.js';
|
|
11
11
|
import { deliveryIntentRequested, mergeDenied } from './event-data.js';
|
|
12
12
|
import { activityCommandContext, createJournalIntentAppender, } from './intent.js';
|
|
13
|
+
import { ParentActionKind, parentDeliveryScopeSchema, } from './parent-scope.js';
|
|
14
|
+
import { resolveActionResource, resolveParentTarget } from './parent-target.js';
|
|
13
15
|
import { decidePullRequestAuthority } from './policy.js';
|
|
14
16
|
export const pullRequestMergeInputSchema = z
|
|
15
17
|
.object({
|
|
16
18
|
target: pullRequestTargetSchema,
|
|
19
|
+
scope: parentDeliveryScopeSchema.optional(),
|
|
17
20
|
method: z.enum([MergeMethod.Merge, MergeMethod.Squash, MergeMethod.Rebase]),
|
|
18
21
|
requireChecks: z.boolean(),
|
|
19
22
|
requireApproval: z.boolean().default(true),
|
|
@@ -29,8 +32,14 @@ export const pullRequestMergeInputSchema = z
|
|
|
29
32
|
path: ['requireApproval'],
|
|
30
33
|
message: 'requireApproval may be false only when autoMerge is true',
|
|
31
34
|
});
|
|
35
|
+
if (input.scope !== undefined && input.target !== ActivityResourceRole.Primary)
|
|
36
|
+
context.addIssue({
|
|
37
|
+
code: 'custom',
|
|
38
|
+
path: ['target'],
|
|
39
|
+
message: 'A delivery scope selects its own target; it cannot be combined with target',
|
|
40
|
+
});
|
|
32
41
|
});
|
|
33
|
-
export function createPullRequestMergeActivity(journal, pullRequests, appender = createJournalIntentAppender(journal)) {
|
|
42
|
+
export function createPullRequestMergeActivity(journal, pullRequests, appender = createJournalIntentAppender(journal), parentActions) {
|
|
34
43
|
return {
|
|
35
44
|
name: BuiltInActivityName.PullRequestMerge,
|
|
36
45
|
inputSchema: pullRequestMergeInputSchema,
|
|
@@ -40,23 +49,57 @@ export function createPullRequestMergeActivity(journal, pullRequests, appender =
|
|
|
40
49
|
ActivityOutcomeKind.Done,
|
|
41
50
|
ActivityOutcomeKind.Blocked,
|
|
42
51
|
ActivityOutcomeKind.Failed,
|
|
52
|
+
ActivityOutcomeKind.Integrated,
|
|
43
53
|
],
|
|
44
54
|
resources: [],
|
|
45
55
|
executionKind: ActivityExecutionKind.Deterministic,
|
|
46
56
|
handler: {
|
|
47
|
-
execute: (invocation, context) => executeMerge(journal, pullRequests, appender, invocation, context),
|
|
57
|
+
execute: (invocation, context) => executeMerge(journal, pullRequests, appender, parentActions, invocation, context),
|
|
48
58
|
},
|
|
49
59
|
};
|
|
50
60
|
}
|
|
51
|
-
async function
|
|
61
|
+
async function denyByAuthority({ journal, appender }, invocation, authority, resourceId, decision, command) {
|
|
62
|
+
const audit = selectedDenialAudit(authority, resourceId);
|
|
63
|
+
const policyDenial = readMergePolicyDenial({
|
|
64
|
+
kind: ActivityOutcomeKind.Blocked,
|
|
65
|
+
data: { reason: decision.reason },
|
|
66
|
+
});
|
|
67
|
+
const denial = mergeDenied(decision.reason, command, {
|
|
68
|
+
...audit,
|
|
69
|
+
method: invocation.input.method,
|
|
70
|
+
});
|
|
71
|
+
return claimAndCompleteDecision(journal, appender, invocation.activationId, MergeMethod.Merge, {
|
|
72
|
+
decisionKind: 'denied',
|
|
73
|
+
outcome: {
|
|
74
|
+
kind: ActivityOutcomeKind.Blocked,
|
|
75
|
+
data: {
|
|
76
|
+
reason: decision.reason,
|
|
77
|
+
...(policyDenial === null
|
|
78
|
+
? {}
|
|
79
|
+
: {
|
|
80
|
+
resourceId,
|
|
81
|
+
...(audit.revision === null ? {} : { revision: audit.revision }),
|
|
82
|
+
}),
|
|
83
|
+
...(decision.policy === undefined ? {} : { policy: decision.policy }),
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
fact: denial,
|
|
87
|
+
factStream: resourceStream(resourceId),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
async function executeMerge(journal, pullRequests, appender, parentActions, invocation, context) {
|
|
52
91
|
const requireApproval = invocation.input.requireApproval ?? true;
|
|
53
92
|
const autoMerge = invocation.input.autoMerge ?? false;
|
|
54
93
|
const command = activityCommandContext(invocation.activationId, invocation.orchestrationGroupId, context.occurredAt);
|
|
55
94
|
const prior = await readDecisionClaim(journal, invocation.activationId, MergeMethod.Merge);
|
|
56
95
|
if (prior !== null)
|
|
57
96
|
return completeDecisionClaim(journal, appender, prior);
|
|
58
|
-
const
|
|
59
|
-
|
|
97
|
+
const parentTarget = await resolveParentTarget(parentActions, invocation, invocation.input.scope !== undefined, ParentActionKind.Merge);
|
|
98
|
+
if (parentTarget.kind === 'fully-integrated')
|
|
99
|
+
return { kind: ActivityOutcomeKind.Integrated, data: { complete: true } };
|
|
100
|
+
const scoped = parentTarget.kind === 'target' ? parentTarget : undefined;
|
|
101
|
+
const authority = await pullRequests.authorityInput(scoped?.context.ownerWorkItemId ?? invocation.workItemId);
|
|
102
|
+
const resource = resolveActionResource(parentTarget, authority, invocation, invocation.input.target, BuiltInResourceCapability.Mergeable);
|
|
60
103
|
if (!resource.allowed) {
|
|
61
104
|
const factStream = workItemStream(invocation.workItemId);
|
|
62
105
|
const denial = mergeDenied(resource.reason, command, {
|
|
@@ -82,36 +125,8 @@ async function executeMerge(journal, pullRequests, appender, invocation, context
|
|
|
82
125
|
blockedPaths: invocation.input.blockedPaths,
|
|
83
126
|
},
|
|
84
127
|
});
|
|
85
|
-
if (!decision.allowed)
|
|
86
|
-
|
|
87
|
-
const audit = selectedDenialAudit(authority, resource.resourceId);
|
|
88
|
-
const policyDenial = readMergePolicyDenial({
|
|
89
|
-
kind: ActivityOutcomeKind.Blocked,
|
|
90
|
-
data: { reason: decision.reason },
|
|
91
|
-
});
|
|
92
|
-
const denial = mergeDenied(decision.reason, command, {
|
|
93
|
-
...selectedDenialAudit(authority, resource.resourceId),
|
|
94
|
-
method: invocation.input.method,
|
|
95
|
-
});
|
|
96
|
-
return claimAndCompleteDecision(journal, appender, invocation.activationId, MergeMethod.Merge, {
|
|
97
|
-
decisionKind: 'denied',
|
|
98
|
-
outcome: {
|
|
99
|
-
kind: ActivityOutcomeKind.Blocked,
|
|
100
|
-
data: {
|
|
101
|
-
reason: decision.reason,
|
|
102
|
-
...(policyDenial === null
|
|
103
|
-
? {}
|
|
104
|
-
: {
|
|
105
|
-
resourceId: resource.resourceId,
|
|
106
|
-
...(audit.revision === null ? {} : { revision: audit.revision }),
|
|
107
|
-
}),
|
|
108
|
-
...(decision.policy === undefined ? {} : { policy: decision.policy }),
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
fact: denial,
|
|
112
|
-
factStream,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
128
|
+
if (!decision.allowed)
|
|
129
|
+
return denyByAuthority({ journal, appender }, invocation, authority, resource.resourceId, decision, command);
|
|
115
130
|
const intent = deliveryIntentRequested(decision.resourceId, ActivityEventType.PrMergeRequested, {
|
|
116
131
|
activationId: invocation.activationId,
|
|
117
132
|
workflowInstanceId: invocation.workflowInstanceId,
|
|
@@ -120,6 +135,7 @@ async function executeMerge(journal, pullRequests, appender, invocation, context
|
|
|
120
135
|
method: invocation.input.method,
|
|
121
136
|
requireChecks: invocation.input.requireChecks,
|
|
122
137
|
autoMerge,
|
|
138
|
+
...(scoped === undefined ? {} : { parent: scoped.context }),
|
|
123
139
|
}, command);
|
|
124
140
|
return claimAndCompleteDecision(journal, appender, invocation.activationId, MergeMethod.Merge, {
|
|
125
141
|
decisionKind: 'requested',
|