@defrex/autobuild 1.19.0 → 1.21.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 (63) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +88 -11
  3. package/docs/architecture.md +48 -8
  4. package/docs/assets/headline-wide.png +0 -0
  5. package/docs/dispatcher-hosting.md +6 -1
  6. package/docs/dispatcher.md +2 -2
  7. package/docs/merge-policy.md +2 -1
  8. package/docs/operator-surfaces.md +1 -1
  9. package/docs/plugin-authoring.md +11 -4
  10. package/docs/process-ownership.md +43 -0
  11. package/docs/remote-store-protocol.md +7 -0
  12. package/docs/restacking.md +11 -2
  13. package/docs/setup.md +7 -2
  14. package/docs/troubleshooting.md +6 -0
  15. package/docs/verification.md +1 -1
  16. package/package.json +3 -3
  17. package/packages/core/src/cli/dashboard/model.ts +1 -0
  18. package/packages/core/src/cli/dashboard/vocabulary.ts +3 -0
  19. package/packages/core/src/cli/dispatch.ts +3 -0
  20. package/packages/core/src/events/repository.ts +45 -1
  21. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +1 -0
  22. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3f0c4e6d1d54e5bf.json +92 -0
  23. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/b440840a01ea216f.json +115 -0
  24. package/packages/core/src/kernel/dispatch-capacity.ts +47 -6
  25. package/packages/core/src/kernel/engine.ts +15 -2
  26. package/packages/core/src/kernel/janitor-failure.ts +1 -0
  27. package/packages/core/src/kernel/reducer-revisions.ts +3 -0
  28. package/packages/core/src/kernel/repository-read-facts.ts +6 -1
  29. package/packages/core/src/processes/build-runner.ts +67 -7
  30. package/packages/core/src/processes/check-termination.ts +44 -0
  31. package/packages/core/src/processes/dispatcher.ts +472 -57
  32. package/packages/core/src/processes/pass-stages.ts +94 -4
  33. package/packages/core/src/processes/publication-loss.ts +29 -0
  34. package/packages/core/src/processes/repo-view.ts +50 -10
  35. package/packages/core/src/store/contract.ts +43 -0
  36. package/packages/core/src/store/digest.ts +19 -1
  37. package/packages/core/src/store/reducer-value-shapes.json +5605 -5454
  38. package/packages/core/src/store/remote/protocol.ts +3 -0
  39. package/packages/core/src/store/remote/released-clients.json +22 -0
  40. package/packages/core/src/store/remote/released-reducer-values/1.20.0.json +36469 -0
  41. package/packages/core/src/store/remote/released-reducer-values/1.21.0.json +36612 -0
  42. package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -14
  43. package/packages/core/src/store/types.ts +5 -0
  44. package/packages/core/src/testing/reduced-read-budget.ts +412 -2
  45. package/skills/code-review/SKILL.md +5 -0
  46. package/skills/finalize/SKILL.md +5 -0
  47. package/skills/guide/SKILL.md +36 -9
  48. package/skills/guide/references/merge-policy.md +2 -1
  49. package/skills/guide/references/plugin-authoring.md +11 -4
  50. package/skills/guide/references/process-ownership.md +43 -0
  51. package/skills/guide/references/remote-store-protocol.md +7 -0
  52. package/skills/guide/references/restacking.md +11 -2
  53. package/skills/guide/references/setup.md +7 -2
  54. package/skills/harvest/SKILL.md +5 -0
  55. package/skills/harvest-review/SKILL.md +5 -0
  56. package/skills/implement/SKILL.md +5 -0
  57. package/skills/judge/SKILL.md +4 -0
  58. package/skills/operate/SKILL.md +12 -0
  59. package/skills/plan/SKILL.md +5 -0
  60. package/skills/plan-review/SKILL.md +5 -0
  61. package/skills/propose/SKILL.md +5 -0
  62. package/skills/reconcile/SKILL.md +5 -0
  63. package/templates/hosted-service/package.json +2 -2
package/README.md CHANGED
@@ -26,7 +26,7 @@ From the repository you want built, install Autobuild as a development dependenc
26
26
  <!-- release-install:start -->
27
27
 
28
28
  ```sh
29
- bun add -d --exact @defrex/autobuild@1.19.0
29
+ bun add -d --exact @defrex/autobuild@1.21.0
30
30
  ```
31
31
 
32
32
  <!-- release-install:end -->
package/SPEC.md CHANGED
@@ -197,7 +197,8 @@ forge-side backup of displaced leaf and node history and of unpublished
197
197
  workspace commits: where the forge refuses them, rewrites and node writes keep a
198
198
  BuildStore copy or warn and proceed, and workspace preservation keeps a
199
199
  BuildStore copy or refuses the release, except under abort cleanup, which
200
- records the commits lost and releases (§15.7). Results are pass, fail, or unknown; incomplete
200
+ records the commits lost and releases, and merged completion, which needs no
201
+ preservation (§15.7). Results are pass, fail, or unknown; incomplete
201
202
  inspection never proves permission. Local Git passes trivially; legacy plugins
202
203
  report unknown. Known hard failures fail init validation and produce one durable
203
204
  `dispatcher.forge-readiness-failed` repository fact per run/check; historical
@@ -2111,7 +2112,12 @@ tickets, parked admission, ticket waits) keep their order. In a bounded pass a
2111
2112
  node's integration receipts are recovered at the start of its own janitor
2112
2113
  visit, and listings are not filtered for mixed-version deferral: the build a
2113
2114
  decision reads, writes or acts on is checked itself, at most once a pass. Each
2114
- bounded pass logs `stages:` with each stage's time and items; a pass the work
2115
+ bounded pass logs `stages:` with each stage's time and items, and names every
2116
+ parked admission a stage decided with its level and outcome (`admitted`,
2117
+ `deferred` or `carried`, the last on intake, where the retry would have run);
2118
+ the deferred stage also decides parked admissions an earlier pass carried
2119
+ (§12 "Slot admission order"). The durable stage record keeps at most 1000
2120
+ admissions per stage and counts the rest as `admissionsOmitted`. A pass the work
2115
2121
  deadline cuts short logs `tick: work deadline reached during <stage>` with the
