@defrex/autobuild 1.11.1 → 1.13.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 (213) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +601 -203
  3. package/bin/ab-build-runner.ts +8 -0
  4. package/docs/answering-blocked-builds.md +32 -2
  5. package/docs/architecture.md +188 -57
  6. package/docs/assets/headline-wide.png +0 -0
  7. package/docs/cli.md +1 -1
  8. package/docs/configuration.md +120 -23
  9. package/docs/dispatcher.md +19 -8
  10. package/docs/integration-overview.md +1 -1
  11. package/docs/integration-tree.md +33 -18
  12. package/docs/merge-policy.md +7 -2
  13. package/docs/operating.md +5 -3
  14. package/docs/operator-api.md +48 -25
  15. package/docs/operator-surfaces.md +39 -3
  16. package/docs/optimization-nodes.md +10 -8
  17. package/docs/plugin-authoring.md +46 -18
  18. package/docs/remote-store-protocol.md +51 -12
  19. package/docs/remote-ticket-protocol.md +85 -38
  20. package/docs/restacking.md +48 -3
  21. package/docs/setup.md +2 -1
  22. package/docs/ticket-migration.md +2 -2
  23. package/docs/ticket-sources.md +23 -8
  24. package/docs/tickets.md +4 -4
  25. package/docs/troubleshooting.md +17 -2
  26. package/docs/verification.md +3 -1
  27. package/package.json +3 -3
  28. package/packages/core/src/cli/ambient-errors.ts +17 -0
  29. package/packages/core/src/cli/bounded-io.ts +174 -0
  30. package/packages/core/src/cli/build-control.ts +72 -6
  31. package/packages/core/src/cli/dashboard/actions.ts +4 -0
  32. package/packages/core/src/cli/dashboard/integration-row.ts +43 -19
  33. package/packages/core/src/cli/dashboard/model.ts +93 -29
  34. package/packages/core/src/cli/dashboard/poll.ts +231 -34
  35. package/packages/core/src/cli/dashboard/queue.ts +21 -10
  36. package/packages/core/src/cli/dashboard/render.ts +14 -37
  37. package/packages/core/src/cli/dashboard/row-text.ts +26 -8
  38. package/packages/core/src/cli/dashboard/tone-ansi.ts +39 -0
  39. package/packages/core/src/cli/dashboard/vocabulary.ts +165 -20
  40. package/packages/core/src/cli/dispatch-frontend.ts +2 -1
  41. package/packages/core/src/cli/dispatch-handoff.ts +41 -10
  42. package/packages/core/src/cli/dispatch-launch-contract.ts +5 -0
  43. package/packages/core/src/cli/dispatch-launcher-cadence.ts +80 -0
  44. package/packages/core/src/cli/dispatch-launcher.ts +9 -10
  45. package/packages/core/src/cli/dispatch-preflight.ts +12 -3
  46. package/packages/core/src/cli/dispatch-release-observer.ts +53 -0
  47. package/packages/core/src/cli/dispatch-runtime-cache.ts +204 -82
  48. package/packages/core/src/cli/dispatch-runtime-dependencies.ts +250 -43
  49. package/packages/core/src/cli/dispatch-tickets.ts +33 -12
  50. package/packages/core/src/cli/dispatch-upgrade-install.ts +36 -16
  51. package/packages/core/src/cli/dispatch-upgrade-source.ts +8 -2
  52. package/packages/core/src/cli/dispatch-yield-observer.ts +82 -0
  53. package/packages/core/src/cli/dispatch.ts +595 -149
  54. package/packages/core/src/cli/env.ts +2 -15
  55. package/packages/core/src/cli/help.ts +43 -28
  56. package/packages/core/src/cli/main.ts +11 -7
  57. package/packages/core/src/cli/production-store.ts +102 -0
  58. package/packages/core/src/cli/publication-settlement.ts +4 -0
  59. package/packages/core/src/cli/remote-poll.ts +22 -5
  60. package/packages/core/src/cli/repo-state.ts +2 -3
  61. package/packages/core/src/cli/repository-status.ts +44 -28
  62. package/packages/core/src/cli/sessionless-store.ts +26 -0
  63. package/packages/core/src/cli/status.ts +188 -47
  64. package/packages/core/src/cli/store-opening.ts +26 -57
  65. package/packages/core/src/cli/store-ref.ts +6 -1
  66. package/packages/core/src/cli/ticket-start.ts +3 -3
  67. package/packages/core/src/cli/ticket.ts +12 -11
  68. package/packages/core/src/cli/wait.ts +8 -28
  69. package/packages/core/src/cli/watch.ts +113 -50
  70. package/packages/core/src/config/reference-metadata.ts +7 -1
  71. package/packages/core/src/config/reference.ts +5 -2
  72. package/packages/core/src/config/schema.ts +51 -16
  73. package/packages/core/src/distribution-packaging.ts +156 -18
  74. package/packages/core/src/events/catalog-identity.ts +28 -0
  75. package/packages/core/src/events/catalog.ts +3 -9
  76. package/packages/core/src/events/compatibility.ts +2 -30
  77. package/packages/core/src/events/payloads.ts +85 -14
  78. package/packages/core/src/events/policy.ts +3 -0
  79. package/packages/core/src/events/repository.ts +15 -4
  80. package/packages/core/src/events/sessions.ts +1 -1
  81. package/packages/core/src/events/validation-error.ts +12 -0
  82. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +36 -0
  83. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/0a10010ee5cf2e47.json +577 -0
  84. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/227701361be6d1e0.json +490 -0
  85. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3064e337cc75f8d6.json +310 -0
  86. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/76e5043bae7a80ab.json +86 -0
  87. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/87a917802870bbed.json +87 -0
  88. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/9d85616e5b9e24c1.json +500 -0
  89. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a1e90a969d32a367.json +307 -0
  90. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/c7c94fbe7f63cf07.json +84 -0
  91. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/da3bc91c49211eab.json +310 -0
  92. package/packages/core/src/kernel/auto-merge-default.ts +2 -1
  93. package/packages/core/src/kernel/capacity-build.ts +21 -0
  94. package/packages/core/src/kernel/clean-restack-policy.ts +40 -0
  95. package/packages/core/src/kernel/discard-in-flight.ts +13 -0
  96. package/packages/core/src/kernel/dispatch-capacity.ts +578 -235
  97. package/packages/core/src/kernel/done-escalations.ts +269 -0
  98. package/packages/core/src/kernel/engine.ts +30 -17
  99. package/packages/core/src/kernel/integration-landing.ts +24 -4
  100. package/packages/core/src/kernel/integration-stack.ts +39 -0
  101. package/packages/core/src/kernel/janitor-failure.ts +20 -1
  102. package/packages/core/src/kernel/log-index-value.ts +3 -0
  103. package/packages/core/src/kernel/log-index.ts +41 -2
  104. package/packages/core/src/kernel/measurement.ts +24 -0
  105. package/packages/core/src/kernel/open-pr-backpressure.ts +3 -3
  106. package/packages/core/src/kernel/read-facts.ts +8 -370
  107. package/packages/core/src/kernel/reducer-registry.ts +43 -125
  108. package/packages/core/src/kernel/reducer-revisions.ts +18 -0
  109. package/packages/core/src/kernel/reducer-value-entry.ts +98 -0
  110. package/packages/core/src/kernel/reducer-value-index.ts +75 -0
  111. package/packages/core/src/kernel/reducer.ts +84 -16
  112. package/packages/core/src/kernel/reopen-state.ts +10 -0
  113. package/packages/core/src/kernel/repository-attention.ts +14 -5
  114. package/packages/core/src/kernel/repository-read-facts.ts +375 -0
  115. package/packages/core/src/kernel/ticket-starts.ts +15 -4
  116. package/packages/core/src/kernel/verify-stage-state.ts +145 -3
  117. package/packages/core/src/kernel/verify-stages.ts +46 -7
  118. package/packages/core/src/operator/attention.ts +28 -3
  119. package/packages/core/src/operator/done-escalations.ts +38 -0
  120. package/packages/core/src/operator/presentation.ts +14 -1
  121. package/packages/core/src/operator/protocol.ts +8 -5
  122. package/packages/core/src/operator/query.ts +72 -57
  123. package/packages/core/src/operator/registry.ts +19 -15
  124. package/packages/core/src/operator/ticket-start.ts +8 -7
  125. package/packages/core/src/operator/tickets.ts +28 -9
  126. package/packages/core/src/plugin-sdk/index.ts +10 -0
  127. package/packages/core/src/plugins/manifest.ts +14 -1
  128. package/packages/core/src/ports/forge/create.ts +8 -0
  129. package/packages/core/src/ports/forge/github-transport.ts +5 -1
  130. package/packages/core/src/ports/forge/github.ts +3 -0
  131. package/packages/core/src/ports/tickets/contract.ts +147 -76
  132. package/packages/core/src/ports/tickets/create.ts +47 -7
  133. package/packages/core/src/ports/tickets/fake.ts +8 -4
  134. package/packages/core/src/ports/tickets/file-codec.ts +4 -3
  135. package/packages/core/src/ports/tickets/file.ts +7 -3
  136. package/packages/core/src/ports/tickets/github.ts +1 -0
  137. package/packages/core/src/ports/tickets/grants.ts +11 -3
  138. package/packages/core/src/ports/tickets/hosted-index.ts +5 -0
  139. package/packages/core/src/ports/tickets/linear.ts +28 -9
  140. package/packages/core/src/ports/tickets/migration.ts +4 -4
  141. package/packages/core/src/ports/tickets/operations.ts +4 -2
  142. package/packages/core/src/ports/tickets/priority-labels.ts +213 -0
  143. package/packages/core/src/ports/tickets/priority.ts +127 -21
  144. package/packages/core/src/ports/tickets/remote-protocol.ts +10 -0
  145. package/packages/core/src/ports/tickets/remote.ts +104 -11
  146. package/packages/core/src/ports/tickets/revision.ts +5 -3
  147. package/packages/core/src/ports/tickets/search.ts +9 -0
  148. package/packages/core/src/ports/tickets/tree.ts +8 -6
  149. package/packages/core/src/ports/types.ts +30 -15
  150. package/packages/core/src/ports/workspace/build-execution.ts +4 -0
  151. package/packages/core/src/ports/workspace/builtin-capabilities.ts +4 -0
  152. package/packages/core/src/ports/workspace/create.ts +16 -3
  153. package/packages/core/src/ports/workspace/execution-exit-marker.ts +41 -0
  154. package/packages/core/src/ports/workspace/fake.ts +15 -3
  155. package/packages/core/src/ports/workspace/recovery-step.ts +101 -0
  156. package/packages/core/src/ports/workspace/vercel-sandbox.ts +510 -145
  157. package/packages/core/src/processes/build-execution-state.ts +4 -0
  158. package/packages/core/src/processes/build-runner.ts +14 -1
  159. package/packages/core/src/processes/dispatcher.ts +777 -288
  160. package/packages/core/src/processes/execution-no-progress.ts +1 -0
  161. package/packages/core/src/processes/execution-settlement.ts +1 -0
  162. package/packages/core/src/processes/harvest-runner.ts +12 -7
  163. package/packages/core/src/processes/infrastructure-failure-budget.ts +7 -2
  164. package/packages/core/src/processes/invocation-budget.ts +176 -0
  165. package/packages/core/src/processes/publication-loss.ts +38 -3
  166. package/packages/core/src/processes/workspace-preservation.ts +86 -15
  167. package/packages/core/src/store/contract.ts +81 -3
  168. package/packages/core/src/store/event-reads.ts +30 -1
  169. package/packages/core/src/store/local/capabilities.ts +115 -0
  170. package/packages/core/src/store/local/store.ts +86 -56
  171. package/packages/core/src/store/reduced-reads.ts +32 -1
  172. package/packages/core/src/store/reducer-value-read.ts +235 -0
  173. package/packages/core/src/store/reducer-value-shapes.json +6722 -6475
  174. package/packages/core/src/store/reducer-value-validation.ts +181 -33
  175. package/packages/core/src/store/reducer-values.ts +36 -204
  176. package/packages/core/src/store/remote/client.ts +169 -29
  177. package/packages/core/src/store/remote/compatibility.ts +113 -56
  178. package/packages/core/src/store/remote/credentials.ts +4 -1
  179. package/packages/core/src/store/remote/protocol.ts +3 -0
  180. package/packages/core/src/store/remote/released-clients.json +22 -0
  181. package/packages/core/src/store/remote/released-reducer-values/1.12.0.json +35806 -0
  182. package/packages/core/src/store/remote/released-reducer-values/1.13.0.json +35966 -0
  183. package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
  184. package/packages/core/src/store/remote/released-value-policy.ts +144 -0
  185. package/packages/core/src/store/remote/retry.ts +406 -0
  186. package/packages/core/src/store/rollup-lease.ts +41 -0
  187. package/packages/core/src/store/rollups.ts +7 -38
  188. package/packages/core/src/store/snapshots.ts +1 -1
  189. package/packages/core/src/testing/dispatch-read-budget.ts +409 -14
  190. package/packages/core/src/testing/import-graph.ts +78 -0
  191. package/packages/core/src/testing/index.ts +2 -0
  192. package/packages/core/src/testing/invocation-budget.ts +42 -0
  193. package/packages/core/src/testing/reduced-read-budget.ts +602 -40
  194. package/packages/core/src/testing/released-value-coverage.ts +423 -0
  195. package/packages/core/src/testing/slot-agreement.ts +52 -0
  196. package/packages/core/src/web/assets/app.js +5 -5
  197. package/packages/core/src/web/overview-source.ts +19 -6
  198. package/skills/guide/SKILL.md +245 -103
  199. package/skills/guide/references/integration-tree.md +33 -18
  200. package/skills/guide/references/merge-policy.md +7 -2
  201. package/skills/guide/references/operator-api.md +48 -25
  202. package/skills/guide/references/optimization-nodes.md +10 -8
  203. package/skills/guide/references/plugin-authoring.md +46 -18
  204. package/skills/guide/references/remote-store-protocol.md +51 -12
  205. package/skills/guide/references/remote-ticket-protocol.md +85 -38
  206. package/skills/guide/references/restacking.md +48 -3
  207. package/skills/guide/references/setup.md +2 -1
  208. package/skills/guide/references/ticket-migration.md +2 -2
  209. package/skills/operate/SKILL.md +114 -65
  210. package/skills/plan/SKILL.md +4 -3
  211. package/skills/spec/SKILL.md +9 -5
  212. package/skills/tickets/SKILL.md +25 -17
  213. package/templates/hosted-service/package.json +2 -2
