@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
package/SPEC.md CHANGED
@@ -82,20 +82,21 @@ event log handling, state reducer. No I/O opinions — no ticket tracker, no
82
82
  telemetry vendor, no terminal.
83
83
 
84
84
  ### 3.2 Ports
85
- Ticket sources may optionally provide native `listPage(criteria, page)` windows with a matching total. Paged operator reads use it when present, otherwise slice the exhaustive listing; unpaged and dispatcher reads remain exhaustive.
86
-
87
85
 
88
86
  Interfaces to the world, each with swappable adapters:
89
87
 
90
88
  | Port | Duty | Initial adapters |
91
89
  |---|---|---|
92
- | `TicketSource` | list/claim/comment/transition/create/update tickets; add, remove, and resolve declared dependencies | file-based (default directory); Linear; third-party in-process registrations; later GitHub Issues |
90
+ | `TicketSource` | list/claim/comment/transition/create/update tickets; add, remove, and resolve declared dependencies | file-based (default directory); Linear; hosted; GitHub Issues; third-party in-process registrations |
93
91
  | `AgentRunner` | run agent sessions (see §9) | Claude Code CLI (headless); Codex CLI (`exec --json`); local pi CLI (`--mode rpc`, minimum 0.84.3); third-party in-process registrations |
94
92
  | `Workspace` | provision isolated working copies | git worktree; third-party in-process registrations; later remote sandbox |
95
93
  | `Forge` | git + PR plumbing | GitHub; local Git; third-party in-process registrations |
96
94
  | `TelemetrySource` | production signals | Sentry; later log streams |
97
95
  | `BuildStore` | per-build streams plus repository journals: events, artifacts, transcripts, leases (see §7) | local; remote HTTP |
98
96
 
97
+ Ticket sources may optionally provide native `listPage(criteria, page)` windows with a matching total. Paged operator reads use it when present, otherwise slice the exhaustive listing; unpaged and dispatcher reads remain exhaustive.
98
+ Integration-tree sources may optionally provide `listTargeting(nodeId)`, every ticket targeting one node in every state, equal to the exhaustive listing filtered by target. Integration observation uses it when present, otherwise `listAll`.
99
+
99
100
  #### 3.2.1 In-process adapter plugins
100
101
 
101
102
  A repository may list trusted Bun modules in `autobuild.toml`. Each module
@@ -219,7 +220,7 @@ surface remains the remote HTTP protocol rather than in-process registration.
219
220
 
220
221
  Small, independently runnable, crash-safe:
221
222
 
222
- Explicit human `ab dispatch --viewer` is a Store-only dashboard lifecycle,
223
+ Explicit human `ab dispatch --viewer` is a Store-backed dashboard lifecycle,
223
224
  available from a local checkout in TTY and plain/non-TTY modes. It bypasses the
224
225
  resident launcher, execution configuration/plugins, account admission and kernel
225
226
  wiring. It never takes or renews a repository lease, starts a child, writes
@@ -228,7 +229,9 @@ Canonical repository facts supply the observed dispatcher's status and effective
228
229
  configuration, independent of the viewer's operator correlation identity. With no
229
230
  configuration the display waits, polling bounded canonical state. Fresh viewers
230
231
  reuse saved server reductions; missing presentation caches never trigger event
231
- history reconstruction. Idle polls read zero event rows.
232
+ history reconstruction. Idle polls read zero event rows. Its one ticket-source
233
+ read is the header's triage count, sampled at most once per 60 s, outside
234
+ dispatcher ticks.
232
235
 
233
236
  Every frame reserves a row for `viewer`, optionally `viewer · dispatched by
234
237
  <label>` from explicit `--dispatched-by` input. Plain output states the mode at
@@ -240,9 +243,11 @@ and session inspection. No current control requires a local dispatcher. Viewer
240
243
  rejects startup intake flags and explicit `--repository`.
241
244
 
242
245
  A plain `ab dispatch` reads dispatch placement once before starting local execution.
243
- For a hosted project it opens the Store-only viewer automatically, displaying
246
+ For a hosted project it opens the viewer automatically, displaying
244
247
  `viewer · dispatched by <host>` from the placement origin (including a nondefault
245
248
  port). `--once`, `--plain`, and `--interval` retain their viewer meanings.
249
+ The viewer reads its dashboard from the Store; its one ticket-source read is
250
+ the header's triage count, through the source's optional `countStates`.
246
251
  `--takeover` explicitly dispatches locally, with a warning that it can displace
247
252
  the hosted dispatcher; it cannot be combined with `--viewer`. Startup intake
248
253
  flags require `--takeover` when placement selects viewer.
@@ -251,8 +256,11 @@ An unreadable placement fails closed with a typed error naming the cause:
251
256
  use `--viewer` to watch or `--takeover` to dispatch locally. Both explicit modes
252
257
  skip placement discovery. Older services without the capability and projects
253
258
  with unknown or nonhosted placement retain local dispatch behavior. Local stores
254
- need no placement request. Origin mode (`--repository` or `AB_REPOSITORY`) and
255
- hosted cron dispatch bypass this check. Placement is a startup snapshot, not a
259
+ need no placement request. Failing to resolve the checkout's store selection
260
+ (for example, a malformed `autobuild.toml`) is not a placement failure: default
261
+ startup reports it as a repository resolution error naming its cause, and
262
+ neither explicit mode bypasses it. Origin mode (`--repository` or
263
+ `AB_REPOSITORY`) and hosted cron dispatch bypass this check. Placement is a startup snapshot, not a
256
264
  liveness probe or a polling input. Operator agents' prohibition on running dispatch includes viewer.
257
265
 
258
266
  Resident checkout-backed `ab dispatch` starts a launcher and one dispatcher
@@ -441,7 +449,7 @@ files, including development configs, remain exactly as installed.
441
449
  - **dispatcher** — watches the TicketSource for tickets passing the configured
442
450
  ready gate, claims, establishes the final conforming spec, chooses a short
443
451
  immutable build slug, provisions a workspace, and launches build-runners up
444
- to capacity. On process startup it attempts every current build for its
452
+ to capacity, which counts builds running work (§12). On process startup it attempts every current build for its
445
453
  repo, so re-running `ab dispatch` resumes durable work rather than only
446
454
  looking for new tickets. Every ordinary tick also completes queued dispatch
447
455
  records whose pre-run sequence was interrupted: it reconstructs a missing
@@ -471,7 +479,16 @@ files, including development configs, remain exactly as installed.
471
479
  automatic recovery with an `abandoned` resolution and diagnostic reason. The
472
480
  ticket is left unchanged; an operator can leave it finished or cancelled, or
473
481
  inspect ownership and explicitly return it to Ready for another attempt. These
474
- cases stop provider polling and diagnostic appends. Recovery failures are
482
+ cases stop provider polling and further durable diagnostic appends. The tick
483
+ that records the abandonment reports one dispatcher diagnostic naming the
484
+ ticket and attempt, whether the claim was confirmed or its provider outcome is
485
+ unknown, and the recorded reason. If that tick fails for any reason, its
486
+ failure error carries the diagnostics instead. Later ticks do not repeat it.
487
+ The `abandoned` resolution event records whether the claim was confirmed, and
488
+ default `ab watch` repository attention reports the same line once as it
489
+ lands, whether or not its tick failed; a fresh watch does not replay
490
+ historical abandonments.
491
+ Recovery failures are
475
492
  reported without preventing janitor, lease sweep, or other dispatch recovery.
476
493
  This is not general process
477
494
  crash recovery. Confirmed Ready/Triage transitions settle idempotently, so a
@@ -503,6 +520,14 @@ by sequence. It contains scheduling metadata only, never counts or lifecycle
503
520
  state, and is distinct from reducer checkpoints. Missing or stale metadata
504
521
  falls back to the recorded fact and can cause one safe extra scan without
505
522
  reconstructing history. Successful unchanged scans advance this cache only.
523
+ While less than one interval has elapsed since the recorded fact's
524
+ measurement, with unchanged readiness and criteria fingerprints and no
525
+ admission following an observation measurement, a tick defers without reading
526
+ the cache, because the cache only acknowledges that measurement or a later one.
527
+ If the wall clock moved backwards, a cache entry dated later than the current
528
+ clock is therefore consulted only once that window ends, at most one scan
529
+ interval after the recorded measurement; the dispatcher then treats it as a
530
+ clock rollback, rescans, and resets the cache to the current clock.
506
531
 
507
532
 
508
533
  ### 3.4 The event log spine
@@ -727,18 +752,27 @@ the standard — moving failure to the cheapest point instead of launching a
727
752
  build that will thrash and escalate.
728
753
 
729
754
  **Build identity at dispatch:** once the final conforming spec is in hand,
730
- the selected runtime proposes a short kebab-case slug from its substance —
731
- judgment proposes; the dispatcher validates, deduplicates against the store,
732
- and falls back to a deterministic title-derived name on any absence, invalid
733
- output, error, or timeout. Naming failure never prevents build creation. The
734
- slug and its `ab/<slug>` branch are recorded once and never renamed.
755
+ the selected runtime may propose a short kebab-case slug from its substance.
756
+ Judgment proposes; the dispatcher validates the proposal under a hard
757
+ deadline. A missing capability, invalid output, error, or timeout falls back
758
+ to a deterministic title-derived name, so a failed proposal never prevents
759
+ build creation. The dispatcher then deduplicates the base with `-2`, `-3`, …
760
+ suffixes against the store and, when the forge can answer, against `ab/` or
761
+ `ab-node/` build branches already on the remote, so a build never takes a
762
+ branch another store owns. That check is not best effort: if a remote branch
763
+ lookup fails, or the base and its `-2` … `-100` candidates are all taken, the
764
+ claim fails at the naming stage, no build is created, and the ticket returns
765
+ to configured Ready under the dispatcher's preparation recovery contract
766
+ (§3.3). The slug and its `ab/<slug>` (or `ab-node/<slug>` for a node) branch
767
+ are recorded once and never renamed.
735
768
 
736
769
  **Immutability:** the spec cannot change during a build except through the
737
770
  explicit operator revision protocol (leaf escalation or the node exception below). Every downstream reviewer approves
738
771
  conformance *to it*; a drifting spec silently converts approvals into
