@defrex/autobuild 1.0.0-beta.1 → 1.0.0-beta.3

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/SPEC.md +310 -56
  2. package/bin/ab-build-runner.ts +10 -8
  3. package/docs/architecture.md +177 -23
  4. package/docs/configuration.md +35 -4
  5. package/docs/hosted-service.md +35 -0
  6. package/docs/integration-tree.md +83 -4
  7. package/docs/landing-policy.md +11 -0
  8. package/docs/migration-1.0.md +9 -0
  9. package/docs/operator-api.md +18 -0
  10. package/docs/remote-store-protocol.md +16 -0
  11. package/docs/remote-ticket-protocol.md +5 -0
  12. package/docs/restacking.md +42 -7
  13. package/docs/setup.md +25 -0
  14. package/docs/spec-standard.md +71 -0
  15. package/docs/ticket-dependencies.md +6 -45
  16. package/docs/ticket-migration.md +50 -4
  17. package/package.json +3 -3
  18. package/packages/core/src/cli/attention.ts +4 -1
  19. package/packages/core/src/cli/binary.ts +17 -1
  20. package/packages/core/src/cli/build-control.ts +3 -3
  21. package/packages/core/src/cli/context.ts +53 -1
  22. package/packages/core/src/cli/dashboard/actions.ts +4 -0
  23. package/packages/core/src/cli/dashboard/detail.ts +45 -1
  24. package/packages/core/src/cli/dashboard/facts.ts +7 -2
  25. package/packages/core/src/cli/dashboard/integration-detail.ts +144 -0
  26. package/packages/core/src/cli/dashboard/integration-row.ts +255 -0
  27. package/packages/core/src/cli/dashboard/landing-display.ts +64 -0
  28. package/packages/core/src/cli/dashboard/model.ts +147 -16
  29. package/packages/core/src/cli/dashboard/poll.ts +40 -4
  30. package/packages/core/src/cli/dashboard/render.ts +106 -5
  31. package/packages/core/src/cli/dashboard/transcript.ts +2 -1
  32. package/packages/core/src/cli/dispatch-frontend.ts +11 -0
  33. package/packages/core/src/cli/dispatch-repository-feed.ts +2 -1
  34. package/packages/core/src/cli/dispatch.ts +49 -14
  35. package/packages/core/src/cli/help.ts +17 -1
  36. package/packages/core/src/cli/main.ts +48 -8
  37. package/packages/core/src/cli/publication-settlement.ts +49 -5
  38. package/packages/core/src/cli/repository-status.ts +103 -2
  39. package/packages/core/src/cli/status.ts +24 -1
  40. package/packages/core/src/cli/terminals.ts +94 -93
  41. package/packages/core/src/cli/ticket.ts +35 -11
  42. package/packages/core/src/cli/wait.ts +11 -2
  43. package/packages/core/src/cli/watch.ts +12 -0
  44. package/packages/core/src/config/schema.ts +3 -0
  45. package/packages/core/src/events/catalog.ts +38 -0
  46. package/packages/core/src/events/compatibility.ts +183 -0
  47. package/packages/core/src/events/native-session.ts +13 -0
  48. package/packages/core/src/events/payloads.ts +150 -2
  49. package/packages/core/src/events/policy.ts +210 -0
  50. package/packages/core/src/events/repository.ts +69 -0
  51. package/packages/core/src/integration/harness.ts +4 -4
  52. package/packages/core/src/kernel/__snapshots__/{reducer-registry.test.ts.snap → reducer-accumulator-shapes.json} +4286 -4006
  53. package/packages/core/src/kernel/change-presence.ts +11 -3
  54. package/packages/core/src/kernel/dispatch-capacity.ts +127 -0
  55. package/packages/core/src/kernel/dispatcher-liveness.ts +5 -1
  56. package/packages/core/src/kernel/engine.ts +25 -5
  57. package/packages/core/src/kernel/forge-health.ts +19 -0
  58. package/packages/core/src/kernel/generators/build-log.ts +18 -0
  59. package/packages/core/src/kernel/generators/node-restack-log.ts +1 -1
  60. package/packages/core/src/kernel/generators/repository-journals.ts +10 -0
  61. package/packages/core/src/kernel/guarded-forge.ts +159 -0
  62. package/packages/core/src/kernel/incremental.ts +4 -2
  63. package/packages/core/src/kernel/integration-completeness.ts +108 -9
  64. package/packages/core/src/kernel/integration-landing.ts +5 -4
  65. package/packages/core/src/kernel/janitor-failure.ts +36 -0
  66. package/packages/core/src/kernel/landing-publication.ts +35 -15
  67. package/packages/core/src/kernel/landing-state.ts +7 -0
  68. package/packages/core/src/kernel/leaf-restack-state.ts +1 -1
  69. package/packages/core/src/kernel/log-index.ts +12 -1
  70. package/packages/core/src/kernel/mixed-version.ts +52 -0
  71. package/packages/core/src/kernel/node-landing.ts +14 -11
  72. package/packages/core/src/kernel/node-parent.ts +35 -10
  73. package/packages/core/src/kernel/node-restack-demand.ts +29 -0
  74. package/packages/core/src/kernel/node-restack-state.ts +46 -16
  75. package/packages/core/src/kernel/node-restack-transaction.ts +151 -8
  76. package/packages/core/src/kernel/node-restack.ts +34 -10
  77. package/packages/core/src/kernel/publication.ts +22 -0
  78. package/packages/core/src/kernel/read-deferrals.ts +111 -0
  79. package/packages/core/src/kernel/read-facts.ts +34 -6
  80. package/packages/core/src/kernel/reconcile-restack.ts +23 -2
  81. package/packages/core/src/kernel/reducer-registry.ts +18 -2
  82. package/packages/core/src/kernel/reducer.ts +196 -10
  83. package/packages/core/src/kernel/repository-attention.ts +38 -1
  84. package/packages/core/src/kernel/terminal-guard.ts +11 -4
  85. package/packages/core/src/kernel/ticket-migrations.ts +139 -0
  86. package/packages/core/src/operator/annotations.ts +6 -0
  87. package/packages/core/src/operator/index.ts +2 -0
  88. package/packages/core/src/operator/presentation.ts +5 -0
  89. package/packages/core/src/operator/query.ts +51 -11
  90. package/packages/core/src/operator/registry.ts +17 -1
  91. package/packages/core/src/operator/restack.ts +51 -0
  92. package/packages/core/src/operator/tickets.ts +30 -26
  93. package/packages/core/src/plugin-sdk/index.ts +10 -0
  94. package/packages/core/src/plugins/manifest.ts +1 -1
  95. package/packages/core/src/ports/forge/contract.ts +23 -0
  96. package/packages/core/src/ports/forge/fake.ts +6 -2
  97. package/packages/core/src/ports/forge/git-rewrite.ts +92 -64
  98. package/packages/core/src/ports/forge/github-transport.ts +45 -2
  99. package/packages/core/src/ports/forge/github.ts +56 -17
  100. package/packages/core/src/ports/forge/local-git.ts +7 -2
  101. package/packages/core/src/ports/forge-failure.ts +40 -0
  102. package/packages/core/src/ports/forge-request-context.ts +35 -0
  103. package/packages/core/src/ports/forge-telemetry.ts +16 -0
  104. package/packages/core/src/ports/runner/claude.ts +136 -9
  105. package/packages/core/src/ports/runner/codex.ts +112 -7
  106. package/packages/core/src/ports/runner/contract.ts +78 -0
  107. package/packages/core/src/ports/runner/fake.ts +59 -1
  108. package/packages/core/src/ports/runner/native-cli-fixture.ts +86 -0
  109. package/packages/core/src/ports/runner/native-process-fixture.ts +38 -0
  110. package/packages/core/src/ports/runner/native-session.ts +110 -0
  111. package/packages/core/src/ports/runner/pi-rpc.ts +7 -1
  112. package/packages/core/src/ports/runner/pi.ts +162 -2
  113. package/packages/core/src/ports/tickets/linear.ts +180 -12
  114. package/packages/core/src/ports/tickets/migration.ts +92 -9
  115. package/packages/core/src/ports/types.ts +60 -5
  116. package/packages/core/src/ports/workspace/git-worktree.ts +45 -51
  117. package/packages/core/src/ports/workspace/vercel-sandbox.ts +28 -12
  118. package/packages/core/src/processes/build-child-exit.ts +50 -2
  119. package/packages/core/src/processes/build-child.ts +15 -7
  120. package/packages/core/src/processes/build-runner.ts +909 -213
  121. package/packages/core/src/processes/dispatcher.ts +815 -369
  122. package/packages/core/src/processes/execution-no-progress.ts +15 -0
  123. package/packages/core/src/processes/pause-execution-fixture.ts +37 -0
  124. package/packages/core/src/processes/phase-failure-budget.ts +2 -1
  125. package/packages/core/src/processes/publication-loss.ts +7 -3
  126. package/packages/core/src/processes/repo-view.ts +53 -6
  127. package/packages/core/src/processes/tick-publication.ts +6 -2
  128. package/packages/core/src/runtime-identity.ts +37 -0
  129. package/packages/core/src/store/adapter.ts +4 -2
  130. package/packages/core/src/store/build-scope.ts +9 -0
  131. package/packages/core/src/store/contract.ts +233 -16
  132. package/packages/core/src/store/digest.ts +20 -2
  133. package/packages/core/src/store/local/schema.ts +6 -0
  134. package/packages/core/src/store/local/store.ts +57 -4
  135. package/packages/core/src/store/memory.ts +83 -2
  136. package/packages/core/src/store/new-build.ts +2 -2
  137. package/packages/core/src/store/phase-session.ts +13 -0
  138. package/packages/core/src/store/reduced-reads.ts +43 -4
  139. package/packages/core/src/store/reducer-value-shapes.json +8911 -6344
  140. package/packages/core/src/store/reducer-value-validation.ts +103 -3
  141. package/packages/core/src/store/reducer-values.ts +21 -6
  142. package/packages/core/src/store/remote/client.ts +145 -20
  143. package/packages/core/src/store/remote/index.ts +2 -0
  144. package/packages/core/src/store/remote/protocol.ts +19 -0
  145. package/packages/core/src/store/remote/version.ts +2 -0
  146. package/packages/core/src/store/repo-state-events.ts +5 -2
  147. package/packages/core/src/store/repo-tick.ts +6 -1
  148. package/packages/core/src/store/session-handle.ts +8 -0
  149. package/packages/core/src/store/snapshots.ts +21 -5
  150. package/packages/core/src/store/types.ts +17 -1
  151. package/packages/core/src/testing/dispatch-read-budget.ts +18 -2
  152. package/packages/core/src/testing/index.ts +7 -0
  153. package/packages/core/src/testing/newer-writer.ts +37 -0
  154. package/packages/core/src/testing/reduced-read-budget.ts +3 -0
  155. package/skills/guide/SKILL.md +140 -25
  156. package/skills/guide/references/integration-tree.md +83 -4
  157. package/skills/guide/references/landing-policy.md +11 -0
  158. package/skills/guide/references/migration-1.0.md +9 -0
  159. package/skills/guide/references/operator-api.md +18 -0
  160. package/skills/guide/references/plugin-authoring.md +47 -4
  161. package/skills/guide/references/remote-store-protocol.md +16 -0
  162. package/skills/guide/references/remote-ticket-protocol.md +5 -0
  163. package/skills/guide/references/restacking.md +42 -7
  164. package/skills/guide/references/setup.md +25 -0
  165. package/skills/guide/references/spec-standard.md +71 -0
  166. package/skills/guide/references/ticket-dependencies.md +6 -45
  167. package/skills/guide/references/ticket-migration.md +50 -4
  168. package/skills/implement/SKILL.md +4 -2
  169. package/skills/operate/SKILL.md +63 -6
  170. package/skills/reconcile/SKILL.md +3 -1
  171. package/skills/spec/SKILL.md +62 -40
  172. package/skills/tickets/SKILL.md +15 -43
