@defrex/autobuild 1.4.2 → 1.6.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 (218) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +512 -101
  3. package/bin/ab-dispatch-kernel.ts +1 -0
  4. package/docs/accounts.md +9 -0
  5. package/docs/agent-runtimes.md +1 -0
  6. package/docs/answering-blocked-builds.md +7 -3
  7. package/docs/architecture.md +313 -130
  8. package/docs/assets/headline-wide.png +0 -0
  9. package/docs/build-store.md +33 -3
  10. package/docs/cli.md +2 -1
  11. package/docs/configuration-overview.md +9 -0
  12. package/docs/configuration.md +217 -106
  13. package/docs/dispatcher-hosting.md +19 -3
  14. package/docs/dispatcher.md +11 -6
  15. package/docs/glossary.md +1 -1
  16. package/docs/integration-overview.md +2 -2
  17. package/docs/integration-tree.md +91 -28
  18. package/docs/merge-policy.md +28 -9
  19. package/docs/operating.md +1 -1
  20. package/docs/operator-api.md +57 -20
  21. package/docs/operator-surfaces.md +1 -1
  22. package/docs/plugin-authoring.md +89 -8
  23. package/docs/remote-store-protocol.md +39 -11
  24. package/docs/remote-ticket-protocol.md +126 -12
  25. package/docs/restacking.md +24 -6
  26. package/docs/seams.md +2 -2
  27. package/docs/setup.md +19 -13
  28. package/docs/spec-standard.md +2 -1
  29. package/docs/ticket-dependencies.md +26 -8
  30. package/docs/ticket-migration.md +70 -7
  31. package/docs/ticket-sources.md +82 -5
  32. package/docs/tickets.md +34 -2
  33. package/docs/troubleshooting.md +3 -3
  34. package/docs/verification.md +5 -5
  35. package/docs/website.md +8 -0
  36. package/docs/workspaces.md +1 -1
  37. package/package.json +4 -3
  38. package/packages/core/src/accounts/hosted-readiness.ts +21 -0
  39. package/packages/core/src/cli/attention.ts +3 -0
  40. package/packages/core/src/cli/build-control.ts +36 -12
  41. package/packages/core/src/cli/connect.ts +9 -18
  42. package/packages/core/src/cli/context.ts +44 -0
  43. package/packages/core/src/cli/dashboard/configuration.ts +11 -0
  44. package/packages/core/src/cli/dashboard/model.ts +51 -11
  45. package/packages/core/src/cli/dashboard/poll.ts +14 -0
  46. package/packages/core/src/cli/dashboard/queue.ts +21 -0
  47. package/packages/core/src/cli/dashboard/render.ts +43 -22
  48. package/packages/core/src/cli/dispatch-frontend.ts +63 -30
  49. package/packages/core/src/cli/dispatch-mode.ts +35 -16
  50. package/packages/core/src/cli/dispatch-preflight.ts +4 -1
  51. package/packages/core/src/cli/dispatch-repository-feed.ts +40 -11
  52. package/packages/core/src/cli/dispatch-tickets.ts +47 -0
  53. package/packages/core/src/cli/dispatch-upgrade-controller.ts +3 -0
  54. package/packages/core/src/cli/dispatch.ts +522 -145
  55. package/packages/core/src/cli/help.ts +63 -24
  56. package/packages/core/src/cli/init-hosted-accounts.ts +54 -0
  57. package/packages/core/src/cli/init-readiness-remote.ts +16 -3
  58. package/packages/core/src/cli/init-validation.ts +144 -42
  59. package/packages/core/src/cli/issue-links.ts +67 -0
  60. package/packages/core/src/cli/main.ts +32 -15
  61. package/packages/core/src/cli/pr-summary-publication.ts +38 -7
  62. package/packages/core/src/cli/publication-settlement.ts +36 -24
  63. package/packages/core/src/cli/repo-lease.ts +225 -0
  64. package/packages/core/src/cli/repository-status.ts +203 -49
  65. package/packages/core/src/cli/status.ts +42 -4
  66. package/packages/core/src/cli/terminals.ts +37 -2
  67. package/packages/core/src/cli/ticket-editor.ts +20 -6
  68. package/packages/core/src/cli/ticket.ts +264 -46
  69. package/packages/core/src/cli/triage-count-sampler.ts +59 -0
  70. package/packages/core/src/cli/wait.ts +4 -1
  71. package/packages/core/src/cli/watch.ts +19 -4
  72. package/packages/core/src/config/live.ts +45 -4
  73. package/packages/core/src/config/load.ts +9 -0
  74. package/packages/core/src/config/pipeline-source.ts +6 -2
  75. package/packages/core/src/config/ready-assignee.ts +86 -0
  76. package/packages/core/src/config/schema.ts +202 -38
  77. package/packages/core/src/distribution-packaging.ts +1 -1
  78. package/packages/core/src/events/catalog.ts +7 -0
  79. package/packages/core/src/events/compatibility.ts +2 -1
  80. package/packages/core/src/events/payloads.ts +85 -0
  81. package/packages/core/src/events/policy.ts +10 -0
  82. package/packages/core/src/events/repository.ts +93 -28
  83. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +237 -230
  84. package/packages/core/src/kernel/build-identity.ts +12 -0
  85. package/packages/core/src/kernel/change-presence.ts +139 -6
  86. package/packages/core/src/kernel/dispatch-capacity.ts +189 -19
  87. package/packages/core/src/kernel/dispatch-status.ts +10 -1
  88. package/packages/core/src/kernel/dispatch-upgrade.ts +104 -5
  89. package/packages/core/src/kernel/engine.ts +17 -8
  90. package/packages/core/src/kernel/finalize-pr-rejection.ts +95 -0
  91. package/packages/core/src/kernel/generators/build-log.ts +9 -0
  92. package/packages/core/src/kernel/generators/repository-journals.ts +15 -1
  93. package/packages/core/src/kernel/harvest.ts +4 -1
  94. package/packages/core/src/kernel/incremental-fixtures.ts +1 -0
  95. package/packages/core/src/kernel/integration-completeness.ts +104 -17
  96. package/packages/core/src/kernel/integration-landing.ts +17 -0
  97. package/packages/core/src/kernel/integration-state.ts +17 -0
  98. package/packages/core/src/kernel/issue-keywords.ts +202 -0
  99. package/packages/core/src/kernel/janitor-failure.ts +96 -5
  100. package/packages/core/src/kernel/kernel-git.ts +87 -0
  101. package/packages/core/src/kernel/landing-readiness.ts +25 -17
  102. package/packages/core/src/kernel/leaf-restack-state.ts +4 -2
  103. package/packages/core/src/kernel/log-index.ts +1 -1
  104. package/packages/core/src/kernel/node-issue-links.ts +142 -0
  105. package/packages/core/src/kernel/node-landing.ts +2 -1
  106. package/packages/core/src/kernel/node-parent.ts +6 -0
  107. package/packages/core/src/kernel/node-restack-transaction.ts +2 -0
  108. package/packages/core/src/kernel/pr-summary.ts +24 -0
  109. package/packages/core/src/kernel/read-deferrals.ts +75 -12
  110. package/packages/core/src/kernel/read-facts.ts +32 -1
  111. package/packages/core/src/kernel/reconcile-restack.ts +1 -1
  112. package/packages/core/src/kernel/reducer-registry.ts +37 -2
  113. package/packages/core/src/kernel/reducer.ts +147 -5
  114. package/packages/core/src/kernel/ticket-preparation.ts +16 -0
  115. package/packages/core/src/kernel/verify-budget.ts +43 -0
  116. package/packages/core/src/operator/index.ts +3 -1
  117. package/packages/core/src/operator/presentation.ts +3 -0
  118. package/packages/core/src/operator/protocol.ts +38 -2
  119. package/packages/core/src/operator/query.ts +69 -29
  120. package/packages/core/src/operator/registry.ts +47 -26
  121. package/packages/core/src/operator/tickets.ts +77 -10
  122. package/packages/core/src/plugin-sdk/index.ts +13 -0
  123. package/packages/core/src/plugins/manifest.ts +1 -1
  124. package/packages/core/src/plugins/registry.ts +1 -0
  125. package/packages/core/src/ports/forge/contract.ts +69 -0
  126. package/packages/core/src/ports/forge/create.ts +5 -0
  127. package/packages/core/src/ports/forge/fake.ts +184 -3
  128. package/packages/core/src/ports/forge/git-rewrite.ts +4 -2
  129. package/packages/core/src/ports/forge/github.ts +175 -38
  130. package/packages/core/src/ports/forge/local-git.ts +14 -0
  131. package/packages/core/src/ports/forge/readiness.ts +10 -0
  132. package/packages/core/src/ports/forge-failure.ts +43 -0
  133. package/packages/core/src/ports/runner/claude.ts +7 -1
  134. package/packages/core/src/ports/runner/codex.ts +7 -2
  135. package/packages/core/src/ports/runner/native-cli-fixture.ts +2 -1
  136. package/packages/core/src/ports/runner/pi.ts +7 -1
  137. package/packages/core/src/ports/runner/runtime.ts +3 -0
  138. package/packages/core/src/ports/runner/start-prompt.ts +37 -0
  139. package/packages/core/src/ports/tickets/contract.ts +320 -7
  140. package/packages/core/src/ports/tickets/create.ts +89 -20
  141. package/packages/core/src/ports/tickets/fake.ts +18 -0
  142. package/packages/core/src/ports/tickets/file-codec.ts +20 -0
  143. package/packages/core/src/ports/tickets/file.ts +43 -1
  144. package/packages/core/src/ports/tickets/github-fake.ts +1123 -0
  145. package/packages/core/src/ports/tickets/github-issues.ts +431 -0
  146. package/packages/core/src/ports/tickets/github-validators.ts +194 -0
  147. package/packages/core/src/ports/tickets/github.ts +2029 -0
  148. package/packages/core/src/ports/tickets/hosted-index.ts +34 -3
  149. package/packages/core/src/ports/tickets/issue-links.ts +86 -0
  150. package/packages/core/src/ports/tickets/lifecycle.ts +60 -4
  151. package/packages/core/src/ports/tickets/linear.ts +66 -6
  152. package/packages/core/src/ports/tickets/migration.ts +290 -68
  153. package/packages/core/src/ports/tickets/operations.ts +98 -12
  154. package/packages/core/src/ports/tickets/priority.ts +55 -0
  155. package/packages/core/src/ports/tickets/remote-protocol.ts +195 -29
  156. package/packages/core/src/ports/tickets/remote.ts +188 -13
  157. package/packages/core/src/ports/tickets/revision.ts +22 -1
  158. package/packages/core/src/ports/tickets/states.ts +43 -0
  159. package/packages/core/src/ports/tickets/tree.ts +58 -12
  160. package/packages/core/src/ports/tickets/update.ts +12 -2
  161. package/packages/core/src/ports/types.ts +194 -9
  162. package/packages/core/src/ports/workspace/commit-preservation.ts +163 -25
  163. package/packages/core/src/ports/workspace/git-worktree.ts +6 -2
  164. package/packages/core/src/ports/workspace/harvest-execution.ts +4 -2
  165. package/packages/core/src/ports/workspace/vercel-sandbox.ts +121 -27
  166. package/packages/core/src/processes/build-runner.ts +101 -22
  167. package/packages/core/src/processes/dispatcher.ts +1046 -372
  168. package/packages/core/src/processes/execution-no-progress.ts +7 -0
  169. package/packages/core/src/processes/harvest-child.ts +4 -2
  170. package/packages/core/src/processes/harvest-execution-state.ts +104 -0
  171. package/packages/core/src/processes/harvest-runner.ts +263 -25
  172. package/packages/core/src/processes/harvest.ts +5 -8
  173. package/packages/core/src/processes/tick-publication.ts +12 -2
  174. package/packages/core/src/processes/ticket-scan-schedule.ts +78 -0
  175. package/packages/core/src/processes/workspace-preservation.ts +36 -1
  176. package/packages/core/src/runtime-identity.ts +10 -2
  177. package/packages/core/src/scenarios/harness.ts +149 -35
  178. package/packages/core/src/store/adapter.ts +7 -1
  179. package/packages/core/src/store/contract.ts +83 -2
  180. package/packages/core/src/store/digest.ts +32 -1
  181. package/packages/core/src/store/reduced-reads.ts +10 -0
  182. package/packages/core/src/store/reducer-value-shapes.json +4471 -3427
  183. package/packages/core/src/store/remote/protocol.ts +2 -0
  184. package/packages/core/src/store/remote/released-clients.json +22 -0
  185. package/packages/core/src/store/remote/released-reducer-values/1.5.0.json +26924 -0
  186. package/packages/core/src/store/remote/released-reducer-values/1.6.0.json +27173 -0
  187. package/packages/core/src/store/remote/released-reducer-values/index.ts +4 -0
  188. package/packages/core/src/store/repo-state-events.ts +2 -0
  189. package/packages/core/src/store/types.ts +5 -0
  190. package/packages/core/src/testing/dispatch-read-budget.ts +729 -123
  191. package/packages/core/src/testing/index.ts +18 -1
  192. package/packages/core/src/testing/presence-history.ts +79 -0
  193. package/packages/core/src/testing/reduced-read-budget.ts +1424 -33
  194. package/packages/core/src/testing/upgrade-generations.ts +77 -0
  195. package/skills/code-review/SKILL.md +4 -3
  196. package/skills/finalize/SKILL.md +18 -2
  197. package/skills/guide/SKILL.md +417 -143
  198. package/skills/guide/references/accounts.md +9 -0
  199. package/skills/guide/references/integration-tree.md +91 -28
  200. package/skills/guide/references/merge-policy.md +28 -9
  201. package/skills/guide/references/operator-api.md +57 -20
  202. package/skills/guide/references/plugin-authoring.md +89 -8
  203. package/skills/guide/references/remote-store-protocol.md +39 -11
  204. package/skills/guide/references/remote-ticket-protocol.md +126 -12
  205. package/skills/guide/references/restacking.md +24 -6
  206. package/skills/guide/references/setup.md +19 -13
  207. package/skills/guide/references/spec-standard.md +2 -1
  208. package/skills/guide/references/ticket-dependencies.md +26 -8
  209. package/skills/guide/references/ticket-migration.md +70 -7
  210. package/skills/harvest-review/SKILL.md +4 -3
  211. package/skills/implement/SKILL.md +20 -1
  212. package/skills/operate/SKILL.md +149 -35
  213. package/skills/plan/SKILL.md +1 -1
  214. package/skills/reconcile/SKILL.md +5 -4
  215. package/skills/spec/SKILL.md +15 -2
  216. package/skills/tickets/SKILL.md +116 -37
  217. package/templates/autobuild.toml +5 -0
  218. package/templates/hosted-service/package.json +2 -2
