@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
@@ -7,6 +7,10 @@ import {
7
7
  } from '../packages/core/src/processes/build-child-exit'
8
8
  import { watchBuildParent } from '../packages/core/src/processes/build-parent-watch'
9
9
  import { BUILD_RUNNER_OPTIONS_ENV } from '../packages/core/src/ports/workspace/local-build-execution'
10
+ import {
11
+ EXECUTION_EXIT_FILE_ENV,
12
+ writeExecutionExitSync,
13
+ } from '../packages/core/src/ports/workspace/execution-exit-marker'
10
14
  import {
11
15
  parseBuildChildLaunch,
12
16
  type BuildChildLaunch,
@@ -51,5 +55,9 @@ if (input.supervision.kind === 'local-parent') {
51
55
  } catch {
52
56
  exitCode = 1
53
57
  }
58
+ // A stopped persistent sandbox no longer reports the command's exit, so the
59
+ // runner records it on the environment's own filesystem for re-observation.
60
+ const exitFile = process.env[EXECUTION_EXIT_FILE_ENV]
61
+ if (exitFile) writeExecutionExitSync(exitFile, input.instance, exitCode)
54
62
  process.exit(exitCode)
55
63
  }
@@ -6,8 +6,8 @@ Every action below is sessionless, records a human-authored fact, and accepts
6
6
  `--store <ref>`.
7
7
 
8
8
  A blocked build holds no capacity slot once nothing is still working on it.
9
- Answering doesn't give it one: it waits as a `resume` request ahead of normal
10
- ticket claims, urgent work first, and runs once a slot frees. A build whose
9
+ Answering doesn't give it one: it waits as a `resume` request ahead of ticket
10
+ claims at its level, higher levels first, and runs once a slot frees. A build whose
11
11
  work goes on keeps its slot through the answer and requests nothing: another
12
12
  step of its verify stage still running, a launch in flight, or a running
13
13
  execution launched with the slot. A `--revise-spec` answer requests nothing
@@ -22,7 +22,7 @@ until the revision lands.
22
22
  | Replace the build contract from a file | `ab answer <slug> --revise-spec <file>` | Records the replacement as the next spec revision and restarts leaves at `plan`; nodes recollect and verify. |
23
23
  | Re-import an amended ticket | `ab answer <slug> --revise-spec-from-ticket` | Reads the build's recorded ticket and performs the same revision. |
24
24
  | Accept a rewritten target | `ab answer <slug> --accept-target` | Answers only a `target-rewritten` escalation; the build's own commits restack onto the current target. See [A rewritten target](#a-rewritten-target). |
