@defrex/autobuild 1.11.0 → 1.12.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 (110) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +186 -57
  3. package/docs/answering-blocked-builds.md +10 -2
  4. package/docs/architecture.md +76 -10
  5. package/docs/assets/headline-wide.png +0 -0
  6. package/docs/cli.md +1 -1
  7. package/docs/configuration.md +13 -11
  8. package/docs/dispatcher.md +5 -4
  9. package/docs/integration-tree.md +28 -16
  10. package/docs/operator-api.md +4 -4
  11. package/docs/operator-surfaces.md +38 -3
  12. package/docs/optimization-nodes.md +3 -2
  13. package/docs/tickets.md +1 -1
  14. package/docs/troubleshooting.md +1 -1
  15. package/package.json +3 -3
  16. package/packages/core/src/cli/ambient-errors.ts +17 -0
  17. package/packages/core/src/cli/bounded-io.ts +174 -0
  18. package/packages/core/src/cli/dashboard/header.ts +10 -0
  19. package/packages/core/src/cli/dashboard/model.ts +81 -23
  20. package/packages/core/src/cli/dashboard/poll.ts +24 -34
  21. package/packages/core/src/cli/dashboard/render.ts +44 -37
  22. package/packages/core/src/cli/dashboard/row-text.ts +24 -7
  23. package/packages/core/src/cli/dashboard/tone-ansi.ts +39 -0
  24. package/packages/core/src/cli/dashboard/vocabulary.ts +161 -20
  25. package/packages/core/src/cli/dispatch-frontend.ts +12 -3
  26. package/packages/core/src/cli/dispatch-handoff.ts +41 -10
  27. package/packages/core/src/cli/dispatch-launch-contract.ts +5 -0
  28. package/packages/core/src/cli/dispatch-launcher-cadence.ts +80 -0
  29. package/packages/core/src/cli/dispatch-launcher.ts +9 -10
  30. package/packages/core/src/cli/dispatch-preflight.ts +12 -3
  31. package/packages/core/src/cli/dispatch-release-observer.ts +53 -0
  32. package/packages/core/src/cli/dispatch-runtime-cache.ts +204 -82
  33. package/packages/core/src/cli/dispatch-runtime-dependencies.ts +250 -43
  34. package/packages/core/src/cli/dispatch-upgrade-install.ts +36 -16
  35. package/packages/core/src/cli/dispatch-upgrade-source.ts +8 -2
  36. package/packages/core/src/cli/dispatch-yield-observer.ts +82 -0
  37. package/packages/core/src/cli/dispatch.ts +70 -9
  38. package/packages/core/src/cli/env.ts +2 -15
  39. package/packages/core/src/cli/help.ts +5 -4
  40. package/packages/core/src/cli/main.ts +4 -2
  41. package/packages/core/src/cli/production-store.ts +102 -0
  42. package/packages/core/src/cli/repo-state.ts +2 -3
  43. package/packages/core/src/cli/repository-status.ts +36 -28
  44. package/packages/core/src/cli/sessionless-store.ts +26 -0
  45. package/packages/core/src/cli/status.ts +169 -40
  46. package/packages/core/src/cli/store-opening.ts +15 -58
  47. package/packages/core/src/cli/store-ref.ts +6 -1
  48. package/packages/core/src/config/schema.ts +1 -1
  49. package/packages/core/src/distribution-packaging.ts +156 -18
  50. package/packages/core/src/events/catalog-identity.ts +28 -0
  51. package/packages/core/src/events/catalog.ts +3 -9
  52. package/packages/core/src/events/compatibility.ts +2 -30
  53. package/packages/core/src/events/payloads.ts +11 -0
  54. package/packages/core/src/events/policy.ts +3 -0
  55. package/packages/core/src/events/repository.ts +1 -1
  56. package/packages/core/src/events/sessions.ts +1 -1
  57. package/packages/core/src/events/validation-error.ts +12 -0
  58. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +74 -30
  59. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3064e337cc75f8d6.json +310 -0
  60. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/46196d8f0076496a.json +97 -0
  61. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a1e90a969d32a367.json +307 -0
  62. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/da3bc91c49211eab.json +310 -0
  63. package/packages/core/src/kernel/auto-merge-default.ts +2 -1
  64. package/packages/core/src/kernel/capacity-build.ts +21 -0
  65. package/packages/core/src/kernel/discard-in-flight.ts +13 -0
  66. package/packages/core/src/kernel/dispatch-capacity.ts +354 -147
  67. package/packages/core/src/kernel/dispatch-status.ts +139 -0
  68. package/packages/core/src/kernel/engine.ts +2 -8
  69. package/packages/core/src/kernel/measurement.ts +24 -0
  70. package/packages/core/src/kernel/read-facts.ts +9 -369
  71. package/packages/core/src/kernel/reducer-registry.ts +40 -125
  72. package/packages/core/src/kernel/reducer-revisions.ts +5 -0
  73. package/packages/core/src/kernel/reducer-value-entry.ts +98 -0
  74. package/packages/core/src/kernel/reducer-value-index.ts +75 -0
  75. package/packages/core/src/kernel/reducer.ts +57 -9
  76. package/packages/core/src/kernel/reopen-state.ts +10 -0
  77. package/packages/core/src/kernel/repository-read-facts.ts +375 -0
  78. package/packages/core/src/kernel/verify-stage-state.ts +145 -3
  79. package/packages/core/src/operator/presentation.ts +13 -0
  80. package/packages/core/src/operator/query.ts +47 -41
  81. package/packages/core/src/operator/registry.ts +3 -3
  82. package/packages/core/src/ports/workspace/fake.ts +15 -3
  83. package/packages/core/src/processes/dispatcher.ts +232 -75
  84. package/packages/core/src/processes/execution-no-progress.ts +1 -0
  85. package/packages/core/src/store/local/capabilities.ts +115 -0
  86. package/packages/core/src/store/local/store.ts +86 -56
  87. package/packages/core/src/store/reduced-reads.ts +9 -1
  88. package/packages/core/src/store/reducer-value-read.ts +235 -0
  89. package/packages/core/src/store/reducer-value-shapes.json +3796 -3670
  90. package/packages/core/src/store/reducer-values.ts +36 -204
  91. package/packages/core/src/store/remote/released-clients.json +22 -0
  92. package/packages/core/src/store/remote/released-reducer-values/1.11.1.json +35718 -0
  93. package/packages/core/src/store/remote/released-reducer-values/1.12.0.json +35806 -0
  94. package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
  95. package/packages/core/src/store/rollup-lease.ts +41 -0
  96. package/packages/core/src/store/rollups.ts +7 -38
  97. package/packages/core/src/store/snapshots.ts +1 -1
  98. package/packages/core/src/testing/dispatch-journals.ts +117 -0
  99. package/packages/core/src/testing/dispatch-read-budget.ts +265 -4
  100. package/packages/core/src/testing/import-graph.ts +78 -0
  101. package/packages/core/src/testing/reduced-read-budget.ts +221 -22
  102. package/packages/core/src/testing/slot-agreement.ts +52 -0
  103. package/packages/core/src/web/assets/app.js +5 -5
  104. package/packages/core/src/web/repository-source.ts +6 -2
  105. package/skills/guide/SKILL.md +126 -47
  106. package/skills/guide/references/integration-tree.md +28 -16
  107. package/skills/guide/references/operator-api.md +4 -4
  108. package/skills/guide/references/optimization-nodes.md +3 -2
  109. package/skills/operate/SKILL.md +38 -20
  110. package/templates/hosted-service/package.json +2 -2
