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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/SPEC.md +310 -56
  2. package/bin/ab-build-runner.ts +10 -8
  3. package/docs/architecture.md +177 -23
  4. package/docs/configuration.md +35 -4
  5. package/docs/hosted-service.md +35 -0
  6. package/docs/integration-tree.md +83 -4
  7. package/docs/landing-policy.md +11 -0
  8. package/docs/migration-1.0.md +9 -0
  9. package/docs/operator-api.md +18 -0
  10. package/docs/remote-store-protocol.md +16 -0
  11. package/docs/remote-ticket-protocol.md +5 -0
  12. package/docs/restacking.md +42 -7
  13. package/docs/setup.md +25 -0
  14. package/docs/spec-standard.md +71 -0
  15. package/docs/ticket-dependencies.md +6 -45
  16. package/docs/ticket-migration.md +50 -4
  17. package/package.json +3 -3
  18. package/packages/core/src/cli/attention.ts +4 -1
  19. package/packages/core/src/cli/binary.ts +17 -1
  20. package/packages/core/src/cli/build-control.ts +3 -3
  21. package/packages/core/src/cli/context.ts +53 -1
  22. package/packages/core/src/cli/dashboard/actions.ts +4 -0
  23. package/packages/core/src/cli/dashboard/detail.ts +45 -1
  24. package/packages/core/src/cli/dashboard/facts.ts +7 -2
  25. package/packages/core/src/cli/dashboard/integration-detail.ts +144 -0
  26. package/packages/core/src/cli/dashboard/integration-row.ts +255 -0
  27. package/packages/core/src/cli/dashboard/landing-display.ts +64 -0
  28. package/packages/core/src/cli/dashboard/model.ts +147 -16
  29. package/packages/core/src/cli/dashboard/poll.ts +40 -4
  30. package/packages/core/src/cli/dashboard/render.ts +106 -5
  31. package/packages/core/src/cli/dashboard/transcript.ts +2 -1
  32. package/packages/core/src/cli/dispatch-frontend.ts +11 -0
  33. package/packages/core/src/cli/dispatch-repository-feed.ts +2 -1
  34. package/packages/core/src/cli/dispatch.ts +49 -14
  35. package/packages/core/src/cli/help.ts +17 -1
  36. package/packages/core/src/cli/main.ts +48 -8
  37. package/packages/core/src/cli/publication-settlement.ts +49 -5
  38. package/packages/core/src/cli/repository-status.ts +103 -2
  39. package/packages/core/src/cli/status.ts +24 -1
  40. package/packages/core/src/cli/terminals.ts +94 -93
  41. package/packages/core/src/cli/ticket.ts +35 -11
  42. package/packages/core/src/cli/wait.ts +11 -2
  43. package/packages/core/src/cli/watch.ts +12 -0
  44. package/packages/core/src/config/schema.ts +3 -0
  45. package/packages/core/src/events/catalog.ts +38 -0
  46. package/packages/core/src/events/compatibility.ts +183 -0
  47. package/packages/core/src/events/native-session.ts +13 -0
  48. package/packages/core/src/events/payloads.ts +150 -2
  49. package/packages/core/src/events/policy.ts +210 -0
  50. package/packages/core/src/events/repository.ts +69 -0
  51. package/packages/core/src/integration/harness.ts +4 -4
  52. package/packages/core/src/kernel/__snapshots__/{reducer-registry.test.ts.snap → reducer-accumulator-shapes.json} +4286 -4006
  53. package/packages/core/src/kernel/change-presence.ts +11 -3
  54. package/packages/core/src/kernel/dispatch-capacity.ts +127 -0
  55. package/packages/core/src/kernel/dispatcher-liveness.ts +5 -1
  56. package/packages/core/src/kernel/engine.ts +25 -5
  57. package/packages/core/src/kernel/forge-health.ts +19 -0
  58. package/packages/core/src/kernel/generators/build-log.ts +18 -0
  59. package/packages/core/src/kernel/generators/node-restack-log.ts +1 -1
  60. package/packages/core/src/kernel/generators/repository-journals.ts +10 -0
  61. package/packages/core/src/kernel/guarded-forge.ts +159 -0
  62. package/packages/core/src/kernel/incremental.ts +4 -2
  63. package/packages/core/src/kernel/integration-completeness.ts +108 -9
  64. package/packages/core/src/kernel/integration-landing.ts +5 -4
  65. package/packages/core/src/kernel/janitor-failure.ts +36 -0
  66. package/packages/core/src/kernel/landing-publication.ts +35 -15
  67. package/packages/core/src/kernel/landing-state.ts +7 -0
  68. package/packages/core/src/kernel/leaf-restack-state.ts +1 -1
  69. package/packages/core/src/kernel/log-index.ts +12 -1
  70. package/packages/core/src/kernel/mixed-version.ts +52 -0
  71. package/packages/core/src/kernel/node-landing.ts +14 -11
  72. package/packages/core/src/kernel/node-parent.ts +35 -10
  73. package/packages/core/src/kernel/node-restack-demand.ts +29 -0
  74. package/packages/core/src/kernel/node-restack-state.ts +46 -16
  75. package/packages/core/src/kernel/node-restack-transaction.ts +151 -8
  76. package/packages/core/src/kernel/node-restack.ts +34 -10
  77. package/packages/core/src/kernel/publication.ts +22 -0
  78. package/packages/core/src/kernel/read-deferrals.ts +111 -0
  79. package/packages/core/src/kernel/read-facts.ts +34 -6
  80. package/packages/core/src/kernel/reconcile-restack.ts +23 -2
  81. package/packages/core/src/kernel/reducer-registry.ts +18 -2
  82. package/packages/core/src/kernel/reducer.ts +196 -10
  83. package/packages/core/src/kernel/repository-attention.ts +38 -1
  84. package/packages/core/src/kernel/terminal-guard.ts +11 -4
  85. package/packages/core/src/kernel/ticket-migrations.ts +139 -0
  86. package/packages/core/src/operator/annotations.ts +6 -0
  87. package/packages/core/src/operator/index.ts +2 -0
  88. package/packages/core/src/operator/presentation.ts +5 -0
  89. package/packages/core/src/operator/query.ts +51 -11
  90. package/packages/core/src/operator/registry.ts +17 -1
  91. package/packages/core/src/operator/restack.ts +51 -0
  92. package/packages/core/src/operator/tickets.ts +30 -26
  93. package/packages/core/src/plugin-sdk/index.ts +10 -0
  94. package/packages/core/src/plugins/manifest.ts +1 -1
  95. package/packages/core/src/ports/forge/contract.ts +23 -0
  96. package/packages/core/src/ports/forge/fake.ts +6 -2
  97. package/packages/core/src/ports/forge/git-rewrite.ts +92 -64
  98. package/packages/core/src/ports/forge/github-transport.ts +45 -2
  99. package/packages/core/src/ports/forge/github.ts +56 -17
  100. package/packages/core/src/ports/forge/local-git.ts +7 -2
  101. package/packages/core/src/ports/forge-failure.ts +40 -0
  102. package/packages/core/src/ports/forge-request-context.ts +35 -0
  103. package/packages/core/src/ports/forge-telemetry.ts +16 -0
  104. package/packages/core/src/ports/runner/claude.ts +136 -9
  105. package/packages/core/src/ports/runner/codex.ts +112 -7
  106. package/packages/core/src/ports/runner/contract.ts +78 -0
  107. package/packages/core/src/ports/runner/fake.ts +59 -1
  108. package/packages/core/src/ports/runner/native-cli-fixture.ts +86 -0
  109. package/packages/core/src/ports/runner/native-process-fixture.ts +38 -0
  110. package/packages/core/src/ports/runner/native-session.ts +110 -0
  111. package/packages/core/src/ports/runner/pi-rpc.ts +7 -1
  112. package/packages/core/src/ports/runner/pi.ts +162 -2
  113. package/packages/core/src/ports/tickets/linear.ts +180 -12
  114. package/packages/core/src/ports/tickets/migration.ts +92 -9
  115. package/packages/core/src/ports/types.ts +60 -5
  116. package/packages/core/src/ports/workspace/git-worktree.ts +45 -51
  117. package/packages/core/src/ports/workspace/vercel-sandbox.ts +28 -12
  118. package/packages/core/src/processes/build-child-exit.ts +50 -2
  119. package/packages/core/src/processes/build-child.ts +15 -7
  120. package/packages/core/src/processes/build-runner.ts +909 -213
  121. package/packages/core/src/processes/dispatcher.ts +815 -369
  122. package/packages/core/src/processes/execution-no-progress.ts +15 -0
  123. package/packages/core/src/processes/pause-execution-fixture.ts +37 -0
  124. package/packages/core/src/processes/phase-failure-budget.ts +2 -1
  125. package/packages/core/src/processes/publication-loss.ts +7 -3
  126. package/packages/core/src/processes/repo-view.ts +53 -6
  127. package/packages/core/src/processes/tick-publication.ts +6 -2
  128. package/packages/core/src/runtime-identity.ts +37 -0
  129. package/packages/core/src/store/adapter.ts +4 -2
  130. package/packages/core/src/store/build-scope.ts +9 -0
  131. package/packages/core/src/store/contract.ts +233 -16
  132. package/packages/core/src/store/digest.ts +20 -2
  133. package/packages/core/src/store/local/schema.ts +6 -0
  134. package/packages/core/src/store/local/store.ts +57 -4
  135. package/packages/core/src/store/memory.ts +83 -2
  136. package/packages/core/src/store/new-build.ts +2 -2
  137. package/packages/core/src/store/phase-session.ts +13 -0
  138. package/packages/core/src/store/reduced-reads.ts +43 -4
  139. package/packages/core/src/store/reducer-value-shapes.json +8911 -6344
  140. package/packages/core/src/store/reducer-value-validation.ts +103 -3
  141. package/packages/core/src/store/reducer-values.ts +21 -6
  142. package/packages/core/src/store/remote/client.ts +145 -20
  143. package/packages/core/src/store/remote/index.ts +2 -0
  144. package/packages/core/src/store/remote/protocol.ts +19 -0
  145. package/packages/core/src/store/remote/version.ts +2 -0
  146. package/packages/core/src/store/repo-state-events.ts +5 -2
  147. package/packages/core/src/store/repo-tick.ts +6 -1
  148. package/packages/core/src/store/session-handle.ts +8 -0
  149. package/packages/core/src/store/snapshots.ts +21 -5
  150. package/packages/core/src/store/types.ts +17 -1
  151. package/packages/core/src/testing/dispatch-read-budget.ts +18 -2
  152. package/packages/core/src/testing/index.ts +7 -0
  153. package/packages/core/src/testing/newer-writer.ts +37 -0
  154. package/packages/core/src/testing/reduced-read-budget.ts +3 -0
  155. package/skills/guide/SKILL.md +140 -25
  156. package/skills/guide/references/integration-tree.md +83 -4
  157. package/skills/guide/references/landing-policy.md +11 -0
  158. package/skills/guide/references/migration-1.0.md +9 -0
  159. package/skills/guide/references/operator-api.md +18 -0
  160. package/skills/guide/references/plugin-authoring.md +47 -4
  161. package/skills/guide/references/remote-store-protocol.md +16 -0
  162. package/skills/guide/references/remote-ticket-protocol.md +5 -0
  163. package/skills/guide/references/restacking.md +42 -7
  164. package/skills/guide/references/setup.md +25 -0
  165. package/skills/guide/references/spec-standard.md +71 -0
  166. package/skills/guide/references/ticket-dependencies.md +6 -45
  167. package/skills/guide/references/ticket-migration.md +50 -4
  168. package/skills/implement/SKILL.md +4 -2
  169. package/skills/operate/SKILL.md +63 -6
  170. package/skills/reconcile/SKILL.md +3 -1
  171. package/skills/spec/SKILL.md +62 -40
  172. package/skills/tickets/SKILL.md +15 -43
