@defrex/autobuild 1.11.1 → 1.13.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 +601 -203
- package/bin/ab-build-runner.ts +8 -0
- package/docs/answering-blocked-builds.md +32 -2
- package/docs/architecture.md +188 -57
- package/docs/assets/headline-wide.png +0 -0
- package/docs/cli.md +1 -1
- package/docs/configuration.md +120 -23
- package/docs/dispatcher.md +19 -8
- package/docs/integration-overview.md +1 -1
- package/docs/integration-tree.md +33 -18
- package/docs/merge-policy.md +7 -2
- package/docs/operating.md +5 -3
- package/docs/operator-api.md +48 -25
- package/docs/operator-surfaces.md +39 -3
- package/docs/optimization-nodes.md +10 -8
- package/docs/plugin-authoring.md +46 -18
- package/docs/remote-store-protocol.md +51 -12
- package/docs/remote-ticket-protocol.md +85 -38
- package/docs/restacking.md +48 -3
- package/docs/setup.md +2 -1
- package/docs/ticket-migration.md +2 -2
- package/docs/ticket-sources.md +23 -8
- package/docs/tickets.md +4 -4
- package/docs/troubleshooting.md +17 -2
- package/docs/verification.md +3 -1
- package/package.json +3 -3
- package/packages/core/src/cli/ambient-errors.ts +17 -0
- package/packages/core/src/cli/bounded-io.ts +174 -0
- package/packages/core/src/cli/build-control.ts +72 -6
- package/packages/core/src/cli/dashboard/actions.ts +4 -0
- package/packages/core/src/cli/dashboard/integration-row.ts +43 -19
- package/packages/core/src/cli/dashboard/model.ts +93 -29
- package/packages/core/src/cli/dashboard/poll.ts +231 -34
- package/packages/core/src/cli/dashboard/queue.ts +21 -10
- package/packages/core/src/cli/dashboard/render.ts +14 -37
- package/packages/core/src/cli/dashboard/row-text.ts +26 -8
- package/packages/core/src/cli/dashboard/tone-ansi.ts +39 -0
- package/packages/core/src/cli/dashboard/vocabulary.ts +165 -20
- package/packages/core/src/cli/dispatch-frontend.ts +2 -1
- package/packages/core/src/cli/dispatch-handoff.ts +41 -10
- package/packages/core/src/cli/dispatch-launch-contract.ts +5 -0
- package/packages/core/src/cli/dispatch-launcher-cadence.ts +80 -0
- package/packages/core/src/cli/dispatch-launcher.ts +9 -10
- package/packages/core/src/cli/dispatch-preflight.ts +12 -3
- package/packages/core/src/cli/dispatch-release-observer.ts +53 -0
- package/packages/core/src/cli/dispatch-runtime-cache.ts +204 -82
- package/packages/core/src/cli/dispatch-runtime-dependencies.ts +250 -43
- package/packages/core/src/cli/dispatch-tickets.ts +33 -12
- package/packages/core/src/cli/dispatch-upgrade-install.ts +36 -16
- package/packages/core/src/cli/dispatch-upgrade-source.ts +8 -2
- package/packages/core/src/cli/dispatch-yield-observer.ts +82 -0
- package/packages/core/src/cli/dispatch.ts +595 -149
- package/packages/core/src/cli/env.ts +2 -15
- package/packages/core/src/cli/help.ts +43 -28
- package/packages/core/src/cli/main.ts +11 -7
- package/packages/core/src/cli/production-store.ts +102 -0
- package/packages/core/src/cli/publication-settlement.ts +4 -0
- package/packages/core/src/cli/remote-poll.ts +22 -5
- package/packages/core/src/cli/repo-state.ts +2 -3
- package/packages/core/src/cli/repository-status.ts +44 -28
- package/packages/core/src/cli/sessionless-store.ts +26 -0
- package/packages/core/src/cli/status.ts +188 -47
- package/packages/core/src/cli/store-opening.ts +26 -57
- package/packages/core/src/cli/store-ref.ts +6 -1
- package/packages/core/src/cli/ticket-start.ts +3 -3
- package/packages/core/src/cli/ticket.ts +12 -11
- package/packages/core/src/cli/wait.ts +8 -28
- package/packages/core/src/cli/watch.ts +113 -50
- package/packages/core/src/config/reference-metadata.ts +7 -1
- package/packages/core/src/config/reference.ts +5 -2
- package/packages/core/src/config/schema.ts +51 -16
- package/packages/core/src/distribution-packaging.ts +156 -18
- package/packages/core/src/events/catalog-identity.ts +28 -0
- package/packages/core/src/events/catalog.ts +3 -9
- package/packages/core/src/events/compatibility.ts +2 -30
- package/packages/core/src/events/payloads.ts +85 -14
- package/packages/core/src/events/policy.ts +3 -0
- package/packages/core/src/events/repository.ts +15 -4
- package/packages/core/src/events/sessions.ts +1 -1
- package/packages/core/src/events/validation-error.ts +12 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +36 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/0a10010ee5cf2e47.json +577 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/227701361be6d1e0.json +490 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3064e337cc75f8d6.json +310 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/76e5043bae7a80ab.json +86 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/87a917802870bbed.json +87 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/9d85616e5b9e24c1.json +500 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a1e90a969d32a367.json +307 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/c7c94fbe7f63cf07.json +84 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/da3bc91c49211eab.json +310 -0
- package/packages/core/src/kernel/auto-merge-default.ts +2 -1
- package/packages/core/src/kernel/capacity-build.ts +21 -0
- package/packages/core/src/kernel/clean-restack-policy.ts +40 -0
- package/packages/core/src/kernel/discard-in-flight.ts +13 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +578 -235
- package/packages/core/src/kernel/done-escalations.ts +269 -0
- package/packages/core/src/kernel/engine.ts +30 -17
- package/packages/core/src/kernel/integration-landing.ts +24 -4
- package/packages/core/src/kernel/integration-stack.ts +39 -0
- package/packages/core/src/kernel/janitor-failure.ts +20 -1
- package/packages/core/src/kernel/log-index-value.ts +3 -0
- package/packages/core/src/kernel/log-index.ts +41 -2
- package/packages/core/src/kernel/measurement.ts +24 -0
- package/packages/core/src/kernel/open-pr-backpressure.ts +3 -3
- package/packages/core/src/kernel/read-facts.ts +8 -370
- package/packages/core/src/kernel/reducer-registry.ts +43 -125
- package/packages/core/src/kernel/reducer-revisions.ts +18 -0
- package/packages/core/src/kernel/reducer-value-entry.ts +98 -0
- package/packages/core/src/kernel/reducer-value-index.ts +75 -0
- package/packages/core/src/kernel/reducer.ts +84 -16
- package/packages/core/src/kernel/reopen-state.ts +10 -0
- package/packages/core/src/kernel/repository-attention.ts +14 -5
- package/packages/core/src/kernel/repository-read-facts.ts +375 -0
- package/packages/core/src/kernel/ticket-starts.ts +15 -4
- package/packages/core/src/kernel/verify-stage-state.ts +145 -3
- package/packages/core/src/kernel/verify-stages.ts +46 -7
- package/packages/core/src/operator/attention.ts +28 -3
- package/packages/core/src/operator/done-escalations.ts +38 -0
- package/packages/core/src/operator/presentation.ts +14 -1
- package/packages/core/src/operator/protocol.ts +8 -5
- package/packages/core/src/operator/query.ts +72 -57
- package/packages/core/src/operator/registry.ts +19 -15
- package/packages/core/src/operator/ticket-start.ts +8 -7
- package/packages/core/src/operator/tickets.ts +28 -9
- package/packages/core/src/plugin-sdk/index.ts +10 -0
- package/packages/core/src/plugins/manifest.ts +14 -1
- package/packages/core/src/ports/forge/create.ts +8 -0
- package/packages/core/src/ports/forge/github-transport.ts +5 -1
- package/packages/core/src/ports/forge/github.ts +3 -0
- package/packages/core/src/ports/tickets/contract.ts +147 -76
- package/packages/core/src/ports/tickets/create.ts +47 -7
- package/packages/core/src/ports/tickets/fake.ts +8 -4
- package/packages/core/src/ports/tickets/file-codec.ts +4 -3
- package/packages/core/src/ports/tickets/file.ts +7 -3
- package/packages/core/src/ports/tickets/github.ts +1 -0
- package/packages/core/src/ports/tickets/grants.ts +11 -3
- package/packages/core/src/ports/tickets/hosted-index.ts +5 -0
- package/packages/core/src/ports/tickets/linear.ts +28 -9
- package/packages/core/src/ports/tickets/migration.ts +4 -4
- package/packages/core/src/ports/tickets/operations.ts +4 -2
- package/packages/core/src/ports/tickets/priority-labels.ts +213 -0
- package/packages/core/src/ports/tickets/priority.ts +127 -21
- package/packages/core/src/ports/tickets/remote-protocol.ts +10 -0
- package/packages/core/src/ports/tickets/remote.ts +104 -11
- package/packages/core/src/ports/tickets/revision.ts +5 -3
- package/packages/core/src/ports/tickets/search.ts +9 -0
- package/packages/core/src/ports/tickets/tree.ts +8 -6
- package/packages/core/src/ports/types.ts +30 -15
- package/packages/core/src/ports/workspace/build-execution.ts +4 -0
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +4 -0
- package/packages/core/src/ports/workspace/create.ts +16 -3
- package/packages/core/src/ports/workspace/execution-exit-marker.ts +41 -0
- package/packages/core/src/ports/workspace/fake.ts +15 -3
- package/packages/core/src/ports/workspace/recovery-step.ts +101 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +510 -145
- package/packages/core/src/processes/build-execution-state.ts +4 -0
- package/packages/core/src/processes/build-runner.ts +14 -1
- package/packages/core/src/processes/dispatcher.ts +777 -288
- package/packages/core/src/processes/execution-no-progress.ts +1 -0
- package/packages/core/src/processes/execution-settlement.ts +1 -0
- package/packages/core/src/processes/harvest-runner.ts +12 -7
- package/packages/core/src/processes/infrastructure-failure-budget.ts +7 -2
- package/packages/core/src/processes/invocation-budget.ts +176 -0
- package/packages/core/src/processes/publication-loss.ts +38 -3
- package/packages/core/src/processes/workspace-preservation.ts +86 -15
- package/packages/core/src/store/contract.ts +81 -3
- package/packages/core/src/store/event-reads.ts +30 -1
- package/packages/core/src/store/local/capabilities.ts +115 -0
- package/packages/core/src/store/local/store.ts +86 -56
- package/packages/core/src/store/reduced-reads.ts +32 -1
- package/packages/core/src/store/reducer-value-read.ts +235 -0
- package/packages/core/src/store/reducer-value-shapes.json +6722 -6475
- package/packages/core/src/store/reducer-value-validation.ts +181 -33
- package/packages/core/src/store/reducer-values.ts +36 -204
- package/packages/core/src/store/remote/client.ts +169 -29
- package/packages/core/src/store/remote/compatibility.ts +113 -56
- package/packages/core/src/store/remote/credentials.ts +4 -1
- package/packages/core/src/store/remote/protocol.ts +3 -0
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.12.0.json +35806 -0
- package/packages/core/src/store/remote/released-reducer-values/1.13.0.json +35966 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
- package/packages/core/src/store/remote/released-value-policy.ts +144 -0
- package/packages/core/src/store/remote/retry.ts +406 -0
- package/packages/core/src/store/rollup-lease.ts +41 -0
- package/packages/core/src/store/rollups.ts +7 -38
- package/packages/core/src/store/snapshots.ts +1 -1
- package/packages/core/src/testing/dispatch-read-budget.ts +409 -14
- package/packages/core/src/testing/import-graph.ts +78 -0
- package/packages/core/src/testing/index.ts +2 -0
- package/packages/core/src/testing/invocation-budget.ts +42 -0
- package/packages/core/src/testing/reduced-read-budget.ts +602 -40
- package/packages/core/src/testing/released-value-coverage.ts +423 -0
- package/packages/core/src/testing/slot-agreement.ts +52 -0
- package/packages/core/src/web/assets/app.js +5 -5
- package/packages/core/src/web/overview-source.ts +19 -6
- package/skills/guide/SKILL.md +245 -103
- package/skills/guide/references/integration-tree.md +33 -18
- package/skills/guide/references/merge-policy.md +7 -2
- package/skills/guide/references/operator-api.md +48 -25
- package/skills/guide/references/optimization-nodes.md +10 -8
- package/skills/guide/references/plugin-authoring.md +46 -18
- package/skills/guide/references/remote-store-protocol.md +51 -12
- package/skills/guide/references/remote-ticket-protocol.md +85 -38
- package/skills/guide/references/restacking.md +48 -3
- package/skills/guide/references/setup.md +2 -1
- package/skills/guide/references/ticket-migration.md +2 -2
- package/skills/operate/SKILL.md +114 -65
- package/skills/plan/SKILL.md +4 -3
- package/skills/spec/SKILL.md +9 -5
- package/skills/tickets/SKILL.md +25 -17
- package/templates/hosted-service/package.json +2 -2
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
import type { TicketStartPriority } from '../../events/repository'
|
|
3
|
-
import type { Ticket, TicketPriority, TicketSource } from '../types'
|
|
3
|
+
import type { BuildPriority, Ticket, TicketPriority, TicketSource } from '../types'
|
|
4
4
|
|
|
5
|
-
export type { TicketPriority } from '../types'
|
|
5
|
+
export type { BuildPriority, TicketPriority } from '../types'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/** Every ticket priority level, highest first. */
|
|
8
|
+
export const TICKET_PRIORITIES = ['urgent', 'high', 'normal', 'low'] as const
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
export const ticketPrioritySchema = z.enum(TICKET_PRIORITIES)
|
|
11
|
+
|
|
12
|
+
/** A build's slot-admission level, as operators name it: the four ticket
|
|
13
|
+
* levels. Persisted facts encode it compatibly (`prioritySetPayload`). */
|
|
14
|
+
export const buildPrioritySchema = ticketPrioritySchema
|
|
15
|
+
|
|
16
|
+
/** A write naming a level other than `normal` reached a source that cannot
|
|
17
|
+
* store priority. */
|
|
10
18
|
export class TicketPriorityUnsupported extends Error {
|
|
11
19
|
constructor(readonly source: string) {
|
|
12
20
|
super(`${source} ticket source cannot store ticket priority; nothing was written`)
|
|
@@ -14,17 +22,17 @@ export class TicketPriorityUnsupported extends Error {
|
|
|
14
22
|
}
|
|
15
23
|
}
|
|
16
24
|
|
|
17
|
-
/** Refuse before any write:
|
|
18
|
-
* value every source already holds. */
|
|
25
|
+
/** Refuse before any write: every level but `normal` needs the capability;
|
|
26
|
+
* `normal` is the value every source already holds. */
|
|
19
27
|
export function refuseUnsupportedPriority(
|
|
20
28
|
source: Pick<TicketSource, 'name' | 'priority'>,
|
|
21
29
|
patch: { priority?: unknown },
|
|
22
30
|
): void {
|
|
23
|
-
if (patch.priority
|
|
31
|
+
if (patch.priority !== undefined && patch.priority !== 'normal' && !source.priority)
|
|
24
32
|
throw new TicketPriorityUnsupported(source.name)
|
|
25
33
|
}
|
|
26
34
|
|
|
27
|
-
/** Refuse `
|
|
35
|
+
/** Refuse any level but `normal`, then drop a `normal` no-op for a source without the
|
|
28
36
|
* capability so its write (and wire) never names priority. */
|
|
29
37
|
export function withoutUnsupportedPriority<T extends { priority?: unknown }>(
|
|
30
38
|
source: Pick<TicketSource, 'name' | 'priority'>,
|
|
@@ -36,12 +44,48 @@ export function withoutUnsupportedPriority<T extends { priority?: unknown }>(
|
|
|
36
44
|
return rest as T
|
|
37
45
|
}
|
|
38
46
|
|
|
39
|
-
/**
|
|
40
|
-
export function ticketPriority(ticket:
|
|
41
|
-
|
|
47
|
+
/** The stored level; absent and unrecognised values read as normal. */
|
|
48
|
+
export function ticketPriority(ticket: { priority?: unknown }): TicketPriority {
|
|
49
|
+
const level = ticket.priority
|
|
50
|
+
return typeof level === 'string' && (TICKET_PRIORITIES as readonly string[]).includes(level)
|
|
51
|
+
? (level as TicketPriority)
|
|
52
|
+
: 'normal'
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The level a ticket is claimed at, and the level its build takes. */
|
|
56
|
+
export function dispatchPriority(ticket: { priority?: unknown }): BuildPriority {
|
|
57
|
+
return ticketPriority(ticket)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** 0 for urgent through 3 for low. */
|
|
61
|
+
export function priorityRank(level: TicketPriority): number {
|
|
62
|
+
return TICKET_PRIORITIES.indexOf(level)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Stable four-tier sort: urgent, high, normal, low, each in input order. */
|
|
66
|
+
export function byPriority<T extends { priority?: unknown }>(tickets: readonly T[]): T[] {
|
|
67
|
+
const tiers: T[][] = TICKET_PRIORITIES.map(() => [])
|
|
68
|
+
for (const ticket of tickets) tiers[priorityRank(ticketPriority(ticket))]?.push(ticket)
|
|
69
|
+
return tiers.flat()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Stable four-tier sort by a caller's level: urgent, high, normal, low,
|
|
73
|
+
* each in input order. */
|
|
74
|
+
export function byPriorityBy<T>(items: readonly T[], level: (item: T) => TicketPriority): T[] {
|
|
75
|
+
const tiers: T[][] = TICKET_PRIORITIES.map(() => [])
|
|
76
|
+
for (const item of items) tiers[priorityRank(level(item))]?.push(item)
|
|
77
|
+
return tiers.flat()
|
|
42
78
|
}
|
|
43
79
|
|
|
44
|
-
/**
|
|
80
|
+
/** The value with `priority` always named, `normal` when absent. */
|
|
81
|
+
export function namedPriority<T extends { priority?: unknown }>(
|
|
82
|
+
value: T,
|
|
83
|
+
): Omit<T, 'priority'> & { priority: TicketPriority } {
|
|
84
|
+
return { ...value, priority: ticketPriority(value) }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Stable partition: urgent candidates first, then the rest, each in input
|
|
88
|
+
* order. Kept for plugins; dispatch orders by `byPriority`. */
|
|
45
89
|
export function urgentFirst<T extends Pick<Ticket, 'priority'>>(tickets: readonly T[]): T[] {
|
|
46
90
|
const urgent: T[] = []
|
|
47
91
|
const normal: T[] = []
|
|
@@ -50,8 +94,8 @@ export function urgentFirst<T extends Pick<Ticket, 'priority'>>(tickets: readonl
|
|
|
50
94
|
}
|
|
51
95
|
|
|
52
96
|
/** Stable partition by a caller's tier: urgent first, then the rest, each in
|
|
53
|
-
* input order. */
|
|
54
|
-
export function urgentFirstBy<T>(tickets: readonly T[], tier: (ticket: T) =>
|
|
97
|
+
* input order. Kept for plugins; dispatch orders by `byPriorityBy`. */
|
|
98
|
+
export function urgentFirstBy<T>(tickets: readonly T[], tier: (ticket: T) => BuildPriority): T[] {
|
|
55
99
|
const urgent: T[] = []
|
|
56
100
|
const normal: T[] = []
|
|
57
101
|
for (const ticket of tickets) (tier(ticket) === 'urgent' ? urgent : normal).push(ticket)
|
|
@@ -60,16 +104,78 @@ export function urgentFirstBy<T>(tickets: readonly T[], tier: (ticket: T) => Tic
|
|
|
60
104
|
|
|
61
105
|
export function parsePriorityFlag(value: string, flag = '--priority'): TicketPriority {
|
|
62
106
|
const result = ticketPrioritySchema.safeParse(value.trim())
|
|
63
|
-
if (!result.success)
|
|
107
|
+
if (!result.success)
|
|
108
|
+
throw new Error(`${flag}: expected urgent, high, normal or low, got "${value}"`)
|
|
109
|
+
return result.data
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** `ab priority`: a build's slot-admission level. */
|
|
113
|
+
export function parseBuildPriorityFlag(value: string, flag = 'priority'): BuildPriority {
|
|
114
|
+
const result = buildPrioritySchema.safeParse(value.trim())
|
|
115
|
+
if (!result.success)
|
|
116
|
+
throw new Error(`${flag}: expected urgent, high, normal or low, got "${value}"`)
|
|
64
117
|
return result.data
|
|
65
118
|
}
|
|
66
119
|
|
|
67
|
-
|
|
120
|
+
/** Every start request admission tier, in admission order: `manual` first,
|
|
121
|
+
* then the four ticket levels. */
|
|
122
|
+
export const START_TIERS = ['manual', 'urgent', 'high', 'normal', 'low'] as const
|
|
123
|
+
export type StartTier = (typeof START_TIERS)[number]
|
|
124
|
+
|
|
125
|
+
export const startTierSchema = z.enum(START_TIERS)
|
|
68
126
|
|
|
69
127
|
/** `ab start --priority`: a start request's admission tier. */
|
|
70
|
-
export function parseStartPriorityFlag(value: string, flag = '--priority'):
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
throw new Error(`${flag}: expected manual, urgent or
|
|
74
|
-
return
|
|
128
|
+
export function parseStartPriorityFlag(value: string, flag = '--priority'): StartTier {
|
|
129
|
+
const tier = START_TIERS.find((entry) => entry === value.trim())
|
|
130
|
+
if (tier === undefined)
|
|
131
|
+
throw new Error(`${flag}: expected manual, urgent, high, normal or low, got "${value}"`)
|
|
132
|
+
return tier
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** The levels persisted facts carry in their additive `level` key. Older
|
|
136
|
+
* readers drop the key and see the fact's two-level field: normal. */
|
|
137
|
+
export type RefinedLevel = 'high' | 'low'
|
|
138
|
+
|
|
139
|
+
function refined(level: string): level is RefinedLevel {
|
|
140
|
+
return level === 'high' || level === 'low'
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** `build.created`'s priority fields for a build's level: `urgent` in
|
|
144
|
+
* `priority`, `high` and `low` in `level`, normal omitted. */
|
|
145
|
+
export function createdPriorityFields(level: BuildPriority): {
|
|
146
|
+
priority?: 'urgent'
|
|
147
|
+
level?: RefinedLevel
|
|
148
|
+
} {
|
|
149
|
+
if (level === 'urgent') return { priority: 'urgent' }
|
|
150
|
+
return refined(level) ? { level } : {}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** A `build.priority-set` payload for a level: `priority` stays two-level
|
|
154
|
+
* (high and low write `normal`) and `level` refines it. */
|
|
155
|
+
export function prioritySetPayload(level: BuildPriority): {
|
|
156
|
+
priority: 'urgent' | 'normal'
|
|
157
|
+
level?: RefinedLevel
|
|
158
|
+
} {
|
|
159
|
+
return {
|
|
160
|
+
priority: level === 'urgent' ? 'urgent' : 'normal',
|
|
161
|
+
...(refined(level) ? { level } : {}),
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** A start request's persisted tier fields: `priority` stays in its
|
|
166
|
+
* three-tier domain (high and low write `normal`) and `level` refines it. */
|
|
167
|
+
export function startTierFields(tier: StartTier): {
|
|
168
|
+
priority: TicketStartPriority
|
|
169
|
+
level?: RefinedLevel
|
|
170
|
+
} {
|
|
171
|
+
return refined(tier) ? { priority: 'normal', level: tier } : { priority: tier }
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** The admission tier a persisted start request names: its `level` when
|
|
175
|
+
* present, otherwise its `priority`. */
|
|
176
|
+
export function startTierOf(request: {
|
|
177
|
+
priority: TicketStartPriority
|
|
178
|
+
level?: RefinedLevel
|
|
179
|
+
}): StartTier {
|
|
180
|
+
return request.level ?? request.priority
|
|
75
181
|
}
|
|
@@ -37,6 +37,15 @@ export const TICKET_ISSUE_LINKS_CAPABILITY = '1'
|
|
|
37
37
|
export const TICKET_PRIORITY_HEADER = 'x-autobuild-ticket-priority'
|
|
38
38
|
export const TICKET_PRIORITY_CAPABILITY = '1'
|
|
39
39
|
|
|
40
|
+
/** Explicit opt-in: released clients decode priority strictly as `urgent` or
|
|
41
|
+
* `normal`. Servers answer all four levels (and search-hit priority) only to
|
|
42
|
+
* clients sending it; a client sending only the priority header reads `high`
|
|
43
|
+
* and `low` as `normal`. Servers echo it on every ticket response, so a client
|
|
44
|
+
* writing `high` or `low` can tell an older server's strict-schema refusal
|
|
45
|
+
* from an ordinary validation failure. */
|
|
46
|
+
export const TICKET_PRIORITY_LEVELS_HEADER = 'x-autobuild-ticket-priority-levels'
|
|
47
|
+
export const TICKET_PRIORITY_LEVELS_CAPABILITY = '1'
|
|
48
|
+
|
|
40
49
|
/** Explicit opt-in: released clients decode dependency states strictly without
|
|
41
50
|
* `state`. Servers include each blocker's native state name only for clients
|
|
42
51
|
* that send this header; an older server ignores it and omits the field. */
|
|
@@ -140,6 +149,7 @@ export const ticketSearchHitWireSchema = z.strictObject({
|
|
|
140
149
|
.string()
|
|
141
150
|
.refine((v) => v.trim().length > 0)
|
|
142
151
|
.optional(),
|
|
152
|
+
priority: ticketPrioritySchema.optional(),
|
|
143
153
|
})
|
|
144
154
|
export const ticketSearchPageWireSchema = z.strictObject({
|
|
145
155
|
tickets: z.array(ticketSearchHitWireSchema),
|
|
@@ -15,6 +15,7 @@ import type {
|
|
|
15
15
|
TicketListing,
|
|
16
16
|
TicketPage,
|
|
17
17
|
TicketPageListing,
|
|
18
|
+
TicketPriority,
|
|
18
19
|
TicketSearchPage,
|
|
19
20
|
TicketSearchQuery,
|
|
20
21
|
TicketSource,
|
|
@@ -23,6 +24,16 @@ import type {
|
|
|
23
24
|
} from '../types'
|
|
24
25
|
import { RemoteBuildStore, AuthError } from '../../store/remote/client'
|
|
25
26
|
import { errorBodySchema } from '../../store/remote/protocol'
|
|
27
|
+
import {
|
|
28
|
+
RemoteUnavailableError,
|
|
29
|
+
fetchWithRetry,
|
|
30
|
+
isTransientStatus,
|
|
31
|
+
resolveRemoteRetry,
|
|
32
|
+
responseAttempts,
|
|
33
|
+
type RemoteRetryOptions,
|
|
34
|
+
type RemoteRetryPolicy,
|
|
35
|
+
type RetrySafety,
|
|
36
|
+
} from '../../store/remote/retry'
|
|
26
37
|
import {
|
|
27
38
|
claimWireSchema,
|
|
28
39
|
TICKET_TREE_HEADER,
|
|
@@ -37,6 +48,8 @@ import {
|
|
|
37
48
|
TICKET_ISSUE_LINKS_CAPABILITY,
|
|
38
49
|
TICKET_PRIORITY_HEADER,
|
|
39
50
|
TICKET_PRIORITY_CAPABILITY,
|
|
51
|
+
TICKET_PRIORITY_LEVELS_HEADER,
|
|
52
|
+
TICKET_PRIORITY_LEVELS_CAPABILITY,
|
|
40
53
|
TICKET_DEPENDENCY_STATE_HEADER,
|
|
41
54
|
TICKET_DEPENDENCY_STATE_CAPABILITY,
|
|
42
55
|
TICKET_POLICY_ROLES_HEADER,
|
|
@@ -77,8 +90,29 @@ export interface HostedTicketSourceOptions extends HostedTicketContext {
|
|
|
77
90
|
url: string
|
|
78
91
|
token: string
|
|
79
92
|
fetchFn?: HostedTicketFetch
|
|
93
|
+
/** Transient-failure retries; `false` makes a single attempt. */
|
|
94
|
+
retry?: RemoteRetryOptions
|
|
80
95
|
}
|
|
81
96
|
|
|
97
|
+
/** Operations whose retry after a lost response is harmless: reads, and
|
|
98
|
+
* set-or-replace writes whose repeat is a no-op or a typed revision conflict. */
|
|
99
|
+
const IDEMPOTENT_TICKET_OPERATIONS: ReadonlySet<string> = new Set([
|
|
100
|
+
'policy',
|
|
101
|
+
'list-ready',
|
|
102
|
+
'list-targeting',
|
|
103
|
+
'list-page',
|
|
104
|
+
'search',
|
|
105
|
+
'states',
|
|
106
|
+
'state-counts',
|
|
107
|
+
'get',
|
|
108
|
+
'dependency-states',
|
|
109
|
+
'transition',
|
|
110
|
+
'update',
|
|
111
|
+
'add-blocker',
|
|
112
|
+
'remove-blocker',
|
|
113
|
+
'mutate-if-revision',
|
|
114
|
+
])
|
|
115
|
+
|
|
82
116
|
/** The project ticket policy a hosted `[tickets]` table publishes. The backlog
|
|
83
117
|
* and rejected roles appear only when configured, and `createLabels` only when
|
|
84
118
|
* nonempty, so a policy without them is exactly what services predating them
|
|
@@ -132,6 +166,7 @@ export class HostedTicketSource implements TicketSource {
|
|
|
132
166
|
private readonly base: string
|
|
133
167
|
private readonly token: string
|
|
134
168
|
private readonly fetchFn: HostedTicketFetch
|
|
169
|
+
private readonly retry: RemoteRetryPolicy | false
|
|
135
170
|
private readonly context: HostedTicketContext
|
|
136
171
|
/** Unknown until a response settles it; see `noteCapabilities`. */
|
|
137
172
|
private targetingSupport: boolean | undefined
|
|
@@ -150,6 +185,7 @@ export class HostedTicketSource implements TicketSource {
|
|
|
150
185
|
url: options.url,
|
|
151
186
|
token: options.token,
|
|
152
187
|
...(options.fetchFn ? { fetchFn: options.fetchFn as typeof fetch } : {}),
|
|
188
|
+
...(options.retry !== undefined ? { retry: options.retry } : {}),
|
|
153
189
|
})
|
|
154
190
|
this.assets = {
|
|
155
191
|
ticketAssetLimits: client.ticketAssetLimits.bind(client),
|
|
@@ -161,6 +197,7 @@ export class HostedTicketSource implements TicketSource {
|
|
|
161
197
|
this.base = options.url.replace(/\/+$/, '')
|
|
162
198
|
this.token = options.token
|
|
163
199
|
this.fetchFn = options.fetchFn ?? fetch
|
|
200
|
+
this.retry = resolveRemoteRetry(options.retry)
|
|
164
201
|
this.context = {
|
|
165
202
|
teamKey: options.teamKey,
|
|
166
203
|
...(options.repo !== undefined ? { repo: options.repo } : {}),
|
|
@@ -179,6 +216,14 @@ export class HostedTicketSource implements TicketSource {
|
|
|
179
216
|
})
|
|
180
217
|
}
|
|
181
218
|
|
|
219
|
+
/** The dispatcher's ticket preparation (at its first tick boundary): publish
|
|
220
|
+
* the project policy when given, then settle targeted listing, which the
|
|
221
|
+
* policy response normally answers for free. */
|
|
222
|
+
async prepareForDispatch(policy: HostedTicketPolicy | undefined): Promise<void> {
|
|
223
|
+
if (policy !== undefined) await this.synchronizePolicy(policy)
|
|
224
|
+
await this.negotiateTargeting()
|
|
225
|
+
}
|
|
226
|
+
|
|
182
227
|
/** Present only once the service has positively advertised `list-targeting`;
|
|
183
228
|
* while support is unknown or refused, observation keeps the exhaustive path. */
|
|
184
229
|
get listTargeting(): TicketSource['listTargeting'] {
|
|
@@ -230,8 +275,21 @@ export class HostedTicketSource implements TicketSource {
|
|
|
230
275
|
else if (response.ok) this.searchSupport = false
|
|
231
276
|
}
|
|
232
277
|
|
|
233
|
-
private async send(
|
|
234
|
-
|
|
278
|
+
private async send(
|
|
279
|
+
operation: string,
|
|
280
|
+
input: unknown,
|
|
281
|
+
safety: RetrySafety = IDEMPOTENT_TICKET_OPERATIONS.has(operation) ? 'idempotent' : 'unsafe',
|
|
282
|
+
): Promise<Response> {
|
|
283
|
+
const response = await fetchWithRetry(
|
|
284
|
+
(signal) => this.fetchFn(`${this.base}/tickets/${operation}`, this.init(input, signal)),
|
|
285
|
+
{ safety, policy: this.retry, label: 'ticket service' },
|
|
286
|
+
)
|
|
287
|
+
this.noteCapabilities(response)
|
|
288
|
+
return response
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
private init(input: unknown, signal: AbortSignal | undefined): RequestInit {
|
|
292
|
+
return {
|
|
235
293
|
method: 'POST',
|
|
236
294
|
headers: {
|
|
237
295
|
[TICKET_TREE_HEADER]: TICKET_TREE_CAPABILITY,
|
|
@@ -241,6 +299,7 @@ export class HostedTicketSource implements TicketSource {
|
|
|
241
299
|
[TICKET_REVISIONS_HEADER]: TICKET_REVISIONS_CAPABILITY,
|
|
242
300
|
[TICKET_ISSUE_LINKS_HEADER]: TICKET_ISSUE_LINKS_CAPABILITY,
|
|
243
301
|
[TICKET_PRIORITY_HEADER]: TICKET_PRIORITY_CAPABILITY,
|
|
302
|
+
[TICKET_PRIORITY_LEVELS_HEADER]: TICKET_PRIORITY_LEVELS_CAPABILITY,
|
|
244
303
|
[TICKET_DEPENDENCY_STATE_HEADER]: TICKET_DEPENDENCY_STATE_CAPABILITY,
|
|
245
304
|
[TICKET_POLICY_ROLES_HEADER]: TICKET_POLICY_ROLES_CAPABILITY,
|
|
246
305
|
[TICKET_POLICY_CREATE_LABELS_HEADER]: TICKET_POLICY_CREATE_LABELS_CAPABILITY,
|
|
@@ -251,9 +310,8 @@ export class HostedTicketSource implements TicketSource {
|
|
|
251
310
|
[REMOTE_STORE_PROTOCOL_VERSION_HEADER]: REMOTE_STORE_PROTOCOL_VERSION,
|
|
252
311
|
},
|
|
253
312
|
body: JSON.stringify({ context: this.context, input }),
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
return response
|
|
313
|
+
...(signal !== undefined ? { signal } : {}),
|
|
314
|
+
}
|
|
257
315
|
}
|
|
258
316
|
|
|
259
317
|
private project(ticket: Ticket): Ticket {
|
|
@@ -267,11 +325,14 @@ export class HostedTicketSource implements TicketSource {
|
|
|
267
325
|
names: {
|
|
268
326
|
issueLinks?: boolean
|
|
269
327
|
priority?: boolean
|
|
328
|
+
/** The write names `high` or `low`. */
|
|
329
|
+
priorityLevel?: boolean
|
|
270
330
|
policyRoles?: boolean
|
|
271
331
|
policyCreateLabels?: boolean
|
|
272
332
|
} = {},
|
|
333
|
+
safety?: RetrySafety,
|
|
273
334
|
): Promise<T> {
|
|
274
|
-
const response = await this.send(operation, input)
|
|
335
|
+
const response = await this.send(operation, input, safety)
|
|
275
336
|
if (!response.ok) {
|
|
276
337
|
// A service predating targeted listing has no such route (or refuses it
|
|
277
338
|
// with a strict schema) and never echoes the capability header. The read
|
|
@@ -328,8 +389,10 @@ export class HostedTicketSource implements TicketSource {
|
|
|
328
389
|
'ticket service predates backlog/rejected roles in ticket policy; upgrade the service or unset [tickets].backlogState and rejectedState',
|
|
329
390
|
)
|
|
330
391
|
let message = `ticket service responded ${response.status}`
|
|
392
|
+
let parsedBody: unknown
|
|
331
393
|
try {
|
|
332
394
|
const body = (await response.json()) as Record<string, unknown>
|
|
395
|
+
parsedBody = body
|
|
333
396
|
if (
|
|
334
397
|
response.status === 409 &&
|
|
335
398
|
typeof body.currentRevision === 'string' &&
|
|
@@ -367,6 +430,16 @@ export class HostedTicketSource implements TicketSource {
|
|
|
367
430
|
message.includes('priority')
|
|
368
431
|
)
|
|
369
432
|
throw new TicketPriorityUnsupported(this.name)
|
|
433
|
+
// A server storing only urgent and normal refuses `high` and `low`
|
|
434
|
+
// with its strict request schema and never echoes the levels header.
|
|
435
|
+
if (
|
|
436
|
+
names.priorityLevel &&
|
|
437
|
+
response.status === 400 &&
|
|
438
|
+
response.headers.get(TICKET_PRIORITY_LEVELS_HEADER) !==
|
|
439
|
+
TICKET_PRIORITY_LEVELS_CAPABILITY &&
|
|
440
|
+
message.includes('priority')
|
|
441
|
+
)
|
|
442
|
+
throw new TicketPriorityUnsupported(this.name)
|
|
370
443
|
} catch (error) {
|
|
371
444
|
if (
|
|
372
445
|
error instanceof TicketRevisionConflict ||
|
|
@@ -380,6 +453,11 @@ export class HostedTicketSource implements TicketSource {
|
|
|
380
453
|
// Keep the status-only safe fallback for non-protocol responses.
|
|
381
454
|
}
|
|
382
455
|
if (response.status === 401 || response.status === 403) throw new AuthError(message)
|
|
456
|
+
if (isTransientStatus(response.status, parsedBody))
|
|
457
|
+
throw new RemoteUnavailableError(message, {
|
|
458
|
+
status: response.status,
|
|
459
|
+
attempts: responseAttempts(response),
|
|
460
|
+
})
|
|
383
461
|
throw new Error(message)
|
|
384
462
|
}
|
|
385
463
|
return schema.parse(await response.json())
|
|
@@ -516,13 +594,21 @@ export class HostedTicketSource implements TicketSource {
|
|
|
516
594
|
// working against a service predating it.
|
|
517
595
|
async create(draft: TicketDraft, options: TicketCreateOptions = {}): Promise<Ticket> {
|
|
518
596
|
const { priority, ...rest } = draft
|
|
519
|
-
const write = priority
|
|
597
|
+
const write = priority !== undefined && priority !== 'normal' ? { ...rest, priority } : rest
|
|
520
598
|
const { idempotencyKeyReservedAt: _reservedAt, ...wireOptions } = options
|
|
521
599
|
return this.project(
|
|
522
|
-
await this.request(
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
600
|
+
await this.request(
|
|
601
|
+
'create',
|
|
602
|
+
{ draft: write, options: wireOptions },
|
|
603
|
+
ticketWireSchema,
|
|
604
|
+
{
|
|
605
|
+
issueLinks: write.issueLinks !== undefined,
|
|
606
|
+
priority: 'priority' in write,
|
|
607
|
+
priorityLevel: namesLevel(priority),
|
|
608
|
+
},
|
|
609
|
+
// A keyed create is answered by the earlier ticket on a repeat.
|
|
610
|
+
options.idempotencyKey !== undefined ? 'idempotent' : 'unsafe',
|
|
611
|
+
),
|
|
526
612
|
)
|
|
527
613
|
}
|
|
528
614
|
|
|
@@ -539,6 +625,7 @@ export class HostedTicketSource implements TicketSource {
|
|
|
539
625
|
? {
|
|
540
626
|
issueLinks: mutation.patch.issueLinks !== undefined,
|
|
541
627
|
priority: mutation.patch.priority !== undefined,
|
|
628
|
+
priorityLevel: namesLevel(mutation.patch.priority),
|
|
542
629
|
}
|
|
543
630
|
: {},
|
|
544
631
|
)
|
|
@@ -548,6 +635,7 @@ export class HostedTicketSource implements TicketSource {
|
|
|
548
635
|
await this.request('update', { id, patch }, successWireSchema, {
|
|
549
636
|
issueLinks: patch.issueLinks !== undefined,
|
|
550
637
|
priority: patch.priority !== undefined,
|
|
638
|
+
priorityLevel: namesLevel(patch.priority),
|
|
551
639
|
})
|
|
552
640
|
}
|
|
553
641
|
|
|
@@ -563,3 +651,8 @@ export class HostedTicketSource implements TicketSource {
|
|
|
563
651
|
return this.request('dependency-states', { ids }, dependencyStatesWireSchema)
|
|
564
652
|
}
|
|
565
653
|
}
|
|
654
|
+
|
|
655
|
+
/** A level only a server echoing the priority-levels header can store. */
|
|
656
|
+
function namesLevel(priority: TicketPriority | undefined): boolean {
|
|
657
|
+
return priority === 'high' || priority === 'low'
|
|
658
|
+
}
|
|
@@ -39,9 +39,11 @@ export function ticketRevision(
|
|
|
39
39
|
...(issueLinks.length > 0
|
|
40
40
|
? [['issueLinks', issueLinks.map((link) => [link.issue, link.intent])]]
|
|
41
41
|
: []),
|
|
42
|
-
// Appended only when
|
|
43
|
-
// the revisions they had before priority existed.
|
|
44
|
-
...(ticket.priority
|
|
42
|
+
// Appended only when not normal, for the same reason: normal tickets
|
|
43
|
+
// keep the revisions they had before priority existed.
|
|
44
|
+
...(ticket.priority !== undefined && ticket.priority !== 'normal'
|
|
45
|
+
? [['priority', ticket.priority]]
|
|
46
|
+
: []),
|
|
45
47
|
]),
|
|
46
48
|
)
|
|
47
49
|
.digest('hex')
|
|
@@ -56,9 +56,17 @@ export function searchHit(ticket: Ticket): TicketSearchHit {
|
|
|
56
56
|
labels: [...ticket.labels],
|
|
57
57
|
kind: ticket.kind ?? 'work',
|
|
58
58
|
...(ticket.target !== undefined ? { target: ticket.target } : {}),
|
|
59
|
+
...hitPriority(ticket),
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
/** A non-normal level, or nothing: absent and `normal` stay byte-identical,
|
|
64
|
+
* an unrecognised value is dropped. */
|
|
65
|
+
function hitPriority(value: { priority?: unknown }): Pick<TicketSearchHit, 'priority'> {
|
|
66
|
+
const level = value.priority
|
|
67
|
+
return level === 'urgent' || level === 'high' || level === 'low' ? { priority: level } : {}
|
|
68
|
+
}
|
|
69
|
+
|
|
62
70
|
/** Search an in-memory listing in its own order. `query.state` must already be
|
|
63
71
|
* the source's canonical state name. The cursor is a decimal match offset. */
|
|
64
72
|
export function pageSearch(
|
|
@@ -135,5 +143,6 @@ function normalizeHit(hit: TicketSearchHit): TicketSearchHit {
|
|
|
135
143
|
labels: [...hit.labels],
|
|
136
144
|
kind: hit.kind ?? 'work',
|
|
137
145
|
...(hit.target !== undefined ? { target: hit.target } : {}),
|
|
146
|
+
...hitPriority(hit),
|
|
138
147
|
}
|
|
139
148
|
}
|
|
@@ -2,7 +2,8 @@ import type { Ticket, TicketDraft, TicketSource, TicketUpdate } from '../types'
|
|
|
2
2
|
import { checkTicketRevision } from './revision'
|
|
3
3
|
import { validateTicketUpdate } from './update'
|
|
4
4
|
import { refuseUnsupportedIssueLinks } from './issue-links'
|
|
5
|
-
import { refuseUnsupportedPriority, withoutUnsupportedPriority } from './priority'
|
|
5
|
+
import { refuseUnsupportedPriority, ticketPriority, withoutUnsupportedPriority } from './priority'
|
|
6
|
+
import { priorityLabelSource } from './priority-labels'
|
|
6
7
|
import { refuseUnsupportedAssignees } from './assignees'
|
|
7
8
|
import { objectiveBlocks } from '../../objective'
|
|
8
9
|
|
|
@@ -14,14 +15,14 @@ export function normalizeTicket(
|
|
|
14
15
|
priority = true,
|
|
15
16
|
assignees = true,
|
|
16
17
|
): Ticket {
|
|
17
|
-
const { target, issueLinks: links, priority:
|
|
18
|
+
const { target, issueLinks: links, priority: level, assignees: assigned, ...rest } = ticket
|
|
18
19
|
return {
|
|
19
20
|
...rest,
|
|
20
21
|
kind: supported ? (ticket.kind ?? 'work') : 'work',
|
|
21
22
|
...(supported && target !== undefined ? { target } : {}),
|
|
22
23
|
...(issueLinks && links !== undefined ? { issueLinks: links } : {}),
|
|
23
24
|
// Normal is the absence of the field, so strict wire schemas never see it.
|
|
24
|
-
...(priority &&
|
|
25
|
+
...(priority && ticketPriority({ priority: level }) !== 'normal' ? { priority: level } : {}),
|
|
25
26
|
...(assignees && assigned !== undefined ? { assignees: assigned } : {}),
|
|
26
27
|
}
|
|
27
28
|
}
|
|
@@ -105,11 +106,12 @@ function writablePatch(source: TicketSource, patch: TicketUpdate): TicketUpdate
|
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
/** Forward through an empty facade so frozen source properties do not constrain
|
|
108
|
-
* proxy results. Methods and accessors still receive the original source.
|
|
109
|
+
* proxy results. Methods and accessors still receive the original source. A
|
|
110
|
+
* source without native priority gets the `priority:<level>` label fallback. */
|
|
109
111
|
export function compatibleTicketSource(source: TicketSource): TicketSource {
|
|
110
|
-
|
|
112
|
+
const target = source.priority ? source : priorityLabelSource(source)
|
|
113
|
+
return new Proxy(Object.create(target) as TicketSource, {
|
|
111
114
|
get(_facade, property) {
|
|
112
|
-
const target = source
|
|
113
115
|
const value = Reflect.get(target, property, target)
|
|
114
116
|
if (typeof value !== 'function') return value
|
|
115
117
|
if (property === 'get')
|
|
@@ -94,16 +94,21 @@ export interface Ticket {
|
|
|
94
94
|
/** Forge issues this ticket addresses, sorted by issue number. Absent ≡ none
|
|
95
95
|
* or unsupported by the source. */
|
|
96
96
|
issueLinks?: IssueLink[]
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
97
|
+
/** Priority level. Absent means `normal`; normalized tickets never carry
|
|
98
|
+
* `normal`. Dispatch claims ready work by level, urgent, high, normal, then
|
|
99
|
+
* low, never preempting a running build. */
|
|
99
100
|
priority?: TicketPriority
|
|
100
101
|
/** Usernames the ticket is assigned to. Present (possibly empty) only for
|
|
101
102
|
* sources with the `assignees` capability; not part of `revision`. */
|
|
102
103
|
assignees?: string[]
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
/**
|
|
106
|
-
export type TicketPriority = 'urgent' | 'normal'
|
|
106
|
+
/** A ticket's priority level, highest first. `normal` is the default. */
|
|
107
|
+
export type TicketPriority = 'urgent' | 'high' | 'normal' | 'low'
|
|
108
|
+
|
|
109
|
+
/** A build's slot-admission level, the same four levels as a ticket's. A
|
|
110
|
+
* build claimed from a ticket takes the ticket's level (`dispatchPriority`). */
|
|
111
|
+
export type BuildPriority = TicketPriority
|
|
107
112
|
|
|
108
113
|
export type IssueLinkIntent = 'closes' | 'refs'
|
|
109
114
|
|
|
@@ -161,6 +166,8 @@ export interface TicketSearchHit {
|
|
|
161
166
|
labels: string[]
|
|
162
167
|
kind: TicketKind
|
|
163
168
|
target?: string
|
|
169
|
+
/** Same meaning as Ticket.priority: absent means `normal`. */
|
|
170
|
+
priority?: TicketPriority
|
|
164
171
|
}
|
|
165
172
|
|
|
166
173
|
export interface TicketSearchPage {
|
|
@@ -193,8 +200,9 @@ export interface TicketDraft {
|
|
|
193
200
|
/** Forge issues this ticket addresses. An adapter without the `issueLinks`
|
|
194
201
|
* capability must refuse, never discard. */
|
|
195
202
|
issueLinks?: IssueLink[]
|
|
196
|
-
/**
|
|
197
|
-
*
|
|
203
|
+
/** Priority level; absent files the ticket at `normal`. A raw source without
|
|
204
|
+
* the `priority` capability refuses any other level; the compatibility
|
|
205
|
+
* facade stores it as a `priority:<level>` label instead. */
|
|
198
206
|
priority?: TicketPriority
|
|
199
207
|
/** Exact assignees: entries are usernames or `me` (the owner of the source's
|
|
200
208
|
* credential). Callers apply any `[tickets].createAssignee` default. A source
|
|
@@ -262,8 +270,9 @@ export interface TicketUpdate {
|
|
|
262
270
|
labels?: string[]
|
|
263
271
|
/** A complete issue-link replacement. An explicit empty array clears links. */
|
|
264
272
|
issueLinks?: IssueLink[]
|
|
265
|
-
/** `normal`
|
|
266
|
-
* refuses
|
|
273
|
+
/** Replaces the priority level; `normal` clears it. A raw source without the
|
|
274
|
+
* `priority` capability refuses any other level; the compatibility facade
|
|
275
|
+
* stores it as a `priority:<level>` label instead. */
|
|
267
276
|
priority?: TicketPriority
|
|
268
277
|
/** A complete assignee replacement; entries are usernames or `me`. An
|
|
269
278
|
* explicit empty array clears assignees. A source without the `assignees`
|
|
@@ -349,13 +358,19 @@ export interface TicketSource {
|
|
|
349
358
|
/** Opt in only when kind/target persistence, graph validation and complete
|
|
350
359
|
* enumeration are supported at every write boundary, including guarded writes. */
|
|
351
360
|
readonly integrationTree?: boolean
|
|
361
|
+
/** The label through which this source records the `node` kind, when it
|
|
362
|
+
* records kind as a label rather than natively. The priority-label fallback
|
|
363
|
+
* adds or removes it to match a kind change written beside a priority; on
|
|
364
|
+
* sources without it, that fallback never touches a non-priority label. */
|
|
365
|
+
readonly kindLabel?: string
|
|
352
366
|
/** Opt in only when issue links are persisted and returned at every write
|
|
353
367
|
* boundary, including create and guarded writes. Sources without it refuse
|
|
354
368
|
* any write naming issue links. */
|
|
355
369
|
readonly issueLinks?: boolean
|
|
356
|
-
/** Opt in only when
|
|
357
|
-
* boundary, including create and guarded writes.
|
|
358
|
-
*
|
|
370
|
+
/** Opt in only when all four priority levels are persisted natively and
|
|
371
|
+
* returned at every write boundary, including create and guarded writes.
|
|
372
|
+
* A raw source without it refuses any level but `normal`; the compatibility
|
|
373
|
+
* facade gives it the `priority:<level>` label fallback instead. */
|
|
359
374
|
readonly priority?: boolean
|
|
360
375
|
/** Opt in only when assignees are persisted, returned on every read (an
|
|
361
376
|
* empty array when unassigned) and verified at every write boundary,
|
|
@@ -422,10 +437,10 @@ export interface TicketSource {
|
|
|
422
437
|
* Fatal source failures and invariants still reject the call. */
|
|
423
438
|
listReady(criteria: TicketCriteria): Promise<TicketListing>
|
|
424
439
|
/** Optional native window over the listReady matches. `oldest` (default)
|
|
425
|
-
* is
|
|
426
|
-
* listReady order. `newest` is newest filed first: creation
|
|
427
|
-
* independent of
|
|
428
|
-
*
|
|
440
|
+
* is priority order: with `priority`, urgent, then high, then normal, then
|
|
441
|
+
* low, each in listReady order. `newest` is newest filed first: creation
|
|
442
|
+
* time descending, independent of priority, with a stable tie-break; it is
|
|
443
|
+
* not the reverse of priority order. Offset and limit apply after ordering. Default offset 0.
|
|
429
444
|
* Arguments are nonnegative integers; zero limit returns no tickets with the
|
|
430
445
|
* full matching total. Diagnostics
|
|
431
446
|
* and failures match listReady; a failure must not trigger a full-read fallback.
|
|
@@ -67,6 +67,10 @@ export interface BuildExecutionIdentity {
|
|
|
67
67
|
/** Provider-native detached command identity, recorded durably at launch so
|
|
68
68
|
* a later process can re-observe the execution without process memory. */
|
|
69
69
|
commandId?: string
|
|
70
|
+
/** The execution instance being observed. In-memory observation input
|
|
71
|
+
* only, never persisted as part of the identity: it keys the runner's own
|
|
72
|
+
* exit record when the provider can no longer report the command's state. */
|
|
73
|
+
instance?: string
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
/** Teardown must distinguish proof from an interrupted/ambiguous acknowledgement. */
|