@defrex/autobuild 1.6.0 → 1.7.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.
Files changed (97) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +107 -10
  3. package/docs/agent-runtimes.md +1 -1
  4. package/docs/architecture.md +62 -22
  5. package/docs/configuration-overview.md +10 -0
  6. package/docs/configuration.md +285 -5
  7. package/docs/forges.md +1 -0
  8. package/docs/operator-api.md +19 -8
  9. package/docs/operator-surfaces.md +6 -3
  10. package/docs/plugin-authoring.md +44 -6
  11. package/docs/remote-store-protocol.md +19 -6
  12. package/docs/restacking.md +12 -7
  13. package/docs/ticket-sources.md +34 -6
  14. package/docs/tickets.md +6 -0
  15. package/docs/workspaces.md +1 -1
  16. package/package.json +3 -3
  17. package/packages/core/src/cli/attention.ts +1 -0
  18. package/packages/core/src/cli/binary-direct.ts +1 -0
  19. package/packages/core/src/cli/dispatch-frontend.ts +10 -14
  20. package/packages/core/src/cli/dispatch-preflight.ts +1 -0
  21. package/packages/core/src/cli/dispatch-repository-feed.ts +145 -109
  22. package/packages/core/src/cli/dispatch.ts +9 -3
  23. package/packages/core/src/cli/help.ts +11 -4
  24. package/packages/core/src/cli/init-validation.ts +14 -1
  25. package/packages/core/src/cli/repository-status.ts +37 -2
  26. package/packages/core/src/cli/status.ts +8 -0
  27. package/packages/core/src/cli/ticket.ts +22 -4
  28. package/packages/core/src/cli/watch.ts +2 -0
  29. package/packages/core/src/config/live.ts +4 -0
  30. package/packages/core/src/config/profiles.ts +96 -0
  31. package/packages/core/src/config/ready-assignee.ts +43 -11
  32. package/packages/core/src/config/roles.ts +33 -10
  33. package/packages/core/src/config/schema.ts +166 -24
  34. package/packages/core/src/events/compatibility.ts +3 -1
  35. package/packages/core/src/events/forge-degradation-policy.ts +16 -2
  36. package/packages/core/src/events/payloads.ts +8 -0
  37. package/packages/core/src/events/policy.ts +1 -0
  38. package/packages/core/src/events/repository.ts +17 -0
  39. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +73 -124
  40. package/packages/core/src/kernel/build-creation.ts +29 -0
  41. package/packages/core/src/kernel/forge-health.ts +47 -0
  42. package/packages/core/src/kernel/guarded-forge.ts +76 -18
  43. package/packages/core/src/kernel/node-parent.ts +2 -0
  44. package/packages/core/src/kernel/read-facts.ts +9 -1
  45. package/packages/core/src/kernel/reducer.ts +18 -1
  46. package/packages/core/src/kernel/ticket-preparation.ts +4 -1
  47. package/packages/core/src/operator/protocol.ts +10 -0
  48. package/packages/core/src/operator/query.ts +1 -1
  49. package/packages/core/src/operator/registry.ts +25 -5
  50. package/packages/core/src/operator/sandbox-host.ts +3 -0
  51. package/packages/core/src/operator/tickets.ts +15 -3
  52. package/packages/core/src/plugin-sdk/index.ts +4 -0
  53. package/packages/core/src/ports/forge/create.ts +6 -0
  54. package/packages/core/src/ports/forge/github-transport.ts +40 -3
  55. package/packages/core/src/ports/forge/github.ts +12 -1
  56. package/packages/core/src/ports/forge/workspace-ancestry.ts +60 -0
  57. package/packages/core/src/ports/forge-failure.ts +31 -2
  58. package/packages/core/src/ports/runner/routing.ts +66 -5
  59. package/packages/core/src/ports/tickets/assignees.ts +54 -0
  60. package/packages/core/src/ports/tickets/contract.ts +164 -4
  61. package/packages/core/src/ports/tickets/create.ts +17 -3
  62. package/packages/core/src/ports/tickets/github-fake.ts +18 -2
  63. package/packages/core/src/ports/tickets/github.ts +247 -29
  64. package/packages/core/src/ports/tickets/hosted-index.ts +1 -0
  65. package/packages/core/src/ports/tickets/operations.ts +6 -1
  66. package/packages/core/src/ports/tickets/tree.ts +12 -2
  67. package/packages/core/src/ports/tickets/update.ts +6 -2
  68. package/packages/core/src/ports/types.ts +33 -3
  69. package/packages/core/src/ports/workspace/vercel-sandbox.ts +9 -0
  70. package/packages/core/src/processes/build-child.ts +28 -7
  71. package/packages/core/src/processes/build-execution-state.ts +4 -1
  72. package/packages/core/src/processes/build-runner.ts +15 -1
  73. package/packages/core/src/processes/dispatcher.ts +98 -18
  74. package/packages/core/src/processes/harvest-child.ts +4 -0
  75. package/packages/core/src/processes/harvest-runner.ts +5 -0
  76. package/packages/core/src/processes/repo-view.ts +2 -0
  77. package/packages/core/src/scenarios/harness.ts +15 -1
  78. package/packages/core/src/store/reducer-value-shapes.json +3119 -2926
  79. package/packages/core/src/store/remote/client.ts +21 -8
  80. package/packages/core/src/store/remote/index.ts +4 -0
  81. package/packages/core/src/store/remote/protocol.ts +7 -0
  82. package/packages/core/src/store/remote/released-clients.json +11 -0
  83. package/packages/core/src/store/remote/released-reducer-values/1.7.0.json +27366 -0
  84. package/packages/core/src/store/remote/released-reducer-values/index.ts +2 -0
  85. package/packages/core/src/store/repo-state-events.ts +1 -0
  86. package/packages/core/src/store/types.ts +11 -0
  87. package/packages/core/src/testing/dispatch-read-budget.ts +84 -58
  88. package/packages/core/src/testing/index.ts +2 -0
  89. package/packages/core/src/testing/reduced-read-budget.ts +72 -9
  90. package/skills/guide/SKILL.md +116 -21
  91. package/skills/guide/references/operator-api.md +19 -8
  92. package/skills/guide/references/plugin-authoring.md +44 -6
  93. package/skills/guide/references/remote-store-protocol.md +19 -6
  94. package/skills/guide/references/restacking.md +12 -7
  95. package/skills/operate/SKILL.md +29 -3
  96. package/skills/tickets/SKILL.md +18 -2
  97. package/templates/hosted-service/package.json +2 -2