@@ -17,8 +17,12 @@ disagree, the code is authoritative.
17
17
  validation and fail-safe fallback.
18
18
  2. **Resumability is not a feature.** Re-running `ab dispatch` attempts every
19
19
  actionable current build; each phase resumes as a function of durable state.
20
- Open escalations remain parked until a human answer is recorded, while
21
- pending operator commands remain actionable.
20
+ Startup is not an answer or a retry. Open phase and policy escalations
21
+ remain parked until an external answer, from the operator agent or you, is
22
+ recorded; a build-phase agent never answers its own escalation. Ordinary
23
+ janitor retries continue across startup, and a successful attempt closes a
24
+ janitor escalation unanswered; a bare retry only brings the next attempt
25
+ forward. Pending operator commands remain actionable.
22
26
  3. **Ingesters propose, humans dispatch.** Nothing auto-generated passes
23
27
  Triage without a human grooming it to Ready, unless the repository waives
24
28
  that gate explicitly with `[tickets].proposalState`.
@@ -58,7 +62,8 @@ surface with `packages/postgres-store`; the separate optional
58
62
  `packages/hosted-dispatcher` workspace owns the cron-driven hosted dispatcher
59
63
  (the `/api/dispatch` route driver, and the deploy-time `pack-distribution` and
60
64
  `ship-deployment` commands that pack the guest archive and ship it, its
61
- manifest and the selected provider plugins into the dispatch function) and
65
+ manifest, a self-contained `linux-x64` Git for kernel node operations, and the
66
+ selected provider plugins into the dispatch function) and
62
67
  peers on both the core and the store service. The optional `packages/vercel-sandbox` workspace publishes the
63
68
  `@defrex/autobuild-vercel-sandbox` provider plugin (AUT-517): while the
64
69
  builtin hosts the implementation, its manifest re-registers the provider name
@@ -81,7 +86,7 @@ remote-store protocol requires matching client and server versions.
81
86
  | `packages/core/src/store/` | BuildStore contract spanning builds, the repository journal, and operator sessions; interface-enforced build, operator-session, and local ambient-session scope wrappers; memory, SQLite/blob, and remote HTTP adapters | §7 |
82
87
  | `packages/core/src/store/streams/` | The stream primitive's shared core (§7.6): record/chunk types and the `ai-ui-message-stream/v1` constants, SDK-backed close-time `UIMessage[]` assembly, and the uniform bounded-wait read loop | §7.6 |
83
88
  | `packages/hosted-store-service/` | Environment-only hosted Fetch handler, lazy PostgreSQL/blob composition, offline token binary, the Next.js operator web app (`app/`, `server.ts`, `next.config.ts`, `vercel.json`), tests, and deployment guide | §7.2, §18 |
84
- | `packages/hosted-dispatcher/` | The optional cron-driven hosted dispatcher: endpoint driver, deploy-time `pack-distribution` and `ship-deployment` binary, packed-distribution trace helper, provider plugin shipper, tests, and operator guide | §7.2, §12, §18 |
89
+ | `packages/hosted-dispatcher/` | The optional cron-driven hosted dispatcher: endpoint driver, deploy-time `pack-distribution` and `ship-deployment` binary, packed-distribution trace helper, Git stager (`ship-git.ts`, `elf.ts`) and runtime locator (`shipped-git.ts`), provider plugin shipper, tests, and operator guide | §7.2, §12, §18 |
85
90
  | `packages/vercel-sandbox/` | Published `@defrex/autobuild-vercel-sandbox` provider plugin: transitional manifest over the shared capability object with a guarded factory (implementation stays builtin-hosted until AUT-505) | §3.2.1 |
86
91
  | `packages/hosted-store-service/server.ts`, `packages/hosted-store-service/vercel.json` | One host-neutral Bun listener used locally and by Vercel's Bun preset | §7.2 |