2116
2122
  part in flight and how far it got, records that partial summary in teardown,
2117
2123
  and `ab repository status` shows the latest pass as `last pass stages:`.
@@ -2201,6 +2207,14 @@ The verdict vocabulary is phase-dependent and the CLI enforces it: review
2201
2207
  phases accept `approve|revise|escalate`; agent-verify steps accept
2202
2208
  `pass|fail|skip` (`fail` requires a report; `skip` requires a reason).
2203
2209
  Deterministic checks never touch the CLI — the kernel runs them directly.
2210
+ When a check's command dies from a signal (exit status 128+N), its
2211
+ `verify-report:<step>` names the signal on its first line and records
2212
+ `signal` and `runnerShutdown` in artifact metadata. `runnerShutdown: false`
2213
+ means the runner's own shutdown was not in effect, so another process sent
2214
+ the signal; the failure is counted as usual. A check the runner's own
2215
+ shutdown kills deposits only an uncounted report artifact with
2216
+ `runnerShutdown: true` and appends no event, so no attempt is spent and the
2217
+ step reruns after relaunch. No event payload changes.
2204
2218
  Exact flags and validation live with the CLI implementation and its tests.
2205
2219
 
2206
2220
  ### 8.3 What `ab context` materializes
@@ -3407,7 +3421,35 @@ nothing and keeps the build's reservation against claims at its level; it
3407
3421
  makes that tick's admission scan due, and the deferred admissions are retried
3408
3422
  after the tick's dispatch only when that scan decided claims at every level
3409
3423
  (its claim loop ran to the end, or it proved no ticket could claim or count as
3410
- demand). Otherwise they are decided again on a later tick. A forced scan is
3424
+ demand). Otherwise an unbounded tick decides them again on a later tick. A
3425
+ bounded pass, which is a fresh process with no memory of the last one, carries
3426
+ instead every deferral whose retry did not run (its intake did not decide
3427
+ claims, the budget was spent, or the pass never reached intake): the
3428
+ `dispatcher.work-deferred` fact's `parked` entry names each deferred leaf, at
3429
+ most 64, with the occupancy its deferring measurement saw. That occupancy is
3430
+ the repository change position read before the measurement, the builds holding
3431
+ a slot, those requesting one with their level, and the open nodes whose slot
3432
+ state can change without an event on the node because it reads a clock or a
3433
+ lease (a value with no recorded admission, a never-admitted node whose legacy
3434
+ runner a live lease can evidence, and a due proposal whose eligibility reads
3435
+ the clock). The next bounded pass decides those leaves first, in its deferred
3436
+ stage, and never defers them again. It rebuilds occupancy without measuring
3437
+ the fleet: one changed-builds feed call since that position, then one reduced
3438
+ read for each recorded holder, waiter and clock-dependent node, each build
3439
+ changed since and each carried leaf. Every other open build has not changed
3440
+ and its slot state reads no clock, so it still holds and requests nothing. It
3441
+ decides against the latest durable claim demand, pending start requests,
3442
+ unresolved carried preparations and higher-level waiters, so a carried leaf
3443
+ yields to recorded higher-level demand exactly as the order says. A parked
3444
+ leaf therefore waits at most one extra pass for an intake that never
3445
+ completes. The trade is stale demand: a higher-level ticket that became ready
3446
+ after the latest admission scan can lose one slot to a carried leaf once.
3447
+ Without a usable occupancy (none recorded because it exceeded 256 holders, 64
3448
+ waiters or 64 clock-dependent nodes, or the feed reports a reset), the carried
3449
+ leaf only stays undeferred for that pass and the lease sweep decides it on its
3450
+ ordinary visit. A decided entry, admitted or not, leaves the fact; the fact is
3451
+ written at most once per pass and only when the entry changes, and an
3452
+ unbounded tick leaves it unchanged. A forced scan is
3411
3453
  bounded per deferral state: an unchanged set of deferred builds and occupancy
3412
3454
  lists again only when a scan is due on its own. Only gate-passing tickets
3413
3455
  count, so a ticket blocked on a dependency reserves nothing at any level. Free
@@ -3466,7 +3508,12 @@ A build releases its slot as soon as it waits on the outside world:
3466
3508
  | another ticket | an entered ticket wait (§11) |
3467
3509
  | the forge | a finished pipeline waiting for merge gates or for the forge to merge |
3468
3510
  | its children | an integration build with no cycle, conflict, measurement or proposal that needs a runner: collecting child work, or waiting for a repair child |
3469
- | nothing | `done` or `aborted`; abort cleanup holds no slot |
3511
+ | nothing | `done` or `aborted`; abort cleanup holds no slot; a build whose PR merged, before its completion is recorded |
3512
+
3513
+ A build whose PR merged holds and requests no slot: its work is on the target,
3514
+ and only the dispatcher's completion and cleanup remain. The janitor stops
3515
+ observing its target, so a target move after the merge raises no restack or
3516
+ `verification` request.
3470
3517
 
3471
3518
  A pipeline is finished once every verify step and every finalize post-step for
3472
3519
  the current spec has passed. The dispatcher records the finish as an advisory
@@ -5423,7 +5470,7 @@ using a slot and the word tells why.
5423
5470
  | | held | `ABORTING` | an abort was requested and the runner is still stopping |
5424
5471
  | teal (`live`) | requested | `QUEUED` | parked work waiting for admission; the note names the request (`resume`, `reconcile`, `verification`, `reopen`, `propose`) and marks urgent, high and low waiters |
5425
5472
  | amber (`held`) | none | `WAITING` | a finished pipeline waiting for a merge decision or on hold, an entered ticket wait, or a `revise-spec` answer waiting for its revision; the note says which (`merge decision`, `on hold`, `on <tickets>`, `spec revision`) |
5426
- | | none | `MERGING` | a finished pipeline with merge consent, waiting for merge gates or for the forge to merge |
5473
+ | | none | `MERGING` | a finished pipeline with merge consent, waiting for merge gates or for the forge to merge, or a merged PR whose completion is pending (note `merged`) |
5427
5474
  | | none | `PAUSED` | an acknowledged pause |