25
- | Abandon the build | `ab abort <slug> [--to ready] [--reason <text>]` | Irrevocably requests abort; cleanup returns the ticket to Triage, or with `--to ready` to Ready with its blockers kept, and then reports `ticket.handed-back`. Ready requires the current ticket to meet the spec standard; otherwise cleanup returns it to Triage, and the comment and event name the requested destination and the missing parts. An [optimization attempt](optimization-nodes.md#landing-and-settlement) is the exception: its abort settles `aborted`, ignores `--to`, reports no `ticket.handed-back`, and the node moves the ticket to Rejected after cleanup. |
25
+ | Abandon the build | `ab abort <slug> [--to ready] [--reason <text>]` | Irrevocably requests abort. Abort closes the build's open escalations without answering them. Cleanup returns the ticket to Triage, or with `--to ready` to Ready with its blockers kept, and then reports `ticket.handed-back`. Ready requires the current ticket to meet the spec standard; otherwise cleanup returns it to Triage, and the comment and event name the requested destination and the missing parts. An [optimization attempt](optimization-nodes.md#landing-and-settlement) is the exception: its abort settles `aborted`, ignores `--to`, reports no `ticket.handed-back`, and the node moves the ticket to Rejected after cleanup. |
26
26
 
27
27
  The dashboard's blocked-build `r` shortcut requests an inline answer step that
28
28
  supports guidance and a blank retry. While that step is open, it is exclusive
@@ -91,7 +91,7 @@ RESUME on a waiting build answers it. The dispatcher ends the wait on its
91
91
  first tick after every named ticket completes; a wait with some tickets still
92
92
  open stays in place. To end it early, for example when the work landed another
93
93
  way, `ab answer <slug> <text>` or a bare `ab answer <slug>` ends the wait.
94
- Either way the build waits as a `resume` request and takes the next free slot ahead of normal ticket claims (urgent work first; `ab priority <slug> urgent` expedites it). If its target
94
+ Either way the build waits as a `resume` request and takes the next free slot ahead of ticket claims at its level (higher levels first; `ab priority <slug> urgent` expedites it). If its target
95
95
  branch has moved past the base the build's work sits on, the build first
96
96
  restacks onto the target's current head so the resumed phase sees the merged blockers; a conflicting
97
97
  restack shows as `reconcile` and resolves first. The phase that declared the
@@ -189,3 +189,27 @@ uncited artifacts are inert. Leaves still require an open escalation and
189
189
  restart from `plan` after any unfinished reconcile resumes under the revised
190
190
  spec and its publication is confirmed. A settled, unmerged leaf awaiting merge
191
191
  revises without an escalation through `ab reopen`.
192
+
193
+ ## Acknowledging an escalation on a completed build
194
+
195
+ A done build can still gain an escalation: the post-landing integration audit
196
+ raises one when a node's merged result does not match what was verified, after
197
+ the build completed. Answer it like any other:
198
+
199
+ - `ab answer <slug> <text>` or `builds.answer` `guidance` records the text.
200
+ - `ab answer <slug>` or `builds.answer` `retry` records a bare acknowledgement.
201
+
202
+ Either closes every open escalation with `escalation.answered`. The build stays
203
+ done: nothing resumes, restarts or reopens. Every other answer form
204
+ (`--revise-spec`, `--revise-spec-from-ticket`, `--dismiss`, `--accept-target`,
205
+ `--review-round-ceiling`) is refused with `inactive`, and so is a done build
206
+ with nothing open.
207
+
208
+ `ab build status` / `builds.get`, `ab watch` / `ab wait` attention, both
209
+ dashboards, `ab web` and `operator.attention` show the escalation while it is
210
+ open and drop it once acknowledged. On a dashboard the build reads red
211
+ `BLOCKED` with the note `done` and its question, and holds no slot. Completion
212
+ closes nothing, but accepting an abort closes every escalation open then, so an
213
+ aborted build appears here only for an escalation raised afterwards, such as a
214
+ cleanup failure. A discard is accepted only while the build is queued, when
215
+ nothing is open.
@@ -98,7 +98,7 @@ remote-store protocol requires matching client and server versions.
98
98
  | `packages/core/src/ports/` | TicketSource / Workspace / Forge / AgentRunner / Telemetry interfaces, adapters, and fakes; registry-aware builtin/plugin construction; eager primary/alternate runtime routing and provider-failure classification, awaited native identity observation and optional fresh-process native resume under `ports/runner/` | §3.2, §9, §13 |
99
99
  | `packages/core/src/plugins/` | Strict versioned plugin manifests, dual-root repository/package Bun loading, owner-aware adapter registration, contract/credential metadata, and runtime-factory materialization | §3.2.1, §9 |
100
100
  | `packages/core/src/plugin-sdk/` | The sole supported `@defrex/autobuild/plugin-sdk` barrel: port/manifest types, contract suites, and reference fakes | §3.2.1 |
101
- | `packages/core/src/processes/` | build-runner and standalone child composition, durable execution config/diagnostics, dispatcher (+ janitor duty, sandbox idle settlement and harvest trigger), harvest deterministic core + runner, configured hook delivery (`hooks.ts`, `hook-command.ts`, `hook-webhook.ts`), repository agent-context capture (`agent-context.ts`, pure selection in `agent-context-assemble.ts`) | §3.3, §7.1.2, §12, §15.7, §16.1 |
101
+ | `packages/core/src/processes/` | build-runner and standalone child composition, durable execution config/diagnostics, dispatcher (+ janitor duty, sandbox idle settlement and harvest trigger), bounded-invocation budget (`invocation-budget.ts`), harvest deterministic core + runner, configured hook delivery (`hooks.ts`, `hook-command.ts`, `hook-webhook.ts`), repository agent-context capture (`agent-context.ts`, pure selection in `agent-context-assemble.ts`) | §3.3, §7.1.2, §12, §15.7, §16.1 |
102
102
  | `packages/core/src/cli/` and `bin/` | The `ab` CLI — the only agent↔store channel — plus the shared presentation-only durable-progress projection, init/upgrade, the filesystem-only dispatch launcher and immutable generation cache, the dispatch frontend (Store-backed, plus the viewer's ticket-source triage count) and its in-process web server, its private supervised kernel entry, and `bin/ab-build-runner.ts` (one child per build) | §8, §14, §16.3 |
103
103
  | `packages/core/src/cli/dashboard/` | `ab dispatch`'s fixed live frame: pure projection, renderer, poll cache, and deterministic image renderer | §14 |
104
104
  | `bin/agent/ab` | Private launcher placed first on agent-session `PATH`; delegates to the canonical `bin/ab.ts` | §8.1 |
@@ -245,11 +245,16 @@ identity, receive answers projected onto their
245
245
  frozen released contracts in `store/remote/released-reducer-values/` and stamped
246
246
  with their released reducer versions, including projection-capable published clients.
247
247
  The projection covers both named reducer values and historical stream seeds.
248
- `reducerValueForClient` omits optional `lastEvent` fields with newer event variants,
248
+ `reducerValueForClient` omits optional `lastEvent` fields the release cannot
249
+ represent (newer event variants, or well-formed events with newer payload values),
249
250
  including nested build state, and filters `seenTypes` to known event types while
250
- preserving canonical cursor, progress, and compatibility facts. An invalid envelope
251
- or an unrepresentable required value raises `ReducerValueIncompatibilityError`
252
- with client/server versions and validation detail. See the
251
+ preserving canonical cursor, progress, and compatibility facts. Widened literals are
252
+ rewritten or omitted at the sites declared in `store/remote/released-value-policy.ts`;
253
+ `released-value-coverage.integration.test.ts` sweeps populated values covering every
254
+ union variant against every supported contract and fails on an undeclared divergence.
255
+ An invalid envelope or an unrepresentable required value raises
256
+ `ReducerValueIncompatibilityError` with client/server versions, validation detail and
257
+ upgrade advice; `ab watch` and `ab wait` treat it as terminal. See the
253
258
  [reduced-value protocol](remote-store-protocol.md) for the response
254
259
  contract. No remote named read replays events.
255
260
  Repository digest batches likewise return the server batch with one scoped
@@ -287,7 +292,11 @@ registered build reducer, a pure invertible contribution, an accumulator with
287
292
  histograms of `store/histogram.ts`. `kernel/build-roster.ts` is the second:
288
293
  its `buildRosterEntry` build reducer feeds `buildRoster`, the live builds plus
289
294
  a capped history of the newest finished ones, which `ab web`'s overview starts
290
- from. `store/rollups.ts` is the one engine every
295
+ from. `kernel/done-escalations.ts` is the third: its `doneEscalationEntry`
296
+ build reducer mirrors the build reducer's open-escalation rules and feeds
297
+ `doneEscalations`, the done builds whose escalation still awaits
298
+ acknowledgement, which every dashboard and `operator.attention` read beside
299
+ the open builds. `store/rollups.ts` is the one engine every
291
300
  adapter runs over a narrow `RollupStorage` port: fast path on an unchanged
292
301
  change position, otherwise an advance by the changed-builds feed, serialized
293
302
  per key and committed atomically with each build's absorbed contribution in
@@ -528,8 +537,9 @@ head is a no-op; Git/Forge failures stay failure-tolerant observations.
528
537
  **Verify gating.** `packages/core/src/ontology.ts` owns the canonical
529
538
  `pass | fail | skipped` outcome (only `fail` routes back to implement or
530
539
  consumes attempts; a skip satisfies one step without being passing
531
- evidence). Three kernel-authored skip sources narrow the configured universe:
532
- post-reconcile policy, approved plan selection, and changed paths.
540
+ evidence). Four kernel-authored skip sources narrow the configured universe:
541
+ post-reconcile policy, clean-restack policy, approved plan selection, and
542
+ changed paths.
533
543
  The engine captures the ordered effective `afterReconcile` policy in
534
544
  `verify.reconcile-policy-captured` at the action after reconciliation completes,
535
545
  before verification starts. Log-index replay keeps it scoped to that completion;
@@ -540,6 +550,14 @@ and carry `skipCause: "post-reconcile-policy"` plus a setting-specific reason.
540
550
  The shared dashboard model renders that reason, as does the PR summary.
541
551
  Excluded steps do not re-verify merged code, so combination-only breakage can
542
552
  merge; forge requirements and reconcile budgets remain independent.
553
+ The clean-restack policy is frozen earlier, in the restack intent itself:
554
+ `kernel/clean-restack-policy.ts` resolves `afterCleanRestack` for a
555
+ root-targeting leaf's awaiting-landing intent in `BuildRunner.restack`, and
556
+ the intent, rewrite and completion all carry it as `cleanRestackPolicy`, so no
557
+ gap exists between the restack and the policy capture. While that completion
558
+ is the newest code boundary (`cleanRestackPolicyInForce` in
559
+ `kernel/verify-stages.ts`), disabled steps skip with
560
+ `skipCause: "clean-restack-policy"` before plan/path applicability.
543
561
  For enabled steps,
544
562
  `packages/core/src/kernel/plan-verify-selection.ts` resolves an approved plan's front-matter
545
563
  selection (applied at the planner's `ab done` in `packages/core/src/cli/terminals.ts`,
@@ -720,16 +738,30 @@ standalone `dispatcher.tick-failed` diagnostic before the next operational tick.
720
738
  An unacknowledged diagnostic remains pending and may be duplicated after a lost
721
739
  response. Reporting never closes a later tick boundary or gates committed
722
740
  handoff acceptance. Explicit shutdown, supersession and fatal forge publication
723
- still stop the loop; once mode rethrows the original tick error even if reporting
724
- fails. Stopping before recovery leaves only local warnings for unreported failures.
741
+ still stop the loop. Once mode ends its run after its tick: a durably reported tick
742
+ failure records a normal `dispatcher.run-stopped` with exit code 1 and the error
743
+ (`DispatchTickFailedError` carries it to `abDispatch`), then rethrows the original
744
+ error; an unreported failure, fatal forge publication or fatal ticket preparation
745
+ stops abnormally. Stopping before recovery leaves only local warnings for
746
+ unreported failures. A tick-failure episode in `kernel/repository-attention.ts`
747
+ spans runs, so consecutive one-tick hosted runs still reach the five-minute
748
+ persistent-tick attention.
749
+
750
+ `dispatcherTicketSource` returns a hosted source with its preparation deferred:
751
+ `DispatchLoop.prepareTickets` publishes the ticket policy and settles targeted
752
+ listing at the first tick boundary, once it succeeds. A transient
753
+ (`RemoteUnavailableError`) failure there is an ordinary tick failure;
754
+ any other is wrapped as `FatalTicketPreparationError` and stops the run
755
+ abnormally with the original error. `abDispatch` scopes the invocation deadline
756
+ (`withRemoteRetryDeadline`) so it also bounds client retries.
725
757
  Failure settlement writes through the fenced backing store without reading the
726
758
  failed projection. Repository view writes distinguish a committed result from a
727
759
  subsequent refresh failure, retaining the last complete snapshot while propagating
728
760
  the read error to the operational caller. Exact metadata confirmation acknowledges
729
761
  lost finish responses without requiring another projection read or duplicating
730
762
  boundaries. Every operational tick refreshes facts before routing work. Startup
731
- configuration errors, fatal forge publication errors, lease fencing and once-mode
732
- failure behavior retain their existing semantics.
763
+ configuration errors, fatal forge publication errors and lease fencing retain
764
+ their existing semantics.
733
765
 
734
766
  Timeout escalation is held while the matching repository tick observation is open
735
767
  (with historical `tick-started` journal fallback when no observation exists),
@@ -788,7 +820,9 @@ SHAs could not be inspected. An environment that never started executing holds
788
820
  no unpublished work: objects its checkout lacks mean nothing to preserve, so
789
821
  cleanup records `workspace.commits-preserved` (or `workspace.commits-retained`)
790
822
  carrying forward earlier preserved heads, then releases and replaces it. Unknown fencing, inspection, transport, or
791
- receipt-write outcomes leave the workspace and snapshots intact. A workspace
823
+ receipt-write outcomes leave the workspace and snapshots intact, except under
824
+ abort cleanup, which records `workspace.commits-lost` and tears the workspace
825
+ down. A workspace
792
826
  flagged by `workspace.cleanup-required` is never launched into: the dispatcher
793
827
  releases it and provisions the next generation. Provisioning cut off by a
794
828
  recorded dispatcher teardown is the exception: the next invocation asks the
@@ -796,6 +830,18 @@ provider to verify and finish the same generation, and if it cannot, the
796
830
  replacement consumes no infrastructure attempt. A preservation or release
797
831
  failure is recorded against its build, as an infrastructure failure or janitor
798
832
  attention, and never stops the dispatcher from advancing other builds.
833
+ Work a bounded invocation defers for budget (a provision, or a stopped-sandbox
834
+ recovery the Vercel provider admits on a realistic resume estimate rather than
835
+ the `recoveryTimeoutMs` ceiling) is noted per tick by `Dispatcher.noteDeferral`,
836
+ counted as `provisioningDeferred` or `recoveryDeferred` with one diagnostic line
837
+ per build, and carried in the latest-only `dispatcher.work-deferred` fact; one
838
+ noted after the work signal aborts is written through the tick's
839
+ `teardownWrite` scope under the cleanup signal. The
840
+ next tick's first stage, `serviceDeferredWork`, runs the ordinary `sweepBuild`
841
+ pass for those builds before settlement and the janitor; the lease sweep and
842
+ settlement skip what it took up. A resume the deadline cuts short is stopped or
843
+ left uncertain, and observation reports a budget deferral as a `running`
844
+ observation marked `deferred`.
799
845
  Fencing is revalidated after restart; a saved receipt alone never authorizes
800
846
  cleanup of a newer execution. Current recovery notes are linked by the session
801
847
  manifest's `workspaceRecovery` field. Recovery notes apply to the next session
@@ -897,17 +943,19 @@ restart boundary, so the engine re-runs implement, review, verify and finalize
897
943
  without special cases, and the terminal guard lets the re-run finalize and
898
944
  verify attempts complete again.
899
945
  Slot admission order (SPEC §12) is arithmetic in `kernel/dispatch-capacity.ts`:
900
- waiting entries carry the build's reduced `priority` (`build.created`,
901
- `build.priority-set`), `startClaimDemand` counts pending start requests by
902
- tier, `reservedAhead` counts the manual requests ahead of an urgent waiter and
903
- also the urgent reservations, urgent requests and the latest admission scan's
904
- `urgentWaiting` ahead of a normal waiter, `intakeCapacity` gives ordinary urgent
905
- and normal claims separate budgets, and `startCapacity` gives each start tier
906
- its own. The
907
- dispatcher's `leafAdmission`, `nodeAdmission` and proposer admission defer a
908
- normal waiter that fits while claims can run; `dispatch` forces that tick's
909
- admission scan once per deferral key, and `admitDeferredParked` retries the
910
- deferred admissions only after the scan completed its urgent decision: a leaf
946
+ waiting entries carry the build's level (`buildPriority` over the reduced
947
+ `priority` and `priorityLevel` that `build.created` and `build.priority-set`
948
+ set), `startClaimDemand` counts pending start requests by tier (`startTierOf`),
949
+ `reservedAhead` counts, ahead of a waiter at one level, the manual requests and
950
+ every higher level's waiters, start requests and the latest admission scan's
951
+ claim demand (`urgentWaiting`, `highWaiting`, `normalWaiting`, read by
952
+ `claimDemand`), `intakeCapacity` gives each level's ordinary claims its own
953
+ budget, and `startCapacity` gives each start tier its own. The dispatcher's
954
+ `leafAdmission`, `nodeAdmission` and proposer admission defer a non-urgent
955
+ waiter that fits while claims can run and a higher-level claim can exist
956
+ (`higherClaimsPossible`); `dispatch` forces that tick's admission scan once per
957
+ deferral key, and `admitDeferredParked` retries the deferred admissions only
958
+ after the scan decided claims at every level: a leaf
911
959
  through the build sweep, a node reconcile through `cascadeNode`, any other node