@@ -1,6 +1,5 @@
1
1
  import { workTargetDistance } from './target-distance'
2
2
  import { openTicketWait, waitingOnLine } from '../../kernel/ticket-wait'
3
- import { migrationIdentity, ticketMigrationsReducer } from '../../kernel/ticket-migrations'
4
3
  import { openPrBackpressureReducer } from '../../kernel/open-pr-backpressure-state'
5
4
  import type { DashboardRollback } from './rollback'
6
5
  import type { DispatchUpgradeState } from '../../kernel/dispatch-upgrade'
@@ -14,16 +13,18 @@ import {
14
13
  } from './integration-row'
15
14
  import {
16
15
  dispatchCapacity,
16
+ epilogueLeaf,
17
17
  slotWaitText,
18
18
  startClaimDemand,
19
19
  urgentClaimDemand,
20
20
  type DispatchCapacity,
21
+ type SlotState,
21
22
  } from '../../kernel/dispatch-capacity'
22
23
  import { openBuildWorkspace, provisionMarkerReducer } from '../../processes/dispatcher-selectors'
23
24
  import { projectTree, treeVocabulary, type TreeProjection } from './tree'
24
25
  import { holdReason } from './landing-display'
25
26
  import { reopenedSummary, reopenedText } from './reopen-display'
26
- import { reopenSpecPending } from '../../kernel/reopen-state'
27
+ import { reopenSpecPending, reviseSpecPending } from '../../kernel/reopen-state'
27
28
  import { ciFailureText, currentCiFailure } from '../../kernel/forge-checks'
28
29
  export { treeVocabulary, consentQueue } from './tree'