5428
5475
  | | none | `COLLECTING` | an integration build collecting child work |
5429
5476
  | red (`alert`) | none | `BLOCKED` | an open escalation, other than a ticket wait's own, or a failed node verification waiting for a repair child; the note `done` marks a completed build whose escalation awaits acknowledgement |
@@ -5436,7 +5483,8 @@ holding a slot shows them. A build without a slot keeps its word until the
5436
5483
  acknowledgement, which is not gated. A resumed pause is `QUEUED` until it is
5437
5484
  admitted again; there is no separate resuming word. The reducer's `queued` and
5438
5485
  `running` statuses are lifecycle facts, not display words: a newly claimed
5439
- build shows `STARTING`, and a settled build shows `WAITING` or `MERGING`.
5486
+ build shows `STARTING`, a settled build shows `WAITING` or `MERGING`, and a
5487
+ merged build not yet completed shows `MERGING` whatever its consent.
5440
5488
 
5441
5489
  A harvest run is never a build and never holds a slot. Its row shows
5442
5490
  `HARVESTING` (teal) while it works, `PAUSED` or `SUSPENDED` (amber) while it is
@@ -5974,6 +6022,14 @@ janitor's work set until the moves commit, and a settlement recorded on an
5974
6022
  already completed node re-arms it through the node's incrementally advanced
5975
6023
  digest, with no repository scan.
5976
6024
 
6025
+ **Pending merged release in the build digest.** The digest also folds
6026
+ `workspace.provisioned`, `workspace.cleanup-required` and `workspace.released`
6027
+ into `releasePending`, set while a completed build whose PR merged still has
6028
+ an open workspace. Like a pending attachment reclaim, it is a post-terminal
6029
+ duty: the build stays in the janitor's work set until its release lands
6030
+ (§15.7), and the flag clears through the build's incrementally advanced
6031
+ digest, with no repository scan.
6032
+
5977
6033
  **Optimization read cost.** The digest's size does not grow with settled
5978
6034
  attempts: admission caps `inFlight` plus `rejections` at the objective's concurrency, and
5979
6035
  settled attempts leave only counters. The dispatcher, the dashboards, status
@@ -6102,7 +6158,7 @@ code-review.started{r1} → code-review.verdict{approve}
6102
6158
  verify.started{types} → verify.completed{outcome:pass} → …unit
6103
6159
  verify.started{acceptance} → pr-attachment.designated{artifact,filename,mediaType} → verify.completed{outcome:pass}
6104
6160
  finalize.started → pr-attachment.hosted{designationSeq,asset} → finalize.completed{pr} → finalize.step-completed{release-notes}
6105
- (later, janitor:) pr.merged → workspace.released → build.completed{merged} → pr-attachment.reclaimed{hostedSeq}
6161
+ (later, janitor:) pr.merged → build.completed{merged} → pr-attachment.reclaimed{hostedSeq} → workspace.released
6106
6162
  ```
6107
6163
 
6108
6164
  **Interrupted dispatch:** if the log stops after `build.created`, a later
@@ -6261,8 +6317,8 @@ The setup target belongs only to escalation metadata and is not a pipeline `Phas
6261
6317
  native continuation described in §9. The following remote-sandbox recovery
6262
6318
  retains its fresh-session fallback.
6263
6319
 
6264
- Before releasing or replacing a build workspace, the dispatcher confirms a
6265
- non-destructive execution fence for the exact workspace and execution generation.
6320
+ Before releasing or replacing a build workspace, other than completing a merged
6321
+ build (§15.7), the dispatcher confirms a non-destructive execution fence for the exact workspace and execution generation.
6266
6322
  It preserves unpublished branch commits and distinct detached producer candidates
6267
6323
  under immutable `refs/autobuild/archive/<build>/<sha>` refs, verifies their exact
6268
6324
  readback, and records `workspace.commits-preserved` before cleanup. Where the
@@ -6465,6 +6521,26 @@ correlated facts; a failed delete remains pending and retries on later ticks,
6465
6521
  including after the build is already done. A fixup request for a merged or
6466
6522
  closed PR is a *new ticket*, never a reopened build.
6467
6523
 
6524
+ **Merged completion.** When the janitor sees a build's PR merged and no
6525
+ execution is live, it records `pr.merged`, moves the ticket to done and records
6526
+ `build.completed {outcome: merged}` **before** touching the workspace. The
6527
+ merged commit is on the target, so it never fences, preserves or resumes a
6528
+ merged build's workspace. Release then runs the pre-release publication guard
6529
+ without a guest resume where it can: a pending `publication.requested` whose
6530
+ commit equals the merged PR's head or landing, or that a host-side forge
6531
+ ancestry proof places below either, is recorded `publication.lost` without
6532
+ settlement; any other pending request is settled as every release settles it.
6533
+ Provider cleanup (reap or release) follows, then `workspace.released {reason:
6534
+ completion}`. A cleanup the pass cannot finish leaves the build completed with
6535
+ `releasePending` in its digest (§15.5): later janitor visits retry it, a
6536
+ deadline deferral charges nothing, and a failure is a janitor episode with its
6537
+ usual backoff and escalation. Completion never waits on cleanup. Until it is
6538
+ recorded, a merged leaf runs nothing: the engine decides `wait awaiting-pr`
6539
+ for it after operator commands, whatever phase work its log still shows, and
6540
+ the dispatcher never admits it to a slot or launches a runner for it.
6541
+ Closed-unmerged completion and every other release (abort, pause, blocked,
6542
+ replacement, discard) keep their preservation.
6543
+
6468
6544
  **Reopening a settled leaf.** An operator who wants changes to a leaf that
6469
6545
  finished its pipeline and waits for its merge decision sends it back with
6470
6546
  `ab reopen <slug> --feedback <text>`, optionally with `--revise-spec <file>` or
@@ -6606,8 +6682,9 @@ Workspace commit preservation (§12 D) is the strict exception: its unpublished
6606
6682
  commits may exist nowhere else. It tries the forge archive ref, then a
