@defrex/autobuild 1.4.2 → 1.5.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 (201) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +432 -92
  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 +2 -1
  7. package/docs/architecture.md +282 -127
  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 +163 -102
  13. package/docs/dispatcher-hosting.md +19 -3
  14. package/docs/dispatcher.md +9 -4
  15. package/docs/integration-overview.md +2 -2
  16. package/docs/integration-tree.md +91 -28
  17. package/docs/merge-policy.md +28 -9
  18. package/docs/operator-api.md +43 -18
  19. package/docs/operator-surfaces.md +1 -1
  20. package/docs/plugin-authoring.md +85 -8
  21. package/docs/remote-store-protocol.md +25 -7
  22. package/docs/remote-ticket-protocol.md +126 -12
  23. package/docs/restacking.md +20 -6
  24. package/docs/seams.md +2 -2
  25. package/docs/setup.md +19 -13
  26. package/docs/spec-standard.md +2 -1
  27. package/docs/ticket-dependencies.md +26 -8
  28. package/docs/ticket-migration.md +70 -7
  29. package/docs/ticket-sources.md +82 -5
  30. package/docs/tickets.md +34 -2
  31. package/docs/troubleshooting.md +2 -2
  32. package/docs/verification.md +5 -5
  33. package/docs/website.md +8 -0
  34. package/docs/workspaces.md +1 -1
  35. package/package.json +4 -3
  36. package/packages/core/src/accounts/hosted-readiness.ts +21 -0
  37. package/packages/core/src/cli/attention.ts +1 -0
  38. package/packages/core/src/cli/build-control.ts +36 -12
  39. package/packages/core/src/cli/connect.ts +9 -18
  40. package/packages/core/src/cli/context.ts +44 -0
  41. package/packages/core/src/cli/dashboard/configuration.ts +11 -0
  42. package/packages/core/src/cli/dashboard/model.ts +40 -10
  43. package/packages/core/src/cli/dashboard/queue.ts +21 -0
  44. package/packages/core/src/cli/dashboard/render.ts +40 -22
  45. package/packages/core/src/cli/dispatch-frontend.ts +63 -30
  46. package/packages/core/src/cli/dispatch-mode.ts +35 -16
  47. package/packages/core/src/cli/dispatch-repository-feed.ts +40 -11
  48. package/packages/core/src/cli/dispatch.ts +154 -47
  49. package/packages/core/src/cli/help.ts +59 -22
  50. package/packages/core/src/cli/init-hosted-accounts.ts +54 -0
  51. package/packages/core/src/cli/init-readiness-remote.ts +16 -3
  52. package/packages/core/src/cli/init-validation.ts +144 -42
  53. package/packages/core/src/cli/issue-links.ts +67 -0
  54. package/packages/core/src/cli/main.ts +32 -15
  55. package/packages/core/src/cli/pr-summary-publication.ts +38 -7
  56. package/packages/core/src/cli/publication-settlement.ts +36 -24
  57. package/packages/core/src/cli/repository-status.ts +201 -49
  58. package/packages/core/src/cli/status.ts +41 -3
  59. package/packages/core/src/cli/terminals.ts +37 -2
  60. package/packages/core/src/cli/ticket-editor.ts +20 -6
  61. package/packages/core/src/cli/ticket.ts +264 -46
  62. package/packages/core/src/cli/triage-count-sampler.ts +59 -0
  63. package/packages/core/src/cli/watch.ts +4 -0
  64. package/packages/core/src/config/live.ts +45 -4
  65. package/packages/core/src/config/load.ts +9 -0
  66. package/packages/core/src/config/pipeline-source.ts +6 -2
  67. package/packages/core/src/config/ready-assignee.ts +86 -0
  68. package/packages/core/src/config/schema.ts +164 -36
  69. package/packages/core/src/distribution-packaging.ts +1 -1
  70. package/packages/core/src/events/catalog.ts +5 -0
  71. package/packages/core/src/events/compatibility.ts +2 -1
  72. package/packages/core/src/events/payloads.ts +70 -0
  73. package/packages/core/src/events/policy.ts +8 -0
  74. package/packages/core/src/events/repository.ts +91 -28
  75. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +41 -0
  76. package/packages/core/src/kernel/build-identity.ts +12 -0
  77. package/packages/core/src/kernel/change-presence.ts +139 -6
  78. package/packages/core/src/kernel/dispatch-capacity.ts +80 -14
  79. package/packages/core/src/kernel/dispatch-status.ts +10 -1
  80. package/packages/core/src/kernel/dispatch-upgrade.ts +104 -5
  81. package/packages/core/src/kernel/engine.ts +4 -2
  82. package/packages/core/src/kernel/finalize-pr-rejection.ts +95 -0
  83. package/packages/core/src/kernel/generators/repository-journals.ts +15 -1
  84. package/packages/core/src/kernel/harvest.ts +4 -1
  85. package/packages/core/src/kernel/integration-completeness.ts +104 -17
  86. package/packages/core/src/kernel/integration-landing.ts +17 -0
  87. package/packages/core/src/kernel/integration-state.ts +17 -0
  88. package/packages/core/src/kernel/issue-keywords.ts +202 -0
  89. package/packages/core/src/kernel/janitor-failure.ts +11 -0
  90. package/packages/core/src/kernel/kernel-git.ts +87 -0
  91. package/packages/core/src/kernel/landing-readiness.ts +25 -17
  92. package/packages/core/src/kernel/log-index.ts +1 -1
  93. package/packages/core/src/kernel/node-issue-links.ts +142 -0
  94. package/packages/core/src/kernel/node-parent.ts +6 -0
  95. package/packages/core/src/kernel/node-restack-transaction.ts +2 -0
  96. package/packages/core/src/kernel/pr-summary.ts +24 -0
  97. package/packages/core/src/kernel/read-deferrals.ts +75 -12
  98. package/packages/core/src/kernel/read-facts.ts +32 -1
  99. package/packages/core/src/kernel/reconcile-restack.ts +1 -1
  100. package/packages/core/src/kernel/reducer-registry.ts +31 -1
  101. package/packages/core/src/kernel/reducer.ts +90 -2
  102. package/packages/core/src/kernel/ticket-preparation.ts +12 -0
  103. package/packages/core/src/kernel/verify-budget.ts +43 -0
  104. package/packages/core/src/operator/index.ts +3 -1
  105. package/packages/core/src/operator/presentation.ts +3 -0
  106. package/packages/core/src/operator/protocol.ts +38 -2
  107. package/packages/core/src/operator/query.ts +66 -29
  108. package/packages/core/src/operator/registry.ts +47 -26
  109. package/packages/core/src/operator/tickets.ts +77 -10
  110. package/packages/core/src/plugin-sdk/index.ts +13 -0
  111. package/packages/core/src/plugins/manifest.ts +1 -1
  112. package/packages/core/src/plugins/registry.ts +1 -0
  113. package/packages/core/src/ports/forge/contract.ts +69 -0
  114. package/packages/core/src/ports/forge/create.ts +5 -0
  115. package/packages/core/src/ports/forge/fake.ts +184 -3
  116. package/packages/core/src/ports/forge/git-rewrite.ts +4 -2
  117. package/packages/core/src/ports/forge/github.ts +175 -38
  118. package/packages/core/src/ports/forge/local-git.ts +14 -0
  119. package/packages/core/src/ports/forge/readiness.ts +10 -0
  120. package/packages/core/src/ports/forge-failure.ts +43 -0
  121. package/packages/core/src/ports/runner/claude.ts +7 -1
  122. package/packages/core/src/ports/runner/codex.ts +7 -2
  123. package/packages/core/src/ports/runner/native-cli-fixture.ts +2 -1
  124. package/packages/core/src/ports/runner/pi.ts +7 -1
  125. package/packages/core/src/ports/runner/runtime.ts +3 -0
  126. package/packages/core/src/ports/runner/start-prompt.ts +37 -0
  127. package/packages/core/src/ports/tickets/contract.ts +320 -7
  128. package/packages/core/src/ports/tickets/create.ts +72 -17
  129. package/packages/core/src/ports/tickets/fake.ts +18 -0
  130. package/packages/core/src/ports/tickets/file-codec.ts +20 -0
  131. package/packages/core/src/ports/tickets/file.ts +43 -1
  132. package/packages/core/src/ports/tickets/github-fake.ts +1123 -0
  133. package/packages/core/src/ports/tickets/github-issues.ts +431 -0
  134. package/packages/core/src/ports/tickets/github-validators.ts +194 -0
  135. package/packages/core/src/ports/tickets/github.ts +2029 -0
  136. package/packages/core/src/ports/tickets/hosted-index.ts +34 -3
  137. package/packages/core/src/ports/tickets/issue-links.ts +86 -0
  138. package/packages/core/src/ports/tickets/lifecycle.ts +60 -4
  139. package/packages/core/src/ports/tickets/linear.ts +66 -6
  140. package/packages/core/src/ports/tickets/migration.ts +290 -68
  141. package/packages/core/src/ports/tickets/operations.ts +98 -12
  142. package/packages/core/src/ports/tickets/priority.ts +55 -0
  143. package/packages/core/src/ports/tickets/remote-protocol.ts +195 -29
  144. package/packages/core/src/ports/tickets/remote.ts +188 -13
  145. package/packages/core/src/ports/tickets/revision.ts +22 -1
  146. package/packages/core/src/ports/tickets/states.ts +43 -0
  147. package/packages/core/src/ports/tickets/tree.ts +58 -12
  148. package/packages/core/src/ports/tickets/update.ts +12 -2
  149. package/packages/core/src/ports/types.ts +190 -9
  150. package/packages/core/src/ports/workspace/commit-preservation.ts +135 -13
  151. package/packages/core/src/ports/workspace/git-worktree.ts +3 -1
  152. package/packages/core/src/ports/workspace/vercel-sandbox.ts +118 -27
  153. package/packages/core/src/processes/build-runner.ts +99 -21
  154. package/packages/core/src/processes/dispatcher.ts +822 -338
  155. package/packages/core/src/processes/execution-no-progress.ts +5 -0
  156. package/packages/core/src/processes/harvest-runner.ts +17 -8
  157. package/packages/core/src/processes/harvest.ts +5 -8
  158. package/packages/core/src/processes/tick-publication.ts +12 -2
  159. package/packages/core/src/processes/ticket-scan-schedule.ts +78 -0
  160. package/packages/core/src/processes/workspace-preservation.ts +36 -1
  161. package/packages/core/src/runtime-identity.ts +10 -2
  162. package/packages/core/src/scenarios/harness.ts +4 -0
  163. package/packages/core/src/store/adapter.ts +7 -1
  164. package/packages/core/src/store/contract.ts +83 -2
  165. package/packages/core/src/store/digest.ts +32 -1
  166. package/packages/core/src/store/reducer-value-shapes.json +4187 -3391
  167. package/packages/core/src/store/remote/protocol.ts +2 -0
  168. package/packages/core/src/store/remote/released-clients.json +11 -0
  169. package/packages/core/src/store/remote/released-reducer-values/1.5.0.json +26924 -0
  170. package/packages/core/src/store/remote/released-reducer-values/index.ts +2 -0
  171. package/packages/core/src/store/repo-state-events.ts +2 -0
  172. package/packages/core/src/store/types.ts +5 -0
  173. package/packages/core/src/testing/dispatch-read-budget.ts +729 -123
  174. package/packages/core/src/testing/index.ts +18 -1
  175. package/packages/core/src/testing/presence-history.ts +79 -0
  176. package/packages/core/src/testing/reduced-read-budget.ts +1085 -31
  177. package/packages/core/src/testing/upgrade-generations.ts +77 -0
  178. package/skills/code-review/SKILL.md +4 -3
  179. package/skills/finalize/SKILL.md +18 -2
  180. package/skills/guide/SKILL.md +374 -136
  181. package/skills/guide/references/accounts.md +9 -0
  182. package/skills/guide/references/integration-tree.md +91 -28
  183. package/skills/guide/references/merge-policy.md +28 -9
  184. package/skills/guide/references/operator-api.md +43 -18
  185. package/skills/guide/references/plugin-authoring.md +85 -8
  186. package/skills/guide/references/remote-store-protocol.md +25 -7
  187. package/skills/guide/references/remote-ticket-protocol.md +126 -12
  188. package/skills/guide/references/restacking.md +20 -6
  189. package/skills/guide/references/setup.md +19 -13
  190. package/skills/guide/references/spec-standard.md +2 -1
  191. package/skills/guide/references/ticket-dependencies.md +26 -8
  192. package/skills/guide/references/ticket-migration.md +70 -7
  193. package/skills/harvest-review/SKILL.md +4 -3
  194. package/skills/implement/SKILL.md +20 -1
  195. package/skills/operate/SKILL.md +103 -28
  196. package/skills/plan/SKILL.md +1 -1
  197. package/skills/reconcile/SKILL.md +5 -4
  198. package/skills/spec/SKILL.md +15 -2
  199. package/skills/tickets/SKILL.md +114 -37
  200. package/templates/autobuild.toml +5 -0
  201. package/templates/hosted-service/package.json +2 -2