87
92
  | `packages/core/src/kernel/` | Phase table, build reducer, engine; pure harvest, dispatcher-settings, dispatcher-status, and PR-attachment selectors; converge, stall detection, verify gating | §5, §7.5, §10, §12, §14, §15.4–15.5 |
@@ -89,14 +94,14 @@ remote-store protocol requires matching client and server versions.
89
94
  | `packages/core/src/plugins/` | Strict versioned plugin manifests, dual-root repository/package Bun loading, owner-aware adapter registration, contract/credential metadata, and runtime-factory materialization | §3.2.1, §9 |
90
95
  | `packages/core/src/plugin-sdk/` | The sole supported `@defrex/autobuild/plugin-sdk` barrel: port/manifest types, contract suites, and reference fakes | §3.2.1 |
91
96
  | `packages/core/src/processes/` | build-runner and standalone child composition, durable execution config/diagnostics, dispatcher (+ janitor duty, sandbox idle settlement and harvest trigger), harvest deterministic core + runner | §3.3, §7.1.2, §12, §15.7 |
92
- | `packages/core/src/cli/` and `bin/` | The `ab` CLI — the only agent↔store channel — plus the shared presentation-only durable-progress projection, init/upgrade, the filesystem-only dispatch launcher and immutable generation cache, the Store-only dispatch frontend, its private supervised kernel entry, and `bin/ab-build-runner.ts` (one child per build) | §8, §14, §16.3 |
97
+ | `packages/core/src/cli/` and `bin/` | The `ab` CLI — the only agent↔store channel — plus the shared presentation-only durable-progress projection, init/upgrade, the filesystem-only dispatch launcher and immutable generation cache, the dispatch frontend (Store-backed, plus the viewer's ticket-source triage count), its private supervised kernel entry, and `bin/ab-build-runner.ts` (one child per build) | §8, §14, §16.3 |
93
98
  | `packages/core/src/cli/dashboard/` | `ab dispatch`'s fixed live frame: pure projection, renderer, poll cache, and deterministic image renderer | §14 |
94
99
  | `bin/agent/ab` | Private launcher placed first on agent-session `PATH`; delegates to the canonical `bin/ab.ts` | §8.1 |
95
100
  | `packages/core/src/config/` | `autobuild.toml` parsing and strict validation, plus the pure role-key consumability diagnostics `ab dispatch` reports at startup (`roles.ts`); user reference in `docs/configuration.md` | §9, §16.1 |
96
- | `packages/core/src/scenarios/` | In-memory end-to-end harness and product scenarios | — |
101
+ | `packages/core/src/scenarios/` | End-to-end harness over a temporary Git origin and worktrees (integration tests) and product scenarios | — |
97
102
  | `tools/` | This repository's local maintainer tooling, including verification, dashboard capture, and release cutting; not shipped product behavior | — |
98
103
  | `skills/` | Canonical defaults; `ab init` vendors them to `.agents/skills/ab-*` and links `.claude/skills/ab-*` | §16.3 |
99
- | `skills/guide/` | `ab-guide` — the model-invocable reference for the lifecycle and full config surface; `references/` is the shared installed-documentation seam for every vendored skill. Update it when config or shared guidance changes; `packages/core/src/cli/guide-skill.test.ts` guards schema coverage and `packages/core/src/cli/skill-self-containment.test.ts` guards installed references | §16.3 |
104
+ | `skills/guide/` | `ab-guide` — the model-invocable reference for the lifecycle and full config surface; `references/` is the shared installed-documentation seam for every vendored skill. Update it when config or shared guidance changes; `packages/core/src/cli/guide-skill.integration.test.ts` guards schema coverage and `packages/core/src/cli/skill-self-containment.integration.test.ts` guards installed references | §16.3 |
100
105
  | `docs/spec-standard.md` | The standalone definition of "buildable" every ticket surface uses; kept byte-identical with `skills/guide/references/spec-standard.md` for installed agents | §6.1 |
101
106
  | `templates/` | Valid setup-only config baseline with comment anchors rendered by `ab init` | §16.3 |
102
107
 
@@ -155,6 +160,8 @@ canonical changed-outcome scan event by sequence and stores only its scheduling
155
160
  baseline, mode and input fingerprints. It is disposable coordination metadata,
156
161
  not a reducer snapshot or authoritative outcome; loss permits a safe extra scan.
157
162
  Keyed reads and atomic upserts have constant cost and never read journal rows.
163
+ The dispatcher skips the keyed read entirely while the recorded fact alone
164
+ proves the scan interval has not elapsed.
158
165
 
159
166
  **Reducer snapshots.** The `BuildStore` port can keep, per scope (one build log
160
167
  or the repository journal) and registered reducer, that reducer's accumulator as
@@ -309,7 +316,7 @@ cursors outside the tail window fail without replay; see
309
316
  [hosted event bounds and exact resume](remote-store-protocol.md#hosted-event-bounds-and-exact-resume).
310
317
  Actual event listings, transcripts and cursor streams remain raw reads. The
311
318
  interactive terminal frontend retains its independently established incremental
312
- feed. `tools/persisted-reduced-reads.test.ts` scans production TypeScript calls
319
+ feed. `tools/persisted-reduced-reads.integration.test.ts` scans production TypeScript calls
313
320
  and maintains precise, reason-bearing exceptions for these boundaries and pure
314
321
  reference projections; stale exceptions fail the check.
315
322
 
@@ -361,11 +368,11 @@ post-steps reuse the timer but drain expiry through their existing failure-toler
361
368
  completion and observation path. Harvest and deterministic commands do not use
362
369
  this build-phase timer.
363
370
 
364
- **Human guidance delivery.** The routing fact is an `escalation.answered`
371
+ **Guidance delivery.** The routing fact is an `escalation.answered`
365
372
  event carrying `resolution: "guidance"`; nothing else routes an answer. `ab
366
373
  answer` and the dashboard's blocked-build resume control are two surfaces over
367
374
  the one `packages/core/src/cli/build-control.ts` operation that appends it, so delivery is
368
- identical whichever a human used.
375
+ identical whichever surface the operator agent or you used.
369
376
  `packages/core/src/kernel/engine.ts` routes answers from `plan` and `plan-review` to the next
370
377
  `plan` round, and answers from `implement` and `code-review` to the next
371
378
  `implement` round. An agent verifier's own escalation is the deliberate
@@ -400,7 +407,7 @@ recovery; the matching launch consumes it once without process-local state. A
400
407
  producer round's feedback is a discriminated union — findings, a
401
408
  failed verify report, or guidance — and a round may carry none, so a round with
402
409
  guidance writes no `$AB_CONTEXT_DIR/findings.json`. The receiving skills document their
403
- corresponding input, and `packages/core/src/cli/skill-guidance.test.ts` derives that
410
+ corresponding input, and `packages/core/src/cli/skill-guidance.integration.test.ts` derives that
404
411
  requirement from the phase table.
405
412
 
406
413
  **Finalize publication.** Content-producing `finalize:*` checks or agents
@@ -629,11 +636,21 @@ non-destructive execution fence for the exact workspace and execution generation
629
636
  It preserves unpublished branch commits and distinct detached producer candidates
630
637
  under immutable `refs/autobuild/archive/<build>/<sha>` refs, verifies their exact
631
638
  readback, and records `workspace.commits-preserved` before cleanup. Replacement
632
- provisioning restores those exact refs before starting an agent. Preservation
639
+ provisioning restores those exact refs before starting an agent, reading them
640
+ from the local repository with the local-git forge and fetching each exact ref
641
+ from the remote otherwise. A preserved
642
+ branch head that the build's latest 64 replaced heads cover, as the replaced
643
+ head itself or one of its ancestors, is kept only as archived objects: it is
644
+ never preserved or restored as the branch, and provisioning records the skip as
645
+ `restorationSkipped` on `workspace.provisioned`. Rewrites older than that bound,
646
+ and unpublished divergent branch work, are still refused. Preservation
633
647
  never advances the public build branch. A confirmed absent environment, or one
634
648
  that exists without a provisioned checkout, records `workspace.commits-lost`,
635
649
  naming known candidates and explicitly noting that any additional unpublished
636
- SHAs could not be inspected. Unknown fencing, inspection, transport, or
650
+ SHAs could not be inspected. An environment that never started executing holds
651
+ no unpublished work: objects its checkout lacks mean nothing to preserve, so
652
+ cleanup records `workspace.commits-preserved` carrying forward earlier preserved
653
+ heads, then releases and replaces it. Unknown fencing, inspection, transport, or
637
654
  receipt-write outcomes leave the workspace and snapshots intact. A workspace
638
655
  flagged by `workspace.cleanup-required` is never launched into: the dispatcher
639
656
  releases it and provisions the next generation. A preservation or release
@@ -688,6 +705,9 @@ per client and fall back to full artifact reads, never event replay.
688
705
  build-owned identity and source ancestry at settled stage boundaries. Typed
689
706
  `verify.config-captured` and `verify.config-superseded` facts advance the result
690
707
  boundary in the reducer and log index, independently of reconcile identity.
708
+ The advisory `pipeline.settled` fact records that the engine reached a leaf's
709
+ `wait awaiting-pr`; `kernel/dispatch-capacity.ts` reads it so a finished build
710
+ parked for its merge decision holds no slot.
691
711
  The runner refreshes after workspace mutation and before constructing members;
692
712
  concurrent siblings settle before another stage is selected. Recovery and
693
713
  readiness compose live deployment settings onto the captured artifact revision.
@@ -719,7 +739,27 @@ dispatch is tolerated. `Ticket.creationKey` is the optional stable external
719
739
  create/adoption correlation, distinct from `Ticket.ref.id`; Linear projects its
720
740
  issue UUID and file/fake preserve their idempotency metadata through create,
721
741
  adoption, get, and list paths. Legacy/plugin tickets may omit it and dispatch
722
- unchanged.
742
+ unchanged. The ticket-source port optionally exposes `listPage(criteria, page)` for paged operator reads. PostgreSQL counts matches and applies SQL LIMIT/OFFSET; other sources retain exhaustive-read slicing. CLI and dispatcher reads stay exhaustive. See [ticket source contract](ticket-sources.md#writing-your-own).
743
+
744
+ The `github` source spans four modules. `ports/tickets/github.ts` is the
745
+ adapter: REST over the forge's `GitHubRequest` transport and credential order,
746
+ plus display-only state counts (one GraphQL request, and one more per
747
+ further page of 100 `autobuild:` labels) and the bounded
748
+ `last: 100` timeline read that decides whether a reopened issue's state label
749
+ is stale. `ports/tickets/github-issues.ts` holds the pure mapping: issue to
750
+ state through `autobuild:` labels and closing reasons, state to write, issue
751
+ ids, the creation-key body marker, `autobuild-link:` link labels, and kind
752
+ and target through the exact `node` label and `parent_issue_url`. The adapter
753
+ resolves a target from the child's local parent, reading that parent's label
754
+ from the listing batch or one conditional read, and implements
755
+ `listTargeting` from the node's side through its paginated sub-issue list.
756
+ `ports/tickets/github-validators.ts` keeps conditional-request validators and
757
+ reopen verdicts, one atomically written file per entry under
758
+ `<localStateRoot>/github-tickets/<owner>/<repo>/validators/`, evicted after 7
759
+ days unused; without a local state root it uses the in-memory store.
760
+ `ports/tickets/github-fake.ts` is the in-memory GitHub API that the shared
761
+ contract suite and the budget tests run against. The source holds no BuildStore
762
+ handle; assets use the generic BuildStore path.
723
763
 
724
764
  **Workspace, execution, and review base selection.**
725
765
  `packages/core/src/ports/workspace/create.ts` resolves `[workspace].provider` against the
@@ -742,6 +782,9 @@ its proven contribution boundary verbatim: the projected implementation/replay
742
782
  base, falling back to the latest fresh cut. Branch-cut target sampling remains
743
783
  separate from review provenance. The immutable boundary must belong to HEAD's
744
784
  history; missing or invalid provenance fails before publication or notes deposit.
785
+ A HEAD equal to that base is an empty contribution: the terminal records an
786
+ agent `implement` escalation naming both SHAs as the session's terminal, with no
787
+ push, notes deposit, completion or publication request.
745
788
  There is no review-time target fetch or destination merge-base. Successful leaf
746
789
  rewrite facts project `targetBase..headSha` for context, review and agent verify
747
790
  steps without changing historical ranges. Node cycles retain separate semantics.
@@ -822,14 +865,39 @@ request costs one GraphQL freshness query and no extra consent or pipeline read;
822
865
  full gate inspection and refreshed durable consent/engine eligibility precede
823
866
  any repair. Body comparison tolerates provider trimming of trailing whitespace
824
867
  while preserving the complete headline, body content, and squash method.
825
-
826
- Destination observations retain versioned, head-bound Git witnesses (reachable
827
- commit SHAs and direct build trailers) and a fixed-length evidence digest. Current
868
+ `packages/core/src/kernel/issue-keywords.ts` composes a build's sealed issue
869
+ links into `Closes #N` / `Refs #N` lines, neutralizes closing keywords aimed at
870
+ `refs` issues, and places the keyword paragraph before the trailer block; a
871
+ `closesIssues` adapter uses it for the PR title and body, the landing writes and
872
+ the freshness comparison alike.
873
+ `packages/core/src/kernel/node-issue-links.ts` owns a node's issue-link set:
874
+ the dispatcher records each landed child's contribution on its node as
875
+ `node.issue-links-recorded` before the child completes, the build reducer folds
876
+ them per issue into a union, and the node's set merges its own effective links
877
+ with that union. A node's PR body is synced to the set (refs-only into a parent
878
+ node) through the optional `Forge.updatePrIssueLinks` when its
879
+ `node.issue-links-published` readback differs, and a root node's is refreshed
880
+ again by `landIntegrationRoot` before any merge request. A leaf aimed at a node
881
+ opens its PR with refs-only lines (`prIssueLinksForForge`) and lands with none.
882
+
883
+ Destination observations record a head-bound, query-scoped probe rather than
884
+ the destination's history: only the commit SHAs and direct build trailers in the
885
+ proof closure of the identities being decided (blocker identities, plus the
886
+ landings and confirmed foreign aliases that could transport them), which of those
887
+ are reachable from the sampled head, presence answers for only those identities,
888
+ and a fixed-length evidence digest. Observation size is bounded by that closure,
889
+ independent of the destination's reachable commit count and of repository history.
890
+ While the head is unchanged and the probe covers the current questions, current
828
891
  confirmed landings and aliases from only the destination's accepted ancestry are
829
- reapplied before reuse. Unrelated merged history and ready destinations do not
830
- invalidate this proof. Head changes require a fresh Git sample; legacy observations
831
- without witnesses refresh once rather than replaying repository history. Current
832
- readiness and newest-generation checks still apply before claim.
892
+ reapplied without Git; unrelated merged history and ready-set changes neither
893
+ invalidate it nor append events. A moved head requires a fresh Git sample. A
894
+ newly relevant landing or a new question needs only a new probe: a dispatcher
895
+ still holding the full in-memory witness for that branch and head compacts one
896
+ without Git, and otherwise samples Git once. Observations without a probe,
897
+ including older full-history witnesses, are never trusted for admission: they
898
+ are re-derived once the same way, and an unavailable sample leaves the dependent
899
+ queued; neither replays repository history. Current readiness and
900
+ newest-generation checks still apply before claim.
833
901
 
834
902
  Optional `Forge.readCommitMessage` and `Forge.containsBuild` capabilities expose
835
903
  actual merged messages and exact trailer presence in reachable branch history.
@@ -947,9 +1015,13 @@ coalesces these at completed phase boundaries with durable attempt, result,
947
1015
  cooldown, request, and disposition facts. Built-in forges upsert one hidden
948
1016
  per-build marker; legacy plugins keep the existing bounded `commentOnPr` API.
949
1017
  Oversized bodies become a compact pinned download of a full `pr-summary`
950
- store artifact. Local runners publish under their lease; remote guests request
951
- and yield, and dispatcher settlement fences ended execution and owns the
952
- publication lease before launching replacement work. Summary failure never
1018
+ store artifact. Local runners publish under their lease at every boundary;
1019
+ remote guests request and yield, coalescing a verify cycle into one request at
1020
+ its end (`continuesVerifyCycle` in `kernel/pr-summary.ts`). The dispatcher
1021
+ records a guest exit caused only by a request that execution wrote as a
1022
+ routine `dispatcher.summary-handoff`, not a parked runner, and dispatcher
1023
+ settlement fences ended execution and owns the publication lease before
1024
+ launching replacement work. Summary failure never
953
1025
  changes phase outcomes. The GitHub release transport
954
1026
  lives in `packages/core/src/ports/forge/github-pr-attachments.ts`; terminal-build reclamation
955
1027
  and retry facts remain dispatcher janitor duty.
@@ -973,43 +1045,72 @@ AgentRunner failure causes and the exhaustion contract fixture are additive
973
1045
  plugin API 1.3 surfaces; legacy failures without a cause retain permanent-bit
974
1046
  behavior.
975
1047
 
976
- **Dashboard.** `packages/core/src/cli/dispatch-frontend.ts` is a Store-only terminal adapter:
977
- it has no ticket, forge, workspace-provider, LiveConfig, or runtime dependency.
1048
+ **Dashboard.** `packages/core/src/cli/dispatch-frontend.ts` is a Store-first terminal adapter:
1049
+ it has no forge, workspace-provider, LiveConfig, or runtime dependency, and
1050
+ holds only a lazy ticket-source opener for build actions and the viewer's
1051
+ triage count.
978
1052
  It follows one dispatch run's repository facts incrementally through
979
1053
  `packages/core/src/kernel/dispatch-status.ts`, retaining only low-volume settings/Harvest
980
1054
  facts for their replay reducers, validates/caches its effective-config artifact,
981
1055
  and polls build streams independently while elapsed paints continue from cached
982
- intervals. The same polling path samples the header's current count from build
983
- digests plus the repository journal — one journal read plus one repo-scoped
984
- digest read, plus a journal-record probe — paired with the effective config's
985
- `policy.harvestThreshold`. A journal record that does not yet exist reads as an
986
- empty journal: the sample, the operator query, the dispatcher's
987
- repository-wide journal reads (controls, settlement stages, and ready
988
- scans), and the operator sandbox service's journal reads all go through
1056
+ intervals. In local execution mode the header's triage count comes from the
1057
+ reduced `DispatchStatus` (`status.triage`), exactly like the queue depth, so a
1058
+ frontend refresh reads neither the ticket source nor any extra store value for
1059
+ it; viewer mode differs, as described below. The supervised
1060
+ kernel child (`frontendStatus`) samples the count through
1061
+ `TriageCountSampler` (`packages/core/src/cli/triage-count-sampler.ts`): the
1062
+ watch loop pokes it at startup and after each tick returns, so it reads at
1063
+ most once per 60 s (`TRIAGE_COUNT_REFRESH_MS`), outside dispatcher ticks, with
1064
+ one read in flight. It uses the source's bounded `countStates([triage])`, never a listing. Each tick carries the last
1065
+ successful count on `dispatcher.tick-completed`, and the tick itself never
1066
+ reads the ticket source for counts; a changed count is a
1067
+ standing-state change for publication suppression. Hosted, plain and
1068
+ non-TTY dispatchers never sample it. A source without `countStates` makes no
1069
+ request and stays unknown (`–`); a failed read or unmatched state keeps the
1070
+ previous value (initially unknown, shown as `–`).
1071
+ A viewer (`opts.viewer`) whose repository is dispatched elsewhere ignores
1072
+ `status.triage` and shows only its own count: on a refreshed frame it asks
1073
+ the source's optional `countStates([triage])` at most once per 60 s, in the
1074
+ background with one request in flight, while presentation is live and not in
1075
+ `--once`. It keeps the last good value through failures and shows `–` until
1076
+ the first success or for a source without `countStates`. The hosted
1077
+ `state-counts` operation answers that read with per-state totals only. The
1078
+ Postgres source reads them from `ab_ticket_state_counts`, which a row trigger
1079
+ on `ab_tickets` keeps exact in each ticket write's transaction, so the read
1080
+ never touches ticket rows. Like `REPO_CHANGE_DDL`, that table and trigger sit
1081
+ outside the ticket marker. Migration backfills them once when it creates the
1082
+ table, and project deletion removes the project's rows. A
1083
+ journal record that does not yet exist reads as an empty journal: the
1084
+ dispatcher's repository-wide journal reads (controls, settlement stages, and
1085
+ ready scans) and the operator sandbox service's journal reads go through
989
1086
  the same shared missing-record journal read (the AUT-524 helper in
990
1087
  `packages/core/src/processes/harvest.ts`), which writes nothing (no
991
- `ensureRepo` from a display path). That sample
992
- is process-local presentation state: a failed refresh preserves the last
993
- successful value and adds a local diagnostic, while an initial failure delays
994
- the complete frame rather than inventing zero. No repository fact transports
995
- it, and the headless child does not scan for presentation. Navigation is
1088
+ `ensureRepo` from a display path). Navigation is
996
1089
  synchronous presentation state; only Store reads and writes enter its UI action