@@ -25,17 +25,46 @@ verification; reports retain their actual cycle base/head. Conflicted replay
25
25
  runs reconcile and verification, and initial verification cannot be skipped
26
26
  through post-reconcile policy.
27
27
 
28
- Every open node observes its parent and cascades movement to descendants,
29
- including empty nodes without PRs. Movement coalesces onto the newest sample
30
- after an active frozen transaction finishes; no separate throttle is configured.
31
- Unlike clean waiting leaves, nodes must reverify any changed head or parent.
28
+ Nodes observe parent movement durably but restack only on demand: before a
29
+ complete nonempty node verifies; before landing if its parent moved; when queued
30
+ dependency presence requires an ancestor change; on `ab restack <node>`; or on
31
+ accepted re-parenting. There is no eager mode or cadence option. Nested nodes
32
+ need their own demand. Existing frozen transactions, including ones reserved
33
+ before upgrade, finish first; later demand coalesces onto the latest parent.
34
+ Leaves keep verify-entry and awaiting-landing restacks for every target.
35
+
36
+ Presence demand uses change identities, never ticket resolution alone. It follows
37
+ only the path from the nearest proven ancestor source down to the dependent's
38
+ actual destination, processing ancestors first. Unrelated siblings stay idle;
39
+ changes absent from all ancestors cannot trigger a speculative replay. Tickets
40
+ remain queued until presence is observed in their destination.
41
+
42
+ `ab restack <node>` (operator tool `builds.restack`, input `{repo, slug}`) records
43
+ a durable request, coalescing pending demand. It refuses leaves, terminal nodes,
44
+ and unopened nodes. Paused or blocked nodes wait for their normal safety gates.
45
+ A request arriving during replay survives until its parent and required identities
46
+ are covered. Re-parenting invalidates requests for the old destination.
47
+
48
+ Both dashboards show `parent N commits ahead`, `parent current`, or
49
+ `parent distance unknown`. Distance counts commits reachable from the observed
50
+ parent but not the last confirmed contribution base; it is not elapsed time or
51
+ poll count. Samples are invalidated by replay or re-parenting. A stale node
52
+ cannot verify or land; inventory and child landings continue while it collects.
32
53
 