912
960
  need through `admitNode`, and a proposal through `admitProposers`.
913
961
  Ticket waits (SPEC §11) span four seams. `cli/terminals.ts` (`waitOn`, routed
@@ -1317,7 +1365,13 @@ appending `runner.attached`; resume and workspace-using decisions stay behind
1317
1365
  successful setup. For a request arriving during an AgentRunner turn, the runner
1318
1366
  observes the BuildStore subscription, forwards an `AbortSignal`, deposits/ends
1319
1367
  the session without a phase failure, and acknowledges abort. The execution
1320
- supervisor keeps the lease until every local descendant is reaped. `dispatcher.ts`
1368
+ supervisor keeps the lease until every local descendant is reaped. A leaf with
1369
+ no runner to hear the request is acknowledged by the dispatcher instead:
1370
+ `dispatcherAcknowledgesAbort` (`kernel/janitor-failure.ts`) selects a queued,
1371
+ paused or blocked leaf with a pending abort, and with no live execution lease the
1372
+ janitor appends `build.aborted` itself. The lease sweep, startup resume and
1373
+ dispatch recovery stand aside on the same predicate, so no workspace is
1374
+ provisioned and no runner launched only to acknowledge abort. `dispatcher.ts`
1321
1375
  defers destructive abort, discard, and terminal-PR cleanup while that lease is
1322
1376
  live, then resumes the event-checkpointed janitor saga that closes an unmerged PR,
1323
1377
  releases the workspace, deletes exact remote/local branch
@@ -1330,7 +1384,13 @@ back to triage and records the requested role and missing parts. The
1330
1384
  `abort.ticket-returned` checkpoint commits the move and comment, then the
1331
1385
  repository `ticket.handed-back` report is appended before abandoned completion;
1332
1386
  once that report exists the dispatcher writes nothing more to the ticket, so it
1333
- is the safe boundary for a subsequent ticket move. An optimization attempt
1387
+ is the safe boundary for a subsequent ticket move. Abort's workspace release
1388
+ makes one best-effort preservation attempt (`preserveBeforeAbortRelease`):
1389
+ any failure but lost authority, a mixed-version deferral or a live lease
1390
+ (`WorkspaceLeaseLive`), forge deferrals included, records
1391
+ `workspace.commits-lost` and the release proceeds; an uncompleted publication is
1392
+ recorded lost without settlement (`recordPublicationLossBeforeRelease`). A
1393
+ failed provider reap stays due on the next tick. An optimization attempt
1334
1394
  is the exception: cleanup settles it `aborted` on the node's log (or settles a
1335
1395
  merged attempt as a merge), skips the label, ticket move, comment,
