@defrex/autobuild 0.14.0 → 1.0.0-beta.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 (172) hide show
  1. package/README.md +4 -2
  2. package/SPEC.md +654 -98
  3. package/docs/architecture.md +226 -5
  4. package/docs/assets/headline-wide.png +0 -0
  5. package/docs/configuration.md +112 -12
  6. package/docs/hosted-service.md +18 -0
  7. package/docs/integration-tree.md +117 -0
  8. package/docs/landing-policy.md +150 -0
  9. package/docs/mcp.md +24 -0
  10. package/docs/migration-1.0.md +68 -0
  11. package/docs/operator-api.md +19 -8
  12. package/docs/remote-store-protocol.md +30 -7
  13. package/docs/remote-ticket-protocol.md +26 -5
  14. package/docs/restacking.md +79 -0
  15. package/docs/setup.md +49 -6
  16. package/docs/ticket-dependencies.md +69 -0
  17. package/docs/ticket-migration.md +8 -0
  18. package/package.json +3 -3
  19. package/packages/core/src/cli/attention.ts +25 -2
  20. package/packages/core/src/cli/build-control.ts +65 -41
  21. package/packages/core/src/cli/context.ts +54 -2
  22. package/packages/core/src/cli/dashboard/actions.ts +6 -3
  23. package/packages/core/src/cli/dashboard/landing-display.ts +6 -0
  24. package/packages/core/src/cli/dashboard/live.ts +5 -0
  25. package/packages/core/src/cli/dashboard/model.ts +142 -18
  26. package/packages/core/src/cli/dashboard/poll.ts +15 -9
  27. package/packages/core/src/cli/dashboard/refresh.ts +176 -0
  28. package/packages/core/src/cli/dashboard/render.ts +78 -28
  29. package/packages/core/src/cli/dashboard/repository-poll.ts +57 -0
  30. package/packages/core/src/cli/dashboard/selection.ts +7 -1
  31. package/packages/core/src/cli/dashboard/tree.ts +107 -0
  32. package/packages/core/src/cli/dispatch-frontend.ts +156 -109
  33. package/packages/core/src/cli/dispatch.ts +250 -136
  34. package/packages/core/src/cli/dispatcher-liveness.ts +15 -2
  35. package/packages/core/src/cli/help.ts +49 -32
  36. package/packages/core/src/cli/init-validation.ts +43 -2
  37. package/packages/core/src/cli/keyboard.ts +6 -0
  38. package/packages/core/src/cli/landings.ts +18 -0
  39. package/packages/core/src/cli/main.ts +49 -15
  40. package/packages/core/src/cli/mcp.ts +9 -0
  41. package/packages/core/src/cli/publication-settlement.ts +168 -2
  42. package/packages/core/src/cli/repository-status.ts +11 -0
  43. package/packages/core/src/cli/status.ts +72 -5
  44. package/packages/core/src/cli/terminal-restore.ts +54 -0
  45. package/packages/core/src/cli/terminal.ts +16 -2
  46. package/packages/core/src/cli/terminals.ts +98 -79
  47. package/packages/core/src/cli/ticket-editor.ts +10 -3
  48. package/packages/core/src/cli/ticket.ts +113 -18
  49. package/packages/core/src/cli/upgrade-commit.ts +4 -0
  50. package/packages/core/src/cli/upgrade-compatibility.ts +2 -2
  51. package/packages/core/src/cli/upgrade-landing.ts +69 -0
  52. package/packages/core/src/cli/upgrade.ts +16 -0
  53. package/packages/core/src/cli/wait.ts +115 -19
  54. package/packages/core/src/cli/watch.ts +51 -12
  55. package/packages/core/src/config/landing.ts +22 -0
  56. package/packages/core/src/config/live.ts +1 -0
  57. package/packages/core/src/config/schema.ts +3 -0
  58. package/packages/core/src/events/catalog.ts +48 -3
  59. package/packages/core/src/events/payloads.ts +295 -6
  60. package/packages/core/src/events/repository.ts +31 -0
  61. package/packages/core/src/integration/harness.ts +10 -0
  62. package/packages/core/src/kernel/__snapshots__/reducer-registry.test.ts.snap +1030 -239
  63. package/packages/core/src/kernel/auto-merge-default.ts +1 -0
  64. package/packages/core/src/kernel/auto-merge.ts +12 -3
  65. package/packages/core/src/kernel/build-identity.ts +94 -0
  66. package/packages/core/src/kernel/change-presence.ts +179 -0
  67. package/packages/core/src/kernel/dispatch-status.ts +17 -1
  68. package/packages/core/src/kernel/engine.ts +89 -2
  69. package/packages/core/src/kernel/generators/build-log.ts +23 -0
  70. package/packages/core/src/kernel/generators/leaf-restack-log.ts +110 -0
  71. package/packages/core/src/kernel/generators/node-restack-log.ts +94 -0
  72. package/packages/core/src/kernel/generators/repository-journals.ts +11 -0
  73. package/packages/core/src/kernel/integration-completeness.ts +81 -0
  74. package/packages/core/src/kernel/integration-landing.ts +263 -0
  75. package/packages/core/src/kernel/integration-stack.ts +36 -0
  76. package/packages/core/src/kernel/integration-state.ts +135 -0
  77. package/packages/core/src/kernel/landing-policy.ts +47 -0
  78. package/packages/core/src/kernel/landing-publication.ts +41 -0
  79. package/packages/core/src/kernel/landing-readiness.ts +67 -0
  80. package/packages/core/src/kernel/landing-state.ts +96 -0
  81. package/packages/core/src/kernel/leaf-restack-completion.ts +24 -0
  82. package/packages/core/src/kernel/leaf-restack-state.ts +73 -0
  83. package/packages/core/src/kernel/log-index.ts +35 -5
  84. package/packages/core/src/kernel/node-landing.ts +439 -0
  85. package/packages/core/src/kernel/node-parent.ts +184 -0
  86. package/packages/core/src/kernel/node-restack-state.ts +191 -0
  87. package/packages/core/src/kernel/node-restack-transaction.ts +210 -0
  88. package/packages/core/src/kernel/node-restack.ts +274 -0
  89. package/packages/core/src/kernel/read-facts.ts +70 -3
  90. package/packages/core/src/kernel/reconcile-head.ts +51 -0
  91. package/packages/core/src/kernel/reconcile-restack.ts +560 -0
  92. package/packages/core/src/kernel/reducer-registry.ts +16 -0
  93. package/packages/core/src/kernel/reducer.ts +121 -6
  94. package/packages/core/src/kernel/snapshot-parent.ts +33 -0
  95. package/packages/core/src/ontology.ts +9 -1
  96. package/packages/core/src/operator/annotations.ts +12 -0
  97. package/packages/core/src/operator/control.ts +6 -0
  98. package/packages/core/src/operator/index.ts +4 -0
  99. package/packages/core/src/operator/landings.ts +35 -0
  100. package/packages/core/src/operator/presentation.ts +1 -0
  101. package/packages/core/src/operator/protocol.ts +12 -3
  102. package/packages/core/src/operator/query.ts +3 -1
  103. package/packages/core/src/operator/registry.ts +48 -19
  104. package/packages/core/src/operator/requests.ts +1 -8
  105. package/packages/core/src/operator/tickets.ts +55 -9
  106. package/packages/core/src/ports/forge/contract.ts +91 -3
  107. package/packages/core/src/ports/forge/fake.ts +142 -4
  108. package/packages/core/src/ports/forge/git-rewrite.ts +232 -0
  109. package/packages/core/src/ports/forge/github-readiness.ts +421 -0
  110. package/packages/core/src/ports/forge/github.ts +631 -35
  111. package/packages/core/src/ports/forge/local-git.ts +119 -5
  112. package/packages/core/src/ports/forge/readiness.ts +99 -0
  113. package/packages/core/src/ports/tickets/contract.ts +41 -0
  114. package/packages/core/src/ports/tickets/create.ts +8 -1
  115. package/packages/core/src/ports/tickets/fake.ts +32 -1
  116. package/packages/core/src/ports/tickets/file-codec.ts +7 -0
  117. package/packages/core/src/ports/tickets/file.ts +18 -1
  118. package/packages/core/src/ports/tickets/hosted-index.ts +2 -0
  119. package/packages/core/src/ports/tickets/linear.ts +124 -4
  120. package/packages/core/src/ports/tickets/migration.ts +25 -1
  121. package/packages/core/src/ports/tickets/operations.ts +7 -2
  122. package/packages/core/src/ports/tickets/remote-protocol.ts +19 -0
  123. package/packages/core/src/ports/tickets/remote.ts +10 -1
  124. package/packages/core/src/ports/tickets/revision.ts +3 -1
  125. package/packages/core/src/ports/tickets/tree.ts +148 -0
  126. package/packages/core/src/ports/tickets/update.ts +15 -2
  127. package/packages/core/src/ports/types.ts +135 -5
  128. package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
  129. package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -1
  130. package/packages/core/src/ports/workspace/vercel-sandbox.ts +60 -3
  131. package/packages/core/src/processes/build-runner.ts +530 -23
  132. package/packages/core/src/processes/dispatcher-selectors.ts +15 -9
  133. package/packages/core/src/processes/dispatcher.ts +2145 -203
  134. package/packages/core/src/processes/execution-no-progress.ts +46 -1
  135. package/packages/core/src/processes/publication-state.ts +30 -5
  136. package/packages/core/src/processes/repo-view.ts +21 -2
  137. package/packages/core/src/store/build-scope.ts +18 -0
  138. package/packages/core/src/store/contract.ts +658 -0
  139. package/packages/core/src/store/digest.ts +52 -4
  140. package/packages/core/src/store/local/schema.ts +25 -13
  141. package/packages/core/src/store/local/store.ts +117 -1
  142. package/packages/core/src/store/memory.ts +62 -1
  143. package/packages/core/src/store/phase-session.ts +17 -0
  144. package/packages/core/src/store/reduced-reads.ts +2 -1
  145. package/packages/core/src/store/reducer-value-shapes.json +10707 -6440
  146. package/packages/core/src/store/remote/client.ts +44 -0
  147. package/packages/core/src/store/remote/compatibility.ts +19 -9
  148. package/packages/core/src/store/remote/protocol.ts +11 -0
  149. package/packages/core/src/store/repo-state-events.ts +2 -0
  150. package/packages/core/src/store/session-handle.ts +15 -0
  151. package/packages/core/src/store/subscribe.ts +1 -1
  152. package/packages/core/src/store/types.ts +32 -4
  153. package/packages/core/src/testing/index.ts +2 -0
  154. package/packages/core/src/testing/reduced-read-budget.ts +48 -8
  155. package/packages/core/src/testing/refresh-scheduler.ts +32 -0
  156. package/skills/guide/SKILL.md +110 -61
  157. package/skills/guide/references/integration-tree.md +117 -0
  158. package/skills/guide/references/landing-policy.md +150 -0
  159. package/skills/guide/references/migration-1.0.md +68 -0
  160. package/skills/guide/references/operator-api.md +12 -5
  161. package/skills/guide/references/plugin-authoring.md +34 -0
  162. package/skills/guide/references/remote-store-protocol.md +30 -7
  163. package/skills/guide/references/remote-ticket-protocol.md +26 -5
  164. package/skills/guide/references/restacking.md +79 -0
  165. package/skills/guide/references/setup.md +49 -6
  166. package/skills/guide/references/ticket-dependencies.md +69 -0
  167. package/skills/guide/references/ticket-migration.md +8 -0
  168. package/skills/operate/SKILL.md +55 -5
  169. package/skills/reconcile/SKILL.md +55 -48
  170. package/skills/spec/SKILL.md +67 -1
  171. package/skills/tickets/SKILL.md +55 -2
  172. package/templates/autobuild.toml +3 -0