997
1090
  queue. The supervised kernel child owns every slow
998
1091
  adapter operation, so slug naming, provisioning, runners, and Harvest cannot
999
1092
  block input.
1000
1093
 
1001
1094
  Startup restores a validated `dispatchFrontend` checkpoint incrementally only
1002
- when its cursor is within the 1,000-event repository tail window. Older caches
1003
- use the repository-state recovery seed instead. Startup catch-up and prelaunch
1004
- boundary reads enforce that window at selection, including concurrent appends;
1005
- cursor expiry permits one additional seed recovery, never historical gap replay.
1006
- Transfer is bounded by the existing state seed plus a fixed number of windowed
1007
- tails, independently of discarded history (the seed itself retains durable facts
1008
- and the latest run tail). High water is sampled before the sparse seed so later
1009
- updates remain consumable. Steady-state reads and save cadence are unchanged.
1095
+ when its cursor is within the 1,000-event repository tail window. A missing,
1096
+ invalid, unreadable or stale checkpoint, and cursor expiry, instead reseed from
1097
+ the canonical `repositoryReadFacts` value: its latest run start and the sampled
1098
+ holder's start become the retained identities, and its cursor starts one
1099
+ windowed tail. That value is the store's saved reduction, advanced
1100
+ incrementally on the server, so transfer is a fixed number of requests
1101
+ independent of journal and current-run length. Startup never falls back to
1102
+ `getRepoStateEvents` or a journal read from zero; a failed canonical read
1103
+ leaves the feed unready, and the next poll retries the same bounded read.
1104
+ Startup catch-up and prelaunch boundary reads enforce the tail window at
1105
+ selection, including concurrent appends; cursor expiry permits one additional
1106
+ canonical reseed, never historical gap replay. Steady-state reads and save
1107
+ cadence are unchanged.
1010
1108
 