1336
1396
  `abort.ticket-returned` checkpoint and `ticket.handed-back` report whatever
@@ -1463,8 +1523,9 @@ effective-config changes and bounded enrichment refreshes while retaining the
1463
1523
  cached log and reduction. `repository-poll.ts` serializes the complete presentation
1464
1524
  snapshot in both terminal paths. It samples `getRepoChangePosition` before reads,
1465
1525
  acknowledges it only after complete admitted reads, and reuses unchanged snapshots
1466
- for up to ten seconds. Scoped discovery uses `listBuildsForRepo`; unchanged focused
1467
- frames make one counter request. Session feeds remain independent.
1526
+ for up to ten seconds. Discovery never lists builds: the poll cache cold-starts
1527
+ from `listOpenBuilds` and the `doneEscalations` rollup, then advances by
1528
+ `listBuildsChangedSince`; unchanged focused frames make one counter request. Session feeds remain independent.
1468
1529
 
1469
1530
  Both dashboard frontends render one vocabulary. `cli/dashboard/vocabulary.ts`
1470
1531
  holds the browser-safe terms: status words and tones, step marks, and the
@@ -1473,8 +1534,8 @@ clock-dependent step timers. Its only value import is `cells.ts`.
1473
1534
  header, dispatcher-mode, attention-list, finished-row and overview text. The
