@defrex/autobuild 1.0.1 → 1.2.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 (247) hide show
  1. package/README.md +10 -18
  2. package/SPEC.md +499 -238
  3. package/bin/ab-dispatch-generation.ts +11 -2
  4. package/docs/accounts.md +119 -0
  5. package/docs/agent-runtimes.md +4 -4
  6. package/docs/answering-blocked-builds.md +2 -2
  7. package/docs/architecture.md +262 -53
  8. package/docs/assets/headline-wide.png +0 -0
  9. package/docs/build-store.md +3 -41
  10. package/docs/builds.md +4 -4
  11. package/docs/cli.md +18 -4
  12. package/docs/configuration-overview.md +115 -4
  13. package/docs/configuration.md +488 -334
  14. package/docs/dispatcher-hosting.md +19 -34
  15. package/docs/dispatcher.md +1 -1
  16. package/docs/forges.md +5 -5
  17. package/docs/getting-started.md +2 -2
  18. package/docs/glossary.md +6 -6
  19. package/docs/intake.md +2 -0
  20. package/docs/integration-overview.md +15 -15
  21. package/docs/integration-tree.md +45 -38
  22. package/docs/integration.md +6 -6
  23. package/{skills/guide/references/landing-policy.md → docs/merge-policy.md} +40 -24
  24. package/docs/migration-1.0.md +17 -13
  25. package/docs/operating.md +41 -19
  26. package/docs/operator-api.md +180 -51
  27. package/docs/operator-surfaces.md +5 -18
  28. package/docs/overview.md +3 -3
  29. package/docs/plugin-authoring.md +21 -0
  30. package/docs/remote-store-protocol.md +242 -68
  31. package/docs/remote-ticket-protocol.md +30 -50
  32. package/docs/restacking.md +54 -15
  33. package/docs/seams.md +8 -8
  34. package/docs/setup.md +59 -119
  35. package/docs/skills.md +1 -1
  36. package/docs/spec-standard.md +6 -6
  37. package/docs/ticket-dependencies.md +7 -7
  38. package/docs/ticket-sources.md +18 -0
  39. package/docs/tickets.md +8 -2
  40. package/docs/troubleshooting.md +8 -12
  41. package/docs/upgrading.md +9 -4
  42. package/docs/verification.md +60 -14
  43. package/docs/workspaces.md +4 -4
  44. package/package.json +17 -6
  45. package/packages/core/src/accounts/chatgpt-oauth.ts +216 -0
  46. package/packages/core/src/accounts/chatgpt-state.ts +41 -0
  47. package/packages/core/src/accounts/local-credentials.ts +194 -0
  48. package/packages/core/src/accounts/local-inference.ts +106 -0
  49. package/packages/core/src/accounts/local-owner.ts +123 -0
  50. package/packages/core/src/accounts/sensitive.ts +2 -0
  51. package/packages/core/src/cli/accounts.ts +147 -0
  52. package/packages/core/src/cli/binary-direct.ts +13 -1
  53. package/packages/core/src/cli/binary-lifecycle.ts +65 -2
  54. package/packages/core/src/cli/binary.ts +3 -1
  55. package/packages/core/src/cli/build-control.ts +83 -28
  56. package/packages/core/src/cli/connect.ts +3 -3
  57. package/packages/core/src/cli/context.ts +81 -38
  58. package/packages/core/src/cli/dashboard/facts.ts +2 -1
  59. package/packages/core/src/cli/dashboard/integration-detail.ts +8 -8
  60. package/packages/core/src/cli/dashboard/integration-row.ts +40 -13
  61. package/packages/core/src/cli/dashboard/landing-display.ts +25 -0
  62. package/packages/core/src/cli/dashboard/model.ts +56 -33
  63. package/packages/core/src/cli/dashboard/poll.ts +9 -3
  64. package/packages/core/src/cli/dashboard/render.ts +59 -37
  65. package/packages/core/src/cli/dashboard/target-distance.ts +14 -0
  66. package/packages/core/src/cli/dashboard/tree.ts +3 -2
  67. package/packages/core/src/cli/dispatch-args.ts +1 -1
  68. package/packages/core/src/cli/dispatch-frontend.ts +6 -3
  69. package/packages/core/src/cli/dispatch-handoff.ts +125 -44
  70. package/packages/core/src/cli/dispatch-launch-contract.ts +187 -0
  71. package/packages/core/src/cli/dispatch-launcher.ts +54 -21
  72. package/packages/core/src/cli/dispatch-preflight.ts +6 -1
  73. package/packages/core/src/cli/dispatch.ts +106 -11
  74. package/packages/core/src/cli/env.ts +4 -0
  75. package/packages/core/src/cli/help.ts +46 -23
  76. package/packages/core/src/cli/init-readiness-remote.ts +22 -1
  77. package/packages/core/src/cli/init-readiness-shared.ts +5 -1
  78. package/packages/core/src/cli/init-validation.ts +160 -18
  79. package/packages/core/src/cli/main.ts +68 -8
  80. package/packages/core/src/cli/node-verification-provenance.ts +1 -97
  81. package/packages/core/src/cli/publication-settlement.ts +47 -21
  82. package/packages/core/src/cli/repository-status.ts +20 -9
  83. package/packages/core/src/cli/secrets.ts +173 -0
  84. package/packages/core/src/cli/status.ts +42 -5
  85. package/packages/core/src/cli/store-opening.ts +17 -2
  86. package/packages/core/src/cli/terminal.ts +22 -1
  87. package/packages/core/src/cli/terminals.ts +14 -10
  88. package/packages/core/src/cli/upgrade-agent.ts +9 -1
  89. package/packages/core/src/cli/upgrade-landing.ts +70 -30
  90. package/packages/core/src/cli/upgrade.ts +3 -1
  91. package/packages/core/src/cli/wait.ts +15 -7
  92. package/packages/core/src/cli/watch-lifetime.ts +111 -0
  93. package/packages/core/src/cli/watch.ts +635 -510
  94. package/packages/core/src/config/accounts.ts +101 -0
  95. package/packages/core/src/config/effective-artifact.fixture.ts +27 -0
  96. package/packages/core/src/config/effective-artifact.ts +13 -0
  97. package/packages/core/src/config/landing.ts +1 -1
  98. package/packages/core/src/config/live.ts +14 -1
  99. package/packages/core/src/config/load.ts +21 -1
  100. package/packages/core/src/config/pipeline-source.ts +28 -0
  101. package/packages/core/src/config/reference-metadata.ts +2 -0
  102. package/packages/core/src/config/reference.ts +22 -7
  103. package/packages/core/src/config/roles.ts +54 -3
  104. package/packages/core/src/config/schema.ts +146 -162
  105. package/packages/core/src/context-directory.ts +26 -0
  106. package/packages/core/src/distribution-packaging.ts +26 -5
  107. package/packages/core/src/events/catalog.ts +10 -2
  108. package/packages/core/src/events/compatibility.ts +2 -1
  109. package/packages/core/src/events/globs.ts +1 -1
  110. package/packages/core/src/events/payloads.ts +73 -1
  111. package/packages/core/src/events/policy.ts +7 -0
  112. package/packages/core/src/events/repository.ts +4 -4
  113. package/packages/core/src/events/sessions.ts +6 -6
  114. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +574 -0
  115. package/packages/core/src/kernel/auto-merge.ts +2 -2
  116. package/packages/core/src/kernel/engine.ts +255 -26
  117. package/packages/core/src/kernel/generators/leaf-restack-log.ts +10 -0
  118. package/packages/core/src/kernel/integration-landing.ts +3 -3
  119. package/packages/core/src/kernel/integration-state.ts +27 -4
  120. package/packages/core/src/kernel/leaf-restack-state.ts +28 -3
  121. package/packages/core/src/kernel/log-index.ts +13 -1
  122. package/packages/core/src/kernel/node-landing.ts +8 -8
  123. package/packages/core/src/kernel/node-parent.ts +2 -2
  124. package/packages/core/src/kernel/node-restack-transaction.ts +1 -1
  125. package/packages/core/src/kernel/node-verification-context.ts +216 -0
  126. package/packages/core/src/kernel/phases.ts +1 -1
  127. package/packages/core/src/kernel/plan-verify-selection.ts +16 -0
  128. package/packages/core/src/kernel/publication-retry.ts +168 -0
  129. package/packages/core/src/kernel/reconcile-restack.ts +29 -1
  130. package/packages/core/src/kernel/reducer.ts +85 -5
  131. package/packages/core/src/kernel/target-distance.ts +45 -0
  132. package/packages/core/src/kernel/terminal-guard.ts +10 -1
  133. package/packages/core/src/kernel/verify-stage-state.ts +123 -0
  134. package/packages/core/src/kernel/verify-stages.ts +39 -0
  135. package/packages/core/src/ontology.ts +1 -0
  136. package/packages/core/src/operator/annotations.ts +6 -0
  137. package/packages/core/src/operator/control.ts +1 -1
  138. package/packages/core/src/operator/index.ts +3 -7
  139. package/packages/core/src/operator/landings.ts +5 -1
  140. package/packages/core/src/operator/presentation.ts +6 -1
  141. package/packages/core/src/operator/protocol.ts +6 -0
  142. package/packages/core/src/operator/query.ts +14 -18
  143. package/packages/core/src/operator/registry.ts +39 -7
  144. package/packages/core/src/operator/sandbox-host.ts +64 -40
  145. package/packages/core/src/operator/sandbox.ts +3 -0
  146. package/packages/core/src/operator/ticket-source-backend.ts +3 -12
  147. package/packages/core/src/operator/tickets.ts +25 -4
  148. package/packages/core/src/plugins/manifest.ts +2 -1
  149. package/packages/core/src/ports/forge/contract.ts +2 -2
  150. package/packages/core/src/ports/forge/git-rewrite.ts +25 -2
  151. package/packages/core/src/ports/forge/github-readiness.ts +2 -2
  152. package/packages/core/src/ports/forge/github.ts +26 -7
  153. package/packages/core/src/ports/forge/local-git.ts +4 -4
  154. package/packages/core/src/ports/forge/readiness.ts +1 -1
  155. package/packages/core/src/ports/forge-failure.ts +24 -0
  156. package/packages/core/src/ports/runner/account-env.ts +88 -0
  157. package/packages/core/src/ports/runner/chatgpt-provider.ts +85 -0
  158. package/packages/core/src/ports/runner/claude.ts +26 -2
  159. package/packages/core/src/ports/runner/codex.ts +63 -31
  160. package/packages/core/src/ports/runner/one-shot.ts +2 -0
  161. package/packages/core/src/ports/runner/provider-error.ts +5 -0
  162. package/packages/core/src/ports/runner/routing.ts +35 -4
  163. package/packages/core/src/ports/tickets/contract.ts +58 -0
  164. package/packages/core/src/ports/tickets/tree.ts +1 -1
  165. package/packages/core/src/ports/types.ts +28 -7
  166. package/packages/core/src/ports/workspace/account-policy.ts +72 -0
  167. package/packages/core/src/ports/workspace/build-execution.ts +9 -2
  168. package/packages/core/src/ports/workspace/builtin-capabilities.ts +1 -0
  169. package/packages/core/src/ports/workspace/create.ts +2 -0
  170. package/packages/core/src/ports/workspace/git-worktree.ts +6 -1
  171. package/packages/core/src/ports/workspace/phase-scratch.ts +4 -3
  172. package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -0
  173. package/packages/core/src/ports/workspace/vercel-sandbox.ts +182 -72
  174. package/packages/core/src/processes/build-child.ts +6 -8
  175. package/packages/core/src/processes/build-execution-state.ts +8 -5
  176. package/packages/core/src/processes/build-runner.ts +554 -99
  177. package/packages/core/src/processes/dispatcher.ts +209 -101
  178. package/packages/core/src/processes/execution-no-progress.ts +8 -1
  179. package/packages/core/src/processes/execution-settlement.ts +21 -3
  180. package/packages/core/src/processes/harvest-runner.ts +68 -8
  181. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  182. package/packages/core/src/processes/publication-loss.ts +8 -2
  183. package/packages/core/src/processes/publication-state.ts +42 -4
  184. package/packages/core/src/processes/repo-view.ts +14 -0
  185. package/packages/core/src/processes/verify-cycle-config.ts +96 -0
  186. package/packages/core/src/project-secrets.ts +105 -0
  187. package/packages/core/src/{integration → scenarios}/harness.ts +330 -317
  188. package/packages/core/src/secret-name.ts +41 -0
  189. package/packages/core/src/store/account-redaction.ts +156 -0
  190. package/packages/core/src/store/adapter.ts +1 -0
  191. package/packages/core/src/store/build-scope.ts +9 -0
  192. package/packages/core/src/store/contract.ts +116 -2
  193. package/packages/core/src/store/local/schema.ts +13 -0
  194. package/packages/core/src/store/local/store.ts +42 -0
  195. package/packages/core/src/store/memory.ts +47 -0
  196. package/packages/core/src/store/operator-presence.ts +21 -0
  197. package/packages/core/src/store/phase-session.ts +10 -0
  198. package/packages/core/src/store/reducer-value-shapes.json +5185 -4156
  199. package/packages/core/src/store/remote/client.ts +89 -48
  200. package/packages/core/src/store/remote/compatibility.ts +20 -0
  201. package/packages/core/src/store/remote/protocol.ts +4 -0
  202. package/packages/core/src/store/remote/version.ts +3 -1
  203. package/packages/core/src/store/retention.ts +2 -3
  204. package/packages/core/src/store/session-handle.ts +9 -0
  205. package/packages/core/src/store/streams/session-writer.ts +1 -1
  206. package/packages/core/src/store/types.ts +12 -2
  207. package/packages/core/src/testing/dispatch-read-budget.ts +122 -0
  208. package/packages/core/src/testing/index.ts +12 -1
  209. package/packages/core/src/testing/reduced-read-budget.ts +47 -0
  210. package/packages/core/src/testing/temp-directories.ts +58 -0
  211. package/skills/code-review/SKILL.md +23 -9
  212. package/skills/finalize/SKILL.md +15 -7
  213. package/skills/guide/SKILL.md +373 -148
  214. package/skills/guide/references/accounts.md +119 -0
  215. package/skills/guide/references/integration-tree.md +45 -38
  216. package/{docs/landing-policy.md → skills/guide/references/merge-policy.md} +40 -24
  217. package/skills/guide/references/migration-1.0.md +17 -13
  218. package/skills/guide/references/operator-api.md +180 -51
  219. package/skills/guide/references/plugin-authoring.md +21 -0
  220. package/skills/guide/references/remote-store-protocol.md +242 -68
  221. package/skills/guide/references/remote-ticket-protocol.md +30 -50
  222. package/skills/guide/references/restacking.md +54 -15
  223. package/skills/guide/references/setup.md +59 -119
  224. package/skills/guide/references/spec-standard.md +6 -6
  225. package/skills/guide/references/ticket-dependencies.md +7 -7
  226. package/skills/harvest/SKILL.md +3 -1
  227. package/skills/harvest-review/SKILL.md +3 -1
  228. package/skills/implement/SKILL.md +43 -17
  229. package/skills/operate/SKILL.md +118 -118
  230. package/skills/plan/SKILL.md +39 -13
  231. package/skills/plan-review/SKILL.md +15 -10
  232. package/skills/reconcile/SKILL.md +22 -3
  233. package/skills/spec/SKILL.md +20 -20
  234. package/skills/tickets/SKILL.md +12 -9
  235. package/templates/autobuild.toml +1 -1
  236. package/templates/hosted-service/package.json +2 -2
  237. package/docs/hosted-dispatcher-cutover-validation.md +0 -178
  238. package/docs/hosted-dispatcher.md +0 -275
  239. package/docs/hosted-service.md +0 -293
  240. package/docs/mcp.md +0 -149
  241. package/packages/core/src/orchestrator/approvals.ts +0 -115
  242. package/packages/core/src/orchestrator/conversation.ts +0 -167
  243. package/packages/core/src/orchestrator/model.ts +0 -86
  244. package/packages/core/src/orchestrator/prompt.ts +0 -63
  245. package/packages/core/src/orchestrator/tools.ts +0 -117
  246. package/packages/core/src/orchestrator/turn-runner.ts +0 -457
  247. package/packages/core/src/processes/orchestrator-tick.ts +0 -360