@@ -1,3 +1,12 @@
1
+ import { migrationIdentity, ticketMigrationsReducer } from '../../kernel/ticket-migrations'
2
+ import { projectIntegrationDetail, type IntegrationDetail } from './integration-detail'
3
+ import {
4
+ projectIntegrationRow,
5
+ enrichIntegrationRows,
6
+ type IntegrationRow,
7
+ } from './integration-row'
8
+ import { dispatchCapacity, type DispatchCapacity } from '../../kernel/dispatch-capacity'
9
+ import { openBuildWorkspace, provisionMarkerReducer } from '../../processes/dispatcher-selectors'
1
10
  import { projectTree, treeVocabulary, type TreeProjection } from './tree'
2
11
  export { treeVocabulary, consentQueue } from './tree'
3
12
  import { landingAuthorized } from '../../kernel/landing-state'
@@ -6,7 +15,6 @@ import {
6
15
  integrationFailed,
7
16
  integrationCurrent,
8
17
  integrationCycleVerified,
9
- integrationNeedsRunner,
10
18
  } from '../../kernel/integration-state'
11
19
  import type { RepositoryReadFacts } from '../../store/reduced-reads'
12
20
  /**
@@ -121,7 +129,15 @@ export interface PipelineStep {
121
129
  * a verify/finalize step preserves its outcome alongside lifecycle `state`;
122
130
  * `waiting` annotates merge. Rendered inside the `(…)` note, so outcome
123
131
  * distinctions never rely on color alone. */