@@ -184,7 +184,7 @@ The operation names and `input` values are:
184
184
  | `list-ready` | `{labels?: string[], state?: string}` | `TicketListing` |
185
185
  | `list-targeting` | `{nodeId: string}` | `TicketListing` of every state |
186
186
  | `list-page` | `{criteria: {labels?, state?}, page: {limit, offset?, order?}}` | `TicketPageListing` (`{tickets, diagnostics, total}`) |
187
- | `search` | `{text, state?, labels?, limit, cursor?}` | `{tickets: {id, title, state?, labels, kind, target?}[], cursor?, diagnostics}` |
187
+ | `search` | `{text, state?, labels?, limit, cursor?}` | `{tickets: {id, title, state?, labels, kind, target?, priority?}[], cursor?, diagnostics}` |
188
188
  | `get` | `{id}` | `Ticket \| null` |
189
189
  | `claim` | `{id}` | `{claimed: boolean}` |
190
190
  | `comment` | `{id, body}` | `{ok: true}` |
@@ -225,11 +225,35 @@ remain unchanged. These rules apply only to hosted tickets, not file or Linear i
225
225
  ## Errors and conformance
226
226
 
227
227
  Errors are JSON `{ "error": string, "kind": "validation" | "not-found" |
228
- "auth" | "conflict" | "internal" }`. Authentication runs before body parsing
229
- or backend construction. Responses never include exception causes, stacks,
230
- environment values, or credentials. Client 401/403 responses become
228
+ "auth" | "conflict" | "internal" | "unavailable" }`. Authentication runs before
229
+ body parsing or backend construction. Responses never include exception causes,
230
+ stacks, environment values, or credentials. Client 401/403 responses become
231
231
  `AuthError`; other backend messages remain actionable.
232
232
 
233
+ A hosted service answers `503` with kind `unavailable` and a `Retry-After`
234
+ header in seconds when its database is saturated (no free connection slots, or
235
+ a pool acquisition timed out) or when the service is shutting down. The
236
+ response carries no backend detail.
237
+
238
+ The client retries transient failures exactly as the store client does: a
239
+ `429`, `502`, `503`, `504`, a `500` with `kind: "internal"` or no protocol body,
240
+ or a transport failure, at most three attempts within one 10 s bound.
241
+
242
+ - **Retried on any transient failure:** `policy`, `list-ready`,
243
+ `list-targeting`, `list-page`, `search`, `states`, `state-counts`, `get`,
244
+ `dependency-states`, `transition`, `update`, `add-blocker`, `remove-blocker`,
245
+ `mutate-if-revision`, and `create` with an idempotency key. Each is a read or
246
+ a set-or-replace write; a repeated revision check fails as a typed conflict.
247
+ - **Never retried after a response:** `claim`, `comment`, `add-state` and an
248
+ unkeyed `create`. They retry only a `429` or a transport failure that
249
+ preceded delivery.
250
+ - **Exhaustion** surfaces as `RemoteUnavailableError` with the service's
251
+ message; `AuthError` and the typed protocol errors keep precedence.
252
+
253
+ A dispatcher publishes `policy` and settles `list-targeting` at its first tick
254
+ boundary rather than while it starts, so a transient failure there fails only
255
+ that tick.
256
+
233
257
  The shared `TicketSource` contract is normative for protocol implementations.
234
258
  Project partitions must be isolated. The direct Linear client retains its
235
259
  separate opt-in GraphQL contract; this protocol does not proxy Linear.
@@ -307,7 +331,7 @@ snapshot of fields, blockers and revision.
307
331
  `POST /tickets/mutate-if-revision` accepts the usual authenticated context and
308
332
  `input: { id, expectedRevision, mutation }`. Mutation is one of
309
333
  `{ kind: "update", patch: { title?, body?, labels?, kind?, target?,
310
- priority?: "urgent" | "normal" } }`,
334
+ priority?: "urgent" | "high" | "normal" | "low" } }`,
311
335
  `{ kind: "transition", state }`, or