1011
1109
  The frontend's `dispatchFrontend` checkpoint retains dashboard facts plus only
1012
1110
  the latest run-started fact and the sampled lease holder's start (deduplicated).
1111
+ Its dashboard facts are a cache of facts after the feed's restoration point,
1112
+ not presentation authority: settings, Harvest, handoffs and upgrades, ticket
1113
+ migrations and missing accounts all render from canonical repository facts.
1013
1114
  Identity history is always partial, including normalized legacy version-4
1014
1115
  caches; a missing holder is resolved through the bounded per-run reduced read.
1015
1116
  Successful lease samples select or clear the retained holder; failed metadata
@@ -1114,11 +1215,20 @@ and every failure path leaves live and pristine byte-untouched.
1114
1215
 
1115
1216
  ```sh
1116
1217
  bun install
1117
- bun run check # Biome lint + format, zero diagnostics
1118
- bun test # unit tests, colocated *.test.ts
1119
- bun typecheck # tsc --noEmit
1218
+ bun run check # Biome lint + format, zero diagnostics
1219
+ bun run test # in-memory unit tests, colocated *.test.ts, IO-guarded
1220
+ bun run test:integration # IO tests, colocated *.integration.test.ts
1221
+ bun typecheck # tsc --noEmit
1120
1222
  ```
1121
1223
 
1224
+ A unit test touches no filesystem, subprocess, network socket, or real clock
1225
+ wait; `bun run test` preloads a guard that fails any test that does, naming the
1226
+ call. Any test that does IO is an integration test named
1227
+ `*.integration.test.ts`, whether or not it needs a database. Run the suites
1228
+ through these scripts rather than bare `bun test`, which skips the guard and
1229
+ also picks up integration files. Database-backed integration tests skip
1230
+ without `AB_POSTGRES_TEST_URL`; every other integration test runs without it.
1231
+
1122
1232
  For dashboard presentation work, run the repository-only hot CLI:
1123
1233
 