6607
6683
  `history-objects-<sha>` store copy excluding the preservation base, and never
6608
6684
  classifies a commit as `target` or proceeds unretained. When both fail, release
6609
- is refused and cleanup stays pending. Abort cleanup is the one exception: it
6610
- records `workspace.commits-lost` and releases. A history copy is identified by its head:
6685
+ is refused and cleanup stays pending. Abort cleanup is one exception: it
6686
+ records `workspace.commits-lost` and releases. Merged completion is the other:
6687
+ the merged commit is on the target, so it releases without preserving (§15.7). A history copy is identified by its head:
6611
6688
  a later retention of the same commit reuses the existing copy and its saved
6612
6689
  base. Preservation records that base and, when it is no longer an ancestor of
6613
6690
  the current preservation base, retains the base itself the same way, to a
@@ -322,7 +322,9 @@ values. Reads after an append or lost conditional append consult that boundary
322
322
  again, so no process-local memo suppresses a required delta. The adapter owns
323
323
  cache persistence and recovery; the view neither writes work bundles nor hydrates
324
324
  whole logs for decisions. The dispatcher's discovery (`refresh`) uses persisted
325
- build digests, including for settled builds. Operator passes discover through
325
+ build digests, including for settled builds. Within an epoch, a write or lease
326
+ change through the view re-reads only that build's record and digest, never the
327
+ whole roster. Operator passes discover through
326
328
  `refreshOpen` and the store's `listOpenBuilds`, which never reads a settled
327
329
  build. Raw methods forward actual cursor event output.
328
330
 
@@ -793,14 +795,15 @@ lock: a legacy dead session may remain open, while an actual takeover closes it
793
795
  explicitly.
794
796
 
795
797
  `processes/workspace-preservation.ts` owns the non-destructive fence, immutable