33
54
  Before replacement the kernel publishes retained tips, displaced heads and the
34
55
  temporary change under immutable exact archive refs. `restack.*` facts record
35
56
  preparation, replay, intent, archived replacement, contention and completion.
36
57
  Unpublished request/loss records alone cannot preserve objects from a released
37
- sandbox. Publication uses exact expected-head CAS; contention retains evidence
38
- and retries without overwriting another writer. Remote guests park for trusted
58
+ sandbox. The forge is authoritative for publication: after a push or on recovery,
59
+ its branch head must equal the intended SHA before completion. Local refs are
60
+ caches refreshed without an expected-old guard after confirmation; checkout files
61
+ are untouched. Local-git's shared database is the forge and retains authoritative
62
+ CAS. Remote publication uses exact expected-head leases and durable reservations; contention retains evidence
63
+ and retries without overwriting another writer. An overtaken successful guarded
64
+ write can retain its factual receipt, but unconfirmed candidate ancestry cannot
65
+ prove a write or promote a base. Contribution ownership uses recorded boundaries,
66
+ stable build identities and confirmed foreign rewrite aliases, never a merge-base
67
+ against the current destination. Remote guests park for trusted
39
68
  publication after teardown. Historical merge reconciliations keep their original
40
69
  interpretation and supply a promoted contribution base for later replay.