29
30
  import {
@@ -32,6 +33,7 @@ import {
32
33
  landingFallbackReason,
33
34
  } from '../../kernel/landing-state'
34
35
  import { projectObjectiveRow, type ObjectiveRow } from './objective-row'
36
+ import type { StatusBasis } from './vocabulary'
35
37
  export {
36
38
  objectiveElapsedHours,
37
39
  objectiveNumber,
@@ -249,6 +251,13 @@ export function dashboardWait(state: BuildState): DashboardWait | undefined {
249
251
  }
250
252
 
251
253
  export interface DashboardBuild {
254
+ /** Display-only lifecycle facts the row's status word is chosen from
255
+ * (`buildStatusText`); absent on hand-built rows, which imply it from
256
+ * `status`. */
257
+ statusBasis?: StatusBasis
258
+ /** The build's slot state from the frame's capacity projection (SPEC §12
259
+ * "What holds a slot"); absent is unknown, never `none`. */
260
+ slot?: SlotState
252
261
  draining?: boolean
253
262
  /** A work row's standing alert, such as a parked build waiting for a slot. */
254
263
  alert?: { tone: 'yellow' | 'red'; text: string }
@@ -400,7 +409,8 @@ export interface DashboardModel {
400
409
  repo: string
401
410
  /** Ready tickets waiting for a slot — the dispatcher's standing queue depth. */
402
411
  queued: number
403
- /** Shared occupied/effective slot counter; idle integration nodes are free. */
412
+ /** Shared slot counter: builds holding a slot against configured capacity;
413
+ * paused, blocked and idle builds hold none. */
404
414
  active: DashboardCounter
405
415
  capacity?: DispatchCapacity
406
416
  /** Absent: the recorded run's effective configuration projected this model.
@@ -462,6 +472,21 @@ export function effectiveStatus(state: BuildState): EffectiveStatus | BuildState
462
472
  if (state.status === 'done') return 'done'
463
473
  if (state.status === 'aborted') return 'cleaning'
464
474
  if (state.pendingCommands.some((command) => command.command === 'abort')) return 'aborting'
475
+ const resting = restingStatus(state)
476
+ if (resting === 'running' && state.pendingCommands.some((command) => command.command === 'pause'))
477
+ return 'pausing'
478
+ if (resting === 'paused' && state.pendingCommands.some((command) => command.command === 'resume'))
479
+ return 'resuming'
480
+ return resting
481
+ }
482
+
483
+ /** `effectiveStatus` with every pending command ignored: what the build rests
484
+ * on until a pause, resume or abort is acknowledged. */
485
+ export function restingStatus(
486
+ state: BuildState,
487
+ ): Exclude<EffectiveStatus, 'pausing' | 'resuming' | 'aborting'> | 'done' {
488
+ if (state.status === 'done') return 'done'
489
+ if (state.status === 'aborted') return 'cleaning'
465
490
  if (state.kind === 'node' && integrationFailed(state)) return 'blocked'
466
491
  // A ticket wait whose escalation is the only one open reads as waiting; any
467
492
  // other open question outranks it and the build reads blocked.
@@ -477,19 +502,37 @@ export function effectiveStatus(state: BuildState): EffectiveStatus | BuildState
477
502
  ) {
478
503
  return 'blocked'
479
504
  }
480
- if (state.status === 'running') {
481
- return state.pendingCommands.some((command) => command.command === 'pause')
482
- ? 'pausing'
483
- : 'running'
484
- }
485
- if (state.status === 'paused') {
486
- return state.pendingCommands.some((command) => command.command === 'resume')
487
- ? 'resuming'
488
- : 'paused'
489
- }
490
505
  return state.status
491
506
  }
492
507
 
508
+ /** The lifecycle facts a nonterminal build's status word is chosen from
509
+ * (`buildStatusText`), or undefined for a `done` build. Display-only. */
510
+ export function statusBasis(state: BuildState): StatusBasis | undefined {
511
+ const resting = restingStatus(state)
512
+ if (resting === 'done') return undefined
513
+ const pending = (command: string) => state.pendingCommands.some((c) => c.command === command)
514
+ const settled = epilogueLeaf(state)
515
+ ? state.landing?.command?.kind === 'hold'
516
+ ? ('hold' as const)
517
+ : landingAuthorized(state.landing)
518
+ ? ('merging' as const)
519
+ : ('decision' as const)
520
+ : undefined
521
+ const waitTickets =
522
+ resting === 'waiting' ? openTicketWait(state)?.tickets.map((ticket) => ticket.id) : undefined
523
+ return {
524
+ resting,
525
+ ...(pending('pause') ? { pause: true as const } : {}),
526
+ ...(pending('abort') ? { abort: true as const } : {}),
527
+ ...(pending('resume') ? { resume: true as const } : {}),
528
+ runner: state.openExecution !== undefined,
529
+ ...(state.kind === 'node' ? { node: true as const } : {}),
530
+ ...(settled !== undefined ? { settled } : {}),
531
+ ...(reviseSpecPending(state) ? { reviseSpec: true as const } : {}),
532
+ ...(waitTickets?.length ? { waitTickets } : {}),
533
+ }
534
+ }
535
+
493
536
  function isVisible(status: EffectiveStatus | BuildState['status']): status is EffectiveStatus {
494
537
  return (
495
538
  status === 'queued' ||
@@ -670,6 +713,7 @@ export function projectBuildFromFacts(
670
713
  const dashboard = facts.dashboard
671
714
  const status = effectiveStatus(state)
672
715
  if (!isVisible(status)) return null
716
+ const basis = statusBasis(state)
673
717
  const wait = dashboardWait(state)
674
718
  const objective = projectObjectiveRow(state)
675
719
  const abortProgress =
@@ -748,6 +792,7 @@ export function projectBuildFromFacts(
748
792
  createdAt: record.createdAt,
749
793
  },
750
794
  status,
795
+ ...(basis !== undefined ? { statusBasis: basis } : {}),
751
796
  alsoPaused: false,
752
797
  ...(record.ticket?.id !== undefined ? { ticketId: record.ticket.id } : {}),
753
798
  steps: [],
@@ -797,6 +842,7 @@ export function projectBuildFromFacts(
797
842
  createdAt: record.createdAt,
798
843
  },
799
844
  status,
845
+ ...(basis !== undefined ? { statusBasis: basis } : {}),
800
846
  alsoPaused: false,
801
847
  ...(record.ticket?.id !== undefined ? { ticketId: record.ticket.id } : {}),
802
848
  steps: [],
@@ -881,7 +927,7 @@ export function projectBuildFromFacts(
881
927
  // away, so they are derived here (display-only, at the one call site that
882
928
  // already has the log in hand). A running build keeps its open interval live
883
929
  // (the renderer ticks it against `now`); a paused build freezes every open
884
- // interval at its acknowledgement (including while RESUMING), while a
930
+ // interval at its acknowledgement (including while a resume is pending), while a
885
931
  // blocked build freezes at the latest non-distance durable event. Timers do
886
932
  // not advance behind either gate (AC 10). Each step scopes by the SAME seq boundary its state uses, so
887
933
  // durations and states restart in lockstep (AC 12).
@@ -1168,6 +1214,7 @@ export function projectBuildFromFacts(
1168
1214
  createdAt: record.createdAt,
1169
1215
  },
1170
1216
  status,
1217
+ ...(basis !== undefined ? { statusBasis: basis } : {}),
1171
1218
  alsoPaused: state.status === 'paused' && (status === 'blocked' || status === 'waiting'),
1172
1219
  ...(record.ticket?.id !== undefined ? { ticketId: record.ticket.id } : {}),
1173
1220
  steps:
@@ -1499,6 +1546,20 @@ export function decorateSlotWaits(
1499
1546
  })
1500
1547
  }
1501
1548
 
1549
+ /** Each row's slot state from the capacity projection. Returns copies;
1550
+ * cached projected rows stay intact. */
1551
+ function decorateSlots(
1552
+ rows: readonly DashboardBuild[],
1553
+ capacity: DispatchCapacity | undefined,
1554
+ ): DashboardBuild[] {
1555
+ const slots = capacity?.slots
1556
+ if (!slots) return [...rows]
1557
+ return rows.map((row) => {
1558
+ const slot = slots[row.slug]
1559
+ return slot ? { ...row, slot } : row
1560
+ })
1561
+ }
1562
+
1502
1563
  export function buildDashboardFromProjected(
1503
1564
  projectedBuilds: readonly DashboardBuild[],
1504
1565
  header: DashboardHeader,
@@ -1511,8 +1572,11 @@ export function buildDashboardFromProjected(
1511
1572
  repositoryEvents,
1512
1573
  upgrades,
1513
1574
  )
1514
- const builds = decorateSlotWaits(
1515
- enrichIntegrationRows(projectedBuilds.map((row) => enrichDrainingRow(row, draining))),
1575
+ const builds = decorateSlots(
1576
+ decorateSlotWaits(
1577
+ enrichIntegrationRows(projectedBuilds.map((row) => enrichDrainingRow(row, draining))),
1578
+ header.capacityProjection,
1579
+ ),
1516
1580
  header.capacityProjection,
1517
1581
  ).sort((a, b) => a.slug.localeCompare(b.slug))
1518
1582
  // Member order matches the terminal model's historical literal.
@@ -1524,7 +1588,7 @@ export function buildDashboardFromProjected(
1524
1588
  queued: repository.queued,
1525
1589
  active: {
1526
1590
  current: header.capacityProjection?.occupied ?? header.activeCount,
1527
- limit: header.capacityProjection?.effective ?? header.capacity,
1591
+ limit: header.capacityProjection?.configured ?? header.capacity,
1528
1592
  },
1529
1593
  ...(header.capacityProjection ? { capacity: header.capacityProjection } : {}),
1530
1594
  drained: repository.drained,
@@ -1563,12 +1627,6 @@ export function buildDashboard(
1563
1627
  })),
1564
1628
  config.capacity,
1565
1629
  new Date(),
1566
- migrationIdentity(
1567
- Array.isArray(repositoryEvents)
1568
- ? ticketMigrationsReducer.reduce(repositoryEvents)
1569
- : repositoryEvents.ticketMigrations,
1570
- config.tickets.source,
1571
- ),
1572
1630
  {
1573
1631
  ...(Array.isArray(repositoryEvents)
1574
1632
  ? {}
@@ -6,7 +6,6 @@ import {
6
6
  type CapacityBuild,
7
7
  } from '../../kernel/dispatch-capacity'
8
8
  import type { DispatchStatus } from '../../kernel/dispatch-status'
9
- import { migrationIdentity } from '../../kernel/ticket-migrations'
10
9
  import {
11
10
  openBuildWorkspaceReducer,
12
11
  provisionMarkerReducer,
@@ -17,6 +16,7 @@ import type { PipelineSourceMeta } from '../../config/pipeline-source'
17
16
  import type { AbEvent } from '../../events/catalog'
18
17
  import { buildReducer, type BuildAcc, type BuildState } from '../../kernel/reducer'
19
18
  import { landingRestackDue } from '../../kernel/engine'
19
+ import { capacityBuildFromFacts } from '../../kernel/capacity-build'
20
20
  import { leafRestackReducer, type LeafRestackState } from '../../kernel/leaf-restack-state'
21
21
  import {
22
22
  BUILD_EFFECTIVE_CONFIG_ARTIFACT,
@@ -30,12 +30,8 @@ import type {
30
30
  StreamRecord,
31
31
  StreamScope,
32
32
  } from '../../store/types'
33
- import {
34
- readBuildFacts,
35
- type CurrentBuildFacts,
36
- type RepositoryReadFacts,
37
- } from '../../store/reduced-reads'
38
- import { dispatchWarningLines } from './header'
33
+ import { readBuildFacts, type RepositoryReadFacts } from '../../store/reduced-reads'
34
+ import { dispatchWarningLines, repositoryQueueDepth } from './header'
39
35
  import {
40
36
  projectBuild,
41
37
  projectBuildFromFacts,
@@ -98,6 +94,7 @@ interface ReducedEntry {
98
94
  state: BuildState
99
95
  workspace: boolean
100
96
  provisioning: boolean
97
+ provisioningSeq?: number
101
98
  restackDue: boolean
102
99
  build: DashboardBuild | null
103
100
  }
@@ -111,18 +108,10 @@ export function isDashboardTerminal(state: BuildState): boolean {
111
108
  return state.status === 'done'
112
109
  }
113
110
 
114
- /** One build's capacity facts from its saved `buildReadFacts` value. */
115
- export function capacityBuildFromFacts(
116
- record: BuildRecord,
117
- value: CurrentBuildFacts,
118
- ): Required<CapacityBuild> {
119
- return {
120
- record,
121
- state: value.state,
122
- workspace: value.workspace !== null,
123
- provisioning: value.provisionMarker !== undefined,
124
- restackDue: landingRestackDue(value.state, value.log),
125
- }
111
+ export { capacityBuildFromFacts }
112
+
113
+ function provisioningSeqOf(seq: number | undefined): Pick<CapacityBuild, 'provisioningSeq'> {
114
+ return seq === undefined ? {} : { provisioningSeq: seq }
126
115
  }
127
116
 
128
117
  /** The display-only reads that decorate one row: authoritative stream
@@ -218,7 +207,8 @@ export function projectRowWithEnrichment(
218
207
 
219
208
  /**
220
209
  * The dashboard header for one repository frame: the queue and capacity
221
- * terms every frontend shows. `states` are the visible builds' reductions;
210
+ * terms every frontend shows. The queue term is the latest ticket scan's
211
+ * depth (`repositoryQueueDepth`), never one dispatcher run's status. `states` are the visible builds' reductions;
222
212
  * acknowledged aborts and integration nodes do not count as active.
223
213
  */
224
214
  export function repositoryDashboardHeader(input: {
@@ -237,25 +227,19 @@ export function repositoryDashboardHeader(input: {
237
227
  return {
238
228
  repo: input.repo,
239
229
  ...(input.standby !== undefined ? { standby: input.standby } : {}),
240
- queued: status.queued ?? 0,
230
+ queued: repositoryQueueDepth(repositoryFacts),
241
231
  activeCount: [...input.states].filter(
242
232
  (state) => state.kind !== 'node' && state.status !== 'done' && state.status !== 'aborted',
243
233
  ).length,
244
234
  capacity: config.capacity,
245
- capacityProjection: dispatchCapacity(
246
- input.capacityBuilds,
247
- config.capacity,
248
- input.now,
249
- migrationIdentity(repositoryFacts.ticketMigrations, config.tickets.source),
250
- {
251
- urgentClaims: urgentClaimDemand(repositoryFacts),
252
- openPrs: {
253
- policy: config.policy,
254
- engaged: repositoryFacts.openPrBackpressure !== undefined,
255
- },
256
- startRequests: startClaimDemand(repositoryFacts),
235
+ capacityProjection: dispatchCapacity(input.capacityBuilds, config.capacity, input.now, {
236
+ urgentClaims: urgentClaimDemand(repositoryFacts),
237
+ openPrs: {
238
+ policy: config.policy,
239
+ engaged: repositoryFacts.openPrBackpressure !== undefined,
257
240
  },
258
- ),
241
+ startRequests: startClaimDemand(repositoryFacts),
242
+ }),
259
243
  ...(input.triage !== undefined ? { triage: input.triage } : {}),
260
244
  ...(status.availableUpgrade !== undefined ? { availableUpgrade: status.availableUpgrade } : {}),
261
245
  ...(warningLines.length > 0 ? { warningLines } : {}),
@@ -374,6 +358,9 @@ export class DashboardBuildPollCache {
374
358
  state: value.state,
375
359
  workspace: capacity.workspace,
376
360
  provisioning: capacity.provisioning,
361
+ ...(capacity.provisioningSeq !== undefined
362
+ ? { provisioningSeq: capacity.provisioningSeq }
363
+ : {}),
377
364
  restackDue: capacity.restackDue,
378
365
  build:
379
366
  current?.kind === 'reduced' &&
@@ -459,6 +446,9 @@ export class DashboardBuildPollCache {
459
446
  workspace: entry.kind === 'reduced' ? entry.workspace : entry.workspace.open !== null,
460
447
  provisioning:
461
448
  entry.kind === 'reduced' ? entry.provisioning : entry.provisionMarker.marker !== null,
449
+ ...provisioningSeqOf(
450
+ entry.kind === 'reduced' ? entry.provisioningSeq : entry.provisionMarker.marker?.seq,
451
+ ),
462
452
  restackDue:
463
453
  entry.kind === 'reduced'
464
454
  ? entry.restackDue
@@ -45,6 +45,7 @@ import { displayText, layoutComposer, packAtomic, wrapDisplay } from './composer
45
45
  import { cellWidth, graphemes, padEndCells } from './cells'
46
46
  import {
47
47
  HARVEST_TITLE,
48
+ buildRowStatus,
48
49
  projectHarvestRowText,
49
50
  projectHeaderText,
50
51
  projectProgress,
@@ -52,14 +53,8 @@ import {
52
53
  reviewRoundCeilingText,
53
54
  type RowAttention,
54
55
  } from './row-text'
55
- import {
56
- PROGRESS_VERIFIED,
57
- statusText,
58
- stepLine,
59
- stepTone,
60
- viewerLabel,
61
- type DashboardTone,
62
- } from './vocabulary'
56
+ import { RESET, TONE_COLOR, paint, type ColorName } from './tone-ansi'
57
+ import { PROGRESS_VERIFIED, harvestStatusText, stepLine, stepTone, viewerLabel } from './vocabulary'
63
58
 
64
59
  export { formatDuration } from './vocabulary'
65
60
 
@@ -107,34 +102,9 @@ export type DashboardRendererResolver = () => DashboardRenderer
107
102
 
108
103
  // ── ANSI ─────────────────────────────────────────────────────────────────────
109
104
 
110
- const ESC = '\x1b['
111
- const RESET = `${ESC}0m`
112
105
  /** Closes an OSC 8 hyperlink. `RESET` does NOT: it is an SGR reset, and the
113
106
  * two families are independent — only this ends the link. */
114
107
  const LINK_OFF = '\x1b]8;;\x07'
115
- const CODES = {
116
- dim: 2,
117
- red: 31,
118
- green: 32,
119
- yellow: 33,
120
- blue: 34,
121
- cyan: 36,
122
- bold: 1,
123
- } as const
124
- type ColorName = keyof typeof CODES
125
-
126
- /** The terminal's colour for each shared tone. */
127
- const TONE_COLOR: Record<DashboardTone, ColorName> = {
128
- ok: 'green',
129
- live: 'cyan',
130
- held: 'yellow',
131
- alert: 'red',
132
- pending: 'dim',
133
- }
134
-
135
- function paint(text: string, color: ColorName, on: boolean): string {
136
- return on ? `${ESC}${CODES[color]}m${text}${RESET}` : text
137
- }
138
108
 
139
109
  /** OSC 8: the escape common terminals turn into a real hyperlink. In plain
140
110
  * mode we emit the bare URL, which those same terminals linkify on sight —
@@ -356,7 +326,12 @@ function renderBuild(
356
326
  if (text.pr !== undefined) rightTokens.push(link(text.pr.url, text.pr.text, color))
357
327
  for (const flag of text.flags)
358
328
  rightTokens.push(paint(`(${flag.term})`, TONE_COLOR[flag.tone], color))
359
- rightTokens.push(paint(text.status.word.padStart(widths.status), statusColor, color))
329
+ // The status note (`(merge decision)`) hugs the word it explains; the
330
+ // padding goes ahead of both so the word still ends at the right edge.
331
+ const statusPad = ' '.repeat(Math.max(0, widths.status - cellWidth(text.status.word)))
332
+ const statusNote =
333
+ text.status.note !== undefined ? `${paint(`(${text.status.note})`, 'dim', color)} ` : ''
334
+ rightTokens.push(`${statusPad}${statusNote}${paint(text.status.word, statusColor, color)}`)
360
335
  const rightStr = rightTokens.join(' ')
361
336
 
362
337
  // The slug is the sole flexible segment; narrow frames truncate it before
@@ -497,8 +472,8 @@ function frameWidths(builds: DashboardBuild[], harvest: DashboardHarvest | undef
497
472
  ),
498
473
  status: Math.max(
499
474
  0,
500
- ...builds.map((b) => cellWidth(statusText(b.status).word)),
501
- ...(harvest !== undefined ? [cellWidth(statusText(harvest.status).word)] : []),
475
+ ...builds.map((b) => cellWidth(buildRowStatus(b).word)),
476
+ ...(harvest !== undefined ? [cellWidth(harvestStatusText(harvest.status).word)] : []),
502
477
  ),
503
478
  }
504
479
  }
@@ -1001,11 +976,13 @@ function renderDetail(model: DashboardModel, opts: RenderOpts): string[] {
1001
976
  const { color, width, height } = opts
1002
977
  const draining = build.draining ? ` ${paint('(draining)', 'yellow', color)}` : ''
1003
978
  const paused = build.alsoPaused ? ' (also paused)' : ''
979
+ const status = buildRowStatus(build)
980
+ const statusNote = status.note !== undefined ? ` (${status.note})` : ''
1004
981
  const notice = upgradeNoticeLine(model, color, width)
1005
982
  const top = [
1006
983
  truncate(`${paint('Build', 'bold', color)} ${displayText(build.slug)}`, width),
1007
984
  truncate(
1008
- ` status ${paint(statusText(build.status).word, TONE_COLOR[statusText(build.status).tone], color)}${paused}${draining}`,
985
+ ` status ${paint(`${status.word}${statusNote}`, TONE_COLOR[status.tone], color)}${paused}${draining}`,
1009
986
  width,
1010
987
  ),
1011
988
  ...standbyLine(model, color, width),
@@ -1835,6 +1812,36 @@ export function viewerIndicator(viewer: { dispatchedBy?: string }, width: number
1835
1812
  return width >= 6 && width < 9 ? 'viewer' : truncate(viewerLabel(viewer), width)
1836
1813
  }
1837
1814
 
1815
+ /**
1816
+ * Pin the web UI's `url` to the right end of a composed frame's first line.
1817
+ *
1818
+ * The URL ends in the terminal's last column; the rest of the line keeps its
1819
+ * gutters and is truncated first so that at least two spaces separate it from
1820
+ * the URL. The line's leading label (gutter, selection marker, first word) is
1821
+ * never cut: when the line cannot hold that label plus the whole URL, the
1822
+ * frame is returned unchanged, so a partial URL is never painted. The URL is
1823
+ * emitted as plain contiguous text, so terminals that detect URLs can make it
1824
+ * clickable. Only `lines[0]` changes; the frame never gains a line.
1825
+ */
1826
+ export function pinTopLineUrl(
1827
+ lines: readonly string[],
1828
+ url: string,
1829
+ terminalWidth: number,
1830
+ ): string[] {
1831
+ const first = lines[0]
1832
+ if (first === undefined || url === '' || terminalWidth <= 0) return [...lines]
1833
+ const urlWidth = cellWidth(url)
1834
+ const budget = terminalWidth - urlWidth - 2
1835
+ const plain = stripAnsi(first)
1836
+ const label = /^\s*(?:> )?\S+/.exec(plain)?.[0] ?? /^\s*/.exec(plain)?.[0] ?? ''
1837
+ const labelWidth = cellWidth(label)
1838
+ const need = visibleLength(first) <= budget ? labelWidth : labelWidth + 1
1839
+ if (budget < need) return [...lines]
1840
+ const left = truncate(first, budget)
1841
+ const gap = terminalWidth - visibleLength(left) - urlWidth
1842
+ return [`${left}${' '.repeat(gap)}${url}`, ...lines.slice(1)]
1843
+ }
1844
+
1838
1845
  export function renderDashboard(model: DashboardModel, opts: RenderOpts): string[] {
1839
1846
  const terminalWidth = Math.max(0, opts.width)
1840
1847
  const contentWidth = dashboardContentWidth(terminalWidth)
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * Layout (padding, truncation, wrapping, separators) stays with each frontend.
13
13
  */
14
- import { capacityExplanation } from '../../kernel/dispatch-capacity'
14
+ import { capacityExplanation, type SlotState } from '../../kernel/dispatch-capacity'
15
15
  import type { BuildRosterFinished } from '../../kernel/build-roster'
16
16
  import type { DispatchHealth } from '../../kernel/dispatch-status'
17
17
  import { NO_DISPATCHER_RUN_LINE, activeCounterText } from './configuration'
@@ -24,8 +24,9 @@ import { treeVocabulary } from './tree'
24
24
  import {
25
25
  dispatchedByText,
26
26
  dispatcherModeWord,
27
+ buildStatusText,
27
28
  finishedOutcomeText,
28
- statusText,
29
+ harvestStatusText,
29
30
  stepMark,
30
31
  stepTone,
31
32
  type DashboardTone,
@@ -67,6 +68,9 @@ export interface DashboardRowText {
67
68
  ticketUrl?: string
68
69
  kind: 'work' | 'integration'
69
70
  status: StatusText
71
+ /** The build's slot state, passed through from the projection; absent is
72
+ * unknown, never `none`. */
73
+ slot?: SlotState
70
74
  /** The label of the step currently running. */
71
75
  phase?: string
72
76
  /** Ordered parenthesised annotations beside the status. */
@@ -231,6 +235,17 @@ function treeLines(build: DashboardBuild): string[] | undefined {
231
235
  ]
232
236
  }
233
237
 
238
+ /** A build row's status word, tone and note (SPEC §14 "Status words"). */
239
+ export function buildRowStatus(
240
+ build: Pick<DashboardBuild, 'status' | 'slot' | 'statusBasis'>,
241
+ ): StatusText {
242
+ return buildStatusText({
243
+ status: build.status,
244
+ ...(build.slot !== undefined ? { slot: build.slot } : {}),
245
+ ...(build.statusBasis !== undefined ? { basis: build.statusBasis } : {}),
246
+ })
247
+ }
248
+
234
249
  /**
235
250
  * Everything one build row says. Integration rows (an `integrationRow` is
236
251
  * present) show their own steps, progress and alert, and hide the tree,
@@ -240,13 +255,14 @@ export function projectRowText(
240
255
  build: DashboardBuild,
241
256
  options: { repositoryPaused: boolean },
242
257
  ): DashboardRowText {
243
- const status = statusText(build.status)
258
+ const status = buildRowStatus(build)
244
259
  const row = build.integrationRow
245
260
  const steps = (row?.steps ?? build.steps).map(stepText)
246
261
  const phase = steps.find((step) => step.state === 'current')?.label
247
262
  const flags: DashboardRowText['flags'] = [
248
- // A repository hold changes no build lifecycle state: QUEUED stays literal
249
- // and only the rows the hold prevents from launching are annotated.
263
+ // A repository hold changes no build lifecycle state: a newly claimed
264
+ // build still reads STARTING, and only the rows the hold prevents from
265
+ // launching are annotated.
250
266
  ...(options.repositoryPaused && build.status === 'queued'
251
267
  ? [{ term: 'held' as const, tone: 'held' as const }]
252
268
  : []),
@@ -315,6 +331,7 @@ export function projectRowText(
315
331
  : {}),
316
332
  kind: build.kind === 'integration' ? 'integration' : 'work',
317
333
  status,
334
+ ...(build.slot !== undefined ? { slot: build.slot } : {}),
318
335
  ...(phase !== undefined ? { phase } : {}),
319
336
  flags,
320
337
  ...(build.kind !== 'integration'
@@ -338,7 +355,7 @@ export function projectRowText(
338
355
  }
339
356
 
340
357
  export function projectHarvestRowText(harvest: DashboardHarvest): HarvestRowText {
341
- const status = statusText(harvest.status)
358
+ const status = harvestStatusText(harvest.status)
342
359
  return {
343
360
  title: HARVEST_TITLE,
344
361
  status,
@@ -451,7 +468,7 @@ export function projectAttention(
451
468
  ): AttentionItem[] {
452
469
  const items: AttentionItem[] = []
453
470
  if (harvest !== undefined && (harvest.status === 'escalated' || harvest.status === 'failed')) {
454
- const status = statusText(harvest.status)
471
+ const status = harvestStatusText(harvest.status)
455
472
  items.push({
456
473
  kind: 'harvest',
457
474
  tone: status.tone,
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The terminal's ANSI colour for each shared tone. The dashboard renderer and
3
+ * the plain `ab builds` / `ab build status` text paint a tone through the same
4
+ * table, so a status word has one colour on every terminal surface.
5
+ *
6
+ * Pure: no IO and no `process`. Whether to paint is the caller's decision.
7
+ */
8
+ import type { DashboardTone } from './vocabulary'
9
+
10
+ export const ESC = '\x1b['
11
+ export const RESET = `${ESC}0m`
12
+
13
+ export const CODES = {
14
+ dim: 2,
15
+ red: 31,
16
+ green: 32,
17
+ yellow: 33,
18
+ blue: 34,
19
+ cyan: 36,
20
+ bold: 1,
21
+ } as const
22
+ export type ColorName = keyof typeof CODES
23
+
24
+ /** The terminal's colour for each shared tone. */
25
+ export const TONE_COLOR: Record<DashboardTone, ColorName> = {
26
+ ok: 'green',
27
+ live: 'cyan',
28
+ held: 'yellow',
29
+ alert: 'red',
30
+ pending: 'dim',
31
+ }
32
+
33
+ export function paint(text: string, color: ColorName, on: boolean): string {
34
+ return on ? `${ESC}${CODES[color]}m${text}${RESET}` : text
35
+ }
36
+
37
+ export function paintTone(text: string, tone: DashboardTone, on: boolean): string {
38
+ return paint(text, TONE_COLOR[tone], on)
39
+ }