@defrex/autobuild 0.13.0 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/README.md +5 -3
  2. package/SPEC.md +673 -99
  3. package/bin/ab-dispatch-kernel.ts +4 -6
  4. package/docs/architecture.md +322 -75
  5. package/docs/assets/headline-wide.png +0 -0
  6. package/docs/configuration.md +112 -12
  7. package/docs/hosted-service.md +20 -2
  8. package/docs/integration-tree.md +117 -0
  9. package/docs/landing-policy.md +150 -0
  10. package/docs/mcp.md +24 -0
  11. package/docs/migration-1.0.md +68 -0
  12. package/docs/operator-api.md +20 -9
  13. package/docs/remote-store-protocol.md +114 -9
  14. package/docs/remote-ticket-protocol.md +26 -5
  15. package/docs/restacking.md +79 -0
  16. package/docs/setup.md +49 -6
  17. package/docs/ticket-dependencies.md +69 -0
  18. package/docs/ticket-migration.md +8 -0
  19. package/package.json +4 -3
  20. package/packages/core/src/cli/attention.ts +40 -163
  21. package/packages/core/src/cli/build-control.ts +75 -55
  22. package/packages/core/src/cli/bulk-control.ts +3 -2
  23. package/packages/core/src/cli/context.ts +68 -78
  24. package/packages/core/src/cli/dashboard/actions.ts +6 -3
  25. package/packages/core/src/cli/dashboard/landing-display.ts +6 -0
  26. package/packages/core/src/cli/dashboard/live.ts +5 -0
  27. package/packages/core/src/cli/dashboard/model.ts +178 -40
  28. package/packages/core/src/cli/dashboard/poll.ts +15 -9
  29. package/packages/core/src/cli/dashboard/refresh.ts +176 -0
  30. package/packages/core/src/cli/dashboard/render.ts +78 -28
  31. package/packages/core/src/cli/dashboard/repository-poll.ts +57 -0
  32. package/packages/core/src/cli/dashboard/selection.ts +7 -1
  33. package/packages/core/src/cli/dashboard/tree.ts +107 -0
  34. package/packages/core/src/cli/dispatch-frontend.ts +173 -169
  35. package/packages/core/src/cli/dispatch-process.ts +14 -7
  36. package/packages/core/src/cli/dispatch-repository-feed.ts +196 -0
  37. package/packages/core/src/cli/dispatch.ts +397 -214
  38. package/packages/core/src/cli/dispatcher-liveness.ts +41 -21
  39. package/packages/core/src/cli/harvest.ts +71 -39
  40. package/packages/core/src/cli/help.ts +49 -32
  41. package/packages/core/src/cli/historical-build-state.ts +27 -0
  42. package/packages/core/src/cli/init-validation.ts +43 -2
  43. package/packages/core/src/cli/keyboard.ts +6 -0
  44. package/packages/core/src/cli/landings.ts +18 -0
  45. package/packages/core/src/cli/main.ts +52 -18
  46. package/packages/core/src/cli/mcp.ts +9 -0
  47. package/packages/core/src/cli/pr-attachments.ts +10 -13
  48. package/packages/core/src/cli/pr-summary-publication.ts +27 -60
  49. package/packages/core/src/cli/pr-summary.ts +43 -13
  50. package/packages/core/src/cli/publication-settlement.ts +177 -21
  51. package/packages/core/src/cli/repository-status.ts +49 -2
  52. package/packages/core/src/cli/status.ts +133 -36
  53. package/packages/core/src/cli/terminal-restore.ts +54 -0
  54. package/packages/core/src/cli/terminal.ts +16 -2
  55. package/packages/core/src/cli/terminals.ts +121 -219
  56. package/packages/core/src/cli/ticket-editor.ts +10 -3
  57. package/packages/core/src/cli/ticket.ts +115 -20
  58. package/packages/core/src/cli/upgrade-commit.ts +4 -0
  59. package/packages/core/src/cli/upgrade-compatibility.ts +2 -2
  60. package/packages/core/src/cli/upgrade-landing.ts +69 -0
  61. package/packages/core/src/cli/upgrade.ts +16 -0
  62. package/packages/core/src/cli/wait.ts +194 -91
  63. package/packages/core/src/cli/watch.ts +111 -109
  64. package/packages/core/src/config/landing.ts +22 -0
  65. package/packages/core/src/config/live.ts +1 -0
  66. package/packages/core/src/config/pipeline-source.ts +4 -3
  67. package/packages/core/src/config/schema.ts +3 -0
  68. package/packages/core/src/events/catalog.ts +48 -3
  69. package/packages/core/src/events/payloads.ts +295 -6
  70. package/packages/core/src/events/repository.ts +38 -3
  71. package/packages/core/src/integration/harness.ts +11 -2
  72. package/packages/core/src/kernel/__snapshots__/reducer-registry.test.ts.snap +3330 -119
  73. package/packages/core/src/kernel/auto-merge-default.ts +1 -0
  74. package/packages/core/src/kernel/auto-merge.ts +29 -4
  75. package/packages/core/src/kernel/build-identity.ts +94 -0
  76. package/packages/core/src/kernel/change-presence.ts +179 -0
  77. package/packages/core/src/kernel/dispatch-status.ts +17 -1
  78. package/packages/core/src/kernel/dispatcher-liveness.ts +10 -4
  79. package/packages/core/src/kernel/engine.ts +89 -2
  80. package/packages/core/src/kernel/generators/build-log.ts +23 -0
  81. package/packages/core/src/kernel/generators/leaf-restack-log.ts +110 -0
  82. package/packages/core/src/kernel/generators/node-restack-log.ts +94 -0
  83. package/packages/core/src/kernel/generators/repository-journals.ts +25 -3
  84. package/packages/core/src/kernel/harvest.ts +25 -23
  85. package/packages/core/src/kernel/integration-completeness.ts +81 -0
  86. package/packages/core/src/kernel/integration-landing.ts +263 -0
  87. package/packages/core/src/kernel/integration-stack.ts +36 -0
  88. package/packages/core/src/kernel/integration-state.ts +135 -0
  89. package/packages/core/src/kernel/landing-policy.ts +47 -0
  90. package/packages/core/src/kernel/landing-publication.ts +41 -0
  91. package/packages/core/src/kernel/landing-readiness.ts +67 -0
  92. package/packages/core/src/kernel/landing-state.ts +96 -0
  93. package/packages/core/src/kernel/leaf-restack-completion.ts +24 -0
  94. package/packages/core/src/kernel/leaf-restack-state.ts +73 -0
  95. package/packages/core/src/kernel/log-index-value.ts +38 -0
  96. package/packages/core/src/kernel/log-index.ts +35 -5
  97. package/packages/core/src/kernel/node-landing.ts +439 -0
  98. package/packages/core/src/kernel/node-parent.ts +184 -0
  99. package/packages/core/src/kernel/node-restack-state.ts +191 -0
  100. package/packages/core/src/kernel/node-restack-transaction.ts +210 -0
  101. package/packages/core/src/kernel/node-restack.ts +274 -0
  102. package/packages/core/src/kernel/read-facts.ts +704 -0
  103. package/packages/core/src/kernel/reconcile-head.ts +51 -0
  104. package/packages/core/src/kernel/reconcile-restack.ts +560 -0
  105. package/packages/core/src/kernel/reducer-registry.ts +153 -3
  106. package/packages/core/src/kernel/reducer.ts +121 -6
  107. package/packages/core/src/kernel/repository-attention.ts +179 -0
  108. package/packages/core/src/kernel/service-facts.ts +135 -0
  109. package/packages/core/src/kernel/snapshot-parent.ts +33 -0
  110. package/packages/core/src/kernel/terminal-guard.ts +133 -0
  111. package/packages/core/src/ontology.ts +9 -1
  112. package/packages/core/src/operator/annotations.ts +12 -0
  113. package/packages/core/src/operator/control.ts +11 -6
  114. package/packages/core/src/operator/index.ts +6 -0
  115. package/packages/core/src/operator/landings.ts +35 -0
  116. package/packages/core/src/operator/presentation.ts +1 -0
  117. package/packages/core/src/operator/protocol.ts +12 -3
  118. package/packages/core/src/operator/query.ts +40 -21
  119. package/packages/core/src/operator/read-view.ts +4 -13
  120. package/packages/core/src/operator/registry.ts +48 -19
  121. package/packages/core/src/operator/requests.ts +3 -22
  122. package/packages/core/src/operator/sandbox.ts +10 -9
  123. package/packages/core/src/operator/tickets.ts +57 -11
  124. package/packages/core/src/plugin-sdk/index.ts +13 -0
  125. package/packages/core/src/ports/forge/contract.ts +91 -3
  126. package/packages/core/src/ports/forge/fake.ts +142 -4
  127. package/packages/core/src/ports/forge/git-rewrite.ts +232 -0
  128. package/packages/core/src/ports/forge/github-readiness.ts +421 -0
  129. package/packages/core/src/ports/forge/github.ts +631 -35
  130. package/packages/core/src/ports/forge/local-git.ts +119 -5
  131. package/packages/core/src/ports/forge/readiness.ts +99 -0
  132. package/packages/core/src/ports/tickets/contract.ts +41 -0
  133. package/packages/core/src/ports/tickets/create.ts +8 -1
  134. package/packages/core/src/ports/tickets/fake.ts +32 -1
  135. package/packages/core/src/ports/tickets/file-codec.ts +7 -0
  136. package/packages/core/src/ports/tickets/file.ts +18 -1
  137. package/packages/core/src/ports/tickets/hosted-index.ts +2 -0
  138. package/packages/core/src/ports/tickets/linear.ts +124 -4
  139. package/packages/core/src/ports/tickets/migration.ts +25 -1
  140. package/packages/core/src/ports/tickets/operations.ts +7 -2
  141. package/packages/core/src/ports/tickets/remote-protocol.ts +19 -0
  142. package/packages/core/src/ports/tickets/remote.ts +10 -1
  143. package/packages/core/src/ports/tickets/revision.ts +3 -1
  144. package/packages/core/src/ports/tickets/tree.ts +148 -0
  145. package/packages/core/src/ports/tickets/update.ts +15 -2
  146. package/packages/core/src/ports/types.ts +135 -5
  147. package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
  148. package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -1
  149. package/packages/core/src/ports/workspace/vercel-sandbox.ts +60 -3
  150. package/packages/core/src/processes/build-child.ts +6 -6
  151. package/packages/core/src/processes/build-runner.ts +586 -87
  152. package/packages/core/src/processes/dispatch-failure-budget.ts +5 -4
  153. package/packages/core/src/processes/dispatcher-selectors.ts +15 -9
  154. package/packages/core/src/processes/dispatcher.ts +2239 -357
  155. package/packages/core/src/processes/execution-no-progress.ts +46 -1
  156. package/packages/core/src/processes/harvest-execution-state.ts +15 -9
  157. package/packages/core/src/processes/harvest-runner.ts +34 -70
  158. package/packages/core/src/processes/harvest.ts +38 -15
  159. package/packages/core/src/processes/infrastructure-failure-budget.ts +13 -15
  160. package/packages/core/src/processes/orchestrator-tick.ts +2 -2
  161. package/packages/core/src/processes/publication-loss.ts +35 -21
  162. package/packages/core/src/processes/publication-state.ts +30 -5
  163. package/packages/core/src/processes/repo-view.ts +244 -1130
  164. package/packages/core/src/processes/tick-publication.ts +110 -0
  165. package/packages/core/src/store/adapter.ts +23 -0
  166. package/packages/core/src/store/build-scope.ts +35 -0
  167. package/packages/core/src/store/contract.ts +909 -0
  168. package/packages/core/src/store/digest.ts +52 -4
  169. package/packages/core/src/store/local/schema.ts +26 -13
  170. package/packages/core/src/store/local/store.ts +296 -55
  171. package/packages/core/src/store/memory.ts +181 -30
  172. package/packages/core/src/store/phase-session.ts +34 -0
  173. package/packages/core/src/store/reduced-reads.ts +240 -0
  174. package/packages/core/src/store/reducer-value-shapes.json +18323 -0
  175. package/packages/core/src/store/reducer-value-validation.ts +96 -0
  176. package/packages/core/src/store/reducer-values.ts +145 -0
  177. package/packages/core/src/store/remote/client.ts +85 -0
  178. package/packages/core/src/store/remote/compatibility.ts +21 -9
  179. package/packages/core/src/store/remote/index.ts +19 -0
  180. package/packages/core/src/store/remote/protocol.ts +27 -0
  181. package/packages/core/src/store/remote/version.ts +3 -1
  182. package/packages/core/src/store/repo-state-events.ts +3 -1
  183. package/packages/core/src/store/repo-tick.ts +72 -0
  184. package/packages/core/src/store/session-handle.ts +34 -0
  185. package/packages/core/src/store/snapshots.ts +10 -0
  186. package/packages/core/src/store/subscribe.ts +1 -1
  187. package/packages/core/src/store/ticket-assets.ts +4 -4
  188. package/packages/core/src/store/types.ts +71 -6
  189. package/packages/core/src/testing/dispatch-read-budget.ts +215 -0
  190. package/packages/core/src/testing/index.ts +10 -0
  191. package/packages/core/src/testing/reduced-read-budget.ts +502 -0
  192. package/packages/core/src/testing/refresh-scheduler.ts +32 -0
  193. package/skills/guide/SKILL.md +116 -62
  194. package/skills/guide/references/integration-tree.md +117 -0
  195. package/skills/guide/references/landing-policy.md +150 -0
  196. package/skills/guide/references/migration-1.0.md +68 -0
  197. package/skills/guide/references/operator-api.md +13 -6
  198. package/skills/guide/references/plugin-authoring.md +34 -0
  199. package/skills/guide/references/remote-store-protocol.md +114 -9
  200. package/skills/guide/references/remote-ticket-protocol.md +26 -5
  201. package/skills/guide/references/restacking.md +79 -0
  202. package/skills/guide/references/setup.md +49 -6
  203. package/skills/guide/references/ticket-dependencies.md +69 -0
  204. package/skills/guide/references/ticket-migration.md +8 -0
  205. package/skills/operate/SKILL.md +55 -5
  206. package/skills/reconcile/SKILL.md +55 -48
  207. package/skills/spec/SKILL.md +67 -1
  208. package/skills/tickets/SKILL.md +55 -2
  209. package/templates/autobuild.toml +3 -0
  210. package/templates/hosted-service/package.json +2 -2