1474
1535
  terminal renderer paints those values, and `web/protocol.ts` aliases the same
1475
1536
  types for the web frame, so a term changes in one place.
1476
- `web/overview-source.ts` builds `ab web`'s overview from `buildRoster` and the
1477
- changed-builds feed, through the poll cache's shared row and header helpers
1537
+ `web/overview-source.ts` builds `ab web`'s overview from `buildRoster`,
1538
+ `doneEscalations` and the changed-builds feed, through the poll cache's shared row and header helpers
1478
1539
  (`readRowEnrichment`, `projectRowWithEnrichment`, `repositoryDashboardHeader`
1479
1540
  in `cli/dashboard/poll.ts`), so the terminal and the web project rows the same
1480
1541
  way.
@@ -1672,11 +1733,18 @@ from `dispatch.failed`, which completes an already established build.
1672
1733
  (`ticket.identity-recorded`) into `repositoryReadFacts`. `operator/ticket-start.ts`
1673
1734
  is the one request/cancel seam behind `ab start` (`cli/ticket-start.ts`), the
1674
1735
  `tickets.start` tool and the HTTP start routes. The dispatcher's
1675
- `honorStartRequests` stage runs twice per tick, for `manual` and `urgent`
1676
- requests before intake and for `normal` requests after intake and the deferred
1677
- parked admissions. It admits pending requests through `dispatch()` in its
1678
- targeted mode, which skips the ready listing and scan checkpoint, budgets each
1679
- ticket by its request's tier, but keeps every admission gate.
1736
+ `honorStartRequests` stage runs for `manual` and `urgent` requests before
1737
+ intake, and for `high`, `normal` and `low` requests inside intake, before the
1738
+ first ready ticket at their level, or after intake and the deferred parked
1739
+ admissions. The early pass reads at most `START_REQUESTS_PER_TICK` requests and
1740
+ the late passes share as many. It admits pending requests through `dispatch()`
1741
+ in its targeted mode, which skips the ready listing and scan checkpoint, budgets
1742
+ each ticket by its request's tier, but keeps every admission gate. A request the
1743
+ allowance leaves unread is the tick's start barrier (`startBarrier` in
1744
+ `kernel/dispatch-capacity.ts`), sampled when the tick starts.
1745
+ `admissionBarred` is the one guard that applies it: `slotAdmission` consults it
1746
+ for parked leaves, nodes and proposers, intake for ordinary claims, and the
1747
+ start passes for lower tiers.
1680
1748
  `kernel/build-creation.ts` derives the keyed canonical slug that the dispatcher and
