@defrex/autobuild 1.4.2 → 1.5.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 +432 -92
- package/bin/ab-dispatch-kernel.ts +1 -0
- package/docs/accounts.md +9 -0
- package/docs/agent-runtimes.md +1 -0
- package/docs/answering-blocked-builds.md +2 -1
- package/docs/architecture.md +282 -127
- package/docs/assets/headline-wide.png +0 -0
- package/docs/build-store.md +33 -3
- package/docs/cli.md +2 -1
- package/docs/configuration-overview.md +9 -0
- package/docs/configuration.md +163 -102
- package/docs/dispatcher-hosting.md +19 -3
- package/docs/dispatcher.md +9 -4
- package/docs/integration-overview.md +2 -2
- package/docs/integration-tree.md +91 -28
- package/docs/merge-policy.md +28 -9
- package/docs/operator-api.md +43 -18
- package/docs/operator-surfaces.md +1 -1
- package/docs/plugin-authoring.md +85 -8
- package/docs/remote-store-protocol.md +25 -7
- package/docs/remote-ticket-protocol.md +126 -12
- package/docs/restacking.md +20 -6
- package/docs/seams.md +2 -2
- package/docs/setup.md +19 -13
- package/docs/spec-standard.md +2 -1
- package/docs/ticket-dependencies.md +26 -8
- package/docs/ticket-migration.md +70 -7
- package/docs/ticket-sources.md +82 -5
- package/docs/tickets.md +34 -2
- package/docs/troubleshooting.md +2 -2
- package/docs/verification.md +5 -5
- package/docs/website.md +8 -0
- package/docs/workspaces.md +1 -1
- package/package.json +4 -3
- package/packages/core/src/accounts/hosted-readiness.ts +21 -0
- package/packages/core/src/cli/attention.ts +1 -0
- package/packages/core/src/cli/build-control.ts +36 -12
- package/packages/core/src/cli/connect.ts +9 -18
- package/packages/core/src/cli/context.ts +44 -0
- package/packages/core/src/cli/dashboard/configuration.ts +11 -0
- package/packages/core/src/cli/dashboard/model.ts +40 -10
- package/packages/core/src/cli/dashboard/queue.ts +21 -0
- package/packages/core/src/cli/dashboard/render.ts +40 -22
- package/packages/core/src/cli/dispatch-frontend.ts +63 -30
- package/packages/core/src/cli/dispatch-mode.ts +35 -16
- package/packages/core/src/cli/dispatch-repository-feed.ts +40 -11
- package/packages/core/src/cli/dispatch.ts +154 -47
- package/packages/core/src/cli/help.ts +59 -22
- package/packages/core/src/cli/init-hosted-accounts.ts +54 -0
- package/packages/core/src/cli/init-readiness-remote.ts +16 -3
- package/packages/core/src/cli/init-validation.ts +144 -42
- package/packages/core/src/cli/issue-links.ts +67 -0
- package/packages/core/src/cli/main.ts +32 -15
- package/packages/core/src/cli/pr-summary-publication.ts +38 -7
- package/packages/core/src/cli/publication-settlement.ts +36 -24
- package/packages/core/src/cli/repository-status.ts +201 -49
- package/packages/core/src/cli/status.ts +41 -3
- package/packages/core/src/cli/terminals.ts +37 -2
- package/packages/core/src/cli/ticket-editor.ts +20 -6
- package/packages/core/src/cli/ticket.ts +264 -46
- package/packages/core/src/cli/triage-count-sampler.ts +59 -0
- package/packages/core/src/cli/watch.ts +4 -0
- package/packages/core/src/config/live.ts +45 -4
- package/packages/core/src/config/load.ts +9 -0
- package/packages/core/src/config/pipeline-source.ts +6 -2
- package/packages/core/src/config/ready-assignee.ts +86 -0
- package/packages/core/src/config/schema.ts +164 -36
- package/packages/core/src/distribution-packaging.ts +1 -1
- package/packages/core/src/events/catalog.ts +5 -0
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/payloads.ts +70 -0
- package/packages/core/src/events/policy.ts +8 -0
- package/packages/core/src/events/repository.ts +91 -28
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +41 -0
- package/packages/core/src/kernel/build-identity.ts +12 -0
- package/packages/core/src/kernel/change-presence.ts +139 -6
- package/packages/core/src/kernel/dispatch-capacity.ts +80 -14
- package/packages/core/src/kernel/dispatch-status.ts +10 -1
- package/packages/core/src/kernel/dispatch-upgrade.ts +104 -5
- package/packages/core/src/kernel/engine.ts +4 -2
- package/packages/core/src/kernel/finalize-pr-rejection.ts +95 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +15 -1
- package/packages/core/src/kernel/harvest.ts +4 -1
- package/packages/core/src/kernel/integration-completeness.ts +104 -17
- package/packages/core/src/kernel/integration-landing.ts +17 -0
- package/packages/core/src/kernel/integration-state.ts +17 -0
- package/packages/core/src/kernel/issue-keywords.ts +202 -0
- package/packages/core/src/kernel/janitor-failure.ts +11 -0
- package/packages/core/src/kernel/kernel-git.ts +87 -0
- package/packages/core/src/kernel/landing-readiness.ts +25 -17
- package/packages/core/src/kernel/log-index.ts +1 -1
- package/packages/core/src/kernel/node-issue-links.ts +142 -0
- package/packages/core/src/kernel/node-parent.ts +6 -0
- package/packages/core/src/kernel/node-restack-transaction.ts +2 -0
- package/packages/core/src/kernel/pr-summary.ts +24 -0
- package/packages/core/src/kernel/read-deferrals.ts +75 -12
- package/packages/core/src/kernel/read-facts.ts +32 -1
- package/packages/core/src/kernel/reconcile-restack.ts +1 -1
- package/packages/core/src/kernel/reducer-registry.ts +31 -1
- package/packages/core/src/kernel/reducer.ts +90 -2
- package/packages/core/src/kernel/ticket-preparation.ts +12 -0
- package/packages/core/src/kernel/verify-budget.ts +43 -0
- package/packages/core/src/operator/index.ts +3 -1
- package/packages/core/src/operator/presentation.ts +3 -0
- package/packages/core/src/operator/protocol.ts +38 -2
- package/packages/core/src/operator/query.ts +66 -29
- package/packages/core/src/operator/registry.ts +47 -26
- package/packages/core/src/operator/tickets.ts +77 -10
- package/packages/core/src/plugin-sdk/index.ts +13 -0
- package/packages/core/src/plugins/manifest.ts +1 -1
- package/packages/core/src/plugins/registry.ts +1 -0
- package/packages/core/src/ports/forge/contract.ts +69 -0
- package/packages/core/src/ports/forge/create.ts +5 -0
- package/packages/core/src/ports/forge/fake.ts +184 -3
- package/packages/core/src/ports/forge/git-rewrite.ts +4 -2
- package/packages/core/src/ports/forge/github.ts +175 -38
- package/packages/core/src/ports/forge/local-git.ts +14 -0
- package/packages/core/src/ports/forge/readiness.ts +10 -0
- package/packages/core/src/ports/forge-failure.ts +43 -0
- package/packages/core/src/ports/runner/claude.ts +7 -1
- package/packages/core/src/ports/runner/codex.ts +7 -2
- package/packages/core/src/ports/runner/native-cli-fixture.ts +2 -1
- package/packages/core/src/ports/runner/pi.ts +7 -1
- package/packages/core/src/ports/runner/runtime.ts +3 -0
- package/packages/core/src/ports/runner/start-prompt.ts +37 -0
- package/packages/core/src/ports/tickets/contract.ts +320 -7
- package/packages/core/src/ports/tickets/create.ts +72 -17
- package/packages/core/src/ports/tickets/fake.ts +18 -0
- package/packages/core/src/ports/tickets/file-codec.ts +20 -0
- package/packages/core/src/ports/tickets/file.ts +43 -1
- package/packages/core/src/ports/tickets/github-fake.ts +1123 -0
- package/packages/core/src/ports/tickets/github-issues.ts +431 -0
- package/packages/core/src/ports/tickets/github-validators.ts +194 -0
- package/packages/core/src/ports/tickets/github.ts +2029 -0
- package/packages/core/src/ports/tickets/hosted-index.ts +34 -3
- package/packages/core/src/ports/tickets/issue-links.ts +86 -0
- package/packages/core/src/ports/tickets/lifecycle.ts +60 -4
- package/packages/core/src/ports/tickets/linear.ts +66 -6
- package/packages/core/src/ports/tickets/migration.ts +290 -68
- package/packages/core/src/ports/tickets/operations.ts +98 -12
- package/packages/core/src/ports/tickets/priority.ts +55 -0
- package/packages/core/src/ports/tickets/remote-protocol.ts +195 -29
- package/packages/core/src/ports/tickets/remote.ts +188 -13
- package/packages/core/src/ports/tickets/revision.ts +22 -1
- package/packages/core/src/ports/tickets/states.ts +43 -0
- package/packages/core/src/ports/tickets/tree.ts +58 -12
- package/packages/core/src/ports/tickets/update.ts +12 -2
- package/packages/core/src/ports/types.ts +190 -9
- package/packages/core/src/ports/workspace/commit-preservation.ts +135 -13
- package/packages/core/src/ports/workspace/git-worktree.ts +3 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +118 -27
- package/packages/core/src/processes/build-runner.ts +99 -21
- package/packages/core/src/processes/dispatcher.ts +822 -338
- package/packages/core/src/processes/execution-no-progress.ts +5 -0
- package/packages/core/src/processes/harvest-runner.ts +17 -8
- package/packages/core/src/processes/harvest.ts +5 -8
- package/packages/core/src/processes/tick-publication.ts +12 -2
- package/packages/core/src/processes/ticket-scan-schedule.ts +78 -0
- package/packages/core/src/processes/workspace-preservation.ts +36 -1
- package/packages/core/src/runtime-identity.ts +10 -2
- package/packages/core/src/scenarios/harness.ts +4 -0
- package/packages/core/src/store/adapter.ts +7 -1
- package/packages/core/src/store/contract.ts +83 -2
- package/packages/core/src/store/digest.ts +32 -1
- package/packages/core/src/store/reducer-value-shapes.json +4187 -3391
- package/packages/core/src/store/remote/protocol.ts +2 -0
- package/packages/core/src/store/remote/released-clients.json +11 -0
- package/packages/core/src/store/remote/released-reducer-values/1.5.0.json +26924 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +2 -0
- package/packages/core/src/store/repo-state-events.ts +2 -0
- package/packages/core/src/store/types.ts +5 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +729 -123
- package/packages/core/src/testing/index.ts +18 -1
- package/packages/core/src/testing/presence-history.ts +79 -0
- package/packages/core/src/testing/reduced-read-budget.ts +1085 -31
- package/packages/core/src/testing/upgrade-generations.ts +77 -0
- package/skills/code-review/SKILL.md +4 -3
- package/skills/finalize/SKILL.md +18 -2
- package/skills/guide/SKILL.md +374 -136
- package/skills/guide/references/accounts.md +9 -0
- package/skills/guide/references/integration-tree.md +91 -28
- package/skills/guide/references/merge-policy.md +28 -9
- package/skills/guide/references/operator-api.md +43 -18
- package/skills/guide/references/plugin-authoring.md +85 -8
- package/skills/guide/references/remote-store-protocol.md +25 -7
- package/skills/guide/references/remote-ticket-protocol.md +126 -12
- package/skills/guide/references/restacking.md +20 -6
- package/skills/guide/references/setup.md +19 -13
- package/skills/guide/references/spec-standard.md +2 -1
- package/skills/guide/references/ticket-dependencies.md +26 -8
- package/skills/guide/references/ticket-migration.md +70 -7
- package/skills/harvest-review/SKILL.md +4 -3
- package/skills/implement/SKILL.md +20 -1
- package/skills/operate/SKILL.md +103 -28
- package/skills/plan/SKILL.md +1 -1
- package/skills/reconcile/SKILL.md +5 -4
- package/skills/spec/SKILL.md +15 -2
- package/skills/tickets/SKILL.md +114 -37
- package/templates/autobuild.toml +5 -0
- package/templates/hosted-service/package.json +2 -2
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { boundedStateCount } from '../ports/tickets/states'
|
|
2
|
+
import type { TicketSource } from '../ports/types'
|
|
3
|
+
|
|
4
|
+
/** Minimum gap between display-only triage count reads, measured from the
|
|
5
|
+
* start of one read to the start of the next. Shared by the dispatcher's
|
|
6
|
+
* dashboard sampler and the viewer frontend. */
|
|
7
|
+
export const TRIAGE_COUNT_REFRESH_MS = 60_000
|
|
8
|
+
|
|
9
|
+
/** Background, single-flight sampler for the display-only triage count.
|
|
10
|
+
* Callers poke it between dispatcher ticks; it never runs inside one. A read
|
|
11
|
+
* that throws or answers `undefined` keeps the last good value, so the header
|
|
12
|
+
* shows `–` until the first success rather than an invented zero. */
|
|
13
|
+
export class TriageCountSampler {
|
|
14
|
+
private current: number | undefined
|
|
15
|
+
private lastStartedAt = -Infinity
|
|
16
|
+
private inFlight: Promise<void> | undefined
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
private readonly read: () => Promise<number | undefined>,
|
|
20
|
+
private readonly clock: () => Date,
|
|
21
|
+
private readonly intervalMs = TRIAGE_COUNT_REFRESH_MS,
|
|
22
|
+
) {}
|
|
23
|
+
|
|
24
|
+
get value(): number | undefined {
|
|
25
|
+
return this.current
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Start a background read when none is in flight and the interval has
|
|
29
|
+
* passed since the last read started. Never awaits the read. */
|
|
30
|
+
poke(): void {
|
|
31
|
+
const now = this.clock().getTime()
|
|
32
|
+
if (this.inFlight !== undefined || now - this.lastStartedAt < this.intervalMs) return
|
|
33
|
+
this.lastStartedAt = now
|
|
34
|
+
this.inFlight = (async () => {
|
|
35
|
+
try {
|
|
36
|
+
const count = await this.read()
|
|
37
|
+
if (count !== undefined) this.current = count
|
|
38
|
+
} catch {
|
|
39
|
+
// Display only: keep the last good count and retry after the interval.
|
|
40
|
+
} finally {
|
|
41
|
+
this.inFlight = undefined
|
|
42
|
+
}
|
|
43
|
+
})()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Resolves once the in-flight read, if any, finishes. For tests. */
|
|
47
|
+
async settled(): Promise<void> {
|
|
48
|
+
await this.inFlight
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** One bounded triage count read, never a state listing. The triage name
|
|
53
|
+
* is resolved per read so a config reload takes effect. */
|
|
54
|
+
export function triageReader(
|
|
55
|
+
source: Pick<TicketSource, 'countStates' | 'listStates'>,
|
|
56
|
+
triageName: () => string,
|
|
57
|
+
): () => Promise<number | undefined> {
|
|
58
|
+
return () => boundedStateCount(source, triageName())
|
|
59
|
+
}
|
|
@@ -457,6 +457,10 @@ export function summarizeEvent(event: AbEvent | RepositoryEvent, state: BuildSta
|
|
|
457
457
|
return `Account credentials recovered: ${JSON.stringify(event.payload.name)}`
|
|
458
458
|
case 'dispatcher.forge-recovered':
|
|
459
459
|
return `Forge recovered: ${event.payload.forge}`
|
|
460
|
+
case 'dispatcher.kernel-git-unavailable':
|
|
461
|
+
return `Kernel Git unavailable (${event.payload.executable}): ${singleLine(event.payload.detail)}`
|
|
462
|
+
case 'dispatcher.kernel-git-recovered':
|
|
463
|
+
return `Kernel Git recovered (${event.payload.executable})`
|
|
460
464
|
case 'phase.deferral-escalated':
|
|
461
465
|
case 'escalation.raised':
|
|
462
466
|
return `${event.payload.id}: ${singleLine(event.payload.question)}`
|
|
@@ -42,6 +42,8 @@ export const CONFIG_RELOAD_CLASSIFICATION = {
|
|
|
42
42
|
createState: 'restart',
|
|
43
43
|
triageState: 'hot',
|
|
44
44
|
proposalState: 'hot',
|
|
45
|
+
backlogState: 'hot',
|
|
46
|
+
rejectedState: 'hot',
|
|
45
47
|
dir: 'restart',
|
|
46
48
|
},
|
|
47
49
|
} as const satisfies {
|
|
@@ -148,8 +150,20 @@ export interface ConfigSnapshot {
|
|
|
148
150
|
|
|
149
151
|
export type ConfigReloadOutcome =
|
|
150
152
|
| { kind: 'unchanged' }
|
|
151
|
-
| {
|
|
152
|
-
|
|
153
|
+
| {
|
|
154
|
+
kind: 'rejected'
|
|
155
|
+
error: string
|
|
156
|
+
notify: boolean
|
|
157
|
+
/** Deprecation lines of a candidate that parsed but failed validation
|
|
158
|
+
* afterwards; non-empty only on the first evaluation of that content. */
|
|
159
|
+
deprecations?: readonly string[]
|
|
160
|
+
}
|
|
161
|
+
| {
|
|
162
|
+
kind: 'publication-failed'
|
|
163
|
+
error: string
|
|
164
|
+
/** As for `rejected`: non-empty only on first evaluation of the content. */
|
|
165
|
+
deprecations: readonly string[]
|
|
166
|
+
}
|
|
153
167
|
| {
|
|
154
168
|
kind: 'adopted'
|
|
155
169
|
snapshot: ConfigSnapshot
|
|
@@ -169,11 +183,18 @@ export type ConfigReloadPublisher = (input: {
|
|
|
169
183
|
* Process-local owner of the dispatcher's effective config. A candidate is
|
|
170
184
|
* published only after parsing, eager route validation, and durable journal
|
|
171
185
|
* publication all succeed. Callers capture `current()` once per boundary.
|
|
186
|
+
*
|
|
187
|
+
* Parsing never writes: deprecation lines are collected. `deprecations()`
|
|
188
|
+
* holds the accepted content's lines, and a candidate that parses but is not
|
|
189
|
+
* adopted returns its lines on the outcome once per distinct content, so a
|
|
190
|
+
* re-evaluated pending file stays quiet on later ticks.
|
|
172
191
|
*/
|
|
173
192
|
export class LiveConfig {
|
|
174
193
|
private snapshot: ConfigSnapshot
|
|
175
194
|
private acceptedContent: string
|
|
176
195
|
private rejectedContent: string | undefined
|
|
196
|
+
private acceptedDeprecations: readonly string[]
|
|
197
|
+
private noticedCandidate: string | undefined
|
|
177
198
|
|
|
178
199
|
constructor(
|
|
179
200
|
private readonly source: string,
|
|
@@ -181,8 +202,14 @@ export class LiveConfig {
|
|
|
181
202
|
startupContent: string,
|
|
182
203
|
private readonly runtimes: RuntimeRegistry,
|
|
183
204
|
private readonly publish: ConfigReloadPublisher,
|
|
205
|
+
startupDeprecations: readonly string[] = [],
|
|
206
|
+
/** A synchronous, request-free check of a composed reload against the
|
|
207
|
+
* running process (for example the ticket source's capabilities); a
|
|
208
|
+
* throw rejects the reload and keeps the previous snapshot. */
|
|
209
|
+
private readonly validate?: (config: Config) => void,
|
|
184
210
|
) {
|
|
185
211
|
this.acceptedContent = startupContent
|
|
212
|
+
this.acceptedDeprecations = startupDeprecations
|
|
186
213
|
this.snapshot = {
|
|
187
214
|
config: startup,
|
|
188
215
|
resolver: createRuntimeResolver(
|
|
@@ -199,6 +226,11 @@ export class LiveConfig {
|
|
|
199
226
|
return this.snapshot
|
|
200
227
|
}
|
|
201
228
|
|
|
229
|
+
/** Deprecation lines of the accepted content (startup or last adoption). */
|
|
230
|
+
deprecations(): readonly string[] {
|
|
231
|
+
return this.acceptedDeprecations
|
|
232
|
+
}
|
|
233
|
+
|
|
202
234
|
async refreshFromDisk(): Promise<ConfigReloadOutcome> {
|
|
203
235
|
return this.refreshFrom(() => Bun.file(this.source).text())
|
|
204
236
|
}
|
|
@@ -234,12 +266,14 @@ export class LiveConfig {
|
|
|
234
266
|
async refresh(content: string): Promise<ConfigReloadOutcome> {
|
|
235
267
|
if (content === this.acceptedContent) {
|
|
236
268
|
this.rejectedContent = undefined
|
|
269
|
+
this.noticedCandidate = undefined
|
|
237
270
|
return { kind: 'unchanged' }
|
|
238
271
|
}
|
|
239
272
|
|
|
240
273
|
let candidate: Config
|
|
274
|
+
const deprecations: string[] = []
|
|
241
275
|
try {
|
|
242
|
-
candidate = parseConfig(content, this.source)
|
|
276
|
+
candidate = parseConfig(content, this.source, (line) => deprecations.push(line))
|
|
243
277
|
} catch (error) {
|
|
244
278
|
const message = error instanceof Error ? error.message : String(error)
|
|
245
279
|
const notify = this.rejectedContent !== content
|
|
@@ -247,9 +281,13 @@ export class LiveConfig {
|
|
|
247
281
|
return { kind: 'rejected', error: message, notify }
|
|
248
282
|
}
|
|
249
283
|
|
|
284
|
+
const candidateDeprecations = this.noticedCandidate === content ? [] : deprecations
|
|
285
|
+
this.noticedCandidate = content
|
|
286
|
+
|
|
250
287
|
const config = composeReloadedConfig(this.startup, candidate)
|
|
251
288
|
let resolver: RuntimeResolver
|
|
252
289
|
try {
|
|
290
|
+
this.validate?.(config)
|
|
253
291
|
for (const [name, account] of Object.entries(this.snapshot.config.accounts)) {
|
|
254
292
|
if (account.kind === 'chatgpt-subscription' && !same(account, config.accounts[name]))
|
|
255
293
|
throw new Error(
|
|
@@ -266,7 +304,7 @@ export class LiveConfig {
|
|
|
266
304
|
const message = error instanceof Error ? error.message : String(error)
|
|
267
305
|
const notify = this.rejectedContent !== content
|
|
268
306
|
this.rejectedContent = content
|
|
269
|
-
return { kind: 'rejected', error: message, notify }
|
|
307
|
+
return { kind: 'rejected', error: message, notify, deprecations: candidateDeprecations }
|
|
270
308
|
}
|
|
271
309
|
|
|
272
310
|
const restartRequired = restartRequiredChanges(this.startup, candidate)
|
|
@@ -277,11 +315,14 @@ export class LiveConfig {
|
|
|
277
315
|
return {
|
|
278
316
|
kind: 'publication-failed',
|
|
279
317
|
error: error instanceof Error ? error.message : String(error),
|
|
318
|
+
deprecations: candidateDeprecations,
|
|
280
319
|
}
|
|
281
320
|
}
|
|
282
321
|
|
|
283
322
|
this.acceptedContent = content
|
|
323
|
+
this.acceptedDeprecations = deprecations
|
|
284
324
|
this.rejectedContent = undefined
|
|
325
|
+
this.noticedCandidate = undefined
|
|
285
326
|
this.snapshot = {
|
|
286
327
|
config,
|
|
287
328
|
resolver,
|
|
@@ -70,6 +70,15 @@ function describeIssue(issue: z.core.$ZodIssue): string {
|
|
|
70
70
|
return ` ${formatPath(path)}: ${message}`
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Parse and validate autobuild.toml text. Deprecated spellings are reported
|
|
75
|
+
* through `warn` after validation succeeds; invalid text throws first. The
|
|
76
|
+
* `console.error` default suits explicit one-shot reads (scoped CLI commands,
|
|
77
|
+
* `ab init`, `ab upgrade`). Recurring or internal callers — the dispatcher and
|
|
78
|
+
* pipeline-source resolution — pass their own sink, a collector or a no-op, so
|
|
79
|
+
* a deprecation is reported once per startup or changed file instead of per
|
|
80
|
+
* phase launch.
|
|
81
|
+
*/
|
|
73
82
|
export function parseConfig(
|
|
74
83
|
tomlText: string,
|
|
75
84
|
source = 'autobuild.toml',
|
|
@@ -170,7 +170,10 @@ function parsePipeline(
|
|
|
170
170
|
try {
|
|
171
171
|
return {
|
|
172
172
|
meta: commit === undefined ? { ref } : { ref, commit },
|
|
173
|
-
|
|
173
|
+
// Merge policy is dispatcher-owned (composeBuildConfig), so a branch's
|
|
174
|
+
// deprecated spelling is not reported per launch; the dispatcher reports
|
|
175
|
+
// its own config's deprecations at startup and reload.
|
|
176
|
+
config: parseConfig(content, `autobuild.toml@${label}`, () => {}),
|
|
174
177
|
}
|
|
175
178
|
} catch (error) {
|
|
176
179
|
onFailure({
|
|
@@ -412,6 +415,7 @@ export async function readVerifyPipeline(
|
|
|
412
415
|
committed.split(/\s+/)[2] === working
|
|
413
416
|
? { ref: 'branch-head', commit: head }
|
|
414
417
|
: { ref: 'worktree-dirty' },
|
|
415
|
-
|
|
418
|
+
// Dispatcher-owned keys are not read from here; see parsePipeline.
|
|
419
|
+
config: parseConfig(content, `autobuild.toml@${head}`, () => {}),
|
|
416
420
|
}
|
|
417
421
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `[tickets].readyAssignee` is a ticket-source capability. A source opts in
|
|
3
|
+
* with `readyAssignee = true` on the constructed `TicketSource`; parse time
|
|
4
|
+
* can only check the builtins, because plugins load after config parse, so the
|
|
5
|
+
* registry-aware seams (`createTicketSource` and `LiveConfig` reloads) enforce
|
|
6
|
+
* the declaration for every source. The value forms below are the builtins'
|
|
7
|
+
* own rules; a plugin source enforces its own.
|
|
8
|
+
*/
|
|
9
|
+
import type { TicketSource } from '../ports/types'
|
|
10
|
+
import type { TicketsConfig } from './schema'
|
|
11
|
+
|
|
12
|
+
export interface ReadyAssigneeForm {
|
|
13
|
+
accepts(value: string): boolean
|
|
14
|
+
message: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Linear: `"me"` (the owner of LINEAR_API_KEY) or a user's email. */
|
|
18
|
+
export const LINEAR_READY_ASSIGNEE: ReadyAssigneeForm = {
|
|
19
|
+
accepts: (s) => s === 'me' || (s === s.trim() && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)),
|
|
20
|
+
message:
|
|
21
|
+
'[tickets].readyAssignee must be "me" (the owner of the API key) or a user email address (e.g. "person@example.com")',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* GitHub: `"me"` (the owner of the GitHub credential) or a login. A personal
|
|
26
|
+
* login is alphanumerics and dashes; an Enterprise Managed User login is the
|
|
27
|
+
* normalized base, `_`, and a 3–8 character alphanumeric shortcode; either is
|
|
28
|
+
* at most 39 characters (docs.github.com, "Username considerations for
|
|
29
|
+
* external authentication"). The base is deliberately permissive about dash
|
|
30
|
+
* placement, since older accounts predate the normalization rules; `ab init
|
|
31
|
+
* --validate` proves the user can actually be assigned.
|
|
32
|
+
*/
|
|
33
|
+
export const GITHUB_READY_ASSIGNEE: ReadyAssigneeForm = {
|
|
34
|
+
accepts: (s) =>
|
|
35
|
+
s === 'me' || (s.length <= 39 && /^[A-Za-z0-9][A-Za-z0-9-]*(?:_[A-Za-z0-9]{3,8})?$/.test(s)),
|
|
36
|
+
message:
|
|
37
|
+
'[tickets].readyAssignee 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"',
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function readyAssigneeUnsupported(source: string, plugin?: string): string {
|
|
41
|
+
const from = plugin !== undefined ? ` from plugin "${plugin}"` : ''
|
|
42
|
+
return `[tickets].readyAssignee: ticket source "${source}"${from} cannot filter ready tickets by assignee — remove readyAssignee (selected source: "${source}")`
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Refuse `readyAssignee` for a constructed source that does not declare it. */
|
|
46
|
+
export function assertReadyAssigneeSupported(
|
|
47
|
+
tickets: TicketsConfig,
|
|
48
|
+
source: TicketSource,
|
|
49
|
+
plugin?: string,
|
|
50
|
+
): void {
|
|
51
|
+
if (tickets.readyAssignee !== undefined && source.readyAssignee !== true)
|
|
52
|
+
throw new Error(readyAssigneeUnsupported(tickets.source, plugin))
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The reload check: synchronous and request-free, because `LiveConfig`
|
|
57
|
+
* refreshes at the head of a dispatcher tick. It decides from what
|
|
58
|
+
* `prepareReadyAssignee` resolved at startup.
|
|
59
|
+
*/
|
|
60
|
+
export function assertReadyAssigneeAccepted(tickets: TicketsConfig, source: TicketSource): void {
|
|
61
|
+
assertReadyAssigneeSupported(tickets, source)
|
|
62
|
+
if (tickets.readyAssignee === undefined) return
|
|
63
|
+
const refusal = source.readyAssigneeRefusal?.(tickets.readyAssignee)
|
|
64
|
+
if (refusal !== undefined) throw new Error(refusal)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Dispatcher startup, before the loop: prepare whatever a later `"me"` needs,
|
|
69
|
+
* whether or not `readyAssignee` is set, so no tick ever resolves it. A
|
|
70
|
+
* preparation failure fails startup only when the configuration needs it.
|
|
71
|
+
*/
|
|
72
|
+
export async function prepareReadyAssigneeForDispatch(
|
|
73
|
+
source: TicketSource,
|
|
74
|
+
tickets: TicketsConfig,
|
|
75
|
+
warn: (message: string) => void,
|
|
76
|
+
): Promise<void> {
|
|
77
|
+
try {
|
|
78
|
+
await source.prepareReadyAssignee?.()
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (tickets.readyAssignee !== undefined) throw error
|
|
81
|
+
warn(
|
|
82
|
+
`ticket source "${source.name}" could not prepare readyAssignee: ${error instanceof Error ? error.message : String(error)}`,
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
assertReadyAssigneeAccepted(tickets, source)
|
|
86
|
+
}
|
|
@@ -18,6 +18,7 @@ import { documentSchema, documentFields } from './reference-metadata'
|
|
|
18
18
|
import { landingRuleSchema } from './landing'
|
|
19
19
|
export { landingRuleSchema, type LandingRule } from './landing'
|
|
20
20
|
import { normalizeServiceURL } from '../connection'
|
|
21
|
+
import { holdsState, ticketLifecycle } from '../ports/tickets/lifecycle'
|
|
21
22
|
import { prImageHostSchema } from '../ontology'
|
|
22
23
|
import { SANDBOX_FORBIDDEN_ENV } from '../ports/workspace/operator-sandbox'
|
|
23
24
|
import {
|
|
@@ -28,6 +29,11 @@ import {
|
|
|
28
29
|
import { defineEntry, openMap, ownEntries, parseEntry } from '../open-map'
|
|
29
30
|
import { forwardIssues } from '../zod-issues'
|
|
30
31
|
import { effectiveRuntimeReferences } from './roles'
|
|
32
|
+
import {
|
|
33
|
+
GITHUB_READY_ASSIGNEE,
|
|
34
|
+
LINEAR_READY_ASSIGNEE,
|
|
35
|
+
readyAssigneeUnsupported,
|
|
36
|
+
} from './ready-assignee'
|
|
31
37
|
|
|
32
38
|
// ── Open maps ────────────────────────────────────────────────────────────────
|
|
33
39
|
|
|
@@ -380,7 +386,7 @@ export interface WorkspaceProviderConfigDeclaration {
|
|
|
380
386
|
* carries EXACTLY ONE of `configSchema` / `configRefusalMessage`: when the
|
|
381
387
|
* schema is absent, the declaration must carry `configRefusalMessage` for
|
|
382
388
|
* nonempty provider config to be refused (the neither-key side is pinned by
|
|
383
|
-
* the AUT-565 test in config.test.ts), and carrying BOTH is forbidden —
|
|
389
|
+
* the AUT-565 test in config.integration.test.ts), and carrying BOTH is forbidden —
|
|
384
390
|
* `configSchema`'s superRefine checks `configRefusalMessage` first, so the
|
|
385
391
|
* refusal branch would win and the schema would silently never apply (the
|
|
386
392
|
* both-keys side is pinned by its sibling test). Providers absent from
|
|
@@ -756,10 +762,12 @@ documentFields(policySchema, {
|
|
|
756
762
|
'Active-time bound for each build agent session unless its logical role overrides it. Native continuation retains the original ceiling; suspension does not consume it.',
|
|
757
763
|
stallRounds: 'Escalate when the same review finding survives this many rounds.',
|
|
758
764
|
maxVerifyAttempts: 'Bound failure-driven verify \u2192 implement retry cycles.',
|
|
759
|
-
maxDispatchAttempts:
|
|
760
|
-
|
|
765
|
+
maxDispatchAttempts:
|
|
766
|
+
'Bound consecutive dispatch failures before a setup-targeted `dispatch-failure-limit` escalation.',
|
|
767
|
+
maxSetupAttempts:
|
|
768
|
+
'Bound consecutive workspace setup failures before a setup-targeted policy escalation.',
|
|
761
769
|
maxInfrastructureAttempts:
|
|
762
|
-
'Bound consecutive provision/start/wait/cleanup failures before a setup-targeted policy escalation; a
|
|
770
|
+
'Bound consecutive provision/start/wait/cleanup failures before a setup-targeted policy escalation; a `retry` answer from your operator agent or you re-arms this budget.',
|
|
763
771
|
maxReconcileAttempts:
|
|
764
772
|
'Bound completed reconciles that leave the PR conflicted against an unchanged authoritative base. Moving-base races do not consume the bound.',
|
|
765
773
|
maxReviewRounds:
|
|
@@ -796,8 +804,8 @@ export const ticketsInputSchema = z.strictObject({
|
|
|
796
804
|
* (§3.3). A nonempty list is conjunctive: every configured label must be
|
|
797
805
|
* present. For readyLabels = ["autobuild", "ready"], a ticket carrying only
|
|
798
806
|
* "autobuild" does not satisfy the label gate. An explicit [] disables the
|
|
799
|
-
* label gate; absent uses the ticket source's default (linear:
|
|
800
|
-
* file: none). Resolved by readyCriteria in src/processes/dispatcher.ts.
|
|
807
|
+
* label gate; absent uses the ticket source's default (linear and github:
|
|
808
|
+
* ["autobuild"]; file: none). Resolved by readyCriteria in src/processes/dispatcher.ts.
|
|
801
809
|
*/
|
|
802
810
|
readyLabels: z.array(z.string().min(1)).optional(),
|
|
803
811
|
/**
|
|
@@ -819,20 +827,24 @@ export const ticketsInputSchema = z.strictObject({
|
|
|
819
827
|
)
|
|
820
828
|
.optional(),
|
|
821
829
|
/**
|
|
822
|
-
* Narrows readiness to tickets assigned to one
|
|
823
|
-
*
|
|
824
|
-
*
|
|
825
|
-
*
|
|
826
|
-
*
|
|
830
|
+
* Narrows readiness to tickets assigned to one user — a third conjunctive
|
|
831
|
+
* gate beside readyState and readyLabels. A ticket-source capability: the
|
|
832
|
+
* source must declare `readyAssignee`, and it defines the value's forms.
|
|
833
|
+
* `"me"` is the owner of the source's credential (linear: LINEAR_API_KEY;
|
|
834
|
+
* github: the GitHub token); linear also takes an email, github a username.
|
|
835
|
+
* Unassigned tickets are never ready while it is set. Builtin forms are
|
|
836
|
+
* checked below; plugin declarations at the registry-aware seams
|
|
837
|
+
* (`config/ready-assignee.ts`). Absent leaves readiness unchanged.
|
|
827
838
|
*/
|
|
828
839
|
readyAssignee: z
|
|
829
840
|
.string()
|
|
830
841
|
.refine(
|
|
831
|
-
(s) => s
|
|
832
|
-
'[tickets].readyAssignee must be
|
|
842
|
+
(s) => s.trim().length > 0 && s === s.trim(),
|
|
843
|
+
'[tickets].readyAssignee must be a nonblank value with no surrounding whitespace',
|
|
833
844
|
)
|
|
834
845
|
.optional(),
|
|
835
|
-
/** Backend team key (e.g. "ENG") — required for linear and hosted
|
|
846
|
+
/** Backend team key (e.g. "ENG") — required for linear and hosted;
|
|
847
|
+
* forbidden for github. */
|
|
836
848
|
teamKey: z.string().min(1).optional(),
|
|
837
849
|
/** Workflow state claim() moves an issue to (§12); Linear and hosted. */
|
|
838
850
|
claimedState: z
|
|
@@ -875,6 +887,22 @@ export const ticketsInputSchema = z.strictObject({
|
|
|
875
887
|
.min(1)
|
|
876
888
|
.refine((value) => value.trim().length > 0, 'state must be nonblank')
|
|
877
889
|
.optional(),
|
|
890
|
+
/** State that holds deliberately deferred work — the backlog role. Optional
|
|
891
|
+
* with no default: unset means the role does not exist. Never dispatched
|
|
892
|
+
* from, moved into, or harvested into by the dispatcher. */
|
|
893
|
+
backlogState: z
|
|
894
|
+
.string()
|
|
895
|
+
.min(1)
|
|
896
|
+
.refine((value) => value.trim().length > 0, 'state must be nonblank')
|
|
897
|
+
.optional(),
|
|
898
|
+
/** State that holds considered-and-declined work — the rejected role.
|
|
899
|
+
* Optional with no default. A ticket in it never resolves a blocker and
|
|
900
|
+
* never keeps a node incomplete. */
|
|
901
|
+
rejectedState: z
|
|
902
|
+
.string()
|
|
903
|
+
.min(1)
|
|
904
|
+
.refine((value) => value.trim().length > 0, 'state must be nonblank')
|
|
905
|
+
.optional(),
|
|
878
906
|
/** Directory of state dirs (`triage/ ready/ doing/ done/`) holding `<id>.md`
|
|
879
907
|
* ticket files; optional — defaults to `.autobuild/tickets`, resolved
|
|
880
908
|
* relative to the repo. Kept schema-optional (not `.default()`) so the
|
|
@@ -889,7 +917,7 @@ documentFields(ticketsInputSchema, {
|
|
|
889
917
|
readyLabels: 'Require every listed label in addition to the state gate.',
|
|
890
918
|
readyState: 'The one workflow state eligible for dispatch.',
|
|
891
919
|
readyAssignee:
|
|
892
|
-
'Require the ticket to be assigned to one
|
|
920
|
+
'Require the ticket to be assigned to one user, in addition to the state and label gates.',
|
|
893
921
|
teamKey: 'Backend team key such as `"ENG"`, or an existing plugin config field.',
|
|
894
922
|
claimedState: 'Workflow state entered when a ticket is claimed.',
|
|
895
923
|
doneState: 'Project completion state and merged-ticket transition.',
|
|
@@ -897,50 +925,118 @@ documentFields(ticketsInputSchema, {
|
|
|
897
925
|
triageState: 'State used for spec-gate bounces, aborts, and closed-unmerged PRs.',
|
|
898
926
|
proposalState:
|
|
899
927
|
'State harvest files its synthesized proposals into. Setting it to `readyState` waives the human grooming gate, not dependency eligibility.',
|
|
928
|
+
backlogState:
|
|
929
|
+
'State that holds deliberately deferred work (the backlog role). Optional and recommended; unset means the role does not exist.',
|
|
930
|
+
rejectedState:
|
|
931
|
+
'State that holds considered-and-declined work (the rejected role). A rejected ticket never resolves a blocker and never keeps a node incomplete. Optional and recommended.',
|
|
900
932
|
dir: 'Root containing file-source state directories, or an existing plugin config field. Relative file paths resolve from the repository.',
|
|
901
933
|
})
|
|
902
934
|
documentSchema(ticketsInputSchema, {
|
|
903
935
|
constraints:
|
|
904
|
-
'readyState is required except for hosted, which
|
|
936
|
+
'readyState is required except for hosted and github, which resolve omission to ready. url is forbidden for file, linear and github; hosted URLs are normalized service URLs.',
|
|
905
937
|
})
|
|
906
938
|
documentSchema(ticketsInputSchema.shape.readyState, {
|
|
907
|
-
required:
|
|
939
|
+
required:
|
|
940
|
+
'Required unless source = "hosted" or "github"; omission there resolves to "ready". GitHub states are `autobuild:<state>` labels.',
|
|
908
941
|
})
|
|
909
942
|
documentSchema(ticketsInputSchema.shape.teamKey, {
|
|
910
|
-
required: 'Required for linear and hosted; forbidden for file; optional for plugins.',
|
|
943
|
+
required: 'Required for linear and hosted; forbidden for file and github; optional for plugins.',
|
|
911
944
|
})
|
|
912
945
|
documentSchema(ticketsInputSchema.shape.claimedState, { constraints: 'Forbidden for file.' })
|
|
913
|
-
documentSchema(ticketsInputSchema.shape.dir, {
|
|
914
|
-
|
|
946
|
+
documentSchema(ticketsInputSchema.shape.dir, {
|
|
947
|
+
constraints: 'Forbidden for linear, hosted and github.',
|
|
948
|
+
})
|
|
949
|
+
documentSchema(ticketsInputSchema.shape.readyAssignee, {
|
|
950
|
+
constraints:
|
|
951
|
+
'Allowed for sources that can filter by assignee: linear ("me" or an email), github ("me" or a GitHub username, including managed-user logins such as mona_acme), and plugin sources that declare readyAssignee. Refused for file and hosted.',
|
|
952
|
+
})
|
|
915
953
|
documentSchema(ticketsInputSchema.shape.readyLabels, {
|
|
916
954
|
constraints:
|
|
917
|
-
'Omission uses source readiness defaults (Linear: autobuild label; file: none). Explicit [] disables label gating.',
|
|
955
|
+
'Omission uses source readiness defaults (Linear and GitHub: autobuild label; file: none). Explicit [] disables label gating.',
|
|
918
956
|
})
|
|
919
957
|
documentSchema(ticketsInputSchema.shape.url, {
|
|
920
958
|
constraints:
|
|
921
|
-
'Forbidden for file and
|
|
959
|
+
'Forbidden for file, linear and github. Hosted omission uses the selected remote BuildStore URL; with a local BuildStore an explicit hosted URL is required.',
|
|
922
960
|
})
|
|
923
961
|
documentSchema(ticketsInputSchema.shape.doneState, {
|
|
924
|
-
constraints:
|
|
962
|
+
constraints:
|
|
963
|
+
'Hosted and github resolution uses done when omitted. A github ticket is done when its issue is closed as completed.',
|
|
925
964
|
})
|
|
926
965
|
documentSchema(ticketsInputSchema.shape.claimedState, {
|
|
927
966
|
constraints:
|
|
928
|
-
'Forbidden for file. Resolution uses In Progress for direct Linear, doing for hosted.',
|
|
967
|
+
'Forbidden for file. Resolution uses In Progress for direct Linear, doing for hosted and github.',
|
|
929
968
|
})
|
|
930
969
|
documentSchema(ticketsInputSchema.shape.createState, {
|
|
931
|
-
constraints:
|
|
970
|
+
constraints:
|
|
971
|
+
'Omission uses the source creation state (Linear team default; file Triage; github triage).',
|
|
932
972
|
})
|
|
933
973
|
documentSchema(ticketsInputSchema.shape.triageState, {
|
|
934
974
|
constraints:
|
|
935
|
-
'Omission resolves to Backlog for Linear, triage for hosted, Triage for file/plugin sources.',
|
|
975
|
+
'Omission resolves to Backlog for Linear, triage for hosted and github, Triage for file/plugin sources.',
|
|
936
976
|
})
|
|
937
977
|
documentSchema(ticketsInputSchema.shape.proposalState, {
|
|
938
978
|
constraints: 'Omission uses the resolved triageState.',
|
|
939
979
|
})
|
|
980
|
+
documentSchema(ticketsInputSchema.shape.backlogState, {
|
|
981
|
+
constraints:
|
|
982
|
+
'Optional for every source, no default; `ab init` writes it for new configurations. Must differ from the ready, claimed, done, triage and proposal states and from rejectedState (case-insensitive).',
|
|
983
|
+
})
|
|
984
|
+
documentSchema(ticketsInputSchema.shape.rejectedState, {
|
|
985
|
+
constraints:
|
|
986
|
+
'Optional for every source, no default; `ab init` writes it for new configurations. On github it maps to an issue closed as not planned. Must differ from the ready, claimed, done, triage and proposal states and from backlogState (case-insensitive).',
|
|
987
|
+
})
|
|
940
988
|
documentSchema(ticketsInputSchema.shape.dir, {
|
|
941
989
|
constraints:
|
|
942
|
-
'Forbidden for linear and
|
|
990
|
+
'Forbidden for linear, hosted and github. File omission resolves to the selected local state root tickets directory; plugin omission remains omitted.',
|
|
943
991
|
})
|
|
992
|
+
const FILE_CLAIMED_STATE = 'doing'
|
|
993
|
+
const FILE_DONE_STATE = 'Done'
|
|
994
|
+
const OPTIONAL_ROLES = [
|
|
995
|
+
['backlog', 'backlogState'],
|
|
996
|
+
['rejected', 'rejectedState'],
|
|
997
|
+
] as const
|
|
998
|
+
const DISPATCHER_ROLES = [
|
|
999
|
+
['ready', 'readyState'],
|
|
1000
|
+
['claimed', 'claimedState'],
|
|
1001
|
+
['done', 'doneState'],
|
|
1002
|
+
['triage', 'triageState'],
|
|
1003
|
+
['proposal', 'proposalState'],
|
|
1004
|
+
] as const
|
|
1005
|
+
|
|
1006
|
+
/** The backlog and rejected roles must hold their own states: the dispatcher
|
|
1007
|
+
* never claims from, moves into, or files proposals into them, whatever the
|
|
1008
|
+
* other lifecycle names say, and the two may not share a state. */
|
|
1009
|
+
function refuseOptionalRoleOverlap(tickets: TicketsConfig, ctx: z.RefinementCtx): void {
|
|
1010
|
+
const names = ticketLifecycle({ ...tickets, readyState: tickets.readyState ?? 'ready' })
|
|
1011
|
+
// The file source ignores claimedState and doneState: claims always move
|
|
1012
|
+
// into doing and completion is Done. Check the states it actually uses as
|
|
1013
|
+
// well as the configured spellings.
|
|
1014
|
+
const file = tickets.source === 'file'
|
|
1015
|
+
const resolved: Record<string, (string | undefined)[]> = {
|
|
1016
|
+
ready: [names.ready],
|
|
1017
|
+
claimed: file ? [FILE_CLAIMED_STATE, tickets.claimedState] : [names.doing],
|
|
1018
|
+
done: file ? [FILE_DONE_STATE, tickets.doneState] : [names.done],
|
|
1019
|
+
triage: [names.triage],
|
|
1020
|
+
proposal: [names.proposal],
|
|
1021
|
+
backlog: [names.backlog],
|
|
1022
|
+
rejected: [names.rejected],
|
|
1023
|
+
}
|
|
1024
|
+
for (const [index, [role, key]] of OPTIONAL_ROLES.entries()) {
|
|
1025
|
+
const name = tickets[key]
|
|
1026
|
+
if (name === undefined) continue
|
|
1027
|
+
const others = [...DISPATCHER_ROLES, ...OPTIONAL_ROLES.slice(index + 1)]
|
|
1028
|
+
for (const [other, otherKey] of others) {
|
|
1029
|
+
const held = resolved[other]?.find((state) => holdsState(name, state))
|
|
1030
|
+
if (held === undefined) continue
|
|
1031
|
+
ctx.addIssue({
|
|
1032
|
+
code: 'custom',
|
|
1033
|
+
path: [key],
|
|
1034
|
+
message: `[tickets].${key} "${name}" names the same state as the ${other} role ([tickets].${otherKey} resolves to "${held}"); the ${role} and ${other} roles must name different states`,
|
|
1035
|
+
})
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
|
|
944
1040
|
export const ticketsSchema = ticketsInputSchema
|
|
945
1041
|
.superRefine((tickets, ctx) => {
|
|
946
1042
|
if (tickets.source === 'hosted' && tickets.url !== undefined) {
|
|
@@ -950,19 +1046,20 @@ export const ticketsSchema = ticketsInputSchema
|
|
|
950
1046
|
ctx.addIssue({ code: 'custom', path: ['url'], message: (error as Error).message })
|
|
951
1047
|
}
|
|
952
1048
|
}
|
|
953
|
-
if (tickets.source
|
|
1049
|
+
if (!['hosted', 'github'].includes(tickets.source) && tickets.readyState === undefined)
|
|
954
1050
|
ctx.addIssue({
|
|
955
1051
|
code: 'custom',
|
|
956
1052
|
path: ['readyState'],
|
|
957
1053
|
message:
|
|
958
1054
|
'[tickets].readyState is required — name the one workflow state a ticket must sit in to be dispatched (e.g. "ready").',
|
|
959
1055
|
})
|
|
960
|
-
if (['file', 'linear'].includes(tickets.source) && tickets.url !== undefined)
|
|
1056
|
+
if (['file', 'linear', 'github'].includes(tickets.source) && tickets.url !== undefined)
|
|
961
1057
|
ctx.addIssue({
|
|
962
1058
|
code: 'custom',
|
|
963
1059
|
path: ['url'],
|
|
964
1060
|
message: '[tickets].url applies only to source = "hosted"',
|
|
965
1061
|
})
|
|
1062
|
+
refuseOptionalRoleOverlap(tickets as TicketsConfig, ctx)
|
|
966
1063
|
})
|
|
967
1064
|
.transform((tickets) => ({
|
|
968
1065
|
...tickets,
|
|
@@ -974,7 +1071,7 @@ export const ticketsSchema = ticketsInputSchema
|
|
|
974
1071
|
|
|
975
1072
|
documentSchema(ticketsSchema, {
|
|
976
1073
|
constraints:
|
|
977
|
-
'readyState is required except for hosted, whose omitted value resolves to ready. url is forbidden for file and
|
|
1074
|
+
'readyState is required except for hosted and github, whose omitted value resolves to ready. url is forbidden for file, linear and github; hosted URLs must be absolute HTTPS (loopback HTTP allowed), without credentials, query or fragment, and are normalized.',
|
|
978
1075
|
})
|
|
979
1076
|
export type TicketsConfig = z.infer<typeof ticketsSchema>
|
|
980
1077
|
|
|
@@ -1374,6 +1471,18 @@ export const configSchema = normalizedConfigSchema.superRefine((config, ctx) =>
|
|
|
1374
1471
|
message: '[tickets].dir applies only to source = "file" — remove it or set source = "file"',
|
|
1375
1472
|
})
|
|
1376
1473
|
}
|
|
1474
|
+
} else if (tickets.source === 'github') {
|
|
1475
|
+
// The forge repository is the tracker: no team or directory. A service
|
|
1476
|
+
// url is refused with the other non-hosted sources in ticketsSchema.
|
|
1477
|
+
for (const key of ['teamKey', 'dir'] as const) {
|
|
1478
|
+
if (tickets[key] !== undefined) {
|
|
1479
|
+
ctx.addIssue({
|
|
1480
|
+
code: 'custom',
|
|
1481
|
+
path: ['tickets', key],
|
|
1482
|
+
message: `[tickets].${key} applies only to source = ${key === 'dir' ? '"file"' : '"linear" or "hosted"'} — remove it for source = "github"`,
|
|
1483
|
+
})
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1377
1486
|
} else if (tickets.source === 'file') {
|
|
1378
1487
|
// dir is optional for the file source: absent = .autobuild/tickets.
|
|
1379
1488
|
for (const key of ['teamKey', 'claimedState'] as const) {
|
|
@@ -1386,12 +1495,31 @@ export const configSchema = normalizedConfigSchema.superRefine((config, ctx) =>
|
|
|
1386
1495
|
}
|
|
1387
1496
|
}
|
|
1388
1497
|
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1498
|
+
// readyAssignee is a source capability. Builtins are known here; a plugin
|
|
1499
|
+
// source passes parse and is checked against its declaration once
|
|
1500
|
+
// constructed (createTicketSource, LiveConfig reloads).
|
|
1501
|
+
const assignee = tickets.readyAssignee
|
|
1502
|
+
if (assignee !== undefined) {
|
|
1503
|
+
const form =
|
|
1504
|
+
tickets.source === 'linear'
|
|
1505
|
+
? LINEAR_READY_ASSIGNEE
|
|
1506
|
+
: tickets.source === 'github'
|
|
1507
|
+
? GITHUB_READY_ASSIGNEE
|
|
1508
|
+
: undefined
|
|
1509
|
+
if (tickets.source === 'file' || tickets.source === 'hosted') {
|
|
1510
|
+
ctx.addIssue({
|
|
1511
|
+
code: 'custom',
|
|
1512
|
+
path: ['tickets', 'readyAssignee'],
|
|
1513
|
+
message: readyAssigneeUnsupported(tickets.source),
|
|
1514
|
+
})
|
|
1515
|
+
} else if (
|
|
1516
|
+
form !== undefined &&
|
|
1517
|
+
assignee.trim().length > 0 &&
|
|
1518
|
+
assignee === assignee.trim() &&
|
|
1519
|
+
!form.accepts(assignee)
|
|
1520
|
+
) {
|
|
1521
|
+
ctx.addIssue({ code: 'custom', path: ['tickets', 'readyAssignee'], message: form.message })
|
|
1522
|
+
}
|
|
1395
1523
|
}
|
|
1396
1524
|
// Plugin sources receive the existing ticket lifecycle/configuration fields
|
|
1397
1525
|
// unchanged; adapter-specific validation belongs to their factory.
|