@defrex/autobuild 0.14.0 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +4 -2
  2. package/SPEC.md +654 -98
  3. package/docs/architecture.md +226 -5
  4. package/docs/assets/headline-wide.png +0 -0
  5. package/docs/configuration.md +112 -12
  6. package/docs/hosted-service.md +18 -0
  7. package/docs/integration-tree.md +117 -0
  8. package/docs/landing-policy.md +150 -0
  9. package/docs/mcp.md +24 -0
  10. package/docs/migration-1.0.md +68 -0
  11. package/docs/operator-api.md +19 -8
  12. package/docs/remote-store-protocol.md +30 -7
  13. package/docs/remote-ticket-protocol.md +26 -5
  14. package/docs/restacking.md +79 -0
  15. package/docs/setup.md +49 -6
  16. package/docs/ticket-dependencies.md +69 -0
  17. package/docs/ticket-migration.md +8 -0
  18. package/package.json +3 -3
  19. package/packages/core/src/cli/attention.ts +25 -2
  20. package/packages/core/src/cli/build-control.ts +65 -41
  21. package/packages/core/src/cli/context.ts +54 -2
  22. package/packages/core/src/cli/dashboard/actions.ts +6 -3
  23. package/packages/core/src/cli/dashboard/landing-display.ts +6 -0
  24. package/packages/core/src/cli/dashboard/live.ts +5 -0
  25. package/packages/core/src/cli/dashboard/model.ts +142 -18
  26. package/packages/core/src/cli/dashboard/poll.ts +15 -9
  27. package/packages/core/src/cli/dashboard/refresh.ts +176 -0
  28. package/packages/core/src/cli/dashboard/render.ts +78 -28
  29. package/packages/core/src/cli/dashboard/repository-poll.ts +57 -0
  30. package/packages/core/src/cli/dashboard/selection.ts +7 -1
  31. package/packages/core/src/cli/dashboard/tree.ts +107 -0
  32. package/packages/core/src/cli/dispatch-frontend.ts +156 -109
  33. package/packages/core/src/cli/dispatch.ts +250 -136
  34. package/packages/core/src/cli/dispatcher-liveness.ts +15 -2
  35. package/packages/core/src/cli/help.ts +49 -32
  36. package/packages/core/src/cli/init-validation.ts +43 -2
  37. package/packages/core/src/cli/keyboard.ts +6 -0
  38. package/packages/core/src/cli/landings.ts +18 -0
  39. package/packages/core/src/cli/main.ts +49 -15
  40. package/packages/core/src/cli/mcp.ts +9 -0
  41. package/packages/core/src/cli/publication-settlement.ts +168 -2
  42. package/packages/core/src/cli/repository-status.ts +11 -0
  43. package/packages/core/src/cli/status.ts +72 -5
  44. package/packages/core/src/cli/terminal-restore.ts +54 -0
  45. package/packages/core/src/cli/terminal.ts +16 -2
  46. package/packages/core/src/cli/terminals.ts +98 -79
  47. package/packages/core/src/cli/ticket-editor.ts +10 -3
  48. package/packages/core/src/cli/ticket.ts +113 -18
  49. package/packages/core/src/cli/upgrade-commit.ts +4 -0
  50. package/packages/core/src/cli/upgrade-compatibility.ts +2 -2
  51. package/packages/core/src/cli/upgrade-landing.ts +69 -0
  52. package/packages/core/src/cli/upgrade.ts +16 -0
  53. package/packages/core/src/cli/wait.ts +115 -19
  54. package/packages/core/src/cli/watch.ts +51 -12
  55. package/packages/core/src/config/landing.ts +22 -0
  56. package/packages/core/src/config/live.ts +1 -0
  57. package/packages/core/src/config/schema.ts +3 -0
  58. package/packages/core/src/events/catalog.ts +48 -3
  59. package/packages/core/src/events/payloads.ts +295 -6
  60. package/packages/core/src/events/repository.ts +31 -0
  61. package/packages/core/src/integration/harness.ts +10 -0
  62. package/packages/core/src/kernel/__snapshots__/reducer-registry.test.ts.snap +1030 -239
  63. package/packages/core/src/kernel/auto-merge-default.ts +1 -0
  64. package/packages/core/src/kernel/auto-merge.ts +12 -3
  65. package/packages/core/src/kernel/build-identity.ts +94 -0
  66. package/packages/core/src/kernel/change-presence.ts +179 -0
  67. package/packages/core/src/kernel/dispatch-status.ts +17 -1
  68. package/packages/core/src/kernel/engine.ts +89 -2
  69. package/packages/core/src/kernel/generators/build-log.ts +23 -0
  70. package/packages/core/src/kernel/generators/leaf-restack-log.ts +110 -0
  71. package/packages/core/src/kernel/generators/node-restack-log.ts +94 -0
  72. package/packages/core/src/kernel/generators/repository-journals.ts +11 -0
  73. package/packages/core/src/kernel/integration-completeness.ts +81 -0
  74. package/packages/core/src/kernel/integration-landing.ts +263 -0
  75. package/packages/core/src/kernel/integration-stack.ts +36 -0
  76. package/packages/core/src/kernel/integration-state.ts +135 -0
  77. package/packages/core/src/kernel/landing-policy.ts +47 -0
  78. package/packages/core/src/kernel/landing-publication.ts +41 -0
  79. package/packages/core/src/kernel/landing-readiness.ts +67 -0
  80. package/packages/core/src/kernel/landing-state.ts +96 -0
  81. package/packages/core/src/kernel/leaf-restack-completion.ts +24 -0
  82. package/packages/core/src/kernel/leaf-restack-state.ts +73 -0
  83. package/packages/core/src/kernel/log-index.ts +35 -5
  84. package/packages/core/src/kernel/node-landing.ts +439 -0
  85. package/packages/core/src/kernel/node-parent.ts +184 -0
  86. package/packages/core/src/kernel/node-restack-state.ts +191 -0
  87. package/packages/core/src/kernel/node-restack-transaction.ts +210 -0
  88. package/packages/core/src/kernel/node-restack.ts +274 -0
  89. package/packages/core/src/kernel/read-facts.ts +70 -3
  90. package/packages/core/src/kernel/reconcile-head.ts +51 -0
  91. package/packages/core/src/kernel/reconcile-restack.ts +560 -0
  92. package/packages/core/src/kernel/reducer-registry.ts +16 -0
  93. package/packages/core/src/kernel/reducer.ts +121 -6
  94. package/packages/core/src/kernel/snapshot-parent.ts +33 -0
  95. package/packages/core/src/ontology.ts +9 -1
  96. package/packages/core/src/operator/annotations.ts +12 -0
  97. package/packages/core/src/operator/control.ts +6 -0
  98. package/packages/core/src/operator/index.ts +4 -0
  99. package/packages/core/src/operator/landings.ts +35 -0
  100. package/packages/core/src/operator/presentation.ts +1 -0
  101. package/packages/core/src/operator/protocol.ts +12 -3
  102. package/packages/core/src/operator/query.ts +3 -1
  103. package/packages/core/src/operator/registry.ts +48 -19
  104. package/packages/core/src/operator/requests.ts +1 -8
  105. package/packages/core/src/operator/tickets.ts +55 -9
  106. package/packages/core/src/ports/forge/contract.ts +91 -3
  107. package/packages/core/src/ports/forge/fake.ts +142 -4
  108. package/packages/core/src/ports/forge/git-rewrite.ts +232 -0
  109. package/packages/core/src/ports/forge/github-readiness.ts +421 -0
  110. package/packages/core/src/ports/forge/github.ts +631 -35
  111. package/packages/core/src/ports/forge/local-git.ts +119 -5
  112. package/packages/core/src/ports/forge/readiness.ts +99 -0
  113. package/packages/core/src/ports/tickets/contract.ts +41 -0
  114. package/packages/core/src/ports/tickets/create.ts +8 -1
  115. package/packages/core/src/ports/tickets/fake.ts +32 -1
  116. package/packages/core/src/ports/tickets/file-codec.ts +7 -0
  117. package/packages/core/src/ports/tickets/file.ts +18 -1
  118. package/packages/core/src/ports/tickets/hosted-index.ts +2 -0
  119. package/packages/core/src/ports/tickets/linear.ts +124 -4
  120. package/packages/core/src/ports/tickets/migration.ts +25 -1
  121. package/packages/core/src/ports/tickets/operations.ts +7 -2
  122. package/packages/core/src/ports/tickets/remote-protocol.ts +19 -0
  123. package/packages/core/src/ports/tickets/remote.ts +10 -1
  124. package/packages/core/src/ports/tickets/revision.ts +3 -1
  125. package/packages/core/src/ports/tickets/tree.ts +148 -0
  126. package/packages/core/src/ports/tickets/update.ts +15 -2
  127. package/packages/core/src/ports/types.ts +135 -5
  128. package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
  129. package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -1
  130. package/packages/core/src/ports/workspace/vercel-sandbox.ts +60 -3
  131. package/packages/core/src/processes/build-runner.ts +530 -23
  132. package/packages/core/src/processes/dispatcher-selectors.ts +15 -9
  133. package/packages/core/src/processes/dispatcher.ts +2145 -203
  134. package/packages/core/src/processes/execution-no-progress.ts +46 -1
  135. package/packages/core/src/processes/publication-state.ts +30 -5
  136. package/packages/core/src/processes/repo-view.ts +21 -2
  137. package/packages/core/src/store/build-scope.ts +18 -0
  138. package/packages/core/src/store/contract.ts +658 -0
  139. package/packages/core/src/store/digest.ts +52 -4
  140. package/packages/core/src/store/local/schema.ts +25 -13
  141. package/packages/core/src/store/local/store.ts +117 -1
  142. package/packages/core/src/store/memory.ts +62 -1
  143. package/packages/core/src/store/phase-session.ts +17 -0
  144. package/packages/core/src/store/reduced-reads.ts +2 -1
  145. package/packages/core/src/store/reducer-value-shapes.json +10707 -6440
  146. package/packages/core/src/store/remote/client.ts +44 -0
  147. package/packages/core/src/store/remote/compatibility.ts +19 -9
  148. package/packages/core/src/store/remote/protocol.ts +11 -0
  149. package/packages/core/src/store/repo-state-events.ts +2 -0
  150. package/packages/core/src/store/session-handle.ts +15 -0
  151. package/packages/core/src/store/subscribe.ts +1 -1
  152. package/packages/core/src/store/types.ts +32 -4
  153. package/packages/core/src/testing/index.ts +2 -0
  154. package/packages/core/src/testing/reduced-read-budget.ts +48 -8
  155. package/packages/core/src/testing/refresh-scheduler.ts +32 -0
  156. package/skills/guide/SKILL.md +110 -61
  157. package/skills/guide/references/integration-tree.md +117 -0
  158. package/skills/guide/references/landing-policy.md +150 -0
  159. package/skills/guide/references/migration-1.0.md +68 -0
  160. package/skills/guide/references/operator-api.md +12 -5
  161. package/skills/guide/references/plugin-authoring.md +34 -0
  162. package/skills/guide/references/remote-store-protocol.md +30 -7
  163. package/skills/guide/references/remote-ticket-protocol.md +26 -5
  164. package/skills/guide/references/restacking.md +79 -0
  165. package/skills/guide/references/setup.md +49 -6
  166. package/skills/guide/references/ticket-dependencies.md +69 -0
  167. package/skills/guide/references/ticket-migration.md +8 -0
  168. package/skills/operate/SKILL.md +55 -5
  169. package/skills/reconcile/SKILL.md +55 -48
  170. package/skills/spec/SKILL.md +67 -1
  171. package/skills/tickets/SKILL.md +55 -2
  172. package/templates/autobuild.toml +3 -0
