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

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 (158) hide show
  1. package/SPEC.md +285 -53
  2. package/bin/ab-build-runner.ts +10 -8
  3. package/docs/architecture.md +173 -23
  4. package/docs/configuration.md +35 -4
  5. package/docs/hosted-service.md +35 -0
  6. package/docs/integration-tree.md +81 -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 +11 -0
  11. package/docs/restacking.md +42 -7
  12. package/docs/setup.md +21 -0
  13. package/docs/ticket-dependencies.md +6 -45
  14. package/package.json +3 -3
  15. package/packages/core/src/cli/attention.ts +4 -1
  16. package/packages/core/src/cli/binary.ts +17 -1
  17. package/packages/core/src/cli/context.ts +53 -1
  18. package/packages/core/src/cli/dashboard/actions.ts +4 -0
  19. package/packages/core/src/cli/dashboard/detail.ts +45 -1
  20. package/packages/core/src/cli/dashboard/facts.ts +7 -2
  21. package/packages/core/src/cli/dashboard/integration-detail.ts +142 -0
  22. package/packages/core/src/cli/dashboard/integration-row.ts +248 -0
  23. package/packages/core/src/cli/dashboard/landing-display.ts +64 -0
  24. package/packages/core/src/cli/dashboard/model.ts +140 -16
  25. package/packages/core/src/cli/dashboard/poll.ts +40 -4
  26. package/packages/core/src/cli/dashboard/render.ts +106 -5
  27. package/packages/core/src/cli/dashboard/transcript.ts +2 -1
  28. package/packages/core/src/cli/dispatch-frontend.ts +6 -0
  29. package/packages/core/src/cli/dispatch.ts +44 -14
  30. package/packages/core/src/cli/help.ts +16 -1
  31. package/packages/core/src/cli/main.ts +37 -0
  32. package/packages/core/src/cli/publication-settlement.ts +49 -5
  33. package/packages/core/src/cli/repository-status.ts +97 -2
  34. package/packages/core/src/cli/status.ts +24 -1
  35. package/packages/core/src/cli/terminals.ts +94 -93
  36. package/packages/core/src/cli/wait.ts +11 -2
  37. package/packages/core/src/cli/watch.ts +12 -0
  38. package/packages/core/src/config/schema.ts +3 -0
  39. package/packages/core/src/events/catalog.ts +38 -0
  40. package/packages/core/src/events/compatibility.ts +183 -0
  41. package/packages/core/src/events/native-session.ts +13 -0
  42. package/packages/core/src/events/payloads.ts +148 -2
  43. package/packages/core/src/events/policy.ts +209 -0
  44. package/packages/core/src/events/repository.ts +48 -0
  45. package/packages/core/src/integration/harness.ts +4 -4
  46. package/packages/core/src/kernel/__snapshots__/{reducer-registry.test.ts.snap → reducer-accumulator-shapes.json} +771 -538
  47. package/packages/core/src/kernel/change-presence.ts +4 -2
  48. package/packages/core/src/kernel/dispatch-capacity.ts +119 -0
  49. package/packages/core/src/kernel/dispatcher-liveness.ts +5 -1
  50. package/packages/core/src/kernel/engine.ts +25 -5
  51. package/packages/core/src/kernel/forge-health.ts +19 -0
  52. package/packages/core/src/kernel/generators/build-log.ts +18 -0
  53. package/packages/core/src/kernel/generators/node-restack-log.ts +1 -1
  54. package/packages/core/src/kernel/generators/repository-journals.ts +10 -0
  55. package/packages/core/src/kernel/guarded-forge.ts +159 -0
  56. package/packages/core/src/kernel/incremental.ts +4 -2
  57. package/packages/core/src/kernel/integration-completeness.ts +61 -0
  58. package/packages/core/src/kernel/integration-landing.ts +5 -4
  59. package/packages/core/src/kernel/janitor-failure.ts +36 -0
  60. package/packages/core/src/kernel/landing-publication.ts +35 -15
  61. package/packages/core/src/kernel/landing-state.ts +7 -0
  62. package/packages/core/src/kernel/leaf-restack-state.ts +1 -1
  63. package/packages/core/src/kernel/log-index.ts +12 -1
  64. package/packages/core/src/kernel/mixed-version.ts +52 -0
  65. package/packages/core/src/kernel/node-landing.ts +14 -11
  66. package/packages/core/src/kernel/node-restack-demand.ts +29 -0
  67. package/packages/core/src/kernel/node-restack-state.ts +46 -16
  68. package/packages/core/src/kernel/node-restack-transaction.ts +151 -8
  69. package/packages/core/src/kernel/node-restack.ts +34 -10
  70. package/packages/core/src/kernel/publication.ts +22 -0
  71. package/packages/core/src/kernel/read-deferrals.ts +111 -0
  72. package/packages/core/src/kernel/read-facts.ts +27 -6
  73. package/packages/core/src/kernel/reconcile-restack.ts +23 -2
  74. package/packages/core/src/kernel/reducer-registry.ts +15 -2
  75. package/packages/core/src/kernel/reducer.ts +196 -10
  76. package/packages/core/src/kernel/repository-attention.ts +38 -1
  77. package/packages/core/src/kernel/terminal-guard.ts +11 -4
  78. package/packages/core/src/operator/annotations.ts +6 -0
  79. package/packages/core/src/operator/index.ts +2 -0
  80. package/packages/core/src/operator/presentation.ts +5 -0
  81. package/packages/core/src/operator/query.ts +45 -11
  82. package/packages/core/src/operator/registry.ts +17 -1
  83. package/packages/core/src/operator/restack.ts +51 -0
  84. package/packages/core/src/plugin-sdk/index.ts +10 -0
  85. package/packages/core/src/plugins/manifest.ts +1 -1
  86. package/packages/core/src/ports/forge/contract.ts +23 -0
  87. package/packages/core/src/ports/forge/fake.ts +6 -2
  88. package/packages/core/src/ports/forge/git-rewrite.ts +92 -64
  89. package/packages/core/src/ports/forge/github-transport.ts +45 -2
  90. package/packages/core/src/ports/forge/github.ts +56 -17
  91. package/packages/core/src/ports/forge/local-git.ts +7 -2
  92. package/packages/core/src/ports/forge-failure.ts +40 -0
  93. package/packages/core/src/ports/forge-request-context.ts +35 -0
  94. package/packages/core/src/ports/forge-telemetry.ts +16 -0
  95. package/packages/core/src/ports/runner/claude.ts +136 -9
  96. package/packages/core/src/ports/runner/codex.ts +112 -7
  97. package/packages/core/src/ports/runner/contract.ts +78 -0
  98. package/packages/core/src/ports/runner/fake.ts +59 -1
  99. package/packages/core/src/ports/runner/native-cli-fixture.ts +86 -0
  100. package/packages/core/src/ports/runner/native-process-fixture.ts +38 -0
  101. package/packages/core/src/ports/runner/native-session.ts +110 -0
  102. package/packages/core/src/ports/runner/pi-rpc.ts +7 -1
  103. package/packages/core/src/ports/runner/pi.ts +162 -2
  104. package/packages/core/src/ports/types.ts +53 -5
  105. package/packages/core/src/ports/workspace/git-worktree.ts +45 -51
  106. package/packages/core/src/ports/workspace/vercel-sandbox.ts +28 -12
  107. package/packages/core/src/processes/build-child-exit.ts +50 -2
  108. package/packages/core/src/processes/build-child.ts +15 -7
  109. package/packages/core/src/processes/build-runner.ts +909 -213
  110. package/packages/core/src/processes/dispatcher.ts +652 -334
  111. package/packages/core/src/processes/execution-no-progress.ts +15 -0
  112. package/packages/core/src/processes/pause-execution-fixture.ts +37 -0
  113. package/packages/core/src/processes/phase-failure-budget.ts +2 -1
  114. package/packages/core/src/processes/publication-loss.ts +7 -3
  115. package/packages/core/src/processes/repo-view.ts +53 -6
  116. package/packages/core/src/processes/tick-publication.ts +6 -2
  117. package/packages/core/src/runtime-identity.ts +37 -0
  118. package/packages/core/src/store/adapter.ts +4 -2
  119. package/packages/core/src/store/build-scope.ts +9 -0
  120. package/packages/core/src/store/contract.ts +203 -16
  121. package/packages/core/src/store/digest.ts +20 -2
  122. package/packages/core/src/store/local/schema.ts +6 -0
  123. package/packages/core/src/store/local/store.ts +57 -4
  124. package/packages/core/src/store/memory.ts +83 -2
  125. package/packages/core/src/store/new-build.ts +2 -2
  126. package/packages/core/src/store/phase-session.ts +13 -0
  127. package/packages/core/src/store/reduced-reads.ts +43 -4
  128. package/packages/core/src/store/reducer-value-shapes.json +8238 -5764
  129. package/packages/core/src/store/reducer-value-validation.ts +103 -3
  130. package/packages/core/src/store/reducer-values.ts +21 -6
  131. package/packages/core/src/store/remote/client.ts +145 -20
  132. package/packages/core/src/store/remote/index.ts +2 -0
  133. package/packages/core/src/store/remote/protocol.ts +19 -0
  134. package/packages/core/src/store/remote/version.ts +2 -0
  135. package/packages/core/src/store/repo-state-events.ts +3 -1
  136. package/packages/core/src/store/repo-tick.ts +6 -1
  137. package/packages/core/src/store/session-handle.ts +8 -0
  138. package/packages/core/src/store/snapshots.ts +21 -5
  139. package/packages/core/src/store/types.ts +17 -1
  140. package/packages/core/src/testing/dispatch-read-budget.ts +17 -2
  141. package/packages/core/src/testing/index.ts +7 -0
  142. package/packages/core/src/testing/newer-writer.ts +37 -0
  143. package/packages/core/src/testing/reduced-read-budget.ts +3 -0
  144. package/skills/guide/SKILL.md +137 -24
  145. package/skills/guide/references/integration-tree.md +81 -4
  146. package/skills/guide/references/landing-policy.md +11 -0
  147. package/skills/guide/references/migration-1.0.md +9 -0
  148. package/skills/guide/references/operator-api.md +18 -0
  149. package/skills/guide/references/plugin-authoring.md +47 -4
  150. package/skills/guide/references/remote-store-protocol.md +11 -0
  151. package/skills/guide/references/restacking.md +42 -7
  152. package/skills/guide/references/setup.md +21 -0
  153. package/skills/guide/references/ticket-dependencies.md +6 -45
  154. package/skills/implement/SKILL.md +4 -2
  155. package/skills/operate/SKILL.md +63 -6
  156. package/skills/reconcile/SKILL.md +3 -1
  157. package/skills/spec/SKILL.md +49 -39
  158. 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`,
@@ -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
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.2",
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.2",
148
+ "@defrex/autobuild-vercel-sandbox": "1.0.0-beta.2",
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,
@@ -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)
@@ -0,0 +1,142 @@
1
+ import type { Config } from '../../config/schema'
2
+ import type { BuildRecord } from '../../store/types'
3
+ import type { BuildState } from '../../kernel/reducer'
4
+ import type { LeafRestackState } from '../../kernel/leaf-restack-state'
5
+ import {
6
+ integrationComplete,
7
+ integrationCurrent,
8
+ integrationCycleVerified,
9
+ } from '../../kernel/integration-state'
10
+ import { landingReady } from '../../kernel/landing-readiness'
11
+ import { projectIntegrationRow } from './integration-row'
12
+ import { nodeLandingPolicyDisplay, nodeLandingRuleDisplay } from './landing-display'
13
+
14
+ export interface IntegrationChild {
15
+ source: string
16
+ id: string
17
+ title: string
18
+ builds?: string[]
19
+ state: string
20
+ landed: boolean
21
+ }
22
+ export interface IntegrationDetail {
23
+ parentDistance?: string
24
+ destination: string
25
+ branch: string
26
+ restack: string
27
+ conflictFiles?: string[]
28
+ children: IntegrationChild[]
29
+ membershipKnown: boolean
30
+ diagnostics: string[]
31
+ verification: string
32
+ verifySteps: { step: string; outcome: string }[]
33
+ landing: string
34
+ }
35
+
36
+ export function projectIntegrationDetail(
37
+ record: BuildRecord,
38
+ state: BuildState,
39
+ restack: LeafRestackState,
40
+ config: Config,
41
+ pipeline: Config,
42
+ ): IntegrationDetail | undefined {
43
+ const row = projectIntegrationRow(record, state, restack, config)
44
+ if (!row) return undefined
45
+ const observation = state.integration?.observation
46
+ const open = new Set(observation?.openChildren ?? [])
47
+ const contributions = new Set(observation?.contributions ?? [])
48
+ const children: IntegrationChild[] = (observation?.children ?? [])
49
+ .filter(
50
+ (c) =>
51
+ observation!.diagnostics.length ||
52
+ (c.source === record.ticket?.source && open.has(c.id)) ||
53
+ c.builds?.some((b) => contributions.has(b)),
54
+ )
55
+ .map((c) => ({
56
+ ...c,
57
+ title: c.title ?? 'title unavailable',
58
+ landed:
59
+ !!c.builds?.some((b) => contributions.has(b)) &&
60
+ !(c.source === record.ticket?.source && open.has(c.id)),
61
+ state:
62
+ c.builds?.some((b) => contributions.has(b)) &&
63
+ !(c.source === record.ticket?.source && open.has(c.id))
64
+ ? 'landed'
65
+ : 'queued',
66
+ }))
67
+ for (const id of open)
68
+ if (!children.some((c) => c.id === id && c.source === record.ticket?.source))
69
+ children.push({
70
+ source: record.ticket?.source ?? '',
71
+ id,
72
+ title: 'title unavailable',
73
+ state: 'queued',
74
+ landed: false,
75
+ })
76
+ for (const contribution of contributions)
77
+ if (!children.some((c) => c.builds?.includes(contribution)))
78
+ children.push({
79
+ source: record.ticket?.source ?? '',
80
+ id: contribution,
81
+ builds: [contribution],
82
+ title: 'title unavailable',
83
+ state: 'landed',
84
+ landed: true,
85
+ })
86
+ children.sort(
87
+ (a, b) =>
88
+ Number(a.landed) - Number(b.landed) ||
89
+ a.source.localeCompare(b.source) ||
90
+ a.id.localeCompare(b.id),
91
+ )
92
+ const cycle = state.integration?.cycle
93
+ const current = integrationCurrent(state)
94
+ const expected: string[] = cycle ? JSON.parse(cycle.config).verify.steps : pipeline.verify.steps
95
+ const results =
96
+ current && cycle
97
+ ? state.verify.results.filter(
98
+ (r) =>
99
+ r.seq > cycle.seq &&
100
+ r.restackId === cycle.id &&
101
+ r.headSha === cycle.head &&
102
+ r.baseSha === cycle.parent,
103
+ )
104
+ : []
105
+ const verifySteps = [...new Set(expected)].map((step) => ({
106
+ step,
107
+ outcome:
108
+ results.find((r) => r.step === step && r.outcome === 'fail')?.outcome ??
109
+ results.findLast((r) => r.step === step)?.outcome ??
110
+ 'pending',
111
+ }))
112
+ const failed = verifySteps.find((s) => s.outcome === 'fail')
113
+ const conflict =
114
+ state.nodeRestack?.conflict ??
115
+ (restack.active && restack.replay?.conflicted ? restack.replay : undefined)
116
+ const mode = nodeLandingPolicyDisplay(state, config.landing)
117
+ return {
118
+ parentDistance: row.parentDistance,
119
+ destination: `${row.destination}${state.target ? '' : ' (the configured base branch)'}`,
120
+ branch: record.branch ?? state.nodeOpening?.branch ?? 'unknown branch',
121
+ restack: conflict
122
+ ? 'conflicted'
123
+ : state.nodeRestack?.active || restack.active
124
+ ? 'active'
125
+ : 'idle',
126
+ ...(conflict
127
+ ? { conflictFiles: conflict.files ?? ['conflicting filenames were not recorded'] }
128
+ : {}),
129
+ children,
130
+ membershipKnown: !!observation && !observation.diagnostics.length,
131
+ diagnostics: observation?.diagnostics ?? ['child membership unknown'],
132
+ verification: failed
133
+ ? `${failed.step} failed — file a repair child targeting ${record.ticket?.id ?? record.slug}`
134
+ : !integrationComplete(state)
135
+ ? `pending — runs on the node head against ${row.destination} once every child has landed`
136
+ : current && integrationCycleVerified(state)
137
+ ? 'verified on the current node head and destination'
138
+ : 'pending on the current node head and destination',
139
+ verifySteps,
140
+ landing: `${mode} — ${nodeLandingRuleDisplay(state, config.landing)}${landingReady(state, restack) && mode === 'consent' && state.landing?.command?.kind !== 'land' ? ` — press l, or ab land ${record.slug}` : ''}`,
141
+ }
142
+ }