41
70
 
@@ -52,7 +81,8 @@ child landings. Reservations freeze expected head, parent, contribution boundary
52
81
  archives, changes and merge proofs. Lease expiry recovers the same operation,
53
82
  not a competing one. Prepared/conflicted/replayed item receipts, publication
54
83
  intent, proven replacement and settlement distinguish each recovery boundary.
55
- Inventory exposes source identities, node-owned foreign commits, active operation,
84
+ Inventory retains its sampled source boundary even while the confirmed parent
85
+ boundary stays unchanged. It exposes source identities, node-owned foreign commits, active operation,
56
86
  conflict item and unsafe merge evidence.
57
87
 
58
88
  Only a conflicted item attaches a reconcile runner. It receives the original
@@ -77,3 +107,8 @@ never preserves merge topology or decomposes an unsafe merge automatically.
77
107
 
78
108
  See [integration trees](integration-tree.md), [landing](landing-policy.md), and
79
109
  [migration](migration-1.0.md).
110
+
111
+ Native cancellation receipts are candidate- and operation-specific. Publication
112
+ retries confirm forge state before reusing a receipt; external re-enables require
113
+ another confirmed cancellation. Classified transient landing failures retain
114
+ retry eligibility and recheck authorization after repository forge cooldown.
package/docs/setup.md CHANGED
@@ -156,6 +156,27 @@ Vercel team/project credential set; provide separate private-clone credentials;
156
156
  use an HTTPS GitHub origin and hosted Store; authorize the Store token; or commit
157
157
  and push the selected base branch.
158
158
 
159
+ ## Keep per-build records in separate fragments
160
+
161
+ When a repository keeps per-build records, such as changelog entries, write a
162
+ separate fragment file for each build and assemble the consolidated record at
163
+ release. For example, use distinct filenames per build (these names are
164
+ illustrative):
165
+
166
+ ```text
167
+ changelog.d/
168
+ build-alpha.md
169
+ build-beta.md
170
+ CHANGELOG.md # assembled from the fragments at release
171
+ ```
172
+
173
+ Shared append-only files are an anti-pattern for finalize steps. Under the
174
+ integration tree, independent builds that append to the same shared lines can
175
+ conflict when their commits are replayed onto a destination that already has
176
+ other entries, including during restacks and node cascades. Each conflicting
177
+ replay costs an agent reconcile session. Separate fragment files remove that
178
+ shared edit surface; the repository owns the release-time assembly tooling.
179
+
159
180
  ## Repository identity is the origin, not a checkout path
160
181
 
161
182
  Repository identity in the Store, dispatcher, `ab builds`, `ab build status`,
@@ -520,3 +541,7 @@ gate. External orchestrators follow these through `ab watch` with no slugs or an
520
541
  explicit repository watch; `ab wait` remains build-only. The dashboard and operator
521
542
  repository query retain all failures for that run. After correcting settings or
522
543
  access, revalidate and restart dispatch to refresh its startup diagnostics.
544
+
545
+ Changing the connected ticket source does not itself migrate in-flight builds.
546
+ Follow [ticket migration](ticket-migration.md), keeping the existing BuildStore
547
+ and recording continuity before resuming build-related ticket writes.
@@ -54,6 +54,77 @@ evidence is not.
54
54
 
55
55
  ---
56
56
 