@@ -68,3 +68,28 @@ export function nodeLandingRuleDisplay(
68
68
  ? 'default rule for integration builds: consent'
69
69
  : `rule ${rule.index + 1}: ${JSON.stringify(rule.snapshot)}`
70
70
  }
71
+
72
+ /** Public merge vocabulary shared by terminal and web renderers. */
73
+ export const mergeVocabulary = {
74
+ title: 'Merge',
75
+ label: 'merge',
76
+ merged: 'merged',
77
+ consent: 'Merge awaits consent. Merge releases this build; Hold keeps it waiting.',
78
+ } as const
79
+
80
+ export function mergeSummary(build: {
81
+ landing?: BuildState['landing']
82
+ autoMerge: string
83
+ }): string {
84
+ const landing = build.landing
85
+ const status =
86
+ landing?.command?.kind === 'hold'
87
+ ? 'held'
88
+ : landing?.decision?.mode === 'consent' && landing.command?.kind !== 'land'
89
+ ? 'awaiting consent'
90
+ : build.autoMerge
91
+ return `${mergeVocabulary.label} ${status}`
92
+ }
93
+ export function mergedChildren(merged: number, total: number): string {
94
+ return `${merged}/${total} ${mergeVocabulary.merged}`
95
+ }
@@ -1,3 +1,4 @@
1
+ import { workTargetDistance } from './target-distance'
1
2
  import { migrationIdentity, ticketMigrationsReducer } from '../../kernel/ticket-migrations'