1124
1234
  ```sh
@@ -1201,7 +1311,16 @@ external ticket state, missing ticket/state, or conflicting slug ownership termi
1201
1311
  automatic recovery with an `abandoned` resolution and diagnostic reason. The
1202
1312
  ticket is left unchanged; an operator can leave it finished or cancelled, or
1203
1313
  inspect ownership and explicitly return it to Ready for another attempt. These
1204
- cases stop provider polling and diagnostic appends. Recovery failures are
1314
+ cases stop provider polling and further durable diagnostic appends. The tick
1315
+ that records the abandonment reports one dispatcher diagnostic naming the
1316
+ ticket and attempt, whether the claim was confirmed or its provider outcome is
1317
+ unknown, and the recorded reason. If that tick fails for any reason, its
1318
+ failure error carries the diagnostics instead. Later ticks do not repeat it.
1319
+ The `abandoned` resolution event records whether the claim was confirmed, and
1320
+ default `ab watch` repository attention reports the same line once as it lands,
1321
+ whether or not its tick failed; a fresh watch does not replay historical
1322
+ abandonments.
1323
+ Recovery failures are
1205
1324
  reported without preventing janitor, lease sweep, or other dispatch recovery.
1206
1325
  This is not general process
1207
1326
  crash recovery. Confirmed Ready/Triage transitions settle idempotently, so a
@@ -1213,42 +1332,16 @@ Reads use explicit manifest/chunk revisions without a ticket connection. Old
1213
1332
  pins retain ticket-row reads; existing service attachments need no migration,
1214
1333
  and attachments in old local stores are not moved.
1215
1334
 
1216
- In node `verify:*` context, `nodeVerification` in the manifest identifies the frozen
1217
- `range`, `indexPath`, `contributions`, `handPushedCommits` and `unattributedCommits`. Each contribution
1218
- has `build`, its preparation-time stored `ticket` identity, `spec: {kind: 'spec', rev}`,
1219
- `specPath` and `commits`. The JSON index repeats this metadata and adds the
1220
- exhaustive ordered `commits: [{sha, build?}]` mapping. Paths are workspace-relative
1221
- and reflect scratch allocation, including legacy tracked-file collisions.
1222
- Contribution specs normally live at `$AB_CONTEXT_DIR/contributions/<build>/spec.md`; the index
1223
- normally lives at `$AB_CONTEXT_DIR/node-verification.json`. These files are marked `derived`
1224
- in `materialized`, with their source build and revision recorded in the metadata.
1225
-
1226
- Membership comes from build identity trailers on every commit reachable in the
1227
- frozen parent-to-head range, including earlier cycles and merge side history.
1228
- The dispatcher gathers contributor material with repository authority while
1229
- preparing the exact cycle head, before launching verification. Specs use the
1230
- event-authorized revision at preparation, never an unsanctioned latest deposit
1231
- or mutable ticket body. Unknown identities, ambiguous or invalid trailers, and
1232
- missing source data prevent preparation. A versioned node-owned
1233
- `node-verification-context` artifact is deposited atomically with
1234
- `integration.prepared`, which cites its exact revision. Context hydration reads
1235
- only that citation, validates its cycle and range, and allocates public paths;
1236
- it needs no contributor reads or Git provenance discovery. Concurrent members
1237
- and resumed sessions retain the same frozen specs; a new cycle collects fresh
1238
- inputs. Missing, corrupt or mismatched inputs fail without publishing a manifest.
1239
- Historical agent cycles without a citation require a new prepared cycle;
1240
- check-only cycles do not require contributor inputs. Session and build scope
1241
- permissions remain unchanged. Commits without a build trailer are
1242
- listed as unattributed, a mechanical absence of a trailer rather than an authorization verdict.
1243
- `handPushedCommits: [{sha, originalSha, message}]` identifies node-owned hand-pushed
1244
- commits in the frozen range. Ownership uses the durable first-parent contribution
1245
- boundary; inherited and merge-side history are not automatically owned. Confirmed
1246
- rewrite aliases preserve original identity, and `message` is the full commit message.
1247
- These messages express maintainer-authorized intent: judge quality and consistency;
1248
- never fail these commits solely for lacking a covering spec.
1249
- Other node changes are authorized when the node spec or the spec of the contribution
1250
- that introduced it covers it; use the commit mapping to find that spec.
1251
- Leaf verification omits node provenance.
1335
+ Node verification context is prepared, not discovered at hydration.
1336
+ `packages/core/src/kernel/node-verification-context.ts` collects trailer-based
1337
+ provenance (`collectNodeVerificationProvenance`) and builds the versioned
1338
+ `node-verification-context` artifact (`prepareNodeVerificationContext`), which
1339
+ `packages/core/src/processes/dispatcher.ts` deposits atomically with
1340
+ `integration.prepared`. `packages/core/src/cli/context.ts` parses only that
1341
+ cited artifact (`parseNodeVerificationContext`) and materializes
1342
+ `nodeVerification`, the index and the contribution specs. The design contract
1343
+ is SPEC §8.3; the agent-facing explanation is
1344
+ [node verification context](integration-tree.md#node-verification-context).
1252
1345
 
1253
1346
  Both `ab dispatch` and sessionless `ab ticket` load the repository's plugins
1254
1347
  before selecting their TicketSource; dispatch passes that one adapter instance
@@ -1258,12 +1351,15 @@ but reported as skipped: live provider access requires credentials/resources
1258
1351
  and an explicit opt-in. When
1259
1352
  adding an adapter, start from its contract suite, not only the interface.
1260
1353
 
1261
- The two remote clients get client-only unit coverage in core itself:
1262
- `RemoteBuildStore` (`store/remote/client.test.ts`, which also pins scoped-token
1263
- minting/verification) and `HostedTicketSource` (`ports/tickets/remote.test.ts`)
1264
- run against an injected `fetchFn` with responses built from the protocol's wire
1265
- schemas. The full over-the-wire seam suites (client → HTTP → server) run in
1266
- `packages/hosted-store-service` in the same `bun test`.
1354
+ The two remote clients get client-only coverage in core itself, against an
1355
+ injected `fetchFn` with responses built from the protocol's wire schemas.
1356
+ `HostedTicketSource` (`ports/tickets/remote.test.ts`) is in-memory unit
1357
+ coverage that runs in `bun run test`. `RemoteBuildStore`
1358
+ (`store/remote/client.integration.test.ts`, which also pins scoped-token
1359
+ minting/verification) is integration coverage. The full over-the-wire seam
1360
+ suites (client → HTTP → server) live in `packages/hosted-store-service`
1361
+ (`*.seam.integration.test.ts`) and run with the `RemoteBuildStore` client tests
1362
+ in `bun run test:integration`.
1267
1363
 
1268
1364
  To run the Linear contract manually against a destructive scratch target:
1269
1365
 
@@ -1272,7 +1368,7 @@ AB_RUN_LIVE_PORT_CONTRACTS=1 \
1272
1368
  LINEAR_API_KEY=… \
1273
1369
  AB_LINEAR_CONTRACT_TEAM_KEY=SCRATCH \
1274
1370
  AB_LINEAR_CONTRACT_PROJECT_ID=… \
1275
- bun test packages/core/src/ports/tickets/linear.live.test.ts
1371
+ bun test packages/core/src/ports/tickets/linear.live.integration.test.ts
1276
1372
  ```
1277
1373
 
1278
1374
  The token must be able to create, update, relate, and archive issues in the
@@ -1290,7 +1386,7 @@ To run the GitHub contract manually:
1290
1386
  AB_RUN_LIVE_PORT_CONTRACTS=1 \
1291
1387
  GH_TOKEN=… \
1292
1388
  AB_GITHUB_CONTRACT_REPO=owner/destructive-scratch-repo \
1293
- bun test packages/core/src/ports/forge/github.live.test.ts
1389
+ bun test packages/core/src/ports/forge/github.live.integration.test.ts
1294
1390
  ```
1295
1391
 
1296
1392
  `GITHUB_TOKEN` may be used instead of `GH_TOKEN`. The repository must have
@@ -1309,15 +1405,15 @@ execution, and one-shot completion:
1309
1405
  ```sh
1310
1406
  AB_RUN_LIVE_PORT_CONTRACTS=1 \
1311
1407
  AB_CLAUDE_CONTRACT_MODEL=claude-sonnet-4-… \
1312
- bun test packages/core/src/ports/runner/claude.live.test.ts
1408
+ bun test packages/core/src/ports/runner/claude.live.integration.test.ts
1313
1409
 
1314
1410
  AB_RUN_LIVE_PORT_CONTRACTS=1 \
1315
1411
  AB_CODEX_CONTRACT_MODEL=gpt-… \
1316
- bun test packages/core/src/ports/runner/codex.live.test.ts
1412
+ bun test packages/core/src/ports/runner/codex.live.integration.test.ts
1317
1413
 
1318
1414
  AB_RUN_LIVE_PORT_CONTRACTS=1 \
1319
1415
  AB_PI_CONTRACT_MODEL=openai/gpt-… \
1320
- bun test packages/core/src/ports/runner/pi.live.test.ts
1416
+ bun test packages/core/src/ports/runner/pi.live.integration.test.ts
1321
1417
  ```
1322
1418
 
1323
1419
  Claude uses the locally installed Claude Code CLI and its configured login; the
@@ -1351,7 +1447,7 @@ That package probe does not invoke a provider and can be selected without
1351
1447
 
1352
1448
  ```sh
1353
1449
  AB_RUN_LIVE_PORT_CONTRACTS=1 \