@@ -17,8 +17,9 @@ 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
+ Open escalations remain parked until an external answer, from the operator
21
+ agent or you, is recorded; a build-phase agent never answers its own
22
+ escalation. Pending operator commands remain actionable.
22
23
  3. **Ingesters propose, humans dispatch.** Nothing auto-generated passes
23
24
  Triage without a human grooming it to Ready, unless the repository waives
24
25
  that gate explicitly with `[tickets].proposalState`.
@@ -58,7 +59,8 @@ surface with `packages/postgres-store`; the separate optional
58
59
  `packages/hosted-dispatcher` workspace owns the cron-driven hosted dispatcher
59
60
  (the `/api/dispatch` route driver, and the deploy-time `pack-distribution` and
60
61
  `ship-deployment` commands that pack the guest archive and ship it, its
61
- manifest and the selected provider plugins into the dispatch function) and
62
+ manifest, a self-contained `linux-x64` Git for kernel node operations, and the
63
+ selected provider plugins into the dispatch function) and
62
64
  peers on both the core and the store service. The optional `packages/vercel-sandbox` workspace publishes the
63
65
  `@defrex/autobuild-vercel-sandbox` provider plugin (AUT-517): while the
64
66
  builtin hosts the implementation, its manifest re-registers the provider name
@@ -81,7 +83,7 @@ remote-store protocol requires matching client and server versions.
81
83
  | `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
84
  | `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