57
+ ## Sizing and splitting
58
+
59
+ Every build pays a fixed cost no matter how small its diff: spec, plan and
60
+ plan review, code review, the repository's full verify suite, finalize,
61
+ landing, and a restack for everything queued behind it. Ten small tickets pay
62
+ that cost ten times, and a blocker chain pays it in series. Prefer fewer,
63
+ larger tickets: one ticket per coherent change, as large as one plan and one
64
+ review pass can hold without the quality bar slipping.
65
+
66
+ A ticket is the right size when its acceptance criteria describe one feature
67
+ or fix a reviewer can judge in a single pass, one plan can cover it without
68
+ deferring a design decision to a later build, and its out-of-scope list is
69
+ short and obvious. It is too big when its criteria fall into groups that share
70
+ no behavior, when part of it waits on a decision nobody has made, or when its
71
+ parts need different landing — one can ship now while another needs consent
72
+ or must wait.
73
+
74
+ Do not split:
75
+
76
+ - by layer (schema, then API, then UI) when the layers make one behavior
77
+ change;
78
+ - into "refactor, then feature" unless the refactor is valuable and safe on
79
+ its own;
80
+ - to make progress visible, or because the spec got long. A long spec with
81
+ clear criteria is fine.
82
+
83
+ ### Cut along seams
84
+
85
+ A seam decides where to cut once a split is justified; it is not a reason to
86
+ split. A full-stack change that crosses an API boundary stays one ticket
87
+ unless its size says otherwise.
88
+
89
+ When a feature does need several tickets, find the seams before deciding the
90
+ cut: places where the code already has a narrow, stable contract between
91
+ parts — a port or adapter interface, a schema or event type, a wire protocol,
92
+ a CLI command's output, a module's public API. Read the code to find them;
93
+ don't guess. Put each ticket on one side of a seam.
94
+
95
+ A cut at a seam pays twice:
96
+
97
+ - **Fewer conflicts.** Tickets on opposite sides of a contract touch
98
+ different code, so they build in parallel and restack cleanly. Two tickets
99
+ that would edit the same functions are one ticket, or a blocker chain.
100
+ - **Testability.** The contract is the test boundary. Each side is verified
101
+ against it — the provider by contract tests, the consumer against a fake or
102
+ fixture — so neither build needs the other to prove it works.
103
+
104
+ If no seam exists where the work divides, keep it as one ticket, or make the
105
+ first ticket establish the contract with tests at the boundary and block the
106
+ tickets on either side of it until it lands. After that, they can build
107
+ concurrently.
108
+
109
+ State the seam in each ticket as behavior, not structure: what the contract
110
+ promises observably (the event, the command output, the protocol response) is
111
+ a fair acceptance criterion on both sides; file names and signatures still
112
+ belong to the planner. Record in Evidence why the cut falls where it does, so
113
+ a planner reading one ticket knows what its siblings own.
114
+
115
+ ### Keep the blocker graph wide
116
+
117
+ A split feature takes as long as its longest blocker chain, not as long as
118
+ its ticket count. A wave of independent tickets finishes in about one build's
119
+ time; the same tickets in a chain take one build per link. Prefer cuts that
120
+ let tickets start together. When one ticket must land first — usually the one
121
+ that establishes a shared contract — keep it to that contract and its tests,
122
+ so the wave behind it starts sooner, and fold nothing unrelated into it.
123
+ Add a blocker only for a real prerequisite, never to express a preferred
124
+ order.
125
+
126
+ ---
127
+
57
128
  ## Immutability during a build
58
129
 
59
130
  The spec is the build's contract artifact (kind `spec`, revision 0). It
@@ -60,49 +60,10 @@ and claims the ticket only after they resolve and other readiness gates pass.
60
60
 
61
61
  ## Node tickets and targets