1354
- bun test packages/core/src/ports/runner/pi.live.test.ts -t 'gates tools discovered'
1450
+ bun test packages/core/src/ports/runner/pi.live.integration.test.ts -t 'gates tools discovered'
1355
1451
  ```
1356
1452
 
1357
1453
  Once opted in, the probe fails with the missing expected tool and its exact
@@ -1400,7 +1496,14 @@ Dispatch prepares harvest claims using `HarvestRunner.run(true)` before issuing
1400
1496
  an execution grant. `harvest.execution.authorized` binds the selected run,
1401
1497
  execution and adopted lease holder; the guest resumes only that prepared run.
1402
1498
  Local completion records `harvest.execution.ended`; hosted completion retains
1403
- its provider release fact. Recovery controls remain trusted dispatcher work.
1499
+ its provider release fact. While an observable hosted execution is open, the
1500
+ dispatcher withholds harvest launch, so runner loss on its open session is
1501
+ judged only after its release fact. The guest's authority is that
1502
+ authorization, not the launching invocation's lease, which it never claims,
1503
+ renews or releases: at durable boundaries it re-reads the constant-size
1504
+ `hostedHarvestAuthority` value (`processes/harvest-execution-state.ts`) and
1505
+ exits `held`, closing its open session bracket, once its execution was
1506
+ released or replaced. Recovery controls remain trusted dispatcher work.
1404
1507
  Execution launch auth is transient and separate from serialized identity. Runners
1405
1508
  request exact phase grants after session-start facts and before runtime calls.
1406
1509
  Workspace plugin factories receive an exchange callback and a scrubbed environment,
@@ -1424,19 +1527,24 @@ Every ticket read includes an opaque `revision`. Pass it as `expectedRevision`
1424
1527
  `move`, `block` and `unblock`. A stale write fails without changing anything and
1425
1528
  reports the current revision. Omission preserves unguarded behavior. Blocker
1426
1529
  checks cover the entire batch. Dispatcher moves remain unguarded and change the
1427
- revision. Sources without guarded writes, including Linear, refuse supplied
1428
- revisions rather than ignoring them.
1530
+ revision. Sources without guarded writes, including Linear and GitHub, refuse
1531
+ supplied revisions rather than ignoring them.
1429
1532
 
1430
1533
  `ab ticket edit <id>` opens `$VISUAL`, falling back to `$EDITOR`, using TOML
1431
1534
  frontmatter and a Markdown body. Only title, body and labels are editable;
1432
- kind, target, id, blockers, creation key and reference comments are read-only. It saves only
1433
- changed fields with the opening revision. Unchanged or formatting-only edits
1535
+ kind, target, id, blockers, issue links, priority, creation key and reference comments are read-only. It saves only
1536
+ changed fields with the opening revision. Sources without guarded writes,
1537
+ including Linear and GitHub, re-read the ticket immediately before an
1538
+ unguarded write and refuse a changed revision, with the no-lock race window of file checks. Unchanged or formatting-only edits
1434
1539
  write nothing. On conflict, invalid input or editor failure, the error names an
1435
1540
  absolute file path containing the edited text. Read the current ticket and
1436
1541
  reapply the intended changes before retrying; conflicts are never merged.
1437
1542
 
1438
- File and Linear revisions fingerprint kind, target, title, body, canonical label/blocker sets
1439
- and state; reverting identical content restores its fingerprint. File checks
1543
+ File and Linear revisions fingerprint kind, target, title, body, canonical label/blocker sets,
1544
+ state and urgent priority; file revisions also cover nonempty issue links. GitHub revisions
1545
+ fingerprint kind, target, title, body, canonical label/blocker sets, state and issue links,
1546
+ including the ticket's own issue; GitHub tickets carry no comments. Reverting
1547
+ identical content restores its fingerprint. File checks
1440
1548
  re-read immediately before writing, with the existing no-lock race window.
1441
1549
  Direct file edits and state-directory moves change revisions. File comments
1442
1550
  change the body and revision; separate hosted comments do not. Hosted revisions
@@ -1453,7 +1561,8 @@ explicit ticket URL. Project registration and ticket policy publication through
1453
1561
  record, outside BuildStore events/artifacts; legacy uploaded configuration remains
1454
1562
  a compatibility fallback. Hosted lifecycle defaults are triage/ready/doing/done.
1455
1563
  Hosted state initialization checks only the distinct configured role names through
1456
- an indexed project/name lookup. Already-present names require no state mutation
1564
+ an indexed project/name lookup; the optional backlog and rejected names match
1565
+ case-insensitively within that same lookup. Already-present names require no state mutation
1457
1566
  lock or writes. Missing names are rechecked under the project advisory lock and
1458
1567
  inserted in the same transaction. Custom-state creation and policy publication
1459
1568
  always take that lock; publication reads the previous policy under it and retains
@@ -1468,10 +1577,26 @@ Hosted ticket detail reads expose complete, oldest-first structured comments in
1468
1577
  `ticket.comments`, preserving exact bodies. Scans do not fetch comments. Hosted
1469
1578
  HTTP clients opt in with `x-autobuild-ticket-comments: 1` so historical strict
1470
1579
  decoders retain compatible responses. File comments remain embedded in the body;
1471
- Linear comment reads are unchanged.
1580
+ Linear comment reads are unchanged. Issue links follow the same pattern with
1581
+ `x-autobuild-ticket-issue-links: 1`, stored in the `ab_tickets.issue_links` jsonb
1582
+ column that every listing already selects. Dependency states carry each blocker's
1583
+ native `state` for clients that send `x-autobuild-ticket-dependency-state: 1`,
1584
+ read from the row each lookup already loads; the dispatcher applies the
1585
+ configured rejected role on top (`markRejected` in `processes/dispatcher.ts`).
1586
+ Priority follows the issue-link pattern with `x-autobuild-ticket-priority: 1`,
1587
+ stored in the `ab_tickets.priority` column that every listing already selects;
1588
+ the ready listing orders urgent first in its existing statement, and the ticket
1589
+ server applies the same stable partition to every `list-ready` response.
1472
1590
 
1473
1591
  Ticket integration metadata lives in `ports/tickets/tree.ts`: source compatibility
1474
1592
  normalization, capability refusal, graph validation and the pure tree projection.
1593
+ Ticket priority lives in `ports/tickets/priority.ts`: the `priority` capability's
1594
+ typed refusal, the normal no-op strip and `urgentFirst`, the stable partition the
1595
+ dispatcher applies to its ready listing. Normalized tickets carry only `urgent`;
1596
+ the hosted service answers `priority` only to clients sending its capability
1597
+ header, so published strict wire schemas never see the key. The Linear adapter
1598
+ maps its native Urgent priority (1) to `urgent` and, on `normal`, clears only a
1599
+ current Urgent.
1475
1600
  File/fake/Linear adapters validate metadata at write boundaries; `operations.ts`
1476
1601
  and CLI/operator source opening wrap injected or plugin sources with the same
1477
1602
  compatibility facade. Metadata is excluded from hosted persistence/protocols.
@@ -1508,9 +1633,11 @@ The optional grouped Forge rewrite capability owns authoritative head snapshots,
1508
1633
  immutable `refs/autobuild/archive/<slug>/<sha>` publication and expected-head CAS.
1509
1634
  Remote archives also publish commits present only on the remote: GitHub uses create-only
1510
1635
  Git-reference REST creation when the workspace lacks the commit, retaining guarded Git
1511
- pushes for local objects. Exact remote readback confirms publication, then a depth-one
1512
- fetch by the archive ref (without tags or configured refmap expansion) restores missing
1513
- commits and verifies them locally before returning.
1636
+ pushes for local objects. Exact remote readback confirms publication, then a non-shallow
1637
+ fetch of only that exact archive ref (without tags, configured refmap expansion or a
1638
+ depth limit) restores missing commits and their missing ancestry, writes no shallow
1639
+ boundary, leaves an already-shallow repository's existing boundaries unchanged, and
1640
+ verifies the commits locally before returning.
1514
1641
  GitHub uses explicit Git transport leases; local-git uses shared-database
1515
1642
  `update-ref` CAS without network calls. Exact authoritative readback acknowledges
1516
1643
  publication. Remote-backed local refs are caches refreshed without expected-old
@@ -1542,7 +1669,7 @@ Replay retention stores thin Git packs in bounded binary chunks, with a fixed-si
1542
1669
 
1543
1670
 
1544
1671
  GitHub archive push/fresh-fetch and rewrite contracts are manual opt-in cases in
1545
- `ports/forge/github.live.test.ts`, using `AB_RUN_LIVE_PORT_CONTRACTS=1` and an
1672
+ `ports/forge/github.live.integration.test.ts`, using `AB_RUN_LIVE_PORT_CONTRACTS=1` and an
1546
1673
  explicit disposable `AB_GITHUB_CONTRACT_REPO`. Offline transport tests are not
1547
1674
  live provider evidence.
1548
1675
 
@@ -1552,7 +1679,10 @@ live provider evidence.
1552
1679
  `node.restack-availability-observed` facts. The dispatcher checks this reduced value
1553
1680
  before repository preparation; transactions retain unavailable requests and explicitly
1554
1681
  settle obsolete destinations. Landing and ancestry changes invalidate waiting results
1555
- even at unchanged Git heads. Targeting-leaf cancellation runs only at the actionable
1682
+ even at unchanged Git heads. The dispatcher's per-tick availability batch is
1683
+ `repoBuildDigests(true)`, which includes mixed-version deferred builds' landing facts
1684
+ without deciding for them, so its fingerprint equals the one the node transaction
1685
+ records. Targeting-leaf cancellation runs only at the actionable
1556
1686
  replay boundary using `landing-publication.ts` receipts, including recovery.
1557
1687
 
1558
1688
  `kernel/node-restack.ts` inventories the contribution above the durable previous
@@ -1561,7 +1691,11 @@ and replays individual changes. `kernel/node-restack-state.ts` reduces writer
1561
1691
  reservations, ordered receipts, conflicts, publication intent, confirmed effects,
1562
1692
  and inventory. `kernel/node-restack-transaction.ts` retains replay objects and
1563
1693
  archives before expected-head publication. The dispatcher polls all open nodes,
1564
- including empty nodes, and advances clean cascades without agent calls. Only the
1694
+ including empty nodes, to observe parent movement durably, but replays a node only
1695
+ when it has demand: before a complete nonempty node verifies, before merge if its
1696
+ parent moved, for queued dependency presence, on `ab restack <node>`, or after
1697
+ accepted re-parenting. A clean replay needs no agent call. A restacked node does
1698
+ not restack its descendants: each nested node needs its own demand. Only the
1565
1699
  active conflicted item attaches a reconcile runner, using source-build artifacts
1566
1700
  materialized by the dispatcher into the integration owner's store scope.
1567
1701
 
@@ -1575,7 +1709,7 @@ confirmed, revalidated request with `node.parent-accepted`. Provider edits use
1575
1709
  the same validation; refusals are deduplicated by revision, target and reason.
1576
1710
  Uncertain writes recover by source readback rather than replaying a caller patch.
1577
1711
  Tracker observation errors are contained within that observation, preserving
1578
- ordinary cascade and PR handling against durable ancestry. Already accepted moves
1712
+ ordinary demand-driven restack and PR handling against durable ancestry. Already accepted moves
1579
1713
  complete their PR effects without another tracker read. Rejection comparisons use
1580
1714
  revision, target and reason fields so JSONB key ordering cannot defeat deduplication;
1581
1715
  `node.parent-rejection-cleared` removes a current refusal after correction while
@@ -1591,8 +1725,11 @@ PR through the optional `Forge.retargetPr` capability, inspects its acknowledged
1591
1725
  base/head, records a receipt and completes the parent operation. GitHub uses the
1592
1726
  [documented PR update endpoint](https://docs.github.com/en/rest/pulls/pulls#update-a-pull-request)
1593
1727
  with a branch-name `base`. Publication and PR acknowledgement retry separately;
1594
- terminal human PR changes keep their ordinary handling. Children retain the moved
1595
- node's identity and branch, so the usual target observations cascade the move.
1728
+ terminal human PR changes keep their ordinary handling. Children keep targeting
1729
+ the moved node's identity and branch and observe its new head, but re-parenting a
1730
+ node alone does not restack its descendants; each descendant catches up only
1731
+ through its own demand, such as verification, merge, queued dependency presence,
1732
+ or `ab restack <node>`.
1596
1733
 
1597
1734
  In origin mode, node plumbing uses the forge's trusted `kernelExec` transport.
1598
1735
  The GitHub adapter supplies its token through subprocess-only Git configuration,
@@ -1608,9 +1745,13 @@ receive-pack path.
1608
1745
  `kernel/node-landing.ts` shares the node writer lease and reservation with
1609
1746
  restacking. It cancels native auto-merge, refreshes actual PR refs, proves the
1610
1747
  exact destination ungated and fast-forwards the canonical child commit under
1611
- CAS. The destination write proves merge; provider PR reconciliation is
1612
- best-effort and never decides or retries that write. Root merge retains squash
1613
- semantics. Store adapters expose node writer claim, renewal and holder-checked
1748
+ CAS. Only exact authoritative readback of the destination showing the
1749
+ candidate, or the durable receipt of an accepted write overtaken before
1750
+ readback, records `node.rewritten` and the source build's `pr.merged`; another
1751
+ observed head settles the writer `contended`, a failed readback records nothing
1752
+ and is retried, and recovery of an interrupted merge uses the same exact
1753
+ readback. Provider PR reconciliation is best-effort and never decides or
1754
+ retries that merge. Root merge retains squash semantics. Store adapters expose node writer claim, renewal and holder-checked
1614
1755
  release separately from execution leases; Postgres schema version 15 adds their
1615
1756
  columns. Reservations live in the event stream and survive lease expiry.
1616
1757
 
@@ -1622,7 +1763,11 @@ both inventory and active items, retaining original identities after rewrites.
1622
1763
 
1623
1764
 
1624
1765
  Integration completion is sampled by `kernel/integration-completeness.ts` from
1625
- exhaustive source listings, frozen claims and retained contribution identities.
1766
+ exhaustive source listings (a source's `listTargeting` per node, memoized for
1767
+ the dispatcher pass, else one shared `listAll`), frozen claims and retained
1768
+ contribution identities. The hosted source serves `listTargeting` through the
1769
+ `list-targeting` ticket operation, which the PostgreSQL ticket store answers with
1770
+ one statement on the `(repo, target_id)` index.
1626
1771
  `integration.*` events retain observations, immutable cycle inputs, merge
1627
1772
  intents, provenance and tree audits. The build reducer projects these facts and
1628
1773
  `engine.ts` routes nodes directly through verification, without producer phases.
@@ -1714,14 +1859,21 @@ facts retain the mixed-version wait gate and durable compatibility diagnostic.
1714
1859
  When the scoped `ab context` initial own-build read fails, the CLI best-effort
1715
1860
  writes `session.build-read-failed` with exact session, phase, round, operation
1716
1861
  `context`, reason `own-build-read`, and diagnostic. A valid terminal from that
1717
- session wins if the agent recovers. Otherwise settlement records `phase.deferred`
1862
+ session, or from its native continuation, wins if the agent recovers; a
1863
+ continuation inherits its predecessor's pending deferral, so a chain parks at
1864
+ most once. A later successful own-build read in the same session records
1865
+ `session.build-read-recovered`, which a newer classified failure invalidates. A
1866
+ finalize post-step, which has no terminal, settles as recovered only with that
1867
+ evidence and a completed turn, and the kernel then records its
1868
+ `finalize.step-completed`. Otherwise settlement records `phase.deferred`
1718
1869
  and `phase.deferral-escalated`, immediately projecting ordinary blocked attention.
1719
1870
  The raise cites `own-build-read:<evidenceSeq>`; replay repairs either settlement
1720
1871
  crash gap before launching another agent. An `escalation.answered` retry or
1721
1872
  guidance authorizes one fresh session without resetting genuine phase failures;
1722
1873
  a new classified failure parks again. There are zero automatic paid retries
1723
1874
  after this deferral. If evidence cannot be written, ordinary recovery applies;
1724
- agent output and `no-terminal` alone never classify a read failure.
1875
+ agent output and `no-terminal` alone never classify a read failure or settle
1876
+ one as recovered.
1725
1877
 
1726
1878
  A kernel store write rejected with HTTP 413 raises `StoreWriteTooLargeError`
1727
1879
  and records `phase.failed {willRetry:false}` on its first attempt, including
@@ -1807,12 +1959,43 @@ Classified rate limits retain repository cooldown and consume no publication
1807
1959
  retry allowance. Rejected pushes, lease conflicts, dirty trees and unclassified
1808
1960
  errors retain their existing behavior.
1809
1961
 
1962
+ A forge that refuses a dispatcher-side finalize PR create with a client error
1963
+ throws `ForgeRejection` (`ports/forge-failure.ts`), carrying the forge name, HTTP
1964
+ status and the forge's message; GitHub's "No commits between" 422 is its
1965
+ `NoCommitsBetweenBranchesError` subclass. Rate limits and transient failures
1966
+ stay `ForgeFailure`s on their existing paths. `kernel/finalize-pr-rejection.ts`
1967
+ raises one `finalize` escalation (`policy`, `non-retryable-phase-failure`) per
1968
+ rejection, keyed by the publication request and the answer that authorized the
1969
+ attempt, and throws `ForgeRequestDeferred`. Launch, ended-execution and release
1970
+ settlement therefore record no `infrastructure.failed`. While the escalation is
1971
+ open, `cli/publication-settlement.ts` defers on the facts it already read, with
1972
+ no provider probe, description read or forge request. Each answer authorizes
1973
+ one more PR create; an abort answer stops retrying so release can proceed.
1974
+
1810
1975
  Janitor failures are durable per-build episodes. Eligible failures retry after
1811
1976
  30, 60, 120, 240 seconds, then at the configured cap (300 seconds by default).
1812
- Skipped polls preserve the episode across restart. After
1813
- `policy.janitorFailureAttentionSeconds` (600 by default), `build.janitor-failing`
1814
- notifies default watchers and appears on the build row. A successful attempt
1815
- clears it. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
1977
+ A classified forge rate limit is repository cooldown, not a janitor failure:
1978
+ neither the first limited response nor the cooldown that follows starts an
1979
+ episode or records an attempt, so a build that only waits out cooldown never
1980
+ escalates. Skipped polls preserve the episode across restart. Both thresholds
1981
+ below are wall-clock from the episode's first failed attempt and are checked
1982
+ when an attempt fails, so cooldown inside an episode that already started still
1983
+ counts. After `policy.janitorFailureAttentionSeconds` (600 by default),
1984
+ `build.janitor-failing` notifies default watchers and appears on the build row.
1985
+ After `policy.janitorFailureEscalationSeconds` (3600 by default), the build
1986
+ raises one escalation through `build.janitor-escalated`, naming the failing
1987
+ operation, the last error, the failed attempt count and when the episode
1988
+ started. The build is then blocked and shows wherever open escalations show.
1989
+ The janitor keeps retrying on its backoff underneath; a successful attempt
1990
+ clears the attention, closes the escalation unanswered and the build continues.
1991
+ Answering it with a bare retry makes the janitor attempt on its next tick. An
1992
+ episode raises at most one escalation; a new episode after recovery can raise
1993
+ another. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
1994
+ A dispatcher that cannot execute Git for kernel node work (a missing or
1995
+ unloadable `git` for the bare clone) records no janitor failures. It records
1996
+ one durable `dispatcher.kernel-git-unavailable` repository condition, node work
1997
+ waits, and `dispatcher.kernel-git-recovered` closes the condition once a clone
1998
+ succeeds.
1816
1999
 
1817
2000
  A classified forge rate limit records repository degradation with `resetAt`.
1818
2001
  Forge work waits during cooldown; passing the deadline permits a recovery
@@ -1986,8 +2169,9 @@ manually. ChatGPT credentials are authorized with `ab accounts login NAME
1986
2169
  is the sole refresh owner; no sandbox refreshes. Local Codex uses a protected