85
  | `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 |
86
+ | `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
87
  | `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
88
  | `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
89
  | `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 +91,14 @@ remote-store protocol requires matching client and server versions.
89
91
  | `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
92
  | `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
93
  | `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 |
94
+ | `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
95
  | `packages/core/src/cli/dashboard/` | `ab dispatch`'s fixed live frame: pure projection, renderer, poll cache, and deterministic image renderer | §14 |
94
96
  | `bin/agent/ab` | Private launcher placed first on agent-session `PATH`; delegates to the canonical `bin/ab.ts` | §8.1 |
95
97
  | `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 | — |
98
+ | `packages/core/src/scenarios/` | End-to-end harness over a temporary Git origin and worktrees (integration tests) and product scenarios | — |
97
99
  | `tools/` | This repository's local maintainer tooling, including verification, dashboard capture, and release cutting; not shipped product behavior | — |
98
100
  | `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 |
101
+ | `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
102
  | `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
103
  | `templates/` | Valid setup-only config baseline with comment anchors rendered by `ab init` | §16.3 |
102
104
 
@@ -155,6 +157,8 @@ canonical changed-outcome scan event by sequence and stores only its scheduling
155
157
  baseline, mode and input fingerprints. It is disposable coordination metadata,
156
158
  not a reducer snapshot or authoritative outcome; loss permits a safe extra scan.
157
159
  Keyed reads and atomic upserts have constant cost and never read journal rows.
160
+ The dispatcher skips the keyed read entirely while the recorded fact alone
161
+ proves the scan interval has not elapsed.
158
162
 
159
163
  **Reducer snapshots.** The `BuildStore` port can keep, per scope (one build log
160
164
  or the repository journal) and registered reducer, that reducer's accumulator as
@@ -309,7 +313,7 @@ cursors outside the tail window fail without replay; see
309
313
  [hosted event bounds and exact resume](remote-store-protocol.md#hosted-event-bounds-and-exact-resume).
310
314
  Actual event listings, transcripts and cursor streams remain raw reads. The
311
315
  interactive terminal frontend retains its independently established incremental
312
- feed. `tools/persisted-reduced-reads.test.ts` scans production TypeScript calls
316
+ feed. `tools/persisted-reduced-reads.integration.test.ts` scans production TypeScript calls
313
317
  and maintains precise, reason-bearing exceptions for these boundaries and pure
314
318
  reference projections; stale exceptions fail the check.
315
319
 
@@ -361,11 +365,11 @@ post-steps reuse the timer but drain expiry through their existing failure-toler
361
365
  completion and observation path. Harvest and deterministic commands do not use
362
366
  this build-phase timer.
363
367
 
364
- **Human guidance delivery.** The routing fact is an `escalation.answered`
368
+ **Guidance delivery.** The routing fact is an `escalation.answered`
365
369
  event carrying `resolution: "guidance"`; nothing else routes an answer. `ab
366
370
  answer` and the dashboard's blocked-build resume control are two surfaces over
367
371
  the one `packages/core/src/cli/build-control.ts` operation that appends it, so delivery is
368
- identical whichever a human used.
372
+ identical whichever surface the operator agent or you used.
369
373
  `packages/core/src/kernel/engine.ts` routes answers from `plan` and `plan-review` to the next
370
374
  `plan` round, and answers from `implement` and `code-review` to the next
371
375
  `implement` round. An agent verifier's own escalation is the deliberate
@@ -400,7 +404,7 @@ recovery; the matching launch consumes it once without process-local state. A
400
404
  producer round's feedback is a discriminated union — findings, a
401
405
  failed verify report, or guidance — and a round may carry none, so a round with
402
406
  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
407
+ corresponding input, and `packages/core/src/cli/skill-guidance.integration.test.ts` derives that
404
408
  requirement from the phase table.
405
409
 
406
410
  **Finalize publication.** Content-producing `finalize:*` checks or agents
@@ -629,11 +633,19 @@ non-destructive execution fence for the exact workspace and execution generation
629
633
  It preserves unpublished branch commits and distinct detached producer candidates
630
634
  under immutable `refs/autobuild/archive/<build>/<sha>` refs, verifies their exact
631
635
  readback, and records `workspace.commits-preserved` before cleanup. Replacement
632
- provisioning restores those exact refs before starting an agent. Preservation
636
+ provisioning restores those exact refs before starting an agent. A preserved
637
+ branch head that the build's latest 64 replaced heads cover, as the replaced
638
+ head itself or one of its ancestors, is kept only as archived objects: it is
639
+ never preserved or restored as the branch, and provisioning records the skip as
640
+ `restorationSkipped` on `workspace.provisioned`. Rewrites older than that bound,
641
+ and unpublished divergent branch work, are still refused. Preservation
633
642
  never advances the public build branch. A confirmed absent environment, or one
634
643
  that exists without a provisioned checkout, records `workspace.commits-lost`,
635
644
  naming known candidates and explicitly noting that any additional unpublished
636
- SHAs could not be inspected. Unknown fencing, inspection, transport, or
645
+ SHAs could not be inspected. An environment that never started executing holds
646
+ no unpublished work: objects its checkout lacks mean nothing to preserve, so
647
+ cleanup records `workspace.commits-preserved` carrying forward earlier preserved
648
+ heads, then releases and replaces it. Unknown fencing, inspection, transport, or
637
649
  receipt-write outcomes leave the workspace and snapshots intact. A workspace
638
650
  flagged by `workspace.cleanup-required` is never launched into: the dispatcher
639
651
  releases it and provisions the next generation. A preservation or release
@@ -719,7 +731,27 @@ dispatch is tolerated. `Ticket.creationKey` is the optional stable external
719
731
  create/adoption correlation, distinct from `Ticket.ref.id`; Linear projects its
720
732
  issue UUID and file/fake preserve their idempotency metadata through create,
721
733
  adoption, get, and list paths. Legacy/plugin tickets may omit it and dispatch
722
- unchanged.
734
+ 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).
735
+
736
+ The `github` source spans four modules. `ports/tickets/github.ts` is the
737
+ adapter: REST over the forge's `GitHubRequest` transport and credential order,
738
+ plus display-only state counts (one GraphQL request, and one more per
739
+ further page of 100 `autobuild:` labels) and the bounded
740
+ `last: 100` timeline read that decides whether a reopened issue's state label
741
+ is stale. `ports/tickets/github-issues.ts` holds the pure mapping: issue to
742
+ state through `autobuild:` labels and closing reasons, state to write, issue
743
+ ids, the creation-key body marker, `autobuild-link:` link labels, and kind
744
+ and target through the exact `node` label and `parent_issue_url`. The adapter
745
+ resolves a target from the child's local parent, reading that parent's label
746
+ from the listing batch or one conditional read, and implements
747
+ `listTargeting` from the node's side through its paginated sub-issue list.
748
+ `ports/tickets/github-validators.ts` keeps conditional-request validators and
749
+ reopen verdicts, one atomically written file per entry under
750
+ `<localStateRoot>/github-tickets/<owner>/<repo>/validators/`, evicted after 7
751
+ days unused; without a local state root it uses the in-memory store.
752
+ `ports/tickets/github-fake.ts` is the in-memory GitHub API that the shared
753
+ contract suite and the budget tests run against. The source holds no BuildStore
754
+ handle; assets use the generic BuildStore path.
723
755
 
724
756
  **Workspace, execution, and review base selection.**
725
757
  `packages/core/src/ports/workspace/create.ts` resolves `[workspace].provider` against the
@@ -742,6 +774,9 @@ its proven contribution boundary verbatim: the projected implementation/replay
742
774
  base, falling back to the latest fresh cut. Branch-cut target sampling remains
743
775
  separate from review provenance. The immutable boundary must belong to HEAD's
744
776
  history; missing or invalid provenance fails before publication or notes deposit.
777
+ A HEAD equal to that base is an empty contribution: the terminal records an
778
+ agent `implement` escalation naming both SHAs as the session's terminal, with no
779
+ push, notes deposit, completion or publication request.
745
780
  There is no review-time target fetch or destination merge-base. Successful leaf
746
781
  rewrite facts project `targetBase..headSha` for context, review and agent verify
747
782
  steps without changing historical ranges. Node cycles retain separate semantics.
@@ -822,14 +857,39 @@ request costs one GraphQL freshness query and no extra consent or pipeline read;
822
857
  full gate inspection and refreshed durable consent/engine eligibility precede
823
858
  any repair. Body comparison tolerates provider trimming of trailing whitespace
824
859
  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
860
+ `packages/core/src/kernel/issue-keywords.ts` composes a build's sealed issue
861
+ links into `Closes #N` / `Refs #N` lines, neutralizes closing keywords aimed at
862
+ `refs` issues, and places the keyword paragraph before the trailer block; a
863
+ `closesIssues` adapter uses it for the PR title and body, the landing writes and
864
+ the freshness comparison alike.
865
+ `packages/core/src/kernel/node-issue-links.ts` owns a node's issue-link set:
866
+ the dispatcher records each landed child's contribution on its node as
867
+ `node.issue-links-recorded` before the child completes, the build reducer folds
868
+ them per issue into a union, and the node's set merges its own effective links
869
+ with that union. A node's PR body is synced to the set (refs-only into a parent
870
+ node) through the optional `Forge.updatePrIssueLinks` when its
871
+ `node.issue-links-published` readback differs, and a root node's is refreshed
872
+ again by `landIntegrationRoot` before any merge request. A leaf aimed at a node
873
+ opens its PR with refs-only lines (`prIssueLinksForForge`) and lands with none.
874
+
875
+ Destination observations record a head-bound, query-scoped probe rather than
876
+ the destination's history: only the commit SHAs and direct build trailers in the
877
+ proof closure of the identities being decided (blocker identities, plus the
878
+ landings and confirmed foreign aliases that could transport them), which of those
879
+ are reachable from the sampled head, presence answers for only those identities,
880
+ and a fixed-length evidence digest. Observation size is bounded by that closure,
881
+ independent of the destination's reachable commit count and of repository history.
882
+ While the head is unchanged and the probe covers the current questions, current
828
883
  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.