124
- qualifier?: 'failed' | 'skipped' | 'waiting'
132
+ qualifier?:
133
+ | 'failed'
134
+ | 'skipped'
135
+ | 'waiting'
136
+ | 'consent'
137
+ | 'auto'
138
+ | 'held'
139
+ | 'policy pending'
140
+ | `${number}/${number}`
125
141
  /** Round (plan/implement loops) or attempt (verify/reconcile). Rendered as
126
142
  * `/n` riding the elapsed time when > 1 — supersedes the old `r2`/`a2`. */
127
143
  count?: number
@@ -157,6 +173,20 @@ export interface DashboardHarvest {
157
173
  }
158
174
 
159
175
  export interface DashboardBuild {
176
+ integrationRow?: IntegrationRow
177
+ integrationDetail?: IntegrationDetail
178
+ collectionIdentity?: {
179
+ repo: string
180
+ source?: string
181
+ id?: string
182
+ targetBuild?: string
183
+ targetSource?: string
184
+ targetId?: string
185
+ status: BuildState['status']
186
+ title?: string
187
+ phase?: string
188
+ createdAt?: string
189
+ }
160
190
  tree?: TreeProjection
161
191
  kind?: 'integration' | 'work'
162
192
  target?: string
@@ -279,8 +309,9 @@ export interface DashboardModel {
279
309
  repo: string
280
310
  /** Ready tickets waiting for a slot — the dispatcher's standing queue depth. */
281
311
  queued: number
282
- /** Every nonterminal build consumes one configured dispatch capacity slot. */
312
+ /** Shared occupied/effective slot counter; idle integration nodes are free. */
283
313
  active: DashboardCounter
314
+ capacity?: DispatchCapacity
284
315
  /** Recorded observation occurrences not claimed by a Harvest snapshot,
285
316
  * against the configured count-pressure trigger. */
286
317
  observations: DashboardCounter
@@ -411,7 +442,15 @@ export function autoMergeConsentReason(slug: string): string {
411
442
  */
412
443
  interface StepExtra {
413
444
  producedOutput?: boolean
414
- qualifier?: 'failed' | 'skipped' | 'waiting'
445
+ qualifier?:
446
+ | 'failed'
447
+ | 'skipped'
448
+ | 'waiting'
449
+ | 'consent'
450
+ | 'auto'
451
+ | 'held'
452
+ | 'policy pending'
453
+ | `${number}/${number}`
415
454
  count?: number
416
455
  timing?: StepTiming
417
456
  reason?: string
@@ -568,6 +607,33 @@ export function projectBuildFromFacts(
568
607
  slug: record.slug,
569
608
  ...buildVocabulary(state),
570
609
  tree: projectTree(record, state, facts.log.restack, pipeline.verify.steps),
610
+ integrationRow: projectIntegrationRow(record, state, facts.log.restack, config),
611
+ integrationDetail: projectIntegrationDetail(
612
+ record,
613
+ state,
614
+ facts.log.restack,
615
+ config,
616
+ pipeline,
617
+ ),
618
+ ...(state.janitor?.attention
619
+ ? { setupError: `Janitor failing: ${state.janitor.message}` }
620
+ : {}),
621
+ collectionIdentity: {
622
+ repo: record.repo,
623
+ source: record.ticket?.source,
624
+ id: record.ticket?.id,
625
+ targetBuild: state.target?.build,
626
+ targetSource: state.target?.ticket.source,
627
+ targetId: state.target?.ticket.id,
628
+ status: state.status,
629
+ title: record.ticket?.title,
630
+ phase:
631
+ state.currentPhase?.phase ??
632
+ buildVocabulary(state).integration ??
633
+ state.phase ??
634
+ state.status,
635
+ createdAt: record.createdAt,
636
+ },
571
637
  status,
572
638
  alsoPaused: false,
573
639
  ...(record.ticket?.id !== undefined ? { ticketId: record.ticket.id } : {}),
@@ -585,6 +651,33 @@ export function projectBuildFromFacts(
585
651
  slug: record.slug,
586
652
  ...buildVocabulary(state),
587
653
  tree: projectTree(record, state, facts.log.restack, pipeline.verify.steps),
654
+ integrationRow: projectIntegrationRow(record, state, facts.log.restack, config),
655
+ integrationDetail: projectIntegrationDetail(
656
+ record,
657
+ state,
658
+ facts.log.restack,
659
+ config,
660
+ pipeline,
661
+ ),
662
+ ...(state.janitor?.attention
663
+ ? { setupError: `Janitor failing: ${state.janitor.message}` }
664
+ : {}),
665
+ collectionIdentity: {
666
+ repo: record.repo,
667
+ source: record.ticket?.source,
668
+ id: record.ticket?.id,
669
+ targetBuild: state.target?.build,
670
+ targetSource: state.target?.ticket.source,
671
+ targetId: state.target?.ticket.id,
672
+ status: state.status,
673
+ title: record.ticket?.title,
674
+ phase:
675
+ state.currentPhase?.phase ??
676
+ buildVocabulary(state).integration ??
677
+ state.phase ??
678
+ state.status,
679
+ createdAt: record.createdAt,
680
+ },
588
681
  status,
589
682
  alsoPaused: false,
590
683
  ...(record.ticket?.id !== undefined ? { ticketId: record.ticket.id } : {}),
@@ -870,8 +963,9 @@ export function projectBuildFromFacts(
870
963
  steps[steps.length - 1] = { ...steps[steps.length - 1]!, reason }
871
964
  }
872
965
 
873
- const setupError =
874
- state.infrastructureFailure !== undefined
966
+ const setupError = state.janitor?.attention
967
+ ? `Janitor failing: ${state.janitor.message}`
968
+ : state.infrastructureFailure !== undefined
875
969
  ? `${state.infrastructureFailure.provider} ${state.infrastructureFailure.operation} failed ` +
876
970
  `(attempt ${state.infrastructureFailure.attempt}, ${state.infrastructureFailure.cause}${
877
971
  state.infrastructureFailure.cleanupPending ? ', cleanup pending' : ''
@@ -895,6 +989,24 @@ export function projectBuildFromFacts(
895
989
  slug: record.slug,
896
990
  ...buildVocabulary(state),
897
991
  tree: projectTree(record, state, facts.log.restack, pipeline.verify.steps),
992
+ integrationRow: projectIntegrationRow(record, state, facts.log.restack, config),
993
+ integrationDetail: projectIntegrationDetail(record, state, facts.log.restack, config, pipeline),
994
+ collectionIdentity: {
995
+ repo: record.repo,
996
+ source: record.ticket?.source,
997
+ id: record.ticket?.id,
998
+ targetBuild: state.target?.build,
999
+ targetSource: state.target?.ticket.source,
1000
+ targetId: state.target?.ticket.id,
1001
+ status: state.status,
1002
+ title: record.ticket?.title,
1003
+ phase:
1004
+ state.currentPhase?.phase ??
1005
+ buildVocabulary(state).integration ??
1006
+ state.phase ??
1007
+ state.status,
1008
+ createdAt: record.createdAt,
1009
+ },
898
1010
  status,
899
1011
  alsoPaused: state.status === 'paused' && status === 'blocked',
900
1012
  ...(record.ticket?.id !== undefined ? { ticketId: record.ticket.id } : {}),
@@ -1164,6 +1276,7 @@ export function projectHarvest(
1164
1276
  }
1165
1277
 
1166
1278
  interface DashboardFrameHeader {
1279
+ capacityProjection?: DispatchCapacity
1167
1280
  repo: string
1168
1281
  queued: number
1169
1282
  observationCount: number
@@ -1191,7 +1304,7 @@ export function buildDashboardFromProjected(
1191
1304
  header: DashboardHeader,
1192
1305
  repositoryEvents: RepositoryEvent[] | RepositoryReadFacts = [],
1193
1306
  ): DashboardModel {
1194
- const builds = [...projectedBuilds].sort((a, b) => a.slug.localeCompare(b.slug))
1307
+ const builds = enrichIntegrationRows(projectedBuilds).sort((a, b) => a.slug.localeCompare(b.slug))
1195
1308
  const harvestProjection = projectRepositoryHarvest(repositoryEvents)
1196
1309
  const settings = Array.isArray(repositoryEvents)
1197
1310
  ? reduceDispatchSettings(repositoryEvents)
@@ -1199,7 +1312,11 @@ export function buildDashboardFromProjected(
1199
1312
  return {
1200
1313
  repo: header.repo,
1201
1314
  queued: header.queued,
1202
- active: { current: header.activeCount, limit: header.capacity },
1315
+ active: {
1316
+ current: header.capacityProjection?.occupied ?? header.activeCount,
1317
+ limit: header.capacityProjection?.effective ?? header.capacity,
1318
+ },
1319
+ ...(header.capacityProjection ? { capacity: header.capacityProjection } : {}),
1203
1320
  observations: { current: header.observationCount, limit: header.observationLimit },
1204
1321
  drained: !settings.intake,
1205
1322
  repositoryPaused: settings.paused,
@@ -1227,17 +1344,31 @@ export function buildDashboard(
1227
1344
  const builds = entries
1228
1345
  .map(({ record, state, events }) => projectBuild(record, state, config, events))
1229
1346
  .filter((build): build is DashboardBuild => build !== null)
1230
- const activeCount = entries.filter(
1231
- ({ state }) =>
1232
- (state.kind !== 'node' ||
1233
- (integrationNeedsRunner(state) && state.phase?.startsWith('verify:'))) &&
1234
- state.status !== 'done' &&
1235
- state.status !== 'aborted',
1236
- ).length
1347
+ const capacityProjection = dispatchCapacity(
1348
+ entries.map(({ record, state, events }) => ({
1349
+ record,
1350
+ state,
1351
+ workspace: openBuildWorkspace(events) !== null,
1352
+ provisioning: provisionMarkerReducer.reduce(events) !== undefined,
1353
+ })),
1354
+ config.capacity,
1355
+ new Date(),
1356
+ migrationIdentity(
1357
+ Array.isArray(repositoryEvents)
1358
+ ? ticketMigrationsReducer.reduce(repositoryEvents)
1359
+ : repositoryEvents.ticketMigrations,
1360
+ config.tickets.source,
1361
+ ),
1362
+ )
1363
+ const activeCount = capacityProjection.occupied
1237
1364
  return buildDashboardFromProjected(
1238
- builds,
1365
+ enrichIntegrationRows(
1366
+ builds,
1367
+ entries.map((e) => e.record),
1368
+ ),
1239
1369
  {
1240
1370
  ...header,
1371
+ capacityProjection,
1241
1372
  activeCount,
1242
1373
  capacity: config.capacity,
1243
1374
  observationLimit: config.policy.harvestThreshold,
@@ -1,3 +1,9 @@
1
+ import { enrichIntegrationRows } from './integration-row'
2
+ import type { CapacityBuild } from '../../kernel/dispatch-capacity'
3
+ import {
4
+ openBuildWorkspaceReducer,
5
+ provisionMarkerReducer,
6
+ } from '../../processes/dispatcher-selectors'
1
7
  import type { Config } from '../../config/schema'
2
8
  import { composeBuildConfig } from '../../config/live'
3
9
  import type { PipelineSourceMeta } from '../../config/pipeline-source'
@@ -27,6 +33,7 @@ export interface DashboardBuildReader {
27
33
  export interface DashboardPollSnapshot {
28
34
  /** Monotonic process-local cache revision. */
29
35
  revision: number
36
+ capacityBuilds?: CapacityBuild[]
30
37
  /** Every dashboard-visible row, including acknowledged abort cleanup. Objects
31
38
  * are reused while their streams are unchanged. */
32
39
  builds: DashboardBuild[]
@@ -37,6 +44,9 @@ export interface DashboardPollSnapshot {
37
44
 
38
45
  interface LiveEntry {
39
46
  kind: 'live'
47
+ record: BuildRecord
48
+ workspace: ReturnType<typeof openBuildWorkspaceReducer.initial>
49
+ provisionMarker: ReturnType<typeof provisionMarkerReducer.initial>
40
50
  events: AbEvent[]
41
51
  /** The reducer accumulator `state` was derived from; the next delta is
42
52
  * folded into a copy of it instead of re-reducing the whole log. */
@@ -48,6 +58,7 @@ interface LiveEntry {
48
58
  /** A fully completed build can never become visible again, so its log is discarded. */
49
59
  interface TerminalEntry {
50
60
  kind: 'terminal'
61
+ record: BuildRecord
51
62
  }
52
63
 
53
64
  type PollEntry = LiveEntry | TerminalEntry
@@ -204,7 +215,7 @@ export class DashboardBuildPollCache {
204
215
  for (const record of records) {
205
216
  const current = this.entries.get(record.slug)
206
217
  if (current?.kind === 'terminal') {
207
- next.set(record.slug, current)
218
+ next.set(record.slug, { ...current, record })
208
219
  continue
209
220
  }
210
221
 
@@ -220,9 +231,10 @@ export class DashboardBuildPollCache {
220
231
  fullEnrichment || configChanged || current.build?.ticketId !== record.ticket?.id
221
232
  ? {
222
233
  ...current,
234
+ record,
223
235
  build: await this.projectRow(record, current.state, current.events, config),
224
236
  }
225
- : current,
237
+ : { ...current, record },
226
238
  )
227
239
  continue
228
240
  }
@@ -231,11 +243,20 @@ export class DashboardBuildPollCache {
231
243
  const acc = buildReducer.advance(current?.acc ?? buildReducer.initial(), delta)
232
244
  const state = buildReducer.finish(acc)
233
245
  if (isTerminal(state)) {
234
- next.set(record.slug, { kind: 'terminal' })
246
+ next.set(record.slug, { kind: 'terminal', record })
235
247
  continue
236
248
  }
237
249
  next.set(record.slug, {
238
250
  kind: 'live',
251
+ record,
252
+ workspace: openBuildWorkspaceReducer.advance(
253
+ current?.workspace ?? openBuildWorkspaceReducer.initial(),
254
+ delta,
255
+ ),
256
+ provisionMarker: provisionMarkerReducer.advance(
257
+ current?.provisionMarker ?? provisionMarkerReducer.initial(),
258
+ delta,
259
+ ),
239
260
  events,
240
261
  acc,
241
262
  state,
@@ -255,12 +276,27 @@ export class DashboardBuildPollCache {
255
276
  private snapshot(): DashboardPollSnapshot {
256
277
  const builds: DashboardBuild[] = []
257
278
  const states = new Map<string, BuildState>()
279
+ const capacityBuilds: CapacityBuild[] = []
258
280
  for (const [slug, entry] of this.entries) {
259
281
  if (entry.kind === 'terminal') continue
282
+ capacityBuilds.push({
283
+ record: entry.record,
284
+ state: entry.state,
285
+ workspace: entry.workspace.open !== null,
286
+ provisioning: entry.provisionMarker.marker !== null,
287
+ })
260
288
  states.set(slug, entry.state)
261
289
  if (entry.build !== null) builds.push(entry.build)
262
290
  }
263
291
  builds.sort((a, b) => a.slug.localeCompare(b.slug))
264
- return { revision: this.committedRevision, builds, states }
292
+ return {
293
+ revision: this.committedRevision,
294
+ builds: enrichIntegrationRows(
295
+ builds,
296
+ [...this.entries.values()].map((e) => e.record),
297
+ ),
298
+ states,
299
+ capacityBuilds,
300
+ }
265
301
  }
266
302
  }
@@ -1,3 +1,5 @@
1
+ import { integrationBarCells } from './integration-row'
2
+ import { capacityExplanation } from '../../kernel/dispatch-capacity'
1
3
  import { treeVocabulary, consentQueue } from './tree'
2
4
  /**
3
5
  * The dashboard's other pure half: model → `string[]`. No terminal, no state,
@@ -29,7 +31,7 @@ import type {
29
31
  PipelineStep,
30
32
  } from './model'
31
33
  import { landingPolicyDisplay } from './landing-display'
32
- import { dashboardBuildControl } from './actions'
34
+ import { dashboardBuildControl, pauseResumeHelp } from './actions'
33
35
  import type { DashboardSession } from './detail'
34
36
  import type { TranscriptPresentation, TranscriptTurn } from './transcript'
35
37
  import { projectSessionDocument, projectSessionParts } from './session-view'
@@ -371,6 +373,34 @@ function renderBuild(
371
373
  // The slug is the sole flexible segment; narrow frames truncate it before
372
374
  // the right-pinned lifecycle status.
373
375
  const lines = [rightPinnedLine(leftPrefix, paint(build.slug, 'bold', color), rightStr, width)]
376
+ if (build.integrationRow) {
377
+ const row = build.integrationRow
378
+ const { bar, counts } = integrationProgress(row, color)
379
+ lines.push(
380
+ ...packLines(
381
+ [
382
+ paint(`integration → ${row.destination}`, 'bold', color),
383
+ bar,
384
+ ...(row.parentDistance ? [paint(row.parentDistance, 'dim', color)] : []),
385
+ ...counts,
386
+ ...(row.verified ? [paint('· verified', 'green', color)] : []),
387
+ ],
388
+ width,
389
+ ' ',
390
+ ),
391
+ )
392
+ lines.push(
393
+ ...packLines(
394
+ row.steps.map((s) => renderStep(s, color, now)),
395
+ width,
396
+ ' ',
397
+ ),
398
+ )
399
+ if (row.alert)
400
+ for (const line of wrappedText(row.alert.text, Math.max(1, width - 4), ''))
401
+ lines.push(paint(` ! ${line}`, row.alert.tone, color))
402
+ return lines
403
+ }
374
404
  if (build.target)
375
405
  lines.push(
376
406
  truncate(
@@ -631,6 +661,9 @@ function sessionLines(session: DashboardSession, selected: boolean, opts: Render
631
661
  `runtime ${session.runtime}`,
632
662
  ...(session.model !== undefined ? [`model ${session.model}`] : []),
633
663
  session.status,
664
+ ...(session.cause ? [`cause ${session.cause}`] : []),
665
+ ...(session.fallbackReason ? [`fresh session: ${session.fallbackReason}`] : []),
666
+ ...(session.predecessor ? [`continued from ${session.predecessor}`] : []),
634
667
  ...(session.stream !== undefined ? [`stream ${session.stream} (${session.streamStatus})`] : []),
635
668
  ...(session.reclaimedBy !== undefined
636
669
  ? [
@@ -667,6 +700,27 @@ interface DetailBodyLayout {
667
700
 
668
701
  export type DetailFocusTarget = 'session' | 'message'
669
702
 
703
+ function integrationProgress(row: NonNullable<DashboardBuild['integrationRow']>, color: boolean) {
704
+ const children = row.children
705
+ let bar = paint('┄'.repeat(22), 'dim', color)
706
+ let counts = [paint('children unknown', 'dim', color)]
707
+ if (children.known) {
708
+ const cells = integrationBarCells(children.landed, children.building, children.queued)
709
+ bar =
710
+ paint('━'.repeat(cells[0]!), 'green', color) +
711
+ paint('━'.repeat(cells[1]!), 'cyan', color) +
712
+ paint('─'.repeat(children.total ? cells[2]! : 22), 'dim', color)
713
+ counts = children.total
714
+ ? [
715
+ paint(`${children.landed}/${children.total} landed`, 'green', color),
716
+ ...(children.building ? [paint(`· ${children.building} building`, 'cyan', color)] : []),
717
+ ...(children.queued ? [paint(`· ${children.queued} queued`, 'dim', color)] : []),
718
+ ]
719
+ : [paint('no children yet', 'dim', color)]
720
+ }
721
+ return { bar, counts }
722
+ }
723
+
670
724
  function detailBody(
671
725
  build: DashboardBuild,
672
726
  view: Extract<NonNullable<DashboardModel['view']>, { kind: 'detail' }>,
@@ -674,12 +728,17 @@ function detailBody(
674
728
  ): DetailBodyLayout {
675
729
  const { color, width } = opts
676
730
  const body: string[] = []
731
+ if (dashboardBuildControl(build.status)) body.push(...wrappedText(pauseResumeHelp, width, ' '))
677
732
  if (build.ticketId !== undefined) body.push(` ticket ${displayText(build.ticketId)}`)
678
- if (build.target)
733
+ if (build.target && !build.integrationDetail)
679
734
  body.push(
680
735
  ` ${build.kind ?? treeVocabulary.work} · ${treeVocabulary.target} ${build.target}${build.integration ? ` · ${build.integration}` : ''}`,
681
736
  )
682
- if (build.tree && (build.kind === 'integration' || build.tree.consent)) {
737
+ if (
738
+ !build.integrationDetail &&
739
+ build.tree &&
740
+ (build.kind === 'integration' || build.tree.consent)
741
+ ) {
683
742
  const tree = build.tree
684
743
  body.push(
685
744
  ` ${treeVocabulary.branch} ${tree.branch ?? 'unknown'} · ${treeVocabulary.restack} ${tree.restack}`,
@@ -700,6 +759,48 @@ function detailBody(
700
759
  ` ${treeVocabulary.landing} ${tree.reason ?? (tree.ready ? treeVocabulary.readyToLand : treeVocabulary.notReady)}`,
701
760
  )
702
761
  }
762
+ if (build.integrationDetail && build.integrationRow) {
763
+ const detail = build.integrationDetail
764
+ const field = (label: string, text: string) =>
765
+ body.push(...wrapDisplay(`${label} ${text}`, width, ' '))
766
+ field('Integration', detail.destination)
767
+ const progress = integrationProgress(build.integrationRow, color)
768
+ body.push(...packLines(['Progress', progress.bar, ...progress.counts], width, ' '))
769
+ field('Branch', `${detail.branch} · restack ${detail.restack}`)
770
+ if (detail.parentDistance) field('Parent', detail.parentDistance.replace(/^parent /, ''))
771
+ for (const path of detail.conflictFiles ?? []) field('Conflict', path)
772
+ body.push(
773
+ ...packLines(
774
+ ['Steps', ...build.integrationRow.steps.map((s) => renderStep(s, color, opts.now))],
775
+ width,
776
+ ' ',
777
+ ),
778
+ )
779
+ const open = detail.children.filter((c) => !c.landed).length
780
+ body.push(
781
+ '',
782
+ paint(
783
+ `Children ${open} open · ${detail.children.length - open} landed${detail.membershipKnown ? '' : ' · membership unknown'}`,
784
+ 'bold',
785
+ color,
786
+ ),
787
+ )
788
+ for (const child of detail.children) {
789
+ const id = displayText(child.id)
790
+ const state = displayText(child.state)
791
+ const tone = child.landed ? 'green' : state === 'queued' ? 'dim' : 'cyan'
792
+ const prefix = ` ${paint(child.landed ? '[x]' : state === 'queued' ? '[ ]' : '[>]', tone, color)} ${paint(id, 'blue', color)} `
793
+ const right = paint(state, tone, color)
794
+ if (visibleLength(prefix) + visibleLength(right) + 2 <= width)
795
+ body.push(rightPinnedLine(prefix, displayText(child.title), right, width))
796
+ else body.push(...packLines([id, right], width, ' '))
797
+ }
798
+ for (const diagnostic of detail.diagnostics) field('Membership', diagnostic)
799
+ body.push('')
800
+ field('Verification', detail.verification)
801
+ for (const result of detail.verifySteps) field(result.step, result.outcome)
802
+ field('Landing', detail.landing)
803
+ }
703
804
  if (build.kind !== 'integration') body.push(` landing ${landingPolicyDisplay(build.landing)}`)
704
805
  const ceiling = reviewRoundCeilingText(build)
705
806
  if (ceiling !== undefined) body.push(` ${ceiling}`)
@@ -723,7 +824,7 @@ function detailBody(
723
824
  body.push(...wrappedText(build.abortProgress, width, ' '))
724
825
  } else if (build.dispatch !== undefined) {
725
826
  body.push('', paint('Dispatch', 'bold', color), ...wrappedText(build.dispatch, width, ' '))
726
- } else {
827
+ } else if (!build.integrationDetail) {
727
828
  body.push('', paint('Pipeline', 'bold', color))
728
829
  body.push(...build.steps.map((item) => ` ${detailStep(item, opts)}`))
729
830
  }
@@ -1464,7 +1565,7 @@ function renderDashboardContent(model: DashboardModel, opts: RenderOpts): string
1464
1565
  paint('Autobuild', 'bold', color),
1465
1566
  displayText(basename(model.repo)),
1466
1567
  paint(
1467
- `queue ${model.queued} | active ${model.active.current}/${model.active.limit} | ` +
1568
+ `queue ${model.queued} | active ${model.active.current}/${model.active.limit}${capacityExplanation(model.capacity)} | ` +
1468
1569
  `observations ${model.observations.current}/${model.observations.limit}`,
1469
1570
  'dim',
1470
1571
  color,
@@ -95,7 +95,8 @@ export function parseTranscript(content: string): TranscriptPresentation {
95
95
  "Producer boundary record: this session was kept live for continuation; only this round's final turn was deposited.",
96
96
  turns: [
97
97
  {
98
- prompt: '(producer round invocation)',
98
+ prompt:
99
+ typeof boundary.prompt === 'string' ? boundary.prompt : '(producer round invocation)',
99
100
  text: boundary.text,
100
101
  ...(usage(boundary.usage) !== undefined ? { usage: usage(boundary.usage)! } : {}),
101
102
  },
@@ -1,3 +1,5 @@
1
+ import { migrationIdentity, ticketMigrationsReducer } from '../kernel/ticket-migrations'
2
+ import { dispatchCapacity } from '../kernel/dispatch-capacity'
1
3
  import { forgeReadinessWarnings } from '../kernel/dispatch-status'
2
4
  import { RepositoryPollCache } from './dashboard/repository-poll'
3
5
  import {
@@ -390,6 +392,15 @@ export class DispatchFrontend {
390
392
  (state) => state.kind !== 'node' && state.status !== 'done' && state.status !== 'aborted',
391
393
  ).length,
392
394
  capacity: config.capacity,
395
+ capacityProjection: dispatchCapacity(
396
+ snapshot.capacityBuilds ?? [],
397
+ config.capacity,
398
+ this.clock(),
399
+ migrationIdentity(
400
+ ticketMigrationsReducer.reduce(repositoryEvents),
401
+ config.tickets.source,
402
+ ),
403
+ ),
393
404
  observationCount: this.observationCount,
394
405
  observationLimit: config.policy.harvestThreshold,
395
406
  ...(status.availableUpgrade !== undefined
@@ -6,6 +6,7 @@ import type { BuildStore, Clock } from '../store/types'
6
6
  export function isDashboardRepositoryEvent(event: RepositoryEvent): boolean {
7
7
  return (
8
8
  event.type.startsWith('harvest.') ||
9
+ event.type === 'tickets.migration-recorded' ||
9
10
  event.type === 'dispatcher.intake-set' ||
10
11
  event.type === 'dispatcher.pause-set' ||
11
12
  event.type === 'dispatcher.auto-merge-default-set'
@@ -13,7 +14,7 @@ export function isDashboardRepositoryEvent(event: RepositoryEvent): boolean {
13
14
  }
14
15
 
15
16
  export const dispatchFrontendReducer = defineReducer({
16
- version: 2,
17
+ version: 3,
17
18
  initial: (): { retained: RepositoryEvent[]; incompleteIdentities: boolean } => ({
18
19
  retained: [],
19
20
  incompleteIdentities: true,