739
772
  approvals-of-something-else. A phase discovering the spec itself is wrong
740
- raises an `escalation`; a human uses `ab answer --revise-spec` (or
741
- `--revise-spec-from-ticket`), the spec gets rev N+1, and the leaf restarts
773
+ raises an `escalation`; the operator agent or a human answers with
774
+ `ab answer --revise-spec` (or `--revise-spec-from-ticket`), the spec gets
775
+ rev N+1, and the leaf restarts
742
776
  from `plan` (cheap — downstream was invalidated anyway).
743
777
 
744
778
  If a leaf spec revision arrives during an unfinished reconcile, the same reconcile attempt resumes under the revised spec on its retained frozen target. Its replay and committed contribution remain owned by reconcile. Confirmed publication must settle before the fresh plan loop opens; prior approvals and verification remain invalidated.
@@ -917,7 +951,7 @@ ticket's other durable data and never expire on their own.
917
951
  Hosted ticket assets live in the ticket service's repository-keyed storage,
918
952
  regardless of where builds run or which BuildStore is selected. File tickets use
919
953
  native portable storage composed with legacy BuildStore attachments; Linear
920
- tickets retain BuildStore storage. Existing service assets need no migration;
954
+ and GitHub tickets retain BuildStore storage. Existing service assets need no migration;
921
955
  old local hosted-ticket attachments are not moved or used as a fallback.
922
956
 
923
957
  Each put creates a new increasing **revision**; earlier revisions stay retrievable.
@@ -1044,12 +1078,14 @@ Operator UIs additionally have a repository-scoped batch read,
1044
1078
  `getRepoBuildDigests(repo)`: the projection of every build's log onto its
1045
1079
  terminal fact, its `observation.recorded` occurrences with their event
1046
1080
  timestamps, and the ts of its latest `pr.merged`, derived from the event log on
1047
- each call. It lets a dashboard snapshot count unclaimed observations and gate
1048
- rows without reading the full history of finished builds (§16.1), and it backs
1049
- the harvest-launch pressure gate (dispatcher and harvest runner alike): launch
1081
+ each call. It lets a dashboard snapshot gate rows without reading the full
1082
+ history of finished builds (§16.1), and it backs the harvest-launch pressure gate (dispatcher and harvest runner alike): launch
1050
1083
  decisions evaluate from digests and the repository journal alone, so
1051
1084
  gate-evaluation cost is flat in accumulated build history, with the full
1052
1085
  per-build scan paid only when a gate actually trips and a scan packet is built.
1086
+ The digest also carries the build's node targets, every node its target or
1087
+ parent moves ever named, so the dispatcher finds a node's child builds from
1088
+ digests and reads full facts only for builds that name that node.
1053
1089
 
1054
1090
  Stateless repository-level readers also have a bounded journal read,
1055
1091
  `getRepoStateEvents(repo)` (AUT-489): every durable, slow-growing event type
@@ -1196,7 +1232,9 @@ The base-selection invariants make this safe with Git:
1196
1232
  resume). It validates that immutable base against HEAD and records it verbatim.
1197
1233
  A moving or rewritten destination never changes the review range, and review
1198
1234
  requires no target fetch or merge-base calculation. Missing provenance fails
1199
- before publication. Successful restacks establish the baseline for later loops
1235
+ before publication. A HEAD equal to the base is an empty contribution: `ab done`
1236
+ records an `implement` escalation naming the build and both SHAs as the
1237
+ session's terminal, instead of a completion or publication request. Successful restacks establish the baseline for later loops
1200
1238
  and collapses. Historical event ranges stay immutable; the current
1201
1239
  `implement.commits` projection advances to `targetBase..headSha`
1202
1240
  on successful leaf `restack.rewritten`, `restack.completed`, and
@@ -1230,6 +1268,8 @@ every refresh and edit it, recreating it only after confirmed absence. The
1230
1268
  full audit trail is queryable, not committed to the branch.
1231
1269
 
1232
1270
  Summary publication is best effort, once per completed phase occurrence,
1271
+ except that a remote guest coalesces a verify cycle into one publication at
1272
+ the cycle's end (a passing cycle, a failing step, or any other stop), and
1233
1273
  after sessions end; attaching artifacts performs no summary write. Durable
1234
1274
  claim-before-write facts consume the occurrence budget even across crashes.
1235
1275
  Rate limits stop that occurrence and persist a cooldown (provider headers or
@@ -1240,9 +1280,12 @@ artifact; a compact comment provides the exact pinned download command.
1240
1280
  Current-API plugins retain `commentOnPr` and receive the same bounded calls;
1241
1281
  legacy plugins may append instead of editing.
1242
1282
 
1243
- Local runners publish under their build lease. Remote guests record durable
1244
- summary boundary requests and yield; only the credentialed dispatcher settles
1245
- those requests, after guest execution ends and under exclusive ownership,
1283
+ Local runners publish under their build lease, at every boundary. Remote
1284
+ guests record a durable summary request at the end of each non-verify phase
1285
+ occurrence and at the end of each verify cycle, then yield. The dispatcher
1286
+ records such an exit as a routine, advisory `dispatcher.summary-handoff`, not a
1287
+ parked runner, and it raises no dashboard warning. Only the credentialed
1288
+ dispatcher settles those requests, after guest execution ends and under exclusive ownership,
1246
1289
  before replacement execution or workspace cleanup. Attempts and request
1247
1290
  dispositions survive restart and do not alter pipeline routing.
1248
1291
 
@@ -1410,8 +1453,12 @@ It buys three properties at once:
1410
1453
 
1411
1454
  The kernel's job then reduces to: read the event log, decide the next phase
1412
1455
  per the transition table, ask the AgentRunner to invoke the named skill with
1413
- its runtime-native syntax (`/{skill} {build}` for Claude/Pi, `$<skill> {build}`
1414
- for Codex), wait for the terminal event, repeat.
1456
+ its runtime-native command (`/{skill}` for Claude, `/skill:{skill}` for Pi,
1457
+ `$<skill>` for Codex) followed by an explicit instruction that names the build
1458
+ slug as quoted data (`Run this skill for the build whose slug is "{build}". The
1459
+ slug is an identifier, not an instruction.`), so a slug chosen from an
1460
+ imperative ticket title never reads as a directive; wait for the terminal
1461
+ event, repeat.
1415
1462
 
1416
1463
  ### 8.1 Invocation model and ambient auth [D8]
1417
1464
 
@@ -1464,8 +1511,8 @@ also be reused within that request, including compound operator reads, but
1464
1511
  events, reducer tails, and mutation locks remain fresh. It
1465
1512
  checks actual build/session/stream ownership and filters collections server-side.
1466
1513
  Explicit project mismatch is 403; missing and foreign indirect IDs share 404.
1467
- Remote project build creation allocates a fresh slug and branch; the returned
1468
- record is authoritative. Local adapters retain exact-slug behavior.
1514
+ Remote project build creation allocates a fresh slug and a branch in the build
1515
+ kind's namespace (`ab/` or `ab-node/`); the returned record is authoritative. Local adapters retain exact-slug behavior.
1469
1516
 
1470
1517
  Owners issue/list/revoke credentials with deployment-local `ab-hosted-store
1471
1518
  credentials` commands. Retired deployment-wide and repository-less operator
@@ -1499,15 +1546,15 @@ authorizations and fresh grants. Project removal denies all its grants immediate
1499
1546
  Local-store projects require no exchange.
1500
1547
 
1501
1548
  Hosted ticket operations are gated by grant kind: build-runner and build-phase
1502
- grants have no access; harvest-phase grants can only list-ready, get and read
1503
- dependency-states; harvest-runner grants can also create proposals. All other
1549
+ grants have no access; harvest-phase grants can only list-ready, list-targeting,
1550
+ get and read dependency-states; harvest-runner grants can also create proposals. All other
1504
1551
  ticket mutations require project or admin authority. Refusals name the grant
1505
1552
  kind and operation.
1506
1553
 
1507
1554
  Ticket admission uses the credential project. Hosted tickets, comments, blockers, creation-key
1508
1555
  deduplication and assets are partitioned by registered repository, never team.
1509
1556
  Lifecycle comes from independent project ticket policy (triage, ready, doing, done
1510
- by default; configurable doneState). Legacy projects without independent policy
1557
+ by default; configurable doneState; optional backlog and rejected roles). Legacy projects without independent policy
1511
1558
  use their uploaded configuration with Backlog / Doing / Done defaults. Owner admin ticket requests explicitly select a registered
1512
1559
  repository. The service has no Linear ticket backend: external tracker and
1513
1560
  file sources remain dispatcher-side, and service ticket surfaces refuse those
@@ -1534,7 +1581,7 @@ sessions need no separate global installation.
1534
1581
  | `ab observe --kind <followup\|refactor\|latent-bug> …` | structured observation, any phase, any time | no |
1535
1582
  | `ab done` | complete a producer phase (validates, then runs phase plumbing) | **yes** |
1536
1583
  | `ab verdict <approve\|revise\|escalate\|pass\|fail\|skip> …` | complete a review/verify phase | **yes** |
1537
- | `ab escalate <question>` | park the build for human input | **yes** |
1584
+ | `ab escalate <question>` | park the build for external judgment | **yes** |
1538
1585
  | `ab mcp [--store <ref>] [--repo <id>]` | serve the agent tool registry as an MCP server over stdio; fails closed inside a phase | no |
1539
1586
 
1540
1587
  The read-only `ab builds`, `ab build status`, and `ab artifact download` forms
@@ -1652,14 +1699,21 @@ facts retain the mixed-version wait gate and durable compatibility diagnostic.
1652
1699
  When the scoped `ab context` initial own-build read fails, the CLI best-effort
1653
1700
  writes `session.build-read-failed` with exact session, phase, round, operation
1654
1701
  `context`, reason `own-build-read`, and diagnostic. A valid terminal from that
1655
- session wins if the agent recovers. Otherwise settlement records `phase.deferred`
1702
+ session, or from its native continuation, wins if the agent recovers; a
1703
+ continuation inherits its predecessor's pending deferral, so a chain parks at
1704
+ most once. A later successful own-build read in the same session records
1705
+ `session.build-read-recovered`, which a newer classified failure invalidates. A
1706
+ finalize post-step, which has no terminal, settles as recovered only with that
1707
+ evidence and a completed turn, and the kernel then records its
1708
+ `finalize.step-completed`. Otherwise settlement records `phase.deferred`
1656
1709
  and `phase.deferral-escalated`, immediately projecting ordinary blocked attention.