312
336
  `{ kind: "blockers", operation: "block" | "unblock", ids: string[] }`.
313
337
  Unknown keys and empty patches are refused. Success returns `{ ok: true }`.
@@ -387,8 +411,12 @@ response without the header, or a `404` or `400` refusal of `list-targeting`
387
411
  without it, means the service predates the operation. Against such a service
388
412
  the client never declares it, and integration observation uses the exhaustive
389
413
  listing by that explicit decision. An inconclusive probe (a network failure or
390
- an unmarked gateway error) fails source construction. A targeted read the
391
- service later refuses fails closed, with no fallback within the pass.
414
+ an unmarked gateway error) fails preparation. An ordinary consumer prepares
415
+ while constructing the source, so construction fails. A dispatcher prepares at
416
+ its first tick boundary: exhausted transient unavailability fails that tick and
417
+ preparation runs again at the next one, while any other failure stops the run.
418
+ A targeted read the service later refuses fails closed, with no fallback within
419
+ the pass.
392
420
 
393
421
  ## Issue links
394
422
 
@@ -425,40 +453,57 @@ not establish continuity for in-flight builds; see the migration procedure.
425
453
 
426
454
  ## Priority
427
455
 
428
- Hosted tickets store `priority`, either `"urgent"` or `"normal"`. Create,
429
- update and guarded update accept it as an optional field. A create that omits it
430
- files a normal ticket, and an update that omits it never changes it. Tickets that
431
- existed before the field read as normal. A priority change increments the
432
- revision, and rewriting the same value is a no-op.
433
-
434
- Ticket responses include `priority` on every ticket, `normal` included, only with
435
- `x-autobuild-ticket-priority: 1`, independently of the other capabilities and of
436
- the client version. Without it, priority is projected away for historical strict
437
- decoders, whose writes never name it and so never clear it. Every `/tickets/*`
438
- response, including errors, carries `x-autobuild-ticket-priority: 1`.
439
-
440
- `list-ready` returns urgent tickets first, then normal ones, each class in filing
441
- order, for every client. Ordering happens within the existing listing; it adds no
442
- per-ticket reads. `list-ready` stays exhaustive; paged reads use `list-page`.
443
-
444
- A service whose backing source cannot store priority refuses a write naming
445
- `urgent` with `409 { "kind": "conflict", "code": "priority-unsupported" }` before
446
- anything is written. A service predating priority refuses the unknown field with a
447
- `400` validation error and no capability header. Clients report both as
448
- `TicketPriorityUnsupported`. Current clients omit `normal` on create, so a plain
449
- create still works against such a service.
456
+ Hosted tickets store `priority`: `"urgent"`, `"high"`, `"normal"` or `"low"`.
457
+ Create, update and guarded update accept it as an optional field. A create that
458
+ omits it files a normal ticket, and an update that omits it never changes it.
459
+ Tickets that existed before the field read as normal. A priority change
460
+ increments the revision, and rewriting the same value is a no-op.
461
+
462
+ Ticket responses project priority by the capability headers the client sends,
463
+ independently of the other capabilities and of the client version:
464
+
465
+ | Client sends | Response `priority` |
466
+ |---|---|
467
+ | `x-autobuild-ticket-priority-levels: 1` | the stored level, on every ticket, `normal` included |
468
+ | only `x-autobuild-ticket-priority: 1` | `urgent` stays `urgent`; `high`, `low` and `normal` read as `normal` |
469
+ | neither | absent, for historical strict decoders, whose writes never name it and so never clear it |
470
+
471
+ Search hits carry an optional `priority`, projected the same way and stripped
472
+ for clients without the levels header. Every `/tickets/*` response, including
473
+ errors, carries both `x-autobuild-ticket-priority: 1` and
474
+ `x-autobuild-ticket-priority-levels: 1`.
475
+
476
+ `list-ready` returns urgent tickets first, then high, then normal, then low,
477
+ each level in filing order, for every client. Ordering happens within the
478
+ existing listing; it adds no per-ticket reads. `list-ready` stays exhaustive;
479
+ paged reads use `list-page`.
480
+
481
+ Refusals, all before anything is written:
482
+
483
+ - A service whose backing source cannot store the level answers
484
+ `409 { "kind": "conflict", "code": "priority-unsupported" }`.
485
+ - A service predating priority refuses the unknown field with a `400`
486
+ validation error and no capability header.
487
+ - A service that stores only `urgent` and `normal` refuses `high` or `low`
488
+ with a `400` validation error and no `x-autobuild-ticket-priority-levels`
489
+ header. The client sends the request; the older service rejects it before
490
+ persisting anything.
491
+
492
+ Clients report each as `TicketPriorityUnsupported` naming the `hosted` source.
493
+ Current clients omit `normal` on create, so a plain create still works against
494
+ an older service.
450
495
 