1987
2170
  loopback inference transport and isolated CODEX_HOME, preserving the shell HOME
1988
2171
  and leaving ambient login untouched.
1989
- Hosted validation uses write-only metadata and states that the first hosted
1990
- build is the live check; local validation makes a minimal runtime request.
2172
+ Hosted validation uses write-only metadata for ChatGPT refreshing secrets and
2173
+ Claude/Kimi static project secrets, and states that the first hosted build is
2174
+ the live check; local validation makes a minimal runtime request.
1991
2175
 
1992
2176
  Selected Claude/Kimi credentials stay out of process arguments: each invocation
1993
2177
  uses a private 0700 directory and a regular 0600 settings file, removed after
@@ -2035,8 +2219,7 @@ fresh connection starts empty and resets hosted ticket numbering. `ab disconnect
2035
2219
  revokes credentials only; admin `projects remove` unregisters without purging.
2036
2220
  See [project deletion protocol](operator-api.md#permanent-project-deletion).
2037
2221
 
2038
- The ticket-source port optionally exposes `listPage(criteria, page)` for paged operator reads. PostgreSQL counts matches and applies SQL LIMIT/OFFSET; other sources retain exhaustive-read slicing. CLI and dispatcher reads stay exhaustive. See [ticket source contract](ticket-sources.md#writing-your-own).
2039
-
2222
+ ### Hosted event reads
2040
2223
 
2041
2224
  Hosted event reads use the bounded capabilities in `store/event-reads.ts`:
2042
2225
  repository cursors must be at least `max(0, head - 1000)`, and build pages