@leitwerk-dev/coding 0.3.0 → 0.3.1

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.
Files changed (45) hide show
  1. package/README.md +34 -1
  2. package/dist/auto-work-branch.js +3 -24
  3. package/dist/auto-work-branch.js.map +1 -1
  4. package/dist/chunk-6E5VQPC4.js +28 -0
  5. package/dist/chunk-6E5VQPC4.js.map +1 -0
  6. package/dist/chunk-KFELB7ZC.js +70 -0
  7. package/dist/chunk-KFELB7ZC.js.map +1 -0
  8. package/dist/profile-bindings-internal.d.ts +3 -0
  9. package/dist/profile-bindings-internal.d.ts.map +1 -0
  10. package/dist/pull-request-publication-internal.d.ts +73 -0
  11. package/dist/pull-request-publication-internal.d.ts.map +1 -0
  12. package/dist/repository-change-launch-internal-Dd-AONUs.d.ts +67 -0
  13. package/dist/repository-change-launch-internal.d.ts +30 -0
  14. package/dist/repository-change-launch-internal.d.ts.map +1 -1
  15. package/dist/repository-change-launch.d.ts +4 -2
  16. package/dist/repository-change-launch.d.ts.map +1 -1
  17. package/dist/repository-change-launch.js +235 -6
  18. package/dist/repository-change-launch.js.map +1 -1
  19. package/dist/repository-change-publication.d.ts +2 -2
  20. package/dist/repository-change-publication.d.ts.map +1 -1
  21. package/dist/repository-change-publication.js +429 -27
  22. package/dist/repository-change-publication.js.map +1 -1
  23. package/dist/repository-change-ui-launcher-internal.d.ts +53 -0
  24. package/dist/repository-change-ui-launcher-internal.d.ts.map +1 -0
  25. package/dist/repository-rebase/git.d.ts +31 -0
  26. package/dist/repository-rebase/git.d.ts.map +1 -0
  27. package/dist/repository-rebase/index.d.ts +42 -0
  28. package/dist/repository-rebase/index.d.ts.map +1 -0
  29. package/dist/repository-rebase/index.js +16 -0
  30. package/dist/repository-rebase/index.js.map +1 -0
  31. package/dist/repository-rebase/policy.d.ts +37 -0
  32. package/dist/repository-rebase/policy.d.ts.map +1 -0
  33. package/dist/repository-rebase/prompt.d.ts +3 -0
  34. package/dist/repository-rebase/prompt.d.ts.map +1 -0
  35. package/package.json +9 -5
  36. package/src/profile-bindings-internal.ts +39 -0
  37. package/src/pull-request-publication-internal.ts +286 -0
  38. package/src/repository-change-launch-internal.ts +76 -0
  39. package/src/repository-change-launch.ts +9 -0
  40. package/src/repository-change-publication.ts +29 -45
  41. package/src/repository-change-ui-launcher-internal.ts +225 -0
  42. package/src/repository-rebase/git.ts +219 -0
  43. package/src/repository-rebase/index.ts +144 -0
  44. package/src/repository-rebase/policy.ts +75 -0
  45. package/src/repository-rebase/prompt.ts +2 -0
