@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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export 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.';
|
|
2
|
+
export const MergeStageApprovalGuidance = 'An authorized independent reviewer can reply with /approved to continue. Approval of your own work is not permitted.';
|
|
1
3
|
export function projectTerminalAgentRunReport(input) {
|
|
2
4
|
if (input.run.finishedAt === undefined)
|
|
3
5
|
return null;
|
|
@@ -14,6 +16,8 @@ export function projectTerminalAgentRunReport(input) {
|
|
|
14
16
|
...(input.run.workspace === undefined ? {} : { workspacePath: input.run.workspace.path }),
|
|
15
17
|
metadata: agent?.metadata ?? {},
|
|
16
18
|
...(input.awaitingApproval === true ? { awaitingApproval: true } : {}),
|
|
19
|
+
...(input.awaitingMerge === true ? { awaitingMerge: true } : {}),
|
|
20
|
+
...(input.mergeStageApproval === true ? { mergeStageApproval: true } : {}),
|
|
17
21
|
...(input.watchGateVerdict === undefined ? {} : { watchGateVerdict: input.watchGateVerdict }),
|
|
18
22
|
};
|
|
19
23
|
}
|
|
@@ -30,6 +30,8 @@ export interface AgentRunPublicationReport {
|
|
|
30
30
|
readonly workspacePath?: string | undefined;
|
|
31
31
|
readonly metadata: Readonly<Record<string, string | number | boolean | null>>;
|
|
32
32
|
readonly awaitingApproval?: boolean | undefined;
|
|
33
|
+
readonly awaitingMerge?: boolean | undefined;
|
|
34
|
+
readonly mergeStageApproval?: boolean | undefined;
|
|
33
35
|
readonly watchGateVerdict?: {
|
|
34
36
|
readonly runId: string;
|
|
35
37
|
} | undefined;
|
|
@@ -35,6 +35,8 @@ const reportSchema = z
|
|
|
35
35
|
workspacePath: z.string().min(1).optional(),
|
|
36
36
|
metadata: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])),
|
|
37
37
|
awaitingApproval: z.boolean().optional(),
|
|
38
|
+
awaitingMerge: z.boolean().optional(),
|
|
39
|
+
mergeStageApproval: z.boolean().optional(),
|
|
38
40
|
watchGateVerdict: z
|
|
39
41
|
.object({ runId: z.string().min(1) })
|
|
40
42
|
.strict()
|
|
@@ -14,6 +14,8 @@ export interface AgentRunComment {
|
|
|
14
14
|
readonly sessionId?: string | undefined;
|
|
15
15
|
readonly workspacePath?: string | undefined;
|
|
16
16
|
readonly awaitingApproval?: boolean | undefined;
|
|
17
|
+
readonly awaitingMerge?: boolean | undefined;
|
|
18
|
+
readonly mergeStageApproval?: boolean | undefined;
|
|
17
19
|
readonly watchGateVerdict?: {
|
|
18
20
|
readonly runId: string;
|
|
19
21
|
} | undefined;
|
|
@@ -1,19 +1,31 @@
|
|
|
1
|
+
import { MergeStageApprovalGuidance, MergeWaitGuidance, } from '../../application/terminal-agent-run-report.js';
|
|
2
|
+
/** Names only the commands the current wait accepts. */
|
|
3
|
+
function waitHintFor(value) {
|
|
4
|
+
if (value.awaitingMerge === true)
|
|
5
|
+
return `_${MergeWaitGuidance}_`;
|
|
6
|
+
if (value.awaitingApproval !== true)
|
|
7
|
+
return undefined;
|
|
8
|
+
if (value.mergeStageApproval === true)
|
|
9
|
+
return `_${MergeStageApprovalGuidance}_`;
|
|
10
|
+
return '_An authorized independent reviewer can reply with /approved or /changes followed by feedback. Approval of your own work is not permitted. To ask a question, reply with /ask followed by your question._';
|
|
11
|
+
}
|
|
1
12
|
export function formatAgentRunComment(value) {
|
|
2
13
|
const details = detailsLine(value);
|
|
3
14
|
const sections = [
|
|
4
15
|
'<!-- wake:agent -->',
|
|
5
16
|
`<!-- wake:delivery:${value.idempotencyKey} -->`,
|
|
6
17
|
`**${wakeHeading(value.publicUiUrl)}** _(Wake${details ? ` - ${details}` : ''})_`,
|
|
7
|
-
`**Outcome:** ${
|
|
18
|
+
`**Outcome:** ${commentOutcome(value)}`,
|
|
8
19
|
value.displayBody.trim() || fallback(value.outcome),
|
|
9
20
|
];
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
21
|
+
const waitHint = waitHintFor(value);
|
|
22
|
+
if (waitHint !== undefined)
|
|
23
|
+
sections.push(waitHint);
|
|
24
|
+
if (hasContinuationHint(value))
|
|
13
25
|
sections.push(value.outcome === 'NEEDS_CLARIFICATION'
|
|
14
26
|
? '_Reply with the requested clarification. A maintainer with repository write, maintain, or admin permission can also use /changes followed by instructions to continue eligible blocked work._'
|
|
15
27
|
: '_A maintainer with repository write, maintain, or admin permission can continue eligible blocked work with /changes followed by instructions, including on an issue they authored. The authenticated UI also offers Continue with instructions. /retry is for eligible failed stages._');
|
|
16
|
-
if (value.outcome === 'FAILED')
|
|
28
|
+
if (value.outcome === 'FAILED' && value.awaitingMerge !== true)
|
|
17
29
|
sections.push('_An authorized maintainer can use /retry for an eligible failed stage, or /restart for a fresh session. These commands do not continue a blocked outcome._');
|
|
18
30
|
const session = sessionSection(value);
|
|
19
31
|
if (session !== undefined)
|
|
@@ -95,3 +107,12 @@ function cost(metadata) {
|
|
|
95
107
|
function formatDuration(value) {
|
|
96
108
|
return `${Math.max(0, Math.round(value / 1000))}s`;
|
|
97
109
|
}
|
|
110
|
+
function commentOutcome(value) {
|
|
111
|
+
if (value.awaitingMerge === true)
|
|
112
|
+
return '⏳ Awaiting merge';
|
|
113
|
+
return value.awaitingApproval === true ? '⏳ Awaiting approval' : outcome(value.outcome);
|
|
114
|
+
}
|
|
115
|
+
function hasContinuationHint(value) {
|
|
116
|
+
return (value.awaitingMerge !== true &&
|
|
117
|
+
(value.outcome === 'BLOCKED' || value.outcome === 'NEEDS_CLARIFICATION'));
|
|
118
|
+
}
|
|
@@ -3,6 +3,7 @@ export function observePullRequest(resourceId, workItemId, payload) {
|
|
|
3
3
|
resourceId,
|
|
4
4
|
workItemId,
|
|
5
5
|
state: payload.state,
|
|
6
|
+
...(payload.mergeability === undefined ? {} : { mergeability: payload.mergeability }),
|
|
6
7
|
headRevision: payload.headRevision ?? payload.revision,
|
|
7
8
|
baseRevision: payload.baseRevision ?? 'unknown',
|
|
8
9
|
checks: payload.checks ?? 'unknown',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type EventDataUnion, type EventEnvelope, type EventUnion } from '@atolis-hq/eventing';
|
|
2
|
-
import { ProviderPermission, PullRequestCheckState, PullRequestState, ReviewActorKind, ReviewerAuthorizationSource, type ReviewerAuthorizationEvidence } from '../../../activities/index.js';
|
|
2
|
+
import { ProviderPermission, PullRequestCheckState, PullRequestMergeability, PullRequestState, ReviewActorKind, ReviewerAuthorizationSource, type ReviewerAuthorizationEvidence } from '../../../activities/index.js';
|
|
3
3
|
import { type ResourceId } from '../../../resources/index.js';
|
|
4
4
|
import { type WorkItemId } from '../../../work/index.js';
|
|
5
5
|
import { ExternalWorkOutcome } from '../../contracts/outcome-vocabulary.js';
|
|
@@ -17,6 +17,7 @@ export declare const GitHubEventType: {
|
|
|
17
17
|
readonly ConversationRecordRecovered: "integration.github.conversation-record-recovered";
|
|
18
18
|
};
|
|
19
19
|
export interface ExternalWorkObservedPayload {
|
|
20
|
+
readonly mergeability?: PullRequestMergeability | undefined;
|
|
20
21
|
readonly externalKey: string;
|
|
21
22
|
readonly kind: 'issue' | 'pull-request';
|
|
22
23
|
readonly title: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { eventDataSchema, eventEnvelopeSchema, } from '@atolis-hq/eventing';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { ProviderPermission, PullRequestCheckState, PullRequestState, ReviewActorKind, ReviewerAuthorizationSource, } from '../../../activities/index.js';
|
|
3
|
+
import { ProviderPermission, PullRequestCheckState, PullRequestMergeability, PullRequestState, ReviewActorKind, ReviewerAuthorizationSource, } from '../../../activities/index.js';
|
|
4
4
|
import { brandedStringSchema } from '../../../kernel/index.js';
|
|
5
5
|
import { resourceId } from '../../../resources/index.js';
|
|
6
6
|
import { workItemId } from '../../../work/index.js';
|
|
@@ -63,6 +63,13 @@ const githubEventSchemas = {
|
|
|
63
63
|
state: z.enum([PullRequestState.Open, PullRequestState.Closed, PullRequestState.Merged]),
|
|
64
64
|
outcome: z.enum([ExternalWorkOutcome.Completed, ExternalWorkOutcome.Cancelled]).optional(),
|
|
65
65
|
revision: z.string(),
|
|
66
|
+
mergeability: z
|
|
67
|
+
.enum([
|
|
68
|
+
PullRequestMergeability.Unknown,
|
|
69
|
+
PullRequestMergeability.Mergeable,
|
|
70
|
+
PullRequestMergeability.Conflicting,
|
|
71
|
+
])
|
|
72
|
+
.optional(),
|
|
66
73
|
headRevision: z.string().optional(),
|
|
67
74
|
baseRevision: z.string().optional(),
|
|
68
75
|
checks: z
|
|
@@ -34,6 +34,7 @@ export interface GitHubIssueCommentPayload {
|
|
|
34
34
|
readonly side?: 'LEFT' | 'RIGHT';
|
|
35
35
|
}
|
|
36
36
|
export interface GitHubPullRequestPayload extends GitHubIssuePayload {
|
|
37
|
+
readonly mergeable?: boolean | null;
|
|
37
38
|
readonly pull_request?: Record<string, unknown>;
|
|
38
39
|
readonly head?: {
|
|
39
40
|
readonly sha?: string;
|
|
@@ -22,17 +22,17 @@ export declare function listPullRequests(octokit: Octokit, cache: ReturnType<typ
|
|
|
22
22
|
comments_url: string;
|
|
23
23
|
statuses_url: string;
|
|
24
24
|
number: number;
|
|
25
|
-
state:
|
|
25
|
+
state: "open" | "closed";
|
|
26
26
|
locked: boolean;
|
|
27
27
|
title: string;
|
|
28
|
-
user: import("@octokit/openapi-types").components["schemas"]["
|
|
28
|
+
user: import("@octokit/openapi-types").components["schemas"]["simple-user"];
|
|
29
29
|
body: string | null;
|
|
30
30
|
labels: {
|
|
31
31
|
id: number;
|
|
32
32
|
node_id: string;
|
|
33
33
|
url: string;
|
|
34
34
|
name: string;
|
|
35
|
-
description: string;
|
|
35
|
+
description: string | null;
|
|
36
36
|
color: string;
|
|
37
37
|
default: boolean;
|
|
38
38
|
}[];
|
|
@@ -46,20 +46,20 @@ export declare function listPullRequests(octokit: Octokit, cache: ReturnType<typ
|
|
|
46
46
|
assignee: import("@octokit/openapi-types").components["schemas"]["nullable-simple-user"];
|
|
47
47
|
assignees?: import("@octokit/openapi-types").components["schemas"]["simple-user"][] | null;
|
|
48
48
|
requested_reviewers?: import("@octokit/openapi-types").components["schemas"]["simple-user"][] | null;
|
|
49
|
-
requested_teams?: import("@octokit/openapi-types").components["schemas"]["team"][] | null;
|
|
49
|
+
requested_teams?: import("@octokit/openapi-types").components["schemas"]["team-simple"][] | null;
|
|
50
50
|
head: {
|
|
51
51
|
label: string;
|
|
52
52
|
ref: string;
|
|
53
53
|
repo: import("@octokit/openapi-types").components["schemas"]["repository"];
|
|
54
54
|
sha: string;
|
|
55
|
-
user: import("@octokit/openapi-types").components["schemas"]["
|
|
55
|
+
user: import("@octokit/openapi-types").components["schemas"]["simple-user"];
|
|
56
56
|
};
|
|
57
57
|
base: {
|
|
58
58
|
label: string;
|
|
59
59
|
ref: string;
|
|
60
60
|
repo: import("@octokit/openapi-types").components["schemas"]["repository"];
|
|
61
61
|
sha: string;
|
|
62
|
-
user: import("@octokit/openapi-types").components["schemas"]["
|
|
62
|
+
user: import("@octokit/openapi-types").components["schemas"]["simple-user"];
|
|
63
63
|
};
|
|
64
64
|
_links: {
|
|
65
65
|
comments: import("@octokit/openapi-types").components["schemas"]["link"];
|
|
@@ -74,6 +74,18 @@ export declare function listPullRequests(octokit: Octokit, cache: ReturnType<typ
|
|
|
74
74
|
author_association: import("@octokit/openapi-types").components["schemas"]["author-association"];
|
|
75
75
|
auto_merge: import("@octokit/openapi-types").components["schemas"]["auto-merge"];
|
|
76
76
|
draft?: boolean;
|
|
77
|
+
merged: boolean;
|
|
78
|
+
mergeable: boolean | null;
|
|
79
|
+
rebaseable?: boolean | null;
|
|
80
|
+
mergeable_state: string;
|
|
81
|
+
merged_by: import("@octokit/openapi-types").components["schemas"]["nullable-simple-user"];
|
|
82
|
+
comments: number;
|
|
83
|
+
review_comments: number;
|
|
84
|
+
maintainer_can_modify: boolean;
|
|
85
|
+
commits: number;
|
|
86
|
+
additions: number;
|
|
87
|
+
deletions: number;
|
|
88
|
+
changed_files: number;
|
|
77
89
|
}, "state"> & {
|
|
78
90
|
readonly state: typeof PullRequestState.Open | typeof PullRequestState.Closed;
|
|
79
91
|
})[]>;
|
|
@@ -67,7 +67,12 @@ export async function listPullRequests(octokit, cache, owner, repo, maxResults)
|
|
|
67
67
|
...(headers === undefined ? {} : { headers }),
|
|
68
68
|
}),
|
|
69
69
|
});
|
|
70
|
-
|
|
70
|
+
// List responses omit mergeability. Detail responses are needed even when the list ETag is unchanged.
|
|
71
|
+
const detailed = [];
|
|
72
|
+
for (const pullRequest of pullRequests) {
|
|
73
|
+
detailed.push(normalizePullRequestState(await getPullRequest(octokit, cache, owner, repo, pullRequest.number)));
|
|
74
|
+
}
|
|
75
|
+
return detailed;
|
|
71
76
|
}
|
|
72
77
|
export async function listReviews(octokit, cache, owner, repo, pullNumber, options) {
|
|
73
78
|
const reviews = await fetchPaginatedWithEtag({
|
|
@@ -43,17 +43,17 @@ export declare function createGitHubClient(token: string): {
|
|
|
43
43
|
comments_url: string;
|
|
44
44
|
statuses_url: string;
|
|
45
45
|
number: number;
|
|
46
|
-
state:
|
|
46
|
+
state: "open" | "closed";
|
|
47
47
|
locked: boolean;
|
|
48
48
|
title: string;
|
|
49
|
-
user: import("@octokit/openapi-types").components["schemas"]["
|
|
49
|
+
user: import("@octokit/openapi-types").components["schemas"]["simple-user"];
|
|
50
50
|
body: string | null;
|
|
51
51
|
labels: {
|
|
52
52
|
id: number;
|
|
53
53
|
node_id: string;
|
|
54
54
|
url: string;
|
|
55
55
|
name: string;
|
|
56
|
-
description: string;
|
|
56
|
+
description: string | null;
|
|
57
57
|
color: string;
|
|
58
58
|
default: boolean;
|
|
59
59
|
}[];
|
|
@@ -67,20 +67,20 @@ export declare function createGitHubClient(token: string): {
|
|
|
67
67
|
assignee: import("@octokit/openapi-types").components["schemas"]["nullable-simple-user"];
|
|
68
68
|
assignees?: import("@octokit/openapi-types").components["schemas"]["simple-user"][] | null;
|
|
69
69
|
requested_reviewers?: import("@octokit/openapi-types").components["schemas"]["simple-user"][] | null;
|
|
70
|
-
requested_teams?: import("@octokit/openapi-types").components["schemas"]["team"][] | null;
|
|
70
|
+
requested_teams?: import("@octokit/openapi-types").components["schemas"]["team-simple"][] | null;
|
|
71
71
|
head: {
|
|
72
72
|
label: string;
|
|
73
73
|
ref: string;
|
|
74
74
|
repo: import("@octokit/openapi-types").components["schemas"]["repository"];
|
|
75
75
|
sha: string;
|
|
76
|
-
user: import("@octokit/openapi-types").components["schemas"]["
|
|
76
|
+
user: import("@octokit/openapi-types").components["schemas"]["simple-user"];
|
|
77
77
|
};
|
|
78
78
|
base: {
|
|
79
79
|
label: string;
|
|
80
80
|
ref: string;
|
|
81
81
|
repo: import("@octokit/openapi-types").components["schemas"]["repository"];
|
|
82
82
|
sha: string;
|
|
83
|
-
user: import("@octokit/openapi-types").components["schemas"]["
|
|
83
|
+
user: import("@octokit/openapi-types").components["schemas"]["simple-user"];
|
|
84
84
|
};
|
|
85
85
|
_links: {
|
|
86
86
|
comments: import("@octokit/openapi-types").components["schemas"]["link"];
|
|
@@ -95,6 +95,18 @@ export declare function createGitHubClient(token: string): {
|
|
|
95
95
|
author_association: import("@octokit/openapi-types").components["schemas"]["author-association"];
|
|
96
96
|
auto_merge: import("@octokit/openapi-types").components["schemas"]["auto-merge"];
|
|
97
97
|
draft?: boolean;
|
|
98
|
+
merged: boolean;
|
|
99
|
+
mergeable: boolean | null;
|
|
100
|
+
rebaseable?: boolean | null;
|
|
101
|
+
mergeable_state: string;
|
|
102
|
+
merged_by: import("@octokit/openapi-types").components["schemas"]["nullable-simple-user"];
|
|
103
|
+
comments: number;
|
|
104
|
+
review_comments: number;
|
|
105
|
+
maintainer_can_modify: boolean;
|
|
106
|
+
commits: number;
|
|
107
|
+
additions: number;
|
|
108
|
+
deletions: number;
|
|
109
|
+
changed_files: number;
|
|
98
110
|
}, "state"> & {
|
|
99
111
|
readonly state: typeof PullRequestState.Open | typeof PullRequestState.Closed;
|
|
100
112
|
})[]>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EventJournal } from '@atolis-hq/eventing';
|
|
2
|
+
import type { AdapterId } from '../../contracts/identifiers.js';
|
|
3
|
+
import { type GitHubAdapterEventData } from '../contracts/events.js';
|
|
4
|
+
export declare function consecutivePullRequestObservations(drafts: readonly GitHubAdapterEventData[], journal: EventJournal | undefined, adapter: AdapterId | undefined): Promise<GitHubAdapterEventData[]>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { integrationStream } from '../../contracts/streams.js';
|
|
3
|
+
import { createGitHubEventData } from '../contracts/event-factory.js';
|
|
4
|
+
import { GitHubEventType, selectGitHubAdapterEvent, } from '../contracts/events.js';
|
|
5
|
+
import { GitHubAdapter } from '../contracts/vocabulary.js';
|
|
6
|
+
export async function consecutivePullRequestObservations(drafts, journal, adapter) {
|
|
7
|
+
if (journal === undefined)
|
|
8
|
+
return [...drafts];
|
|
9
|
+
const latest = new Map();
|
|
10
|
+
for (const envelope of await journal.readStream(integrationStream(adapter ?? GitHubAdapter))) {
|
|
11
|
+
const event = selectGitHubAdapterEvent(envelope)?.event;
|
|
12
|
+
if (event?.eventType === GitHubEventType.WorkObserved && event.payload.kind === 'pull-request')
|
|
13
|
+
latest.set(event.payload.externalKey, event);
|
|
14
|
+
}
|
|
15
|
+
return drafts.flatMap((draft) => {
|
|
16
|
+
if (draft.eventType !== GitHubEventType.WorkObserved || draft.payload.kind !== 'pull-request')
|
|
17
|
+
return [draft];
|
|
18
|
+
const prior = latest.get(draft.payload.externalKey);
|
|
19
|
+
if (prior?.causationId === draft.causationId)
|
|
20
|
+
return [];
|
|
21
|
+
// Chain to durable evidence: replay stays stable, but recurring states get new identities.
|
|
22
|
+
const event = createGitHubEventData({
|
|
23
|
+
...draft,
|
|
24
|
+
eventId: draft.eventId +
|
|
25
|
+
':' +
|
|
26
|
+
createHash('sha256')
|
|
27
|
+
.update(prior?.eventId ?? '')
|
|
28
|
+
.digest('hex'),
|
|
29
|
+
});
|
|
30
|
+
latest.set(draft.payload.externalKey, event);
|
|
31
|
+
return [event];
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventActorKind, EventSourceKind } from '@atolis-hq/eventing';
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
|
-
import { PullRequestCheckState, PullRequestState, ReviewActorKind, } from '../../../activities/index.js';
|
|
3
|
+
import { PullRequestCheckState, PullRequestMergeability, PullRequestState, ReviewActorKind, } from '../../../activities/index.js';
|
|
4
4
|
import { boundedDiagnosticEvidence } from '../contracts/check-evidence.js';
|
|
5
5
|
import { createGitHubEventData } from '../contracts/event-factory.js';
|
|
6
6
|
import { GitHubEventType } from '../contracts/events.js';
|
|
@@ -57,6 +57,11 @@ function pullRequestObservation(input) {
|
|
|
57
57
|
title: pullRequest.title,
|
|
58
58
|
body: fallback(pullRequest.body, ''),
|
|
59
59
|
state: pullRequestState(pullRequest),
|
|
60
|
+
mergeability: pullRequest.mergeable === false
|
|
61
|
+
? PullRequestMergeability.Conflicting
|
|
62
|
+
: pullRequest.mergeable === true
|
|
63
|
+
? PullRequestMergeability.Mergeable
|
|
64
|
+
: PullRequestMergeability.Unknown,
|
|
60
65
|
revision,
|
|
61
66
|
headRevision: revision,
|
|
62
67
|
baseRevision: fallback(pullRequest.base?.sha, UnknownGitHubRevision),
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import type { CheckpointStore } from '@atolis-hq/eventing';
|
|
1
|
+
import type { CheckpointStore, EventJournal } from '@atolis-hq/eventing';
|
|
2
2
|
import type { AdapterId } from '../../contracts/identifiers.js';
|
|
3
3
|
import type { ExternalEventSource } from '../../contracts/intake.js';
|
|
4
4
|
import type { GitHubConfig } from '../contracts/config.js';
|
|
5
|
+
import { type GitHubAdapterEventData } from '../contracts/events.js';
|
|
5
6
|
import { type GitHubAdapterHealthRegistry } from './adapter-health-registry.js';
|
|
6
7
|
import { type GitHubRequestCoordinator } from './request-coordinator.js';
|
|
7
8
|
import type { GitHubSourceClient } from './source-contracts.js';
|
|
8
9
|
export declare function createGitHubSource(config: GitHubConfig, client: GitHubSourceClient, adapter?: AdapterId, requests?: GitHubRequestCoordinator, state?: {
|
|
9
10
|
readonly checkpoints?: CheckpointStore;
|
|
11
|
+
readonly journal?: EventJournal;
|
|
10
12
|
readonly now?: () => number;
|
|
11
13
|
readonly health?: GitHubAdapterHealthRegistry;
|
|
12
|
-
}): ExternalEventSource
|
|
14
|
+
}): Omit<ExternalEventSource, 'poll'> & {
|
|
15
|
+
poll(...args: Parameters<ExternalEventSource['poll']>): Promise<readonly GitHubAdapterEventData[]>;
|
|
16
|
+
};
|
|
@@ -2,6 +2,7 @@ import { gitHubIssueQueryFilters } from '../application/intake-policy.js';
|
|
|
2
2
|
import { GitHubEventType } from '../contracts/events.js';
|
|
3
3
|
import { createGitHubAdapterHealthRegistry, } from './adapter-health-registry.js';
|
|
4
4
|
import { issueCommentEventsFor, reviewCommentEventsFor, reviewEventsFor, } from './comment-source.js';
|
|
5
|
+
import { consecutivePullRequestObservations } from './consecutive-pr-observations.js';
|
|
5
6
|
import { issueObservation } from './issue-source.js';
|
|
6
7
|
import { batchesComplete, batchesSucceeded, completedProviderWatermark, hasProviderTimestamp, loadWatermark, overlapSince, reportPartialPollFailure, timestampsValid, watermarkCheckpoint, } from './poll-watermark.js';
|
|
7
8
|
import { pullRequestEventsFor } from './pr-source.js';
|
|
@@ -10,9 +11,8 @@ export function createGitHubSource(config, client, adapter, requests = createGit
|
|
|
10
11
|
maxConcurrent: config.polling.maxConcurrent,
|
|
11
12
|
}), state) {
|
|
12
13
|
const health = state?.health ?? createGitHubAdapterHealthRegistry(config.repositories);
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// work observations within one process lifetime, so it is only a performance optimization.
|
|
14
|
+
// PR observations use the journal to deduplicate consecutive evidence durably.
|
|
15
|
+
// This cache avoids returning unchanged issue observations within one process.
|
|
16
16
|
const lastEventIds = new Map();
|
|
17
17
|
const pendingWatermarks = new Map();
|
|
18
18
|
const now = state?.now ?? Date.now;
|
|
@@ -41,11 +41,12 @@ export function createGitHubSource(config, client, adapter, requests = createGit
|
|
|
41
41
|
for (const result of perRepository)
|
|
42
42
|
if (result.watermark !== undefined)
|
|
43
43
|
pendingWatermarks.set(result.repository, result.watermark);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.filter((draft) => {
|
|
44
|
+
const drafts = await consecutivePullRequestObservations(perRepository.flatMap((result) => result.drafts), state?.journal, adapter);
|
|
45
|
+
return drafts.filter((draft) => {
|
|
47
46
|
if (draft.eventType !== GitHubEventType.WorkObserved)
|
|
48
47
|
return true;
|
|
48
|
+
if (draft.payload.kind === 'pull-request' && state?.journal !== undefined)
|
|
49
|
+
return true;
|
|
49
50
|
const prior = lastEventIds.get(draft.payload.externalKey);
|
|
50
51
|
lastEventIds.set(draft.payload.externalKey, draft.eventId);
|
|
51
52
|
return prior !== draft.eventId;
|
|
@@ -102,9 +103,8 @@ async function pollRepository(input) {
|
|
|
102
103
|
? pullRequestsResult.value
|
|
103
104
|
: [];
|
|
104
105
|
const topLevelTimestampsValid = timestampsValid(returnedIssues, returnedPullRequestPayloads);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
.filter((pullRequest) => since === undefined || pullRequest.updated_at >= since);
|
|
106
|
+
// Mergeability and checks can change without updating the PR timestamp.
|
|
107
|
+
const pullRequestPayloads = returnedPullRequestPayloads.filter(hasProviderTimestamp);
|
|
108
108
|
const [pullRequests, reviews, reviewComments, issueComments] = await Promise.all([
|
|
109
109
|
pullRequestEventsFor({
|
|
110
110
|
client: { ...client, listPullRequests: async () => pullRequestPayloads },
|
|
@@ -49,6 +49,7 @@ export const gitHubProviderDefinition = {
|
|
|
49
49
|
eventTypes: Object.values(GitHubEventType),
|
|
50
50
|
source: createGitHubSource(config, client, adapter, requests, {
|
|
51
51
|
checkpoints: services.checkpoints,
|
|
52
|
+
journal: services.journal,
|
|
52
53
|
now: () => services.clock.now().getTime(),
|
|
53
54
|
health,
|
|
54
55
|
}),
|
|
@@ -5,6 +5,7 @@ import type { SupplementalActivityRequest } from '../contracts/events.js';
|
|
|
5
5
|
import { type SignalName, type WorkflowInstanceId } from '../contracts/identifiers.js';
|
|
6
6
|
import type { AcceptActivityOutcome } from './accept-activity-outcome.js';
|
|
7
7
|
import type { OrchestrationRepository } from './orchestration-repository.js';
|
|
8
|
+
import { type AgentActivityClassifier, type PendingActivationEntry } from './pending-activations.js';
|
|
8
9
|
import { type ExecutionFailureInput } from './resolve-execution-failure.js';
|
|
9
10
|
import type { StartWorkflow } from './start-workflow.js';
|
|
10
11
|
export declare class OperatorRetryIneligibleError extends Error {
|
|
@@ -15,7 +16,8 @@ export declare class AdvanceWorkflow {
|
|
|
15
16
|
private readonly repository;
|
|
16
17
|
private readonly workflows;
|
|
17
18
|
private readonly acceptOutcome;
|
|
18
|
-
|
|
19
|
+
private readonly isAgentActivity;
|
|
20
|
+
constructor(repository: OrchestrationRepository, workflows: StartWorkflow, acceptOutcome: AcceptActivityOutcome['execute'], isAgentActivity?: AgentActivityClassifier);
|
|
19
21
|
requestSupplementalActivity(id: WorkflowInstanceId, request: SupplementalActivityRequest, context: CommandContext): Promise<import("../index.js").WorkflowInstanceView>;
|
|
20
22
|
markActivationStarted(id: WorkflowInstanceId, activationId: ActivationId, context: CommandContext): Promise<import("../index.js").WorkflowInstanceView | null>;
|
|
21
23
|
blockAwaitingActivation(id: WorkflowInstanceId, activationId: ActivationId, reason: string, context: CommandContext): Promise<import("../index.js").WorkflowInstanceView | null>;
|
|
@@ -34,10 +36,7 @@ export declare class AdvanceWorkflow {
|
|
|
34
36
|
resumeBlockedStageForChanges(id: WorkflowInstanceId, context: CommandContext): Promise<import("../index.js").WorkflowInstanceView | null>;
|
|
35
37
|
resumeNeedsClarificationStage(id: WorkflowInstanceId, context: CommandContext): Promise<import("../index.js").WorkflowInstanceView | null>;
|
|
36
38
|
get(id: WorkflowInstanceId): Promise<import("../index.js").WorkflowInstanceView | null>;
|
|
37
|
-
listPendingActivations(workItemId?: string): Promise<
|
|
38
|
-
workflow: import("../index.js").WorkflowInstanceView;
|
|
39
|
-
activation: import("../index.js").ActivityActivationView;
|
|
40
|
-
}[]>;
|
|
39
|
+
listPendingActivations(workItemId?: string): Promise<readonly PendingActivationEntry[]>;
|
|
41
40
|
listWaiting(signalKind?: SignalName): Promise<import("../index.js").WorkflowInstanceView[]>;
|
|
42
41
|
listAll(): Promise<import("../index.js").WorkflowInstanceView[]>;
|
|
43
42
|
listResourceTransitionMatches(event: PersistedEvent): Promise<readonly import("./resource-transition-matching.js").ResourceTransitionMatch[]>;
|
|
@@ -8,6 +8,7 @@ import { isAuthorisedActor } from '../domain/supplemental-policy.js';
|
|
|
8
8
|
import { appendWithIntentRecovery } from './durable-append.js';
|
|
9
9
|
import { expireTimedOutWaits } from './expire-timed-out-waits.js';
|
|
10
10
|
import { attributeOperatorRetry } from './operator-retry-attribution.js';
|
|
11
|
+
import { prioritisePendingActivations, } from './pending-activations.js';
|
|
11
12
|
import { resolveExecutionFailure, } from './resolve-execution-failure.js';
|
|
12
13
|
import { acceptResourceTransition, matchResourceTransitions, } from './resource-transition-matching.js';
|
|
13
14
|
import { matchWatches } from './watch-matching.js';
|
|
@@ -21,10 +22,12 @@ export class AdvanceWorkflow {
|
|
|
21
22
|
repository;
|
|
22
23
|
workflows;
|
|
23
24
|
acceptOutcome;
|
|
24
|
-
|
|
25
|
+
isAgentActivity;
|
|
26
|
+
constructor(repository, workflows, acceptOutcome, isAgentActivity = () => true) {
|
|
25
27
|
this.repository = repository;
|
|
26
28
|
this.workflows = workflows;
|
|
27
29
|
this.acceptOutcome = acceptOutcome;
|
|
30
|
+
this.isAgentActivity = isAgentActivity;
|
|
28
31
|
}
|
|
29
32
|
async requestSupplementalActivity(id, request, context) {
|
|
30
33
|
const loaded = await this.repository.loadRequired(id);
|
|
@@ -191,11 +194,8 @@ export class AdvanceWorkflow {
|
|
|
191
194
|
return (await this.repository.load(id)).view;
|
|
192
195
|
}
|
|
193
196
|
async listPendingActivations(workItemId) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
view.pendingActivation !== undefined &&
|
|
197
|
-
(workItemId === undefined || view.workItemId === workItemId))
|
|
198
|
-
.map(({ view }) => ({ workflow: view, activation: view.pendingActivation }));
|
|
197
|
+
const views = (await this.listAllLoaded()).map(({ view }) => view);
|
|
198
|
+
return prioritisePendingActivations(this.workflows, views, this.isAgentActivity, workItemId);
|
|
199
199
|
}
|
|
200
200
|
async listWaiting(signalKind) {
|
|
201
201
|
return (await this.listAllLoaded())
|
|
@@ -10,6 +10,7 @@ import { type SignalName, type WorkflowInstanceId } from '../contracts/identifie
|
|
|
10
10
|
import type { WorkflowInstanceView } from '../contracts/views.js';
|
|
11
11
|
import { AdvanceWorkflow } from './advance-workflow.js';
|
|
12
12
|
import { type ConversationCommandInput, type ConversationCommandResult } from './conversation-command.js';
|
|
13
|
+
import type { AgentActivityClassifier } from './pending-activations.js';
|
|
13
14
|
export declare class OrchestrationService {
|
|
14
15
|
private readonly startWorkflow;
|
|
15
16
|
private readonly acceptActivityOutcome;
|
|
@@ -23,7 +24,7 @@ export declare class OrchestrationService {
|
|
|
23
24
|
private readonly journal;
|
|
24
25
|
private readonly definitions;
|
|
25
26
|
private readonly work;
|
|
26
|
-
constructor(journal: EventJournal, work: WorkService, definitions: Readonly<Record<string, CompiledWorkflow>>, projections?: ProjectionStore);
|
|
27
|
+
constructor(journal: EventJournal, work: WorkService, definitions: Readonly<Record<string, CompiledWorkflow>>, projections?: ProjectionStore, isAgentActivity?: AgentActivityClassifier);
|
|
27
28
|
start(command: StartWorkflowInstance, context: CommandContext): Promise<WorkflowInstanceView>;
|
|
28
29
|
requestChild(request: ChildWorkflowRequest & {
|
|
29
30
|
readonly maxPerGroup: number;
|
|
@@ -68,10 +69,7 @@ export declare class OrchestrationService {
|
|
|
68
69
|
}, context: CommandContext): Promise<import("../contracts/views.js").GroupBudgetExhaustedView | WorkflowInstanceView>;
|
|
69
70
|
get(id: WorkflowInstanceId): Promise<WorkflowInstanceView | null>;
|
|
70
71
|
getPrimaryWorkflowInstanceId(workItemId: WorkItemId): Promise<string | undefined>;
|
|
71
|
-
listPendingActivations(workItemId?: string): Promise<
|
|
72
|
-
workflow: WorkflowInstanceView;
|
|
73
|
-
activation: import("../contracts/views.js").ActivityActivationView;
|
|
74
|
-
}[]>;
|
|
72
|
+
listPendingActivations(workItemId?: string): Promise<readonly import("./pending-activations.js").PendingActivationEntry[]>;
|
|
75
73
|
listWaiting(signalKind?: SignalName): Promise<WorkflowInstanceView[]>;
|
|
76
74
|
expireTimedOutWaits(context: CommandContext): Promise<WorkflowInstanceView[]>;
|
|
77
75
|
listAll(): Promise<WorkflowInstanceView[]>;
|
|
@@ -103,4 +101,4 @@ export type OperationCoordinator = <Result>(operation: () => Promise<Result>) =>
|
|
|
103
101
|
export interface WatchChildCancellation {
|
|
104
102
|
cancelSupersededWatchChildren(workflowInstanceIds: readonly string[]): Promise<unknown>;
|
|
105
103
|
}
|
|
106
|
-
export declare const createOrchestrationService: (journal: EventJournal, work: WorkService, definitions: Readonly<Record<string, CompiledWorkflow>>, projections?: ProjectionStore) => OrchestrationService;
|
|
104
|
+
export declare const createOrchestrationService: (journal: EventJournal, work: WorkService, definitions: Readonly<Record<string, CompiledWorkflow>>, projections?: ProjectionStore, isAgentActivity?: AgentActivityClassifier) => OrchestrationService;
|
|
@@ -31,7 +31,7 @@ export class OrchestrationService {
|
|
|
31
31
|
journal;
|
|
32
32
|
definitions;
|
|
33
33
|
work;
|
|
34
|
-
constructor(journal, work, definitions, projections) {
|
|
34
|
+
constructor(journal, work, definitions, projections, isAgentActivity) {
|
|
35
35
|
this.projections = projections;
|
|
36
36
|
this.journal = journal;
|
|
37
37
|
this.work = work;
|
|
@@ -39,7 +39,7 @@ export class OrchestrationService {
|
|
|
39
39
|
this.claims = new CoordinationClaims(journal);
|
|
40
40
|
this.definitions = new WorkflowDefinitionRegistry(journal, projections, definitions);
|
|
41
41
|
this.startWorkflow = new StartWorkflow(repository, this.claims, work, this.definitions);
|
|
42
|
-
this.advanceWorkflow = new AdvanceWorkflow(repository, this.startWorkflow, (command, context) => this.acceptActivityOutcome.execute(command, context));
|
|
42
|
+
this.advanceWorkflow = new AdvanceWorkflow(repository, this.startWorkflow, (command, context) => this.acceptActivityOutcome.execute(command, context), isAgentActivity);
|
|
43
43
|
this.acceptWorkflowSignal = new AcceptSignal(repository, this.startWorkflow, work);
|
|
44
44
|
this.childWorkflows = new RequestChild(repository, this.claims, new GroupBudgetRecorder(journal), this.startWorkflow, this.advanceWorkflow);
|
|
45
45
|
this.acceptActivityOutcome = new AcceptActivityOutcome(repository, this.startWorkflow, (context) => this.childWorkflows.reconcileChildCompletions(context));
|
|
@@ -303,7 +303,7 @@ async function journalGroupBudgetExhaustion(journal, workflowInstanceId) {
|
|
|
303
303
|
: [];
|
|
304
304
|
});
|
|
305
305
|
}
|
|
306
|
-
export const createOrchestrationService = (journal, work, definitions, projections) => new OrchestrationService(journal, work, definitions, projections);
|
|
306
|
+
export const createOrchestrationService = (journal, work, definitions, projections, isAgentActivity) => new OrchestrationService(journal, work, definitions, projections, isAgentActivity);
|
|
307
307
|
function isWorkControllable(work) {
|
|
308
308
|
return work !== null && !work.deleted && !work.frozen && work.state === WorkStatus.Open;
|
|
309
309
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ActivityName, type ActivityRegistry } from '../../activities/index.js';
|
|
2
|
+
import type { ActivityActivationView, WorkflowInstanceView } from '../contracts/views.js';
|
|
3
|
+
import { type PendingActivationPriority } from '../domain/dispatch-priority.js';
|
|
4
|
+
import type { StartWorkflow } from './start-workflow.js';
|
|
5
|
+
/** Whether a stage's activity runs an agent; unknown activities conservatively count as agents. */
|
|
6
|
+
export type AgentActivityClassifier = (activity: ActivityName) => boolean;
|
|
7
|
+
export declare function createAgentActivityClassifier(registry: ActivityRegistry): AgentActivityClassifier;
|
|
8
|
+
export interface PendingActivationEntry {
|
|
9
|
+
readonly workflow: WorkflowInstanceView;
|
|
10
|
+
readonly activation: ActivityActivationView;
|
|
11
|
+
readonly priority: PendingActivationPriority;
|
|
12
|
+
}
|
|
13
|
+
export declare function prioritisePendingActivations(workflows: StartWorkflow, views: readonly WorkflowInstanceView[], isAgentActivity: AgentActivityClassifier, workItemId?: string): Promise<readonly PendingActivationEntry[]>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ActivityExecutionKind, } from '../../activities/index.js';
|
|
2
|
+
import { WorkflowStatus } from '../contracts/vocabulary.js';
|
|
3
|
+
import { pendingActivationPriority, } from '../domain/dispatch-priority.js';
|
|
4
|
+
import { WorkflowDefinitionUnavailableError } from './workflow-definition-registry.js';
|
|
5
|
+
export function createAgentActivityClassifier(registry) {
|
|
6
|
+
const kinds = new Map(registry.list().map((activity) => [activity.name, activity.executionKind]));
|
|
7
|
+
return (activity) => {
|
|
8
|
+
const kind = kinds.get(activity);
|
|
9
|
+
return kind === undefined || kind === ActivityExecutionKind.Agent;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
// Read-only: an unavailable definition ranks last rather than blocking the instance.
|
|
13
|
+
async function resolveDefinition(workflows, view) {
|
|
14
|
+
try {
|
|
15
|
+
return await workflows.definitionFor(view);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (error instanceof WorkflowDefinitionUnavailableError)
|
|
19
|
+
return null;
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function prioritisePendingActivations(workflows, views, isAgentActivity, workItemId) {
|
|
24
|
+
const pending = views.filter((view) => view.status === WorkflowStatus.Active &&
|
|
25
|
+
view.pendingActivation !== undefined &&
|
|
26
|
+
(workItemId === undefined || view.workItemId === workItemId));
|
|
27
|
+
return Promise.all(pending.map(async (view) => ({
|
|
28
|
+
workflow: view,
|
|
29
|
+
activation: view.pendingActivation,
|
|
30
|
+
priority: pendingActivationPriority(await resolveDefinition(workflows, view), view, view.pendingActivation, isAgentActivity),
|
|
31
|
+
})));
|
|
32
|
+
}
|
|
@@ -5,3 +5,8 @@ import type { ResourceTransitionEvidence } from './resource-transition-evidence.
|
|
|
5
5
|
import type { StartWorkflow } from './start-workflow.js';
|
|
6
6
|
export declare function recoverPolicyBlockedMerges(repository: OrchestrationRepository, workflows: StartWorkflow, evidence: ResourceTransitionEvidence, context: CommandContext): Promise<void>;
|
|
7
7
|
export declare function isPolicyBlockedMergeWait(view: WorkflowInstanceView): boolean;
|
|
8
|
+
export declare const MergeWaitBlockReason: {
|
|
9
|
+
readonly Closed: "merge.pr-closed-unmerged: primary PR was closed without merging; restore the PR and resolve the workflow explicitly";
|
|
10
|
+
readonly Conflict: "merge.pr-conflicting: primary PR conflicts with its base; no safe bounded repair route in the pinned workflow";
|
|
11
|
+
readonly Exhausted: "merge.conflict-retry-exhausted: bounded conflict repair exhausted; resolve the PR and workflow explicitly";
|
|
12
|
+
};
|