884
+ reapplied without Git; unrelated merged history and ready-set changes neither
885
+ invalidate it nor append events. A moved head requires a fresh Git sample. A
886
+ newly relevant landing or a new question needs only a new probe: a dispatcher
887
+ still holding the full in-memory witness for that branch and head compacts one
888
+ without Git, and otherwise samples Git once. Observations without a probe,
889
+ including older full-history witnesses, are never trusted for admission: they
890
+ are re-derived once the same way, and an unavailable sample leaves the dependent
891
+ queued; neither replays repository history. Current readiness and
892
+ newest-generation checks still apply before claim.
833
893
 
834
894
  Optional `Forge.readCommitMessage` and `Forge.containsBuild` capabilities expose
835
895
  actual merged messages and exact trailer presence in reachable branch history.
@@ -947,9 +1007,13 @@ coalesces these at completed phase boundaries with durable attempt, result,
947
1007
  cooldown, request, and disposition facts. Built-in forges upsert one hidden
948
1008
  per-build marker; legacy plugins keep the existing bounded `commentOnPr` API.
949
1009
  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
1010
+ store artifact. Local runners publish under their lease at every boundary;
1011
+ remote guests request and yield, coalescing a verify cycle into one request at
1012
+ its end (`continuesVerifyCycle` in `kernel/pr-summary.ts`). The dispatcher
1013
+ records a guest exit caused only by a request that execution wrote as a
1014
+ routine `dispatcher.summary-handoff`, not a parked runner, and dispatcher
1015
+ settlement fences ended execution and owns the publication lease before
1016
+ launching replacement work. Summary failure never
953
1017
  changes phase outcomes. The GitHub release transport
954
1018
  lives in `packages/core/src/ports/forge/github-pr-attachments.ts`; terminal-build reclamation
955
1019
  and retry facts remain dispatcher janitor duty.
@@ -973,43 +1037,72 @@ AgentRunner failure causes and the exhaustion contract fixture are additive
973
1037
  plugin API 1.3 surfaces; legacy failures without a cause retain permanent-bit
974
1038
  behavior.
975
1039
 
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.
1040
+ **Dashboard.** `packages/core/src/cli/dispatch-frontend.ts` is a Store-first terminal adapter:
1041
+ it has no forge, workspace-provider, LiveConfig, or runtime dependency, and
1042
+ holds only a lazy ticket-source opener for build actions and the viewer's
1043
+ triage count.
978
1044
  It follows one dispatch run's repository facts incrementally through
979
1045
  `packages/core/src/kernel/dispatch-status.ts`, retaining only low-volume settings/Harvest
980
1046
  facts for their replay reducers, validates/caches its effective-config artifact,
981
1047
  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