451
496
  ## Paged listing
452
497
 
453
498
  `list-page` answers one window of the tickets matching `criteria`, from the
454
499
  backing source's native paging. `limit` and `offset` are nonnegative integers;
455
- `offset` defaults to 0. `order` is `oldest` (the default), which is dispatch
456
- order: urgent first, then normal, each in filing order. `newest` is newest filed
457
- first, regardless of urgency. Offset and limit apply after ordering, so
500
+ `offset` defaults to 0. `order` is `oldest` (the default), which is priority
501
+ order: urgent, then high, then normal, then low, each in filing order. `newest`
502
+ is newest filed first, regardless of priority. Offset and limit apply after ordering, so
458
503
  consecutive windows traverse the listing with no omissions or duplicates.
459
504
  `total` counts every match before slicing, also for a zero limit or an offset
460
505
  past the end. The service returns the page in the order the source answered;
461
- it does not re-sort it urgent-first. Cost follows the window, not the project's
506
+ it does not re-sort it by priority. Cost follows the window, not the project's
462
507
  ticket count.
463
508
 
464
509
  A backing source without native paging answers `409` with
@@ -469,8 +514,9 @@ ticket grants and harvest delegations receive `403`.
469
514
  Every `/tickets/*` response, including errors, carries
470
515
  `x-autobuild-ticket-paging: 1`. A current client declares `listPage` only after
471
516
  a response from the service has carried that header. It settles the decision on
472
- the response that already finishes source construction (the policy sync or the
473
- targeted-listing probe), with no extra probe. An ok response without the header
517
+ the response that already finishes preparation (the policy sync or the
518
+ targeted-listing probe), with no extra probe, whether preparation runs during
519
+ ordinary source construction or at a dispatcher's first tick. An ok response without the header
474
520
  means the service predates the operation. Against such a service the client
475
521
  never declares `listPage`, and paged operator listings read `list-ready` and
476
522
  slice it, as for any source without native paging. A `list-page` request that the
@@ -498,8 +544,9 @@ for duplicate checks before filing:
498
544
  stable across pages: the PostgreSQL backend answers newest ticket number
499
545
  first. `cursor` is opaque; pass the previous page's `cursor` with the same
500
546
  text and filters. It is absent on the last page.