1681
1749
  the hosted server share. The optional `BuildStore.buildCreationIdentity` port says
1682
1750
  whether a store creates at the exact slug (method absent), at that derived slug for
@@ -1746,7 +1814,11 @@ and an explicit opt-in. When
1746
1814
  adding an adapter, start from its contract suite, not only the interface.
1747
1815
 
1748
1816
  The two remote clients get client-only coverage in core itself, against an
1749
- injected `fetchFn` with responses built from the protocol's wire schemas.
1817
+ injected `fetchFn` with responses built from the protocol's wire schemas. Both
1818
+ send every request through `store/remote/retry.ts`, which retries transient
1819
+ failures by safety class under one bounded retry window (SPEC "Transient remote
1820
+ retries"); its seams (`sleep`, `timeout`, `now`, `random`) keep retry tests free
1821
+ of real timers, and single-answer tests pass `retry: false`.
1750
1822
  `HostedTicketSource` (`ports/tickets/remote.test.ts`) is in-memory unit
1751
1823
  coverage that runs in `bun run test`. `RemoteBuildStore`
1752
1824
  (`store/remote/client.test.ts`, which also pins scoped-token
@@ -1949,8 +2021,8 @@ absolute file path containing the edited text. Read the current ticket and
1949
2021
  reapply the intended changes before retrying; conflicts are never merged.
1950
2022
 
1951
2023
  File and Linear revisions fingerprint kind, target, title, body, canonical label/blocker sets,
1952
- state and urgent priority; file revisions also cover nonempty issue links. GitHub revisions
1953
- fingerprint kind, target, title, body, canonical label/blocker sets, state and issue links,
2024
+ state and any priority other than normal; file revisions also cover nonempty issue links. GitHub revisions
2025
+ fingerprint kind, target, title, body, canonical label/blocker sets (priority labels included), state and issue links,
1954
2026
  including the ticket's own issue; GitHub tickets carry no comments. Reverting
1955
2027
  identical content restores its fingerprint. File checks
1956
2028
  re-read immediately before writing, with the existing no-lock race window.
@@ -1991,20 +2063,27 @@ column that every listing already selects. Dependency states carry each blocker'
1991
2063
  native `state` for clients that send `x-autobuild-ticket-dependency-state: 1`,
1992
2064
  read from the row each lookup already loads; the dispatcher applies the
1993
2065
  configured rejected role on top (`markRejected` in `processes/dispatcher.ts`).
1994
- Priority follows the issue-link pattern with `x-autobuild-ticket-priority: 1`,
1995
- stored in the `ab_tickets.priority` column that every listing already selects;
1996
- the ready listing orders urgent first in its existing statement, and the ticket
1997
- server applies the same stable partition to every `list-ready` response.
2066
+ Priority follows the issue-link pattern, stored in the `ab_tickets.priority`
2067
+ column that every listing already selects. Clients sending
2068
+ `x-autobuild-ticket-priority-levels: 1` see all four levels; clients sending
2069
+ only the older `x-autobuild-ticket-priority: 1` see `urgent` or `normal`
2070
+ (`high` and `low` downgrade to normal). The ready listing and default paged
2071
+ order run urgent, high, normal, low, each in filing order.
1998
2072
 
1999
2073
  Ticket integration metadata lives in `ports/tickets/tree.ts`: source compatibility
2000
2074
  normalization, capability refusal, graph validation and the pure tree projection.
2001
- Ticket priority lives in `ports/tickets/priority.ts`: the `priority` capability's
2002
- typed refusal, the normal no-op strip and `urgentFirst`, the stable partition the
2003
- dispatcher applies to its ready listing. Normalized tickets carry only `urgent`;
2004
- the hosted service answers `priority` only to clients sending its capability
2005
- header, so published strict wire schemas never see the key. The Linear adapter
2006
- maps its native Urgent priority (1) to `urgent` and, on `normal`, clears only a
2007
- current Urgent.
2075
+ Ticket priority lives in `ports/tickets/priority.ts`: the four levels
2076
+ (`TICKET_PRIORITIES`), the `priority` capability's typed refusal, the normal
2077
+ no-op strip, `dispatchPriority` (urgent tickets claim urgent builds, every other
2078
+ level normal) and `urgentFirst`, the stable partition the dispatcher applies to
2079
+ its ready listing. `ports/tickets/priority-labels.ts` holds
2080
+ `priorityLabelSource`, the label fallback the compatibility facade wraps around
2081
+ a source without the capability (GitHub, plugins): one `priority:<level>` label
2082
+ per ticket, read from labels already fetched. Normalized tickets omit normal;
2083
+ the hosted service answers `priority` only to clients sending a priority
2084
+ capability header, so published strict wire schemas never see the key. The
2085
+ Linear adapter maps Urgent, High and Low to the matching levels and Medium or
2086
+ No priority to normal; on `normal` it clears only Urgent, High or Low.
2008
2087
  File/fake/Linear adapters validate metadata at write boundaries; `operations.ts`
2009
2088
  and CLI/operator source opening wrap injected or plugin sources with the same
2010
2089
  compatibility facade. Metadata is excluded from hosted persistence/protocols.
@@ -2066,7 +2145,9 @@ different SHA) and classified transient failures never fall back. Node writes
2066
2145
  use the same order and record `node.history-retained`; node recovery restores
2067
2146
  reserved inputs before reading them and abandons a reservation whose inputs are
2068
2147
  kept nowhere. Workspace preservation (`preserveRetained`, `retainPreservedCopy`)
2069
- is strict: archive ref, else store copy, else release is refused; a reused copy
2148
+ is strict: archive ref, else store copy, else release is refused. Abort cleanup
2149
+ is the one exception: when preservation fails, `recordAbortPreservationFailure`
2150
+ records `workspace.commits-lost` and the release proceeds. A reused copy
2070
2151
  keeps its saved base, which preservation retains in turn and
2071
2152
  `restoreRetainedHead` follows to a bounded depth.
2072
2153
  GitHub uses explicit Git transport leases; local-git uses shared-database
@@ -2112,9 +2193,11 @@ A clean wait-resume `restack.completed` for a wait declared in `verify:*` or
2112
2193
  `waitResumeVerifyBoundary`, the reducer moves `verify.cycleSince`, and the
2113
2194
  engine's stage selection and cycle boundary both read it through
2114
2195
  `leafVerifyCycleInputs`. It is not a replay boundary, so the verify-entry
2115
- restack does not run again. Clean awaiting-merge leaf rewrites preserve completed
2116
- verification when build-owned config is unchanged, even when the old pin commit
2117
- is no longer an ancestor. Changed config still supersedes while waiting.
2196
+ restack does not run again. A leaf `restack.completed` carrying a frozen
2197
+ `cleanRestackPolicy` is the same kind of boundary, recorded as
2198
+ `cleanRestackVerifyBoundary`. Otherwise clean awaiting-merge leaf rewrites
2199
+ preserve completed verification when build-owned config is unchanged, even
2200
+ when the old pin commit is no longer an ancestor. Changed config still supersedes while waiting.
2118
2201
  Ancestry gates cycles that run further steps; those cycles capture fresh config.
2119
2202
  Object packs retain newly introduced replay trees/blobs as well as commit bytes.
2120
2203
  Replay retention stores 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 artifacts are read only when the requested commit is missing locally, never by idle polling.
package/docs/cli.md CHANGED
@@ -39,7 +39,7 @@ Run `bun ab <command>`; `bun ab help <command>` lists flags and subcommands. See
39
39
  - `answer` — Answer escalations or request a retry.
40
40
  - `abort` — Request irreversible build termination and cleanup.
41
41
  - `restack` — Request a node restack onto its current parent.
42
- - `priority` — Set an active build's slot-admission priority: urgent or normal.
42
+ - `priority` — Set an active build's slot-admission level: urgent, high, normal or low.
43
43
  - `objective` — Show, revise or stop an optimization node's objective and progress.
44
44
  - `hold` — Hold a merge, withdrawing consent.
45
45
  - `merge` — Consent to a ready merge.