@@ -0,0 +1,286 @@
1
+ import type {
2
+ defineExternalActionSource,
3
+ RepositoryFeedbackSourceConfig,
4
+ RepositoryIssueCancelledSourceConfig,
5
+ RepositoryPullRequestSourceConfig,
6
+ } from "@leitwerk-dev/process-sdk";
7
+ import type { GitIdentity } from "./finalization-git.js";
8
+ import type { RepositoryIssueOriginParams } from "./repository-change-launch-internal.js";
9
+ import type {
10
+ PublicationContext,
11
+ PublicationEvidence,
12
+ PublicationParams,
13
+ PublicationRequest,
14
+ PublicationSource,
15
+ PublicationState,
16
+ RepositoryChangePublicationAdapter,
17
+ } from "./repository-change-publication.js";
18
+ import {
19
+ publicationObject as object,
20
+ readPublicationState,
21
+ } from "./repository-change-publication.js";
22
+ import type { RepositoryChangeState } from "./repository-change-state.js";
23
+
24
+ const callFor =
25
+ <P>(ctx: PublicationContext<P>, provider: string) =>
26
+ <T>(name: string, args: Record<string, unknown>) =>
27
+ ctx.callIntegrationTool(`${provider}_${name}`, { projectKey: "repo", ...args }) as Promise<T>;
28
+
29
+ /** @internal */
30
+ export async function resolvePullRequestGitIdentity<P>(
31
+ ctx: PublicationContext<P>,
32
+ provider: string,
33
+ profile: string,
34
+ ): Promise<GitIdentity> {
35
+ const project = ctx.projects.find((candidate) => candidate.key === "repo");
36
+ const identity = object(object(project?.metadata)["leitwerk.gitIdentity"]);
37
+ if (
38
+ identity.provider === provider &&
39
+ identity.profile === profile &&
40
+ [identity.login, identity.name, identity.email].every(
41
+ (value) => typeof value === "string" && value.trim(),
42
+ )
43
+ )
44
+ return identity as unknown as GitIdentity;
45
+ return callFor(ctx, provider)<GitIdentity>("resolve_git_identity", {});
46
+ }
47
+
48
+ /** @internal */
49
+ export function readPullRequestFeedback(
50
+ current: PublicationState,
51
+ event: unknown,
52
+ ): Extract<PublicationEvidence, { kind: "feedback" }> {
53
+ const value = object(event);
54
+ const cursors = object(value.cursors);
55
+ return {
56
+ kind: "feedback",
57
+ conversationCursor: Number(cursors.conversationCursor ?? current.conversationCursor),
58
+ reviewCursor: Number(cursors.reviewCursor ?? current.reviewCursor),
59
+ inlineCursor: Number(cursors.inlineCursor ?? current.inlineCursor),
60
+ feedbackIds: (value.feedbackIds ?? []) as PublicationState["feedbackIds"],
61
+ };
62
+ }
63
+
64
+ /** @internal */
65
+ export function reconcilePullRequestSourceIssue<P extends PublicationParams>(
66
+ provider: string,
67
+ labelKey: "id" | "name",
68
+ issueOrigin: (params: P) =>
69
+ | {
70
+ /** @internal */
71
+ issueNumber: number;
72
+ /** @internal */
73
+ triggerLabel: string;
74
+ /** @internal */
75
+ doneLabel: string;
76
+ }
77
+ | undefined,
78
+ ): RepositoryChangePublicationAdapter<P>["reconcileTerminal"] {
79
+ return async (ctx, _current, pr) => {
80
+ const params = issueOrigin(ctx.params);
81
+ if (!params) return;
82
+ const call = callFor(ctx, provider);
83
+ const issue = await call<{ labels: Array<{ id: number; name: string }> }>("get_issue", {
84
+ issueNumber: params.issueNumber,
85
+ });
86
+ let labels = issue.labels
87
+ .filter((label) => label.name !== params.triggerLabel)
88
+ .map((label) => label[labelKey]);
89
+ if (pr.merged) {
90
+ const done = await call<{ id: number; name: string }>("ensure_label", {
91
+ name: params.doneLabel,
92
+ });
93
+ labels = [...new Set([...labels, done[labelKey]])];
94
+ }
95
+ await call("update_issue", {
96
+ issueNumber: params.issueNumber,
97
+ patch: { labels, ...(pr.merged ? { state: "closed" } : {}) },
98
+ writeKey: `${provider}:${ctx.process.id}:${pr.merged ? "complete-source-issue" : "remove-source-trigger"}`,
99
+ });
100
+ await call("add_issue_comment", {
101
+ issueNumber: params.issueNumber,
102
+ body: pr.merged
103
+ ? `Merged ${pr.html_url}${pr.merge_commit_sha ? ` at ${pr.merge_commit_sha}` : ""}.`
104
+ : `Leitwerk stopped because ${pr.html_url} was closed without merge.`,
105
+ writeKey: `${provider}:${ctx.process.id}:${pr.merged ? "merged" : "closed"}-pr-comment`,
106
+ });
107
+ };
108
+ }
109
+
110
+ /** @internal */
111
+ type SourceFactory<C> = ReturnType<typeof defineExternalActionSource<C>>;
112
+
113
+ /** Shared wiring for providers implementing the pull-request source protocol. @internal */
114
+ export function pullRequestPublicationSources<P extends PublicationParams>(
115
+ provider: string,
116
+ label: string,
117
+ external: {
118
+ /** @internal */
119
+ pullRequestFeedback: SourceFactory<
120
+ Omit<RepositoryFeedbackSourceConfig, "disabled" | "terminalOutcome">
121
+ >;
122
+ /** @internal */
123
+ pullRequestTerminal: SourceFactory<Omit<RepositoryPullRequestSourceConfig, "disabled">>;
124
+ /** @internal */
125
+ issueCancelled: SourceFactory<RepositoryIssueCancelledSourceConfig>;
126
+ },
127
+ profile: (params: P) => string,
128
+ issueOrigin: (params: P) => RepositoryIssueOriginParams | undefined,
129
+ ) {
130
+ const remote = (state: RepositoryChangeState) =>
131
+ readPublicationState(state, `${provider}RepoChange`);
132
+ /** @internal */
133
+ function requirePr(state: RepositoryChangeState) {
134
+ const value = remote(state);
135
+ if (!value.headSha || !value.prNumber || !value.prUrl)
136
+ throw new Error("Pull request delivery state is incomplete");
137
+ return {
138
+ ...value,
139
+ /** @internal */ headSha: value.headSha,
140
+ /** @internal */ prNumber: value.prNumber,
141
+ /** @internal */ prUrl: value.prUrl,
142
+ };
143
+ }
144
+ const feedback: PublicationSource<P> = {
145
+ id: `${provider}_feedback`,
146
+ kind: "feedback",
147
+ label: `${label} pull request feedback`,
148
+ source: external.pullRequestFeedback<P, RepositoryChangeState>(({ params, state }) => ({
149
+ profile: profile(params),
150
+ owner: params.owner,
151
+ repo: params.repo,
152
+ prNumber: requirePr(state).prNumber,
153
+ conversationCursor: remote(state).conversationCursor,
154
+ reviewCursor: remote(state).reviewCursor,
155
+ inlineCursor: remote(state).inlineCursor,
156
+ quietPeriodMs: 120000,
157
+ pollInterval: "30s",
158
+ })),
159
+ read: ({ state, event }) => readPullRequestFeedback(remote(state), event),
160
+ };
161
+ const terminal: PublicationSource<P>[] = (["merged", "closed"] as const).map(
162
+ (terminalOutcome) => ({
163
+ id: `${provider}_pr_${terminalOutcome}`,
164
+ kind: "terminal",
165
+ label: `${label} pull request ${terminalOutcome}`,
166
+ source: external.pullRequestTerminal<P, RepositoryChangeState>(({ params, state }) => ({
167
+ profile: profile(params),
168
+ owner: params.owner,
169
+ repo: params.repo,
170
+ prNumber: requirePr(state).prNumber,
171
+ terminalOutcome,
172
+ pollInterval: "30s",
173
+ })),
174
+ read: ({ event }) => ({
175
+ kind: "terminal",
176
+ request: object(event).pullRequest as PublicationRequest,
177
+ }),
178
+ }),
179
+ );
180
+ const cancelled: PublicationSource<P> = {
181
+ id: "source_cancelled",
182
+ kind: "cancelled",
183
+ label: "Source issue cancelled",
184
+ enabled: (params) => issueOrigin(params) !== undefined,
185
+ source: external.issueCancelled<P, RepositoryChangeState>(({ params }) => {
186
+ const issue = issueOrigin(params);
187
+ if (!issue) throw new Error(`${label} source issue metadata is unavailable`);
188
+ return {
189
+ profile: profile(params),
190
+ owner: params.owner,
191
+ repo: params.repo,
192
+ issueNumber: issue.issueNumber,
193
+ triggerLabel: issue.triggerLabel,
194
+ pollInterval: "30s",
195
+ };
196
+ }),
197
+ read: () => ({ kind: "cancelled" }),
198
+ };
199
+ return {
200
+ /** @internal */ requirePr,
201
+ /** @internal */ feedback,
202
+ /** @internal */ terminal,
203
+ /** @internal */ cancelled,
204
+ };
205
+ }
206
+
207
+ /** Callbacks for providers implementing the shared pull-request tool protocol. @internal */
208
+ export function pullRequestPublicationCallbacks<P extends PublicationParams>(
209
+ provider: string,
210
+ label: string,
211
+ issueOrigin: (params: P) =>
212
+ | {
213
+ /** @internal */
214
+ issueNumber: number;
215
+ /** @internal */
216
+ issueUrl: string;
217
+ }
218
+ | undefined,
219
+ ): Pick<
220
+ RepositoryChangePublicationAdapter<P>,
221
+ "ensureRequest" | "linkIssue" | "reply" | "acknowledge" | "head" | "afterRebase"
222
+ > {
223
+ const call = (ctx: PublicationContext<P>) => callFor(ctx, provider);
224
+ return {
225
+ async ensureRequest(ctx) {
226
+ const project = ctx.repo.get("repo");
227
+ const issue = issueOrigin(ctx.params);
228
+ const pr = await call(ctx)<PublicationRequest>("ensure_pull_request", {
229
+ title: ctx.process.title ?? (issue ? `Issue #${issue.issueNumber}` : "Leitwerk change"),
230
+ body: issue
231
+ ? `Implements ${issue.issueUrl}\n\nLeitwerk process: ${ctx.process.id}`
232
+ : `Leitwerk process: ${ctx.process.id}`,
233
+ head: project.workBranch,
234
+ base: project.baseBranch,
235
+ });
236
+ if (!pr) throw new Error(`${label} pull request could not be created or found`);
237
+ return pr;
238
+ },
239
+ async linkIssue(ctx, current) {
240
+ const issue = issueOrigin(ctx.params);
241
+ if (issue)
242
+ await call(ctx)("add_issue_comment", {
243
+ issueNumber: issue.issueNumber,
244
+ body: `Leitwerk opened pull request ${current.prUrl}.`,
245
+ writeKey: `${provider}:${ctx.process.id}:source-pr-link:${current.prNumber}`,
246
+ });
247
+ },
248
+ async reply(ctx, current) {
249
+ const invoke = call(ctx);
250
+ for (const feedback of current.feedbackIds)
251
+ await invoke("reply_to_pull_request_feedback", {
252
+ pullRequestNumber: current.prNumber,
253
+ feedbackKind: feedback.kind,
254
+ feedbackId: feedback.id,
255
+ body: `Addressed in ${current.headSha?.slice(0, 8) ?? "the current revision"}.`,
256
+ writeKey: `${provider}:${ctx.process.id}:feedback-reply:${feedback.kind}:${feedback.id}:${current.headSha}`,
257
+ });
258
+ },
259
+ async acknowledge(ctx, current) {
260
+ const invoke = call(ctx);
261
+ for (const feedback of current.feedbackIds) {
262
+ if (feedback.kind === "review") continue;
263
+ await invoke("add_pull_request_feedback_reaction", {
264
+ pullRequestNumber: current.prNumber,
265
+ feedbackKind: feedback.kind,
266
+ feedbackId: feedback.id,
267
+ writeKey: `${provider}:${ctx.process.id}:feedback-eyes:${feedback.kind}:${feedback.id}`,
268
+ });
269
+ }
270
+ },
271
+ async head(ctx, current) {
272
+ return (
273
+ await call(ctx)<{ head: { sha: string } }>("get_pull_request", {
274
+ pullRequestNumber: current.prNumber,
275
+ })
276
+ ).head.sha;
277
+ },
278
+ async afterRebase(ctx, current) {
279
+ await call(ctx)("add_pull_request_comment", {
280
+ pullRequestNumber: current.prNumber,
281
+ body: `Merge conflict repair completed at ${current.headSha}; base ${current.conflict?.baseSha}.`,
282
+ writeKey: `rebase:${ctx.process.id}:${current.lastConflictKey}:${current.headSha}`,
283
+ });
284
+ },
285
+ };
286
+ }
@@ -17,6 +17,60 @@ export interface RepositoryChangeParamsBase {
17
17
  export type RepositoryChangeLaunchParams<TExtra extends object = Record<never, never>> = TExtra &
18
18
  RepositoryChangeParamsBase;
19
19
 
20
+ /** Shared source metadata; provider-specific interfaces retain their exported names. @public */
21
+ export interface RepositoryIssueOriginParams {
22
+ /** @public */
23
+ origin: "issue";
24
+ /** @public */
25
+ issueNumber: number;
26
+ /** @public */
27
+ issueUrl: string;
28
+ /** @public */
29
+ triggerLabel: string;
30
+ /** @public */
31
+ doneLabel: string;
32
+ }
33
+
34
+ /** @public */
35
+ export interface RepositoryUiOriginParams {
36
+ /** @public */
37
+ origin: "ui";
38
+ /** @public */
39
+ issueNumber: null;
40
+ /** @public */
41
+ issueUrl: null;
42
+ /** @public */
43
+ triggerLabel: null;
44
+ /** @public */
45
+ doneLabel: null;
46
+ }
47
+
48
+ /** GitHub/Forgejo legacy origins default to issue; other providers may be stricter. @internal */
49
+ export function normalizeRepositoryIssueOrigin(
50
+ record: Record<string, unknown>,
51
+ displayName: string,
52
+ text: (name: string) => string,
53
+ ): RepositoryIssueOriginParams | RepositoryUiOriginParams {
54
+ const origin = trimString(record.origin);
55
+ if (origin === "ui") {
56
+ return { origin: "ui", issueNumber: null, issueUrl: null, triggerLabel: null, doneLabel: null };
57
+ }
58
+ if (origin && origin !== "issue") throw new Error(`${displayName} requires a valid origin`);
59
+ if (
60
+ typeof record.issueNumber !== "number" ||
61
+ !Number.isInteger(record.issueNumber) ||
62
+ record.issueNumber <= 0
63
+ )
64
+ throw new Error(`${displayName} requires issueNumber`);
65
+ return {
66
+ origin: "issue",
67
+ issueNumber: record.issueNumber,
68
+ issueUrl: text("issueUrl"),
69
+ triggerLabel: text("triggerLabel"),
70
+ doneLabel: text("doneLabel"),
71
+ };
72
+ }
73
+
20
74
  /** @public */
21
75
  export interface NormalizedRepositoryChangeParamsInput {
22
76
  /** @internal */
@@ -55,6 +109,28 @@ export function normalizeRepositoryChangeParamsInput(
55
109
  };
56
110
  }
57
111
 
112
+ /** Normalize issue-capable repository params with provider-owned required text fields. @internal */
113
+ export function normalizeRepositoryIssueChangeParams<K extends string>(
114
+ value: unknown,
115
+ displayName: string,
116
+ fields: readonly K[],
117
+ ): NormalizedRepositoryChangeParamsInput &
118
+ Record<K, string> &
119
+ (RepositoryIssueOriginParams | RepositoryUiOriginParams) {
120
+ const shared = normalizeRepositoryChangeParamsInput(value, displayName);
121
+ const record = repositoryChangeParamsRecord(value, displayName);
122
+ const text = (name: string) => {
123
+ const value = trimString(record[name]);
124
+ if (!value) throw new Error(`${displayName} requires ${name}`);
125
+ return value;
126
+ };
127
+ return {
128
+ ...shared,
129
+ ...(Object.fromEntries(fields.map((name) => [name, text(name)])) as Record<K, string>),
130
+ ...normalizeRepositoryIssueOrigin(record, displayName, text),
131
+ };
132
+ }
133
+
58
134
  /** @public */
59
135
  export function createRepositoryChangeParamsCodec<T extends RepositoryChangeParamsBase>(input: {
60
136
  /** @public */
@@ -1,10 +1,19 @@
1
+ export { parseRepositoryProfileBindings } from "./profile-bindings-internal.js";
1
2
  export type {
2
3
  NormalizedRepositoryChangeParamsInput,
3
4
  RepositoryChangeLaunchParams,
4
5
  RepositoryChangeParamsBase,
6
+ RepositoryIssueOriginParams,
7
+ RepositoryUiOriginParams,
5
8
  } from "./repository-change-launch-internal.js";
6
9
  export {
7
10
  createRepositoryChangeParamsCodec,
8
11
  normalizeRepositoryChangeParamsInput,
12
+ normalizeRepositoryIssueChangeParams,
13
+ normalizeRepositoryIssueOrigin,
9
14
  repositoryChangeParamsRecord,
10
15
  } from "./repository-change-launch-internal.js";
16
+ export {
17
+ createRepositoryChangeUiLauncher,
18
+ repositoryVisibilityCheck,
19
+ } from "./repository-change-ui-launcher-internal.js";
@@ -1,18 +1,23 @@
1
1
  import { asUnknownRecord } from "@leitwerk-dev/domain";
2
2
  import {
3
+ type AutomaticOutcomeBuilder,
3
4
  type ExternalActionSource,
4
5
  type FlowAutomaticRunContext,
5
6
  flow,
6
7
  } from "@leitwerk-dev/process-sdk";
7
- import {
8
- type ConflictEvidence,
9
- conflictKey,
10
- validateConflict,
11
- } from "@leitwerk-dev/repository-rebase";
12
- import { publishRebase, startRebase } from "@leitwerk-dev/repository-rebase/git";
13
- import { rebasePrompt } from "@leitwerk-dev/repository-rebase/prompt";
14
8
  import { commitAndPushWorkBranch, type GitIdentity } from "./finalization-git.js";
15
9
  import type { RepositoryChangeState } from "./repository-change-state.js";
10
+ import { publishRebase, startRebase } from "./repository-rebase/git.js";
11
+ import { type ConflictEvidence, conflictKey, validateConflict } from "./repository-rebase/index.js";
12
+ import { rebasePrompt } from "./repository-rebase/prompt.js";
13
+
14
+ export {
15
+ pullRequestPublicationCallbacks,
16
+ pullRequestPublicationSources,
17
+ readPullRequestFeedback,
18
+ reconcilePullRequestSourceIssue,
19
+ resolvePullRequestGitIdentity,
20
+ } from "./pull-request-publication-internal.js";
16
21
 
17
22
  /** @public */
18
23
  export interface PublicationRequest {
@@ -393,7 +398,6 @@ function deliveryProgress(value: PublicationState, label: string, activeStepId?:
393
398
  export function createRepositoryChangePublication<P extends PublicationParams>(
394
399
  adapter: RepositoryChangePublicationAdapter<P>,
395
400
  ) {
396
- const applyEvidence = applyPublicationEvidence;
397
401
  const ids = adapter.ids;
398
402
  const publication = flow.fragment<P, RepositoryChangeState>(`${adapter.namespace}-publication`);
399
403
  const remote = (state: RepositoryChangeState) => readPublicationState(state, adapter.namespace);
@@ -435,7 +439,7 @@ export function createRepositoryChangePublication<P extends PublicationParams>(
435
439
  if (current.pendingEvidence) {
436
440
  const evidence = current.pendingEvidence;
437
441
  const needsOperator = evidence.kind === "failure" && current.ciRecoveryCycles >= 3;
438
- current = applyEvidence(ctx.params, current, evidence, !needsOperator);
442
+ current = applyPublicationEvidence(ctx.params, current, evidence, !needsOperator);
439
443
  current.pendingEvidence = null;
440
444
  if (evidence.kind === "cancelled") return result("aborted");
441
445
  if (evidence.kind === "failure")
@@ -508,47 +512,27 @@ export function createRepositoryChangePublication<P extends PublicationParams>(
508
512
  update({ delivery: { stage: "awaiting" } });
509
513
  ctx.reportProgress(deliveryProgress(current, adapter.label, "await_evidence"));
510
514
  return result("awaiting");
511
- })
512
- .outcome("awaiting", (outcome) =>
513
- outcome
514
- .description("Delivery is waiting for external evidence")
515
- .object("nextState")
516
- .wait()
517
- .state(({ event }) => event.params.nextState as RepositoryChangeState),
518
- )
519
- .outcome("feedback_ready", (outcome) =>
520
- outcome
521
- .description("Pull request feedback is acknowledged and ready for revision")
522
- .object("nextState")
523
- .to(ids.feedback)
524
- .state(({ event }) => event.params.nextState as RepositoryChangeState),
525
- )
526
- .outcome("completed", (outcome) =>
527
- outcome
528
- .description("Merged pull request was reconciled")
529
- .object("nextState")
530
- .complete()
531
- .state(({ event }) => event.params.nextState as RepositoryChangeState),
515
+ });
516
+ const outcome = (o: AutomaticOutcomeBuilder<P, RepositoryChangeState>, description: string) =>
517
+ o
518
+ .description(description)
519
+ .object("nextState")
520
+ .state(({ event }) => event.params.nextState as RepositoryChangeState);
521
+ delivery
522
+ .outcome("awaiting", (o) => outcome(o, "Delivery is waiting for external evidence").wait())
523
+ .outcome("feedback_ready", (o) =>
524
+ outcome(o, "Pull request feedback is acknowledged and ready for revision").to(ids.feedback),
532
525
  )
533
- .outcome("aborted", (outcome) =>
534
- outcome
535
- .description("Closed pull request was reconciled")
536
- .object("nextState")
537
- .lifecycleStatus("aborted")
538
- .state(({ event }) => event.params.nextState as RepositoryChangeState),
526
+ .outcome("completed", (o) => outcome(o, "Merged pull request was reconciled").complete())
527
+ .outcome("aborted", (o) =>
528
+ outcome(o, "Closed pull request was reconciled").lifecycleStatus("aborted"),
539
529
  );
540
- for (const [outcome, target] of [
530
+ for (const [name, target] of [
541
531
  ["ci_ready", ids.ciRepair],
542
532
  ["conflict_ready", ids.feedback],
543
533
  ["operator_action", ids.operator],
544
534
  ] as const) {
545
- delivery.outcome(outcome, (o) =>
546
- o
547
- .description("Route observed delivery evidence")
548
- .object("nextState")
549
- .to(target)
550
- .state(({ event }) => event.params.nextState as RepositoryChangeState),
551
- );
535
+ delivery.outcome(name, (o) => outcome(o, "Route observed delivery evidence").to(target));
552
536
  }
553
537
  for (const source of adapter.sources) {
554
538
  const attach = (id: string, operator: boolean) =>
@@ -578,7 +562,7 @@ export function createRepositoryChangePublication<P extends PublicationParams>(
578
562
  input.state,
579
563
  source.kind === "observation"
580
564
  ? { pendingEvidence: evidence }
581
- : applyEvidence(input.params, current, evidence, !operator),
565
+ : applyPublicationEvidence(input.params, current, evidence, !operator),
582
566
  ),
583
567
  };
584
568
  });