@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
@@ -57,3 +57,72 @@ or repair the blocker set, and only then move the ticket back to ready. Moving
57
57
  the ticket before cleanup finishes can be overwritten by cleanup. Ready with
58
58
  unresolved blockers is the normal waiting state: dispatch rechecks dependencies
59
59
  and claims the ticket only after they resolve and other readiness gates pass.
60
+
61
+ ## Node tickets and targets
62
+
63
+ Tickets have `kind = "work"` by default, or `kind = "node"` for a named
64
+ integration point. The optional `target` is a node ticket id in the same source;
65
+ omission means the configured `baseBranch` root. Nodes may target other nodes.
66
+ A ready node opens an integration branch; a targeting build freezes that node
67
+ as its base and landing destination. The existing cascade restacks descendants
68
+ when a parent moves. Blockers remain a separate graph.
69
+
70
+ Use `ab ticket create "Integration" --body spec.md --kind node`, then
71
+ `ab ticket update <id> --target <node-id>`. Clear a target with `--no-target`;
72
+ reset kind with `--kind work`. Omitted fields preserve existing values.
73
+ `ab ticket show <id> [--json]` exposes both fields; `ab ticket tree [--json]`
74
+ shows the configured root and every ticket, including completed work and empty
75
+ nodes, nested by target with state. Siblings are sorted by id. Invalid external
76
+ graphs and listing diagnostics are reported explicitly.
77
+
78
+ Targets must exist and be nodes in the configured source. Self-targeting,
79
+ ancestor cycles and demoting a node with targeting tickets are refused before
80
+ any part of the requested update is written, regardless of ticket state.
81
+ Clear or reparent its children before demotion. File frontmatter persists the
82
+ fields; `ab ticket edit` displays them read-only. Change them through update.
83
+ Kind and target participate in content revisions and revision-checked writes.
84
+ File writes retain their existing best-effort, unlocked concurrency semantics.
85
+
86
+ Linear uses the exact `node` issue label for kind and the parent relation for
87
+ target, only when the parent carries that label. Ordinary grouping parents do
88
+ not impose targets and survive unrelated updates. Explicit target clear clears
89
+ the parent relation. Label replacements can demote nodes and receive the same
90
+ guards; explicit kind and label instructions must agree about `node`. Label
91
+ and parent connections are fully paginated. Linear still refuses guarded writes.
92
+
93
+ Hosted sources support kind and target with project-scoped transactional validation.
94
+ Existing tickets default to work with no target. Metadata changes increment the
95
+ revision once; equivalent aliases and unchanged values do not. Node demotion
96
+ checks all targeting tickets, including completed work. Legacy plugins without
97
+ integrationTree support read as work with no target and refuse metadata writes.
98
+
99
+
100
+ A node remains incomplete while any ticket targeting it is unresolved, including
101
+ triage and backlog tickets. Done and cancelled tickets are terminal. A complete
102
+ node with landed contributions verifies its exact head before explicit per-build
103
+ landing consent can publish it. If node verification fails, file a repair child
104
+ with that node as its target; landing the repair triggers a fresh cycle. Human
105
+ forge merges are recorded escape hatches from these gates.
106
+
107
+ ## When a blocker resolves
108
+
109
+ In a repository with nodes, a blocker that has a build resolves when its change
110
+ is present in the dependent's target head (or the configured root branch).
111
+ Source done state and aggregate blocker flags do not bypass this gate. A
112
+ confirmed landing SHA reachable from the sampled target proves presence even
113
+ without a build trailer. A node blocker requires its entire completed owned
114
+ contribution, including nested changes and foreign commits, excluding inherited
115
+ parent history. An empty completed contribution is satisfied; missing evidence,
116
+ an open or aborted node, or ambiguous newest build generations remain queued.
117
+ Older successful generations are never substituted for the newest build.
118
+
119
+ - Same node: the blocking change lands directly into the target.
120
+ - Ancestor: the change lands into an ancestor, then the cascade restacks the target.
121
+ - Sibling: the blocking node lands into their common ancestor, then the cascade reaches the target.
122
+ - Descendant: the blocking node lands into the dependent's target ancestor.
123
+
124
+ Blockers that never had a build, and repositories without nodes, retain the
125
+ source's done-state rule. Waiting tickets stay source work; diagnostics identify
126
+ the missing blocker and destination. Presence is checked only when claiming,
127
+ against an exact sampled head revalidated before claim. Changing presence later
128
+ never stops an existing build.
@@ -62,3 +62,11 @@ Legacy records without `comments` retain their Markdown comment append behavior;
62
62
  export never interprets Markdown headings as structured history. New file tickets
