@defrex/autobuild 1.6.0 → 1.8.0
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/README.md +1 -1
- package/SPEC.md +423 -57
- package/docs/agent-runtimes.md +1 -1
- package/docs/answering-blocked-builds.md +44 -3
- package/docs/architecture.md +124 -29
- package/docs/cli.md +1 -0
- package/docs/configuration-overview.md +11 -1
- package/docs/configuration.md +334 -14
- package/docs/dispatcher.md +1 -1
- package/docs/forges.md +1 -0
- package/docs/integration-overview.md +2 -2
- package/docs/integration-tree.md +7 -4
- package/docs/merge-policy.md +78 -6
- package/docs/migration-1.0.md +4 -2
- package/docs/operating.md +3 -2
- package/docs/operator-api.md +45 -13
- package/docs/operator-surfaces.md +16 -3
- package/docs/plugin-authoring.md +45 -7
- package/docs/remote-store-protocol.md +28 -7
- package/docs/restacking.md +35 -11
- package/docs/ticket-dependencies.md +9 -4
- package/docs/ticket-sources.md +34 -6
- package/docs/tickets.md +7 -1
- package/docs/troubleshooting.md +1 -1
- package/docs/workspaces.md +1 -1
- package/package.json +3 -3
- package/packages/core/src/cli/attention.ts +2 -0
- package/packages/core/src/cli/binary-direct.ts +1 -0
- package/packages/core/src/cli/build-control.ts +65 -7
- package/packages/core/src/cli/context.ts +55 -14
- package/packages/core/src/cli/dashboard/actions.ts +13 -4
- package/packages/core/src/cli/dashboard/landing-display.ts +32 -8
- package/packages/core/src/cli/dashboard/model.ts +61 -8
- package/packages/core/src/cli/dashboard/render.ts +28 -3
- package/packages/core/src/cli/dashboard/tree.ts +9 -1
- package/packages/core/src/cli/dispatch-frontend.ts +10 -14
- package/packages/core/src/cli/dispatch-preflight.ts +1 -0
- package/packages/core/src/cli/dispatch-repository-feed.ts +145 -109
- package/packages/core/src/cli/dispatch.ts +9 -3
- package/packages/core/src/cli/help.ts +80 -11
- package/packages/core/src/cli/init-validation.ts +14 -1
- package/packages/core/src/cli/landings.ts +1 -1
- package/packages/core/src/cli/main.ts +60 -9
- package/packages/core/src/cli/publication-settlement.ts +10 -0
- package/packages/core/src/cli/repository-status.ts +37 -2
- package/packages/core/src/cli/status.ts +186 -12
- package/packages/core/src/cli/terminals.ts +197 -4
- package/packages/core/src/cli/ticket.ts +22 -4
- package/packages/core/src/cli/wait.ts +1 -0
- package/packages/core/src/cli/watch.ts +73 -0
- package/packages/core/src/config/landing.ts +12 -0
- package/packages/core/src/config/live.ts +4 -0
- package/packages/core/src/config/path-selectors.ts +68 -0
- package/packages/core/src/config/profiles.ts +96 -0
- package/packages/core/src/config/ready-assignee.ts +43 -11
- package/packages/core/src/config/roles.ts +33 -10
- package/packages/core/src/config/schema.ts +205 -81
- package/packages/core/src/events/catalog.ts +17 -3
- package/packages/core/src/events/compatibility.ts +4 -1
- package/packages/core/src/events/forge-degradation-policy.ts +16 -2
- package/packages/core/src/events/head-paths-limits.ts +25 -0
- package/packages/core/src/events/payloads.ts +323 -20
- package/packages/core/src/events/policy.ts +22 -0
- package/packages/core/src/events/repository.ts +47 -1
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +320 -130
- package/packages/core/src/kernel/build-creation.ts +29 -0
- package/packages/core/src/kernel/consent-revocation.ts +72 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +19 -8
- package/packages/core/src/kernel/engine.ts +48 -8
- package/packages/core/src/kernel/forge-health.ts +47 -0
- package/packages/core/src/kernel/guarded-forge.ts +76 -18
- package/packages/core/src/kernel/head-paths-state.ts +63 -0
- package/packages/core/src/kernel/head-paths.ts +401 -0
- package/packages/core/src/kernel/landing-policy-identity.ts +20 -0
- package/packages/core/src/kernel/landing-policy.ts +55 -2
- package/packages/core/src/kernel/landing-readiness.ts +104 -9
- package/packages/core/src/kernel/landing-state.ts +44 -4
- package/packages/core/src/kernel/leaf-restack-state.ts +50 -2
- package/packages/core/src/kernel/log-index.ts +27 -1
- package/packages/core/src/kernel/node-parent.ts +2 -0
- package/packages/core/src/kernel/node-polling.ts +13 -3
- package/packages/core/src/kernel/node-restack-state.ts +8 -1
- package/packages/core/src/kernel/node-restack-transaction.ts +45 -0
- package/packages/core/src/kernel/read-deferrals.ts +3 -1
- package/packages/core/src/kernel/read-facts.ts +37 -2
- package/packages/core/src/kernel/reducer-registry.ts +22 -1
- package/packages/core/src/kernel/reducer.ts +332 -16
- package/packages/core/src/kernel/target-observation.ts +2 -5
- package/packages/core/src/kernel/terminal-guard.ts +52 -3
- package/packages/core/src/kernel/ticket-handbacks.ts +40 -0
- package/packages/core/src/kernel/ticket-preparation.ts +15 -1
- package/packages/core/src/kernel/ticket-wait.ts +345 -0
- package/packages/core/src/kernel/verify-applicability.ts +9 -19
- package/packages/core/src/ontology.ts +1 -0
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/index.ts +3 -0
- package/packages/core/src/operator/protocol.ts +25 -2
- package/packages/core/src/operator/query.ts +1 -1
- package/packages/core/src/operator/registry.ts +122 -10
- package/packages/core/src/operator/repository-events.ts +67 -0
- package/packages/core/src/operator/sandbox-host.ts +3 -0
- package/packages/core/src/operator/tickets.ts +15 -3
- package/packages/core/src/plugin-sdk/index.ts +4 -0
- package/packages/core/src/ports/forge/create.ts +6 -0
- package/packages/core/src/ports/forge/github-transport.ts +40 -3
- package/packages/core/src/ports/forge/github.ts +12 -1
- package/packages/core/src/ports/forge/workspace-ancestry.ts +60 -0
- package/packages/core/src/ports/forge-failure.ts +31 -2
- package/packages/core/src/ports/runner/routing.ts +66 -5
- package/packages/core/src/ports/tickets/assignees.ts +54 -0
- package/packages/core/src/ports/tickets/contract.ts +164 -4
- package/packages/core/src/ports/tickets/create.ts +17 -3
- package/packages/core/src/ports/tickets/fake.ts +5 -0
- package/packages/core/src/ports/tickets/github-fake.ts +18 -2
- package/packages/core/src/ports/tickets/github.ts +247 -29
- package/packages/core/src/ports/tickets/hosted-index.ts +1 -0
- package/packages/core/src/ports/tickets/operations.ts +6 -1
- package/packages/core/src/ports/tickets/tree.ts +12 -2
- package/packages/core/src/ports/tickets/update.ts +6 -2
- package/packages/core/src/ports/types.ts +36 -5
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +9 -0
- package/packages/core/src/processes/build-child.ts +28 -7
- package/packages/core/src/processes/build-execution-state.ts +34 -2
- package/packages/core/src/processes/build-runner.ts +165 -19
- package/packages/core/src/processes/dispatcher.ts +837 -115
- package/packages/core/src/processes/execution-no-progress.ts +22 -2
- package/packages/core/src/processes/harvest-child.ts +4 -0
- package/packages/core/src/processes/harvest-runner.ts +5 -0
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/publication-state.ts +6 -1
- package/packages/core/src/processes/repo-view.ts +2 -0
- package/packages/core/src/scenarios/harness.ts +15 -1
- package/packages/core/src/store/digest.ts +41 -2
- package/packages/core/src/store/reduced-reads.ts +4 -1
- package/packages/core/src/store/reducer-value-shapes.json +10310 -8441
- package/packages/core/src/store/remote/client.ts +49 -10
- package/packages/core/src/store/remote/index.ts +4 -0
- package/packages/core/src/store/remote/protocol.ts +18 -1
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.7.0.json +27366 -0
- package/packages/core/src/store/remote/released-reducer-values/1.8.0.json +29043 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +4 -0
- package/packages/core/src/store/repo-state-events.ts +3 -0
- package/packages/core/src/store/types.ts +27 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +84 -58
- package/packages/core/src/testing/index.ts +2 -0
- package/packages/core/src/testing/reduced-read-budget.ts +419 -9
- package/skills/code-review/SKILL.md +8 -0
- package/skills/finalize/SKILL.md +4 -0
- package/skills/guide/SKILL.md +241 -47
- package/skills/guide/references/integration-tree.md +7 -4
- package/skills/guide/references/merge-policy.md +78 -6
- package/skills/guide/references/migration-1.0.md +4 -2
- package/skills/guide/references/operator-api.md +45 -13
- package/skills/guide/references/plugin-authoring.md +45 -7
- package/skills/guide/references/remote-store-protocol.md +28 -7
- package/skills/guide/references/restacking.md +35 -11
- package/skills/guide/references/ticket-dependencies.md +9 -4
- package/skills/implement/SKILL.md +15 -1
- package/skills/operate/SKILL.md +133 -16
- package/skills/plan/SKILL.md +17 -2
- package/skills/plan-review/SKILL.md +8 -0
- package/skills/reconcile/SKILL.md +21 -5
- package/skills/tickets/SKILL.md +23 -6
- package/templates/hosted-service/package.json +2 -2
|
@@ -5,6 +5,7 @@ import { createForge } from '../ports/forge/create'
|
|
|
5
5
|
import { compatibleTicketSource, type TicketTreeEntry } from '../ports/tickets/tree'
|
|
6
6
|
import { formatIssueLinks, parseIssueLinkList } from '../ports/tickets/issue-links'
|
|
7
7
|
import { parsePriorityFlag, ticketPriority } from '../ports/tickets/priority'
|
|
8
|
+
import { creationAssignees, parseAssigneesFlag } from '../ports/tickets/assignees'
|
|
8
9
|
import { parseIssueId, rejectedStateOf } from '../ports/tickets/github-issues'
|
|
9
10
|
import { readBuildDigests, readBuildFacts } from '../store/reduced-reads'
|
|
10
11
|
import type { TicketRef } from '../ontology'
|
|
@@ -106,6 +107,9 @@ export interface TicketCreateOpts extends TicketCommandOpts {
|
|
|
106
107
|
issueLinks?: import('../ports/types').IssueLink[]
|
|
107
108
|
/** Dispatch class; a source without priority support refuses `urgent`. */
|
|
108
109
|
priority?: import('../ports/types').TicketPriority
|
|
110
|
+
/** Usernames or `me`; replaces the `[tickets].createAssignee` default, and
|
|
111
|
+
* an explicit [] creates an unassigned ticket. Sources without support refuse. */
|
|
112
|
+
assignees?: string[]
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
export interface TicketUpdateOpts extends TicketCommandOpts {
|
|
@@ -122,6 +126,8 @@ export interface TicketUpdateOpts extends TicketCommandOpts {
|
|
|
122
126
|
issueLinks?: import('../ports/types').IssueLink[]
|
|
123
127
|
/** `normal` removes urgency; a source without priority support refuses `urgent`. */
|
|
124
128
|
priority?: import('../ports/types').TicketPriority
|
|
129
|
+
/** Complete assignee replacement (usernames or `me`). An explicit [] clears. */
|
|
130
|
+
assignees?: string[]
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
export interface TicketBlockerOpts extends TicketCommandOpts {
|
|
@@ -368,6 +374,7 @@ function ticketDetail(
|
|
|
368
374
|
lines.push(` blocked by: ${blockers.join(', ')}`)
|
|
369
375
|
}
|
|
370
376
|
if (ticket.issueLinks?.length) lines.push(` issues: ${formatIssueLinks(ticket.issueLinks)}`)
|
|
377
|
+
if (ticket.assignees?.length) lines.push(` assignees: ${ticket.assignees.join(', ')}`)
|
|
371
378
|
if (ticket.ref.url !== undefined) lines.push(` url: ${ticket.ref.url}`)
|
|
372
379
|
if (assets.length > 0) lines.push(' assets:', ...assets.map(assetLine))
|
|
373
380
|
lines.push(' body:')
|
|
@@ -386,7 +393,8 @@ function emitTicketJson(opts: TicketCommandOpts, ticket: Ticket): void {
|
|
|
386
393
|
export async function abTicketCreate(opts: TicketCreateOpts): Promise<void> {
|
|
387
394
|
// Read the complete body before constructing or calling a mutable source.
|
|
388
395
|
const body = await readBody(opts.bodyFile)
|
|
389
|
-
const { source } = await resolveTicketCommand(opts, 'create')
|
|
396
|
+
const { source, config } = await resolveTicketCommand(opts, 'create')
|
|
397
|
+
const assignees = creationAssignees(config.tickets, opts.assignees)
|
|
390
398
|
|
|
391
399
|
const ticket = await createTicket(
|
|
392
400
|
source,
|
|
@@ -399,6 +407,7 @@ export async function abTicketCreate(opts: TicketCreateOpts): Promise<void> {
|
|
|
399
407
|
...(opts.blockedBy !== undefined ? { blockedBy: opts.blockedBy } : {}),
|
|
400
408
|
...(opts.issueLinks !== undefined ? { issueLinks: opts.issueLinks } : {}),
|
|
401
409
|
...(opts.priority !== undefined ? { priority: opts.priority } : {}),
|
|
410
|
+
...(assignees !== undefined ? { assignees } : {}),
|
|
402
411
|
...(opts.state !== undefined ? { state: opts.state } : {}),
|
|
403
412
|
},
|
|
404
413
|
{
|
|
@@ -418,8 +427,9 @@ export async function abTicketCreate(opts: TicketCreateOpts): Promise<void> {
|
|
|
418
427
|
: ''
|
|
419
428
|
const issues = ticket.issueLinks?.length ? ` — ${formatIssueLinks(ticket.issueLinks)}` : ''
|
|
420
429
|
const urgent = ticket.priority === 'urgent' ? ' — urgent' : ''
|
|
430
|
+
const assigned = ticket.assignees?.length ? ` — assigned to ${ticket.assignees.join(', ')}` : ''
|
|
421
431
|
opts.stdout(
|
|
422
|
-
`ticket created: ${ticket.ref.source}:${ticket.ref.id} (${state})${urgent}${blockers}${issues}${url}`,
|
|
432
|
+
`ticket created: ${ticket.ref.source}:${ticket.ref.id} (${state})${urgent}${assigned}${blockers}${issues}${url}`,
|
|
423
433
|
)
|
|
424
434
|
}
|
|
425
435
|
|
|
@@ -434,6 +444,7 @@ export async function abTicketUpdate(opts: TicketUpdateOpts): Promise<void> {
|
|
|
434
444
|
...(opts.labels !== undefined ? { labels: [...opts.labels] } : {}),
|
|
435
445
|
...(opts.issueLinks !== undefined ? { issueLinks: [...opts.issueLinks] } : {}),
|
|
436
446
|
...(opts.priority !== undefined ? { priority: opts.priority } : {}),
|
|
447
|
+
...(opts.assignees !== undefined ? { assignees: [...opts.assignees] } : {}),
|
|
437
448
|
}
|
|
438
449
|
const updated =
|
|
439
450
|
patch.target === undefined
|
|
@@ -931,9 +942,9 @@ export async function abTicketStateCreate(opts: TicketStateCreateOpts): Promise<
|
|
|
931
942
|
}
|
|
932
943
|
|
|
933
944
|
const CREATE_USAGE =
|
|
934
|
-
'usage: ab ticket create <title> --body <file> [--state <state>] [--labels a,b] [--blocked-by id,id] [--issues N[:refs],...] [--priority urgent|normal] [--kind work|node] [--target <id> | --no-target] [--json] (§8.8)'
|
|
945
|
+
'usage: ab ticket create <title> --body <file> [--state <state>] [--labels a,b] [--blocked-by id,id] [--issues N[:refs],...] [--priority urgent|normal] [--assignees a,b] [--kind work|node] [--target <id> | --no-target] [--json] (§8.8)'
|
|
935
946
|
const UPDATE_USAGE =
|
|
936
|
-
'usage: ab ticket update <id> [--kind work|node] [--target <id> | --no-target] [--title <title>] [--body <file>] [--labels a,b] [--issues N[:refs],...] [--priority urgent|normal] [--expected-revision <opaque>] [--json] (§8.8)'
|
|
947
|
+
'usage: ab ticket update <id> [--kind work|node] [--target <id> | --no-target] [--title <title>] [--body <file>] [--labels a,b] [--issues N[:refs],...] [--priority urgent|normal] [--assignees a,b] [--expected-revision <opaque>] [--json] (§8.8)'
|
|
937
948
|
const BLOCK_USAGE =
|
|
938
949
|
'usage: ab ticket block <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json] (§8.8)'
|
|
939
950
|
const UNBLOCK_USAGE =
|
|
@@ -1065,6 +1076,7 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
1065
1076
|
'blocked-by': 'value',
|
|
1066
1077
|
issues: 'value',
|
|
1067
1078
|
priority: 'value',
|
|
1079
|
+
assignees: 'value',
|
|
1068
1080
|
json: 'boolean',
|
|
1069
1081
|
},
|
|
1070
1082
|
TICKET_USAGE,
|
|
@@ -1080,6 +1092,7 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
1080
1092
|
const blockedBy = stringFlag(parsed, 'blocked-by')
|
|
1081
1093
|
const issues = stringFlag(parsed, 'issues')
|
|
1082
1094
|
const priority = stringFlag(parsed, 'priority')
|
|
1095
|
+
const assignees = stringFlag(parsed, 'assignees')
|
|
1083
1096
|
await abTicketCreate({
|
|
1084
1097
|
...opts,
|
|
1085
1098
|
...metadataFlags(parsed),
|
|
@@ -1090,6 +1103,7 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
1090
1103
|
...(blockedBy !== undefined ? { blockedBy: commaList(blockedBy) } : {}),
|
|
1091
1104
|
...(issues !== undefined ? { issueLinks: parseIssueLinkList(issues) } : {}),
|
|
1092
1105
|
...(priority !== undefined ? { priority: parsePriorityFlag(priority) } : {}),
|
|
1106
|
+
...(assignees !== undefined ? { assignees: parseAssigneesFlag(assignees) } : {}),
|
|
1093
1107
|
json: parsed.flags.has('json'),
|
|
1094
1108
|
})
|
|
1095
1109
|
return
|
|
@@ -1114,6 +1128,7 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
1114
1128
|
labels: 'value',
|
|
1115
1129
|
issues: 'value',
|
|
1116
1130
|
priority: 'value',
|
|
1131
|
+
assignees: 'value',
|
|
1117
1132
|
'expected-revision': 'value',
|
|
1118
1133
|
json: 'boolean',
|
|
1119
1134
|
},
|
|
@@ -1126,6 +1141,7 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
1126
1141
|
'labels',
|
|
1127
1142
|
'issues',
|
|
1128
1143
|
'priority',
|
|
1144
|
+
'assignees',
|
|
1129
1145
|
'kind',
|
|
1130
1146
|
'target',
|
|
1131
1147
|
'no-target',
|
|
@@ -1138,6 +1154,7 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
1138
1154
|
const labels = stringFlag(parsed, 'labels')
|
|
1139
1155
|
const issues = stringFlag(parsed, 'issues')
|
|
1140
1156
|
const priority = stringFlag(parsed, 'priority')
|
|
1157
|
+
const assignees = stringFlag(parsed, 'assignees')
|
|
1141
1158
|
if (bodyFile !== undefined && bodyFile.trim() === '') {
|
|
1142
1159
|
throw new Error(TICKET_USAGE)
|
|
1143
1160
|
}
|
|
@@ -1151,6 +1168,7 @@ export async function abTicket(argv: string[], opts: TicketCliOpts): Promise<voi
|
|
|
1151
1168
|
...(labels !== undefined ? { labels: commaList(labels) } : {}),
|
|
1152
1169
|
...(issues !== undefined ? { issueLinks: parseIssueLinkList(issues) } : {}),
|
|
1153
1170
|
...(priority !== undefined ? { priority: parsePriorityFlag(priority) } : {}),
|
|
1171
|
+
...(assignees !== undefined ? { assignees: parseAssigneesFlag(assignees) } : {}),
|
|
1154
1172
|
json: parsed.flags.has('json'),
|
|
1155
1173
|
})
|
|
1156
1174
|
return
|
|
@@ -518,6 +518,7 @@ export async function abWait(opts: AbWaitOpts): Promise<number> {
|
|
|
518
518
|
event.type === 'integration.landed' ||
|
|
519
519
|
event.type === 'integration.verification-failed' ||
|
|
520
520
|
event.type === 'node.item-conflicted' ||
|
|
521
|
+
event.type === 'landing.consent-revoked' ||
|
|
521
522
|
(event.type === 'restack.replayed' && event.payload.conflicted)
|
|
522
523
|
)
|
|
523
524
|
return conditions
|
|
@@ -65,6 +65,14 @@ import {
|
|
|
65
65
|
type PersistenceObservation,
|
|
66
66
|
} from './attention'
|
|
67
67
|
import type { BuildState, PrLifecycle } from '../kernel/reducer'
|
|
68
|
+
import {
|
|
69
|
+
ticketWaitStatus,
|
|
70
|
+
waitEndedText,
|
|
71
|
+
waitingOnLine,
|
|
72
|
+
waitRefusedText,
|
|
73
|
+
waitRequestedText,
|
|
74
|
+
type TicketWaitStatus,
|
|
75
|
+
} from '../kernel/ticket-wait'
|
|
68
76
|
import { buildReducer } from '../kernel/reducer'
|
|
69
77
|
import type { BuildOutcome, BuildStatus, Phase } from '../ontology'
|
|
70
78
|
import type { Exec } from '../ports/workspace/git-worktree'
|
|
@@ -120,6 +128,7 @@ export const BUILD_ATTENTION_EVENTS = [
|
|
|
120
128
|
'integration.landed',
|
|
121
129
|
'integration.verification-failed',
|
|
122
130
|
'node.item-conflicted',
|
|
131
|
+
'landing.consent-revoked',
|
|
123
132
|
] as const satisfies readonly EventType[]
|
|
124
133
|
|
|
125
134
|
// ── Glob compilation and matching ────────────────────────────────────────────
|
|
@@ -317,6 +326,8 @@ export interface WatchRecordState {
|
|
|
317
326
|
pr: { number: number; url: string; headSha: string } | null
|
|
318
327
|
prState: PrLifecycle | null
|
|
319
328
|
outcome: BuildOutcome | null
|
|
329
|
+
/** The ticket wait while requested, open, or ended and not yet resumed. */
|
|
330
|
+
wait?: TicketWaitStatus
|
|
320
331
|
}
|
|
321
332
|
|
|
322
333
|
/** Lease-expiry evidence is an observation, never a fabricated journal event. */
|
|
@@ -382,6 +393,7 @@ export interface WatchRecord {
|
|
|
382
393
|
}
|
|
383
394
|
|
|
384
395
|
function projectState(state: BuildState): WatchRecordState {
|
|
396
|
+
const wait = ticketWaitStatus(state)
|
|
385
397
|
return {
|
|
386
398
|
status: state.status,
|
|
387
399
|
phase: state.phase ?? null,
|
|
@@ -403,6 +415,7 @@ function projectState(state: BuildState): WatchRecordState {
|
|
|
403
415
|
pr: state.pr ?? null,
|
|
404
416
|
prState: state.prState ?? null,
|
|
405
417
|
outcome: state.outcome ?? null,
|
|
418
|
+
...(wait !== undefined ? { wait } : {}),
|
|
406
419
|
}
|
|
407
420
|
}
|
|
408
421
|
|
|
@@ -441,6 +454,13 @@ const SUMMARY_MAX = 200
|
|
|
441
454
|
*/
|
|
442
455
|
export function summarizeEvent(event: AbEvent | RepositoryEvent, state: BuildState | null): string {
|
|
443
456
|
switch (event.type) {
|
|
457
|
+
case 'landing.consent-revoked': {
|
|
458
|
+
const p = event.payload
|
|
459
|
+
const more = p.paths.total - p.paths.preview.length
|
|
460
|
+
return singleLine(
|
|
461
|
+
`Merge consent revoked for ${event.build}: reconcile edited files protected by merge[${p.rule.index}] (${p.paths.preview.join(', ')}${more > 0 ? `, +${more} more` : ''}); head ${p.previousHead} → ${p.head}; re-review and run ab merge ${event.build}`,
|
|
462
|
+
)
|
|
463
|
+
}
|
|
444
464
|
case 'target.rewritten':
|
|
445
465
|
return `Upstream rewrite on ${event.payload.branch}: ${event.payload.previousSha} → ${event.payload.sha}; automatic adoption withheld`
|
|
446
466
|
case 'verify.cancelled':
|
|
@@ -459,6 +479,18 @@ export function summarizeEvent(event: AbEvent | RepositoryEvent, state: BuildSta
|
|
|
459
479
|
return `Account credentials recovered: ${JSON.stringify(event.payload.name)}`
|
|
460
480
|
case 'dispatcher.forge-recovered':
|
|
461
481
|
return `Forge recovered: ${event.payload.forge}`
|
|
482
|
+
case 'forge.credential-limited':
|
|
483
|
+
return `Forge request limited for ${event.payload.process} (${event.payload.credential}${event.payload.missingCredential ? `: ${singleLine(event.payload.missingCredential)}` : ''}); reset ${event.payload.resetAt}; dispatcher forge work continues`
|
|
484
|
+
case 'ticket.handed-back': {
|
|
485
|
+
const p = event.payload
|
|
486
|
+
const details = [
|
|
487
|
+
`${p.cause}${p.build !== undefined ? ` of build ${p.build}` : ''}`,
|
|
488
|
+
...(p.requested !== undefined ? [`requested ${p.requested}`] : []),
|
|
489
|
+
...(p.missing !== undefined ? [`missing: ${p.missing.join('; ')}`] : []),
|
|
490
|
+
...(p.reason !== undefined ? [`reason: ${p.reason}`] : []),
|
|
491
|
+
]
|
|
492
|
+
return singleLine(`ticket ${p.ticket.id} handed back to ${p.state} (${details.join('; ')})`)
|
|
493
|
+
}
|
|
462
494
|
case 'dispatcher.kernel-git-unavailable':
|
|
463
495
|
return `Kernel Git unavailable (${event.payload.executable}): ${singleLine(event.payload.detail)}`
|
|
464
496
|
case 'dispatcher.kernel-git-recovered':
|
|
@@ -469,6 +501,47 @@ export function summarizeEvent(event: AbEvent | RepositoryEvent, state: BuildSta
|
|
|
469
501
|
return `${event.payload.id}: ${singleLine(event.payload.question)}`
|
|
470
502
|
case 'build.compatibility-deferred':
|
|
471
503
|
return event.payload.diagnostic
|
|
504
|
+
case 'wait.requested':
|
|
505
|
+
return singleLine(waitRequestedText(event.payload.tickets, event.payload.reason))
|
|
506
|
+
case 'wait.refused':
|
|
507
|
+
return singleLine(
|
|
508
|
+
waitRefusedText(event.payload.tickets, event.payload.cause, event.payload.message),
|
|
509
|
+
)
|
|
510
|
+
case 'wait.entered':
|
|
511
|
+
return singleLine(
|
|
512
|
+
waitingOnLine(
|
|
513
|
+
event.payload.tickets.map((ticket) => ticket.id),
|
|
514
|
+
event.payload.reason,
|
|
515
|
+
),
|
|
516
|
+
)
|
|
517
|
+
case 'wait.ended':
|
|
518
|
+
return singleLine(
|
|
519
|
+
waitEndedText(
|
|
520
|
+
{
|
|
521
|
+
id: event.payload.id,
|
|
522
|
+
tickets:
|
|
523
|
+
state?.wait?.id === event.payload.id
|
|
524
|
+
? state.wait.tickets.map((ticket) => ticket.id)
|
|
525
|
+
: undefined,
|
|
526
|
+
},
|
|
527
|
+
event.payload.cause,
|
|
528
|
+
event.payload.message,
|
|
529
|
+
),
|
|
530
|
+
)
|
|
531
|
+
case 'escalation.answered': {
|
|
532
|
+
// An operator answer to a wait's escalation is how that wait usually
|
|
533
|
+
// ends; the post-event state says whether this answer ended it.
|
|
534
|
+
const wait = state?.wait
|
|
535
|
+
if (wait?.escalation === event.payload.id && wait.ended?.seq === event.seq)
|
|
536
|
+
return singleLine(
|
|
537
|
+
waitEndedText(
|
|
538
|
+
{ id: wait.id, tickets: wait.tickets.map((ticket) => ticket.id) },
|
|
539
|
+
'operator',
|
|
540
|
+
event.payload.answer,
|
|
541
|
+
),
|
|
542
|
+
)
|
|
543
|
+
return summarizePayload(event.payload)
|
|
544
|
+
}
|
|
472
545
|
case 'phase.failed':
|
|
473
546
|
return `${event.payload.phase}${
|
|
474
547
|
event.payload.round !== undefined ? ` r${event.payload.round}` : ''
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
import { documentFields } from './reference-metadata'
|
|
3
|
+
import { pathSelectorSchema } from './path-selectors'
|
|
3
4
|
|
|
4
5
|
/** Ordered dispatcher-owned policy; omitted predicates are wildcards. */
|
|
5
6
|
export const landingRuleSchema = z.strictObject({
|
|
@@ -18,6 +19,14 @@ export const landingRuleSchema = z.strictObject({
|
|
|
18
19
|
'label must be nonblank (labels match exactly, including case)',
|
|
19
20
|
)
|
|
20
21
|
.optional(),
|
|
22
|
+
paths: z
|
|
23
|
+
.array(pathSelectorSchema)
|
|
24
|
+
.min(1, 'paths must contain at least one repository-relative glob')
|
|
25
|
+
.optional(),
|
|
26
|
+
within: z
|
|
27
|
+
.array(pathSelectorSchema)
|
|
28
|
+
.min(1, 'within must contain at least one repository-relative glob')
|
|
29
|
+
.optional(),
|
|
21
30
|
mode: z.enum(['auto', 'consent']),
|
|
22
31
|
})
|
|
23
32
|
export type LandingRule = z.infer<typeof landingRuleSchema>
|
|
@@ -26,5 +35,8 @@ documentFields(landingRuleSchema, {
|
|
|
26
35
|
into: 'Optional destination: `root`, any `node`, or an exact frozen destination node ticket id.',
|
|
27
36
|
from: 'Restrict this rule to one source build kind; omission matches all kinds.',
|
|
28
37
|
label: 'Optional exact, case-sensitive label on the source ticket. Blank labels are invalid.',
|
|
38
|
+
paths:
|
|
39
|
+
'Match when at least one changed path matches a selector. Same glob grammar and case sensitivity as `[verify.<step>].paths`.',
|
|
40
|
+
within: 'Match when every changed path matches a selector and at least one path changed.',
|
|
29
41
|
mode: 'Choose automatic merge or require recorded consent.',
|
|
30
42
|
})
|
|
@@ -29,6 +29,7 @@ export const CONFIG_RELOAD_CLASSIFICATION = {
|
|
|
29
29
|
verify: 'hot',
|
|
30
30
|
finalize: 'hot',
|
|
31
31
|
roles: 'hot',
|
|
32
|
+
profiles: 'hot',
|
|
32
33
|
accounts: 'hot',
|
|
33
34
|
policy: 'hot',
|
|
34
35
|
orchestrator: 'restart',
|
|
@@ -37,6 +38,7 @@ export const CONFIG_RELOAD_CLASSIFICATION = {
|
|
|
37
38
|
readyLabels: 'hot',
|
|
38
39
|
readyState: 'hot',
|
|
39
40
|
readyAssignee: 'hot',
|
|
41
|
+
createAssignee: 'hot',
|
|
40
42
|
teamKey: 'restart',
|
|
41
43
|
claimedState: 'restart',
|
|
42
44
|
createState: 'restart',
|
|
@@ -217,6 +219,7 @@ export class LiveConfig {
|
|
|
217
219
|
startup.roles,
|
|
218
220
|
startup.policy.sessionBudgetSeconds,
|
|
219
221
|
startup.accounts,
|
|
222
|
+
startup.profiles,
|
|
220
223
|
),
|
|
221
224
|
revision: 0,
|
|
222
225
|
}
|
|
@@ -299,6 +302,7 @@ export class LiveConfig {
|
|
|
299
302
|
config.roles,
|
|
300
303
|
config.policy.sessionBudgetSeconds,
|
|
301
304
|
config.accounts,
|
|
305
|
+
config.profiles,
|
|
302
306
|
)
|
|
303
307
|
} catch (error) {
|
|
304
308
|
const message = error instanceof Error ? error.message : String(error)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { documentSchema } from './reference-metadata'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The intentionally small path-selector grammar (§16.1): positive,
|
|
6
|
+
* repository-relative globs with literal characters, `*`, `?`, and `**` only
|
|
7
|
+
* as a complete path segment. Reject every ambiguous/unsafe form at config
|
|
8
|
+
* load rather than allowing a typo to become a never-running safety gate.
|
|
9
|
+
*/
|
|
10
|
+
export function pathSelectorError(pattern: string): string | undefined {
|
|
11
|
+
if (pattern.length === 0) return 'path selectors must be nonempty'
|
|
12
|
+
if (pattern.includes('\0')) return 'path selectors must not contain NUL bytes'
|
|
13
|
+
if (pattern.startsWith('/') || /^[A-Za-z]:\//.test(pattern)) {
|
|
14
|
+
return 'path selectors must be repository-relative, not absolute'
|
|
15
|
+
}
|
|
16
|
+
if (pattern.includes('\\')) {
|
|
17
|
+
return 'path selectors use Git-style "/" separators; backslashes and escapes are unsupported'
|
|
18
|
+
}
|
|
19
|
+
if (pattern.startsWith('!')) {
|
|
20
|
+
return 'path selectors are positive globs; negation is unsupported'
|
|
21
|
+
}
|
|
22
|
+
if (/[[\]{}]/.test(pattern)) {
|
|
23
|
+
return 'path selectors support only literal characters, *, ?, and whole-segment **; character classes and brace expansion are unsupported'
|
|
24
|
+
}
|
|
25
|
+
if (/[?*+@!]\(/.test(pattern)) {
|
|
26
|
+
return 'path selectors support only literal characters, *, ?, and whole-segment **; extglobs are unsupported'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const segments = pattern.split('/')
|
|
30
|
+
if (segments.some((segment) => segment.length === 0)) {
|
|
31
|
+
return 'path selectors must not contain empty path segments'
|
|
32
|
+
}
|
|
33
|
+
if (segments.some((segment) => segment === '.' || segment === '..')) {
|
|
34
|
+
return 'path selectors must not contain "." or ".." traversal segments'
|
|
35
|
+
}
|
|
36
|
+
if (segments.some((segment) => segment.includes('**') && segment !== '**')) {
|
|
37
|
+
return 'the ** wildcard must occupy a complete path segment'
|
|
38
|
+
}
|
|
39
|
+
return undefined
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const pathSelectorSchema = z.string().superRefine((pattern, ctx) => {
|
|
43
|
+
const message = pathSelectorError(pattern)
|
|
44
|
+
if (message !== undefined) ctx.addIssue({ code: 'custom', message })
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
documentSchema(pathSelectorSchema, {
|
|
48
|
+
constraints:
|
|
49
|
+
'Positive repository-relative globs with literal characters, *, ?, and whole-segment ** only. No NUL, absolute paths, backslashes, negation, empty or traversal segments, character classes, brace expansion or extglobs.',
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Compile validated selectors into one any-match predicate. Fail-closed for
|
|
54
|
+
* direct callers: Bun.Glob is never asked to interpret syntax outside the
|
|
55
|
+
* documented subset. Matching is case-sensitive.
|
|
56
|
+
*/
|
|
57
|
+
export function compilePathSelectors(
|
|
58
|
+
selectors: readonly string[],
|
|
59
|
+
describe: (selector: string, error: string) => string = (selector, error) =>
|
|
60
|
+
`invalid path selector ${JSON.stringify(selector)}: ${error}`,
|
|
61
|
+
): (path: string) => boolean {
|
|
62
|
+
for (const selector of selectors) {
|
|
63
|
+
const error = pathSelectorError(selector)
|
|
64
|
+
if (error !== undefined) throw new Error(describe(selector, error))
|
|
65
|
+
}
|
|
66
|
+
const globs = selectors.map((selector) => new Bun.Glob(selector))
|
|
67
|
+
return (path) => globs.some((glob) => glob.match(path))
|
|
68
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Label-selected role profiles (SPEC §9).
|
|
3
|
+
*
|
|
4
|
+
* A `[profiles.<name>]` table names one ticket label and any number of role
|
|
5
|
+
* entries. A build whose ticket carries that label at claim records the
|
|
6
|
+
* profile on `build.created`; every later session of that build resolves its
|
|
7
|
+
* role through the profile's overlay of the CURRENT configuration.
|
|
8
|
+
*
|
|
9
|
+
* The overlay is a synthetic roles map: a profile entry's declared fields sit
|
|
10
|
+
* over `[roles.<role>]` (or over nothing when the repository does not declare
|
|
11
|
+
* the role), and the resolver then merges each field over `[roles.default]`
|
|
12
|
+
* exactly as it does for repository roles. An omitted field therefore falls
|
|
13
|
+
* back to `[roles.<role>]`, then `[roles.default]`; a declared `alternates`
|
|
14
|
+
* list, including `[]`, replaces the inherited list.
|
|
15
|
+
*
|
|
16
|
+
* Everything here is pure and in memory. Selection reads only the labels the
|
|
17
|
+
* ready scan already returned.
|
|
18
|
+
*/
|
|
19
|
+
import { defineEntry } from '../open-map'
|
|
20
|
+
import { displayName } from './roles'
|
|
21
|
+
import type { RoleConfig } from './schema'
|
|
22
|
+
|
|
23
|
+
export interface ProfileConfig {
|
|
24
|
+
label: string
|
|
25
|
+
roles: Record<string, RoleConfig>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Labels match case-insensitively after trimming, as forge and Linear labels do. */
|
|
29
|
+
export function normalizeProfileLabel(label: string): string {
|
|
30
|
+
return label.trim().toLowerCase()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The repository roles with one profile's entries overlaid. Keys stay intact
|
|
35
|
+
* end to end (`__proto__` included), and only fields an entry actually
|
|
36
|
+
* declares replace the repository role's value.
|
|
37
|
+
*/
|
|
38
|
+
export function profileRoles<T extends object>(
|
|
39
|
+
roles: Record<string, T>,
|
|
40
|
+
entries: Record<string, T>,
|
|
41
|
+
): Record<string, T> {
|
|
42
|
+
const overlaid: Record<string, T> = Object.create(null)
|
|
43
|
+
for (const key of Object.keys(roles)) defineEntry(overlaid, key, roles[key]!)
|
|
44
|
+
for (const key of Object.keys(entries)) {
|
|
45
|
+
const base = (Object.hasOwn(roles, key) ? roles[key]! : {}) as T
|
|
46
|
+
const merged = Object.create(null) as T
|
|
47
|
+
for (const [field, value] of Object.entries(base))
|
|
48
|
+
if (value !== undefined) defineEntry(merged as Record<string, unknown>, field, value)
|
|
49
|
+
for (const [field, value] of Object.entries(entries[key]!))
|
|
50
|
+
if (value !== undefined) defineEntry(merged as Record<string, unknown>, field, value)
|
|
51
|
+
defineEntry(overlaid, key, merged)
|
|
52
|
+
}
|
|
53
|
+
return overlaid
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type ProfileSelection =
|
|
57
|
+
| { kind: 'none' }
|
|
58
|
+
| { kind: 'selected'; name: string }
|
|
59
|
+
| { kind: 'conflict'; matches: { name: string; label: string }[] }
|
|
60
|
+
|
|
61
|
+
/** Which configured profile a ticket's labels select. Two or more distinct
|
|
62
|
+
* profiles matching is a conflict: profiles never combine. */
|
|
63
|
+
export function selectProfile(
|
|
64
|
+
profiles: Record<string, { label: string }> | undefined,
|
|
65
|
+
labels: readonly string[] | undefined,
|
|
66
|
+
): ProfileSelection {
|
|
67
|
+
if (profiles === undefined || labels === undefined || labels.length === 0) return { kind: 'none' }
|
|
68
|
+
const carried = new Set(labels.map(normalizeProfileLabel))
|
|
69
|
+
const matches: { name: string; label: string }[] = []
|
|
70
|
+
for (const name of Object.keys(profiles)) {
|
|
71
|
+
const label = profiles[name]!.label
|
|
72
|
+
if (normalizeProfileLabel(label).length === 0) continue
|
|
73
|
+
if (carried.has(normalizeProfileLabel(label))) matches.push({ name, label })
|
|
74
|
+
}
|
|
75
|
+
if (matches.length === 0) return { kind: 'none' }
|
|
76
|
+
if (matches.length === 1) return { kind: 'selected', name: matches[0]!.name }
|
|
77
|
+
matches.sort((left, right) => (left.name < right.name ? -1 : left.name > right.name ? 1 : 0))
|
|
78
|
+
return { kind: 'conflict', matches }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function andList(parts: readonly string[]): string {
|
|
82
|
+
if (parts.length <= 2) return parts.join(' and ')
|
|
83
|
+
return `${parts.slice(0, -1).join(', ')}, and ${parts[parts.length - 1]}`
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The scan diagnostic for a ready ticket left unclaimed by conflicting labels. */
|
|
87
|
+
export function profileConflictDiagnostic(
|
|
88
|
+
ticketId: string,
|
|
89
|
+
matches: readonly { name: string; label: string }[],
|
|
90
|
+
): string {
|
|
91
|
+
return (
|
|
92
|
+
`ticket ${ticketId}: labels ${andList(matches.map((m) => displayName(m.label)))} select ` +
|
|
93
|
+
`more than one profile (${matches.map((m) => displayName(m.name)).join(', ')}) — ` +
|
|
94
|
+
`remove all but one profile label to make it claimable`
|
|
95
|
+
)
|
|
96
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `[tickets].readyAssignee`
|
|
3
|
-
* with `readyAssignee = true`
|
|
4
|
-
*
|
|
2
|
+
* `[tickets].readyAssignee` and `[tickets].createAssignee` are ticket-source
|
|
3
|
+
* capabilities. A source opts in with `readyAssignee = true` (respectively
|
|
4
|
+
* `assignees = true`) on the constructed `TicketSource`; parse time can only
|
|
5
|
+
* check the builtins, because plugins load after config parse, so the
|
|
5
6
|
* registry-aware seams (`createTicketSource` and `LiveConfig` reloads) enforce
|
|
6
7
|
* the declaration for every source. The value forms below are the builtins'
|
|
7
8
|
* own rules; a plugin source enforces its own.
|
|
@@ -30,18 +31,27 @@ export const LINEAR_READY_ASSIGNEE: ReadyAssigneeForm = {
|
|
|
30
31
|
* placement, since older accounts predate the normalization rules; `ab init
|
|
31
32
|
* --validate` proves the user can actually be assigned.
|
|
32
33
|
*/
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
export function githubAssigneeForm(key: 'readyAssignee' | 'createAssignee'): ReadyAssigneeForm {
|
|
35
|
+
return {
|
|
36
|
+
accepts: (s) =>
|
|
37
|
+
s === 'me' || (s.length <= 39 && /^[A-Za-z0-9][A-Za-z0-9-]*(?:_[A-Za-z0-9]{3,8})?$/.test(s)),
|
|
38
|
+
message: `[tickets].${key} must be "me" (the owner of the GitHub credential) or a GitHub username (e.g. "octocat", or a managed user's "mona_acme") for source = "github"`,
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
export const GITHUB_READY_ASSIGNEE = githubAssigneeForm('readyAssignee')
|
|
43
|
+
export const GITHUB_CREATE_ASSIGNEE = githubAssigneeForm('createAssignee')
|
|
44
|
+
|
|
40
45
|
export function readyAssigneeUnsupported(source: string, plugin?: string): string {
|
|
41
46
|
const from = plugin !== undefined ? ` from plugin "${plugin}"` : ''
|
|
42
47
|
return `[tickets].readyAssignee: ticket source "${source}"${from} cannot filter ready tickets by assignee — remove readyAssignee (selected source: "${source}")`
|
|
43
48
|
}
|
|
44
49
|
|
|
50
|
+
export function createAssigneeUnsupported(source: string, plugin?: string): string {
|
|
51
|
+
const from = plugin !== undefined ? ` from plugin "${plugin}"` : ''
|
|
52
|
+
return `[tickets].createAssignee: ticket source "${source}"${from} cannot assign tickets — remove createAssignee (selected source: "${source}")`
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
/** Refuse `readyAssignee` for a constructed source that does not declare it. */
|
|
46
56
|
export function assertReadyAssigneeSupported(
|
|
47
57
|
tickets: TicketsConfig,
|
|
@@ -52,6 +62,16 @@ export function assertReadyAssigneeSupported(
|
|
|
52
62
|
throw new Error(readyAssigneeUnsupported(tickets.source, plugin))
|
|
53
63
|
}
|
|
54
64
|
|
|
65
|
+
/** Refuse `createAssignee` for a constructed source that cannot store assignees. */
|
|
66
|
+
export function assertCreateAssigneeSupported(
|
|
67
|
+
tickets: TicketsConfig,
|
|
68
|
+
source: TicketSource,
|
|
69
|
+
plugin?: string,
|
|
70
|
+
): void {
|
|
71
|
+
if (tickets.createAssignee !== undefined && source.assignees !== true)
|
|
72
|
+
throw new Error(createAssigneeUnsupported(tickets.source, plugin))
|
|
73
|
+
}
|
|
74
|
+
|
|
55
75
|
/**
|
|
56
76
|
* The reload check: synchronous and request-free, because `LiveConfig`
|
|
57
77
|
* refreshes at the head of a dispatcher tick. It decides from what
|
|
@@ -64,10 +84,21 @@ export function assertReadyAssigneeAccepted(tickets: TicketsConfig, source: Tick
|
|
|
64
84
|
if (refusal !== undefined) throw new Error(refusal)
|
|
65
85
|
}
|
|
66
86
|
|
|
87
|
+
/** The `createAssignee` reload check, synchronous and request-free like
|
|
88
|
+
* `assertReadyAssigneeAccepted`. */
|
|
89
|
+
export function assertCreateAssigneeAccepted(tickets: TicketsConfig, source: TicketSource): void {
|
|
90
|
+
assertCreateAssigneeSupported(tickets, source)
|
|
91
|
+
if (tickets.createAssignee === undefined) return
|
|
92
|
+
const refusal = source.createAssigneeRefusal?.(tickets.createAssignee)
|
|
93
|
+
if (refusal !== undefined) throw new Error(refusal)
|
|
94
|
+
}
|
|
95
|
+
|
|
67
96
|
/**
|
|
68
97
|
* Dispatcher startup, before the loop: prepare whatever a later `"me"` needs,
|
|
69
|
-
* whether or not `readyAssignee` is set, so no tick ever
|
|
70
|
-
*
|
|
98
|
+
* whether or not `readyAssignee` or `createAssignee` is set, so no tick ever
|
|
99
|
+
* resolves it (a harvest proposal filed under `createAssignee = "me"` reuses
|
|
100
|
+
* the prepared owner). A preparation failure fails startup only when the
|
|
101
|
+
* configuration needs it.
|
|
71
102
|
*/
|
|
72
103
|
export async function prepareReadyAssigneeForDispatch(
|
|
73
104
|
source: TicketSource,
|
|
@@ -77,10 +108,11 @@ export async function prepareReadyAssigneeForDispatch(
|
|
|
77
108
|
try {
|
|
78
109
|
await source.prepareReadyAssignee?.()
|
|
79
110
|
} catch (error) {
|
|
80
|
-
if (tickets.readyAssignee !== undefined) throw error
|
|
111
|
+
if (tickets.readyAssignee !== undefined || tickets.createAssignee !== undefined) throw error
|
|
81
112
|
warn(
|
|
82
113
|
`ticket source "${source.name}" could not prepare readyAssignee: ${error instanceof Error ? error.message : String(error)}`,
|
|
83
114
|
)
|
|
84
115
|
}
|
|
85
116
|
assertReadyAssigneeAccepted(tickets, source)
|
|
117
|
+
assertCreateAssigneeAccepted(tickets, source)
|
|
86
118
|
}
|