1657
1710
  The raise cites `own-build-read:<evidenceSeq>`; replay repairs either settlement
1658
1711
  crash gap before launching another agent. An `escalation.answered` retry or
1659
1712
  guidance authorizes one fresh session without resetting genuine phase failures;
1660
1713
  a new classified failure parks again. There are zero automatic paid retries
1661
1714
  after this deferral. If evidence cannot be written, ordinary recovery applies;
1662
- agent output and `no-terminal` alone never classify a read failure.
1715
+ agent output and `no-terminal` alone never classify a read failure or settle
1716
+ one as recovered.
1663
1717
 
1664
1718
  A kernel store write rejected with HTTP 413 raises `StoreWriteTooLargeError`
1665
1719
  and records `phase.failed {willRetry:false}` on its first attempt, including
@@ -1802,7 +1856,8 @@ implementer: ab context (findings.json now materialized) → …
1802
1856
 
1803
1857
  Human/pre-build ticket grooming uses one configured-source namespace
1804
1858
  (`ab ticket create|update|block|unblock|list|show|move`, plus the ticket-asset
1805
- forms below). Migration adds `ab ticket export <dir>` and `ab ticket import <dir>`,
1859
+ forms below). Migration adds `ab ticket export <dir>` and
1860
+ `ab ticket import <dir> [--states <state,…>]`,
1806
1861
  plus `ab ticket migration record <dir>`