1048
+ intervals. In local execution mode the header's triage count comes from the
1049
+ reduced `DispatchStatus` (`status.triage`), exactly like the queue depth, so a
1050
+ frontend refresh reads neither the ticket source nor any extra store value for
1051
+ it; viewer mode differs, as described below. The supervised
1052
+ kernel child (`frontendStatus`) samples the count through
1053
+ `TriageCountSampler` (`packages/core/src/cli/triage-count-sampler.ts`): the
1054
+ watch loop pokes it at startup and after each tick returns, so it reads at
1055
+ most once per 60 s (`TRIAGE_COUNT_REFRESH_MS`), outside dispatcher ticks, with
1056
+ one read in flight. It uses the source's bounded `countStates([triage])`, never a listing. Each tick carries the last
1057
+ successful count on `dispatcher.tick-completed`, and the tick itself never
1058
+ reads the ticket source for counts; a changed count is a
1059
+ standing-state change for publication suppression. Hosted, plain and
1060
+ non-TTY dispatchers never sample it. A source without `countStates` makes no
1061
+ request and stays unknown (`–`); a failed read or unmatched state keeps the
1062
+ previous value (initially unknown, shown as `–`).
1063
+ A viewer (`opts.viewer`) whose repository is dispatched elsewhere ignores
1064
+ `status.triage` and shows only its own count: on a refreshed frame it asks
1065
+ the source's optional `countStates([triage])` at most once per 60 s, in the
1066
+ background with one request in flight, while presentation is live and not in
1067
+ `--once`. It keeps the last good value through failures and shows `–` until
1068
+ the first success or for a source without `countStates`. The hosted
1069
+ `state-counts` operation answers that read with per-state totals only. The
1070
+ Postgres source reads them from `ab_ticket_state_counts`, which a row trigger
1071
+ on `ab_tickets` keeps exact in each ticket write's transaction, so the read
1072
+ never touches ticket rows. Like `REPO_CHANGE_DDL`, that table and trigger sit
1073
+ outside the ticket marker. Migration backfills them once when it creates the
1074
+ table, and project deletion removes the project's rows. A
1075
+ journal record that does not yet exist reads as an empty journal: the
1076
+ dispatcher's repository-wide journal reads (controls, settlement stages, and
1077
+ ready scans) and the operator sandbox service's journal reads go through
989
1078
  the same shared missing-record journal read (the AUT-524 helper in
990
1079
  `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
1080
+ `ensureRepo` from a display path). Navigation is
996
1081
  synchronous presentation state; only Store reads and writes enter its UI action
997
1082
  queue. The supervised kernel child owns every slow
998
1083
  adapter operation, so slug naming, provisioning, runners, and Harvest cannot
999
1084
  block input.
1000
1085
 
1001
1086
  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.
1087
+ when its cursor is within the 1,000-event repository tail window. A missing,
1088
+ invalid, unreadable or stale checkpoint, and cursor expiry, instead reseed from
1089
+ the canonical `repositoryReadFacts` value: its latest run start and the sampled
1090
+ holder's start become the retained identities, and its cursor starts one
1091
+ windowed tail. That value is the store's saved reduction, advanced
1092
+ incrementally on the server, so transfer is a fixed number of requests
1093
+ independent of journal and current-run length. Startup never falls back to
1094
+ `getRepoStateEvents` or a journal read from zero; a failed canonical read
1095
+ leaves the feed unready, and the next poll retries the same bounded read.
1096
+ Startup catch-up and prelaunch boundary reads enforce the tail window at
1097
+ selection, including concurrent appends; cursor expiry permits one additional
1098
+ canonical reseed, never historical gap replay. Steady-state reads and save
1099
+ cadence are unchanged.
1010
1100
 
1011
1101
  The frontend's `dispatchFrontend` checkpoint retains dashboard facts plus only
1012
1102
  the latest run-started fact and the sampled lease holder's start (deduplicated).
1103
+ Its dashboard facts are a cache of facts after the feed's restoration point,
1104
+ not presentation authority: settings, Harvest, handoffs and upgrades, ticket
1105
+ migrations and missing accounts all render from canonical repository facts.
1013
1106
  Identity history is always partial, including normalized legacy version-4
1014
1107
  caches; a missing holder is resolved through the bounded per-run reduced read.
1015
1108
  Successful lease samples select or clear the retained holder; failed metadata
@@ -1114,11 +1207,20 @@ and every failure path leaves live and pristine byte-untouched.
1114
1207
 
1115
1208
  ```sh
1116
1209
  bun install
1117
- bun run check # Biome lint + format, zero diagnostics
1118
- bun test # unit tests, colocated *.test.ts
1119
- bun typecheck # tsc --noEmit
1210
+ bun run check # Biome lint + format, zero diagnostics
1211
+ bun run test # in-memory unit tests, colocated *.test.ts, IO-guarded
1212
+ bun run test:integration # IO tests, colocated *.integration.test.ts
1213
+ bun typecheck # tsc --noEmit
1120
1214
  ```
1121
1215
 
1216
+ A unit test touches no filesystem, subprocess, network socket, or real clock
1217
+ wait; `bun run test` preloads a guard that fails any test that does, naming the
1218
+ call. Any test that does IO is an integration test named
1219
+ `*.integration.test.ts`, whether or not it needs a database. Run the suites
1220
+ through these scripts rather than bare `bun test`, which skips the guard and
1221
+ also picks up integration files. Database-backed integration tests skip
1222
+ without `AB_POSTGRES_TEST_URL`; every other integration test runs without it.
1223
+
1122
1224
  For dashboard presentation work, run the repository-only hot CLI:
1123
1225
 
1124
1226
  ```sh
@@ -1201,7 +1303,12 @@ external ticket state, missing ticket/state, or conflicting slug ownership termi
1201
1303
  automatic recovery with an `abandoned` resolution and diagnostic reason. The
1202
1304
  ticket is left unchanged; an operator can leave it finished or cancelled, or
1203
1305
  inspect ownership and explicitly return it to Ready for another attempt. These
1204
- cases stop provider polling and diagnostic appends. Recovery failures are
1306
+ cases stop provider polling and further durable diagnostic appends. The tick
1307
+ that records the abandonment reports one dispatcher diagnostic naming the
1308
+ ticket and attempt, whether the claim was confirmed or its provider outcome is
1309
+ unknown, and the recorded reason. If that tick fails for any reason, its
1310
+ failure error carries the diagnostics instead. Later ticks do not repeat it.
1311
+ Recovery failures are
1205
1312
  reported without preventing janitor, lease sweep, or other dispatch recovery.
1206
1313
  This is not general process
1207
1314
  crash recovery. Confirmed Ready/Triage transitions settle idempotently, so a
@@ -1213,42 +1320,16 @@ Reads use explicit manifest/chunk revisions without a ticket connection. Old
1213
1320
  pins retain ticket-row reads; existing service attachments need no migration,
1214
1321
  and attachments in old local stores are not moved.
1215
1322
 
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.
1323
+ Node verification context is prepared, not discovered at hydration.
1324
+ `packages/core/src/kernel/node-verification-context.ts` collects trailer-based
1325
+ provenance (`collectNodeVerificationProvenance`) and builds the versioned
1326
+ `node-verification-context` artifact (`prepareNodeVerificationContext`), which
1327
+ `packages/core/src/processes/dispatcher.ts` deposits atomically with
1328
+ `integration.prepared`. `packages/core/src/cli/context.ts` parses only that
1329
+ cited artifact (`parseNodeVerificationContext`) and materializes
1330
+ `nodeVerification`, the index and the contribution specs. The design contract
1331
+ is SPEC §8.3; the agent-facing explanation is
1332
+ [node verification context](integration-tree.md#node-verification-context).
1252
1333
 
1253
1334
  Both `ab dispatch` and sessionless `ab ticket` load the repository's plugins
1254
1335
  before selecting their TicketSource; dispatch passes that one adapter instance
@@ -1258,12 +1339,15 @@ but reported as skipped: live provider access requires credentials/resources
1258
1339
  and an explicit opt-in. When
1259
1340
  adding an adapter, start from its contract suite, not only the interface.
1260
1341
 
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`.
1342
+ The two remote clients get client-only coverage in core itself, against an
1343
+ injected `fetchFn` with responses built from the protocol's wire schemas.
1344
+ `HostedTicketSource` (`ports/tickets/remote.test.ts`) is in-memory unit
1345
+ coverage that runs in `bun run test`. `RemoteBuildStore`
1346
+ (`store/remote/client.integration.test.ts`, which also pins scoped-token
1347
+ minting/verification) is integration coverage. The full over-the-wire seam
1348
+ suites (client → HTTP → server) live in `packages/hosted-store-service`
1349
+ (`*.seam.integration.test.ts`) and run with the `RemoteBuildStore` client tests
1350
+ in `bun run test:integration`.
1267
1351
 
1268
1352
  To run the Linear contract manually against a destructive scratch target:
1269
1353
 
@@ -1272,7 +1356,7 @@ AB_RUN_LIVE_PORT_CONTRACTS=1 \
1272
1356
  LINEAR_API_KEY=… \
1273
1357
  AB_LINEAR_CONTRACT_TEAM_KEY=SCRATCH \
1274
1358
  AB_LINEAR_CONTRACT_PROJECT_ID=… \
1275
- bun test packages/core/src/ports/tickets/linear.live.test.ts
1359
+ bun test packages/core/src/ports/tickets/linear.live.integration.test.ts
1276
1360
  ```
1277
1361
 
1278
1362
  The token must be able to create, update, relate, and archive issues in the
@@ -1290,7 +1374,7 @@ To run the GitHub contract manually:
1290
1374
  AB_RUN_LIVE_PORT_CONTRACTS=1 \
1291
1375
  GH_TOKEN=… \
1292
1376
  AB_GITHUB_CONTRACT_REPO=owner/destructive-scratch-repo \
1293
- bun test packages/core/src/ports/forge/github.live.test.ts
1377
+ bun test packages/core/src/ports/forge/github.live.integration.test.ts
1294
1378
  ```
1295
1379
 
1296
1380
  `GITHUB_TOKEN` may be used instead of `GH_TOKEN`. The repository must have
@@ -1309,15 +1393,15 @@ execution, and one-shot completion:
1309
1393
  ```sh
1310
1394
  AB_RUN_LIVE_PORT_CONTRACTS=1 \
1311
1395
  AB_CLAUDE_CONTRACT_MODEL=claude-sonnet-4-… \
1312
- bun test packages/core/src/ports/runner/claude.live.test.ts
1396
+ bun test packages/core/src/ports/runner/claude.live.integration.test.ts
1313
1397
 
1314
1398
  AB_RUN_LIVE_PORT_CONTRACTS=1 \
1315
1399
  AB_CODEX_CONTRACT_MODEL=gpt-… \
1316
- bun test packages/core/src/ports/runner/codex.live.test.ts
1400
+ bun test packages/core/src/ports/runner/codex.live.integration.test.ts
1317
1401
 
1318
1402
  AB_RUN_LIVE_PORT_CONTRACTS=1 \
1319
1403
  AB_PI_CONTRACT_MODEL=openai/gpt-… \
1320
- bun test packages/core/src/ports/runner/pi.live.test.ts
1404
+ bun test packages/core/src/ports/runner/pi.live.integration.test.ts
1321
1405
  ```
1322
1406
 
1323
1407
  Claude uses the locally installed Claude Code CLI and its configured login; the
@@ -1351,7 +1435,7 @@ That package probe does not invoke a provider and can be selected without
1351
1435
 
1352
1436
  ```sh
1353
1437
  AB_RUN_LIVE_PORT_CONTRACTS=1 \
1354
- bun test packages/core/src/ports/runner/pi.live.test.ts -t 'gates tools discovered'
1438
+ bun test packages/core/src/ports/runner/pi.live.integration.test.ts -t 'gates tools discovered'
1355
1439
  ```
1356
1440
 
1357
1441
  Once opted in, the probe fails with the missing expected tool and its exact
@@ -1400,7 +1484,9 @@ Dispatch prepares harvest claims using `HarvestRunner.run(true)` before issuing
1400
1484
  an execution grant. `harvest.execution.authorized` binds the selected run,
1401
1485
  execution and adopted lease holder; the guest resumes only that prepared run.
1402
1486
  Local completion records `harvest.execution.ended`; hosted completion retains
1403
- its provider release fact. Recovery controls remain trusted dispatcher work.
1487
+ its provider release fact. While an observable hosted execution is open, the
1488
+ dispatcher withholds harvest launch, so runner loss on its open session is
1489
+ judged only after its release fact. Recovery controls remain trusted dispatcher work.
1404
1490
  Execution launch auth is transient and separate from serialized identity. Runners
1405
1491
  request exact phase grants after session-start facts and before runtime calls.
1406
1492
  Workspace plugin factories receive an exchange callback and a scrubbed environment,
@@ -1424,19 +1510,24 @@ Every ticket read includes an opaque `revision`. Pass it as `expectedRevision`
1424
1510
  `move`, `block` and `unblock`. A stale write fails without changing anything and
1425
1511
  reports the current revision. Omission preserves unguarded behavior. Blocker
1426
1512
  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.
1513
+ revision. Sources without guarded writes, including Linear and GitHub, refuse
1514
+ supplied revisions rather than ignoring them.
1429
1515
 
1430
1516
  `ab ticket edit <id>` opens `$VISUAL`, falling back to `$EDITOR`, using TOML
1431
1517
  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
1518
+ kind, target, id, blockers, issue links, priority, creation key and reference comments are read-only. It saves only
1519
+ changed fields with the opening revision. Sources without guarded writes,
1520
+ including Linear and GitHub, re-read the ticket immediately before an
1521
+ unguarded write and refuse a changed revision, with the no-lock race window of file checks. Unchanged or formatting-only edits
1434
1522
  write nothing. On conflict, invalid input or editor failure, the error names an
1435
1523
  absolute file path containing the edited text. Read the current ticket and
1436
1524
  reapply the intended changes before retrying; conflicts are never merged.
1437
1525
 
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
1526
+ File and Linear revisions fingerprint kind, target, title, body, canonical label/blocker sets,
1527
+ state and urgent priority; file revisions also cover nonempty issue links. GitHub revisions
1528
+ fingerprint kind, target, title, body, canonical label/blocker sets, state and issue links,
1529
+ including the ticket's own issue; GitHub tickets carry no comments. Reverting
1530
+ identical content restores its fingerprint. File checks
1440
1531
  re-read immediately before writing, with the existing no-lock race window.
1441
1532
  Direct file edits and state-directory moves change revisions. File comments
1442
1533
  change the body and revision; separate hosted comments do not. Hosted revisions
@@ -1453,7 +1544,8 @@ explicit ticket URL. Project registration and ticket policy publication through
1453
1544
  record, outside BuildStore events/artifacts; legacy uploaded configuration remains
1454
1545
  a compatibility fallback. Hosted lifecycle defaults are triage/ready/doing/done.
1455
1546
  Hosted state initialization checks only the distinct configured role names through
1456
- an indexed project/name lookup. Already-present names require no state mutation
1547
+ an indexed project/name lookup; the optional backlog and rejected names match
1548
+ case-insensitively within that same lookup. Already-present names require no state mutation
1457
1549
  lock or writes. Missing names are rechecked under the project advisory lock and
1458
1550
  inserted in the same transaction. Custom-state creation and policy publication
1459
1551
  always take that lock; publication reads the previous policy under it and retains
@@ -1468,10 +1560,26 @@ Hosted ticket detail reads expose complete, oldest-first structured comments in
1468
1560
  `ticket.comments`, preserving exact bodies. Scans do not fetch comments. Hosted
1469
1561
  HTTP clients opt in with `x-autobuild-ticket-comments: 1` so historical strict
1470
1562
  decoders retain compatible responses. File comments remain embedded in the body;
1471
- Linear comment reads are unchanged.
1563
+ Linear comment reads are unchanged. Issue links follow the same pattern with
1564
+ `x-autobuild-ticket-issue-links: 1`, stored in the `ab_tickets.issue_links` jsonb
1565
+ column that every listing already selects. Dependency states carry each blocker's
1566
+ native `state` for clients that send `x-autobuild-ticket-dependency-state: 1`,
1567
+ read from the row each lookup already loads; the dispatcher applies the
1568
+ configured rejected role on top (`markRejected` in `processes/dispatcher.ts`).
1569
+ Priority follows the issue-link pattern with `x-autobuild-ticket-priority: 1`,
1570
+ stored in the `ab_tickets.priority` column that every listing already selects;
1571
+ the ready listing orders urgent first in its existing statement, and the ticket
1572
+ server applies the same stable partition to every `list-ready` response.
1472
1573
 
1473
1574
  Ticket integration metadata lives in `ports/tickets/tree.ts`: source compatibility
1474
1575
  normalization, capability refusal, graph validation and the pure tree projection.
1576
+ Ticket priority lives in `ports/tickets/priority.ts`: the `priority` capability's
1577
+ typed refusal, the normal no-op strip and `urgentFirst`, the stable partition the
1578
+ dispatcher applies to its ready listing. Normalized tickets carry only `urgent`;
1579
+ the hosted service answers `priority` only to clients sending its capability
1580
+ header, so published strict wire schemas never see the key. The Linear adapter
1581
+ maps its native Urgent priority (1) to `urgent` and, on `normal`, clears only a
1582
+ current Urgent.
1475
1583
  File/fake/Linear adapters validate metadata at write boundaries; `operations.ts`
1476
1584
  and CLI/operator source opening wrap injected or plugin sources with the same
1477
1585
  compatibility facade. Metadata is excluded from hosted persistence/protocols.
@@ -1508,9 +1616,11 @@ The optional grouped Forge rewrite capability owns authoritative head snapshots,
1508
1616
  immutable `refs/autobuild/archive/<slug>/<sha>` publication and expected-head CAS.
1509
1617
  Remote archives also publish commits present only on the remote: GitHub uses create-only
1510
1618
  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.
1619
+ pushes for local objects. Exact remote readback confirms publication, then a non-shallow
1620
+ fetch of only that exact archive ref (without tags, configured refmap expansion or a
1621
+ depth limit) restores missing commits and their missing ancestry, writes no shallow
1622
+ boundary, leaves an already-shallow repository's existing boundaries unchanged, and
1623
+ verifies the commits locally before returning.
1514
1624
  GitHub uses explicit Git transport leases; local-git uses shared-database
1515
1625
  `update-ref` CAS without network calls. Exact authoritative readback acknowledges
1516
1626
  publication. Remote-backed local refs are caches refreshed without expected-old
@@ -1542,7 +1652,7 @@ Replay retention stores thin Git packs in bounded binary chunks, with a fixed-si
1542
1652
 
1543
1653
 
1544
1654
  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
1655
+ `ports/forge/github.live.integration.test.ts`, using `AB_RUN_LIVE_PORT_CONTRACTS=1` and an
1546
1656
  explicit disposable `AB_GITHUB_CONTRACT_REPO`. Offline transport tests are not
1547
1657
  live provider evidence.
1548
1658
 
@@ -1552,7 +1662,10 @@ live provider evidence.
1552
1662
  `node.restack-availability-observed` facts. The dispatcher checks this reduced value
1553
1663
  before repository preparation; transactions retain unavailable requests and explicitly
1554
1664
  settle obsolete destinations. Landing and ancestry changes invalidate waiting results
1555
- even at unchanged Git heads. Targeting-leaf cancellation runs only at the actionable
1665
+ even at unchanged Git heads. The dispatcher's per-tick availability batch is
1666
+ `repoBuildDigests(true)`, which includes mixed-version deferred builds' landing facts
1667
+ without deciding for them, so its fingerprint equals the one the node transaction
1668
+ records. Targeting-leaf cancellation runs only at the actionable
1556
1669
  replay boundary using `landing-publication.ts` receipts, including recovery.
1557
1670
 
1558
1671
  `kernel/node-restack.ts` inventories the contribution above the durable previous
@@ -1561,7 +1674,11 @@ and replays individual changes. `kernel/node-restack-state.ts` reduces writer
1561
1674
  reservations, ordered receipts, conflicts, publication intent, confirmed effects,
1562
1675
  and inventory. `kernel/node-restack-transaction.ts` retains replay objects and
1563
1676
  archives before expected-head publication. The dispatcher polls all open nodes,
1564
- including empty nodes, and advances clean cascades without agent calls. Only the
1677
+ including empty nodes, to observe parent movement durably, but replays a node only
1678
+ when it has demand: before a complete nonempty node verifies, before merge if its
1679
+ parent moved, for queued dependency presence, on `ab restack <node>`, or after
1680
+ accepted re-parenting. A clean replay needs no agent call. A restacked node does
1681
+ not restack its descendants: each nested node needs its own demand. Only the
1565
1682
  active conflicted item attaches a reconcile runner, using source-build artifacts
1566
1683
  materialized by the dispatcher into the integration owner's store scope.
1567
1684
 
@@ -1575,7 +1692,7 @@ confirmed, revalidated request with `node.parent-accepted`. Provider edits use
1575
1692
  the same validation; refusals are deduplicated by revision, target and reason.
1576
1693
  Uncertain writes recover by source readback rather than replaying a caller patch.
1577
1694
  Tracker observation errors are contained within that observation, preserving
1578
- ordinary cascade and PR handling against durable ancestry. Already accepted moves
1695
+ ordinary demand-driven restack and PR handling against durable ancestry. Already accepted moves
1579
1696
  complete their PR effects without another tracker read. Rejection comparisons use
1580
1697
  revision, target and reason fields so JSONB key ordering cannot defeat deduplication;
1581
1698
  `node.parent-rejection-cleared` removes a current refusal after correction while
@@ -1591,8 +1708,11 @@ PR through the optional `Forge.retargetPr` capability, inspects its acknowledged
1591
1708
  base/head, records a receipt and completes the parent operation. GitHub uses the
1592
1709
  [documented PR update endpoint](https://docs.github.com/en/rest/pulls/pulls#update-a-pull-request)
1593
1710
  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.
1711
+ terminal human PR changes keep their ordinary handling. Children keep targeting
1712
+ the moved node's identity and branch and observe its new head, but re-parenting a
1713
+ node alone does not restack its descendants; each descendant catches up only
1714
+ through its own demand, such as verification, merge, queued dependency presence,
1715
+ or `ab restack <node>`.
1596
1716
 
1597
1717
  In origin mode, node plumbing uses the forge's trusted `kernelExec` transport.
1598
1718
  The GitHub adapter supplies its token through subprocess-only Git configuration,
@@ -1608,9 +1728,13 @@ receive-pack path.
1608
1728
  `kernel/node-landing.ts` shares the node writer lease and reservation with
1609
1729
  restacking. It cancels native auto-merge, refreshes actual PR refs, proves the
1610
1730
  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
1731
+ CAS. Only exact authoritative readback of the destination showing the
1732
+ candidate, or the durable receipt of an accepted write overtaken before
1733
+ readback, records `node.rewritten` and the source build's `pr.merged`; another
1734
+ observed head settles the writer `contended`, a failed readback records nothing
1735
+ and is retried, and recovery of an interrupted merge uses the same exact
1736
+ readback. Provider PR reconciliation is best-effort and never decides or
1737
+ retries that merge. Root merge retains squash semantics. Store adapters expose node writer claim, renewal and holder-checked
1614
1738
  release separately from execution leases; Postgres schema version 15 adds their
1615
1739
  columns. Reservations live in the event stream and survive lease expiry.
1616
1740
 
@@ -1622,7 +1746,11 @@ both inventory and active items, retaining original identities after rewrites.
1622
1746
 
1623
1747
 
1624
1748
  Integration completion is sampled by `kernel/integration-completeness.ts` from
1625
- exhaustive source listings, frozen claims and retained contribution identities.
1749
+ exhaustive source listings (a source's `listTargeting` per node, memoized for
1750
+ the dispatcher pass, else one shared `listAll`), frozen claims and retained
1751
+ contribution identities. The hosted source serves `listTargeting` through the
1752
+ `list-targeting` ticket operation, which the PostgreSQL ticket store answers with
1753
+ one statement on the `(repo, target_id)` index.
1626
1754
  `integration.*` events retain observations, immutable cycle inputs, merge
1627
1755
  intents, provenance and tree audits. The build reducer projects these facts and
1628
1756
  `engine.ts` routes nodes directly through verification, without producer phases.
@@ -1714,14 +1842,21 @@ facts retain the mixed-version wait gate and durable compatibility diagnostic.
1714
1842
  When the scoped `ab context` initial own-build read fails, the CLI best-effort
1715
1843
  writes `session.build-read-failed` with exact session, phase, round, operation
1716
1844
  `context`, reason `own-build-read`, and diagnostic. A valid terminal from that
1717
- session wins if the agent recovers. Otherwise settlement records `phase.deferred`
1845
+ session, or from its native continuation, wins if the agent recovers; a
1846
+ continuation inherits its predecessor's pending deferral, so a chain parks at
1847
+ most once. A later successful own-build read in the same session records
1848
+ `session.build-read-recovered`, which a newer classified failure invalidates. A
1849
+ finalize post-step, which has no terminal, settles as recovered only with that
1850
+ evidence and a completed turn, and the kernel then records its
1851
+ `finalize.step-completed`. Otherwise settlement records `phase.deferred`
1718
1852
  and `phase.deferral-escalated`, immediately projecting ordinary blocked attention.
1719
1853
  The raise cites `own-build-read:<evidenceSeq>`; replay repairs either settlement
1720
1854
  crash gap before launching another agent. An `escalation.answered` retry or
1721
1855
  guidance authorizes one fresh session without resetting genuine phase failures;
1722
1856
  a new classified failure parks again. There are zero automatic paid retries
1723
1857
  after this deferral. If evidence cannot be written, ordinary recovery applies;
1724
- agent output and `no-terminal` alone never classify a read failure.
1858
+ agent output and `no-terminal` alone never classify a read failure or settle
1859
+ one as recovered.
1725
1860
 
1726
1861
  A kernel store write rejected with HTTP 413 raises `StoreWriteTooLargeError`
1727
1862
  and records `phase.failed {willRetry:false}` on its first attempt, including
@@ -1807,12 +1942,32 @@ Classified rate limits retain repository cooldown and consume no publication
1807
1942
  retry allowance. Rejected pushes, lease conflicts, dirty trees and unclassified
1808
1943
  errors retain their existing behavior.
1809
1944
 
1945
+ A forge that refuses a dispatcher-side finalize PR create with a client error
1946
+ throws `ForgeRejection` (`ports/forge-failure.ts`), carrying the forge name, HTTP
1947
+ status and the forge's message; GitHub's "No commits between" 422 is its
1948
+ `NoCommitsBetweenBranchesError` subclass. Rate limits and transient failures
1949
+ stay `ForgeFailure`s on their existing paths. `kernel/finalize-pr-rejection.ts`
1950
+ raises one `finalize` escalation (`policy`, `non-retryable-phase-failure`) per
1951
+ rejection, keyed by the publication request and the answer that authorized the
1952
+ attempt, and throws `ForgeRequestDeferred`. Launch, ended-execution and release
1953
+ settlement therefore record no `infrastructure.failed`. While the escalation is
1954
+ open, `cli/publication-settlement.ts` defers on the facts it already read, with
1955
+ no provider probe, description read or forge request. Each answer authorizes
1956
+ one more PR create; an abort answer stops retrying so release can proceed.
1957
+
1810
1958
  Janitor failures are durable per-build episodes. Eligible failures retry after
1811
1959
  30, 60, 120, 240 seconds, then at the configured cap (300 seconds by default).
1812
- Skipped polls preserve the episode across restart. After
1960
+ A classified forge rate limit is repository cooldown, not a janitor failure:
1961
+ neither the first limited response nor the cooldown that follows starts or ages
1962
+ an episode. Skipped polls preserve the episode across restart. After
1813
1963
  `policy.janitorFailureAttentionSeconds` (600 by default), `build.janitor-failing`
1814
1964
  notifies default watchers and appears on the build row. A successful attempt
1815
1965
  clears it. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
1966
+ A dispatcher that cannot execute Git for kernel node work (a missing or
1967
+ unloadable `git` for the bare clone) records no janitor failures. It records
1968
+ one durable `dispatcher.kernel-git-unavailable` repository condition, node work
1969
+ waits, and `dispatcher.kernel-git-recovered` closes the condition once a clone
1970
+ succeeds.
1816
1971
 
1817
1972
  A classified forge rate limit records repository degradation with `resetAt`.
1818
1973
  Forge work waits during cooldown; passing the deadline permits a recovery
@@ -1986,8 +2141,9 @@ manually. ChatGPT credentials are authorized with `ab accounts login NAME
1986
2141
  is the sole refresh owner; no sandbox refreshes. Local Codex uses a protected
1987
2142
  loopback inference transport and isolated CODEX_HOME, preserving the shell HOME
1988
2143
  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.
2144
+ Hosted validation uses write-only metadata for ChatGPT refreshing secrets and
2145
+ Claude/Kimi static project secrets, and states that the first hosted build is
2146
+ the live check; local validation makes a minimal runtime request.
1991
2147
 
1992
2148
  Selected Claude/Kimi credentials stay out of process arguments: each invocation
1993
2149
  uses a private 0700 directory and a regular 0600 settings file, removed after
@@ -2035,8 +2191,7 @@ fresh connection starts empty and resets hosted ticket numbering. `ab disconnect
2035
2191
  revokes credentials only; admin `projects remove` unregisters without purging.
2036
2192
  See [project deletion protocol](operator-api.md#permanent-project-deletion).
2037
2193
 
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
-
2194
+ ### Hosted event reads
2040
2195
 
2041
2196
  Hosted event reads use the bounded capabilities in `store/event-reads.ts`:
2042
2197
  repository cursors must be at least `max(0, head - 1000)`, and build pages