62
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.
63
+ Read [nodes and targets](integration-tree.md) for lifecycle, validation and
64
+ source storage, and [choosing a destination](integration-tree.md#choosing-a-destination)
65
+ when filing a feature set. Blockers order work independently of landing targets;
66
+ landing authorization follows the repository's matched policy.
106
67
 
107
68
  ## When a blocker resolves
108
69
 
@@ -117,8 +78,8 @@ an open or aborted node, or ambiguous newest build generations remain queued.
117
78
  Older successful generations are never substituted for the newest build.
118
79
 
119
80
  - 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.
81
+ - Ancestor: the change lands into an ancestor, then presence demand restacks only the required path to the target.
82
+ - Sibling: the blocking node lands into their common ancestor, then presence demand reaches the target through the minimal ancestor path.
122
83
  - Descendant: the blocking node lands into the dependent's target ancestor.
123
84
 
124
85
  Blockers that never had a build, and repositories without nodes, retain the
@@ -4,8 +4,9 @@ Export and import use the ordinary file ticket layout. They operate on tickets
4
4
  and current attachments through the ticket source; neither command contacts the
5
5
  forge. File and hosted sources support import. Linear supports export only.
6
6
 
7
- 1. Pause intake and stop other ticket writers for the cutover. Import preflight
8
- does not reserve numbers against concurrent writers.
7
+ 1. Pause intake and quiesce build-related ticket writes and other ticket writers
8
+ for the cutover. In-flight builds need not be aborted. Import preflight does
9
+ not reserve numbers against concurrent writers.
9
10
  2. With the old `[tickets]` configuration, run `ab ticket export /path/to/export`.
10
11
  The destination must be absent or empty. Export reads every state, including
11
12
  archived Linear tickets and empty discoverable states, and publishes the
@@ -14,8 +15,20 @@ forge. File and hosted sources support import. Linear supports export only.
14
15
  hosted ticket service. Keep the export directory intact.
15
16
  4. Run `ab ticket import /path/to/export`. Inspect its printed ticket and state
16
17
  mappings and `/path/to/export/.ab-import-map.json`.
17
- 5. Inspect ticket bodies, labels, blockers, comments and attachments in the new
18
- source. Confirm lifecycle configuration and the ready gate, then resume intake.
18
+ 5. Import records a durable source/ID mapping in the same BuildStore and repository
19
+ that hold the existing builds, after tickets, metadata and assets finish.
20
+ Keep that BuildStore/repository identity through the cutover.
21
+ 6. Inspect ticket bodies, labels, blockers, comments and attachments in the new
22
+ source. Confirm lifecycle configuration and the ready gate, then resume builds and intake.
23
+
24
+ Linear export reads full ticket details in batches and prints `read X/Y tickets`.
25
+ The total is shown as pending until inventory discovery finishes. If Linear reports
26
+ a rate limit with a usable future reset time, export prints the wait time, waits
27
+ until that reset, and retries the failed read while retaining completed pages.
28
+ Without a usable reset time, export fails immediately. A running dispatcher and
29
+ other clients authenticated as the same API user share the API budget, so they
30
+ can cause additional waits. Interrupting export with Ctrl-C publishes nothing;
31
+ the destination stays absent or empty until all ticket and attachment reads succeed.
19
32
 
20
33
  Both commands also accept
21
34
  `--store <ref>` to reach legacy BuildStore attachments. Keep the old store available
@@ -70,3 +83,36 @@ identity, establishes node kinds, then applies targets using the durable id map,
70
83
  just like blockers. Input order does not matter. Resuming also restores edges on
71
84
  adopted tickets; normal destination validation still guards existing graphs and
72
85
  node demotion. Older work-only exports remain valid.
86
+
87
+ ## In-flight builds
88
+
89
+ A recorded migration resolves old source-qualified ticket references through the
90
+ new source, including remapped IDs. Completeness, child targeting, capacity
91
+ ancestry, claimed target checks, lifecycle transitions and notices use that
92
+ mapping. Historical build events and ticket references remain unchanged. Moves
93
+ can chain across sources; mappings are never applied backward. A source switch
94
+ alone establishes no continuity. Missing migration evidence or an uncovered ID
95
+ fails closed and names the build and original ticket when operating on that
96
+ build or its frozen membership. Uncovered historical builds stay in their
97
+ original namespace during history searches; they cannot alias current tickets
98
+ or block unrelated intake. Separate trackers with the
99
+ same adapter name cannot be distinguished by historical references; this does
100
+ not establish continuity between them.
101
+
102
+ When using the export directory directly as the configured file tracker, run
103
+ `ab ticket migration record /path/to/export [--store <ref>]`. This verifies the
104
+ manifest inventory and creation keys against the destination and records identity
105
+ mappings for the original manifest IDs, without importing tickets. Additional
106
+ tickets filed in the directory after export are allowed and are not included in
107
+ the mapping. Every original ID must still exist with its recorded creation key.
108
+ Preserve `.ab-migration.json` for this step;
109
+ the tracker itself can operate without it. `.ab-import-map.json` is progress
110
+ information, never proof of continuity. Repeating an identical recording is safe;
111
+ conflicting evidence is refused.
112
+
113
+ Import is not transactional across ticket and build services. A partial import
114
+ records no continuity; rerun with the same directory to adopt by creation key.
115
+ If tickets finish but journal recording fails, the command reports that boundary:
116
+ rerun the same command to finish recording before resuming builds. The migration
117
+ journal belongs to the selected BuildStore even when ticket assets live on an
118
+ independent hosted service. Validate the destination configuration before resume.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defrex/autobuild",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.3",
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": "1.0.0-beta.1",
148
- "@defrex/autobuild-vercel-sandbox": "1.0.0-beta.1",
147
+ "@defrex/autobuild-postgres-store": "1.0.0-beta.3",
148
+ "@defrex/autobuild-vercel-sandbox": "1.0.0-beta.3",
149
149
  "@resvg/resvg-js": "2.6.2",
150
150
  "@types/bun": "^1.3.14",
151
151
  "@types/node": "^24.0.0",
@@ -40,7 +40,10 @@ export function mergeDecisionFromFacts(
40
40
 
41
41
  export function buildNeedsAttention(events: AbEvent[], state: BuildState): boolean {
42
42
  return (
43
- (state.openEscalations?.length ?? 0) > 0 || mergeDecision(events, new Date(0), state) !== null
43
+ state.janitor?.attention === true ||
44
+ (state.compatibility?.decisiveFacts ?? 0) > 0 ||
45
+ (state.openEscalations?.length ?? 0) > 0 ||
46
+ mergeDecision(events, new Date(0), state) !== null
44
47
  )
45
48
  }
46
49
 
@@ -1,3 +1,6 @@
1
+ import { guardForge } from '../kernel/guarded-forge'
2
+ import { scopeLocalStoreToPhaseSession } from '../store/phase-session'
3
+ import { openProductionStore } from './store-opening'
1
4
  /**
2
5
  * Shared wiring for the `ab` process entry points. Production calls this with
3
6
  * argv only; the repo-local hot entry may additionally supply a per-paint
@@ -190,8 +193,21 @@ export async function runBinary(
190
193
  return 1
191
194
  }
192
195
 
193
- const store = openProductionSessionStore(cliEnv)
196
+ const kernelStore = openProductionStore(cliEnv.store, cliEnv.token)
197
+ const store = scopeLocalStoreToPhaseSession(kernelStore, {
198
+ kind: 'build',
199
+ id: cliEnv.build,
200
+ session: cliEnv.session,
201
+ })
194
202
  try {
203
+ const record = await store.getBuild(cliEnv.build)
204
+ if (record)
205
+ forge = guardForge(forge, {
206
+ store: kernelStore,
207
+ repo: record.repo,
208
+ name: forge.name,
209
+ wait: true,
210
+ })
195
211
  return await runCli(argv, {
196
212
  ...unscopedDeps,
197
213
  store,
@@ -435,7 +435,7 @@ export interface ControlBuildOpts {
435
435
  ticketSource?: () => Promise<TicketSource>
436
436
  /** Injected only for --revise-spec-from-ticket. */
437
437
  prepareTicketAssets?: (ref: TicketRef, store: BuildStore, repo: string) => Promise<PinnedAsset[]>
438
- readTicketBody?: (ref: TicketRef) => Promise<string>
438
+ readTicketBody?: (ref: TicketRef, store: BuildStore, repo: string) => Promise<string>
439
439
  }
440
440
 
441
441
  /** Apply one control against a freshly reduced build log. */
@@ -642,7 +642,7 @@ export async function controlBuild(opts: ControlBuildOpts): Promise<BuildControl
642
642
  'ticket body reader is unavailable for --revise-spec-from-ticket',
643
643
  )