501
- - **Hits.** `id`, `title`, `state`, `labels`, `kind` and `target` come from the
502
- search read itself. Bodies are never returned, and there is no read per hit.
547
+ - **Hits.** `id`, `title`, `state`, `labels`, `kind`, `target` and `priority`
548
+ come from the search read itself; `priority` follows the
549
+ [priority projection](#priority). Bodies are never returned, and there is no read per hit.
503
550
  - **Refusals.** A backing source without search answers `409` with
504
551
  `code: "search-unsupported"`. A malformed or foreign cursor answers `400` with
505
552
  `code: "search-cursor-invalid"` and the `cursor`. Clients report them as
@@ -513,7 +560,7 @@ for duplicate checks before filing:
513
560
  Every `/tickets/*` response, including errors, carries
514
561
  `x-autobuild-ticket-search: 1`. A current client declares `search` only after a
515
562
  response from the service has carried that header, settled on the response that
516
- already finishes source construction, with no extra probe. Against a service
563
+ already finishes preparation, with no extra probe. Against a service
517
564
  predating the operation (an ok response without the header) the client never
518
565
  declares `search`, so callers refuse with `TicketSearchUnsupported` before any
519
566
  request and nothing is listed. A `search` request that the service later refuses
@@ -89,7 +89,9 @@ waiting leaves restack when the target moves. Node-target finalize contributions
89
89
  are canonicalized before guarded merge even when the target SHA is unchanged.
90
90
  Clean replay starts no agent. A clean awaiting-merge leaf rewrite preserves completed
91
91
  verification when build-owned config is unchanged, even when replay replaces
92
- the pin commit's ancestry. Reports retain their actual cycle base/head.
92
+ the pin commit's ancestry, unless a
93
+ [clean-restack policy](#clean-restack-re-verification) opts steps in for a
94
+ root-targeting leaf. Reports retain their actual cycle base/head.
93
95
  Changed config still starts a fresh verification cycle while waiting. Before
94
96
  running further verification steps, cycles also require known pin ancestry;
95
97
  a future cycle captures fresh config from its checkout. Configuration
@@ -195,7 +197,9 @@ displaced heads and the temporary change, best effort, per commit:
195
197
  before the guarded update landed abandons the reservation, and the next node
196
198
  transaction reserves again from the published branches.
197
199
  - Workspace preservation is strict: archive ref, else a `history-objects-<sha>`
198
- store copy over the preservation base, else release is refused. Store-kept
200
+ store copy over the preservation base, else release is refused. Abort cleanup
201
+ is the one exception: when preservation fails it records
202
+ `workspace.commits-lost` and releases. Store-kept
199
203
  heads go on decisive `workspace.commits-retained`, and replacement
200
204
  provisioning restores them on any host.
201
205
 
@@ -230,6 +234,45 @@ interpretation and supply a promoted contribution base for later replay.
230
234
 
231
235
  Replay retention (`replay-objects-<sha>`) and leaf history retention (`history-objects-<sha>`) store thin Git packs in bounded binary chunks, with a fixed-size completion manifest written only after every chunk is acknowledged. Digest-keyed chunks make interrupted writes retryable; incomplete uploads are never restored. Recovery validates all chunk sizes and the pack digest before installation, and requires the base objects (restoring node prefixes in order). Existing single-artifact base64 packs remain readable. Retained replay and history artifacts are read only when the requested commit is missing locally, never by idle polling.
232
236
 
237
+ ## Clean-restack re-verification
238
+
239
+ A cleanly restacked waiting leaf lands without re-running verification by
240
+ default. To catch semantic drift a clean replay cannot see, such as a new lint
241
+ rule, a tightened type or a changed shared export on the target, opt steps in:
242
+
243
+ ```toml
244
+ [verify.lint]
245
+ kind = "check"
246
+ command = "lint"
247
+ afterCleanRestack = true
248
+ ```
249
+
250
+ | Setting | Default | Effect |
251
+ |---|---|---|
252
+ | `[verify].afterCleanRestack` | `false` (omitted) | Repository default for every step. |
253
+ | `[verify.<step>].afterCleanRestack` | inherited | Overrides the default in either direction. |
254
+
255
+ - **Scope.** Only a root-targeting leaf's clean awaiting-merge restack,
256
+ including a resolved `[[generated]]` regeneration. A leaf targeting an
257
+ integration node relies on the node's own verification before root.
258
+ - **Frozen policy.** When at least one step is enabled, the runner records the
259
+ resolved ordered policy as `cleanRestackPolicy` on
260
+ `restack.publish-intended`, `restack.rewritten` and `restack.completed`.
261
+ Recovery after a crash keeps it, even if configuration changed.
262
+ - **Fresh cycle.** That completion starts a verify cycle at a new attempt on
263
+ the restacked base and head. Opted-in steps run under the usual plan and
264
+ `paths` rules; the others record `skipped` with
265
+ `skipCause = "clean-restack-policy"`. No further restack runs.
266
+ - **Landing.** The leaf does not land until the cycle is satisfied. A failure
267
+ routes to implement, code review and ordinary verification, and counts
268
+ toward `maxVerifyAttempts`. On success, landing consent survives as for any
269
+ clean restack.
270
+ - **Cost.** Every target move under a waiting leaf re-runs the opted-in steps.
271
+ Prefer cheap deterministic checks; an agent step re-runs only when opted in.
272
+
273
+ Omitted or all-false settings record nothing, so existing builds behave
274
+ exactly as before.
275
+
233
276
  ## Node contributions and recovery
234
277
 
235
278
  Node replay enumerates oldest-first first-parent contributions above the last
@@ -271,7 +314,9 @@ committed unchanged.
271
314
  - **Leaf restack.** `restack.regenerated` records the files, the commands and
272
315
  the outcome. A `resolved` replay's head is retained before the fact is
273
316
  written, and then publishes like a clean restack, so verification follows the
274
- clean-restack rules; the configured verify steps still check the result.
317
+ clean-restack rules, including any
318
+ [clean-restack policy](#clean-restack-re-verification) while waiting to merge;
319
+ the configured verify steps still check the result.
275
320
  The regeneration counts as conflict resolution for merge consent: consent
276
321
  given under a `paths` or `within` rule is revoked, with
277
322
  `landing.consent-revoked`, when the regenerated files match it, even though
package/docs/setup.md CHANGED
@@ -504,7 +504,8 @@ Archive refs are a recommendation (WARN or UNKNOWN, never FAIL):
504
504
  build and proceed.
505
505
  - **Workspace preservation** keeps unpublished workspace commits as BuildStore
506
506
  copies where refused, and refuses to release the workspace only when the store
507
- copy fails too.
507
+ copy fails too. Abort cleanup is the exception: it records
508
+ `workspace.commits-lost` and releases.
508
509
 
509
510
  Require **linear history** on protected root and node target branches to prevent
510
511
  merge commits from GitHub's update-branch action. On the configured root, enable
@@ -93,7 +93,7 @@ timestamps remain in the export; imported comments use the target's metadata.
93
93
 
94
94
  Portable records use TOML frontmatter between `+++` fences and an unchanged
95
95
  Markdown body. Alongside `id`, `title`, `labels`, `blockedBy` and `idempotencyKey`,
96
- optional `issueLinks` contain `issue` and `intent` (`closes` or `refs`), optional `priority` is `"urgent"` (absent means normal), optional `comments` contain `body`, `createdAt` and optional `author`. Optional
96
+ optional `issueLinks` contain `issue` and `intent` (`closes` or `refs`), optional `priority` is `"urgent"`, `"high"` or `"low"` (absent means normal), optional `comments` contain `body`, `createdAt` and optional `author`. Optional
97
97
  `attachments` contain `kind`, `name`, `layout` (`file` or `tree`) and `entries`:
98
98
  `{ type = "dir", path = "empty" }` or
99
99
  `{ type = "file", path = "image.png", base64 = "…" }`. Common asset limits and
@@ -109,7 +109,7 @@ no continuous sync, assignee migration, state history or build-history migration
109
109
 
110
110
  Integration-tree `kind` and `target` are preserved in portable frontmatter.
111
111
  Import validates the complete target graph before changing the destination and
112
- refuses a destination that cannot preserve metadata. Issue links and urgent
112
+ refuses a destination that cannot preserve metadata. Issue links and
113
113
  priority are preserved the same way, and a destination that cannot store them is refused before any write. It creates or adopts every
114
114
  identity, establishes node kinds, then applies targets using the durable id map,
115
115
  just like blockers. Input order does not matter. Resuming also restores edges on
@@ -92,7 +92,7 @@ Replace `ENG` and the case-sensitive workflow names with your team's.
92
92
  - **Admission.** `teamKey` selects the team; `readyState`, every `readyLabels` entry and optional `readyAssignee` filter it.
93
93
  - **Labels.** `readyLabels` defaults to `["autobuild"]`; `[]` removes the gate.
94
94
  - **No `project` key.** Scope the queue through team access, states and labels.
95
- - **Priority.** Linear's Urgent priority reads as `urgent`; every other priority, including none, reads as `normal`. `--priority urgent` sets Urgent. `--priority normal` clears Urgent to No priority and leaves High, Medium or Low untouched.
95
+ - **Priority.** Urgent, High and Low read as `urgent`, `high` and `low`; Medium and No priority read as `normal`. `--priority urgent|high|low` sets the matching Linear priority. `--priority normal` sets No priority on an Urgent, High or Low issue and leaves Medium untouched. The revision covers priority.
96
96
  - **Rate limits** are shared with your other API callers.
97
97
  - **Backlog and rejected.** Neither role has a default, and neither may share a state with triage. Here `Backlog` is the triage state, so a deferred-work state needs its own name, such as `backlogState = "Icebox"`. Linear counts `Canceled` as complete; mapped to `rejectedState`, it no longer resolves blockers.
98
98
 
@@ -156,6 +156,7 @@ rejectedState = "rejected"
156
156
  - **Closing reasons.** Closed as completed, or closed before GitHub recorded reasons, is done. Closed as not planned or duplicate is in the `rejectedState` state; without `rejectedState` it reads as a fixed `not-planned` state that is never ready, never resolves a blocker and can't be moved into. Moving to done or rejected closes the issue with that reason (an issue already closed with the other reason is reopened and closed again, because GitHub changes a reason only with the state); moving to any other state opens it with exactly that state's label.
157
157
  - **Reopen goes to triage.** If a state label survived the close, the adapter strips that stale label the first time it reads the reopened issue. It tells stale from fresh by the issue's last 100 label and reopen events; an issue whose deciding event is older than that is left out of listings with a diagnostic until its state label is removed and re-added.
158
158
  - **Labels.** `readyLabels` defaults to `["autobuild"]`; `[]` removes the gate. Missing labels, [creation labels](#creation-labels) included, are created on demand. State and link labels are never part of a ticket's labels, and a write that names one is refused. The `autobuild:proposal` and `autobuild:aborted` labels that harvest and abort apply are ordinary labels, so `proposal` and `aborted` can't be states.
159
+ - **Priority** is one label: `priority:urgent`, `priority:high` or `priority:low`, none for normal, matched case-insensitively. With several, the highest wins and the next `--priority` write leaves one. Priority labels show as the ticket's `priority`, never in its labels; label writes, filters and `readyLabels`/`createLabels` entries naming one are refused. See Optional priority below.
159
160
  - **Assignee.** `readyAssignee = "me"` keeps only issues assigned to the login that owns the GitHub credential; a username, including an Enterprise Managed User login such as `mona_acme`, names a specific user. The ready read itself is narrowed by assignee, an unassigned issue is never ready, and any one of several assignees matches. While `readyAssignee` is set, each scan reports open ready issues that carry every `readyLabels` entry but have no assignee in the ticket diagnostics, which `ab repository status` and the dashboards show, naming the ten lowest-numbered and counting the rest. The report never claims or assigns them; assigning one makes it claimable. `"me"` costs one `GET /user` per dispatcher start, never during a tick, so a reload that enables it needs no restart unless startup couldn't resolve the credential's owner.
160
161
  - **Assignees.** Tickets carry the issue's assignees as an `assignees` array of usernames in JSON reads, whether they were set on GitHub or through `ab`, and `ab ticket show` prints them. They aren't part of the ticket's `revision`. `--assignees` on `ab ticket create` and `ab ticket update`, and the `assignees` field of the operator `tickets.create` and `tickets.update` tools, set them: each entry is a username or `me`, at most ten entries counted before duplicates collapse, and an update replaces the whole set. `createAssignee = "me"` (or a username) assigns every ticket Autobuild creates, through `ab ticket create`, operator `tickets.create` and harvest proposals, unless the create names its own assignees; a harvest proposal goes to the owner of the filing dispatcher's credential. That pairs with `readyAssignee = "me"`, so each person's dispatcher picks up the tickets they file. A create or update fails, naming the cause and writing nothing, when `me` has no user behind the credential (a GitHub App installation token has none) or a user can't be assigned issues in the repository. GitHub silently drops assignees a token without push access sets, so a write whose assignees don't come back fails, naming the issue and saying it is unassigned; a retried harvest create adopts that issue, assigns it and adds any requested labels it is missing. A write naming assignees costs one check per user per process, `me` reuses the `readyAssignee` `GET /user`, and reads cost nothing extra.
161
162
  - **Blockers** are native issue dependencies ("blocked by"), visible on both issues, including ones added on GitHub. A blocker resolves when its issue is done. One in another repository never resolves and is named in the dependency diagnostics. GitHub's dependency summary lags the edges by seconds, so reads that can lead to a claim (`ab ticket show`, the ready scan, dependency checks) read the dependency list instead; broad listings (`ab ticket list` outside the ready state) and export trust the summary and can miss a blocker recorded seconds earlier. Claim re-reads the dependency list fresh: a ticket whose blocker was added after the scan's dependency check stays ready and counts as dependency-blocked until a later scan. `ab ticket create --blocked-by` into the ready state opens the issue in triage, records every blocker, then moves it to ready; a partial failure says so and leaves it in triage. An issue transferred to another repository is no longer a ticket here: its old number reads as missing, so it is never written and never resolves a blocker.
@@ -192,7 +193,20 @@ The `file`, `hosted` and `github` sources store [forge issue links](tickets.md#g
192
193
 
193
194
  ### Optional priority
194
195
 
195
- A ticket is `urgent` or `normal` (the default); the dispatcher claims urgent ready work first, ahead of normal builds waiting for a slot. The `file` and `hosted` sources store priority: as `priority = "urgent"` frontmatter with no key for normal (`file`), or transactional project data covered by the ticket revision (`hosted`, whose ready listing returns urgent tickets first). `linear` uses its native Urgent priority, described in its section above.
196
+ A ticket is `urgent`, `high`, `normal` (the default) or `low`. The dispatcher claims ready work by level, urgent first and low last, each level in the source's order and ahead of lower-level builds waiting for a slot; each build takes its ticket's level.
197
+
198
+ | Source | Storage | Ready order |
199
+ | --- | --- | --- |
200
+ | `file` | `priority = "<level>"` frontmatter; no key for normal | filing order |
201
+ | `hosted` | transactional project data | urgent, high, normal, low, each in filing order |
202
+ | `linear` | native priority, described in its section above | Linear's order |
203
+ | `github`, plugins without `priority` | one `priority:urgent`, `priority:high` or `priority:low` label; none for normal | the source's order |
204
+
205
+ Native sources cover priority in their revisions. On the label fallback, the revision changes with priority because it covers labels, and:
206
+
207
+ - **Reads.** Priority labels match case-insensitively, hand-added ones included; with several, the highest wins. They are reported as the ticket's `priority`, never in its `labels`, and cost no extra request.
208
+ - **Writes.** A priority write leaves exactly one priority label (none for normal) and touches no other label. A labels replacement neither adds nor removes priority labels.
209
+ - **Refusals.** A label write, a listing or search filter, or a `readyLabels` or `createLabels` entry naming a priority label is refused (configuration at startup); set priority with `--priority`. Priority labels therefore never satisfy or block `readyLabels`.
196
210
 
197
211
  ### Optional ticket tree
198
212
 
@@ -229,6 +243,8 @@ Declare `assignees` only if you store, return and verify ticket assignees; witho
229
243
 
230
244
  Labels need no capability: every source stores them. Callers union `[tickets].createLabels` into the draft's `labels` before `create`, so a draft's labels are always exact.
231
245
 
246
+ Declare `priority` only if you store all four levels natively; without it, Autobuild stores priority as labels for you. See the [optional priority capability](plugin-authoring.md#optional-priority-capability).
247
+
232
248
  Declare tree support only if you keep the [optional tree contract](plugin-authoring.md#optional-ticket-tree-capability) on the same port and harness: exhaustive pagination, canonical targets, revision coverage and atomic rejection.
233
249
 
234
250
  Native paging is an optional API 1.9 ticket-source capability:
@@ -236,18 +252,17 @@ Native paging is an optional API 1.9 ticket-source capability:
236
252
  The SDK exports these types; the result is `TicketListing & { total: number }`.
237
253
  Criteria retain state, labels (AND), and assignee semantics. The page has a
238
254
  nonnegative integer `limit`, optional nonnegative integer `offset` (default 0),
239
- and optional `order: 'oldest' | 'newest'` (default oldest). Oldest is the
240
- source's dispatch order: with `priority`, urgent tickets first, then normal
241
- ones, each in listing order. Newest is newest filed first: creation time
242
- descending, regardless of urgency, with a stable tie-break. It is not the
243
- reverse of dispatch order. Offset and limit apply after ordering. Total counts all matches, even
255
+ and optional `order: 'oldest' | 'newest'` (default oldest). Oldest is
256
+ priority order: urgent, high, normal, then low tickets, each in listing order.
257
+ Newest is newest filed first: creation time descending, regardless of
258
+ priority, with a stable tie-break. It is not the reverse of priority order. Offset and limit apply after ordering. Total counts all matches, even
244
259
  with limit zero or an offset past the end. Records, diagnostics and errors
245
260
  match the exhaustive listing. The shared `describeTicketSourceContract` suite
246
261
  automatically compares declared native paging with full-read windows.
247
262
 
248
263
  Only paged operator listings select this capability. Sources without it retain
249
264
  the full-read fallback, which orders the listing before offset and limit: by
250
- default a stable urgent-first partition (urgent, then normal, each in source
265
+ default a stable priority sort (urgent, high, normal, then low, each in source
251
266
  order), or for newest the reversed listing, which is newest filed first for
252
267
  sources that list in filing order (file, GitHub, Linear). Native errors
253
268
  propagate. Unpaged operator listings, CLI ticket lists and dispatcher ready
package/docs/tickets.md CHANGED
@@ -55,7 +55,7 @@ A build freezes the links when it claims the ticket. On GitHub, a leaf build tha
55
55
  bun ab ticket create "Close stale sandboxes" --body spec.md --issues 824,820:refs
56
56
  ```
57
57
 
58
- When a ticket must go next, such as a fix for a stuck build, mark it urgent instead of moving other tickets out of ready: `--priority urgent` on `ab ticket create` or `ab ticket update`. `--priority normal` removes it. The `file`, `hosted` and `linear` sources store priority. See [Ticket sources](ticket-sources.md#shipped-adapters).
58
+ A ticket's priority is `urgent`, `high`, `normal` (the default) or `low`; set it with `--priority` on `ab ticket create` or `ab ticket update`. When a ticket must go next, such as a fix for a stuck build, mark it urgent instead of moving other tickets out of ready. An update without `--priority` leaves it alone, and any other value is refused before anything is written. Every source stores priority: `file`, `hosted` and `linear` natively, `github` and plugins without native support as one `priority:<level>` label. See [Ticket sources](ticket-sources.md#shipped-adapters).
59
59
 
60
60
  ```sh
61
61
  bun ab ticket update AUT-12 --priority urgent
@@ -90,10 +90,10 @@ Moving a ticket back to triage, backlog or ready restores ordinary behavior. "Bu
90
90
  Ordinary intake claims only tickets in the ready state with the required labels and any source-specific listing filter, such as a ready assignee. A ticket named by `ab start` (`tickets.start`) must still be in the ready state, but those listing labels and the ready assignee are not applied to it. A ready ticket still waits on:
91
91
 
92
92
  - **Blockers.** Unresolved prerequisite tickets keep it queued; they don't create a blocked build. With nodes, prerequisites with builds must be present at the sampled destination; see [integration and blocker presence](integration-overview.md).
93
- - **Destination and capacity.** Its target must accept new work, and a capacity slot must be free and not reserved for an integration node awaiting verification, a finished build waiting to re-verify or reconcile, or a build resuming after its ticket wait ends; each of those is admitted before normal claims (see [slot admission order](dispatcher.md#slot-admission-order)). A pending `ab start` request reserves a slot ahead of the claims and parked work its tier outranks.
94
- - **Open-PR backpressure.** When the repository configures `maxOpenPrs` and that many root build PRs are open and unmerged, the dispatcher pauses ordinary ready-queue normal-priority claims, even with a free slot, until the count drains to `resumeOpenPrs` (below `maxOpenPrs` when the two are equal). Urgent tickets bypass this gate, and so does every `ab start` tier, which still respects capacity and repository pause. See [`[policy]`](configuration.md#policy) for the thresholds.
93
+ - **Destination and capacity.** Its target must accept new work, and a capacity slot must be free and not reserved for an integration node awaiting verification, a finished build waiting to re-verify or reconcile, or a build resuming after an answered escalation, a resumed pause or an ended ticket wait; each of those is admitted before ticket claims at its level (see [slot admission order](dispatcher.md#slot-admission-order)). A pending `ab start` request reserves a slot ahead of the claims and parked work its tier outranks.
94
+ - **Open-PR backpressure.** When the repository configures `maxOpenPrs` and that many root build PRs are open and unmerged, the dispatcher pauses ordinary ready-queue claims of `high`, `normal` and `low` tickets, even with a free slot, until the count drains to `resumeOpenPrs` (below `maxOpenPrs` when the two are equal). Urgent tickets bypass this gate, and so does every `ab start` tier, which still respects capacity and repository pause. See [`[policy]`](configuration.md#policy) for the thresholds.
95
95
 
96
- When a slot is free, the dispatcher takes urgent ready tickets first, then normal ones, each in the source's order. Urgent tickets also go ahead of normal builds waiting to re-verify, reconcile or resume, though not ahead of urgent ones. An ordinary claimed ticket's priority becomes its build's priority. An [optimization node's attempts](optimization-nodes.md#attempts) claim at the node's current priority instead: a later `ab priority` on the node affects attempts claimed afterwards, while an already claimed attempt keeps its build priority. To expedite a build that already exists, run `ab priority <slug> urgent`. Urgent tickets also bypass open-PR backpressure: a blocked urgent ticket waits like any other while normal work proceeds, and an urgent ticket never stops or pauses a running build. The web dashboard's Queue tab lists tickets in the same order and marks urgent ones `URGENT`; the mark shows priority, not that the ticket will dispatch next.
96
+ When a slot is free, the dispatcher takes ready tickets by level, `urgent`, `high`, `normal`, then `low`, each level in the source's order. A level's tickets go ahead of lower-level builds waiting to re-verify, reconcile or resume, though not ahead of waiting builds at their own level or above. Each build takes its ticket's level. An [optimization node's attempts](optimization-nodes.md#attempts) claim at the node's current level instead: a later `ab priority` on the node affects attempts claimed afterwards, while an already claimed attempt keeps its level. To expedite or defer a build that already exists, run `ab priority <slug> urgent|high|normal|low`. Only urgent tickets bypass open-PR backpressure. A blocked ticket waits like any other while lower-level work proceeds, and no level stops or pauses a running build. The web dashboard's Queue tab lists ready tickets in dispatch order and marks them `URGENT`, `HIGH` or `LOW` (normal is unmarked); the mark shows the level, not that the ticket will dispatch next.
97
97
 
98
98
  Before ready filing, the agent checks `ab repository status --json`. With live
99
99
  `operator.registrations`, it records intent, rejected alternatives and out-of-scope
@@ -2,7 +2,7 @@
2
2
  title: Troubleshooting
3
3
  group: reference
4
4
  order: 18
5
- description: "Diagnose configuration, idle dispatch, authentication, stalled builds, and project selection."
5
+ description: "Diagnose configuration, idle dispatch, authentication, stalled builds, sandbox recovery steps, and project selection."
6
6
  ---
7
7
 
8
8
  # Troubleshooting
@@ -58,7 +58,7 @@ bun ab harvest status
58
58
  - **Blockers and destination:** blockers done, target node open, required changes in the destination. A target node built by another dispatcher's store never opens here; see [several dispatchers](build-store.md#several-dispatchers-on-one-repository). `ab repository status` lists the queue diagnostics.
59
59
  - **Claims:** claimed tickets aren't reclaimed.
60
60
  - **Forge cooldown:** `forge landing/polling paused until <reset>` means a GitHub rate limit holds forge work until that reset, whether a request was refused or a successful response reported the quota exhausted. `forge rate limit <resource>` lines show the last observed quota and when it was seen.
61
- - **Capacity:** paused unfinished work, and work blocked on a question, keeps its slot; builds waiting for a merge decision, builds waiting on other tickets, and idle collecting nodes take none. A finished build that must re-verify or reconcile, or a build whose ticket wait ended, reserves a slot ahead of normal claims; urgent work, including urgent ready tickets, goes first, and `ab priority <slug> urgent` expedites a waiting build. Node verification and reconciliation account specially for descendants' slots.
61
+ - **Capacity:** a build holds a slot while Autobuild owes its next move. Paused builds, builds blocked on a question once nothing is still working on them, builds waiting for a merge decision or on other tickets, and idle collecting nodes hold none. An answered or resumed build, a finished build that must re-verify or reconcile, and a build whose ticket wait ended wait as parked work for a slot ahead of claims at its level; higher-level work, including higher-level ready tickets, goes first, and `ab priority <slug> urgent` expedites a waiting build. Occupancy never exceeds `capacity`.
62
62
  - **Harvest:** check the acknowledged harvest gate and unclaimed observations. Harvest triggers at `policy.harvestThreshold` observations, or `policy.harvestMaxDrift` other merged builds since the oldest observation (zero disables drift), and uses no build slot.
63
63
 
64
64
  ## Worktree destination not isolated
@@ -114,6 +114,21 @@ bun ab builds --queued
114
114
 
115
115
  See [answering blocked builds](operating.md#answer-and-pause). Preserve event logs; let the kernel manage leases and recovery.
116
116
 
117
+ ## Infrastructure escalation names a recovery step
118
+
119
+ **Symptom.** `infrastructure.failed`, or an escalation reading `maxInfrastructureAttempts (N) exhausted during reconcile at step resume`, on a remote sandbox build.
120
+
121
+ **Cause.** Workspace recovery failed at the named step:
122
+
123
+ | Step | What failed | Action |
124
+ |---|---|---|
125
+ | `resume` | Cold resume of a stopped sandbox | Usually transient latency. Answer with a retry resolution, or raise `recoveryTimeoutMs` within the hosted invocation budget. |
126
+ | `fence` | Proving the sandbox's execution stopped | Check provider status for the sandbox, then retry. |
127
+ | `preserve` | Inspecting or pushing the sandbox's commits | Check forge credentials and the branch, then retry. |
128
+ | `cleanup` | Stop, snapshot purge or delete | Check the sandbox and its snapshots in the provider, then retry. |
129
+
130
+ A deadline-deferred step records nothing and retries on the next invocation. See [Vercel sandbox recovery](configuration.md#vercel-sandbox).
131
+
117
132
  ## Remote project access
118
133
 
119
134
  **Symptom.** Remote requests refuse a project despite a configured URL.
@@ -21,7 +21,7 @@ Every repository needs an **acceptance check**: an agent verify step that runs t
21
21
  Verification uses ordered stages. A string in `[verify].steps` is a singleton
22
22
  stage; a nonempty array groups members that start together. Empty stages and
23
23
  repeated names are errors. Plain string lists retain serial event sequences.
24
- Every member resolves post-reconcile policy, approved selection/`always`, then
24
+ Every member resolves post-reconcile and clean-restack policy, approved selection/`always`, then
25
25
  path applicability at stage entry. Only pass or skip satisfies a member. The
26
26
  next stage, or finalize after the last, waits for every member to pass or skip.
27
27
 
@@ -115,6 +115,8 @@ Path rules:
115
115
 
116
116
  After a reconcile, the `afterReconcile` policy applies before plan and path selection. By default it re-verifies; excluded steps are recorded as policy skips.
117
117
 
118
+ After a clean restack while a root-targeting leaf waits to land, steps opted in with `afterCleanRestack` re-run on the restacked head before it lands; the rest are recorded as policy skips. It is off by default.
119
+
118
120
  ## What a check command receives
119
121
 
120
122
  A `check` command runs in the build's workspace with `AB_VERIFY_BASE` set to the commit verification compares against, the same base path applicability diffs from:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defrex/autobuild",
3
- "version": "1.11.1",
3
+ "version": "1.13.0",
4
4
  "description": "Agent-driven software delivery from groomed ticket to merged PR",
5
5
  "repository": {
6
6
  "type": "git",
@@ -162,8 +162,8 @@
162
162
  },
163
163
  "devDependencies": {
164
164
  "@biomejs/biome": "2.5.5",
165
- "@defrex/autobuild-postgres-store": "1.11.1",
166
- "@defrex/autobuild-vercel-sandbox": "1.11.1",
165
+ "@defrex/autobuild-postgres-store": "1.13.0",
166
+ "@defrex/autobuild-vercel-sandbox": "1.13.0",
167
167
  "@resvg/resvg-js": "2.6.2",
168
168
  "@types/bun": "^1.3.14",
169
169
  "@types/node": "^24.0.0",
@@ -0,0 +1,17 @@
1
+ /** Ambient-identity errors, free of the session resolvers so store openers can
2
+ * raise them without initializing `./env`, which re-exports them. */
3
+ const BUILD_AMBIENT_TUPLE = 'AB_STORE/AB_BUILD/AB_PHASE/AB_SESSION'
4
+ const HARVEST_AMBIENT_TUPLE = 'AB_STORE/AB_REPO/AB_HARVEST/AB_PHASE/AB_SESSION'
5
+
6
+ /** Optional ambient identity is present but cannot safely select one scope. */
7
+ export class InvalidAmbientContextError extends Error {
8
+ override readonly name = 'InvalidAmbientContextError'
9
+
10
+ constructor(detail: string) {
11
+ super(
12
+ `invalid ambient context: ${detail}. Expected no agent identity markers, ` +
13
+ `a complete build tuple (${BUILD_AMBIENT_TUPLE}), or a complete Harvest tuple ` +
14
+ `(${HARVEST_AMBIENT_TUPLE})`,
15
+ )
16
+ }
17
+ }