@@ -8,7 +8,9 @@ import type { BuildStore, Clock } from '../store/types'
8
8
 
9
9
  const handoffTypes = new Set<string>(DISPATCH_HANDOFF_EVENT_TYPES)
10
10
 
11
- export function isDashboardRepositoryEvent(event: RepositoryEvent): boolean {
11
+ /** Dashboard-class facts a version-4 checkpoint cached; only legacy restore
12
+ * validation still recognizes them. */
13
+ function isLegacyDashboardEvent(event: RepositoryEvent): boolean {
12
14
  return (
13
15
  handoffTypes.has(event.type) ||
14
16
  event.type.startsWith('harvest.') ||
@@ -19,37 +21,36 @@ export function isDashboardRepositoryEvent(event: RepositoryEvent): boolean {
19
21
  )
20
22
  }
21
23
 
24
+ /** The version-4 checkpoint shape, normalized once on restore. */
25
+ const LEGACY_VERSION = 4
26
+
22
27
  export const dispatchFrontendReducer = defineReducer({
23
- version: 4,
24
- initial: (): { retained: RepositoryEvent[]; incompleteIdentities: boolean; holder?: string } => ({
25
- retained: [],
26
- incompleteIdentities: true,
27
- }),
28
+ version: 5,
29
+ initial: (): { identities: RepositoryEvent[]; holder?: string } => ({ identities: [] }),
28
30
  fold(acc, events: readonly RepositoryEvent[]) {
29
- const facts = new Map(acc.retained.map((event) => [event.seq, event]))
31
+ const starts = new Map(acc.identities.map((event) => [event.seq, event]))
30
32
  for (const event of events) {
31
- if (isDashboardRepositoryEvent(event) || event.type === 'dispatcher.run-started')
32
- facts.set(event.seq, event)
33
+ if (event.type === 'dispatcher.run-started') starts.set(event.seq, event)
33
34
  }
34
- const sorted = [...facts.values()].sort((a, b) => a.seq - b.seq)
35
- const latest = sorted.findLast((event) => event.type === 'dispatcher.run-started')
35
+ const sorted = [...starts.values()].sort((a, b) => a.seq - b.seq)
36
+ const latest = sorted.at(-1)
36
37
  const holder = sorted.findLast(
37
38
  (event) => event.type === 'dispatcher.run-started' && event.payload.run === acc.holder,
38
39
  )
39
- acc.retained = sorted.filter(
40
- (event) => event.type !== 'dispatcher.run-started' || event === latest || event === holder,
41
- )
42
- acc.incompleteIdentities = true
40
+ acc.identities = sorted.filter((event) => event === latest || event === holder)
43
41
  },
44
- finish: (acc) => acc.retained,
42
+ finish: (acc) => acc.identities,
45
43
  })
46
44
 
45
+ type FrontendState = { identities: RepositoryEvent[]; holder?: string }
46
+
47
47
  /** One serialized, frontend-only repository projection. The consumed cursor is
48
48
  * independent of retained facts: quiet ticks must never survive in the cache.
49
- * Presentation reads canonical repository facts; the dashboard-event cache holds
50
- * only facts after the feed's restoration point. Without a usable checkpoint,
51
- * startup and cursor-expiry recovery seed identities from the canonical
52
- * `repositoryReadFacts` value, never from the journal. */
49
+ * The checkpoint holds standby identities only (the latest run start and the
50
+ * selected holder's start); presentation reads canonical repository facts.
51
+ * Without a usable checkpoint, startup and cursor-expiry recovery seed
52
+ * identities from the canonical `repositoryReadFacts` value, never from the
53
+ * journal. */
53
54
  export class DispatchRepositoryFeed {
54
55
  private cursor = 0
55
56
  private ready = false
@@ -71,11 +72,13 @@ export class DispatchRepositoryFeed {
71
72
  private readonly clock: Clock,
72
73
  ) {}
73
74
 
74
- get events(): RepositoryEvent[] {
75
- return this.retained.filter(isDashboardRepositoryEvent)
76
- }
77
75
  get identities(): RepositoryEvent[] {
78
- return this.retained.filter((e) => e.type === 'dispatcher.run-started')
76
+ return this.retained
77
+ }
78
+
79
+ /** A consumed nonzero cursor proves the repository journal exists. */
80
+ get present(): boolean {
81
+ return this.cursor > 0
79
82
  }
80
83
 
81
84
  private validate(events: RepositoryEvent[], cursor: number, contiguous: boolean): void {
@@ -108,15 +111,103 @@ export class DispatchRepositoryFeed {
108
111
  }
109
112
  }
110
113
 
114
+ /** Validate a version-5 checkpoint; a re-fold that changes nothing is clean. */
115
+ private restoreCurrent(state: unknown, cursor: number): FrontendState & { clean: boolean } {
116
+ const current = state as FrontendState
117
+ if (!current || !Array.isArray(current.identities) || current.identities.length > 2)
118
+ throw new Error('invalid projection')
119
+ this.validate(current.identities, 0, false)
120
+ if (current.identities.some((e) => e.seq > cursor || e.type !== 'dispatcher.run-started'))
121
+ throw new Error('invalid identity')
122
+ if (current.holder !== undefined && typeof current.holder !== 'string')
123
+ throw new Error('invalid holder')
124
+ const identities = dispatchFrontendReducer.advance(
125
+ { identities: current.identities, holder: current.holder },
126
+ [],
127
+ ).identities
128
+ return {
129
+ identities,
130
+ holder: current.holder,
131
+ clean: identities.length === current.identities.length,
132
+ }
133
+ }
134
+
135
+ /** Normalize a version-4 checkpoint: its dashboard-event cache is discarded
136
+ * and only the identities survive. Never clean, so the next save replaces it. */
137
+ private restoreLegacy(state: unknown, cursor: number): FrontendState {
138
+ const legacy = state as {
139
+ retained: RepositoryEvent[]
140
+ incompleteIdentities: boolean
141
+ holder?: string
142
+ }
143
+ if (
144
+ !legacy ||
145
+ !Array.isArray(legacy.retained) ||
146
+ typeof legacy.incompleteIdentities !== 'boolean'
147
+ )
148
+ throw new Error('invalid projection')
149
+ this.validate(legacy.retained, 0, false)
150
+ if (
151
+ legacy.retained.some(
152
+ (e) =>
153
+ e.seq > cursor || !(isLegacyDashboardEvent(e) || e.type === 'dispatcher.run-started'),
154
+ )
155
+ )
156
+ throw new Error('invalid retained fact')
157
+ if (legacy.holder !== undefined && typeof legacy.holder !== 'string')
158
+ throw new Error('invalid holder')
159
+ return {
160
+ identities: dispatchFrontendReducer.advance(
161
+ { identities: [], holder: legacy.holder },
162
+ legacy.retained,
163
+ ).identities,
164
+ holder: legacy.holder,
165
+ }
166
+ }
167
+
168
+ /** The current checkpoint, or else one read of a legacy version-4 row. */
169
+ private async restore(
170
+ high: number,
171
+ ): Promise<(FrontendState & { cursor: number; clean: boolean }) | undefined> {
172
+ const scope = { kind: 'repo', repo: this.repo } as const
173
+ const usable = (cursor: number) => cursor <= high && high - cursor <= REPOSITORY_TAIL_WINDOW
174
+ const snapshot = await loadReducerSnapshot(
175
+ this.store,
176
+ scope,
177
+ 'dispatchFrontend',
178
+ dispatchFrontendReducer,
179
+ )
180
+ if (snapshot) {
181
+ if (!usable(snapshot.cursor)) return undefined
182
+ try {
183
+ return { ...this.restoreCurrent(snapshot.state, snapshot.cursor), cursor: snapshot.cursor }
184
+ } catch {
185
+ return undefined
186
+ }
187
+ }
188
+ const legacy = await loadReducerSnapshot(this.store, scope, 'dispatchFrontend', {
189
+ version: LEGACY_VERSION,
190
+ })
191
+ if (!legacy || !usable(legacy.cursor)) return undefined
192
+ try {
193
+ return {
194
+ ...this.restoreLegacy(legacy.state, legacy.cursor),
195
+ cursor: legacy.cursor,
196
+ clean: false,
197
+ }
198
+ } catch {
199
+ return undefined
200
+ }
201
+ }
202
+
111
203
  refresh(persist = true): Promise<RepositoryEvent[]> {
112
204
  let result: RepositoryEvent[] = []
113
205
  const next = this.tail.then(async () => {
114
206
  let holder = this.holder
115
207
  let cursor = this.cursor
116
- let retained = this.retained
117
- let incompleteIdentities = this.incompleteIdentities
208
+ let identities = this.retained
118
209
  let restoredKey: string | undefined
119
- let restoredRetained: RepositoryEvent[] | undefined
210
+ let restoredIdentities: RepositoryEvent[] | undefined
120
211
  let delta: RepositoryEvent[]
121
212
  if (!this.ready) {
122
213
  if ((await this.store.getRepo(this.repo)) === null) {
@@ -125,54 +216,19 @@ export class DispatchRepositoryFeed {
125
216
  return
126
217
  }
127
218
  const high = await this.store.getRepoHighWater(this.repo)
128
- const snapshot = await loadReducerSnapshot(
129
- this.store,
130
- { kind: 'repo', repo: this.repo },
131
- 'dispatchFrontend',
132
- dispatchFrontendReducer,
133
- )
134
- let restored = false
135
- if (
136
- snapshot &&
137
- snapshot.cursor <= high &&
138
- high - snapshot.cursor <= REPOSITORY_TAIL_WINDOW
139
- ) {
140
- try {
141
- const state = snapshot.state as {
142
- retained: RepositoryEvent[]
143
- incompleteIdentities: boolean
144
- holder?: string
145
- }
146
- if (!Array.isArray(state.retained) || typeof state.incompleteIdentities !== 'boolean')
147
- throw new Error('invalid projection')
148
- this.validate(state.retained, 0, false)
149
- if (
150
- state.retained.some(
151
- (e) =>
152
- e.seq > snapshot.cursor ||
153
- !(isDashboardRepositoryEvent(e) || e.type === 'dispatcher.run-started'),
154
- )
155
- )
156
- throw new Error('invalid retained fact')
157
- if (state.holder !== undefined && typeof state.holder !== 'string')
158
- throw new Error('invalid holder')
159
- holder = state.holder
160
- retained = dispatchFrontendReducer.advance({ ...state }, []).retained
161
- incompleteIdentities = true
162
- if (state.incompleteIdentities && retained.length === state.retained.length) {
163
- restoredKey = `${snapshot.cursor}:${this.generation}`
164
- restoredRetained = retained
165
- }
166
- cursor = snapshot.cursor
167
- restored = true
168
- } catch {
169
- /* A malformed cache uses the canonical seed. */
219
+ // A malformed, stale or missing cache uses the canonical seed.
220
+ const restored = await this.restore(high)
221
+ if (restored) {
222
+ holder = restored.holder
223
+ identities = restored.identities
224
+ cursor = restored.cursor
225
+ if (restored.clean) {
226
+ restoredKey = `${restored.cursor}:${this.generation}`
227
+ restoredIdentities = identities
170
228
  }
171
- }
172
- if (!restored) {
229
+ } else {
173
230
  const seed = await this.canonicalSeed(holder)
174
- incompleteIdentities = true
175
- retained = seed.retained
231
+ identities = seed.identities
176
232
  cursor = seed.cursor
177
233
  }
178
234
  delta = await this.readStartupTail(cursor)
@@ -192,22 +248,17 @@ export class DispatchRepositoryFeed {
192
248
  // A standby correlation may have supplied an older identity while the
193
249
  // delta read was pending. Keep those memoized facts in this commit.
194
250
  holder = this.holder
195
- retained = this.retained
196
- incompleteIdentities = this.incompleteIdentities
251
+ identities = this.retained
197
252
  }
198
253
  if (delta.length > 0)
199
- retained = dispatchFrontendReducer.advance(
200
- { retained, incompleteIdentities, holder },
201
- delta,
202
- ).retained
254
+ identities = dispatchFrontendReducer.advance({ identities, holder }, delta).identities
203
255
  this.holder = holder
204
256
  this.cursor = Math.max(cursor, delta.at(-1)?.seq ?? 0)
205
- this.incompleteIdentities = true
206
257
  if (restoredKey !== undefined) {
207
258
  this.settled = restoredKey
208
- this.retained = restoredRetained!
259
+ this.retained = restoredIdentities!
209
260
  }
210
- this.replaceRetained(retained)
261
+ this.replaceIdentities(identities)
211
262
 
212
263
  this.ready = true
213
264
  this.recovery = false
@@ -220,14 +271,11 @@ export class DispatchRepositoryFeed {
220
271
  const cursor = seed.cursor
221
272
  const delta = await this.readStartupTail(cursor)
222
273
  this.validate(delta, cursor, true)
223
- this.replaceRetained(
224
- dispatchFrontendReducer.advance(
225
- { retained: seed.retained, incompleteIdentities: true, holder: this.holder },
226
- delta,
227
- ).retained,
274
+ this.replaceIdentities(
275
+ dispatchFrontendReducer.advance({ identities: seed.identities, holder: this.holder }, delta)
276
+ .identities,
228
277
  )
229
278
  this.cursor = Math.max(cursor, delta.at(-1)?.seq ?? 0)
230
- this.incompleteIdentities = true
231
279
  this.ready = true
232
280
  this.recovery = false
233
281
  this.boundary = undefined
@@ -242,7 +290,7 @@ export class DispatchRepositoryFeed {
242
290
  * repository value: cost is independent of journal and current-run length. */
243
291
  private async canonicalSeed(
244
292
  holder: string | undefined,
245
- ): Promise<{ cursor: number; retained: RepositoryEvent[] }> {
293
+ ): Promise<{ cursor: number; identities: RepositoryEvent[] }> {
246
294
  const { cursor, value } = await readRepositoryFacts(this.store, this.repo, true)
247
295
  const runs = new Map(value.recentRuns)
248
296
  const starts = new Map<number, RepositoryEvent>()
@@ -258,10 +306,7 @@ export class DispatchRepositoryFeed {
258
306
  throw new Error('invalid canonical identity')
259
307
  return {
260
308
  cursor,
261
- retained: dispatchFrontendReducer.advance(
262
- { retained: [], incompleteIdentities: true, holder },
263
- sorted,
264
- ).retained,
309
+ identities: dispatchFrontendReducer.advance({ identities: [], holder }, sorted).identities,
265
310
  }
266
311
  }
267
312
 
@@ -271,7 +316,7 @@ export class DispatchRepositoryFeed {
271
316
  return this.store.getRepositoryTail(this.repo, cursor)
272
317
  }
273
318
 
274
- private replaceRetained(events: RepositoryEvent[]): void {
319
+ private replaceIdentities(events: RepositoryEvent[]): void {
275
320
  // Sequence numbers identify immutable journal facts; no deep serialization on polls.
276
321
  const changed =
277
322
  events !== this.retained &&
@@ -285,15 +330,8 @@ export class DispatchRepositoryFeed {
285
330
  if (this.holder === holder) return
286
331
  this.generation++
287
332
  this.holder = holder
288
- this.replaceRetained(
289
- dispatchFrontendReducer.advance(
290
- {
291
- retained: this.retained,
292
- incompleteIdentities: true,
293
- holder,
294
- },
295
- [],
296
- ).retained,
333
+ this.replaceIdentities(
334
+ dispatchFrontendReducer.advance({ identities: this.retained, holder }, []).identities,
297
335
  )
298
336
  }
299
337
 
@@ -304,11 +342,9 @@ export class DispatchRepositoryFeed {
304
342
  0,
305
343
  false,
306
344
  )
307
- this.replaceRetained(
308
- dispatchFrontendReducer.advance(
309
- { retained: this.retained, incompleteIdentities: true, holder: this.holder },
310
- eligible,
311
- ).retained,
345
+ this.replaceIdentities(
346
+ dispatchFrontendReducer.advance({ identities: this.retained, holder: this.holder }, eligible)
347
+ .identities,
312
348
  )
313
349
  }
314
350
 
@@ -321,7 +357,7 @@ export class DispatchRepositoryFeed {
321
357
  const snapshot = {
322
358
  version: dispatchFrontendReducer.version,
323
359
  cursor: this.cursor,
324
- state: { retained: this.retained, incompleteIdentities: true, holder: this.holder },
360
+ state: { identities: this.retained, holder: this.holder },
325
361
  }
326
362
  this.nextSaveAt = now + 30_000
327
363
  this.saving = persistReducerSnapshotOutcome(
@@ -1,4 +1,5 @@
1
1
  import {
2
+ assertCreateAssigneeAccepted,
2
3
  assertReadyAssigneeAccepted,
3
4
  prepareReadyAssigneeForDispatch,
4
5
  } from '../config/ready-assignee'
@@ -602,8 +603,9 @@ async function defaultWire(
602
603
  opened.localStateRoot,
603
604
  plugins,
604
605
  )
605
- // Once, before the loop: whatever a readyAssignee value needs is resolved
606
- // here so neither a tick nor a reload ever spends a request on it.
606
+ // Once, before the loop: whatever a readyAssignee or createAssignee value
607
+ // needs is resolved here so neither a tick nor a reload ever spends a
608
+ // request on it.
607
609
  await prepareReadyAssigneeForDispatch(tickets, config.tickets, (line) => {
608
610
  if (opts.silent !== true) opts.stderr(`warning: ${line}`)
609
611
  })
@@ -4880,6 +4882,7 @@ class DispatchLoop {
4880
4882
  config.roles,
4881
4883
  config.policy.sessionBudgetSeconds,
4882
4884
  config.accounts,
4885
+ config.profiles,
4883
4886
  )
4884
4887
  const deadline = new Date(
4885
4888
  Date.parse(retirement.startedAt) + config.policy.upgradeDrainSeconds * 1000,
@@ -5662,7 +5665,10 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5662
5665
  wiring.updateRuntimeReferences?.(effectiveConfig)
5663
5666
  },
5664
5667
  startupDeprecations,
5665
- (next) => assertReadyAssigneeAccepted(next.tickets, wiring.tickets),
5668
+ (next) => {
5669
+ assertReadyAssigneeAccepted(next.tickets, wiring.tickets)
5670
+ assertCreateAssigneeAccepted(next.tickets, wiring.tickets)
5671
+ },
5666
5672
  )
5667
5673
 
5668
5674
  // Launch flags are durable repository setters. Omission writes nothing, so
@@ -201,12 +201,12 @@ export const HELP_CATALOG: readonly HelpEntry[] = [
201
201
  detail: page([
202
202
  'Usage:',
203
203
  ' ab ticket tree [--json]',
204
- ' ab ticket create <title> --body <file> [--state <state>] [--labels a,b] [--blocked-by id,id] [--issues N[:refs],...] [--priority urgent|normal] [--kind work|node] [--target <id> | --no-target] [--json]',
204
+ ' ab ticket create <title> --body <file> [--state <state>] [--labels a,b] [--blocked-by id,id] [--issues N[:refs],...] [--priority urgent|normal] [--assignees a,b] [--kind work|node] [--target <id> | --no-target] [--json]',
205
205
  ' ab ticket edit <id>',
206
206
  ' ab ticket export <dir> [--store <ref>]',
207
207
  ' ab ticket import <dir> [--states <state,...>] [--store <ref>]',
208
208
  ' ab ticket migration record <dir> [--store <ref>]',
209
- ' ab ticket update <id> [--kind work|node] [--target <id> | --no-target] [--title <title>] [--body <file>] [--labels a,b] [--issues N[:refs],...] [--priority urgent|normal] [--expected-revision <opaque>] [--json]',
209
+ ' ab ticket update <id> [--kind work|node] [--target <id> | --no-target] [--title <title>] [--body <file>] [--labels a,b] [--issues N[:refs],...] [--priority urgent|normal] [--assignees a,b] [--expected-revision <opaque>] [--json]',
210
210
  ' ab ticket block <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json]',
211
211
  ' ab ticket unblock <id> <blocker-id[,blocker-id...]> [--expected-revision <opaque>] [--json]',
212
212
  ' ab ticket list [--state <state>] [--labels a,b] [--json]',
@@ -243,12 +243,18 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
243
243
  'in source order; it never preempts a running build. normal (the default)',
244
244
  'removes urgency. Sources that cannot store priority refuse urgent, name the',
245
245
  'source, and write nothing; normal is a no-op there.',
246
+ '--assignees entries are usernames or me (the owner of the source credential).',
247
+ 'On create they replace the [tickets].createAssignee default and --assignees ""',
248
+ 'creates an unassigned ticket; on update they replace the set and "" clears it.',
249
+ 'Sources that cannot store assignees refuse the write, name the source, and',
250
+ 'write nothing.',
246
251
  '',
247
252
  'With no list filters, list uses the same ready criteria as dispatch. show one ticket, including its body/spec.',
248
253
  'Human output is the default and marks urgent tickets. --json emits exactly',
249
254
  'one bare value, and every JSON ticket names its priority: Ticket[]',
250
255
  'for list, the hierarchy for tree, and the resulting Ticket for ticket mutations; show',
251
- 'adds an assets array (kind, name, revision, size, layout, fileCount).',
256
+ 'adds an assets array (kind, name, revision, size, layout, fileCount). Sources',
257
+ 'that store assignees add an assignees array of usernames.',
252
258
  '',
253
259
  'Ticket assets are files or folders (a design export, a reference screenshot, a',
254
260
  'sample payload) attached to a ticket and kept in the BuildStore, never in the',
@@ -407,7 +413,8 @@ These fields describe intent; dispatch and merge behavior are unchanged.`,
407
413
  'Consent and held ready merges use only build.consent-ready, once per readiness episode.',
408
414
  'Unready or stale consent candidates stay silent; one merge gate decision per build/PR.',
409
415
  'Repository: harvest.escalated, harvest.recovery-exhausted, dispatcher.config-rejected, dispatcher.forge-readiness-failed,',
410
- 'dispatcher.kernel-git-unavailable, dispatcher.config-reloaded with restartRequired, abnormal dispatcher.run-stopped,',
416
+ 'dispatcher.kernel-git-unavailable, forge.credential-limited, dispatcher.config-reloaded with restartRequired,',
417
+ 'abnormal dispatcher.run-stopped,',
411
418
  'abandoned ticket-preparation.resolved (claim confirmed or unconfirmed; ticket unchanged),',
412
419
  'and dispatcher.lost. dispatcher.ticket-source-persistent reports degradation past',
413
420
  'resetAt after a tick started at or after reset completes or fails while still degraded,',
@@ -158,7 +158,13 @@ function effectiveTargets(
158
158
  ): Array<{ runtime: string; models: string[] }> {
159
159
  // Preserve eager registry/model/argument validation, but probe only routes
160
160
  // the pipeline can consume rather than every declared role table.
161
- createRuntimeResolver(runtimes, config.roles, config.policy.sessionBudgetSeconds, config.accounts)
161
+ createRuntimeResolver(
162
+ runtimes,
163
+ config.roles,
164
+ config.policy.sessionBudgetSeconds,
165
+ config.accounts,
166
+ config.profiles,
167
+ )
162
168
  return effectiveRuntimeReferences(config).flatMap((group) => {
163
169
  const selected = Object.keys(config.accounts).length ? group.legacyAuthentication : group
164
170
  if (selected === undefined) return []
@@ -577,6 +583,7 @@ async function validateInitReadinessInner(opts: {
577
583
  ])
578
584
  let caps: WorkspaceProviderCapabilities | undefined
579
585
  let assigneeLine: string | undefined
586
+ let createAssigneeLine: string | undefined
580
587
  let roles: Awaited<ReturnType<typeof ticketRoleReadiness>> = { notes: [], checks: [] }
581
588
  let forgeChecks: ForgeReadinessCheck[] = readinessChecks(
582
589
  'unknown',
@@ -659,6 +666,11 @@ async function validateInitReadinessInner(opts: {
659
666
  const assignee = config.tickets.readyAssignee
660
667
  if (assignee !== undefined && ticketSource.describeReadyAssignee !== undefined)
661
668
  assigneeLine = `Ticket assignee gate: ${await ticketSource.describeReadyAssignee(assignee)}`
669
+ // Who every created ticket would be assigned to, so a create never
670
+ // finds out first.
671
+ const createAssignee = config.tickets.createAssignee
672
+ if (createAssignee !== undefined && ticketSource.describeCreateAssignee !== undefined)
673
+ createAssigneeLine = `Ticket create assignee: ${await ticketSource.describeCreateAssignee(createAssignee)}`
662
674
  await ticketSource.listReady({
663
675
  ...(config.tickets.readyLabels !== undefined ? { labels: config.tickets.readyLabels } : {}),
664
676
  state: config.tickets.readyState,
@@ -809,6 +821,7 @@ async function validateInitReadinessInner(opts: {
809
821
  stdout(`Store: ${state.storeRef}`)
810
822
  stdout(`Forge: ${config.forge}`)
811
823
  if (assigneeLine !== undefined) stdout(assigneeLine)
824
+ if (createAssigneeLine !== undefined) stdout(createAssigneeLine)
812
825
  for (const note of roles.notes) stdout(note)
813
826
  // Same raw `[workspace.config]` fallback guestEnvNames gets (f_55ba7591): a
814
827
  // provider that declares describeEnvironment without a configSchema still
@@ -16,7 +16,13 @@ import {
16
16
  type DispatchCapacity,
17
17
  type CapacityBuild,
18
18
  } from '../kernel/dispatch-capacity'
19
- import { forgeHealthReducer, type ForgeDegradation } from '../kernel/forge-health'
19
+ import {
20
+ activeForgeCredentialLimits,
21
+ forgeCredentialLimitsReducer,
22
+ forgeHealthReducer,
23
+ type ForgeCredentialLimit,
24
+ type ForgeDegradation,
25
+ } from '../kernel/forge-health'
20
26
  import { forgeHotspot, type ForgeRequestCounts } from '../ports/forge-telemetry'
21
27
  import { configSchema } from '../config/schema'
22
28
  import type { BuildStore } from '../store/types'
@@ -167,6 +173,10 @@ export interface RepositoryStatus extends DispatchSettings {
167
173
  capacity?: DispatchCapacity
168
174
  /** Dispatcher startup warnings, then forge readiness warnings. */
169
175
  warningLines?: string[]
176
+ /** Standing ticket diagnostics from the latest completed ticket scan — for
177
+ * example an invalid ticket, or a ready ticket whose labels select more than
178
+ * one role profile and is therefore not claimed. */
179
+ ticketDiagnostics?: string[]
170
180
  /** Standing dependency/target diagnostics from the latest completed ticket
171
181
  * scan — for example a ticket held because its target node is being built
172
182
  * by another store. */
@@ -176,6 +186,10 @@ export interface RepositoryStatus extends DispatchSettings {
176
186
  forgeRequests?: ForgeRequestCounts
177
187
  forgeRequestHotspot?: string
178
188
  forgeDegradation?: ForgeDegradation
189
+ /** Active rate limits outside the dispatcher's credential (unauthenticated
190
+ * requests, build runners, phase sessions). They never pause dispatcher
191
+ * forge work; each names the limited process. */
192
+ forgeCredentialLimits?: ForgeCredentialLimit[]
179
193
  ticketSourceDegradation?: TicketSourceDegradation
180
194
  /** Live operator sandboxes (AUT-340); released environments are omitted. */
181
195
  sandboxes: Array<{
@@ -216,7 +230,12 @@ export function projectRepositoryStatus(
216
230
  repo: string,
217
231
  events: RepositoryEvent[],
218
232
  dispatcher = projectDispatcherLiveness(null, [], new Date()),
233
+ now: Date = new Date(),
219
234
  ): RepositoryStatus {
235
+ const credentialLimits = activeForgeCredentialLimits(
236
+ forgeCredentialLimitsReducer.reduce(events),
237
+ now,
238
+ )
220
239
  const publications: RepositoryStatus['publications'] = []
221
240
  for (const event of events) {
222
241
  if (event.type !== 'orchestrator.sandbox.published') continue
@@ -252,10 +271,15 @@ export function projectRepositoryStatus(
252
271
  latestScan?.type === 'dispatcher.ticket-scan-completed'
253
272
  ? latestScan.payload.dependencyDiagnostics
254
273
  : []
274
+ const ticketDiagnostics =
275
+ latestScan?.type === 'dispatcher.ticket-scan-completed'
276
+ ? latestScan.payload.ticketDiagnostics
277
+ : []
255
278
  return {
256
279
  ...(forgeHealthReducer.reduce(events)
257
280
  ? { forgeDegradation: forgeHealthReducer.reduce(events) }
258
281
  : {}),
282
+ ...(credentialLimits.length ? { forgeCredentialLimits: credentialLimits } : {}),
259
283
  ...(active === undefined ? {} : { ticketSourceDegradation: active }),
260
284
  ...(Object.keys(repositoryReadFactsReducer.reduce(events).missingAccounts).length
261
285
  ? { missingAccounts: repositoryReadFactsReducer.reduce(events).missingAccounts }
@@ -266,6 +290,7 @@ export function projectRepositoryStatus(
266
290
  upgradeStatus: projectUpgradeStatus(dispatchUpgradeReducer.reduce(events), dispatcher),
267
291
  rollbackHold: effectiveRollbackHold(dispatchUpgradeReducer.reduce(events), dispatcher),
268
292
  ...(warningLines.length ? { warningLines } : {}),
293
+ ...(ticketDiagnostics.length ? { ticketDiagnostics: [...ticketDiagnostics] } : {}),
269
294
  ...(dependencyDiagnostics.length ? { dependencyDiagnostics: [...dependencyDiagnostics] } : {}),
270
295
  dispatcher,
271
296
  ...(() => {
@@ -294,11 +319,14 @@ export function repositoryStatusFromFacts(
294
319
  repo: string,
295
320
  facts: RepositoryReadFacts,
296
321
  dispatcher: DispatcherLiveness,
322
+ now: Date = new Date(),
297
323
  ): RepositoryStatus {
324
+ const credentialLimits = activeForgeCredentialLimits(facts.forgeCredentialLimits, now)
298
325
  const warningLines = facts.status
299
326
  ? [...facts.status.roleWarnings, ...forgeReadinessWarnings(facts.status)]
300
327
  : []
301
328
  const dependencyDiagnostics = facts.scan?.dependencyDiagnostics ?? []
329
+ const ticketDiagnostics = facts.scan?.ticketDiagnostics ?? []
302
330
  return {
303
331
  ...(Object.keys(facts.missingAccounts).length
304
332
  ? { missingAccounts: facts.missingAccounts }
@@ -309,6 +337,7 @@ export function repositoryStatusFromFacts(
309
337
  upgradeStatus: projectUpgradeStatus(facts.upgrades, dispatcher),
310
338
  rollbackHold: effectiveRollbackHold(facts.upgrades, dispatcher),
311
339
  ...(warningLines.length ? { warningLines } : {}),
340
+ ...(ticketDiagnostics.length ? { ticketDiagnostics: [...ticketDiagnostics] } : {}),
312
341
  ...(dependencyDiagnostics.length ? { dependencyDiagnostics: [...dependencyDiagnostics] } : {}),
313
342
  dispatcher,
314
343
  ...(() => {
@@ -321,6 +350,7 @@ export function repositoryStatusFromFacts(
321
350
  })(),
322
351
  ...facts.settings,
323
352
  ...(facts.forgeHealth ? { forgeDegradation: facts.forgeHealth } : {}),
353
+ ...(credentialLimits.length ? { forgeCredentialLimits: credentialLimits } : {}),
324
354
  ...(facts.health === undefined ? {} : { ticketSourceDegradation: facts.health }),
325
355
  sandboxes: facts.sandboxes
326
356
  .filter((state) => state.state !== 'released')
@@ -425,6 +455,10 @@ export function renderRepositoryStatus(status: RepositoryStatus): string[] {
425
455
  `forge ${status.forgeDegradation.forge}: degraded — ${status.forgeDegradation.message}; reset ${status.forgeDegradation.resetAt}`,
426
456
  ]
427
457
  : []),
458
+ ...(status.forgeCredentialLimits ?? []).map(
459
+ (limit) =>
460
+ `forge ${limit.forge}: ${limit.process} rate-limited (${limit.credential}${limit.missingCredential ? `: ${limit.missingCredential}` : ''}) until ${limit.resetAt}; dispatcher forge work is not paused`,
461
+ ),
428
462
  ...(active === undefined
429
463
  ? []
430
464
  : [
@@ -458,6 +492,7 @@ export function renderRepositoryStatus(status: RepositoryStatus): string[] {
458
492
  `intake: ${setting(status.intake)}`,
459
493
  `repository pause: ${setting(status.paused)}`,
460
494
  `default auto-merge: ${setting(status.defaultAutoMerge)}`,
495
+ ...(status.ticketDiagnostics ?? []).map((line) => `queue: ${line}`),
461
496
  ...(status.dependencyDiagnostics ?? []).map((line) => `queue: ${line}`),
462
497
  ...status.sandboxes.map(
463
498
  (sandbox) =>
@@ -525,7 +560,7 @@ export async function abRepositoryStatus(opts: RepositoryStatusOpts): Promise<vo
525
560
  const observedAt = opts.now?.() ?? new Date()
526
561
  const { dispatcher } = await readDispatcherLiveness(store, repo, observedAt)
527
562
  const facts = (await readRepositoryFacts(store, repo)).value
528
- const status = repositoryStatusFromFacts(repo, facts, dispatcher)
563
+ const status = repositoryStatusFromFacts(repo, facts, dispatcher, observedAt)
529
564
  status.operator = {
530
565
  presence: 'loaded',
531
566
  registrations: (await store.listOperatorPresence(repo))
@@ -185,6 +185,9 @@ export interface BuildDetail extends BuildSummary {
185
185
  issueLinks?: BuildState['issueLinks']
186
186
  /** Present with `issueLinks`: whether finalize sealed them for the PR. */
187
187
  issueLinksSealed?: boolean
188
+ /** The role profile frozen at claim; `configured: false` when the latest
189
+ * session found it removed and used the repository roles. Omitted when none. */
190
+ profile?: { name: string; configured: boolean }
188
191
  suspendedSessions: OpenSession[]
189
192
  sessionTotals: BuildState['sessions']['totals']
190
193
  openSessions: StatusOpenSession[]
@@ -412,6 +415,7 @@ export function detailFromFacts(
412
415
  issueLinksSealed: state.issueLinksSealedSeq !== undefined,
413
416
  }
414
417
  : {}),
418
+ ...(state.profile !== undefined ? { profile: { ...state.profile } } : {}),
415
419
  ...(state.reviewRoundCeilings.plan !== undefined || state.reviewRoundCeilings.code !== undefined
416
420
  ? { reviewRoundCeilings: { ...state.reviewRoundCeilings } }
417
421
  : {}),
@@ -637,6 +641,10 @@ export function renderDetail(d: BuildDetail, now: Date): string[] {
637
641
  const sealed = d.issueLinksSealed === true ? ' (sealed)' : ''
638
642
  lines.push(` issues: ${safeStatusText(describeIssueLinks(d.issueLinks))}${sealed}`)
639
643
  }
644
+ if (d.profile !== undefined)
645
+ lines.push(
646
+ ` profile: ${safeStatusText(d.profile.name)}${d.profile.configured ? '' : " (no longer configured — sessions use the repository's roles)"}`,
647
+ )
640
648
  if (d.target)
641
649
  lines.push(
642
650
  ` ${d.kind ?? 'work'} · target ${d.target}${d.integration ? ` · ${d.integration}` : ''}`,