@@ -1,3 +1,7 @@
1
+ import { advanceLanding, type LandingState } from './landing-state'
2
+ import { advanceIntegration, type IntegrationState } from './integration-state'
3
+ import { advanceNodeRestack, type NodeRestackState } from './node-restack-state'
4
+ import { reconcileRewriteHead } from './reconcile-head'
1
5
  /**
2
6
  * The state reducer (SPEC §15.5, §3.4): state is a reduction of events — any
3
7
  * snapshot is a cache, never the source of truth, and resumability falls out.
@@ -109,6 +113,9 @@ export interface OpenSession {
109
113
  * the aggregate attempt high-water and cannot identify the current cycle in
110
114
  * the window between a verify failure and the next `verify.started`. */
111
115
  export interface VerifyResult {
116
+ baseSha?: string
117
+ headSha?: string
118
+ restackId?: string
112
119
  step: string
113
120
  attempt: number
114
121
  outcome: VerifyOutcome
@@ -132,6 +139,7 @@ export type PrLifecycle = 'open' | 'merged' | 'closed' | 'conflicted'
132
139
  * non-transactional forge/event boundary: consumers treat the command as
133
140
  * settled only when both `enabled` and `commandSeq` match. */
134
141
  export interface AutoMergeProjection {
142
+ explicitCommandSeq?: number
135
143
  /** Latest human command. False with no commandSeq means the default: off. */
136
144
  requested: boolean
137
145
  commandSeq?: number
@@ -148,6 +156,16 @@ export interface AutoMergeProjection {
148
156
  export type ObservationRecord = EventPayload<'observation.recorded'>
149
157
 
150
158
  export interface BuildState {
159
+ kind?: 'work' | 'node'
160
+ target?: EventPayload<'build.created'>['target']
161
+ baseBranch?: string
162
+ mergedSha?: string
163
+ nodeOpening?: EventPayload<'node.opening'>
164
+ nodeOpened?: EventPayload<'node.opened'>
165
+ nodeRestack?: NodeRestackState
166
+ integration?: IntegrationState
167
+ nodeComparison?: EventPayload<'node.compared'>
168
+
151
169
  /**
152
170
  * §15.5: 'queued' until `runner.attached`, 'running' after;
153
171
  * 'blocked' ≡ open escalation; 'paused' ≡ `build.paused` without a later
@@ -186,7 +204,9 @@ export interface BuildState {
186
204
  /** From `finalize.completed` (§15.3) — the kernel opened the PR (D7). */
187
205
  pr?: { number: number; url: string; headSha: string }
188
206
  prState?: PrLifecycle
189
- /** Human auto-merge intent and its correlated forge application fact. */
207
+ /** Readiness provenance, landing-bound consent and native application receipts. */
208
+ landing?: LandingState
209
+ /** Historical auto-merge controls retained for replay compatibility. */
190
210
  autoMerge: AutoMergeProjection
191
211
  /** seq of the latest `finalize.completed`, else 0 — "has finalize run for
192
212
  * the CURRENT spec". `prState` cannot answer that: it is the full-log PR
@@ -308,6 +328,16 @@ export function discardInFlight(state: Pick<BuildState, 'discardRequest'>): bool
308
328
  * trip through `JSON.stringify` — the foundation for incremental advancement
309
329
  * and cached state. */
310
330
  export interface BuildAcc {
331
+ kind?: 'work' | 'node'
332
+ target?: EventPayload<'build.created'>['target']
333
+ baseBranch?: string
334
+ mergedSha?: string
335
+ nodeOpening?: EventPayload<'node.opening'>
336
+ nodeOpened?: EventPayload<'node.opened'>
337
+ nodeRestack?: NodeRestackState
338
+ integration?: IntegrationState
339
+ nodeComparison?: EventPayload<'node.compared'>
340
+
311
341
  attached: boolean
312
342
  pausedFlag: boolean
313
343
  terminal?: 'done' | 'aborted'
@@ -320,6 +350,7 @@ export interface BuildAcc {
320
350
  reviewRoundCeilings: BuildState['reviewRoundCeilings']
321
351
  pr: BuildState['pr']
322
352
  prState?: PrLifecycle
353
+ landing?: LandingState
323
354
  autoMerge: AutoMergeProjection
324
355
  specRev?: number
325
356
  restartSince: number
@@ -350,7 +381,7 @@ export interface BuildAcc {
350
381
  }
351
382
 
352
383
  /** Bump when `BuildAcc`'s shape or the fold's semantics change. */
353
- export const BUILD_REDUCER_VERSION = 1
384
+ export const BUILD_REDUCER_VERSION = 11
354
385
 
355
386
  function initialBuildAcc(): BuildAcc {
356
387
  return {
@@ -361,6 +392,7 @@ function initialBuildAcc(): BuildAcc {
361
392
  answeredEscalations: [],
362
393
  reviewRoundCeilings: {},
363
394
  pr: undefined,
395
+ landing: {},
364
396
  autoMerge: { requested: false },
365
397
  restartSince: 0,
366
398
  pinnedAssets: [],
@@ -451,10 +483,52 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
451
483
 
452
484
  let lastEvent = acc.lastEvent
453
485
  for (const event of events) {
486
+ acc.landing ??= {}
487
+ advanceLanding(acc.landing, event)
488
+ if (event.type.startsWith('integration.')) {
489
+ acc.integration ??= {}
490
+ advanceIntegration(acc.integration, event)
491
+ }
492
+ if (event.type.startsWith('node.') || (acc.kind === 'node' && event.type === 'target.moved')) {
493
+ acc.nodeRestack ??= { items: [] }
494
+ advanceNodeRestack(acc.nodeRestack, [event])
495
+ }
454
496
  switch (event.type) {
455
497
  // Facts the projection does not need (workspace liveness is the
456
498
  // dispatcher's concern; finalize post-steps are failure-tolerant §5).
499
+ case 'node.parent-accepted':
500
+ if (acc.kind === 'node') {
501
+ acc.target = event.payload.next.target ?? undefined
502
+ acc.baseBranch = event.payload.next.branch
503
+ delete acc.nodeComparison
504
+ if (acc.integration) {
505
+ delete acc.integration.cycle
506
+ delete acc.integration.observation
507
+ }
508
+ }
509
+ break
510
+ case 'node.opening':
511
+ acc.nodeOpening = event.payload
512
+ break
513
+ case 'node.opened':
514
+ acc.nodeOpened = event.payload
515
+ break
516
+ case 'node.compared':
517
+ acc.nodeComparison = event.payload
518
+ break
519
+ case 'node.rewritten':
520
+ if (acc.nodeComparison)
521
+ acc.nodeComparison = { ...acc.nodeComparison, headSha: event.payload.head }
522
+ if (pr) pr = { ...pr, headSha: event.payload.head }
523
+ break
524
+ case 'pr.opened':
525
+ pr = event.payload.pr
526
+ prState = 'open'
527
+ break
457
528
  case 'build.created':
529
+ acc.kind = event.payload.kind
530
+ acc.target = event.payload.target
531
+ acc.baseBranch = event.payload.baseBranch
458
532
  pinnedAssets = event.payload.assets ?? []
459
533
  break
460
534
  case 'workspace.provisioned':
@@ -556,6 +630,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
556
630
  discardRequest = { seq: event.seq, actor: event.actor }
557
631
  break
558
632
  case 'build.auto-merge-requested':
633
+ if (event.payload.integrationConsent === true) autoMerge.explicitCommandSeq = event.seq
559
634
  autoMerge.requested = true
560
635
  autoMerge.commandSeq = event.seq
561
636
  // A fan-out (or seeded) command carries the default fact it answers; a
@@ -691,6 +766,9 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
691
766
  const result = normalizeVerifyCompletion(event.payload)
692
767
  verify.maxAttemptSeen = Math.max(verify.maxAttemptSeen, result.attempt)
693
768
  verify.results.push({
769
+ ...(result.baseSha === undefined ? {} : { baseSha: result.baseSha }),
770
+ ...(result.headSha === undefined ? {} : { headSha: result.headSha }),
771
+ ...(result.restackId === undefined ? {} : { restackId: result.restackId }),
694
772
  step: result.step,
695
773
  attempt: result.attempt,
696
774
  outcome: result.outcome,
@@ -731,6 +809,7 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
731
809
  autoMerge.applied = { enabled: false, commandSeq: event.payload.commandSeq }
732
810
  break
733
811
  case 'pr.merged':
812
+ acc.mergedSha = event.payload.sha
734
813
  prState = 'merged'
735
814
  break
736
815
  case 'pr.closed':
@@ -747,7 +826,24 @@ function foldBuild(acc: BuildAcc, events: readonly AbEvent[]): void {
747
826
  seq: event.seq,
748
827
  })
749
828
  break
829
+ case 'restack.rewritten':
830
+ case 'restack.completed':
831
+ if (event.type === 'restack.completed' && prState === 'conflicted') prState = 'open'
832
+ if (pr !== undefined)
833
+ pr = {
834
+ ...pr,
835
+ headSha:
836
+ event.type === 'restack.rewritten'
837
+ ? (event.payload.observedHead ?? event.payload.headSha)
838
+ : event.payload.headSha,
839
+ }
840
+ break
841
+ case 'reconcile.rewritten':
842
+ if (pr !== undefined) pr = { ...pr, headSha: reconcileRewriteHead(event.payload) }
843
+ break
750
844
  case 'reconcile.completed': {
845
+ if (acc.kind !== 'node' && 'headSha' in event.payload && pr !== undefined)
846
+ pr = { ...pr, headSha: event.payload.headSha }
751
847
  // The terminal payload has no attempt, so preserve it from the
752
848
  // matching in-flight occurrence before complete() clears that context.
753
849
  // An unmatched completion remains a bare context rather than borrowing
@@ -873,15 +969,33 @@ function finishBuild(acc: BuildAcc): BuildState {
873
969
  terminal ??
874
970
  (pausedFlag
875
971
  ? 'paused'
876
- : acc.openEscalations.length > 0
972
+ : acc.openEscalations.length > 0 ||
973
+ (acc.integration?.cycle &&
974
+ acc.nodeComparison?.headSha === acc.integration.cycle.head &&
975
+ acc.nodeComparison?.parentSha === acc.integration.cycle.parent &&
976
+ acc.verify.results.some(
977
+ (result) =>
978
+ result.restackId === acc.integration!.cycle!.id && result.outcome === 'fail',
979
+ ))
877
980
  ? 'blocked'
878
- : attached
879
- ? 'running'
880
- : 'queued')
981
+ : acc.kind === 'node' && acc.nodeOpened !== undefined
982
+ ? 'collecting'
983
+ : attached
984
+ ? 'running'
985
+ : 'queued')
881
986
 
882
987
  const active = currentPhase ?? lastCompletedPhase
883
988
 
884
989
  return {
990
+ kind: acc.kind,
991
+ target: acc.target,
992
+ baseBranch: acc.baseBranch,
993
+ nodeOpening: acc.nodeOpening,
994
+ mergedSha: acc.mergedSha,
995
+ nodeOpened: acc.nodeOpened,
996
+ integration: acc.integration,
997
+ nodeComparison: acc.nodeComparison,
998
+ nodeRestack: acc.nodeRestack,
885
999
  status,
886
1000
  outcome: acc.outcome,
887
1001
  phase: active?.phase,
@@ -893,6 +1007,7 @@ function finishBuild(acc: BuildAcc): BuildState {
893
1007
  reviewRoundCeilings: acc.reviewRoundCeilings,
894
1008
  pr: acc.pr,
895
1009
  prState: acc.prState,
1010
+ landing: acc.landing,
896
1011
  autoMerge: acc.autoMerge,
897
1012
  finalizeCompletedSeq: acc.finalizeCompletedSeq,
898
1013
  finalizeSteps: acc.finalizeSteps,
@@ -0,0 +1,33 @@
1
+ import type { RestackDeps } from './reconcile-restack'
2
+ import { isValidGitBranchName } from './origin'
3
+
4
+ export async function snapshotParent(
5
+ deps: Pick<RestackDeps, 'forge' | 'exec' | 'workspacePath'>,
6
+ base: string,
7
+ destinationRef: string,
8
+ ) {
9
+ const input = { workspacePath: deps.workspacePath, base, destinationRef }
10
+ if (deps.forge.snapshotBase) return deps.forge.snapshotBase(input)
11
+ if (!isValidGitBranchName(base)) throw new Error('invalid node parent branch')
12
+ // Like leaf target snapshots, Git-transport forges fetch into a private ref.
13
+ // The dispatcher supplies the forge's credentialed kernel execution seam.
14
+ const fetched = await deps.exec(
15
+ [
16
+ 'git',
17
+ 'fetch',
18
+ '--no-tags',
19
+ '--no-write-fetch-head',
20
+ '--refmap=',
21
+ 'origin',
22
+ `+refs/heads/${base}:${destinationRef}`,
23
+ ],
24
+ { cwd: deps.workspacePath },
25
+ )
26
+ if (fetched.exitCode !== 0) throw new Error(fetched.stderr)
27
+ const head = await deps.exec(['git', 'rev-parse', '--verify', `${destinationRef}^{commit}`], {
28
+ cwd: deps.workspacePath,
29
+ })
30
+ if (head.exitCode !== 0 || !/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(head.stdout.trim()))
31
+ throw new Error('node parent snapshot did not resolve to a commit')
32
+ return head.stdout.trim()
33
+ }
@@ -245,7 +245,15 @@ export const buildOutcomeSchema = z.enum(['merged', 'closed-unmerged', 'abandone
245
245
  export type BuildOutcome = z.infer<typeof buildOutcomeSchema>
246
246
 
247
247
  /** Derived status — a reduction of events, never stored (SPEC §15.5). */
248
- export const BUILD_STATUSES = ['queued', 'running', 'paused', 'blocked', 'done', 'aborted'] as const
248
+ export const BUILD_STATUSES = [
249
+ 'queued',
250
+ 'running',
251
+ 'collecting',
252
+ 'paused',
253
+ 'blocked',
254
+ 'done',
255
+ 'aborted',
256
+ ] as const
249
257
  export type BuildStatus = (typeof BUILD_STATUSES)[number]
250
258
 
251
259
  export const commitRangeSchema = z.strictObject({
@@ -26,6 +26,18 @@ export interface ToolAnnotationsTableEntry {
26
26
 
27
27
  /** The exact version-one tool names; the registry's closed table must match. */
28
28
  export const OPERATOR_TOOL_ANNOTATIONS = {
29
+ 'landings.list': {
30
+ readOnlyHint: true,
31
+ destructiveHint: false,
32
+ idempotentHint: true,
33
+ approval: 'never',
34
+ },
35
+ 'tickets.tree': {
36
+ readOnlyHint: true,
37
+ destructiveHint: false,
38
+ idempotentHint: true,
39
+ approval: 'never',
40
+ },
29
41
  'builds.list': {
30
42
  readOnlyHint: true,
31
43
  destructiveHint: false,
@@ -7,6 +7,7 @@ import { projectHarvest, type HarvestRunAction } from '../cli/dashboard/model'
7
7
  export class OperatorControlError extends Error {
8
8
  constructor(
9
9
  readonly code:
10
+ | 'retired-setting'
10
11
  | 'stale-harvest-run'
11
12
  | 'harvest-paused'
12
13
  | 'harvest-pending'
@@ -33,6 +34,11 @@ export async function setRepositorySetting(opts: {
33
34
  * journal; optional so the operator API (which has no run) is unchanged. */
34
35
  run?: string
35
36
  }): Promise<{ enabled: boolean; event: RepositoryEventEnvelope }> {
37
+ if (opts.setting === 'auto-merge-default')
38
+ throw new OperatorControlError(
39
+ 'retired-setting',
40
+ 'Auto-merge default is retired; configure [[landing]] rules in autobuild.toml',
41
+ )
36
42
  await opts.store.ensureRepo(opts.repo)
37
43
  const payload = {
38
44
  enabled: opts.enabled,
@@ -92,6 +92,7 @@ export type {
92
92
  OperatorTicketQueue,
93
93
  } from './tickets'
94
94
  export {
95
+ openOperatorTickets,
95
96
  prepareOperatorTicketAssets,
96
97
  listOperatorTicketStates,
97
98
  createOperatorTicketState,
@@ -139,3 +140,6 @@ export {
139
140
  export { ticketStateCreateRequestSchema } from './protocol'
140
141
 
141
142
  export { readBuildFacts } from '../store/reduced-reads'
143
+
144
+ export { listOperatorLandings } from './landings'
145
+ export { readTicketTree, getOperatorTicketTree } from './tickets'
@@ -0,0 +1,35 @@
1
+ import {
2
+ BUILD_EFFECTIVE_CONFIG_ARTIFACT,
3
+ parseEffectiveBuildConfig,
4
+ } from '../processes/build-execution-state'
5
+ import type { BuildStore } from '../store/types'
6
+ import { readBuildDigests } from '../store/reduced-reads'
7
+ import { withOperatorView } from './read-view'
8
+ import { projectTree, type ConsentQueueEntry } from '../cli/dashboard/tree'
9
+
10
+ /** Stored readiness only; land reobserves live completeness at its mutation boundary. */
11
+ export async function listOperatorLandings(opts: {
12
+ store: BuildStore
13
+ repo: string
14
+ }): Promise<ConsentQueueEntry[]> {
15
+ return withOperatorView(opts.store, opts.repo, 'builds', async (view) => {
16
+ const records = await view.listBuilds()
17
+ const digests = await readBuildDigests(view, opts.repo)
18
+ const entries: ConsentQueueEntry[] = []
19
+ for (const record of records) {
20
+ if (record.repo !== opts.repo) continue
21
+ const digest = digests.get(record.slug)
22
+ if (!digest)
23
+ throw new Error(`getRepoBuildDigests is missing an entry for build "${record.slug}"`)
24
+ if (digest.terminal !== undefined) continue
25
+ const facts = await view.buildFacts(record.slug)
26
+ const artifact = facts.state.landing?.decision
27
+ ? await view.getArtifact(record.slug, BUILD_EFFECTIVE_CONFIG_ARTIFACT)
28
+ : null
29
+ const expected = artifact ? parseEffectiveBuildConfig(artifact).verify.steps : undefined
30
+ const tree = projectTree(record, facts.state, facts.log.restack, expected)
31
+ if (tree.consent) entries.push({ slug: record.slug, ...tree })
32
+ }
33
+ return entries.sort((a, b) => a.slug.localeCompare(b.slug))
34
+ })
35
+ }
@@ -1,3 +1,4 @@
1
+ export { landingPolicyDisplay } from '../cli/dashboard/landing-display'
1
2
  export {
2
3
  buildActionAvailability,
3
4
  dashboardBuildControl,
@@ -8,8 +8,8 @@ export const buildControlRequestSchema = z.discriminatedUnion('action', [
8
8
  z.strictObject({ action: z.literal('resume') }),
9
9
  z.strictObject({ action: z.literal('abort') }),
10
10
  z.strictObject({ action: z.literal('discard') }),
11
- z.strictObject({ action: z.literal('auto-merge-on') }),
12
- z.strictObject({ action: z.literal('auto-merge-off') }),
11
+ z.strictObject({ action: z.literal('land') }),
12
+ z.strictObject({ action: z.literal('hold') }),
13
13
  ])
14
14
  export type OperatorBuildControlRequest = z.infer<typeof buildControlRequestSchema>
15
15
 
@@ -49,6 +49,8 @@ export const harvestControlRequestSchema = z.discriminatedUnion('action', [
49
49
  ])
50
50
 
51
51
  export const ticketCreateRequestSchema = z.strictObject({
52
+ kind: z.enum(['work', 'node']).optional(),
53
+ target: z.string().trim().min(1).nullable().optional(),
52
54
  title: z.string(),
53
55
  body: z.string(),
54
56
  labels: z.array(z.string()).optional(),
@@ -61,13 +63,20 @@ const expectedRevisionSchema = z
61
63
  .optional()
62
64
  export const ticketUpdateRequestSchema = z
63
65
  .strictObject({
66
+ kind: z.enum(['work', 'node']).optional(),
67
+ target: z.string().trim().min(1).nullable().optional(),
64
68
  expectedRevision: expectedRevisionSchema,
65
69
  title: z.string().optional(),
66
70
  body: z.string().optional(),
67
71
  labels: z.array(z.string()).optional(),
68
72
  })
69
73
  .refine(
70
- (value) => value.title !== undefined || value.body !== undefined || value.labels !== undefined,
74
+ (value) =>
75
+ value.title !== undefined ||
76
+ value.body !== undefined ||
77
+ value.labels !== undefined ||
78
+ value.kind !== undefined ||
79
+ value.target !== undefined,
71
80
  'update must name at least one field',
72
81
  )
73
82
  export const ticketMoveRequestSchema = z.strictObject({
@@ -1,3 +1,4 @@
1
+ import { forgeReadinessWarnings } from '../kernel/dispatch-status'
1
2
  import { readBuildDigests } from '../store/reduced-reads'
2
3
  import {
3
4
  readBuildFacts,
@@ -359,7 +360,7 @@ async function dashboardFromView(
359
360
  // Reduced status is `done`/`aborted` exactly when a terminal fact exists,
360
361
  // so `terminal === undefined` is exactly the old active test — no history
361
362
  // read needed for the count.
362
- if (digest.terminal === undefined) activeCount += 1
363
+ if (digest.terminal === undefined && digest.kind !== 'node') activeCount += 1
363
364
  if (digest.terminal === 'done') continue
364
365
  // Both query surfaces share the `projectsNoDashboardRow` gate (AUT-486
365
366
  // snapshot, AUT-496 detail query): a build that projects no row —
@@ -392,6 +393,7 @@ async function dashboardFromView(
392
393
  })
393
394
  const warningLines = [
394
395
  ...status.roleWarnings,
396
+ ...forgeReadinessWarnings(status),
395
397
  ...(status.warningNotice !== undefined ? [status.warningNotice] : []),
396
398
  ]
397
399
  const model = buildDashboardFromProjected(
@@ -1,3 +1,6 @@
1
+ import { listOperatorLandings } from './landings'
2
+ import { getOperatorTicketTree } from './tickets'
3
+ import { openOperatorTickets } from './tickets'
1
4
  import { TicketRevisionConflict, TicketRevisionUnsupported } from '../ports/tickets/revision'
2
5
  /**
3
6
  * The agent tool registry — one typed table that is the single source of
@@ -262,17 +265,9 @@ const buildControlInput = z.strictObject({
262
265
  repo: repoField,
263
266
  slug: slugField,
264
267
  action: z
265
- .enum([
266
- 'pause',
267
- 'cancel-pause',
268
- 'resume',
269
- 'auto-merge-on',
270
- 'auto-merge-off',
271
- 'abort',
272
- 'discard',
273
- ])
268
+ .enum(['pause', 'cancel-pause', 'resume', 'land', 'hold', 'abort', 'discard'])
274
269
  .describe(
275
- 'Control to request: "pause" (or "cancel-pause" to revoke a pending pause), "resume" a paused build, "auto-merge-on"/"auto-merge-off" for native auto-merge — or the destructive "abort" (cancels the build, cleans up its PR and workspace, returns the ticket to triage) and "discard" (dequeue a queued build).',
270
+ 'Control to request: "pause" (or "cancel-pause" to revoke a pending pause), "resume" a paused build, "land" for landing consent or "hold" to withdraw consent — or the destructive "abort" (cancels the build, cleans up its PR and workspace, returns the ticket to triage) and "discard" (dequeue a queued build).',
276
271
  ),
277
272
  })
278
273
 
@@ -282,11 +277,7 @@ const repositoryStatusInput = z.strictObject({ repo: repoField })
282
277
 
283
278
  const repositorySettingsInput = z.strictObject({
284
279
  repo: repoField,
285
- setting: z
286
- .enum(['intake', 'auto-merge-default'])
287
- .describe(
288
- '"intake" gates whether new tickets may be claimed; "auto-merge-default" is the claim-time auto-merge default for newly claimed builds.',
289
- ),
280
+ setting: z.enum(['intake']).describe('"intake" gates whether new tickets may be claimed.'),
290
281
  enabled: z
291
282
  .boolean()
292
283
  .optional()
@@ -326,7 +317,12 @@ const ticketsCreateInput = ticketCreateRequestSchema.extend({ repo: repoField })
326
317
  const ticketsUpdateInput = ticketUpdateRequestSchema
327
318
  .extend({ repo: repoField, id: ticketIdField })
328
319
  .refine(
329
- (value) => value.title !== undefined || value.body !== undefined || value.labels !== undefined,
320
+ (value) =>
321
+ value.title !== undefined ||
322
+ value.body !== undefined ||
323
+ value.labels !== undefined ||
324
+ value.kind !== undefined ||
325
+ value.target !== undefined,
330
326
  'update must name at least one field',
331
327
  )
332
328
 
@@ -481,6 +477,25 @@ function defineTool(
481
477
  * here and a row in `operator/annotations.ts`; the contract suite proves the
482
478
  * two stay in lockstep. */
483
479
  export const TOOLS: readonly ToolEntry[] = [
480
+ defineTool(
481
+ 'landings.list',
482
+ 'List ready landings awaiting consent or held, with frozen effective targets and verification evidence.',
483
+ repositoryStatusInput,
484
+ 'JSON array ordered by slug: kind, target, branch, candidate, reason, verification and node completeness.',
485
+ async (raw, ctx) => listOperatorLandings({ store: ctx.store, ...(raw as { repo: string }) }),
486
+ ),
487
+ defineTool(
488
+ 'tickets.tree',
489
+ 'Read the exhaustive source ticket tree, including completed tickets and empty nodes.',
490
+ repositoryStatusInput,
491
+ '{root, children, diagnostics}: source metadata ancestry, distinct from frozen build targets.',
492
+ async (raw, ctx) =>
493
+ getOperatorTicketTree({
494
+ store: ctx.store,
495
+ backend: ticketsOf(ctx),
496
+ ...(raw as { repo: string }),
497
+ }),
498
+ ),
484
499
  defineTool(
485
500
  'builds.list',
486
501
  'List one repository’s builds, newest first, with effective status derived from the build log.',
@@ -560,7 +575,7 @@ export const TOOLS: readonly ToolEntry[] = [
560
575
  ),
561
576
  defineTool(
562
577
  'builds.control',
563
- 'Request a durable control for one active build: pause/cancel-pause, resume, auto-merge on/off — or the destructive abort and discard.',
578
+ 'Request a durable control for one active build: pause/cancel-pause, resume, hold or land — or the destructive abort and discard. Land requires a ready candidate; hold withdraws landing consent.',
564
579
  buildControlInput,
565
580
  'Either {kind: "command", slug, command, event} for an accepted control, or {kind: "answer-required", slug, escalationIds} when a resume needs its open escalations answered first.',
566
581
  async (raw, ctx) => {
@@ -578,6 +593,12 @@ export const TOOLS: readonly ToolEntry[] = [
578
593
  : { kind: input.action }
579
594
  return controlBuild({
580
595
  store: ctx.store,
596
+ ticketSource: async () => {
597
+ if (!ctx.tickets) throw new Error('ticket source unavailable')
598
+ return (
599
+ await openOperatorTickets({ store: ctx.store, repo: input.repo, backend: ctx.tickets })
600
+ ).source
601
+ },
581
602
  repo: input.repo,
582
603
  slug: input.slug,
583
604
  user: attributed(ctx),
@@ -597,6 +618,12 @@ export const TOOLS: readonly ToolEntry[] = [
597
618
  const { action, readTicketBody } = answerAction(input)
598
619
  return controlBuild({
599
620
  store: ctx.store,
621
+ ticketSource: async () => {
622
+ if (!ctx.tickets) throw new Error('ticket source unavailable')
623
+ return (
624
+ await openOperatorTickets({ store: ctx.store, repo: input.repo, backend: ctx.tickets })
625
+ ).source
626
+ },
600
627
  repo: input.repo,
601
628
  slug: input.slug,
602
629
  user: attributed(ctx),
@@ -763,13 +790,15 @@ export const TOOLS: readonly ToolEntry[] = [
763
790
  '{ticket, blockers, build}: the created ticket and its (usually empty) dependency states.',
764
791
  async (raw, ctx) => {
765
792
  const input = raw as z.infer<typeof ticketsCreateInput>
766
- const { repo, title, body, labels, state, blockedBy } = input
793
+ const { repo, title, body, labels, state, blockedBy, kind, target } = input
767
794
  return mutateOperatorTicket({
768
795
  store: ctx.store,
769
796
  repo,
770
797
  backend: ticketsOf(ctx),
771
798
  operation: {
772
799
  kind: 'create',
800
+ ...(kind !== undefined ? { ticketKind: kind } : {}),
801
+ ...(target !== undefined ? { target } : {}),
773
802
  title,
774
803
  body,
775
804
  ...(labels !== undefined ? { labels } : {}),
@@ -781,7 +810,7 @@ export const TOOLS: readonly ToolEntry[] = [
781
810
  ),
782
811
  defineTool(
783
812
  'tickets.update',
784
- 'Partially replace a ticket’s editable fields (title, body, labels); state is never changed here.',
813
+ 'Partially replace a ticket’s editable fields (title, body, labels, kind, target); state is never changed here.',
785
814
  ticketsUpdateInput,
786
815
  '{ticket, blockers, build}: the updated ticket.',
787
816
  async (raw, ctx) => {
@@ -57,14 +57,7 @@ export async function controlPrechecks(
57
57
  store: BuildStore,
58
58
  repo: string,
59
59
  slug: string,
60
- action:
61
- | 'pause'
62
- | 'cancel-pause'
63
- | 'resume'
64
- | 'auto-merge-on'
65
- | 'auto-merge-off'
66
- | 'abort'
67
- | 'discard',
60
+ action: 'pause' | 'cancel-pause' | 'resume' | 'land' | 'hold' | 'abort' | 'discard',
68
61
  ): Promise<void> {
69
62
  await requireRouteBuild(store, repo, slug)
70
63
  if (action === 'pause' || action === 'cancel-pause') {