644
644
  }
645
- body = await opts.readTicketBody(record.ticket)
645
+ body = await opts.readTicketBody(record.ticket, opts.store, record.repo)
646
646
  if (record.ticket.source === 'hosted' && !opts.prepareTicketAssets) {
647
647
  throw new BuildControlError(
648
648
  'ticket-unavailable',
@@ -891,7 +891,7 @@ export interface AbBuildControlOpts {
891
891
  storeRef?: string
892
892
  /** Injected only for --revise-spec-from-ticket. */
893
893
  prepareTicketAssets?: (ref: TicketRef, store: BuildStore, repo: string) => Promise<PinnedAsset[]>
894
- readTicketBody?: (ref: TicketRef) => Promise<string>
894
+ readTicketBody?: (ref: TicketRef, store: BuildStore, repo: string) => Promise<string>
895
895
  /** Injectable adapter seam for unit tests. */
896
896
  openStore?: StoreOpener
897
897
  }
@@ -1,3 +1,4 @@
1
+ import { compatibilityDiagnostic } from '../kernel/mixed-version'
1
2
  import { readBuildFacts, type CurrentBuildFacts } from '../store/reduced-reads'
2
3
  /**
3
4
  * The `ab context` materializer (SPEC §8.3): a phase-scoped hydration of the
@@ -66,6 +67,8 @@ export type MaterializedEntry = ArtifactRef | 'derived'
66
67
  * commands validate with, so skills are self-checking.
67
68
  */
68
69
  export interface ContextManifest {
70
+ compatibility?: import('../events/compatibility').CompatibilityState
71
+ compatibilityDiagnostic?: string
69
72
  build: string
70
73
  phase: Phase
71
74
  round: number
@@ -160,7 +163,29 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
160
163
  const { build, phase, round } = env
161
164
  const spec = phaseSpecFor(phase)
162
165
  const inputs = spec.inputs
163
- const events = (await readBuildFacts(store, build)).value
166
+ let events: CurrentBuildFacts
167
+ try {
168
+ events = (await readBuildFacts(store, build)).value
169
+ } catch (error) {
170
+ try {
171
+ await store.append(build, {
172
+ actor: KERNEL,
173
+ type: 'session.build-read-failed',
174
+ payload: {
175
+ session: env.session,
176
+ phase,
177
+ round,
178
+ operation: 'context',
179
+ reason: 'own-build-read',
180
+ diagnostic:
181
+ (error instanceof Error ? error.message : String(error)).trim() || 'build read failed',
182
+ },
183
+ })
184
+ } catch {
185
+ /* Preserve the original read error when evidence cannot be written. */
186
+ }
187
+ throw error
188
+ }
164
189
  const state = events.state
165
190
 
166
191
  // Preserve legacy tracked scratch exactly while replacing disposable files.
@@ -224,6 +249,12 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
224
249
  }
225
250
 
226
251
  const manifest: ContextManifest = {
252
+ ...(state.compatibility.unknownFacts
253
+ ? {
254
+ compatibility: state.compatibility,
255
+ compatibilityDiagnostic: compatibilityDiagnostic(state.compatibility),
256
+ }
257
+ : {}),
227
258
  build,
228
259
  phase,
229
260
  round,
@@ -396,6 +427,27 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
396
427
  }
397
428
  }
398
429
 
430
+ // Read-deferral guidance repairs access for this same execution occurrence,
431
+ // including reviewers, which have no producer-feedback carrier.
432
+ if (manifest.feedback === undefined && (phase === 'plan-review' || phase === 'code-review')) {
433
+ const latest = state.answeredEscalations
434
+ .filter(
435
+ (item) =>
436
+ item.deferral === 'own-build-read' &&
437
+ item.resolution === 'guidance' &&
438
+ item.phase === phase &&
439
+ item.round === round,
440
+ )
441
+ .at(-1)
442
+ if (latest) {
443
+ manifest.feedback = { guidance: { escalation: latest.id, answer: latest.answer } }
444
+ await writeDerived(
445
+ 'guidance.json',
446
+ `${JSON.stringify(manifest.feedback.guidance, null, 2)}\n`,
447
+ )
448
+ }
449
+ }
450
+
399
451
  if (inputs.commitRange === true && state.kind === 'node' && state.integration?.cycle) {
400
452
  manifest.commitRange = {
401
453
  base: state.integration.cycle.parent,
@@ -60,3 +60,7 @@ export function repositoryActionAvailability(model: DashboardModel) {
60
60
  export function harvestActionAvailability(harvest: DashboardHarvest | undefined) {
61
61
  return { resume: harvest?.action === 'resume', acknowledge: harvest?.action === 'acknowledge' }
62
62
  }
63
+
64
+ /** Shared explanation for the two operator frontends. */
65
+ export const pauseResumeHelp =
66
+ 'Pause stops the live session immediately; resume continues where it stopped when supported. Remote or unsupported sessions rerun fresh.'
@@ -15,7 +15,11 @@ export interface DashboardSession {
15
15
  runtime: string
16
16
  model?: string
17
17
  startedSeq: number
18
- status: 'open' | 'ended' | 'reclaimed'
18
+ status: 'open' | 'ended' | 'reclaimed' | 'suspended' | 'resumed'
19
+ predecessor?: string
20
+ root?: string
21
+ cause?: 'shutdown' | 'pause' | 'runner-loss'
22
+ fallbackReason?: string
19
23
  usage?: SessionUsage
20
24
  transcript?: { kind: string; rev: number }
21
25
  reclaimedBy?: { instance: string; resumedFromSeq: number }
@@ -50,6 +54,15 @@ export function projectSessions(
50
54
 
51
55
  for (const event of events) {
52
56
  if (event.type === 'session.started') {
57
+ const predecessor = event.payload.continuation?.predecessor
58
+ if (predecessor) {
59
+ const previous = open.get(predecessor)
60
+ if (previous) {
61
+ previous.status = 'reclaimed'
62
+ previous.streamStatus = 'closed'
63
+ open.delete(predecessor)
64
+ }
65
+ }
53
66
  const record = streamsByLabel.get(`session:${event.payload.session}`)
54
67
  const session: DashboardSession = {
55
68
  id: event.payload.session,
@@ -60,6 +73,13 @@ export function projectSessions(
60
73
  ...(event.payload.model !== undefined ? { model: event.payload.model } : {}),
61
74
  startedSeq: event.seq,
62
75
  status: 'open',
76
+ ...(event.payload.continuation
77
+ ? {
78
+ predecessor: event.payload.continuation.predecessor,
79
+ root: event.payload.continuation.root,
80
+ cause: event.payload.continuation.cause,
81
+ }
82
+ : {}),
63
83
  // The store's records are authoritative when available; without them
64
84
  // the pairing degrades gracefully (open until `session.ended`).
65
85
  ...(record !== undefined
@@ -73,6 +93,30 @@ export function projectSessions(
73
93
  open.set(session.id, session)
74
94
  continue
75
95
  }
96
+ if (event.type === 'session.resume-fallback' && !event.payload.stale) {
97
+ const current = sessions.find((s) => s.id === event.payload.session)
98
+ if (current) current.fallbackReason = event.payload.reason
99
+ continue
100
+ }
101
+ if (event.type === 'session.resumed') {
102
+ if (!event.payload.stale) {
103
+ const current = open.get(event.payload.session)
104
+ if (current) current.status = 'resumed'
105
+ }
106
+ continue
107
+ }
108
+ if (event.type === 'session.suspended') {
109
+ const current = open.get(event.payload.session)
110
+ if (current) {
111
+ current.status = 'suspended'
112
+ current.cause = event.payload.cause
113
+ current.transcript = event.payload.transcript
114
+ current.usage = event.payload.usage
115
+ current.streamStatus = 'closed'
116
+ open.delete(current.id)
117
+ }
118
+ continue
119
+ }
76
120
  if (event.type !== 'session.ended') continue
77
121
  const started = open.get(event.payload.session)
78
122
  if (started === undefined) continue
@@ -14,7 +14,7 @@ import type { AbEvent } from '../../events/catalog'
14
14
  import { defineReducer } from '../../kernel/incremental'
15
15
  import { verifyPhase } from '../../ontology'
16
16
 
17
- export const DASHBOARD_FACTS_REDUCER_VERSION = 1
17
+ export const DASHBOARD_FACTS_REDUCER_VERSION = 2
18
18
 
19
19
  /** One phase occurrence's wall-clock span, keyed by phase. `startSeq` is the
20
20
  * seq of the `*.started` event, so callers can scope by the same seq
@@ -40,7 +40,10 @@ export interface DispatchFailureFact {
40
40
  /** Max seq per round of one loop output event. */
41
41
  export type RoundSeqs = Record<string, number>
42
42
 
43
- type SessionEvent = Extract<AbEvent, { type: 'session.started' | 'session.ended' }>
43
+ type SessionEvent = Extract<
44
+ AbEvent,
45
+ { type: 'session.started' | 'session.ended' | 'session.suspended' | 'session.resumed' }
46
+ >
44
47
 
45
48
  export interface DashboardFacts {
46
49
  /** Seq of the latest event of each queued-row kind (`undefined` until seen). */
@@ -187,6 +190,8 @@ export const dashboardFactsReducer = defineReducer<DashboardFacts, AbEvent, Dash
187
190
  error: event.payload.error,
188
191
  }
189
192
  break
193
+ case 'session.suspended':
194
+ case 'session.resumed':
190
195
  case 'session.started':
191
196
  case 'session.ended':
192
197
  acc.sessionEvents.push(event)