796
- checkpoint and durable receipt ordering shared by both release paths in the
797
- dispatcher. `ports/workspace/commit-preservation.ts` inventories the unpublished
798
+ checkpoint and durable receipt ordering shared by the dispatcher's release
799
+ paths; merged completion bypasses it (see
800
+ [Leaf and reconcile restacking](#leaf-and-reconcile-restacking)). `ports/workspace/commit-preservation.ts` inventories the unpublished
798
801
  change and restores exact refs or store copies, keeping detached producer objects
799
802
  separate from the named branch. Provider provisioning and start failures signal
800
803
  `WorkspaceCleanupRequired`; they cannot delete an existing build checkout.
801
804
 
802
- Before releasing or replacing a build workspace, the dispatcher confirms a
803
- non-destructive execution fence for the exact workspace and execution generation.
805
+ Before releasing or replacing a build workspace, other than completing a
806
+ merged build, the dispatcher confirms a non-destructive execution fence for the exact workspace and execution generation.
804
807
  It preserves unpublished branch commits and distinct detached producer candidates
805
808
  under immutable `refs/autobuild/archive/<build>/<sha>` refs, verifies their exact
806
809
  readback, and records `workspace.commits-preserved` before cleanup. Where the
@@ -826,7 +829,12 @@ cleanup records `workspace.commits-preserved` (or `workspace.commits-retained`)
826
829
  carrying forward earlier preserved heads, then releases and replaces it. Unknown fencing, inspection, transport, or
827
830
  receipt-write outcomes leave the workspace and snapshots intact, except under
828
831
  abort cleanup, which records `workspace.commits-lost` and tears the workspace
829
- down. A workspace
832
+ down. Merged completion skips this ordering: the janitor records
833
+ `build.completed` first, then releases the workspace without a fence,
834
+ preservation or resume, since the merged commit is on the target. A pending
835
+ publication still passes the merged pre-release guard before cleanup, and a
836
+ cleanup the pass cannot finish stays pending (`releasePending`) and retries
837
+ on later janitor visits. A workspace
830
838
  flagged by `workspace.cleanup-required` is never launched into: the dispatcher
831
839
  releases it and provisions the next generation. Provisioning cut off by a
832
840
  recorded dispatcher teardown is the exception: the next invocation asks the
@@ -1020,6 +1028,28 @@ deferral key, and `admitDeferredParked` retries the deferred admissions only
1020
1028
  after the scan decided claims at every level: a leaf
1021
1029
  through the build sweep, a node reconcile through `cascadeNode`, any other node
1022
1030
  need through `admitNode`, and a proposal through `admitProposers`.
1031
+ A bounded pass carries the leaf deferrals whose retry did not run (#1435).
1032
+ `leafAdmission` records each deferred leaf in `pendingParkedRetries`, and keeps
1033
+ the latest deferring measurement's occupancy as a witness (`witnessOf`): the
1034
+ repository change position read once before the first such measurement, the
1035
+ holders, the waiters with their levels, and the nodes `nodeSlotTimeDependent`
1036
+ names, the only node slot states that read a clock or a lease.
1037
+ `finalizeParkedCarries` runs once per pass, from `tick()` or from bounded
1038
+ teardown's `settleCutStarts`. It moves what remains into the hint's `parked`
1039
+ entry through `persistDeferrals`, names it on the intake stage record
1040
+ (`PassStageTracker.carriedAdmission`) and adds one deferred-diagnostics line
1041
+ per leaf. The next bounded pass loads the entry, closes the admission boundary
1042
+ for those slugs in `slotAdmission`, and `serviceCarriedAdmissions` in the
1043
+ deferred stage rebuilds occupancy from the witness plus one
1044
+ `listBuildsChangedSince` call, reading facts (`capacityBuildOf`) only for the
1045
+ witness and changed builds and the carried slugs. It then sweeps each carried
1046
+ leaf, highest level first, with that occupancy passed to `leafAdmission` as
1047
+ `measured`; the lease sweep skips it through `tickPrioritized`. Without a
1048
+ usable witness the carried leaf keeps only its closed boundary for the sweep's
1049
+ ordinary visit. Every parked admission a stage decides is recorded through
1050
+ `PassStageTracker.admission` as `admitted` or `deferred`. The in-memory record
1051
+ is uncapped; `boundStageRecords` bounds the durable copy to 1000 per stage with
1052
+ `admissionsOmitted`.
1023
1053
  Ticket waits (SPEC §11) span four seams. `cli/terminals.ts` (`waitOn`, routed
1024
1054
  as `ab wait-on`) appends the agent's terminal `wait.requested`; the build
1025
1055
  digest marks it pending. The dispatcher's lease-sweep pass validates a pending
@@ -2222,8 +2252,18 @@ use the same order and record `node.history-retained`; node recovery restores
2222
2252
  reserved inputs before reading them and abandons a reservation whose inputs are
2223
2253
  kept nowhere. Workspace preservation (`preserveRetained`, `retainPreservedCopy`)
2224
2254
  is strict: archive ref, else store copy, else release is refused. Abort cleanup
2225
- is the one exception: when preservation fails, `recordAbortPreservationFailure`
2226
- records `workspace.commits-lost` and the release proceeds. A reused copy
2255
+ is one exception: when preservation fails, `recordAbortPreservationFailure`
2256
+ records `workspace.commits-lost` and the release proceeds. Merged completion is
2257
+ the other: `releaseMergedWorkspace` runs after `build.completed` and never
2258
+ fences, preserves or resumes, because the merged commit is on the target.
2259
+ Its pre-release publication guard (`mergedHeadCovers`) treats a pending
2260
+ `publication.requested` as covered when its commit equals the merged PR's head
2261
+ or landing, or a host-side forge ancestry proof places it below either. A
2262
+ covered request is recorded `publication.lost` without settlement; an uncovered
2263
+ request, or one whose ancestry is unknown, is settled as every release settles
2264
+ it. The guard runs before provider cleanup. Completion is already recorded, so
2265
+ a cleanup the pass cannot finish leaves `releasePending` on the build's digest
2266
+ and later janitor visits retry it. A reused copy
2227
2267
  keeps its saved base, which preservation retains in turn and
2228
2268
  `restoreRetainedHead` follows to a bounded depth.
2229
2269
  GitHub uses explicit Git transport leases; local-git uses shared-database
Binary file
@@ -100,7 +100,12 @@ Deferred work is every start a pass admitted but didn't finish (a ticket
100
100
  preparation, a provision, a launch the work deadline cut, or a stopped-sandbox
101
101
  recovery); the next invocation runs it first. A ticket preparation that won't
102
102
  fit, or that the deadline cuts, keeps its ticket and is never handed back to
103
- Ready.
103
+ Ready. A parked leaf build that waited for this pass's intake to rank ticket
104
+ claims, when that intake didn't finish, is carried too. A later invocation
105
+ decides it without waiting for intake: first, when it can rebuild slot
106
+ occupancy from what the pass recorded, otherwise on the lease sweep's ordinary
107
+ visit. It's admitted only into a free slot that no recorded higher-level ticket
108
+ demand, start request or waiter takes.
104
109
 
105
110
  ### Origin-mode dispatcher with remote workspaces
106
111
 
@@ -55,7 +55,7 @@ Others stay queued. Ready tickets are claimed by level, `urgent`, `high`, `norma
55
55
 
56
56
  To start one ticket without turning intake on for the whole ready queue, run `ab start <ticket-id> [--priority manual|urgent|high|normal|low]` (or the `tickets.start` operator tool). The running dispatcher, local or hosted, claims just that ticket on its next tick with a free slot in the request's tier and records the outcome as a `ticket.start-settled` event shown by `ab watch` and `ab repository status`. The default `manual` tier goes ahead of all waiting work; the four level tiers wait their turn as described below. The ticket must still be in the ready state, meet the spec standard, have no unresolved blockers and a destination that accepts work, and is deduplicated against existing builds; capacity and repository pause still apply. Listing labels and the ready assignee are not applied, because the ticket is named. Every tier bypasses intake off and open-PR backpressure for that ticket only. See `ab help start`.
57
57
 
58
- Each build gets its own workspace (local git worktree or remote sandbox) and a build-runner that owns its pipeline. Capacity is the repository's number of slots. A build takes a slot only by admission (a ticket claim, a start request or an admitted slot request) and holds it while Autobuild owes its next move, runner or not: between phases, while provisioning, across a crashed runner or expired lease, while a requested pause or abort winds down, and while work it started outlasts a question: other steps of a verify stage, or a recorded launch and its execution. The dispatcher records `slot.admitted` before every such launch. It releases the slot as soon as it waits on the outside world: an open question nothing is still working past, an acknowledged pause, a merge decision or merge gates, or other tickets (`ab wait-on`). When that wait ends (an answer, a resume, a moved target, a conflicted PR, an ended ticket wait) the build holds no slot until it is admitted again, ahead of ticket claims at its level. Occupancy never exceeds `capacity`. Builds without a slot keep their workspaces, so retained workspaces can exceed `capacity`. An integration node takes a slot only when admitted to verify, reconcile or propose, and holds it until that work is done; it holds none while collecting children, waiting for a repair child, or blocked. See [the integration tree](integration-overview.md). `ab builds`, `ab build status` and `ab repository status` report each build's slot state; see [Operator surfaces](operator-surfaces.md).
58
+ Each build gets its own workspace (local git worktree or remote sandbox) and a build-runner that owns its pipeline. Capacity is the repository's number of slots. A build takes a slot only by admission (a ticket claim, a start request or an admitted slot request) and holds it while Autobuild owes its next move, runner or not: between phases, while provisioning, across a crashed runner or expired lease, while a requested pause or abort winds down, and while work it started outlasts a question: other steps of a verify stage, or a recorded launch and its execution. The dispatcher records `slot.admitted` before every such launch. It releases the slot as soon as it waits on the outside world: an open question nothing is still working past, an acknowledged pause, a merge decision or merge gates, or other tickets (`ab wait-on`). A build whose PR merged holds and requests no slot and runs nothing more: the janitor completes it and releases its workspace. When that wait ends (an answer, a resume, a moved target, a conflicted PR, an ended ticket wait) the build holds no slot until it is admitted again, ahead of ticket claims at its level. Occupancy never exceeds `capacity`. Builds without a slot keep their workspaces, so retained workspaces can exceed `capacity`. An integration node takes a slot only when admitted to verify, reconcile or propose, and holds it until that work is done; it holds none while collecting children, waiting for a repair child, or blocked. See [the integration tree](integration-overview.md). `ab builds`, `ab build status` and `ab repository status` report each build's slot state; see [Operator surfaces](operator-surfaces.md).
59
59
 
60
60
  ## Slot admission order
61
61
 
@@ -75,7 +75,7 @@ A free slot goes, in order, to:
75
75
  - **Build level.** A build takes its ticket's level. A build started by a non-`manual` request takes the request's level; `manual` never becomes a build level. A ticket with a pending non-`manual` request is claimed only by that request, at its tier, ahead of that level's ready tickets.
76
76
  - **Optimization attempts.** [Attempts](optimization-nodes.md#attempts) claim at the node's current level, any of the four. A later `ab priority` on the node affects attempts claimed afterwards; an already claimed attempt keeps its level.
77
77
  - **Changing a build.** `ab priority <slug> urgent|high|normal|low` (or the `builds.control` action `priority`) changes an active build's level, for example to expedite a waiting reconcile that now blocks other work, or to defer one with `low`. It never changes the ticket.
78
- - **Reservations.** A pending start request reserves its slot ahead of the tiers below it until it settles or is cancelled. Lower-level waiting work waits while gate-passing higher-level tickets are ready, until the dispatcher has offered them the free slots that tick. A ticket blocked on a dependency reserves nothing at any level.
78
+ - **Reservations.** A pending start request reserves its slot ahead of the tiers below it until it settles or is cancelled. Lower-level waiting work waits while gate-passing higher-level tickets are ready, until the dispatcher has offered them the free slots that tick. When a hosted pass's intake doesn't finish, a parked leaf build held back this way is carried: a later pass decides it without waiting for intake, against the last recorded ticket demand. Waiting nodes and proposals aren't carried; they still wait for a pass whose intake finishes. A ticket blocked on a dependency reserves nothing at any level.
79
79
  - **Unread start requests.** A tick reads at most eight `manual` and `urgent` requests and eight `high`, `normal` and `low` requests. While a request at a level is left unread, nothing below that level is admitted that tick, and that level's ready tickets wait too. That level's waiting work still goes first. A later tick reads the request once the requests ahead of it settle.
80
80
  - **No preemption.** Priority orders free slots only: it never interrupts a running build.
81
81
  - **Status.** `ab repository status`, `ab builds` and both dashboards show each waiter's level, pending start requests by tier, and higher-level ticket claims waiting ahead of lower-level waiting work.
@@ -264,7 +264,8 @@ displaced history under immutable exact archive refs
264
264
  - **Workspace preservation** keeps unpublished workspace commits under archive
265
265
  refs, else as BuildStore copies. When neither holds them, release is refused,
266
266
  except under abort cleanup, which records `workspace.commits-lost` and
267
- releases.
267
+ releases, and merged completion, which releases without preserving: the
268
+ merged commit is already on the target.
268
269
  - There is never a branch or tag fallback. When an environment refuses non-branch
269
270
  Git pushes, as Claude Code on the web's GitHub proxy does, the GitHub adapter
270
271
  creates the same archive ref through REST ref creation and confirms it by exact
@@ -72,7 +72,7 @@ Every nonterminal build row on both dashboards, `ab builds` and `ab build status
72
72
  | `ABORTING` | green | held | An abort was requested and the runner is still stopping. |
73
73
  | `QUEUED` | teal | requested | Parked work waiting for admission. The note names the request (`resume`, `reconcile`, `verification`, `reopen`, `propose`) and marks urgent, high and low waiters. |
74
74
  | `WAITING` | amber | none | A finished pipeline waiting for a merge decision (`merge decision`) or on hold (`on hold`), a ticket wait (`on <ids>`), or a `revise-spec` answer waiting for its revision (`spec revision`). |
75
- | `MERGING` | amber | none | A finished pipeline with merge consent, waiting for merge gates or the forge. |
75
+ | `MERGING` | amber | none | A finished pipeline with merge consent, waiting for merge gates or the forge, or a merged PR whose completion is pending (note `merged`). |
76
76
  | `PAUSED` | amber | none | An acknowledged pause. |
77
77
  | `COLLECTING` | amber | none | An integration build collecting child work. |
78
78
  | `BLOCKED` | red | none | An open escalation, or a failed node verification waiting for a repair child. The note `done` marks a completed build with an open escalation, such as a post-landing audit or an escalation raised during abort cleanup; the row stays until `ab answer` acknowledges it. |
@@ -136,8 +136,8 @@ applying a thin replay pack whose base is missing, and return true for an
136
136
  available leaf candidate even when archiving it is refused. Missing capabilities fail
137
137
  safely at destructive boundaries. `WorkspaceRecovery.fence(handle)` reports
138
138
  confirmed, absent, or unknown without deleting an environment or its snapshots.
139
- Only dispatcher-authorized reap follows the durable fence and preservation/loss
140
- receipt. `provision` accepts exact `restoration` heads; branch ancestry must be
139
+ Outside merged completion, dispatcher-authorized reap follows only the durable
140
+ fence and preservation/loss receipt. `provision` accepts exact `restoration` heads; branch ancestry must be
141
141
  verified, and detached producer objects must never overwrite the named branch.
142
142
  `provision` also receives `restorationArchives`: `local` for the local-git
143
143
  forge, whose repository already holds the archive refs and must not be fetched
@@ -158,9 +158,16 @@ archive transport refuses a head's archive ref, call it with your trusted Git
158
158
  transport. It keeps the head as a BuildStore copy and resolves to the copy's
159
159
  exclusion base; record the head with that `storeBase` in place of `remoteRef`.
160
160
  It throws when the head cannot be kept; rethrow so release is refused. A
161
- provider that ignores it preserves strictly. Abort cleanup is the exception:
161
+ provider that ignores it preserves strictly. Abort cleanup is one exception:
162
162
  when preservation fails, the dispatcher records the commits as lost
163
- (`workspace.commits-lost`) and releases anyway. A `restoration` head may name
163
+ (`workspace.commits-lost`) and releases anyway. Merged completion is the other:
164
+ the merged commit is on the target, so the dispatcher records `build.completed`
165
+ first, then reaps the workspace with no fence, `preserve` call or resume. A
166
+ pending publication passes the merged pre-release guard before reap. For a
167
+ merged build, `reap` can rely only on that guard having run and on the build
168
+ being terminal; it must not expect a fence or receipt, and a reap that cannot
169
+ finish stays pending and is retried on later janitor visits. Every other
170
+ release keeps the strict ordering above. A `restoration` head may name
164
171
  `storeBase` instead of `remoteRef`. Then `provision` receives
165
172
  `restoreStored({ exec, workspacePath, sha })`: when the commit is absent, call
166
173
  it with your trusted transport, and fail provisioning when it resolves false.
@@ -0,0 +1,43 @@
1
+ # Stopping processes on a shared host
2
+
3
+ Several builds' agents and the kernel's verify commands run side by side on
4
+ one host. A name or pattern kill matches every process with that name, so it
5
+ also stops other builds' work. The victim's verify check records an ordinary
6
+ failed attempt and spends verify budget, and nothing in its output tells the
7
+ kill apart from a real failure.
8
+
9
+ ## Rule
10
+
11
+ Stop only processes your session started, by the PID or process group you
12
+ recorded when you started them.
13
+
14
+ ## Forbidden
15
+
16
+ - `pkill`, `pkill -f`, `killall`, `kill $(pgrep …)`.
17
+ - Any selection by command name or pattern, including names that look like
18
+ yours: `tsc`, `node`, `bun`, browsers, dev servers.
19
+
20
+ ## Recipes
21
+
22
+ | Need | Do |
23
+ |---|---|
24
+ | Stop a background command | `cmd & pid=$!` when starting it, then `kill "$pid"` |
25
+ | Stop a process tree | `setsid cmd & pid=$!`, then `kill -TERM -- -"$pid"` |
26
+ | Bound a command's runtime | `timeout 300 cmd`, or the harness's own background-task stop |
27
+ | The PID was lost | Leave the process; it ends with the session's teardown. Never hunt for it by name. |
28
+
29
+ **Not yours:** the kernel's verify check commands and every other session's
30
+ processes, whatever their names.
31
+
32
+ ## Reading a signal-killed verify report
33
+
34
+ A check command that dies from a signal names the signal on the first line
35
+ of its `verify-report:<step>` artifact, and its metadata carries `signal` and
36
+ `runnerShutdown`.
37
+
38
+ - `runnerShutdown: false` — the runner's own shutdown was not in effect, so
39
+ another process sent the signal. Rerun the check before changing code, and
40
+ record it with `ab observe` if it recurs.
41
+ - `runnerShutdown: true` — the runner stopped the check during its own
42
+ shutdown. That is an orderly stop: not a failure, not counted, and the step
43
+ reruns after relaunch.
@@ -899,6 +899,13 @@ The member is additive and keeps the protocol version. A digest without it is
899
899
  an older service's answer: the activity pass fails closed with a typed
900
900
  capability error and never reads the build's events instead.
901
901
 
902
+ `releasePending` is `true` on a completed build whose PR merged while its
903
+ workspace is still open (no `workspace.released` after its latest
904
+ `workspace.provisioned` or `workspace.cleanup-required`). It keeps the build in
905
+ the dispatcher's janitor work set until its release lands. The member is
906
+ additive and keeps the protocol version; an older service omits it, and its
907
+ clients retry a merged build's pending release only once the service deploys.
908
+
902
909
  The digest is derived from the event log on every call — the server persists
903
910
  nothing and there is no refresh step. Protocol version `3` reshaped the
904
911
  digest's `observations` from bare sequence numbers to `{seq, ts}` pairs and
@@ -199,8 +199,17 @@ displaced heads and the temporary change, best effort, per commit:
199
199
  transaction reserves again from the published branches.
200
200
  - Workspace preservation is strict: archive ref, else a `history-objects-<sha>`
201
201
  store copy over the preservation base, else release is refused. Abort cleanup
202
- is the one exception: when preservation fails it records
203
- `workspace.commits-lost` and releases. Store-kept
202
+ is one exception: when preservation fails it records
203
+ `workspace.commits-lost` and releases. Merged completion is the other: the
204
+ merged commit is on the target, so a merged build's workspace is released
205
+ without preservation, after `build.completed` is recorded.
206
+ Before cleanup, a pending `publication.requested` is covered when its commit
207
+ equals the merged PR's head or landing, or a host-side forge ancestry proof
208
+ places it below either. A covered request is recorded `publication.lost`
209
+ without settlement; an uncovered request, or one whose ancestry is unknown,
210
+ is settled as every release settles it. A cleanup the pass cannot finish
211
+ leaves the build completed with `releasePending` set, and later janitor
212
+ visits retry it. Store-kept
204
213
  heads go on decisive `workspace.commits-retained`, and replacement
205
214
  provisioning restores them on any host.
206
215
 
package/docs/setup.md CHANGED
@@ -416,6 +416,9 @@ repositories or configuration through parent directories, including focused test
416
416
  and Git probes. Do not relocate required installed tooling or retained evidence;
417
417
  manifest-directed artifact paths remain authoritative. Never commit scratch.
418
418
 
419
+ Stop only processes the session started, by recorded PID or process group;
420
+ see [process ownership](process-ownership.md).
421
+
419
422
 
420
423
  1. Run `ab context` and read `"$AB_CONTEXT_DIR/context.json"`. The verifier receives
421
424
  `$AB_CONTEXT_DIR/spec.md`, the configured step,
@@ -519,8 +522,10 @@ Archive refs are a recommendation (WARN or UNKNOWN, never FAIL):
519
522
  build and proceed.
520
523
  - **Workspace preservation** keeps unpublished workspace commits as BuildStore
521
524
  copies where refused, and refuses to release the workspace only when the store
522
- copy fails too. Abort cleanup is the exception: it records
523
- `workspace.commits-lost` and releases.
525
+ copy fails too. Abort cleanup is one exception: it records
526
+ `workspace.commits-lost` and releases. Merged completion is the other: the
527
+ merged PR head already covers the work, so the workspace is released without
528
+ preservation after the build completes.
524
529
 
525
530
  Require **linear history** on protected root and node target branches to prevent
526
531
  merge commits from GitHub's update-branch action. On the configured root, enable
@@ -203,6 +203,12 @@ stages: settlement 3.1s 6/11 (executions 5/9, harvest 1/2, sandboxes 0/0) · jan
203
203
  - **Time and items:** each stage's seconds and the items it reached out of those it listed.
204
204
  - **`(share)`:** the stage used its share of the window and stopped starting items. In settlement, the janitor, hand-backs, dispatch recovery, resume and the lease sweep, the loop continues on the next invocation after the last item it started, so it works through its whole listing over successive passes. Priority-ordered loops (node admission, start requests, ready tickets, ticket waits) start from the top again.
205
205
  - **`(deadline)`:** the work deadline stopped the pass inside that stage. The `tick: work deadline reached during …` line names the part in flight, such as `settlement: harvest 1 of 2 (6 of 11 overall)`.
206
+ - **Parked admissions:** a stage that decided parked builds names them after its items, grouped by outcome, each with its level, for example `sweep 41.0s 12/30 (waits 0/0, sweep 12/30) (share) admitted a-fix high; deferred b-docs normal`.
207
+ - `deferred`: the build waited for this pass's intake to rank ticket claims.
208
+ - `carried`: that intake didn't finish, so a later pass decides the build without waiting for intake. A `build <slug> (<level>): parked admission carried to the next pass` line names it too.
209
+ - `admitted`: the build took a slot. A carried build is decided on the next pass's `deferred` stage when that pass can rebuild slot occupancy, otherwise on its ordinary `sweep` visit. Either way it's admitted only into a free slot that higher-level ticket demand, start requests or waiters don't take.
210
+
211
+ `ab priority <slug> urgent` isn't needed to unstick such a build.
206
212
 
207
213
  **Cause.** One visit in the named stage takes most of the window: usually a slow forge or provider call for one build.
208
214
 
@@ -55,7 +55,7 @@ For example: `steps = ["types", ["unit", "integration"], ["acceptance", "docs"]]
55
55
 
56
56
  | Kind | Runs | Outcome |
57
57
  |---|---|---|
58
- | `check` | a named `command` from `[commands]`, no agent | exit 0 passes; nonzero fails, keeping the output |
58
+ | `check` | a named `command` from `[commands]`, no agent | exit 0 passes; nonzero fails, keeping the output. A command killed by a signal says so in its report, with whether Autobuild's own shutdown was in effect; a check Autobuild's shutdown stops leaves an uncounted report and reruns |
59
59
  | `agent` | the exact `skill` you configure ([repository-local](skills.md#add-a-repository-local-skill), no prefix inferred) | `ab verdict` records pass, fail or skip |
60
60
 
61
61
  - **Pass** satisfies the member; the next stage waits for its siblings.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defrex/autobuild",
3
- "version": "1.19.0",
3
+ "version": "1.21.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.19.0",
166
- "@defrex/autobuild-vercel-sandbox": "1.19.0",
165
+ "@defrex/autobuild-postgres-store": "1.21.0",
166
+ "@defrex/autobuild-vercel-sandbox": "1.21.0",
167
167
  "@resvg/resvg-js": "2.6.2",
168
168
  "@types/bun": "^1.3.14",
169
169
  "@types/node": "^24.0.0",
@@ -536,6 +536,7 @@ export function statusBasis(state: BuildState): StatusBasis | undefined {
536
536
  ...(settled !== undefined ? { settled } : {}),
537
537
  ...(reviseSpecPending(state) ? { reviseSpec: true as const } : {}),
538
538
  ...(waitTickets?.length ? { waitTickets } : {}),
539
+ ...(state.prState === 'merged' ? { merged: true as const } : {}),
539
540
  }
540
541
  }
541
542
 
@@ -110,6 +110,8 @@ export interface StatusBasis {
110
110
  /** A completed build with an open escalation, raised after completion; it
111
111
  * rests `blocked` until an operator acknowledges it. */
112
112
  done?: true
113
+ /** The PR merged; completion is pending. A merged build holds no slot. */
114
+ merged?: true
113
115
  }
114
116
 
115
117
  /** The basis a hand-built row without one implies from its status alone. */
@@ -174,6 +176,7 @@ export function buildStatusText(input: {
174
176
  )
175
177
  // No slot: a pending pause or abort waits for its acknowledgement.
176
178
  if (basis.resting === 'blocked') return buildWord(status, 'BLOCKED')
179
+ if (basis.merged) return buildWord(status, 'MERGING', 'merged')
177
180
  if (basis.resting === 'waiting')
178
181
  return buildWord(
179
182
  status,
@@ -242,6 +242,7 @@ import {
242
242
  type TickReport,
243
243
  } from '../processes/dispatcher'
244
244
  import {
245
+ boundStageRecords,
245
246
  formatDeadlineStop,
246
247
  formatPassStages,
247
248
  type PassStageRecord,
@@ -3580,6 +3581,7 @@ class DispatchLoop {
3580
3581
  deferredDiagnostics: _deferredDiagnostics,
3581
3582
  ...counters
3582
3583
  } = merged
3584
+ if (counters.stages !== undefined) counters.stages = boundStageRecords(counters.stages)
3583
3585
  const completed = {
3584
3586
  actor: DISPATCHER,
3585
3587
  type: 'dispatcher.tick-completed' as const,
@@ -5889,6 +5891,7 @@ class DispatchLoop {
5889
5891
  deferredDiagnostics: _deferredDiagnostics,
5890
5892
  ...counters
5891
5893
  } = partial
5894
+ if (counters.stages !== undefined) counters.stages = boundStageRecords(counters.stages)
5892
5895
  await this.teardownWrite(budget)(() =>
5893
5896
  this.finishTick({ outcome: 'completed', counters }, []),
5894
5897
  )