@@ -18,7 +18,7 @@ import { projectBuild, type DashboardBuild } from './model'
18
18
  * metadata decorates each row with its pinned pipeline source and revision
19
19
  * (SPEC §16.1). */
20
20
  export interface DashboardBuildReader {
21
- listBuilds(): Promise<BuildRecord[]>
21
+ listBuildsForRepo(repo: string): Promise<BuildRecord[]>
22
22
  getEvents(slug: string, sinceSeq?: number): Promise<AbEvent[]>
23
23
  listStreams?(scope: StreamScope): Promise<StreamRecord[]>
24
24
  getArtifact?(slug: string, kind: string): Promise<Artifact | null>
@@ -81,7 +81,7 @@ function validateDelta(slug: string, sinceSeq: number, events: AbEvent[]): void
81
81
  /**
82
82
  * Process-local, display-only acceleration for the interactive dispatch frame.
83
83
  *
84
- * Every refresh still discovers records with `listBuilds()`. A first-seen
84
+ * Every refresh still discovers records with `listBuildsForRepo(repo)`. A first-seen
85
85
  * stream is hydrated from seq 0; a cached dashboard-visible stream is read only
86
86
  * after its reduced `lastSeq`. Empty deltas preserve the exact reduction and
87
87
  * projected row, so phase timing is not recomputed. Only fully completed
@@ -180,8 +180,11 @@ export class DashboardBuildPollCache {
180
180
  refresh(
181
181
  config: Config = this.config,
182
182
  configRevision = this.configRevision,
183
+ fullEnrichment = false,
183
184
  ): Promise<DashboardPollSnapshot> {
184
- const result = this.refreshTail.then(() => this.refreshNow(config, configRevision))
185
+ const result = this.refreshTail.then(() =>
186
+ this.refreshNow(config, configRevision, fullEnrichment),
187
+ )
185
188
  this.refreshTail = result.then(
186
189
  () => undefined,
187
190
  () => undefined,
@@ -189,9 +192,13 @@ export class DashboardBuildPollCache {
189
192
  return result
190
193
  }
191
194
 
192
- private async refreshNow(config: Config, configRevision: number): Promise<DashboardPollSnapshot> {
195
+ private async refreshNow(
196
+ config: Config,
197
+ configRevision: number,
198
+ fullEnrichment: boolean,
199
+ ): Promise<DashboardPollSnapshot> {
193
200
  const configChanged = configRevision !== this.configRevision || config !== this.config
194
- const records = (await this.reader.listBuilds()).filter((record) => record.repo === this.repo)
201
+ const records = await this.reader.listBuildsForRepo(this.repo)
195
202
  const next = new Map<string, PollEntry>()
196
203
 
197
204
  for (const record of records) {
@@ -206,12 +213,11 @@ export class DashboardBuildPollCache {
206
213
  validateDelta(record.slug, sinceSeq, delta)
207
214
 
208
215
  if (current !== undefined && delta.length === 0) {
209
- // Dashboard rows derive from event streams and effective config only.
210
- // Heartbeat and lease renewals are mutable record facts, so they leave
211
- // both the cached reduction and projected row untouched.
216
+ // Preserve the reduction on empty deltas. Bounded full refreshes also
217
+ // reload mutable record, stream and artifact enrichment.
212
218
  next.set(
213
219
  record.slug,
214
- configChanged || current.build?.ticketId !== record.ticket?.id
220
+ fullEnrichment || configChanged || current.build?.ticketId !== record.ticket?.id
215
221
  ? {
216
222
  ...current,
217
223
  build: await this.projectRow(record, current.state, current.events, config),
@@ -0,0 +1,176 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks'
2
+
3
+ const readIntent = new AsyncLocalStorage<boolean>()
4
+
5
+ /** Reads needed by an explicitly requested action may finish while unfocused. */
6
+ export function interactionRead<T>(operation: () => T): T {
7
+ return readIntent.run(true, operation)
8
+ }
9
+
10
+ /** Presentation-only read scheduling. Kernel timers never use this controller. */
11
+ export interface RefreshScheduler {
12
+ now(): number
13
+ set(callback: () => void, delay: number): unknown
14
+ clear(handle: unknown): void
15
+ }
16
+ const scheduler: RefreshScheduler = {
17
+ now: Date.now,
18
+ set: (callback, delay) => {
19
+ const timer = setTimeout(callback, delay)
20
+ timer.unref?.()
21
+ return timer
22
+ },
23
+ clear: (handle) => clearTimeout(handle as ReturnType<typeof setTimeout>),
24
+ }
25
+
26
+ export class DashboardRefresh {
27
+ private focused = true
28
+ private active = true
29
+ private suspended = false
30
+ private live = true // Unknown startup activity retries quickly.
31
+ private deadline = -Infinity
32
+ private started = -Infinity
33
+ private timer: unknown
34
+ private flight: Promise<void> | undefined
35
+ private generation = 0
36
+ private permit: number | undefined
37
+ private wake = false
38
+
39
+ constructor(
40
+ private readonly refresh: () => Promise<void>,
41
+ private readonly time: RefreshScheduler = scheduler,
42
+ ) {}
43
+
44
+ get painting(): boolean {
45
+ return !this.suspended
46
+ }
47
+
48
+ get isFocused(): boolean {
49
+ return this.focused && !this.suspended
50
+ }
51
+
52
+ get admitted(): boolean {
53
+ return this.active && !this.suspended && (this.focused || this.permit === this.generation)
54
+ }
55
+
56
+ activity(live: boolean): void {
57
+ this.live = live
58
+ }
59
+
60
+ focus(focused: boolean): void {
61
+ this.focused = focused
62
+ this.generation += 1
63
+ this.cancel()
64
+ if (focused) void this.request()
65
+ }
66
+
67
+ interaction(): void {
68
+ this.deadline = this.time.now() + 30_000
69
+ void this.request(true)
70
+ }
71
+
72
+ suspend(): void {
73
+ this.suspended = true
74
+ this.generation += 1
75
+ this.cancel()
76
+ }
77
+
78
+ resume(): void {
79
+ this.suspended = false
80
+ this.focus(true)
81
+ }
82
+
83
+ stop(): void {
84
+ this.active = false
85
+ this.generation += 1
86
+ this.cancel()
87
+ }
88
+
89
+ async join(): Promise<void> {
90
+ await this.flight
91
+ }
92
+
93
+ /** One final focused snapshot, after input and scheduled polling are closed. */
94
+ async finalRefresh(): Promise<void> {
95
+ await this.join()
96
+ if (!this.focused || this.suspended) return
97
+ this.active = true
98
+ try {
99
+ await this.request()
100
+ } finally {
101
+ this.stop()
102
+ }
103
+ }
104
+
105
+ request(interaction = false): Promise<void> {
106
+ if (!this.active || this.suspended || (!this.focused && !interaction)) return Promise.resolve()
107
+ if (this.flight !== undefined) {
108
+ // A focus round trip invalidates an outstanding read. Refresh again after
109
+ // it settles, rather than losing the focus-in wakeup.
110
+ if (this.permit !== this.generation) this.wake = true
111
+ return this.flight
112
+ }
113
+ this.cancel()
114
+ this.wake = false
115
+ this.started = this.time.now()
116
+ this.permit = this.generation
117
+ const current = Promise.resolve()
118
+ .then(() => readIntent.run(false, this.refresh))
119
+ .catch(() => {})
120
+ .finally(() => {
121
+ if (this.flight !== current) return
122
+ this.flight = undefined
123
+ this.permit = undefined
124
+ if (this.wake && this.active && !this.suspended && this.focused) {
125
+ this.wake = false
126
+ void this.request()
127
+ } else this.schedule()
128
+ })
129
+ this.flight = current
130
+ return current
131
+ }
132
+
133
+ private cancel(): void {
134
+ if (this.timer !== undefined) this.time.clear(this.timer)
135
+ this.timer = undefined
136
+ }
137
+
138
+ /** Current admission cadence, also used to bound presentation staleness. */
139
+ get intervalMs(): number {
140
+ return this.live || this.time.now() < this.deadline ? 500 : 5000
141
+ }
142
+
143
+ private schedule(): void {
144
+ if (!this.active || this.suspended || !this.focused) return
145
+ const interval = this.intervalMs
146
+ // Slow/failing requests do not spin when their start deadline is overdue.
147
+ const remaining = this.started + interval - this.time.now()
148
+ const delay = remaining > 0 ? remaining : 50
149
+ this.timer = this.time.set(() => {
150
+ this.timer = undefined
151
+ void this.request()
152
+ }, delay)
153
+ }
154
+ }
155
+
156
+ /** Guard each asynchronous read stage, including reads inside shared caches.
157
+ * Operator mutations keep their original store; only presentation readers use
158
+ * this facade. A focus loss cannot recall I/O already dispatched. */
159
+ export function presentationReader<T extends object>(store: T, admitted: () => boolean): T {
160
+ return new Proxy(store, {
161
+ get(target, key, receiver) {
162
+ const value = Reflect.get(target, key, receiver)
163
+ if (typeof value !== 'function') return value
164
+ return (...args: unknown[]) => {
165
+ if (
166
+ /^(get|list|read|load)/u.test(String(key)) &&
167
+ !admitted() &&
168
+ readIntent.getStore() !== true
169
+ ) {
170
+ return Promise.reject(new Error('dashboard presentation read paused'))
171
+ }
172
+ return Reflect.apply(value, target, args)
173
+ }
174
+ },
175
+ })
176
+ }
@@ -1,3 +1,4 @@
1
+ import { treeVocabulary, consentQueue } from './tree'
1
2
  /**
2
3
  * The dashboard's other pure half: model → `string[]`. No terminal, no state,
3
4
  * no I/O — `live.ts` owns the writer, this owns the pixels.
@@ -27,6 +28,7 @@ import type {
27
28
  DashboardSelection,
28
29
  PipelineStep,
29
30
  } from './model'
31
+ import { landingPolicyDisplay } from './landing-display'
30
32
  import { dashboardBuildControl } from './actions'
31
33
  import type { DashboardSession } from './detail'
32
34
  import type { TranscriptPresentation, TranscriptTurn } from './transcript'
@@ -261,6 +263,7 @@ function renderStep(step: PipelineStep, color: boolean, now: number): string {
261
263
  const STATUS_COLOR: Record<DashboardBuild['status'] | DashboardHarvest['status'], ColorName> = {
262
264
  queued: 'cyan',
263
265
  running: 'green',
266
+ collecting: 'cyan',
264
267
  pausing: 'yellow',
265
268
  paused: 'yellow',
266
269
  resuming: 'cyan',
@@ -308,7 +311,6 @@ function renderBuild(
308
311
  widths: Widths,
309
312
  selected: boolean,
310
313
  selecting: boolean,
311
- defaultAutoMerge: boolean,
312
314
  ): string[] {
313
315
  const { color, width, now } = opts
314
316
 
@@ -332,9 +334,8 @@ function renderBuild(
332
334
  // the frame's right edge (AC 3, AC 5).
333
335
  const rightTokens: string[] = []
334
336
  // The state is ALWAYS drawn — including `off` — so consent is never conveyed
335
- // by the absence of a token alone. `off` turns red while the repository
336
- // default reads ON: the default-on/build-off mismatch an operator must see
337
- // without opening the detail view.
337
+ // by the absence of a token alone. Legacy repository defaults have no
338
+ // effect on a landing or its presentation.
338
339
  {
339
340
  const autoColor: ColorName =
340
341
  build.autoMerge === 'enabled'
@@ -343,10 +344,15 @@ function renderBuild(
343
344
  ? 'cyan'
344
345
  : build.autoMerge === 'cancelling'
345
346
  ? 'yellow'
346
- : defaultAutoMerge
347
- ? 'red'
348
- : 'dim'
349
- rightTokens.push(paint(`auto merge ${build.autoMerge}`, autoColor, color))
347
+ : 'dim'
348
+ if (build.kind !== 'integration')
349
+ rightTokens.push(
350
+ paint(
351
+ `landing ${build.landing?.command?.kind === 'hold' ? 'held' : build.landing?.decision?.mode === 'consent' && build.landing.command?.kind !== 'land' ? 'awaiting consent' : build.autoMerge}`,
352
+ autoColor,
353
+ color,
354
+ ),
355
+ )
350
356
  }
351
357
  if (build.pr !== undefined) rightTokens.push(link(build.pr.url, `PR ${build.pr.state}`, color))
352
358
  // A repository hold changes no build lifecycle state. Keep QUEUED literal
@@ -365,6 +371,26 @@ function renderBuild(
365
371
  // The slug is the sole flexible segment; narrow frames truncate it before
366
372
  // the right-pinned lifecycle status.
367
373
  const lines = [rightPinnedLine(leftPrefix, paint(build.slug, 'bold', color), rightStr, width)]
374
+ if (build.target)
375
+ lines.push(
376
+ truncate(
377
+ ` ${build.kind ?? treeVocabulary.work} · ${treeVocabulary.target} ${build.target}${build.integration ? ` · ${build.integration}` : ''}`,
378
+ width,
379
+ ),
380
+ )
381
+ if (build.tree && (build.kind === 'integration' || build.tree.consent)) {
382
+ const tree = build.tree
383
+ for (const text of [
384
+ `${tree.branch ?? 'unknown branch'} · ${treeVocabulary.restack} ${tree.restack} · ${treeVocabulary.verify} ${tree.verification.current ? treeVocabulary.current : treeVocabulary.pending} · ${tree.reason ?? (tree.ready ? treeVocabulary.readyToLand : treeVocabulary.notReady)}`,
385
+ ...(tree.kind === 'node'
386
+ ? [
387
+ `${treeVocabulary.children} ${tree.children?.length ?? 'unknown'} · ${tree.completeness}${tree.diagnostics?.length ? ` · ${tree.diagnostics.join('; ')}` : ''}`,
388
+ ]
389
+ : []),
390
+ ])
391
+ for (const line of wrappedText(text, width - 4, ''))
392
+ lines.push(truncate(` ${line}`, width))
393
+ }
368
394
  const ceiling = reviewRoundCeilingText(build)
369
395
  if (ceiling !== undefined) lines.push(truncate(` ${ceiling}`, width))
370
396
 
@@ -462,13 +488,13 @@ function frameWidths(builds: DashboardBuild[], harvest: DashboardHarvest | undef
462
488
  // ── The frame ────────────────────────────────────────────────────────────────
463
489
 
464
490
  export const DASHBOARD_GLOBAL_LEGEND =
465
- 'Keys: Up/Down select h harvest m auto-merge i intake p pause all r resume all Ctrl-C quit'
491
+ 'Keys: Up/Down select h harvest l land o hold i intake p pause all r resume all Ctrl-C quit'
466
492
  export const DASHBOARD_HARVEST_LEGEND = 'Keys: Up/Down select Ctrl-C quit'
467
493
  export const DASHBOARD_HARVEST_RESUME_LEGEND = 'Keys: Up/Down select p resume Ctrl-C quit'
468
494
  export const DASHBOARD_HARVEST_ACKNOWLEDGE_LEGEND =
469
495
  'Keys: Up/Down select p acknowledge Ctrl-C quit'
470
496
  export const DASHBOARD_BUILD_LEGEND =
471
- 'Keys: Up/Down select Enter details m auto-merge p pause a abort Ctrl-C quit'
497
+ 'Keys: Up/Down select Enter details l land o hold p pause a abort Ctrl-C quit'
472
498
  export const DASHBOARD_QUEUED_BUILD_LEGEND =
473
499
  'Keys: Up/Down select Enter details d discard a abort Ctrl-C quit'
474
500
  /** The session view offers ONLY scrolling, back, and quit — it is read-only,
@@ -492,8 +518,8 @@ function buildLegend(build: DashboardBuild, detail: boolean): string {
492
518
  const control = dashboardBuildControl(build.status)
493
519
  const action = control === undefined ? '' : ` ${control.key} ${control.label}`
494
520
  return detail
495
- ? `Keys: Up/Down scroll Left/Right select session Enter transcript m auto-merge${action} a abort Esc back Ctrl-C quit`
496
- : `Keys: Up/Down select Enter details m auto-merge${action} a abort Ctrl-C quit`
521
+ ? `Keys: Up/Down scroll Left/Right select session Enter transcript l land o hold${action} a abort Esc back Ctrl-C quit`
522
+ : `Keys: Up/Down select Enter details l land o hold${action} a abort Ctrl-C quit`
497
523
  }
498
524
 
499
525
  const MESSAGE_PREVIEW_ROWS = 3
@@ -649,7 +675,32 @@ function detailBody(
649
675
  const { color, width } = opts
650
676
  const body: string[] = []
651
677
  if (build.ticketId !== undefined) body.push(` ticket ${displayText(build.ticketId)}`)
652
- body.push(` auto merge ${build.autoMerge}`)
678
+ if (build.target)
679
+ body.push(
680
+ ` ${build.kind ?? treeVocabulary.work} · ${treeVocabulary.target} ${build.target}${build.integration ? ` · ${build.integration}` : ''}`,
681
+ )
682
+ if (build.tree && (build.kind === 'integration' || build.tree.consent)) {
683
+ const tree = build.tree
684
+ body.push(
685
+ ` ${treeVocabulary.branch} ${tree.branch ?? 'unknown'} · ${treeVocabulary.restack} ${tree.restack}`,
686
+ )
687
+ body.push(
688
+ ` ${treeVocabulary.verification} ${tree.verification.current ? treeVocabulary.current : treeVocabulary.pending} · ${tree.verification.head ?? 'unknown head'} onto ${tree.verification.parent ?? 'unknown parent'}`,
689
+ )
690
+ for (const result of tree.verification.results)
691
+ body.push(` ${result.step}: ${result.outcome}`)
692
+ if (tree.kind === 'node') {
693
+ body.push(
694
+ ` ${treeVocabulary.children} ${tree.children?.length ?? 'unknown'} · ${tree.completeness}`,
695
+ )
696
+ for (const child of tree.children ?? []) body.push(` ${JSON.stringify(child)}`)
697
+ for (const diagnostic of tree.diagnostics ?? []) body.push(` ${diagnostic}`)
698
+ }
699
+ body.push(
700
+ ` ${treeVocabulary.landing} ${tree.reason ?? (tree.ready ? treeVocabulary.readyToLand : treeVocabulary.notReady)}`,
701
+ )
702
+ }
703
+ if (build.kind !== 'integration') body.push(` landing ${landingPolicyDisplay(build.landing)}`)
653
704
  const ceiling = reviewRoundCeilingText(build)
654
705
  if (ceiling !== undefined) body.push(` ${ceiling}`)
655
706
  if (build.pr !== undefined)
@@ -1402,11 +1453,6 @@ function renderDashboardContent(model: DashboardModel, opts: RenderOpts): string
1402
1453
  const intake = model.drained
1403
1454
  ? paint('intake OFF', 'yellow', color)
1404
1455
  : paint('intake ON', 'green', color)
1405
- // "default" is implicit at the top level — the header is repo-wide state,
1406
- // while a build row's own `auto merge` token is that build's setting.
1407
- const autoMergeDefault = model.defaultAutoMerge
1408
- ? paint('auto merge ON', 'green', color)
1409
- : paint('auto merge OFF', 'yellow', color)
1410
1456
  const harvestGate = model.harvestPaused
1411
1457
  ? paint('harvest OFF', 'yellow', color)
1412
1458
  : paint('harvest ON', 'green', color)
@@ -1430,7 +1476,7 @@ function renderDashboardContent(model: DashboardModel, opts: RenderOpts): string
1430
1476
  // marker prefix aligns the first toggle with the title while keeping the
1431
1477
  // selection lane empty.
1432
1478
  const toggles = truncate(
1433
- ` ${[intake, autoMergeDefault, harvestGate, repositoryPause]
1479
+ ` ${[intake, harvestGate, repositoryPause]
1434
1480
  .filter((token): token is string => token !== undefined)
1435
1481
  .join(' ')}`,
1436
1482
  width,
@@ -1500,15 +1546,19 @@ function renderDashboardContent(model: DashboardModel, opts: RenderOpts): string
1500
1546
  return [
1501
1547
  {
1502
1548
  selection,
1503
- lines: renderBuild(
1504
- build,
1505
- model.repositoryPaused,
1506
- opts,
1507
- widths,
1508
- sameSelection(selection, model.selection),
1509
- selecting,
1510
- model.defaultAutoMerge,
1511
- ),
1549
+ lines: [
1550
+ ...(consentQueue(model.builds)[0]?.slug === build.slug
1551
+ ? [paint(` ${treeVocabulary.consent} ${treeVocabulary.queue}`, 'dim', color)]
1552
+ : []),
1553
+ ...renderBuild(
1554
+ build,
1555
+ model.repositoryPaused,
1556
+ opts,
1557
+ widths,
1558
+ sameSelection(selection, model.selection),
1559
+ selecting,
1560
+ ),
1561
+ ],
1512
1562
  },
1513
1563
  ]
1514
1564
  },
@@ -0,0 +1,57 @@
1
+ /** Display-only repository snapshot gate. Sample before reads, publish only
2
+ * after a complete admitted read, and serialize action/timer refreshes. */
3
+ export class RepositoryPollCache<T> {
4
+ private tail: Promise<void> = Promise.resolve()
5
+ private cached: { value: T; position: string; revision: number; enrichedAt: number } | undefined
6
+
7
+ refresh(options: {
8
+ position: () => Promise<string>
9
+ now: () => number
10
+ revision: number
11
+ enabled: boolean
12
+ admitted: () => boolean
13
+ valid?: (value: T) => boolean
14
+ /** The scheduler's current cadence, for refreshing before the next poll
15
+ * would overshoot the enrichment deadline. This does not change cadence. */
16
+ nextPollMs?: number
17
+ read: (options: { fullEnrichment: boolean }) => Promise<T | undefined>
18
+ }): Promise<T | undefined> {
19
+ const result = this.tail.then(async () => {
20
+ if (!options.admitted()) return undefined
21
+ const startedAt = options.now()
22
+ const position = options.enabled ? await options.position() : ''
23
+ if (!options.admitted()) return undefined
24
+ const cached = this.cached
25
+ const deadline = (cached?.enrichedAt ?? startedAt) + 10_000
26
+ const fullEnrichment =
27
+ options.enabled &&
28
+ cached !== undefined &&
29
+ (startedAt >= deadline || startedAt + (options.nextPollMs ?? 0) > deadline)
30
+ if (
31
+ options.enabled &&
32
+ cached &&
33
+ (options.valid?.(cached.value) ?? true) &&
34
+ cached.position === position &&
35
+ cached.revision === options.revision &&
36
+ !fullEnrichment
37
+ ) {
38
+ return cached.value
39
+ }
40
+ const value = await options.read({ fullEnrichment })
41
+ if (value === undefined || !options.admitted()) return undefined
42
+ this.cached = {
43
+ value,
44
+ position,
45
+ revision: options.revision,
46
+ // Position-driven reads must not postpone independent enrichment.
47
+ enrichedAt: cached === undefined || fullEnrichment ? startedAt : cached.enrichedAt,
48
+ }
49
+ return value
50
+ })
51
+ this.tail = result.then(
52
+ () => undefined,
53
+ () => undefined,
54
+ )
55
+ return result
56
+ }
57
+ }
@@ -1,3 +1,4 @@
1
+ import { consentQueue } from './tree'
1
2
  /** Pure stable-identity selection for every selectable dashboard row. */
2
3
  import type { DashboardModel, DashboardSelection } from './model'
3
4
 
@@ -6,10 +7,15 @@ import type { DashboardModel, DashboardSelection } from './model'
6
7
  export function dashboardSelections(
7
8
  model: Pick<DashboardModel, 'harvest' | 'builds'>,
8
9
  ): DashboardSelection[] {
10
+ const queue = consentQueue(model.builds)
11
+ const queued = new Set(queue.map((entry) => entry.slug))
9
12
  return [
10
13
  { kind: 'global' },
11
14
  ...(model.harvest !== undefined ? [{ kind: 'harvest' } as const] : []),
12
- ...model.builds.map((build) => ({ kind: 'build' as const, slug: build.slug })),
15
+ ...[...queue, ...model.builds.filter((build) => !queued.has(build.slug))].map((build) => ({
16
+ kind: 'build' as const,
17
+ slug: build.slug,
18
+ })),
13
19
  ]
14
20
  }
15
21
 
@@ -0,0 +1,107 @@
1
+ import type { BuildRecord } from '../../store/types'
2
+ import type { BuildState } from '../../kernel/reducer'
3
+ import type { LeafRestackState } from '../../kernel/leaf-restack-state'
4
+ import {
5
+ integrationComplete,
6
+ integrationCurrent,
7
+ integrationCycleVerified,
8
+ } from '../../kernel/integration-state'
9
+ import { awaitsConsent, landingReady } from '../../kernel/landing-readiness'
10
+
11
+ export const treeVocabulary = {
12
+ root: 'root',
13
+ node: 'node',
14
+ target: 'target',
15
+ integration: 'integration build',
16
+ landing: 'landing',
17
+ restack: 'restack',
18
+ consent: 'consent',
19
+ queue: 'queue',
20
+ work: 'work',
21
+ integrationKind: 'integration',
22
+ branch: 'branch',
23
+ children: 'children',
24
+ verify: 'verify',
25
+ verification: 'verification',
26
+ current: 'current',
27
+ pending: 'pending',
28
+ readyToLand: 'ready to land',
29
+ notReady: 'not ready',
30
+ } as const
31
+
32
+ /** Frozen effective ancestry shared by queue entries and readiness observations. */
33
+ export function effectiveTreeTarget(state: Pick<BuildState, 'target' | 'baseBranch'>) {
34
+ return {
35
+ kind: state.target ? ('node' as const) : ('root' as const),
36
+ branch: state.baseBranch,
37
+ ...(state.target ? { ticket: state.target.ticket, build: state.target.build } : {}),
38
+ }
39
+ }
40
+
41
+ export function projectTree(
42
+ record: BuildRecord,
43
+ state: BuildState,
44
+ restack: LeafRestackState,
45
+ expectedSteps?: readonly string[],
46
+ ) {
47
+ const cycle = state.integration?.cycle
48
+ const candidate = state.landing?.decision?.candidate
49
+ const receipts = state.verify.results.filter((result) =>
50
+ state.kind === 'node'
51
+ ? !!cycle &&
52
+ result.restackId === cycle.id &&
53
+ result.headSha === cycle.head &&
54
+ result.baseSha === cycle.parent
55
+ : result.seq > state.verify.cycleSince,
56
+ )
57
+ const observation = state.integration?.observation
58
+ return {
59
+ kind: state.kind === 'node' ? ('node' as const) : ('work' as const),
60
+ target: effectiveTreeTarget(state),
61
+ branch: record.branch ?? state.nodeOpening?.branch,
62
+ candidate,
63
+ restack:
64
+ state.nodeRestack?.conflict || (restack.active && restack.replay?.conflicted)
65
+ ? ('conflicted' as const)
66
+ : state.nodeRestack?.active || restack.active
67
+ ? ('active' as const)
68
+ : ('idle' as const),
69
+ verification: {
70
+ head: cycle?.head ?? candidate?.head,
71
+ parent: cycle?.parent ?? candidate?.parent,
72
+ current:
73
+ state.kind === 'node'
74
+ ? integrationCurrent(state) && integrationCycleVerified(state)
75
+ : landingReady(state, restack),
76
+ results: receipts,
77
+ ...(expectedSteps ? { expectedSteps: [...expectedSteps] } : {}),
78
+ },
79
+ ...(state.kind === 'node'
80
+ ? {
81
+ children: observation?.openChildren,
82
+ diagnostics: observation?.diagnostics,
83
+ completeness: !observation
84
+ ? ('unknown' as const)
85
+ : integrationComplete(state)
86
+ ? ('complete' as const)
87
+ : ('incomplete' as const),
88
+ }
89
+ : {}),
90
+ ready: landingReady(state, restack),
91
+ consent: awaitsConsent(state, restack),
92
+ reason: awaitsConsent(state, restack)
93
+ ? state.landing?.command?.kind === 'hold'
94
+ ? ('held' as const)
95
+ : ('consent required' as const)
96
+ : undefined,
97
+ }
98
+ }
99
+ export type TreeProjection = ReturnType<typeof projectTree>
100
+ export type ConsentQueueEntry = TreeProjection & { slug: string }
101
+ export function consentQueue(
102
+ builds: readonly { slug: string; tree?: TreeProjection }[],
103
+ ): ConsentQueueEntry[] {
104
+ return builds
105
+ .flatMap((build) => (build.tree?.consent ? [{ slug: build.slug, ...build.tree }] : []))
106
+ .sort((a, b) => a.slug.localeCompare(b.slug))
107
+ }