1807
1862
  (see [Ticket source migration](#ticket-source-migration)). These commands are
1808
1863
  sessionless, source-agnostic, and never available as a mid-build spec
@@ -1856,9 +1911,16 @@ dispatch-settings reducer as dispatcher decisions and the dashboard. An absent
1856
1911
  repository stream reduces as an empty journal and reports intake on, repository
1857
1912
  pause off; the query does not create that stream,
1858
1913
  append an event, claim a ticket, attach a runner, or start dispatcher work.
1859
- The CLI additionally loads mutable advisory `operator.registrations`, with each
1860
- live registration's ID, host, PID, original startedAt, heartbeatAt and heartbeatAgeMs.
1861
- Human output includes one `operator: absent` or `operator: present (N registrations)` line.
1914
+ The CLI additionally loads mutable advisory presence and reports
1915
+ `operator.presence: "loaded"` with `operator.registrations`, each live
1916
+ registration's ID, host, PID, original startedAt, heartbeatAt and heartbeatAgeMs.
1917
+ Other surfaces sharing the projection — the operator registry's
1918
+ `repository.status` over MCP and HTTP `GET …/status` — do not load presence and
1919
+ report `operator.presence: "unavailable"` with a `reason` and no `registrations`.
1920
+ Unavailable is not evidence of absence; only a loaded empty list is. Human
1921
+ output includes exactly one of `operator: absent`,
1922
+ `operator: present (N registrations)` or
1923
+ `operator: unavailable (presence not loaded)`.
1862
1924
 
1863
1925
  `ab watch --operator` opts into repository-wide advisory presence. Named slugs
1864
1926
  and ambient build/scoped sessions are usage errors. Unflagged watches remain
@@ -2213,7 +2275,7 @@ converge<A>(
2213
2275
  reviewer marks persistence — judgment; the kernel applies the threshold —
2214
2276
  determinism).
2215
2277
  - **Round ceiling:** `policy.maxReviewRounds` is the default absolute cap for
2216
- each loop. Once its `review-round-limit` escalation is open, a human may
2278
+ each loop. Once its `review-round-limit` escalation is open, the operator agent or a human may
2217
2279
  answer it with an optional positive `reviewRoundCeiling`. That value replaces
2218
2280
  the configured cap for only the escalation's plan or code loop and current
2219
2281
  spec revision. It is absolute, durable, and cleared by `spec.revised`; the
@@ -2250,10 +2312,13 @@ loops to the configured default. The value is attached only to the matching
2250
2312
  review-limit answer, so unrelated blockers answered in the same command do not
2251
2313
  acquire it and build-phase agents cannot widen their own build's loop.
2252
2314
 
2253
- Every open escalation remains an external judgment gate until an operator answers
2254
- it. The answer may come from the operator agent or a human; build-phase agents
2255
- cannot answer their own escalations. This includes all policy and setup causes;
2256
- human authorization requirements still apply. Starting either `ab dispatch` or
2315
+ Every open phase and policy escalation remains an external judgment gate until an
2316
+ operator answers it. The answer may come from the operator agent or a human;
2317
+ build-phase agents cannot answer their own escalations. This includes all policy
2318
+ and setup causes; human authorization requirements still apply. A janitor
2319
+ escalation (Forge failure recovery) is the exception: ordinary janitor retries
2320
+ continue across startup, a successful attempt closes it without an answer, and a
2321
+ bare retry only brings the next attempt forward. Starting either `ab dispatch` or
2257
2322
  `ab dispatch --once` never appends `escalation.answered` and never re-arms a
2258
2323
  budget. Startup still recovers every actionable current build and delivers
2259
2324
  pending operator commands, whose decisions take precedence over a blocked wait;
@@ -2305,6 +2370,27 @@ signals (telemetry, observations)
2305
2370
  → build → PR → merge
2306
2371
  ```
2307
2372
 
2373
+ **Intake order.** When a slot is free, dispatch takes ready candidates urgent
2374
+ first, then normal, each class in the source's listing order (see Ticket
2375
+ priority in §13). Every admission gate is unchanged — blockers, labels,
2376
+ creation holds, capacity, intake off and repository pause — so a blocked urgent
2377
+ ticket never holds back normal work. Priority never preempts: an urgent ticket
2378
+ does not stop, pause or displace a running build.
2379
+
2380
+ **What holds a slot.** `capacity` counts builds running work. A work build that
2381
+ has finished its pipeline (every verify step and every finalize post-step for
2382
+ the current spec) holds no slot while it waits for a merge decision, for merge
2383
+ gates or the forge, or on hold, and the slot goes to the next ready ticket. The
2384
+ dispatcher records the finish as an advisory `pipeline.settled` fact when the
2385
+ engine first decides `wait awaiting-pr`. A build that has not finished keeps its
2386
+ slot, even while paused, blocked or interrupted between `finalize.completed`
2387
+ and its post-steps. When a finished build must restack, re-verify or reconcile,
2388
+ it is admitted before new ticket claims, as a node is: intake reserves a slot
2389
+ for it, and its wait records nothing, consumes no attempt and raises no
2390
+ attention. Abort and pause acknowledgements are not gated. A finished build
2391
+ keeps its workspace until it merges or closes, so retained workspaces can
2392
+ exceed `capacity`; running work cannot.
2393
+
2308
2394
  Additional scheduled ingesters such as `ingest:sentry` remain an open design
2309
2395
  thread and have no shipped config surface. Observation harvest is
2310
2396
  pressure-driven: on the existing one-pass scan of repository build streams, the
@@ -2386,6 +2472,21 @@ event-level mechanics live in the repository catalog and reducer tests):
2386
2472
  ordinary parked run and clears every exhaustion barrier. It never
2387
2473
  resurrects a terminal run. Completed and escalated runs are irrevocable; a
2388
2474
  deliberate escalation consumes its snapshot and is never auto-recovered.
2475
+ - **A live hosted execution owns its run.** While a `harvest.execution.started`
2476
+ has no release and its provider reports it running (or cannot answer),
2477
+ dispatch launches no harvest and never judges its open session. Only after
2478
+ settlement records the release does the next launch record an interrupted
2479
+ session, once, and recovery proceeds. The guest's authority is its durable
2480
+ `harvest.execution.authorized`, not the launching invocation's repository
2481
+ lease: it never claims, renews or releases that lease, so `--once`
2482
+ teardown and a successor's acquisition neither fence it nor are blocked by
2483
+ it. At durable boundaries, at most once per heartbeat interval, it re-reads
2484
+ one constant-size served value of the current authorization and exits
2485
+ `held` once its execution was released or a later execution was
2486
+ authorized. It fails closed: an unreadable or unsupported value stops it,
2487
+ and transient read failures are tolerated for at most one lease TTL.
2488
+ Before exiting it closes any open session bracket with its transcript, so
2489
+ runner loss is judged only for real interruptions.
2389
2490
  - **The harvester only proposes.** It never claims, grooms, or dispatches a
2390
2491
  proposal, and it files every one into the same configured state rather than
2391
2492
  ranking them. Humans own Triage → Ready by default. A repository that points
@@ -2406,13 +2507,40 @@ repository; an owner selects a registered repository explicitly. Team and state
2406
2507
  fields from clients convey no authority or lifecycle policy. Tickets, comments,
2407
2508
  blockers, creation-key deduplication and assets are isolated by repository.
2408
2509
  Independent project ticket policy supplies hosted lifecycle names: triage, ready,
2409
- doing, done (`doneState`), and create/proposal equal to triage by default. Hosted
2410
- readyState defaults to ready; other sources require it. Legacy clients without
2411
- independent policy use uploaded dispatcher config and its old defaults. Configured roles may overlap.
2510
+ doing, done (`doneState`), and create/proposal equal to triage by default, plus
2511
+ the optional backlog and rejected roles. Hosted
2512
+ and GitHub readyState defaults to ready; other sources require it. Legacy clients without
2513
+ independent policy use uploaded dispatcher config and its old defaults. Configured roles may overlap,
2514
+ except the backlog and rejected roles below.
2412
2515
  The service has no Linear backend and never relays external ticket sources.
2413
- Projects using Linear, files or plugins keep their direct dispatcher connection;
2516
+ Projects using Linear, GitHub, files or plugins keep their direct dispatcher connection;
2414
2517
  service ticket surfaces refuse with project/source feedback instead of empty data.
2415
2518
 
2519
+ **GitHub tickets are the forge repository's issues.** `[tickets] source = "github"`
2520
+ selects the issues of the GitHub repository `origin` names and authenticates as the
2521
+ `github` forge does: `GITHUB_TOKEN`, then `GH_TOKEN`, then the gh CLI login.
2522
+ Ticket ids are issue numbers, and pull requests are never tickets. Lifecycle
2523
+ defaults are triage, ready, doing and done, with create and proposal equal to
2524
+ triage and `readyLabels` defaulting to `["autobuild"]`. A state is an
2525
+ `autobuild:<state>` label on an open issue; an open issue with no state label is
2526
+ in triage, and one with two or more is excluded with a diagnostic. Closing
2527
+ reasons carry the terminal states: closed as completed (or with no recorded
2528
+ reason) is done; closed as not planned or duplicate is the rejected role's
2529
+ state, or a fixed `not-planned` state, never ready and never resolving a
2530
+ blocker, when no rejected role is configured. Reopening an issue on GitHub
2531
+ returns it to triage, and the adapter strips a stale pre-reopen state label the
2532
+ first time it reads the issue. Blockers are GitHub's native issue dependencies,
2533
+ and a blocker in another repository never resolves. Assets live in the
2534
+ BuildStore, with notes posted as issue comments, and `get` carries no comment
2535
+ history; export and import read it explicitly. A ticket's own issue is an implicit `closes` link. A node is an issue
2536
+ with the exact `node` label, and a ticket targets a node by being a sub-issue
2537
+ of the node's issue (§13.1). The source has no guarded writes. Export and import are supported (see
2538
+ [Ticket source migration](#ticket-source-migration)). Dispatcher reads are
2539
+ conditional requests whose validators live only under the local state root, so
2540
+ an unchanged repository costs a tick no primary rate-limit budget; display-only
2541
+ state counts are one fresh GraphQL request per call, plus one per further
2542
+ page of 100 `autobuild:` labels, and are never cached.
2543
+
2416
2544
 
2417
2545
  The TicketSource **initiates and receives projections; it is never consulted
2418
2546
  mid-build and never used as artifact storage.** Dispatch reads the ticket
@@ -2431,7 +2559,7 @@ replacing, or removing an asset instead leaves a note on the ticket through the
2431
2559
  existing `comment()` port — the outward projection every source, including the
2432
2560
  plugin surface, already supports. The note names the asset, its revision, file
2433
2561
  count, and size, and gives the `ab ticket asset get` command that fetches it, so
2434
- a person reading the ticket in Linear, the hosted service, or a local file knows
2562
+ a person reading the ticket in Linear, GitHub, the hosted service, or a local file knows
2435
2563
  the asset exists. The note is a projection outward only; nothing reads it back,
2436
2564
  and existing sources and plugins need no asset capability.
2437
2565
 
@@ -2455,11 +2583,28 @@ boundary: a label name need not already exist for either create or update.
2455
2583
  Adapters own reconciliation with provider-side label registries, including
2456
2584
  concurrent attempts to create the same name; callers never pre-register labels.
2457
2585
 
2586
+ **Lifecycle roles.** The roles are triage, backlog, ready, claimed, done and
2587
+ rejected, plus the create and proposal placements. Each source maps them to its
2588
+ own native state names through `[tickets].*State`. Backlog holds work that is
2589
+ deliberately deferred, and rejected holds work that was considered and declined.
2590
+ Both are optional and have no default: `backlogState` and `rejectedState` unset
2591
+ means the role does not exist, and a state that merely shares the role's name
2592
+ holds no role. Neither may share its native state with the ready, claimed, done,
2593
+ triage or proposal role, or with each other. The dispatcher never claims from,
2594
+ moves into, or files harvest proposals into either. A ticket in the rejected
2595
+ state never resolves a blocker, and a rejected child no longer keeps its node
2596
+ incomplete; a backlog child still does, as triage and ready children do. Moving
2597
+ a ticket out of the rejected state restores ordinary behavior. Agents and
2598
+ operators move tickets by role (`ab ticket move <id> --role backlog`); a role
2599
+ the repository has not configured is refused with the key to set. "Building"
2600
+ is the claimed role, not a role of its own.
2601
+
2458
2602
  **Ticket dependencies.** A ticket may declare blockers within its source, at
2459
2603
  creation or later. The source owns representation (how a blocker is stored)
2460
2604
  and completion semantics (what "done" means); the dispatcher owns the
2461
2605
  decision — an unresolved blocker means the ticket is not claimed and creates
2462
- no build. Dependencies are written during grooming or by an approved harvest
2606
+ no build. A blocker in the configured rejected state never resolves, whatever
2607
+ the source's native completion semantics. Dependencies are written during grooming or by an approved harvest
2463
2608
  create, then read at dispatch time. Harvest validates agent-declared source-local ids
2464
2609
  and automatically derives unresolved same-source observation origins through
2465
2610
  fresh configured-source lifecycle reads before creating the proposal ticket.
@@ -2470,6 +2615,112 @@ dependency-blocked ticket stays
2470
2615
  queued source work rather than becoming a blocked build: the runtime `blocked`
2471
2616
  status is for builds awaiting a human.
2472
2617
 
2618
+ **Forge issue links.** A ticket may record the forge issues it addresses, each
2619
+ as `{issue, intent}`: `issue` is a positive issue number and `intent` is
2620
+ `closes` (the default; the work fully resolves the issue) or `refs` (the work
2621
+ only partly addresses it). Issue numbers are unique within a ticket and reads
2622
+ return links sorted by number; absent means none. Create sets links; update
2623
+ replaces the whole set, and an empty set clears it. Sources declare support.
2624
+ The file and hosted sources store links. The GitHub source stores each link to
2625
+ another issue as an `autobuild-link:<intent> #<n>` label and always reports the
2626
+ ticket's own issue as a `closes` link that cannot be removed. The Linear source
2627
+ refuses them, because Linear links GitHub issues natively through its own
2628
+ integration.
2629
+ A source that cannot store links refuses any create or update that names
2630
+ them, including an empty set, with a typed error naming the source, before
2631
+ anything is written; it never drops them. Writes that name no links are
2632
+ unaffected. `ab ticket create` and `update` take `--issues N[:refs],...`;
2633
+ operator and MCP ticket requests take `issueLinks`.
2634
+
2635
+ **Ticket priority.** A ticket's priority is `urgent` or `normal`; absent means
2636
+ normal. Urgent ready work is claimed before normal ready work (§12) and nothing
2637
+ else changes. Sources declare support. The file source stores
2638
+ `priority = "urgent"` in its frontmatter, writes no key for normal, and covers
2639
+ urgent priority in its revisions; the in-memory fake behaves the same way.
2640
+ The hosted source stores priority in the hosted ticket store, covers it in its
2641
+ revision, and lists urgent ready tickets first; an update that omits priority
2642
+ never changes it. The Linear source maps its native Urgent priority (1) to
2643
+ `urgent` and reads every other value as normal; it writes Urgent for `urgent`,
2644
+ clears only a current Urgent to No priority for `normal`, and covers urgent
2645
+ priority in its revisions. Plugins without the capability read every ticket
2646
+ as normal and refuse a create or
2647
+ update naming `urgent` with a typed error naming the source, before anything is
2648
+ written. Naming `normal` on such a source is a successful no-op. `ab ticket
2649
+ create` and `update` take `--priority urgent|normal`; operator and MCP ticket
2650
+ requests take `priority`; JSON ticket output always names it. Harvest files
2651
+ every proposal normal; grooming marks one urgent.
2652
+
2653
+ A build freezes its ticket's links into `build.created` when it claims the
2654
+ ticket, from the same sample as the body. Later ticket edits and spec revisions
2655
+ never change them. An agent in the build may downgrade one linked `closes`
2656
+ issue to `refs` with `ab issue downgrade <N> --reason <text>`, recorded as the
2657
+ agent fact `issue-link.downgraded {issue, reason}`. No fact expresses an
2658
+ upgrade, and downgrading a `refs` or unlinked issue is refused. Before the
2659
+ first PR side effect, local finalize appends the kernel fact
2660
+ `issue-links.sealed`; remote finalize is sealed by its
2661
+ `publication.requested {operation: finalize}`. The reducer applies a downgrade
2662
+ only when it precedes the seal, so retries and an adopted PR always compose the
2663
+ same links. `ab context` and `ab build status` show the effective links and
2664
+ any downgrade reason.
2665
+
2666
+ A forge declares the `closesIssues` capability when closing keywords that
2667
+ reach the default branch close issues; GitHub does, `local-git` does not. Only
2668
+ for a leaf whose target is the configured base branch, through such a forge,
2669
+ the kernel passes the sealed links to the adapter, which composes them with
2670
+ `kernel/issue-keywords.ts`. The PR body ends with one `Closes #N` or `Refs #N`
2671
+ line per link, ascending by number, whatever the description says. The landed
2672
+ squash message, including forge auto-merge and the janitor's freshness
2673
+ comparison, carries the same paragraph immediately before its terminal
2674
+ trailer block. Every closing keyword aimed at a `refs` issue in the PR title,
2675
+ body or landing message, including `owner/name#N` and issue URLs for the
2676
+ adapter's own repository, is rewritten to `refs`. A forge without the
2677
+ capability records links without emitting them.
2678
+
2679
+ A leaf targeting a node cannot close anything, because only the default
2680
+ branch closes issues. Its PR body still ends with one `Refs #N` line per linked
2681
+ issue, ascending by number, whatever each link's intent, so each issue shows
2682
+ the PR, and every closing keyword aimed at a linked issue in its title or body
2683
+ is rewritten to `refs`. Its landed commit carries no keyword lines. Its links
2684
+ travel to the node. When a child of node N, a leaf or a nested node, reaches `pr.merged`
2685
+ by kernel landing, human merge or abort cleanup, the dispatcher appends
2686
+ `node.issue-links-recorded {build, issueLinks}` to N before the child completes.
2687
+ Until that fact exists, a merged child with links that has not completed stays
2688
+ one of N's open children, even when it is aborted or its ticket no longer
2689
+ targets N, so N cannot verify or land without its contribution. The payload is the child's contribution: a leaf's effective links, with
2690
+ `downgraded: true` where a downgrade applied before its seal, or a nested node's
2691
+ set: its own effective links, with the same downgrade provenance, merged with
2692
+ its union. Every contributing child gets its own fact, even when the union does
2693
+ not change, and N's reducer keeps the recorded child slugs so a retry never
2694
+ records twice. N's reducer folds contributions into a running union, never
2695
+ re-reading child history. Per issue, a downgrade by any child makes it `refs`;
2696
+ otherwise any `closes` makes it `closes`; an issue every child only references
2697
+ stays `refs`.
2698
+
2699
+ A node's set is its own effective links merged with its union under the same
2700
+ per-issue rules. A root node's PR into the default branch carries the set, and
2701
+ only through a forge with both `closesIssues` and `updatePrIssueLinks`. The PR
2702
+ opens with the set, and each later contribution rewrites the body's keyword
2703
+ lines through `updatePrIssueLinks`, which preserves prose, neutralizes closing
2704
+ references to `refs` issues in the title, writes only on change and confirms by
2705
+ readback. `node.issue-links-published {pr, issueLinks}` records the confirmed
2706
+ lines, so a poll compares reduced state and calls the forge only when the set
2707
+ or PR changed. An open root PR whose confirmed lines predate the node's own
2708
+ links gains them on its next sync. Before the kernel lands a root node it
2709
+ refreshes the body to the final set and confirms the readback, whatever was
2710
+ published; a failure stops the attempt before any merge request. Merging the node PR, by the
2711
+ kernel's rebase landing or a human, closes every fully resolved issue. Landed
2712
+ child commits keep their own messages and carry no keywords, so one child's
2713
+ `Closes` cannot override another child's downgrade. A nested node's PR into its
2714
+ parent carries its set as refs-only lines, kept current the same way. A forge
2715
+ lacking either capability records the union and emits nothing.
2716
+
2717
+ When a `closesIssues` adapter's `openPr` adopts an existing open PR for the
2718
+ head with links, it converges that PR as a fresh one would be composed: it
2719
+ neutralizes the kept title, recomposes the body's keyword lines, writes only on
2720
+ change and confirms by readback. The title, prose and merge message are never
2721
+ replaced, so a retry, re-finalize, reconcile or hand-opened PR carries the same
2722
+ lines as the first publication, never duplicated.
2723
+
2473
2724
  In repositories with integration nodes, a blocker that has a build resolves only
2474
2725
  when its change identity is present in the dependent's sampled target head
2475
2726
  (the configured root branch when no target is set). Source completion or an
@@ -2481,13 +2732,24 @@ is excluded. An empty completed node contributes nothing; missing or ambiguous
2481
2732
  completion evidence does not mean empty. The newest build generation is used,
2482
2733
  with ties diagnosed rather than falling back to older successful work.
2483
2734
 
2484
- Destination observations retain versioned, head-bound Git witnesses (reachable
2485
- commit SHAs and direct build trailers) and a fixed-length evidence digest. Current
2735
+ Destination observations record a head-bound, query-scoped probe rather than
2736
+ the destination's history: only the commit SHAs and direct build trailers in the
2737
+ proof closure of the identities being decided (blocker identities, plus the
2738
+ landings and confirmed foreign aliases that could transport them), which of those
2739
+ are reachable from the sampled head, presence answers for only those identities,
2740
+ and a fixed-length evidence digest. Observation size is bounded by that closure,
2741
+ independent of the destination's reachable commit count and of repository history.
2742
+ While the head is unchanged and the probe covers the current questions, current
2486
2743
  confirmed landings and aliases from only the destination's accepted ancestry are
2487
- reapplied before reuse. Unrelated merged history and ready destinations do not
2488
- invalidate this proof. Head changes require a fresh Git sample; legacy observations
2489
- without witnesses refresh once rather than replaying repository history. Current
2490
- readiness and newest-generation checks still apply before claim.
2744
+ reapplied without Git; unrelated merged history and ready-set changes neither
2745
+ invalidate it nor append events. A moved head requires a fresh Git sample. A
2746
+ newly relevant landing or a new question needs only a new probe: a dispatcher
2747
+ still holding the full in-memory witness for that branch and head compacts one
2748
+ without Git, and otherwise samples Git once. Observations without a probe,
2749
+ including older full-history witnesses, are never trusted for admission: they
2750
+ are re-derived once the same way, and an unavailable sample leaves the dependent
2751
+ queued; neither replays repository history. Current readiness and
2752
+ newest-generation checks still apply before claim.
2491
2753
 
2492
2754
  Demand-driven restacking supplies ancestor changes to descendants. Sibling changes
2493
2755
  wait for their node to merge in the common ancestor and presence demand into the target;
@@ -2506,7 +2768,12 @@ that support idempotent creation preserve it through create, adoption, get, and
2506
2768
  ready listing. The reservation fact precedes the external side effect — that
2507
2769
  ordering, not provider behavior, is what makes filing crash-safe. Dispatch
2508
2770
  uses the key only to withhold unfinished Autobuild creates; its absence fails
2509
- open for legacy/plugin tickets and introduces no new readiness gate.
2771
+ open for legacy/plugin tickets and introduces no new readiness gate. A keyed
2772
+ create may also carry `idempotencyKeyReservedAt`, the earliest time the key could
2773
+ first have been used, which callers repeat unchanged on every retry. A source
2774
+ whose key lookup is bounded by time, such as GitHub, refuses a keyed create
2775
+ without it; harvest passes its reservation fact's time, and migration import
2776
+ passes the time its migration identity was first saved.
2510
2777
 
2511
2778
  ### 13.1 Node tickets and targets
2512
2779
 
@@ -2519,14 +2786,20 @@ the branch is open to targeting tickets immediately, without a PR. Idle integrat
2519
2786
  builds use no provisioned workspace, runner, execution lease, or dispatch capacity.
2520
2787
 
2521
2788
  A node requesting reconcile or verification is admitted before new ticket
2522
- claims. Its candidate occupancy excludes itself and capacity-bearing blocked or
2789
+ claims. The request is durable: a prepared verification cycle or a restack
2790
+ conflict, with no runner yet. Until the node holds its slot, intake reserves one
2791
+ slot for it, and the dispatcher checks its admission every tick regardless of
2792
+ idle node polling, so a slot freed in any tick goes to the node, not to a new
2793
+ claim. Its candidate occupancy excludes itself and capacity-bearing blocked or
2523
2794
  paused descendants, following accepted source-qualified build target ancestry.
2524
2795
  Running descendants and unrelated builds still count; ordinary blocked and
2525
2796
  paused work retains its slot for every other admission. Provisioning reserves
2526
2797
  node occupancy before the runner starts. This exception never raises the budget
2527
2798
  for new claims. Status and both dashboards report actual occupancy, configured
2528
2799
  capacity, effective display capacity and the nodes using descendant-held slots.
2529
- Idle collecting nodes remain free.
2800
+ Status, `ab builds` and both dashboards report each node waiting for a slot
2801
+ ahead of new ticket claims, and report a finished work build waiting to run
2802
+ again the same way. Idle collecting nodes remain free.
2530
2803
 
2531
2804
  An empty node has no PR and reports `integration`, `target`, and `empty`.
2532
2805
  Once it holds commits its current parent lacks, the dispatcher opens or adopts
@@ -2538,8 +2811,8 @@ metadata changes. Missing, unopened, merged, closed or aborted targets remain
2538
2811
  queued with a diagnostic. The newest generation wins; a closed generation never
2539
2812
  falls back to an older open one. Blockers remain a separate graph.
2540
2813
 
2541
- A node is complete when exhaustive native ticket enumeration finds no unresolved
2542
- ticket targeting it, no unsettled frozen child claim remains, and a merged
2814
+ A node is complete when exhaustive native enumeration of the tickets targeting
2815
+ it (the optional `listTargeting`, else `listAll`) finds no unresolved one, no unsettled frozen child claim remains, and a merged
2543
2816
  contribution is durably known. Triage, backlog and ready children keep it open;
2544
2817
  done and cancelled children do not. Listing diagnostics fail closed. Completeness
2545
2818
  is sampled again before verification and publication. Source edits cannot be
@@ -2557,6 +2830,9 @@ Merge refuses incomplete nodes and names open children; `ab hold` remains availa
2557
2830
  Node parents and local-git roots receive guarded fast-forwards, preserving one
2558
2831
  commit and identity trailer per contributing build. GitHub shared roots use the
2559
2832
  PR rebase endpoint guarded on verified head, after a final parent freshness read.
2833
+ A root node's PR body carries the node's own issue links and its landed
2834
+ children's, and is refreshed before landing, so merging it closes them (see
2835
+ Forge issue links).
2560
2836
  Authoritative enforced up-to-date protection records fenced merge; uncertainty
2561
2837
  records unfenced merge and triggers immutable merged-tree comparison. A mismatch
2562
2838
  raises operator attention and never rewrites the shared parent.
@@ -2610,7 +2886,7 @@ deduplicated `node.parent-rejected` diagnostics when invalid, preserving effecti
2610
2886
  ancestry. Restoring the effective target records `node.parent-rejection-cleared`,
2611
2887
  removing the current refusal while retaining its historical fact. Rejection deduplication
2612
2888
  compares revision, target and reason independently of persistence key order.
2613
- Missing source reads withhold parent acceptance; ordinary cascade and PR handling
2889
+ Missing source reads withhold parent acceptance; ordinary demand-driven restack and PR handling
2614
2890
  continue against durable effective ancestry. Accepted moves finish their reserved
2615
2891
  Git and PR effects independently of tracker availability. A PR merged or closed
2616
2892
  by a human follows ordinary terminal handling. Changing a claimed work ticket's target is
@@ -2636,8 +2912,11 @@ pending while ancestors restack or reconcile. A durable availability observation
2636
2912
  allows unchanged idle ticks, including after restart, to skip repository preparation
2637
2913
  and native auto-merge cancellation. Exact node/parent heads, contribution base,
2638
2914
  request contents, accepted ancestry, foreign aliases and confirmed landing evidence
2639
- invalidate that observation when they change; polling timestamps do not. Failed
2640
- assessments never establish unavailability. Availability is not proof of destination
2915
+ invalidate that observation when they change; polling timestamps do not. Confirmed
2916
+ landing evidence comes from every repository build, including mixed-version deferred
2917
+ builds whose own decisions stay withheld, so the dispatcher check and the node
2918
+ transaction assess the same fingerprint. Failed assessments never establish
2919
+ unavailability. Availability is not proof of destination
2641
2920
  coverage. Moving to another destination branch explicitly settles obsolete requests
2642
2921
  with `destination-changed`; losing identities on the same branch leaves them waiting.
2643
2922
  Native auto-merge is suspended with confirmed, reusable receipts only when replay
@@ -2739,6 +3018,18 @@ the parent relation. Label replacements can demote nodes and receive the same
2739
3018
  guards; explicit kind and label instructions must agree about `node`. Label
2740
3019
  and parent connections are fully paginated. Linear still refuses guarded writes.
2741
3020
 
3021
+ GitHub uses the exact `node` issue label for kind and the sub-issue relation for
3022
+ target, only when the parent issue carries that label and is in the same
3023
+ repository. Any other parent is grouping: it imposes no target, never blocks
3024
+ dispatch and is never removed or replaced. A target write on a sub-issue of a
3025
+ grouping parent is refused, naming the parent; a target clear leaves grouping
3026
+ alone; setting a target replaces a node parent. Sub-issue and label changes
3027
+ made on GitHub read back the same as `ab ticket` writes. Demotion checks the
3028
+ node's fully paginated sub-issue list. A repository label that differs from
3029
+ `node` only by case is refused before any write. Integration observation reads
3030
+ the node issue and its sub-issues conditionally, so its cost follows the
3031
+ node's children, not the repository. GitHub refuses guarded writes.
3032
+
2742
3033
  Hosted sources support kind and target with project-scoped transactional validation.
2743
3034
  Existing tickets default to work with no target. Metadata changes increment the
2744
3035
  revision once; equivalent aliases and unchanged values do not. Node demotion
@@ -2853,7 +3144,16 @@ request against the base branch and records published/publish-failed journal
2853
3144
  facts.
2854
3145
 
2855
3146
  Successful dispatcher ticks with no effects, counters, diagnostics, queue change,
2856
- or attention transition append no tick boundary events. The first queue baseline,
3147
+ sampled triage-count change, or attention transition append no tick boundary
3148
+ events. Only a dispatcher feeding an interactive dashboard samples the triage
3149
+ count, at most once per 60 s, outside dispatcher ticks, from the ticket
3150
+ source's state counts; each tick publishes the last good sample. A viewer
3151
+ (`ab dispatch --viewer`, or the default viewer placement for hosted dispatch)
3152
+ reads the configured triage state's count itself, at most once per 60 s while
3153
+ its dashboard runs, through the ticket source's bounded state-count answer
3154
+ (`countStates`, the hosted `state-counts` operation). It never lists tickets
3155
+ or reads events for it, and its header shows only its own last successful
3156
+ count, never published status; a headless tick still makes no triage read. The first queue baseline,
2857
3157
  failed ticks, meaningful ticks, diagnostic clearing, failure recovery, and the
2858
3158
  first retry after a source cooldown remain recorded. Recorded starts may arrive
2859
3159
  with completion; optional `startedAt` preserves the actual start time, falling
@@ -2885,6 +3185,25 @@ stands in for tick completion. Telemetry survives lease release. Safe shutdown
2885
3185
  uses the matching run's open observation, historical journal boundaries when
2886
3186
  absent, and refuses forced termination when the observation cannot be read.
2887
3187
 
3188
+ The repository dispatch lease lasts `policy.dispatchLeaseTimeoutSeconds`
3189
+ without renewal (60 by default) and is renewed every
3190
+ `policy.dispatchLeaseRenewalSeconds` (20 by default; it must be less than the
3191
+ timeout). A claim stores the timeout with the lease, so a reloaded pair is
3192
+ adopted at the next tick through a same-holder claim. Claims and adoption are
3193
+ serialized, and a renewal answered under an earlier pair is discarded, so the
3194
+ holder's local deadline never outlasts the stored expiry. A holder whose own
3195
+ lease lapsed — a host stall longer than the timeout, or renewals lost to a store
3196
+ outage — starts no ticket claim, launch, execution start, provisioning, forge
3197
+ write, `git push` or status publication, including from a continuation that
3198
+ resumes mid-operation; those effects are fenced where they are called. It then
3199
+ reads the repository record: when the record still names it, expired or not, it
3200
+ claims the lease again and carries on; when the record names another run, or
3201
+ there is no record (only a holder's release clears it), it stops as
3202
+ `superseded`. An expired lease of its own is never treated as a takeover, and it
3203
+ never records a `tick-yielded` naming itself. A store error is retried at the
3204
+ next renewal or tick. An effect already in flight when the stall began
3205
+ completes; cancelling it could tear external state.
3206
+
2888
3207
  Both dashboards show each accepted unfinished generation handoff, naming its source
2889
3208
  and target runtimes (version and abbreviated commit), mode and drain deadline
2890
3209
  (`unknown` for missing historical facts). A drain-mode outstanding execution
@@ -3018,7 +3337,7 @@ with illustrative members:
3018
3337
  | Operator commands [D2] | `build.pause-requested` → `build.paused`; `build.discard-requested`; `build.hold-requested`; `build.land-requested` → `landing.command-acknowledged`; `escalation.answered` (optionally carrying a validated `reviewRoundCeiling`, or the `assets` sampled with a revise-from-ticket authorization) |
3019
3338
  | Merge policy | `landing.decided` (candidate, matched rule/default, labels, target, mode); `landing.native-enable-started`; `landing.native-applied` |
3020
3339
  | Spec | `spec.imported`, `spec.authored`, `spec.revised` (either positive `escalation` sequence or exclusive `operator: {user, via?}` provenance for an idle node; optionally carrying `assets`, a re-pin of the ticket's assets, §6.3) |
3021
- | Sessions | `session.started` (including optional write-ahead continuation intent and budget ceiling); `session.suspended` with partial transcript and active duration; `session.resumed` acceptance (stale reports are inert); reasoned `session.resume-fallback`; kernel-only `session.native-handle-recorded` with bracket and native execution identity; `session.ended` with transcript ref and usage (ordinary completion — the analysis corpus), or `session.ended {outcome: reclaimed, reclaimedBy: {instance, resumedFromSeq}}` (explicit transcriptless takeover) |
3340
+ | Sessions | `session.started` (including optional write-ahead continuation intent, budget ceiling, and the effective first `prompt` the bracket sent: the start prompt, the live continuation message, or the interruption notice); `session.suspended` with partial transcript and active duration; `session.resumed` acceptance (stale reports are inert); reasoned `session.resume-fallback`; kernel-only `session.native-handle-recorded` with bracket and native execution identity; `session.ended` with transcript ref and usage (ordinary completion — the analysis corpus), or `session.ended {outcome: reclaimed, reclaimedBy: {instance, resumedFromSeq}}` (explicit transcriptless takeover) |
3022
3341
  | Plan/code loops | `plan.started` … `plan-review.verdict`; `implement.started` … `code-review.verdict` |
3023
3342
  | Verify/finalize | `verify.started {step, attempt, feedback?, baseSha?, headSha?, restackId?}`, `verify.completed {step, outcome, skipCause?, baseSha?, headSha?, restackId?}`, `verify.cancelled {step, attempt, cause: {step}, baseSha?, headSha?, restackId?}`, `verify.stage-failed {attempt, cycle, stage, failed, cancelled, baseSha?, headSha?, restackId?}`, `verify.reconcile-policy-captured {reconcileSeq, steps}`, `finalize.completed {pr}`, `finalize.step-started {step}`, `finalize.step-completed {step, ok, headSha?}` |
3024
3343
  | Integration attention | Kernel/dispatcher `integration.verification-failed {id, head, parent, steps, guidance}`: one durable failed-cycle notification, recovered from exact verification receipts |
@@ -3026,7 +3345,7 @@ with illustrative members:
3026
3345
  | PR attachments | `pr-attachment.designated`, `pr-attachment.hosted`, `pr-attachment.reclaimed`, `pr-attachment.reclaim-failed` |
3027
3346
  | Leaf restacking | `target.moved {branch, sha, lineage?}`, `target.rewritten {branch, previousSha, sha}`, `target.rewrite-cleared {branch, sha, lineage?}`, advisory `target.distance {branch, sha, head, count}`, `restack.prepared`, `restack.replayed`, `restack.publish-intended`, `restack.rewritten`, `restack.contended`, `restack.completed` |
3028
3347
  | Post-PR [D1] | `pr.merged`, `pr.conflicted`, `reconcile.progress-checked`, `reconcile.started`, `reconcile.prepared`, `reconcile.replayed`, `reconcile.publish-intended`, `reconcile.rewritten`, `reconcile.contended`, `reconcile.completed` |
3029
- | Cross-cutting | `observation.recorded`, `escalation.raised`, `phase.failed`, `session.build-read-failed`, `phase.deferred`, `phase.deferral-escalated` |
3348
+ | Cross-cutting | `observation.recorded`, `escalation.raised`, `phase.failed`, `session.build-read-failed`, `session.build-read-recovered`, `phase.deferred`, `phase.deferral-escalated` |
3030
3349
  | Repository journal | dispatcher setting facts; run lifecycle, effective config, tick/queue diagnostics, reload and runner outcomes; the `harvest.*` workflow, recovery, and ledger facts |
3031
3350
 
3032
3351
  Abort cleanup is a dispatcher-owned ordered saga. While an execution lease is
@@ -3283,7 +3602,11 @@ Passed or skipped target-movement, restack and reconcile cycles consume zero.
3283
3602
  Cycle identifiers remain monotonic independently of this budget. The history
3284
3603
  pass, pass, pass, fail uses one failure even when the failing cycle is attempt 4.
3285
3604
  The third distinct failed cycle at the default limit escalates. Budget
3286
- exhausted → `escalation.raised {source: "policy"}`. Guidance answering that
3605
+ exhausted → `escalation.raised {source: "policy"}`. The budget is build-wide, so
3606
+ its question lists each counted failed attempt with that attempt's failed steps.
3607
+ It says a step failed in every counted cycle only when it did; otherwise it names
3608
+ the latest failed cycle and its steps. The escalation still targets the last failed
3609
+ `verify:<step>`. Guidance answering that
3287
3610
  policy escalation routes to `implement` and outranks the pending report. By
3288
3611
  contrast, when the agent verifier itself uses `ab escalate`, guidance answering
3289
3612
  it reruns that same step with `verify.started {feedback: {guidance}}`; `ab context`
@@ -3334,7 +3657,10 @@ compatibility deferral. Interrupted pairs and historical logs remain readable
3334
3657
  with runtime null in JSON and `runtime unrecorded` in human detail.
3335
3658
 
3336
3659
  The runtime is captured once per executing process from its own distribution,
3337
- never the consuming repository or dispatcher on behalf of a runner. It includes
3660
+ never the consuming repository or dispatcher on behalf of a runner. Capture
3661
+ happens on first need, no later than the process's first runtime-recorded
3662
+ companion (the runner's construction or the dispatcher's run start); importing
3663
+ modules performs no capture. It includes
3338
3664
  `version`, `commit` (a Git object id or explicit `unknown`), and
3339
3665
  `source: {kind: source | package, location}` with an absolute distribution root
3340
3666
  (realpath when available). A source distribution owns its Git top level,
@@ -3355,8 +3681,8 @@ setup under the claimed lease before announcing another attachment. Another
3355
3681
  failure appends only a new failure fact; success appends `runner.attached
3356
3682
  {resumedFromSeq}` and clears the current error projection. After
3357
3683
  `policy.maxSetupAttempts`, the kernel raises one policy escalation targeted at
3358
- `setup`; lease sweeps and fresh dispatcher startup leave it parked until a human
3359
- answer re-arms the setup budget. Its exhaustion guard considers only setup-targeted
3684
+ `setup`; lease sweeps and fresh dispatcher startup leave it parked until an answer
3685
+ from the operator agent or a human re-arms the setup budget. Its exhaustion guard considers only setup-targeted
3360
3686
  policy raises, independently of phase-policy exhaustion. After claiming the lease,
3361
3687
  however, a runner honors an engine-selected pause or abort acknowledgement before
3362
3688
  setup-failure gating, even while that escalation is open. This control-only path
@@ -3373,11 +3699,21 @@ non-destructive execution fence for the exact workspace and execution generation
3373
3699
  It preserves unpublished branch commits and distinct detached producer candidates
3374
3700
  under immutable `refs/autobuild/archive/<build>/<sha>` refs, verifies their exact
3375
3701
  readback, and records `workspace.commits-preserved` before cleanup. Replacement
3376
- provisioning restores those exact refs before starting an agent. Preservation
3702
+ provisioning restores those exact refs before starting an agent, reading them
3703
+ from the local repository with the local-git forge and fetching each exact ref
3704
+ from the remote otherwise. A preserved
3705
+ branch head that the build's latest 64 replaced heads cover, as the replaced
3706
+ head itself or one of its ancestors, is kept only as archived objects: it is
3707
+ never preserved or restored as the branch, and provisioning records the skip as
3708
+ `restorationSkipped` on `workspace.provisioned`. Rewrites older than that bound,
3709
+ and unpublished divergent branch work, are still refused. Preservation
3377
3710
  never advances the public build branch. A confirmed absent environment, or one
3378
3711
  that exists without a provisioned checkout, records `workspace.commits-lost`,
3379
3712
  naming known candidates and explicitly noting that any additional unpublished
3380
- SHAs could not be inspected. Unknown fencing, inspection, transport, or
3713
+ SHAs could not be inspected. An environment that never started executing holds
3714
+ no unpublished work: objects its checkout lacks mean nothing to preserve, so
3715
+ cleanup records `workspace.commits-preserved` carrying forward earlier preserved
3716
+ heads, then releases and replaces it. Unknown fencing, inspection, transport, or
3381
3717
  receipt-write outcomes leave the workspace and snapshots intact. A workspace
3382
3718
  flagged by `workspace.cleanup-required` is never launched into: the dispatcher
3383
3719
  releases it and provisions the next generation. A preservation or release
@@ -3492,6 +3828,11 @@ and `verify.config-superseded` (§16.1). These facts do not change reconcile
3492
3828
  identity or its policy snapshot; replay gates still refer to the code/reconcile
3493
3829
  boundary. Superseded receipts remain historical evidence.
3494
3830
 
3831
+ `pipeline.settled { cycle }` is advisory capacity evidence. The dispatcher
3832
+ appends it once per settlement key (the later of the current verify cycle start
3833
+ and the latest `finalize.completed`) when the engine decides `wait awaiting-pr`;
3834
+ no pipeline decision reads it (§12).
3835
+
3495
3836
  ### 15.7 Post-PR lifecycle [D1 — confirmed]
3496
3837
 
3497
3838
  Walking the happy path exposed a gap in the grammar: `finalize` creates the
@@ -3538,9 +3879,11 @@ history and rewrite facts, plus both heads and the temporary change, under immut
3538
3879
  namespace or permission failures stop publication without a branch/tag fallback. Remote
3539
3880
  archives also publish commits present only on the remote: GitHub uses create-only
3540
3881
  Git-reference REST creation when the workspace lacks the commit, retaining guarded Git
3541
- pushes for local objects. Exact remote readback confirms publication, then a depth-one
3542
- fetch by the archive ref (without tags or configured refmap expansion) restores missing
3543
- commits and verifies them locally before returning.
3882
+ pushes for local objects. Exact remote readback confirms publication, then a non-shallow
3883
+ fetch of only that exact archive ref (without tags, configured refmap expansion or a
3884
+ depth limit) restores missing commits and their missing ancestry, writes no shallow
3885
+ boundary, leaves an already-shallow repository's existing boundaries unchanged, and
3886
+ verifies the commits locally before returning.
3544
3887
  Publication requests and loss records alone are not retained Git history: their
3545
3888
  unpublished objects may have died with a released sandbox. A separately published
3546
3889
  or reviewed tip remains an archive requirement even when an earlier request named
@@ -3604,7 +3947,9 @@ in Forge failure recovery; publication intent and frozen target remain unchanged
3604
3947
 
3605
3948
  **Stable merged identity.** A root-target leaf kernel merge remains one squash commit and
3606
3949
  preserves the forge's existing message except for normalizing terminal build
3607
- identity trailers to exactly one final `Autobuild-Build: <immutable slug>`.
3950
+ identity trailers to exactly one final `Autobuild-Build: <immutable slug>` and,
3951
+ for a build with issue links on a `closesIssues` forge, the issue keyword
3952
+ composition described under Forge issue links.
3608
3953
  Implementation commits and deposited PR descriptions are unchanged. The janitor
3609
3954
  records `pr.merged { sha, buildTrailerPresent? }` from the actual merged message,
3610
3955
  including human merges. True and false are successful observations; historical
@@ -3614,11 +3959,16 @@ completion. This evidence does not change reduction or display semantics.
3614
3959
 
3615
3960
  A node-target child merge instead fast-forwards its already canonical
3616
3961
  single-change commit, preserving exactly one terminal source-build identity.
3617
- The guarded destination write is authoritative: its pushed SHA and identity
3618
- produce the durable merge receipt independently of forge PR state. PR
3619
- acknowledgement is best-effort: observe a provider-reported merge, or comment
3620
- with the merged SHA and close a still-open review. Acknowledgement failure never
3621
- retries or fails the merge.
3962
+ The guarded destination write is authoritative once confirmed: the durable
3963
+ merge receipt, carrying the candidate SHA and identity, is recorded only after
3964
+ exact authoritative readback of the destination shows that candidate, or from
3965
+ the durable receipt of an accepted write overtaken before readback,
3966
+ independently of forge PR state. A different observed head is contention and
3967
+ records no merge; a failed readback records nothing and is retried; recovery of
3968
+ an interrupted merge uses the same exact readback. PR acknowledgement is
3969
+ best-effort: observe a provider-reported merge, or comment with the merged SHA
3970
+ and close a still-open review. Acknowledgement failure never retries or fails
3971
+ the merge.
3622
3972
 
3623
3973
  GitHub uses its authoritative viewer squash headline and body with an expected
3624
3974
  head guard. Native auto-merge messages are checked against fresh server defaults
@@ -3678,8 +4028,10 @@ Quiet polls append no attempt facts. Native application receipts and janitor
3678
4028
  bookkeeping are not pipeline execution progress.
3679
4029
 
3680
4030
  Native auto-merge is reconciled on every janitor poll against durable desired
3681
- merge state using the native state in the existing PR read, without additional
3682
- forge reads. A native write is issued only when observed and desired state disagree. It is disabled while held, unauthorized, unready, or replacement
4031
+ merge state using the native state in the existing PR read; an armed, authorized
4032
+ request on an eligible poll additionally gets the forge's landing-identity
4033
+ readback. A native write is issued only when observed and desired state,
4034
+ including that identity, disagree. It is disabled while held, unauthorized, unready, or replacement
3683
4035
  publication is pending or just completed; enabling binds to the current head
3684
4036
  through the forge's expected-head guard. Every replacement publication confirms
3685
4037
  cancellation first, and its first following poll re-reads and reconciles native
@@ -3747,7 +4099,7 @@ committer are Git's ordinary resolved repository identity, exactly as for a plai
3747
4099
  local commit; commit signing remains disabled. Before offering the candidate,
3748
4100
  the adapter resolves both identities through Git. If either is unavailable,
3749
4101
  consent remains pending and one reason-bearing follow-up names the missing
3750
- `user.name` / `user.email` configuration; later polls retry after the operator
4102
+ `user.name` / `user.email` configuration; later polls retry after the user
3751
4103
  configures it. When the base branch is checked out, Git's two-tree
3752
4104
  `read-tree -m -u` transition preflights and merges the old-to-squash tree:
3753
4105
  tracked/index changes on untouched paths and
@@ -3755,8 +4107,8 @@ untracked non-colliding files survive, while a tracked or untracked overwrite
3755
4107
  leaves consent pending and records one path-bearing follow-up instead of failing
3756
4108
  the dispatcher. Its durable pending-merge record is written before moving the
3757
4109
  base ref. A poll after a crash retries that same old-to-merged transition without
3758
- rolling back the ref or overwriting operator work; the PR remains open and
3759
- retryable until checkout repair succeeds. No merge is ever assumed: a build
4110
+ rolling back the ref or overwriting local work in the checkout; the PR remains
4111
+ open and retryable until checkout repair succeeds. No merge is ever assumed: a build
3760
4112
  reaches `merged` only when a later poll observes the merge and any required
3761
4113
  checkout synchronization. Without authorization, the local branch and PR record
3762
4114
  remain open for inspection with ordinary Git.
@@ -3864,7 +4216,7 @@ and default-attribution fields remain replay-compatible but are not new controls
3864
4216
 
3865
4217
  ```toml
3866
4218
  baseBranch = "main"
3867
- capacity = 3 # concurrent builds for this repo
4219
+ capacity = 3 # builds running work at once; builds parked for a merge decision hold no slot
3868
4220
  ticketScanIntervalSeconds = 60 # positive integer; ready scans, with tick spacing as floor
3869
4221
  forge = "github" # builtin: github | local-git; or a plugin name
3870
4222
  plugins = ["./plugins/local.ts", "@acme/autobuild-plugin"]
@@ -3924,6 +4276,8 @@ sessionBudgetSeconds = 7200 # optional role override
3924
4276
 
3925
4277
  [policy]
3926
4278
  upgradeDrainSeconds = 900 # local generation drain deadline, hot-reloaded
4279
+ dispatchLeaseTimeoutSeconds = 60 # repository dispatch lease lifetime without renewal
4280
+ dispatchLeaseRenewalSeconds = 20 # renewal interval; less than the timeout
3927
4281
  sessionBudgetSeconds = 3600 # non-infinite default for build agent sessions
3928
4282
  stallRounds = 3
3929
4283
  maxVerifyAttempts = 3
@@ -4281,19 +4635,24 @@ Every ticket read includes an opaque `revision`. Pass it as `expectedRevision`
4281
4635
  `move`, `block` and `unblock`. A stale write fails without changing anything and
4282
4636
  reports the current revision. Omission preserves unguarded behavior. Blocker
4283
4637
  checks cover the entire batch. Dispatcher moves remain unguarded and change the
4284
- revision. Sources without guarded writes, including Linear, refuse supplied
4285
- revisions rather than ignoring them.
4638
+ revision. Sources without guarded writes, including Linear and GitHub, refuse
4639
+ supplied revisions rather than ignoring them.
4286
4640
 
4287
4641
  `ab ticket edit <id>` opens `$VISUAL`, falling back to `$EDITOR`, using TOML
4288
4642
  frontmatter and a Markdown body. Only title, body and labels are editable;
4289
- kind, target, id, blockers, creation key and reference comments are read-only. It saves only
4290
- changed fields with the opening revision. Unchanged or formatting-only edits
4643
+ kind, target, id, blockers, issue links, priority, creation key and reference comments are read-only. It saves only
4644
+ changed fields with the opening revision. Sources without guarded writes,
4645
+ including Linear and GitHub, re-read the ticket immediately before an
4646
+ unguarded write and refuse a changed revision, with the no-lock race window of file checks. Unchanged or formatting-only edits
4291
4647
  write nothing. On conflict, invalid input or editor failure, the error names an
4292
4648
  absolute file path containing the edited text. Read the current ticket and
4293
4649
  reapply the intended changes before retrying; conflicts are never merged.
4294
4650
 
4295
- File and Linear revisions fingerprint kind, target, title, body, canonical label/blocker sets
4296
- and state; reverting identical content restores its fingerprint. File checks
4651
+ File and Linear revisions fingerprint kind, target, title, body, canonical label/blocker sets,
4652
+ state and urgent priority; file revisions also cover nonempty issue links. GitHub revisions
4653
+ fingerprint kind, target, title, body, canonical label/blocker sets, state and issue links,
4654
+ including the ticket's own issue; GitHub tickets carry no comments. Reverting
4655
+ identical content restores its fingerprint. File checks
4297
4656
  re-read immediately before writing, with the existing no-lock race window.
4298
4657
  Direct file edits and state-directory moves change revisions. File revisions also
4299
4658
  cover structured comments and portable attachments. Legacy file comments change
@@ -4321,7 +4680,8 @@ journals remain exclusively in the selected BuildStore.
4321
4680
  portable file tracker atomically to an absent or empty destination.
4322
4681
  `ab ticket import <dir>` preflights the entire tracker and target inventory, then
4323
4682
  creates or adopts tickets, maps blockers, deduplicates comments by exact body and
4324
- restores current attachments. Both run sessionless without forge access.
4683
+ restores current attachments. Both run sessionless without forge access. File,
4684
+ hosted and GitHub sources support import; every built-in source supports export.
4325
4685
 
4326
4686
  TicketCreateOptions includes optional `requestedId`. Unsupported sources reject
4327
4687
  it. File keeps safe ids exactly; hosted preserves canonical own-team positive
@@ -4330,6 +4690,27 @@ adoption precedes collision checks. Known kept-number clashes stop import before
4330
4690
  any target mutation. Stable migration identities and atomic mapping files make
4331
4691
  interrupted imports resumable without content-based adoption.
4332
4692
 
4693
+ A source whose ids cannot be chosen declares `allocatesIds`; GitHub does. Import
4694
+ then plans no requested ids and runs no target inventory: every ticket is created
4695
+ without `requestedId`, remapped to the id the source returns, and adopted on
4696
+ resume by its creation key inside `create`. Optional `readComments(id)` returns
4697
+ comment history for export and import only, never on a recurring path, so `get`
4698
+ may stay comment-free. Optional `importProblems` reports every destination
4699
+ refusal (unrepresentable states, colliding labels, unusable creation keys)
4700
+ before any write, together with import's own preflight problems. Issue links are
4701
+ rewritten through the mapping only for an export from GitHub, whose issue
4702
+ numbers are the exported tickets.
4703
+
4704
+ The export manifest records `roles`: each state directory's lifecycle roles under
4705
+ the exporting configuration. Import lands a role-holding state in the
4706
+ destination's state for its first role in the order done, rejected, claimed,
4707
+ ready, backlog, triage, proposal, create, and refuses when the destination
4708
+ configures no state for that role. `ab ticket import <dir> --states <a,b>`
4709
+ imports only tickets in the named states. A blocker on an excluded ticket in the
4710
+ done role is dropped as resolved; any other blocker, target or GitHub issue link
4711
+ naming an excluded ticket, and any unfinished build whose ticket or target is
4712
+ excluded, is refused before any write.
4713
+
4333
4714
  File frontmatter additionally supports optional structured `comments` (body,
4334
4715
  createdAt, optional author) and `attachments` (kind, name, layout, entries with
4335
4716
  file base64 bytes or directory paths). Legacy absent fields retain old behavior;
@@ -4339,8 +4720,9 @@ assets. Build claims and spec re-pins freeze native assets into durable snapshot
4339
4720
 
4340
4721
  State normalization and the complete operator procedure are documented in
4341
4722
  [Ticket migration](docs/ticket-migration.md). The same reference is delivered in
4342
- the installed guide. Export keeps lifecycle membership without inferring roles;
4343
- import reuses unique case-insensitive states and creates normalized missing ones.
4723
+ the installed guide. Export keeps each ticket's state and records the configured
4724
+ roles each state held; import maps role-holding states by role, reuses unique
4725
+ case-insensitive states for the rest and creates normalized missing ones.
4344
4726
 
4345
4727
 
4346
4728
  Completed `ab ticket import <dir> [--store <ref>]` records a durable repository
@@ -4453,12 +4835,41 @@ Classified rate limits retain repository cooldown and consume no publication
4453
4835
  retry allowance. Rejected pushes, lease conflicts, dirty trees and unclassified
4454
4836
  errors retain their existing behavior.
4455
4837
 
4838
+ A forge that refuses a dispatcher-side finalize PR create with a non-transient,
4839
+ non-rate-limit answer (a 4xx such as a validation error or GitHub's "No commits
4840
+ between" 422) is a question for the operator, not a provider failure. The
4841
+ kernel raises one `finalize` escalation (`policy`, `non-retryable-phase-failure`)
4842
+ whose question names the forge, the HTTP status and the forge's message
4843
+ verbatim. It records no `infrastructure.failed` and consumes no
4844
+ `maxInfrastructureAttempts`. While it is open the request is parked without
4845
+ calling the forge. A `retry` answer re-attempts the PR create once; a repeat
4846
+ refusal raises a new escalation. Rate limits and transient forge failures keep
4847
+ their existing handling.
4848
+
4456
4849
  Janitor failures are durable per-build episodes. Eligible failures retry after
4457
4850
  30, 60, 120, 240 seconds, then at the configured cap (300 seconds by default).
4458
- Skipped polls preserve the episode across restart. After
4459
- `policy.janitorFailureAttentionSeconds` (600 by default), `build.janitor-failing`
4460
- notifies default watchers and appears on the build row. A successful attempt
4461
- clears it. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
4851
+ A classified forge rate limit is repository cooldown, not a janitor failure:
4852
+ neither the first limited response nor the cooldown that follows starts an
4853
+ episode or records an attempt, so a build that only waits out cooldown never
4854
+ escalates. Skipped polls preserve the episode across restart. Both thresholds
4855
+ below are wall-clock from the episode's first failed attempt and are checked
4856
+ when an attempt fails, so cooldown inside an episode that already started still
4857
+ counts. After `policy.janitorFailureAttentionSeconds` (600 by default),
4858
+ `build.janitor-failing` notifies default watchers and appears on the build row.
4859
+ After `policy.janitorFailureEscalationSeconds` (3600 by default), the build
4860
+ raises one escalation through `build.janitor-escalated`, naming the failing
4861
+ operation, the last error, the failed attempt count and when the episode
4862
+ started. The build is then blocked and shows wherever open escalations show.
4863
+ The janitor keeps retrying on its backoff underneath; a successful attempt
4864
+ clears the attention, closes the escalation unanswered and the build continues.
4865
+ Answering it with a bare retry makes the janitor attempt on its next tick. An
4866
+ episode raises at most one escalation; a new episode after recovery can raise
4867
+ another. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
4868
+ A dispatcher that cannot execute Git for kernel node work (a missing or
4869
+ unloadable `git` for the bare clone) records no janitor failures. It records
4870
+ one durable `dispatcher.kernel-git-unavailable` repository condition, node work
4871
+ waits, and `dispatcher.kernel-git-recovered` closes the condition once a clone
4872
+ succeeds.
4462
4873
 
4463
4874
  A classified forge rate limit records repository degradation with `resetAt`.
4464
4875
  Forge work waits during cooldown; passing the deadline permits a recovery