@atolis-hq/wake 0.4.120 → 0.4.121
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.
|
@@ -23,7 +23,10 @@ export const pullRequestOutcomeSchema = z.union([
|
|
|
23
23
|
z
|
|
24
24
|
.object({
|
|
25
25
|
kind: z.literal(ActivityOutcomeKind.Done),
|
|
26
|
-
data: z.
|
|
26
|
+
data: z.union([
|
|
27
|
+
z.object({ deliveryEventId: z.string() }).strict(),
|
|
28
|
+
z.object({ resourceId: z.string(), revision: z.string() }).strict(),
|
|
29
|
+
]),
|
|
27
30
|
})
|
|
28
31
|
.strict(),
|
|
29
32
|
z
|
|
@@ -97,6 +97,9 @@ export type PullRequestActivityOutcome = {
|
|
|
97
97
|
readonly kind: typeof ActivityOutcomeKind.Done;
|
|
98
98
|
readonly data: {
|
|
99
99
|
readonly deliveryEventId: string;
|
|
100
|
+
} | {
|
|
101
|
+
readonly resourceId: string;
|
|
102
|
+
readonly revision: string;
|
|
100
103
|
};
|
|
101
104
|
} | {
|
|
102
105
|
readonly kind: typeof ActivityOutcomeKind.Integrated;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ActivityOutcomeKind } from '../contracts/vocabulary.js';
|
|
3
3
|
import { readMergePolicyDenial } from './merge-policy-denial.js';
|
|
4
|
-
import { MergeMethod, PullRequestDenialCode } from './vocabulary.js';
|
|
4
|
+
import { MergeMethod, PullRequestDenialCode, PullRequestState } from './vocabulary.js';
|
|
5
5
|
import { BuiltInResourceCapability, resourceStream, } from '../../resources/index.js';
|
|
6
6
|
import { workItemStream } from '../../work/index.js';
|
|
7
7
|
import { ActivityEventType } from '../contracts/events.js';
|
|
@@ -91,6 +91,23 @@ async function denyByAuthority({ journal, appender }, invocation, authority, res
|
|
|
91
91
|
factStream: resourceStream(resourceId),
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
|
+
function mergePolicyOf(input) {
|
|
95
|
+
return {
|
|
96
|
+
...(input.maxFilesChanged === undefined ? {} : { maxFilesChanged: input.maxFilesChanged }),
|
|
97
|
+
blockedPaths: input.blockedPaths,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function mergedOutcome(authority, resourceId) {
|
|
101
|
+
const merged = authority.pullRequests.find((view) => view.resourceId === resourceId &&
|
|
102
|
+
view.workItemId === authority.work?.workItemId &&
|
|
103
|
+
view.state === PullRequestState.Merged);
|
|
104
|
+
return merged === undefined
|
|
105
|
+
? null
|
|
106
|
+
: {
|
|
107
|
+
kind: ActivityOutcomeKind.Done,
|
|
108
|
+
data: { resourceId: merged.resourceId, revision: merged.headRevision },
|
|
109
|
+
};
|
|
110
|
+
}
|
|
94
111
|
async function executeMerge(journal, pullRequests, appender, parentActions, invocation, context) {
|
|
95
112
|
const requireApproval = invocation.input.requireApproval ?? true;
|
|
96
113
|
const autoMerge = invocation.input.autoMerge ?? false;
|
|
@@ -117,17 +134,17 @@ async function executeMerge(journal, pullRequests, appender, parentActions, invo
|
|
|
117
134
|
factStream,
|
|
118
135
|
});
|
|
119
136
|
}
|
|
137
|
+
// A merge that landed outside Wake (e.g. GitHub auto-merge) leaves nothing to
|
|
138
|
+
// deliver, so the review/check/file gates that guard Wake's own merge do not apply.
|
|
139
|
+
const alreadyMerged = mergedOutcome(authority, resource.resourceId);
|
|
140
|
+
if (alreadyMerged !== null)
|
|
141
|
+
return alreadyMerged;
|
|
120
142
|
const decision = decidePullRequestAuthority(authority, {
|
|
121
143
|
target: { resourceId: resource.resourceId },
|
|
122
144
|
requireAcceptedReview: requireApproval,
|
|
123
145
|
requireChecks: invocation.input.requireChecks,
|
|
124
146
|
allowPendingChecks: autoMerge,
|
|
125
|
-
mergePolicy:
|
|
126
|
-
...(invocation.input.maxFilesChanged === undefined
|
|
127
|
-
? {}
|
|
128
|
-
: { maxFilesChanged: invocation.input.maxFilesChanged }),
|
|
129
|
-
blockedPaths: invocation.input.blockedPaths,
|
|
130
|
-
},
|
|
147
|
+
mergePolicy: mergePolicyOf(invocation.input),
|
|
131
148
|
});
|
|
132
149
|
if (!decision.allowed)
|
|
133
150
|
return denyByAuthority({ journal, appender }, invocation, authority, resource.resourceId, decision, command);
|
|
@@ -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.121";
|
|
128
128
|
/** The registry-installable version used by packaged sandbox images. */
|
|
129
129
|
export const wakePackageVersion = packageVersion(defaultRepoRoot) ?? wakeVersion;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ActivityOutcomeKind } from '../../../activities/index.js';
|
|
2
|
+
import { isApprovalAwaitingSignalKind, WorkflowStatus, } from '../../../orchestration/index.js';
|
|
2
3
|
import { WorkStatus } from '../../../work/index.js';
|
|
3
4
|
import { GitHubWakeStatusLabel, isGitHubWakeMarker, } from '../contracts/vocabulary.js';
|
|
4
5
|
export function reconcileGitHubWakeLabels(current, desired) {
|
|
@@ -82,18 +83,18 @@ function defaultOnError(failure, error) {
|
|
|
82
83
|
}
|
|
83
84
|
function desiredWakeLabels(workflow, watching) {
|
|
84
85
|
return [
|
|
85
|
-
`wake:status.${statusLabel(workflow
|
|
86
|
+
`wake:status.${statusLabel(workflow)}`,
|
|
86
87
|
`wake:stage.${workflow.currentStage}`,
|
|
87
88
|
`wake:workflow.${workflow.workflowName}`,
|
|
88
89
|
...(watching ? ['wake:watching'] : []),
|
|
89
90
|
];
|
|
90
91
|
}
|
|
91
|
-
function statusLabel(
|
|
92
|
-
switch (status) {
|
|
92
|
+
function statusLabel(workflow) {
|
|
93
|
+
switch (workflow.status) {
|
|
93
94
|
case WorkflowStatus.Active:
|
|
94
95
|
return GitHubWakeStatusLabel.Working;
|
|
95
96
|
case WorkflowStatus.Waiting:
|
|
96
|
-
return
|
|
97
|
+
return waitStatusLabel(workflow.waitingFor);
|
|
97
98
|
case WorkflowStatus.Blocked:
|
|
98
99
|
return GitHubWakeStatusLabel.Blocked;
|
|
99
100
|
case WorkflowStatus.Completed:
|
|
@@ -102,6 +103,19 @@ function statusLabel(status) {
|
|
|
102
103
|
return GitHubWakeStatusLabel.Failed;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
106
|
+
// Only approval-style waits are "awaiting approval"; other waits (delivery
|
|
107
|
+
// results, resource transitions) are Wake-side progress.
|
|
108
|
+
function waitStatusLabel(wait) {
|
|
109
|
+
if (wait === undefined)
|
|
110
|
+
return GitHubWakeStatusLabel.Working;
|
|
111
|
+
if (isApprovalAwaitingSignalKind(wait.signalKind))
|
|
112
|
+
return GitHubWakeStatusLabel.AwaitingApproval;
|
|
113
|
+
if (wait.signalKind === ActivityOutcomeKind.Blocked)
|
|
114
|
+
return GitHubWakeStatusLabel.Blocked;
|
|
115
|
+
if (wait.signalKind === ActivityOutcomeKind.Failed)
|
|
116
|
+
return GitHubWakeStatusLabel.Failed;
|
|
117
|
+
return GitHubWakeStatusLabel.Working;
|
|
118
|
+
}
|
|
105
119
|
function parseGitHubIssueKey(key) {
|
|
106
120
|
const match = /^(?<owner>[^/]+)\/(?<repo>[^#]+)#(?<number>[1-9]\d*)$/.exec(key);
|
|
107
121
|
if (match?.groups === undefined)
|