2
3
  import { projectRollback, type DashboardRollback } from './rollback'
3
4
  import { dispatchUpgradeReducer, type DispatchUpgradeState } from '../../kernel/dispatch-upgrade'
@@ -133,6 +134,7 @@ export interface PipelineStep {
133
134
  * `waiting` annotates merge. Rendered inside the `(…)` note, so outcome
134
135
  * distinctions never rely on color alone. */
135
136
  qualifier?:
137
+ | 'cancelled'
136
138
  | 'failed'
137
139
  | 'skipped'
138
140
  | 'waiting'
@@ -193,6 +195,7 @@ export interface DashboardBuild {
193
195
  }
194
196
  tree?: TreeProjection
195
197
  kind?: 'integration' | 'work'
198
+ targetDistance?: string
196
199
  target?: string
197
200
  integration?:
198
201
  | 'reparenting'
@@ -202,11 +205,11 @@ export interface DashboardBuild {
202
205
  | 'verifying'
203
206
  | 'verification failed'
204
207
  | 'awaiting consent'
205
- | 'ready to land'
206
- | 'human landing'
207
- | 'fenced landing'
208
- | 'unfenced landing'
209
- | 'unverified landing'
208
+ | 'ready to merge'
209
+ | 'human merge'
210
+ | 'fenced merge'
211
+ | 'unfenced merge'
212
+ | 'unverified merge'
210
213
  slug: string
211
214
  status: EffectiveStatus
212
215
  /** True when the build is BOTH paused and blocked: blocked wins the status
@@ -436,7 +439,7 @@ export function autoMergeDisplay(state: BuildState): AutoMergeDisplay {
436
439
  * so the terminal row/detail and the web row/detail say the same words, and
437
440
  * so it names the per-build control that unblocks the parked build. */
438
441
  export function autoMergeConsentReason(slug: string): string {
439
- return `Landing awaits consent — use ab land ${slug}; use ab hold ${slug} to withdraw consent`
442
+ return `Merge awaits consent — use ab merge ${slug}; use ab hold ${slug} to withdraw consent`
440
443
  }
441
444
 
442
445
  /**
@@ -450,6 +453,7 @@ export function autoMergeConsentReason(slug: string): string {
450
453
  interface StepExtra {
451
454
  producedOutput?: boolean
452
455
  qualifier?:
456
+ | 'cancelled'
453
457
  | 'failed'
454
458
  | 'skipped'
455
459
  | 'waiting'
@@ -613,6 +617,8 @@ export function projectBuildFromFacts(
613
617
  return {
614
618
  slug: record.slug,
615
619
  ...buildVocabulary(state),
620
+ target: state.target?.ticket.id ?? state.baseBranch ?? config.baseBranch,
621
+ targetDistance: workTargetDistance(state, facts.log.restack),
616
622
  tree: projectTree(record, state, facts.log.restack, pipeline.verify.steps),
617
623
  integrationRow: projectIntegrationRow(record, state, facts.log.restack, config),
618
624
  integrationDetail: projectIntegrationDetail(
@@ -657,6 +663,9 @@ export function projectBuildFromFacts(
657
663
  return {
658
664
  slug: record.slug,
659
665
  ...buildVocabulary(state),
666
+ target: state.target?.ticket.id ?? state.baseBranch ?? config.baseBranch,
667
+ targetDistance:
668
+ state.kind === 'node' ? undefined : workTargetDistance(state, facts.log.restack),
660
669
  tree: projectTree(record, state, facts.log.restack, pipeline.verify.steps),
661
670
  integrationRow: projectIntegrationRow(record, state, facts.log.restack, config),
662
671
  integrationDetail: projectIntegrationDetail(
@@ -761,18 +770,19 @@ export function projectBuildFromFacts(
761
770
  // already has the log in hand). A running build keeps its open interval live
762
771
  // (the renderer ticks it against `now`); a paused build freezes every open
763
772
  // interval at its acknowledgement (including while RESUMING), while a
764
- // blocked build freezes at the latest durable event. Timers therefore do not
765
- // advance behind either gate (AC 10). Each step scopes by the SAME seq boundary its state uses, so
773
+ // blocked build freezes at the latest non-distance durable event. Timers do
774
+ // not advance behind either gate (AC 10). Each step scopes by the SAME seq boundary its state uses, so
766
775
  // durations and states restart in lockstep (AC 12).
767
776
  const intervals = dashboard.intervals
768
777
  const pausedAt = state.status === 'paused' ? dashboard.pausedAt : undefined
778
+ const activityAt = facts.log.restack.activityAt ?? state.lastEvent?.ts
769
779
  const frozenNow =
770
780
  state.status === 'running'
771
781
  ? undefined
772
782
  : pausedAt !== undefined
773
783
  ? Date.parse(pausedAt)
774
- : state.lastEvent !== undefined
775
- ? Date.parse(state.lastEvent.ts)
784
+ : activityAt !== undefined
785
+ ? Date.parse(activityAt)
776
786
  : undefined
777
787
 
778
788
  // ── Shared derivations ────────────────────────────────────────────────────
@@ -865,7 +875,10 @@ export function projectBuildFromFacts(
865
875
 
866
876
  for (const s of pipeline.verify.steps) {
867
877
  const phase = verifyPhase(s)
868
- const current = at(phase)
878
+ const current =
879
+ (
880
+ state.verify.running ?? (state.verify.currentStep ? [state.verify.currentStep] : [])
881
+ ).includes(s) && activePhase !== undefined
869
882
  const stepResults = cycle.filter((r) => r.step === s)
870
883
  // The attempt COUNT comes from `currentPhase.attempt` for the running step
871
884
  // — the attempt ACTUALLY running (`verify.started` populates it directly),
@@ -888,12 +901,20 @@ export function projectBuildFromFacts(
888
901
  steps.push(
889
902
  step(phase, !cycleFailed && verifySatisfied(s), current, {
890
903
  producedOutput: stepResults.length > 0,
891
- qualifier: stepResults.some((r) => r.outcome === 'fail')
892
- ? 'failed'
893
- : stepResults.some((r) => r.outcome === 'skipped')
894
- ? 'skipped'
895
- : undefined,
896
- reason: stepResults.find((r) => r.skipCause === 'post-reconcile-policy')?.reason,
904
+ qualifier: Object.values(state.verifyStage.cancellations).some(
905
+ (c) => c.seq > cycleSince && c.step === s,
906
+ )
907
+ ? 'cancelled'
908
+ : stepResults.some((r) => r.outcome === 'fail')
909
+ ? 'failed'
910
+ : stepResults.some((r) => r.outcome === 'skipped')
911
+ ? 'skipped'
912
+ : undefined,
913
+ reason:
914
+ Object.values(state.verifyStage.cancellations)
915
+ .filter((c) => c.seq > cycleSince && c.step === s)
916
+ .map((c) => `not run: cancelled by verify:${c.cause.step}`)
917
+ .at(-1) ?? stepResults.find((r) => r.skipCause === 'post-reconcile-policy')?.reason,
897
918
  count,
898
919
  timing: timingFor(intervals, phase, cycleSince, frozenNow),
899
920
  }),
@@ -946,11 +967,10 @@ export function projectBuildFromFacts(
946
967
  verifyDrained &&
947
968
  postStepsDrained &&
948
969
  activePhase === undefined
949
- // Merge-ready start = the log's last-event ts: once the build drains the
950
- // engine parks on `wait{awaiting-pr}` and appends nothing, so `lastEvent.ts`
951
- // is exactly when it became merge-ready, ticking like a running phase (AC 9).
970
+ // Advisory distance refreshes must not restart the merge waiting clock.
971
+ // Retain the last lifecycle activity when the engine parks awaiting its PR.
952
972
  // Frozen at that same ts when the build is not running.
953
- const lastMs = state.lastEvent !== undefined ? Date.parse(state.lastEvent.ts) : 0
973
+ const lastMs = activityAt === undefined ? 0 : Date.parse(activityAt)
954
974
  const mergeTiming: StepTiming | undefined = !mergeCurrent
955
975
  ? undefined
956
976
  : frozenNow !== undefined
@@ -963,10 +983,10 @@ export function projectBuildFromFacts(
963
983
  if (mergeCurrent && !landingAuthorized(state.landing)) {
964
984
  const reason =
965
985
  state.landing?.command?.kind === 'hold'
966
- ? `Landing held — use ab land ${record.slug} when ready to release the hold`
986
+ ? `Merge held — use ab merge ${record.slug} when ready to release the hold`
967
987
  : state.landing?.decision?.mode === 'consent'
968
988
  ? autoMergeConsentReason(record.slug)
969
- : 'Landing policy decision pending'
989
+ : 'Merge policy decision pending'
970
990
  steps[steps.length - 1] = { ...steps[steps.length - 1]!, reason }
971
991
  }
972
992
 
@@ -995,6 +1015,9 @@ export function projectBuildFromFacts(
995
1015
  return {
996
1016
  slug: record.slug,
997
1017
  ...buildVocabulary(state),
1018
+ target: state.target?.ticket.id ?? state.baseBranch ?? config.baseBranch,
1019
+ targetDistance:
1020
+ state.kind === 'node' ? undefined : workTargetDistance(state, facts.log.restack),
998
1021
  tree: projectTree(record, state, facts.log.restack, pipeline.verify.steps),
999
1022
  integrationRow: projectIntegrationRow(record, state, facts.log.restack, config),
1000
1023
  integrationDetail: projectIntegrationDetail(record, state, facts.log.restack, config, pipeline),
@@ -1033,7 +1056,7 @@ export function projectBuildFromFacts(
1033
1056
  ? 'integration awaits verification'
1034
1057
  : !landingAuthorized(state.landing)
1035
1058
  ? 'integration awaits explicit per-build consent'
1036
- : 'integration awaits guarded landing',
1059
+ : 'integration awaits guarded merge',
1037
1060
  }),
1038
1061
  ]
1039
1062
  : steps,
@@ -1413,11 +1436,11 @@ export function buildVocabulary(state: BuildState): {
1413
1436
  | 'verifying'
1414
1437
  | 'verification failed'
1415
1438
  | 'awaiting consent'
1416
- | 'ready to land'
1417
- | 'human landing'
1418
- | 'fenced landing'
1419
- | 'unfenced landing'
1420
- | 'unverified landing'
1439
+ | 'ready to merge'
1440
+ | 'human merge'
1441
+ | 'fenced merge'
1442
+ | 'unfenced merge'
1443
+ | 'unverified merge'
1421
1444
  } {
1422
1445
  return {
1423
1446
  kind: state.kind === 'node' ? treeVocabulary.integrationKind : treeVocabulary.work,
@@ -1429,13 +1452,13 @@ export function buildVocabulary(state: BuildState): {
1429
1452
  integration:
1430
1453
  state.integration?.audit &&
1431
1454
  state.integration.audit.verifiedTree !== state.integration.audit.landedTree
1432
- ? 'unverified landing'
1455
+ ? 'unverified merge'
1433
1456
  : state.integration?.landing?.provenance === 'human'
1434
- ? 'human landing'
1457
+ ? 'human merge'
1435
1458
  : state.integration?.landing
1436
1459
  ? state.integration.landing.fenced
1437
- ? 'fenced landing'
1438
- : 'unfenced landing'
1460
+ ? 'fenced merge'
1461
+ : 'unfenced merge'
1439
1462
  : state.nodeRestack?.parentRequest || state.nodeRestack?.parentChange
1440
1463
  ? 'reparenting'
1441
1464
  : integrationFailed(state)
@@ -27,7 +27,7 @@ export interface DashboardBuildReader {
27
27
  listBuildsForRepo(repo: string): Promise<BuildRecord[]>
28
28
  getEvents(slug: string, sinceSeq?: number): Promise<AbEvent[]>
29
29
  listStreams?(scope: StreamScope): Promise<StreamRecord[]>
30
- getArtifact?(slug: string, kind: string): Promise<Artifact | null>
30
+ getArtifact?(slug: string, kind: string, rev?: number): Promise<Artifact | null>
31
31
  }
32
32
 
33
33
  export interface DashboardPollSnapshot {
@@ -140,13 +140,19 @@ export class DashboardBuildPollCache {
140
140
  * (config absent); all failures are display-only. */
141
141
  private async readEffectiveConfig(
142
142
  slug: string,
143
+ pin?: BuildState['verify']['configPin'],
143
144
  ): Promise<
144
145
  { revision?: number; pipelineSource?: PipelineSourceMeta; config?: Config } | undefined
145
146
  > {
146
147
  const getArtifact = this.reader.getArtifact
147
148
  if (getArtifact === undefined) return undefined
148
149
  try {
149
- const artifact = await getArtifact.call(this.reader, slug, BUILD_EFFECTIVE_CONFIG_ARTIFACT)
150
+ const artifact = await getArtifact.call(
151
+ this.reader,
152
+ slug,
153
+ pin?.artifact.kind ?? BUILD_EFFECTIVE_CONFIG_ARTIFACT,
154
+ pin?.artifact.rev,
155
+ )
150
156
  if (artifact === null) return undefined
151
157
  let config: Config | undefined
152
158
  try {
@@ -176,7 +182,7 @@ export class DashboardBuildPollCache {
176
182
  ): Promise<DashboardBuild | null> {
177
183
  const [streams, artifact] = await Promise.all([
178
184
  this.readStreams(record.slug),
179
- this.readEffectiveConfig(record.slug),
185
+ this.readEffectiveConfig(record.slug, state.verify.configPin),
180
186
  ])
181
187
  const pinnedConfig =
182
188
  artifact?.config !== undefined ? composeBuildConfig(artifact.config, config) : undefined
@@ -33,7 +33,12 @@ import type {
33
33
  DashboardSelection,
34
34
  PipelineStep,
35
35
  } from './model'
36
- import { landingPolicyDisplay } from './landing-display'
36
+ import {
37
+ landingPolicyDisplay,
38
+ mergeVocabulary,
39
+ mergeSummary,
40
+ mergedChildren,
41
+ } from './landing-display'
37
42
  import { dashboardBuildControl, pauseResumeHelp } from './actions'
38
43
  import type { DashboardSession } from './detail'
39
44
  import type { TranscriptPresentation, TranscriptTurn } from './transcript'
@@ -230,15 +235,15 @@ const STEP_COLOR: Record<PipelineStep['state'], ColorName> = {
230
235
 
231
236
  /**
232
237
  * Elapsed duration, ASCII only: `Xs` under a minute, `MmSSs` under an hour,
233
- * `HhMMm` above — seconds/minutes zero-padded when a larger unit precedes, so
234
- * the field width is stable as it ticks (`38s`, `4m12s`, `1h04m`).
238
+ * `HhMMmSSs` above — seconds/minutes zero-padded when a larger unit precedes, so
239
+ * the field width is stable as it ticks (`38s`, `4m12s`, `1h04m07s`).
235
240
  */
236
241
  export function formatDuration(ms: number): string {
237
242
  const totalSec = Math.max(0, Math.floor(ms / 1000))
238
243
  if (totalSec < 60) return `${totalSec}s`
239
244
  const totalMin = Math.floor(totalSec / 60)
240
245
  if (totalMin < 60) return `${totalMin}m${String(totalSec % 60).padStart(2, '0')}s`
241
- return `${Math.floor(totalMin / 60)}h${String(totalMin % 60).padStart(2, '0')}m`
246
+ return `${Math.floor(totalMin / 60)}h${String(totalMin % 60).padStart(2, '0')}m${String(totalSec % 60).padStart(2, '0')}s`
242
247
  }
243
248
 
244
249
  function renderStep(step: PipelineStep, color: boolean, now: number): string {
@@ -297,6 +302,25 @@ function rightPinnedLine(prefix: string, flexible: string, right: string, width:
297
302
  return truncate(`${prefix}${left}${gap}${right}`, width)
298
303
  }
299
304
 
305
+ /** Preserve lifecycle, then destination, then identity as space tightens. */
306
+ function buildHeader(
307
+ prefix: string,
308
+ slug: string,
309
+ destination: string,
310
+ right: string,
311
+ width: number,
312
+ status: string,
313
+ ): string {
314
+ const pinned = visibleLength(right) > width ? truncate(status, width) : right
315
+ const available = Math.max(0, width - visibleLength(pinned) - 1)
316
+ const identityPrefix = truncate(prefix, available)
317
+ const target = truncate(destination, Math.max(0, available - visibleLength(identityPrefix)))
318
+ const identityBudget = Math.max(0, available - visibleLength(target))
319
+ const identity = truncate(slug, Math.max(0, identityBudget - visibleLength(identityPrefix)))
320
+ const left = `${identityPrefix}${identity}${target}`
321
+ return `${left}${' '.repeat(Math.max(0, width - visibleLength(left) - visibleLength(pinned)))}${pinned}`
322
+ }
323
+
300
324
  function reviewRoundCeilingText(build: DashboardBuild): string | undefined {
301
325
  if (build.reviewRoundCeilings === undefined) return undefined
302
326
  const values = [
@@ -351,14 +375,7 @@ function renderBuild(
351
375
  : build.autoMerge === 'cancelling'
352
376
  ? 'yellow'
353
377
  : 'dim'
354
- if (build.kind !== 'integration')
355
- rightTokens.push(
356
- paint(
357
- `landing ${build.landing?.command?.kind === 'hold' ? 'held' : build.landing?.decision?.mode === 'consent' && build.landing.command?.kind !== 'land' ? 'awaiting consent' : build.autoMerge}`,
358
- autoColor,
359
- color,
360
- ),
361
- )
378
+ if (build.kind !== 'integration') rightTokens.push(paint(mergeSummary(build), autoColor, color))
362
379
  }
363
380
  if (build.pr !== undefined) rightTokens.push(link(build.pr.url, `PR ${build.pr.state}`, color))
364
381
  // A repository hold changes no build lifecycle state. Keep QUEUED literal
@@ -377,19 +394,27 @@ function renderBuild(
377
394
 
378
395
  // The slug is the sole flexible segment; narrow frames truncate it before
379
396
  // the right-pinned lifecycle status.
380
- const lines = [rightPinnedLine(leftPrefix, paint(build.slug, 'bold', color), rightStr, width)]
397
+ const destination = build.integrationRow?.destination ?? build.target
398
+ const suffix = build.integrationRow?.parentDistance ?? build.targetDistance ?? '+?'
399
+ const target = destination
400
+ ? ` → ${displayText(destination)}${suffix ? ` ${paint(suffix, 'dim', color)}` : ''}`
401
+ : ''
402
+ const lines = [
403
+ buildHeader(
404
+ leftPrefix,
405
+ paint(build.slug, 'bold', color),
406
+ target,
407
+ rightStr,
408
+ width,
409
+ paint(build.status.toUpperCase(), STATUS_COLOR[build.status], color),
410
+ ),
411
+ ]
381
412
  if (build.integrationRow) {
382
413
  const row = build.integrationRow
383
414
  const { bar, counts } = integrationProgress(row, color)
384
415
  lines.push(
385
416
  ...packLines(
386
- [
387
- paint(`integration → ${row.destination}`, 'bold', color),
388
- bar,
389
- ...(row.parentDistance ? [paint(row.parentDistance, 'dim', color)] : []),
390
- ...counts,
391
- ...(row.verified ? [paint('· verified', 'green', color)] : []),
392
- ],
417
+ [bar, ...counts, ...(row.verified ? [paint('· verified', 'green', color)] : [])],
393
418
  width,
394
419
  ' ',
395
420
  ),
@@ -406,13 +431,6 @@ function renderBuild(
406
431
  lines.push(paint(` ! ${line}`, row.alert.tone, color))
407
432
  return lines
408
433
  }
409
- if (build.target)
410
- lines.push(
411
- truncate(
412
- ` ${build.kind ?? treeVocabulary.work} · ${treeVocabulary.target} ${build.target}${build.integration ? ` · ${build.integration}` : ''}`,
413
- width,
414
- ),
415
- )
416
434
  if (build.tree && (build.kind === 'integration' || build.tree.consent)) {
417
435
  const tree = build.tree
418
436
  for (const text of [
@@ -523,13 +541,13 @@ function frameWidths(builds: DashboardBuild[], harvest: DashboardHarvest | undef
523
541
  // ── The frame ────────────────────────────────────────────────────────────────
524
542
 
525
543
  export const DASHBOARD_GLOBAL_LEGEND =
526
- 'Keys: Up/Down select h harvest l land o hold i intake p pause all r resume all Ctrl-C quit'
544
+ 'Keys: Up/Down select h harvest l merge o hold i intake p pause all r resume all Ctrl-C quit'
527
545
  export const DASHBOARD_HARVEST_LEGEND = 'Keys: Up/Down select Ctrl-C quit'
528
546
  export const DASHBOARD_HARVEST_RESUME_LEGEND = 'Keys: Up/Down select p resume Ctrl-C quit'
529
547
  export const DASHBOARD_HARVEST_ACKNOWLEDGE_LEGEND =
530
548
  'Keys: Up/Down select p acknowledge Ctrl-C quit'
531
549
  export const DASHBOARD_BUILD_LEGEND =
532
- 'Keys: Up/Down select Enter details l land o hold p pause a abort Ctrl-C quit'
550
+ 'Keys: Up/Down select Enter details l merge o hold p pause a abort Ctrl-C quit'
533
551
  export const DASHBOARD_QUEUED_BUILD_LEGEND =
534
552
  'Keys: Up/Down select Enter details d discard a abort Ctrl-C quit'
535
553
  /** The session view offers ONLY scrolling, back, and quit — it is read-only,
@@ -553,8 +571,8 @@ function buildLegend(build: DashboardBuild, detail: boolean): string {
553
571
  const control = dashboardBuildControl(build.status)
554
572
  const action = control === undefined ? '' : ` ${control.key} ${control.label}`
555
573
  return detail
556
- ? `Keys: Up/Down scroll Left/Right select session Enter transcript l land o hold${action} a abort Esc back Ctrl-C quit`
557
- : `Keys: Up/Down select Enter details l land o hold${action} a abort Ctrl-C quit`
574
+ ? `Keys: Up/Down scroll Left/Right select session Enter transcript l merge o hold${action} a abort Esc back Ctrl-C quit`
575
+ : `Keys: Up/Down select Enter details l merge o hold${action} a abort Ctrl-C quit`
558
576
  }
559
577
 
560
578
  const MESSAGE_PREVIEW_ROWS = 3
@@ -717,7 +735,7 @@ function integrationProgress(row: NonNullable<DashboardBuild['integrationRow']>,
717
735
  paint('─'.repeat(children.total ? cells[2]! : 22), 'dim', color)
718
736
  counts = children.total
719
737
  ? [
720
- paint(`${children.landed}/${children.total} landed`, 'green', color),
738
+ paint(mergedChildren(children.landed, children.total), 'green', color),
721
739
  ...(children.building ? [paint(`· ${children.building} building`, 'cyan', color)] : []),
722
740
  ...(children.queued ? [paint(`· ${children.queued} queued`, 'dim', color)] : []),
723
741
  ]
@@ -737,7 +755,7 @@ function detailBody(
737
755
  if (build.ticketId !== undefined) body.push(` ticket ${displayText(build.ticketId)}`)
738
756
  if (build.target && !build.integrationDetail)
739
757
  body.push(
740
- ` ${build.kind ?? treeVocabulary.work} · ${treeVocabulary.target} ${build.target}${build.integration ? ` · ${build.integration}` : ''}`,
758
+ ` ${build.kind ?? treeVocabulary.work} · ${treeVocabulary.target} ${build.target}${build.targetDistance ? ` ${build.targetDistance}` : ''}${build.integration ? ` · ${build.integration}` : ''}`,
741
759
  )
742
760
  if (
743
761
  !build.integrationDetail &&
@@ -773,7 +791,10 @@ function detailBody(
773
791
  body.push(...packLines(['Progress', progress.bar, ...progress.counts], width, ' '))
774
792
  field(handPushedLabel, handPushedText(detail.handPushedCommits))
775
793
  field('Branch', `${detail.branch} · restack ${detail.restack}`)
776
- if (detail.parentDistance) field('Parent', detail.parentDistance.replace(/^parent /, ''))
794
+ field(
795
+ 'Parent',
796
+ `${build.integrationRow.destination}${detail.parentDistance ? ` ${detail.parentDistance}` : ''}`,
797
+ )
777
798
  for (const path of detail.conflictFiles ?? []) field('Conflict', path)
778
799
  body.push(
779
800
  ...packLines(
@@ -786,7 +807,7 @@ function detailBody(
786
807
  body.push(
787
808
  '',
788
809
  paint(
789
- `Children ${open} open · ${detail.children.length - open} landed${detail.membershipKnown ? '' : ' · membership unknown'}`,
810
+ `Children ${open} open · ${detail.children.length - open} ${mergeVocabulary.merged}${detail.membershipKnown ? '' : ' · membership unknown'}`,
790
811
  'bold',
791
812
  color,
792
813
  ),
@@ -805,9 +826,10 @@ function detailBody(
805
826
  body.push('')
806
827
  field('Verification', detail.verification)
807
828
  for (const result of detail.verifySteps) field(result.step, result.outcome)
808
- field('Landing', detail.landing)
829
+ field(mergeVocabulary.title, detail.landing)
809
830
  }
810
- if (build.kind !== 'integration') body.push(` landing ${landingPolicyDisplay(build.landing)}`)
831
+ if (build.kind !== 'integration')
832
+ body.push(` ${mergeVocabulary.label} ${landingPolicyDisplay(build.landing)}`)
811
833
  const ceiling = reviewRoundCeilingText(build)
812
834
  if (ceiling !== undefined) body.push(` ${ceiling}`)
813
835
  if (build.pr !== undefined)
@@ -0,0 +1,14 @@
1
+ import type { BuildState } from '../../kernel/reducer'
2
+ import type { LeafRestackState } from '../../kernel/leaf-restack-state'
3
+
4
+ export function distanceSuffix(count: number | null | undefined, terminal?: string): string {
5
+ if (terminal === 'merged' || terminal === 'closed') return ''
6
+ if (count == null || !Number.isSafeInteger(count) || count < 0) return '+?'
7
+ return count === 0 ? '' : `+${count}`
8
+ }
9
+
10
+ export function workTargetDistance(state: BuildState, restack: LeafRestackState): string {
11
+ const sample = restack.distance
12
+ const valid = sample && sample.branch === state.baseBranch && sample.sha === restack.target?.sha
13
+ return distanceSuffix(valid ? sample.count : null, state.prState)
14
+ }
@@ -6,6 +6,7 @@ import {
6
6
  integrationCurrent,
7
7
  integrationCycleVerified,
8
8
  } from '../../kernel/integration-state'
9
+ import { mergeVocabulary } from './landing-display'
9
10
  import { awaitsConsent, landingReady } from '../../kernel/landing-readiness'
10
11
 
11
12
  export const treeVocabulary = {
@@ -13,7 +14,7 @@ export const treeVocabulary = {
13
14
  node: 'node',
14
15
  target: 'target',
15
16
  integration: 'integration build',
16
- landing: 'landing',
17
+ landing: mergeVocabulary.label,
17
18
  restack: 'restack',
18
19
  consent: 'consent',
19
20
  queue: 'queue',
@@ -25,7 +26,7 @@ export const treeVocabulary = {
25
26
  verification: 'verification',
26
27
  current: 'current',
27
28
  pending: 'pending',
28
- readyToLand: 'ready to land',
29
+ readyToLand: 'ready to merge',
29
30
  notReady: 'not ready',
30
31
  } as const
31
32
 
@@ -32,7 +32,7 @@ export function parseDispatchArgs(
32
32
  throw new Error(`--intake and --no-intake cannot be combined — ${usage}`)
33
33
  }
34
34
  if (sawAutoMerge || sawNoAutoMerge) {
35
- throw new Error(`Auto-merge flags are retired; configure [[landing]] policy — ${usage}`)
35
+ throw new Error(`Auto-merge flags are retired; configure [[merge]] policy — ${usage}`)
36
36
  }
37
37
 
38
38
  const interval = stringFlag(parsed, 'interval')
@@ -1,3 +1,4 @@
1
+ import { normalizeEffectiveConfigArtifact } from '../config/effective-artifact'
1
2
  import { migrationIdentity, ticketMigrationsReducer } from '../kernel/ticket-migrations'
2
3
  import type { DispatchUpgradeState } from '../kernel/dispatch-upgrade'
3
4
  import { releaseDispatchPresentation } from './dispatch-presentation-ownership'
@@ -297,7 +298,9 @@ export class DispatchFrontend {
297
298
  if (this.config !== undefined && this.configRef === key) return this.config
298
299
  const artifact = await this.reader.getRepoArtifact(this.opts.repo, kind, rev)
299
300
  if (artifact === null) throw new Error(`effective config ${key} is not retrievable`)
300
- const parsed = configSchema.parse(JSON.parse(new TextDecoder().decode(artifact.content)))
301
+ const parsed = configSchema.parse(
302
+ normalizeEffectiveConfigArtifact(JSON.parse(new TextDecoder().decode(artifact.content))),
303
+ )
301
304
  this.config = parsed
302
305
  this.configRef = key
303
306
  this.configRevision += 1
@@ -749,8 +752,8 @@ export class DispatchFrontend {
749
752
  : result.command === 'abort'
750
753
  ? `build ${slug}: abort requested`
751
754
  : result.command === 'land'
752
- ? `build ${slug}: landing consent requested`
753
- : `build ${slug}: landing hold requested`
755
+ ? `build ${slug}: merge consent requested`
756
+ : `build ${slug}: merge hold requested`
754
757
  await this.report(message)
755
758
  await this.renderOnce()
756
759
  }