@defrex/autobuild 1.12.0 → 1.14.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 (167) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +465 -163
  3. package/bin/ab-build-runner.ts +8 -0
  4. package/docs/answering-blocked-builds.md +28 -4
  5. package/docs/architecture.md +136 -53
  6. package/docs/cli.md +1 -1
  7. package/docs/configuration.md +120 -17
  8. package/docs/dispatcher.md +19 -8
  9. package/docs/integration-overview.md +1 -1
  10. package/docs/integration-tree.md +12 -9
  11. package/docs/merge-policy.md +7 -2
  12. package/docs/operating.md +13 -3
  13. package/docs/operator-api.md +46 -23
  14. package/docs/operator-surfaces.md +7 -6
  15. package/docs/optimization-nodes.md +7 -6
  16. package/docs/plugin-authoring.md +46 -18
  17. package/docs/remote-store-protocol.md +52 -13
  18. package/docs/remote-ticket-protocol.md +85 -38
  19. package/docs/restacking.md +48 -3
  20. package/docs/setup.md +2 -1
  21. package/docs/ticket-migration.md +2 -2
  22. package/docs/ticket-sources.md +23 -8
  23. package/docs/tickets.md +4 -4
  24. package/docs/troubleshooting.md +32 -2
  25. package/docs/verification.md +3 -1
  26. package/package.json +3 -3
  27. package/packages/core/src/cli/build-control.ts +72 -6
  28. package/packages/core/src/cli/dashboard/actions.ts +4 -0
  29. package/packages/core/src/cli/dashboard/integration-row.ts +43 -19
  30. package/packages/core/src/cli/dashboard/model.ts +14 -8
  31. package/packages/core/src/cli/dashboard/poll.ts +218 -10
  32. package/packages/core/src/cli/dashboard/queue.ts +21 -10
  33. package/packages/core/src/cli/dashboard/row-text.ts +2 -1
  34. package/packages/core/src/cli/dashboard/vocabulary.ts +5 -1
  35. package/packages/core/src/cli/dispatch-frontend.ts +2 -1
  36. package/packages/core/src/cli/dispatch-tickets.ts +33 -12
  37. package/packages/core/src/cli/dispatch.ts +547 -145
  38. package/packages/core/src/cli/help.ts +38 -24
  39. package/packages/core/src/cli/main.ts +7 -5
  40. package/packages/core/src/cli/publication-settlement.ts +4 -0
  41. package/packages/core/src/cli/remote-poll.ts +22 -5
  42. package/packages/core/src/cli/repository-status.ts +19 -9
  43. package/packages/core/src/cli/status.ts +23 -11
  44. package/packages/core/src/cli/store-opening.ts +12 -0
  45. package/packages/core/src/cli/ticket-start.ts +3 -3
  46. package/packages/core/src/cli/ticket.ts +12 -11
  47. package/packages/core/src/cli/wait.ts +8 -28
  48. package/packages/core/src/cli/watch.ts +113 -50
  49. package/packages/core/src/config/reference-metadata.ts +7 -1
  50. package/packages/core/src/config/reference.ts +5 -2
  51. package/packages/core/src/config/schema.ts +51 -16
  52. package/packages/core/src/events/payloads.ts +74 -14
  53. package/packages/core/src/events/policy.ts +1 -0
  54. package/packages/core/src/events/repository.ts +33 -3
  55. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +31 -0
  56. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/be211f0e31a65006.json.gz +0 -0
  57. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/0a10010ee5cf2e47.json +577 -0
  58. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/227701361be6d1e0.json +490 -0
  59. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/312cc4090820a612.json +1078 -0
  60. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/76e5043bae7a80ab.json +86 -0
  61. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/87a917802870bbed.json +87 -0
  62. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/9d85616e5b9e24c1.json +500 -0
  63. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a2780567b4989fb6.json +105 -0
  64. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/c7c94fbe7f63cf07.json +84 -0
  65. package/packages/core/src/kernel/clean-restack-policy.ts +40 -0
  66. package/packages/core/src/kernel/dispatch-capacity.ts +243 -107
  67. package/packages/core/src/kernel/done-escalations.ts +273 -0
  68. package/packages/core/src/kernel/engine.ts +28 -9
  69. package/packages/core/src/kernel/integration-landing.ts +24 -4
  70. package/packages/core/src/kernel/integration-stack.ts +39 -0
  71. package/packages/core/src/kernel/janitor-failure.ts +20 -1
  72. package/packages/core/src/kernel/log-index-value.ts +3 -0
  73. package/packages/core/src/kernel/log-index.ts +41 -2
  74. package/packages/core/src/kernel/open-pr-backpressure.ts +3 -3
  75. package/packages/core/src/kernel/reducer-registry.ts +3 -0
  76. package/packages/core/src/kernel/reducer-revisions.ts +19 -0
  77. package/packages/core/src/kernel/reducer.ts +42 -8
  78. package/packages/core/src/kernel/repository-attention.ts +14 -5
  79. package/packages/core/src/kernel/repository-read-facts.ts +9 -0
  80. package/packages/core/src/kernel/ticket-starts.ts +15 -4
  81. package/packages/core/src/kernel/verify-stages.ts +46 -7
  82. package/packages/core/src/operator/attention.ts +28 -3
  83. package/packages/core/src/operator/done-escalations.ts +38 -0
  84. package/packages/core/src/operator/presentation.ts +1 -1
  85. package/packages/core/src/operator/protocol.ts +8 -5
  86. package/packages/core/src/operator/query.ts +33 -19
  87. package/packages/core/src/operator/registry.ts +17 -13
  88. package/packages/core/src/operator/ticket-start.ts +8 -7
  89. package/packages/core/src/operator/tickets.ts +28 -9
  90. package/packages/core/src/plugin-sdk/index.ts +10 -0
  91. package/packages/core/src/plugins/manifest.ts +14 -1
  92. package/packages/core/src/ports/forge/create.ts +8 -0
  93. package/packages/core/src/ports/forge/github-transport.ts +5 -1
  94. package/packages/core/src/ports/forge/github.ts +3 -0
  95. package/packages/core/src/ports/tickets/contract.ts +147 -76
  96. package/packages/core/src/ports/tickets/create.ts +47 -7
  97. package/packages/core/src/ports/tickets/fake.ts +8 -4
  98. package/packages/core/src/ports/tickets/file-codec.ts +4 -3
  99. package/packages/core/src/ports/tickets/file.ts +7 -3
  100. package/packages/core/src/ports/tickets/github.ts +1 -0
  101. package/packages/core/src/ports/tickets/grants.ts +11 -3
  102. package/packages/core/src/ports/tickets/hosted-index.ts +5 -0
  103. package/packages/core/src/ports/tickets/linear.ts +28 -9
  104. package/packages/core/src/ports/tickets/migration.ts +4 -4
  105. package/packages/core/src/ports/tickets/operations.ts +4 -2
  106. package/packages/core/src/ports/tickets/priority-labels.ts +213 -0
  107. package/packages/core/src/ports/tickets/priority.ts +127 -21
  108. package/packages/core/src/ports/tickets/remote-protocol.ts +10 -0
  109. package/packages/core/src/ports/tickets/remote.ts +104 -11
  110. package/packages/core/src/ports/tickets/revision.ts +5 -3
  111. package/packages/core/src/ports/tickets/search.ts +9 -0
  112. package/packages/core/src/ports/tickets/tree.ts +8 -6
  113. package/packages/core/src/ports/types.ts +30 -15
  114. package/packages/core/src/ports/workspace/build-execution.ts +13 -1
  115. package/packages/core/src/ports/workspace/builtin-capabilities.ts +4 -0
  116. package/packages/core/src/ports/workspace/create.ts +16 -3
  117. package/packages/core/src/ports/workspace/execution-exit-marker.ts +41 -0
  118. package/packages/core/src/ports/workspace/recovery-step.ts +101 -0
  119. package/packages/core/src/ports/workspace/vercel-sandbox.ts +596 -144
  120. package/packages/core/src/processes/build-execution-state.ts +4 -0
  121. package/packages/core/src/processes/build-runner.ts +14 -1
  122. package/packages/core/src/processes/dispatcher.ts +841 -230
  123. package/packages/core/src/processes/execution-settlement.ts +25 -3
  124. package/packages/core/src/processes/harvest-runner.ts +12 -7
  125. package/packages/core/src/processes/infrastructure-failure-budget.ts +7 -2
  126. package/packages/core/src/processes/invocation-budget.ts +176 -0
  127. package/packages/core/src/processes/publication-loss.ts +38 -3
  128. package/packages/core/src/processes/tick-publication.ts +1 -0
  129. package/packages/core/src/processes/workspace-preservation.ts +86 -15
  130. package/packages/core/src/store/contract.ts +88 -3
  131. package/packages/core/src/store/event-reads.ts +30 -1
  132. package/packages/core/src/store/reduced-reads.ts +23 -0
  133. package/packages/core/src/store/reducer-value-shapes.json +6759 -6490
  134. package/packages/core/src/store/reducer-value-validation.ts +188 -33
  135. package/packages/core/src/store/remote/client.ts +169 -29
  136. package/packages/core/src/store/remote/compatibility.ts +113 -56
  137. package/packages/core/src/store/remote/credentials.ts +4 -1
  138. package/packages/core/src/store/remote/protocol.ts +3 -0
  139. package/packages/core/src/store/remote/released-clients.json +22 -0
  140. package/packages/core/src/store/remote/released-reducer-values/1.13.0.json +35966 -0
  141. package/packages/core/src/store/remote/released-reducer-values/1.14.0.json +36076 -0
  142. package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
  143. package/packages/core/src/store/remote/released-value-policy.ts +144 -0
  144. package/packages/core/src/store/remote/retry.ts +406 -0
  145. package/packages/core/src/store/repo-state-events.ts +1 -0
  146. package/packages/core/src/testing/dispatch-read-budget.ts +155 -11
  147. package/packages/core/src/testing/index.ts +2 -0
  148. package/packages/core/src/testing/invocation-budget.ts +42 -0
  149. package/packages/core/src/testing/reduced-read-budget.ts +589 -19
  150. package/packages/core/src/testing/released-value-coverage.ts +423 -0
  151. package/packages/core/src/web/overview-source.ts +19 -6
  152. package/skills/guide/SKILL.md +147 -67
  153. package/skills/guide/references/integration-tree.md +12 -9
  154. package/skills/guide/references/merge-policy.md +7 -2
  155. package/skills/guide/references/operator-api.md +46 -23
  156. package/skills/guide/references/optimization-nodes.md +7 -6
  157. package/skills/guide/references/plugin-authoring.md +46 -18
  158. package/skills/guide/references/remote-store-protocol.md +52 -13
  159. package/skills/guide/references/remote-ticket-protocol.md +85 -38
  160. package/skills/guide/references/restacking.md +48 -3
  161. package/skills/guide/references/setup.md +2 -1
  162. package/skills/guide/references/ticket-migration.md +2 -2
  163. package/skills/operate/SKILL.md +136 -55
  164. package/skills/plan/SKILL.md +4 -3
  165. package/skills/spec/SKILL.md +9 -5
  166. package/skills/tickets/SKILL.md +25 -17
  167. 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
@@ -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