63
63
  use structured comments and preserve their body when a comment is added. There is
64
64
  no continuous sync, assignee migration, state history or build-history migration.
65
+
66
+ Integration-tree `kind` and `target` are preserved in portable frontmatter.
67
+ Import validates the complete target graph before changing the destination and
68
+ refuses a destination that cannot preserve metadata. It creates or adopts every
69
+ identity, establishes node kinds, then applies targets using the durable id map,
70
+ just like blockers. Input order does not matter. Resuming also restores edges on
71
+ adopted tickets; normal destination validation still guards existing graphs and
72
+ node demotion. Older work-only exports remain valid.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defrex/autobuild",
3
- "version": "0.14.0",
3
+ "version": "1.0.0-beta.0",
4
4
  "description": "Agent-driven software delivery from groomed ticket to merged PR",
5
5
  "repository": {
6
6
  "type": "git",
@@ -144,8 +144,8 @@
144
144
  },
145
145
  "devDependencies": {
146
146
  "@biomejs/biome": "2.5.5",
147
- "@defrex/autobuild-postgres-store": "0.14.0",
148
- "@defrex/autobuild-vercel-sandbox": "0.14.0",
147
+ "@defrex/autobuild-postgres-store": "1.0.0-beta.0",
148
+ "@defrex/autobuild-vercel-sandbox": "1.0.0-beta.0",
149
149
  "@resvg/resvg-js": "2.6.2",
150
150
  "@types/bun": "^1.3.14",
151
151
  "@types/node": "^24.0.0",
@@ -1,3 +1,6 @@
1
+ import { effectiveTreeTarget } from './dashboard/tree'
2
+ import type { BuildStreamSeed } from '../kernel/read-facts'
3
+ import { buildReducer } from '../kernel/reducer'
1
4
  import type { AbEvent } from '../events/catalog'
2
5
  import type { RepositoryEvent } from '../events/repository'
3
6
  import {
@@ -14,8 +17,8 @@ export interface MergeDecision {
14
17
  observedAt: string
15
18
  }
16
19
 
17
- /** Consent pending application is armed; only a current actionable deferral
18
- * or withdrawn consent needs a person. Currency is owned by the kernel. */
20
+ /** Gate deferrals and unsafe forge outcomes remain merge attention.
21
+ * Consent and holds are represented exclusively by consent-ready. */
19
22
  export function mergeDecision(
20
23
  events: AbEvent[],
21
24
  now: Date,
@@ -49,6 +52,7 @@ export function repositoryNeedsAttention(event: RepositoryEvent): boolean {
49
52
  switch (event.type) {
50
53
  case 'harvest.escalated':
51
54
  case 'harvest.recovery-exhausted':
55
+ case 'dispatcher.forge-readiness-failed':
52
56
  case 'dispatcher.config-rejected':
53
57
  return true
54
58
  case 'dispatcher.config-reloaded':
@@ -61,3 +65,22 @@ export function repositoryNeedsAttention(event: RepositoryEvent): boolean {
61
65
  }
62
66
 
63
67
  export { RepositoryAttention, type PersistenceObservation } from '../kernel/repository-attention'
68
+
69
+ export function consentReady(seed: BuildStreamSeed, observedAt: Date) {
70
+ const state = buildReducer.finish(seed.build)
71
+ const episode = seed.consentEpisode
72
+ if (!episode) return null
73
+ return {
74
+ type: 'build.consent-ready' as const,
75
+ observedAt: observedAt.toISOString(),
76
+ target: effectiveTreeTarget(state),
77
+ candidate: state.landing!.decision!.candidate,
78
+ reason: state.landing?.command?.kind === 'hold' ? 'held' : 'consent required',
79
+ branch: seed.branch ?? state.nodeOpening?.branch,
80
+ position: episode.seq,
81
+ }
82
+ }
83
+ export type ConsentReady = NonNullable<ReturnType<typeof consentReady>>
84
+ export function consentIdentity(slug: string, seq: number): string {
85
+ return JSON.stringify(['consent', slug, seq])
86
+ }
@@ -1,3 +1,6 @@
1
+ import { landPreconditions } from '../kernel/landing-readiness'
2
+ import { observeIntegration } from '../kernel/integration-completeness'
3
+ import type { TicketSource } from '../ports/types'
1
4
  import { readBuildFacts } from '../store/reduced-reads'
2
5
  /**
3
6
  * Durable operator controls for one build.
@@ -18,7 +21,7 @@ import { samplePinnedAssets } from '../store/ticket-assets'
18
21
  import type { BuildStore } from '../store/types'
19
22
  import { withSessionlessStore, type StoreOpener } from './store-opening'
20
23
 
21
- const ACTIVE_STATUSES: readonly BuildStatus[] = ['running', 'paused', 'blocked']
24
+ const ACTIVE_STATUSES: readonly BuildStatus[] = ['running', 'collecting', 'paused', 'blocked']
22
25
 
23
26
  /** Retry carries no phase guidance, but the event schema still requires a
24
27
  * nonempty audit answer. The reducer/materializer route on `resolution`, so
@@ -38,6 +41,8 @@ export type AnswerResolutionRequest =
38
41
  | { kind: 'revise-spec'; body: SpecBodySource }
39
42
 
40
43
  export type BuildControlAction =
44
+ | { kind: 'hold' }
45
+ | { kind: 'land' }
41
46
  | { kind: 'pause' }
42
47
  | { kind: 'resume' }
43
48
  | { kind: 'abort' }
@@ -60,6 +65,8 @@ export type BuildControlAction =
60
65
  }
61
66
 
62
67
  export type BuildControlCommand =
68
+ | 'hold'
69
+ | 'land'
63
70
  | 'pause'
64
71
  | 'resume'
65
72
  | 'abort'
@@ -154,6 +161,9 @@ async function appendCommand(
154
161
  const actor = humanActor(user, via)
155
162
  let event: AbEvent
156
163
  switch (command) {
164
+ case 'hold':
165
+ case 'land':
166
+ throw new Error('Landing commands require compare-and-append authorization')
157
167
  case 'pause':
158
168
  event = await store.append(slug, {
159
169
  actor,
@@ -264,43 +274,6 @@ function discardPending(slug: string): BuildControlError {
264
274
  * re-read state each attempt. `activeState` runs before the guard on every
265
275
  * attempt: a queued build (where the discard normally sits) still reports the
266
276
  * existing `inactive` error. */
267
- async function appendConsentCommand(
268
- store: BuildStore,
269
- slug: string,
270
- user: string,
271
- action: 'auto-merge-on' | 'auto-merge-off' | 'toggle-auto-merge',
272
- via?: Via,
273
- ): Promise<BuildControlResult> {
274
- while (true) {
275
- const state = (await readBuildFacts(store, slug)).value.state
276
- activeState(slug, state)
277
- const command =
278
- action === 'toggle-auto-merge'
279
- ? state.autoMerge.requested
280
- ? 'auto-merge-off'
281
- : 'auto-merge-on'
282
- : action
283
- if (command === 'auto-merge-on' && discardInFlight(state)) throw discardPending(slug)
284
- const actor = humanActor(user, via)
285
- // Written out rather than selected into a variable so `appendIfCurrent`'s
286
- // `T extends EventType` infers a concrete payload type in each branch.
287
- const appended =
288
- command === 'auto-merge-on'
289
- ? await store.appendIfCurrent(slug, state.lastSeq, {
290
- actor,
291
- type: 'build.auto-merge-requested',
292
- payload: {},
293
- })
294
- : await store.appendIfCurrent(slug, state.lastSeq, {
295
- actor,
296
- type: 'build.auto-merge-cancelled',
297
- payload: {},
298
- })
299
- if (appended !== null) return { kind: 'command', slug, command, event: appended }
300
- // The stream advanced under us (a racing discard, a fan-out write, a
301
- // runner acknowledgement): loop to re-read and re-check before writing.
302
- }
303
- }
304
277
 
305
278
  function abortPending(slug: string): BuildControlError {
306
279
  return new BuildControlError(
@@ -459,6 +432,7 @@ export interface ControlBuildOpts {
459
432
  /** Delegated-write attribution marker threaded onto every event actor. */
460
433
  via?: Via
461
434
  action: BuildControlAction
435
+ ticketSource?: () => Promise<TicketSource>
462
436
  /** Injected only for --revise-spec-from-ticket. */
463
437
  prepareTicketAssets?: (ref: TicketRef, store: BuildStore, repo: string) => Promise<PinnedAsset[]>
464
438
  readTicketBody?: (ref: TicketRef) => Promise<string>
@@ -513,12 +487,60 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
513
487
  case 'resume':
514
488
  return appendCommand(opts.store, opts.slug, user, opts.action.kind, opts.via)
515
489
 
490
+ case 'hold':
491
+ case 'land': {
492
+ while (true) {
493
+ const facts = (await readBuildFacts(opts.store, opts.slug)).value
494
+ const current = facts.state
495
+ activeState(opts.slug, current)
496
+ if (opts.action.kind === 'land' && discardInFlight(current)) throw discardPending(opts.slug)
497
+ const decision = current.landing?.decision
498
+ if (opts.action.kind === 'land') {
499
+ if (!landPreconditions(current, facts.log.restack))
500
+ throw new Error(
501
+ 'Landing is not ready; wait for current-base verification and finalize before running ab land',
502
+ )
503
+ if (current.kind === 'node') {
504
+ if (!opts.ticketSource)
505
+ throw new Error('Cannot establish node completeness: ticket source unavailable')
506
+ const observed = await observeIntegration(
507
+ opts.store,
508
+ await opts.ticketSource(),
509
+ opts.slug,
510
+ )
511
+ if (
512
+ observed.openChildren.length ||
513
+ observed.diagnostics.length ||
514
+ !observed.contributions.length
515
+ )
516
+ throw new Error(
517
+ 'Node is incomplete; wait for its children and verification before running ab land',
518
+ )
519
+ }
520
+ }
521
+ const actor = humanActor(user, opts.via)
522
+ const event =
523
+ opts.action.kind === 'hold'
524
+ ? await opts.store.appendIfCurrent(opts.slug, current.lastSeq, {
525
+ actor,
526
+ type: 'build.hold-requested',
527
+ payload: {},
528
+ })
529
+ : await opts.store.appendIfCurrent(opts.slug, current.lastSeq, {
530
+ actor,
531
+ type: 'build.land-requested',
532
+ payload: { decisionSeq: decision!.seq },
533
+ })
534
+ if (event) return { kind: 'command', slug: opts.slug, command: opts.action.kind, event }
535
+ }
536
+ throw new Error('Landing command was not recorded')
537
+ }
516
538
  case 'auto-merge-on':
517
539
  case 'auto-merge-off':
518
540
  case 'toggle-auto-merge':
519
- // Consent has its own guarded, compare-and-append write path; the
520
- // outer `activeState` above only short-circuits the common inactive case.
521
- return appendConsentCommand(opts.store, opts.slug, user, opts.action.kind, opts.via)
541
+ throw new Error(
542
+ 'Auto-merge controls are retired; use ab hold or ab land and [[landing]] policy',
543
+ )
522
544
 
523
545
  case 'dashboard-pause': {
524
546
  const pendingPause = state.pendingCommands.some((command) => command.command === 'pause')
@@ -864,6 +886,7 @@ export interface AbBuildControlOpts {
864
886
  exec: Exec
865
887
  slug: string
866
888
  action: BuildControlAction
889
+ ticketSource?: () => Promise<TicketSource>
867
890
  /** Explicit `--store`; selection remains --store > AB_STORE > repo-local. */
868
891
  storeRef?: string
869
892
  /** Injected only for --revise-spec-from-ticket. */
@@ -886,6 +909,7 @@ export async function abBuildControl(opts: AbBuildControlOpts): Promise<BuildCon
886
909
  slug: opts.slug,
887
910
  env: opts.env,
888
911
  action: opts.action,
912
+ ticketSource: opts.ticketSource,
889
913
  ...(opts.readTicketBody !== undefined ? { readTicketBody: opts.readTicketBody } : {}),
890
914
  ...(opts.prepareTicketAssets ? { prepareTicketAssets: opts.prepareTicketAssets } : {}),
891
915
  }),
@@ -96,6 +96,18 @@ export interface ContextManifest {
96
96
  commitRange?: CommitRange
97
97
  /** Reconcile: `{baseSha}` freshly recorded by this attempt's phase start (§15.7). */
98
98
  conflict?: { baseSha: string }
99
+ nodeChange?: {
100
+ owner: string
101
+ transaction: string
102
+ index: number
103
+ sha: string
104
+ build?: string
105
+ foreign: boolean
106
+ }
107
+ replay?: import('../events/payloads').EventPayload<'reconcile.prepared'> & {
108
+ conflicted?: boolean
109
+ needsCompletion: boolean
110
+ }
99
111
  /** Agent-verify: the step's config from the workspace's autobuild.toml (§16.1). */
100
112
  step?: { name: string; config: VerifyStepConfig }
101
113
  /** The feedback this phase occurrence was started with (§15.3, §10). */
@@ -193,7 +205,16 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
193
205
  /** Latest rev when `rev` omitted; silently skips absent kinds — the tree is
194
206
  * a projection of what exists, and the manifest shows what materialized. */
195
207
  async function writeArtifact(desiredPath: string, kind: string, rev?: number): Promise<void> {
196
- const artifact = await store.getArtifact(build, kind, rev)
208
+ const node = state.nodeRestack
209
+ const sourceKind =
210
+ phase === 'reconcile' && node?.conflict && ['spec', 'plan', 'implement-notes'].includes(kind)
211
+ ? `node-source-${node.active!.id}-${node.conflict.index}-${kind}`
212
+ : kind
213
+ const artifact = await store.getArtifact(
214
+ build,
215
+ sourceKind,
216
+ sourceKind === kind ? rev : undefined,
217
+ )
197
218
  if (artifact === null) return
198
219
  const relPath = locate(desiredPath)
199
220
  const target = join(abDir, relPath)
@@ -375,10 +396,34 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
375
396
  }
376
397
  }
377
398
 
378
- if (inputs.commitRange === true && state.implement.commits !== undefined) {
399
+ if (inputs.commitRange === true && state.kind === 'node' && state.integration?.cycle) {
400
+ manifest.commitRange = {
401
+ base: state.integration.cycle.parent,
402
+ head: state.integration.cycle.head,
403
+ }
404
+ } else if (inputs.commitRange === true && state.implement.commits !== undefined) {
379
405
  manifest.commitRange = state.implement.commits
380
406
  }
381
407
 
408
+ if (phase === 'reconcile' && state.nodeRestack?.conflict) {
409
+ const node = state.nodeRestack
410
+ const conflict = node.conflict!
411
+ const change = node.active!.changes[conflict.index]!
412
+ manifest.nodeChange = {
413
+ owner: build,
414
+ transaction: node.active!.id,
415
+ index: conflict.index,
416
+ sha: change.sha,
417
+ build: change.build,
418
+ foreign: change.build === undefined,
419
+ }
420
+ manifest.conflict = { baseSha: conflict.base }
421
+ if (!change.build)
422
+ await writeArtifact(
423
+ 'foreign-change.patch',
424
+ `node-source-${node.active!.id}-${conflict.index}-foreign`,
425
+ )
426
+ }
382
427
  if (inputs.conflict === true) {
383
428
  // `pr.conflicted.baseSha` is the janitor's detection-time evidence. The
384
429
  // runner refreshes the remote base immediately before each actual run and
@@ -387,6 +432,13 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
387
432
  // attempt is authoritative.
388
433
  const baseSha = events.reconcileBases[String(round)]
389
434
  if (baseSha !== undefined) manifest.conflict = { baseSha }
435
+ if (events.reconcileTransaction?.attempt === round) {
436
+ manifest.replay = {
437
+ ...events.reconcileTransaction,
438
+ conflicted: events.reconcileReplay?.conflicted,
439
+ needsCompletion: events.reconcileReplay?.conflicted ?? true,
440
+ }
441
+ }
390
442
  if (manifest.conflict === undefined) {
391
443
  throw new Error(
392
444
  `reconcile@${round} context requires a matching reconcile.started event ` +
@@ -15,6 +15,7 @@ export function dashboardBuildControl(status: EffectiveStatus): DashboardBuildCo
15
15
  case 'paused':
16
16
  case 'blocked':
17
17
  return { key: 'r', action: 'resume', label: 'resume' }
18
+ case 'collecting':
18
19
  case 'queued':
19
20
  case 'resuming':
20
21
  case 'aborting':
@@ -36,8 +37,10 @@ export function buildActionAvailability(build: DashboardBuild): DashboardActionA
36
37
  ...(dashboardBuildControl(build.status)
37
38
  ? { primary: dashboardBuildControl(build.status)!.action }
38
39
  : {}),
39
- abort: ['queued', 'running', 'pausing', 'paused', 'resuming', 'blocked'].includes(build.status),
40
- discard: build.status === 'queued',
40
+ abort: ['queued', 'running', 'collecting', 'pausing', 'paused', 'resuming', 'blocked'].includes(
41
+ build.status,
42
+ ),
43
+ discard: build.kind !== 'integration' && build.status === 'queued',
41
44
  autoMerge: !['aborting', 'cleaning'].includes(build.status),
42
45
  answer: build.blockers.length > 0,
43
46
  }
@@ -46,7 +49,7 @@ export function buildActionAvailability(build: DashboardBuild): DashboardActionA
46
49
  export function repositoryActionAvailability(model: DashboardModel) {
47
50
  return {
48
51
  intake: true,
49
- defaultAutoMerge: true,
52
+ defaultAutoMerge: false,
50
53
  bulkPause: model.builds.some((build) => build.status === 'running'),
51
54
  bulkResume: model.builds.some((build) => build.status === 'paused'),
52
55
  harvestToggle: true,
@@ -0,0 +1,6 @@
1
+ import type { BuildState } from '../../kernel/reducer'
2
+
3
+ export function landingPolicyDisplay(landing: BuildState['landing']): string {
4
+ if (landing?.command?.kind === 'hold') return 'held'
5
+ return landing?.decision?.mode ?? 'policy pending'
6
+ }
@@ -109,6 +109,11 @@ export class LiveRegion {
109
109
  this.paintedRows = rows
110
110
  }
111
111
 
112
+ /** Force the cached frame to repaint after terminal ownership resumes. */
113
+ invalidate(): void {
114
+ this.paintedRows = undefined
115
+ }
116
+
112
117
  /**
113
118
  * Release the region: restore the normal screen, copy the last frame there,
114
119
  * restore the cursor, and stop tracking. Idempotent.