@@ -1,3 +1,12 @@
1
+ import { forgeReadinessWarnings } from '../kernel/dispatch-status'
2
+ import { RepositoryPollCache } from './dashboard/repository-poll'
3
+ import {
4
+ DashboardRefresh,
5
+ interactionRead,
6
+ presentationReader,
7
+ type RefreshScheduler,
8
+ } from './dashboard/refresh'
9
+ import { FOCUS_REPORTING_MODE, installPresentationSuspension } from './terminal-restore'
1
10
  import { DispatchRepositoryFeed } from './dispatch-repository-feed'
2
11
  import { StandbyIdentityResolver } from './dispatcher-liveness'
3
12
  import { configSchema, type Config } from '../config/schema'
@@ -25,7 +34,7 @@ import {
25
34
  type DashboardSelection,
26
35
  type DashboardView,
27
36
  } from './dashboard/model'
28
- import { DashboardBuildPollCache } from './dashboard/poll'
37
+ import { DashboardBuildPollCache, type DashboardPollSnapshot } from './dashboard/poll'
29
38
  import {
30
39
  dashboardContentWidth,
31
40
  detailScrollLimit,
@@ -48,9 +57,10 @@ import {
48
57
  type DispatchChildOptions,
49
58
  } from './dispatch-process'
50
59
 
51
- const POLL_MS = 500
60
+ import type { TicketSource } from '../ports/types'
61
+
52
62
  const PAINT_MS = 250
53
- const ABORTABLE_STATUSES = new Set(['queued', 'running', 'paused', 'blocked'])
63
+ const ABORTABLE_STATUSES = new Set(['queued', 'running', 'collecting', 'paused', 'blocked'])
54
64
 
55
65
  function validAbortConfirmation(state: BuildState | undefined): boolean {
56
66
  return (
@@ -84,6 +94,7 @@ export interface DispatchFrontendOptions {
84
94
  checkout?: string
85
95
  storeRef: string
86
96
  store: BuildStore
97
+ ticketSource?: () => Promise<TicketSource>
87
98
  env: Record<string, string | undefined>
88
99
  terminal: TerminalOut
89
100
  input: TerminalInput
@@ -92,6 +103,7 @@ export interface DispatchFrontendOptions {
92
103
  intervalMs?: number
93
104
  intake?: boolean
94
105
  defaultAutoMerge?: boolean
106
+ refreshScheduler?: RefreshScheduler
95
107
  clock?: Clock
96
108
  resolveDashboardRenderer?: DashboardRendererResolver
97
109
  launchChild?: (input: {
@@ -134,18 +146,19 @@ export class DispatchFrontend {
134
146
  private abortConfirmation: { slug: string } | undefined
135
147
  private accepting = false
136
148
  private cleanupInput: (() => void) | undefined
137
- private pollTimer: ReturnType<typeof setInterval> | undefined
149
+ private refresh: DashboardRefresh | undefined
150
+ private suspension: ReturnType<typeof installPresentationSuspension> | undefined
151
+ private readonly reader: BuildStore
138
152
  private paintTimer: ReturnType<typeof setInterval> | undefined
139
- private polling = false
140
- private pollInFlight: Promise<void> | undefined
141
153
  private actionTail: Promise<void> = Promise.resolve()
142
154
  private presentationRestored = false
143
155
  private operatorStopRequested = false
144
156
 
145
157
  constructor(private readonly opts: DispatchFrontendOptions) {
158
+ this.reader = presentationReader(opts.store, () => this.refresh?.admitted ?? true)
146
159
  this.clock = opts.clock ?? systemClock
147
- this.repositoryFeed = new DispatchRepositoryFeed(opts.store, opts.repo, this.clock)
148
- this.standbyResolver = new StandbyIdentityResolver(opts.store, opts.repo, {
160
+ this.repositoryFeed = new DispatchRepositoryFeed(this.reader, opts.repo, this.clock)
161
+ this.standbyResolver = new StandbyIdentityResolver(this.reader, opts.repo, {
149
162
  allowLookup: () => this.repositoryFeed.incompleteIdentities,
150
163
  remember: (events, complete) => this.repositoryFeed.remember(events, complete),
151
164
  })
@@ -180,8 +193,10 @@ export class DispatchFrontend {
180
193
  })
181
194
  }
182
195
 
183
- private queue(operation: () => Promise<void>): void {
184
- const result = this.actionTail.then(operation)
196
+ private queue(operation: () => Promise<void>, interaction = true): void {
197
+ const result = this.actionTail.then(() =>
198
+ interaction ? interactionRead(operation) : operation(),
199
+ )
185
200
  this.actionTail = result.then(
186
201
  () => undefined,
187
202
  async (error) => {
@@ -190,7 +205,7 @@ export class DispatchFrontend {
190
205
  `dashboard action failed: ${error instanceof Error ? error.message : String(error)}`,
191
206
  'warning',
192
207
  )
193
- await this.renderOnce()
208
+ await this.renderOnce(interaction)
194
209
  } catch {
195
210
  // The next poll remains the recovery boundary.
196
211
  }
@@ -254,6 +269,7 @@ export class DispatchFrontend {
254
269
  }
255
270
 
256
271
  private paint(): void {
272
+ if (this.refresh !== undefined && !this.refresh.painting) return
257
273
  if (this.model === undefined) return
258
274
  const renderer = this.opts.resolveDashboardRenderer?.() ?? renderDashboard
259
275
  this.region.update(
@@ -269,7 +285,7 @@ export class DispatchFrontend {
269
285
  private async loadConfig(kind: string, rev: number): Promise<Config> {
270
286
  const key = `${kind}@${rev}`
271
287
  if (this.config !== undefined && this.configRef === key) return this.config
272
- const artifact = await this.opts.store.getRepoArtifact(this.opts.repo, kind, rev)
288
+ const artifact = await this.reader.getRepoArtifact(this.opts.repo, kind, rev)
273
289
  if (artifact === null) throw new Error(`effective config ${key} is not retrievable`)
274
290
  const parsed = configSchema.parse(JSON.parse(new TextDecoder().decode(artifact.content)))
275
291
  this.config = parsed
@@ -278,33 +294,69 @@ export class DispatchFrontend {
278
294
  return parsed
279
295
  }
280
296
 
281
- private async renderOnce(): Promise<void> {
282
- let repositoryEvents = await this.events()
283
- let status = this.dispatchStatus
284
- const ref = status.effectiveConfig
285
- // No filesystem fallback: the first frame waits for the child's durable,
286
- // run-correlated effective snapshot.
287
- if (ref === undefined) {
288
- if (status.health === 'failed' && status.warningNotice !== undefined) {
289
- this.region.update([status.warningNotice])
290
- }
291
- return
292
- }
293
- const config = await this.loadConfig(ref.kind, ref.rev)
294
- try {
295
- this.observationCount = unclaimedObservationCount({
296
- digests: await this.opts.store.getRepoBuildDigests(this.opts.repo),
297
- harvestEvents: repositoryEvents,
298
- })
299
- } catch {
300
- // Before the first successful sample there is no factual zero to place in
301
- // a complete frame. Leave the prior frame untouched and retry on the next
302
- // ordinary poll, without manufacturing a repository notice.
303
- if (this.observationCount === undefined) return
304
- }
305
- this.cache ??= new DashboardBuildPollCache(this.opts.store, this.opts.repo, config)
306
- const snapshot = await this.cache.refresh(config, this.configRevision)
307
- if (!this.cache.isCurrent(snapshot)) return
297
+ private async renderOnce(interaction = true): Promise<void> {
298
+ if (this.refresh !== undefined) return this.refresh.request(interaction)
299
+ return this.readFrame()
300
+ }
301
+
302
+ private readonly repositoryPoll = new RepositoryPollCache<{
303
+ repositoryEvents: RepositoryEvent[]
304
+ status: DispatchStatus
305
+ config: Config
306
+ observationCount: number
307
+ snapshot: DashboardPollSnapshot
308
+ }>()
309
+
310
+ private async readFrame(): Promise<void> {
311
+ if (this.refresh !== undefined && !this.refresh.admitted) return
312
+ const frame = await this.repositoryPoll.refresh({
313
+ position: () => this.reader.getRepoChangePosition(this.opts.repo),
314
+ now: () => this.clock().getTime(),
315
+ revision: 0,
316
+ enabled: !this.opts.once,
317
+ valid: (frame) => this.cache?.isCurrent(frame.snapshot) ?? false,
318
+ admitted: () => this.refresh === undefined || this.refresh.admitted,
319
+ nextPollMs: this.refresh?.intervalMs ?? 0,
320
+ read: async ({ fullEnrichment }) => {
321
+ const repositoryEvents = await this.events()
322
+ const status = this.dispatchStatus
323
+ const ref = status.effectiveConfig
324
+ if (ref === undefined) {
325
+ if (status.health === 'failed' && status.warningNotice !== undefined)
326
+ this.region.update([status.warningNotice])
327
+ // Startup is incomplete: retry at the same position.
328
+ return undefined
329
+ }
330
+ const config = await this.loadConfig(ref.kind, ref.rev)
331
+ let observationCount: number
332
+ try {
333
+ observationCount = unclaimedObservationCount({
334
+ digests: await this.reader.getRepoBuildDigests(this.opts.repo),
335
+ harvestEvents: repositoryEvents,
336
+ })
337
+ } catch {
338
+ // Incomplete snapshots never acknowledge the sampled position.
339
+ this.syncControls()
340
+ this.paint()
341
+ return undefined
342
+ }
343
+ this.cache ??= new DashboardBuildPollCache(this.reader, this.opts.repo, config)
344
+ const snapshot = await this.cache.refresh(config, this.configRevision, fullEnrichment)
345
+ if (!this.opts.once)
346
+ await this.standbyResolver.refresh(this.runId, status.yieldedHolder, this.clock())
347
+ await this.repositoryFeed.save()
348
+ if (!this.cache.isCurrent(snapshot)) return undefined
349
+ return { repositoryEvents, status, config, observationCount, snapshot }
350
+ },
351
+ })
352
+ if (frame === undefined) return
353
+ let { repositoryEvents, status } = frame
354
+ const { config, snapshot } = frame
355
+ const standby = this.opts.once
356
+ ? undefined
357
+ : this.standbyResolver.current(this.runId, status.yieldedHolder, this.clock())
358
+ this.observationCount = frame.observationCount
359
+ this.refresh?.activity(snapshot.states.size > 0)
308
360
 
309
361
  if (this.resumePrompt !== undefined) {
310
362
  const state = snapshot.states.get(this.resumePrompt.slug)
@@ -325,11 +377,9 @@ export class DispatchFrontend {
325
377
  const previous = this.model === undefined ? [] : dashboardSelections(this.model)
326
378
  const warningLines = [
327
379
  ...status.roleWarnings,
380
+ ...forgeReadinessWarnings(status),
328
381
  ...(status.warningNotice !== undefined ? [status.warningNotice] : []),
329
382
  ]
330
- const standby = this.opts.once
331
- ? undefined
332
- : await this.standbyResolver.refresh(this.runId, status.yieldedHolder, this.clock())
333
383
  const projected = buildDashboardFromProjected(
334
384
  snapshot.builds,
335
385
  {
@@ -337,7 +387,7 @@ export class DispatchFrontend {
337
387
  ...(standby !== undefined ? { standby } : {}),
338
388
  queued: status.queued ?? 0,
339
389
  activeCount: [...snapshot.states.values()].filter(
340
- (state) => state.status !== 'done' && state.status !== 'aborted',
390
+ (state) => state.kind !== 'node' && state.status !== 'done' && state.status !== 'aborted',
341
391
  ).length,
342
392
  capacity: config.capacity,
343
393
  observationCount: this.observationCount,
@@ -356,7 +406,6 @@ export class DispatchFrontend {
356
406
  ) {
357
407
  this.view = undefined
358
408
  }
359
- await this.repositoryFeed.save()
360
409
  this.model = projected
361
410
  this.syncControls()
362
411
  this.paint()
@@ -483,7 +532,7 @@ export class DispatchFrontend {
483
532
  follow: true,
484
533
  scroll: 0,
485
534
  }
486
- this.sessionFeed = new SessionStreamFeed(this.opts.store, captured.slug)
535
+ this.sessionFeed = new SessionStreamFeed(this.reader, captured.slug)
487
536
  this.syncControls()
488
537
  this.paint()
489
538
  // Kick the first read immediately rather than waiting one interval.
@@ -540,6 +589,7 @@ export class DispatchFrontend {
540
589
  * feed's identity+cursor fence — the same pattern the DispatchLoop path
541
590
  * uses, from the same shared feed module. */
542
591
  private pollSessionFeed(): void {
592
+ if (this.refresh !== undefined && !this.refresh.admitted) return
543
593
  const view = this.view
544
594
  if (view?.kind !== 'session') return
545
595
  if (view.status !== 'open' && view.error === undefined) {
@@ -574,7 +624,7 @@ export class DispatchFrontend {
574
624
  }
575
625
  this.syncControls()
576
626
  this.paint()
577
- })
627
+ }, false)
578
628
  })
579
629
  .catch(() => {
580
630
  // The feed contains its own failures; the next poll retries.
@@ -616,7 +666,7 @@ export class DispatchFrontend {
616
666
  const ref = this.dispatchStatus.effectiveConfig
617
667
  if (ref === undefined) throw new Error('effective config is not available')
618
668
  const config = await this.loadConfig(ref.kind, ref.rev)
619
- this.cache ??= new DashboardBuildPollCache(this.opts.store, this.opts.repo, config)
669
+ this.cache ??= new DashboardBuildPollCache(this.reader, this.opts.repo, config)
620
670
  let snapshot = await this.cache.refresh(config, this.configRevision)
621
671
  while (!this.cache.isCurrent(snapshot)) {
622
672
  snapshot = await this.cache.refresh(config, this.configRevision)
@@ -638,11 +688,12 @@ export class DispatchFrontend {
638
688
  }
639
689
 
640
690
  private async buildAction(
641
- kind: 'pause' | 'resume' | 'discard' | 'toggle-auto-merge' | 'abort',
691
+ kind: 'pause' | 'resume' | 'discard' | 'hold' | 'land' | 'abort',
642
692
  slug: string,
643
693
  ): Promise<void> {
644
694
  const result = await controlBuild({
645
695
  store: this.opts.store,
696
+ ticketSource: this.opts.ticketSource,
646
697
  repo: this.opts.repo,
647
698
  slug,
648
699
  env: this.opts.env,
@@ -672,9 +723,9 @@ export class DispatchFrontend {
672
723
  ? `build ${slug}: discard requested`
673
724
  : result.command === 'abort'
674
725
  ? `build ${slug}: abort requested`
675
- : result.command === 'auto-merge-on'
676
- ? `build ${slug}: auto-merge requested`
677
- : `build ${slug}: auto-merge cancelled`
726
+ : result.command === 'land'
727
+ ? `build ${slug}: landing consent requested`
728
+ : `build ${slug}: landing hold requested`
678
729
  await this.report(message)
679
730
  await this.renderOnce()
680
731
  }
@@ -691,18 +742,6 @@ export class DispatchFrontend {
691
742
  await this.renderOnce()
692
743
  }
693
744
 
694
- private async toggleDefaultAutoMerge(): Promise<void> {
695
- const event = await toggleRepositorySetting({
696
- store: this.opts.store,
697
- repo: this.opts.repo,
698
- user: buildControlUser(this.opts.env),
699
- setting: 'auto-merge-default',
700
- run: this.runId,
701
- })
702
- await this.report(`dispatcher auto-merge default ${event.enabled ? 'ON' : 'OFF'}`)
703
- await this.renderOnce()
704
- }
705
-
706
745
  private async bulk(direction: 'pause' | 'resume'): Promise<void> {
707
746
  const summary = await bulkControlRepository({
708
747
  store: this.opts.store,
@@ -794,6 +833,7 @@ export class DispatchFrontend {
794
833
  }
795
834
 
796
835
  private onInput(input: TerminalInputEvent): void {
836
+ this.refresh?.interaction()
797
837
  if (!this.accepting) return
798
838
  if (input.type === 'interrupt') {
799
839
  this.requestOperatorStop()
@@ -840,7 +880,7 @@ export class DispatchFrontend {
840
880
  if (enter) {
841
881
  // List/detail identity is captured synchronously before any Store read;
842
882
  // a later selection move cannot retarget this navigation.
843
- void this.openSelected().catch((error) =>
883
+ void interactionRead(() => this.openSelected()).catch((error) =>
844
884
  this.report(
845
885
  `dashboard open action failed: ${error instanceof Error ? error.message : String(error)}`,
846
886
  'warning',
@@ -858,13 +898,13 @@ export class DispatchFrontend {
858
898
  if (this.selection?.kind === 'global' && this.view === undefined)
859
899
  this.queue(() => this.toggleIntake())
860
900
  break
861
- case 'm': {
901
+ case 'o':
902
+ case 'l': {
862
903
  const slug = this.selectedSlug()
863
- if (this.view === undefined && this.selection?.kind === 'global') {
864
- this.queue(() => this.toggleDefaultAutoMerge())
865
- } else if (slug !== undefined) {
866
- this.queue(() => this.buildAction('toggle-auto-merge', slug))
867
- }
904
+ if (slug !== undefined)
905
+ this.queue(() =>
906
+ this.buildAction(input.text.toLowerCase() === 'o' ? 'hold' : 'land', slug),
907
+ )
868
908
  break
869
909
  }
870
910
  case 'p': {
@@ -909,38 +949,49 @@ export class DispatchFrontend {
909
949
  }
910
950
  }
911
951
 
912
- private startPresentation(): void {
913
- this.accepting = true
952
+ private listen(): void {
914
953
  this.cleanupInput = this.opts.input.start((input) => this.onInput(input), {
915
954
  onListening: () => this.keyboard.query(),
916
955
  onKeyboardFlags: (flags) => this.keyboard.reported(flags),
917
956
  onDeviceAttributes: () => this.keyboard.deviceAttributes(),
957
+ onFocus: (focused) => this.refresh?.focus(focused),
958
+ onInteraction: () => this.refresh?.interaction(),
959
+ onSuspend: () => this.suspension?.suspend(),
918
960
  })
919
- const poll = (): void => {
920
- if (this.polling) return
921
- this.polling = true
922
- const current = this.renderOnce()
923
- .catch(async (error) => {
924
- try {
925
- await this.report(
926
- `dashboard render failed: ${error instanceof Error ? error.message : String(error)}`,
927
- 'warning',
928
- )
929
- } catch {
930
- // retry on the next poll
931
- }
932
- })
933
- .finally(() => {
934
- if (this.pollInFlight === current) this.pollInFlight = undefined
935
- this.polling = false
936
- })
937
- this.pollInFlight = current
938
- }
939
- this.pollTimer = setInterval(poll, POLL_MS)
961
+ }
962
+
963
+ private startPresentation(): void {
964
+ this.accepting = true
965
+ this.refresh = new DashboardRefresh(async () => {
966
+ try {
967
+ await this.readFrame()
968
+ } catch (error) {
969
+ if (this.refresh?.admitted)
970
+ await this.report(
971
+ `dashboard render failed: ${error instanceof Error ? error.message : String(error)}`,
972
+ 'warning',
973
+ )
974
+ throw error
975
+ }
976
+ }, this.opts.refreshScheduler)
977
+ this.listen()
978
+ this.opts.terminal.modes.enter(FOCUS_REPORTING_MODE)
979
+ this.suspension = installPresentationSuspension(
980
+ this.opts.terminal.modes,
981
+ () => {
982
+ this.refresh?.suspend()
983
+ this.cleanupInput?.()
984
+ this.cleanupInput = undefined
985
+ },
986
+ () => {
987
+ this.listen()
988
+ this.region.invalidate()
989
+ this.refresh?.resume()
990
+ },
991
+ )
940
992
  this.paintTimer = setInterval(() => this.paint(), PAINT_MS)
941
- this.pollTimer.unref?.()
942
993
  this.paintTimer.unref?.()
943
- poll()
994
+ void this.refresh.request()
944
995
  }
945
996
 
946
997
  private requestOperatorStop(): void {
@@ -959,13 +1010,14 @@ export class DispatchFrontend {
959
1010
  if (this.presentationRestored) return
960
1011
  this.presentationRestored = true
961
1012
  this.accepting = false
1013
+ this.refresh?.stop()
1014
+ this.suspension?.close()
1015
+ this.opts.terminal.modes.leave(FOCUS_REPORTING_MODE)
962
1016
  try {
963
1017
  this.cleanupInput?.()
964
1018
  } finally {
965
1019
  this.cleanupInput = undefined
966
- if (this.pollTimer !== undefined) clearInterval(this.pollTimer)
967
1020
  if (this.paintTimer !== undefined) clearInterval(this.paintTimer)
968
- this.pollTimer = undefined
969
1021
  this.paintTimer = undefined
970
1022
  this.region.finish()
971
1023
  }
@@ -974,22 +1026,24 @@ export class DispatchFrontend {
974
1026
  private async finishPresentation(): Promise<void> {
975
1027
  if (!this.presentationRestored) {
976
1028
  this.accepting = false
1029
+ this.refresh?.stop()
1030
+ this.suspension?.close()
1031
+ this.opts.terminal.modes.leave(FOCUS_REPORTING_MODE)
977
1032
  try {
978
1033
  this.cleanupInput?.()
979
1034
  } finally {
980
1035
  this.cleanupInput = undefined
981
1036
  }
982
- if (this.pollTimer !== undefined) clearInterval(this.pollTimer)
983
1037
  if (this.paintTimer !== undefined) clearInterval(this.paintTimer)
984
- this.pollTimer = undefined
985
1038
  this.paintTimer = undefined
986
1039
  }
987
1040
  try {
988
- await this.pollInFlight
1041
+ await this.refresh?.join()
989
1042
  await this.actionTail
990
- await this.renderOnce()
1043
+ if (this.opts.once) await this.readFrame()
1044
+ else if (!this.presentationRestored) await this.refresh?.finalRefresh()
991
1045
  } catch {
992
- // final frame is best-effort
1046
+ // Final presentation remains best-effort.
993
1047
  } finally {
994
1048
  this.region.finish()
995
1049
  }
@@ -1005,13 +1059,6 @@ export class DispatchFrontend {
1005
1059
  payload: { enabled: this.opts.intake, run: this.runId },
1006
1060
  })
1007
1061
  }
1008
- if (this.opts.defaultAutoMerge !== undefined) {
1009
- await this.opts.store.appendRepo(this.opts.repo, {
1010
- actor,
1011
- type: 'dispatcher.auto-merge-default-set',
1012
- payload: { enabled: this.opts.defaultAutoMerge, run: this.runId },
1013
- })
1014
- }
1015
1062
 
1016
1063
  try {
1017
1064
  const delta = await this.repositoryFeed.warm()