@defrex/autobuild 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +85 -14
  3. package/docs/answering-blocked-builds.md +7 -4
  4. package/docs/architecture.md +38 -10
  5. package/docs/configuration.md +55 -5
  6. package/docs/dispatcher.md +2 -2
  7. package/docs/glossary.md +1 -1
  8. package/docs/operating.md +1 -1
  9. package/docs/operator-api.md +14 -2
  10. package/docs/plugin-authoring.md +4 -0
  11. package/docs/remote-store-protocol.md +14 -4
  12. package/docs/restacking.md +4 -0
  13. package/docs/tickets.md +1 -1
  14. package/docs/troubleshooting.md +1 -1
  15. package/package.json +3 -3
  16. package/packages/core/src/cli/attention.ts +2 -0
  17. package/packages/core/src/cli/dashboard/model.ts +14 -4
  18. package/packages/core/src/cli/dashboard/poll.ts +14 -0
  19. package/packages/core/src/cli/dashboard/render.ts +3 -0
  20. package/packages/core/src/cli/dispatch-preflight.ts +4 -1
  21. package/packages/core/src/cli/dispatch-tickets.ts +47 -0
  22. package/packages/core/src/cli/dispatch-upgrade-controller.ts +3 -0
  23. package/packages/core/src/cli/dispatch.ts +368 -98
  24. package/packages/core/src/cli/help.ts +4 -2
  25. package/packages/core/src/cli/repo-lease.ts +225 -0
  26. package/packages/core/src/cli/repository-status.ts +3 -1
  27. package/packages/core/src/cli/status.ts +13 -13
  28. package/packages/core/src/cli/wait.ts +4 -1
  29. package/packages/core/src/cli/watch.ts +15 -4
  30. package/packages/core/src/config/schema.ts +38 -2
  31. package/packages/core/src/events/catalog.ts +2 -0
  32. package/packages/core/src/events/payloads.ts +15 -0
  33. package/packages/core/src/events/policy.ts +2 -0
  34. package/packages/core/src/events/repository.ts +2 -0
  35. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +196 -230
  36. package/packages/core/src/kernel/dispatch-capacity.ts +134 -30
  37. package/packages/core/src/kernel/engine.ts +13 -6
  38. package/packages/core/src/kernel/generators/build-log.ts +9 -0
  39. package/packages/core/src/kernel/incremental-fixtures.ts +1 -0
  40. package/packages/core/src/kernel/janitor-failure.ts +85 -5
  41. package/packages/core/src/kernel/leaf-restack-state.ts +4 -2
  42. package/packages/core/src/kernel/log-index.ts +1 -1
  43. package/packages/core/src/kernel/node-landing.ts +2 -1
  44. package/packages/core/src/kernel/reducer-registry.ts +6 -1
  45. package/packages/core/src/kernel/reducer.ts +58 -4
  46. package/packages/core/src/kernel/ticket-preparation.ts +11 -7
  47. package/packages/core/src/operator/query.ts +15 -12
  48. package/packages/core/src/ports/tickets/create.ts +19 -5
  49. package/packages/core/src/ports/types.ts +4 -0
  50. package/packages/core/src/ports/workspace/commit-preservation.ts +28 -12
  51. package/packages/core/src/ports/workspace/git-worktree.ts +3 -1
  52. package/packages/core/src/ports/workspace/harvest-execution.ts +4 -2
  53. package/packages/core/src/ports/workspace/vercel-sandbox.ts +3 -0
  54. package/packages/core/src/processes/build-runner.ts +2 -1
  55. package/packages/core/src/processes/dispatcher.ts +231 -41
  56. package/packages/core/src/processes/execution-no-progress.ts +2 -0
  57. package/packages/core/src/processes/harvest-child.ts +4 -2
  58. package/packages/core/src/processes/harvest-execution-state.ts +104 -0
  59. package/packages/core/src/processes/harvest-runner.ts +246 -17
  60. package/packages/core/src/scenarios/harness.ts +145 -35
  61. package/packages/core/src/store/reduced-reads.ts +10 -0
  62. package/packages/core/src/store/reducer-value-shapes.json +1463 -1215
  63. package/packages/core/src/store/remote/released-clients.json +11 -0
  64. package/packages/core/src/store/remote/released-reducer-values/1.6.0.json +27173 -0
  65. package/packages/core/src/store/remote/released-reducer-values/index.ts +2 -0
  66. package/packages/core/src/testing/reduced-read-budget.ts +339 -2
  67. package/skills/guide/SKILL.md +53 -17
  68. package/skills/guide/references/operator-api.md +14 -2
  69. package/skills/guide/references/plugin-authoring.md +4 -0
  70. package/skills/guide/references/remote-store-protocol.md +14 -4
  71. package/skills/guide/references/restacking.md +4 -0
  72. package/skills/operate/SKILL.md +50 -11
  73. package/skills/tickets/SKILL.md +4 -2
  74. 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.5.0
29
+ bun add -d --exact @defrex/autobuild@1.6.0
30
30
  ```
31
31
 
32
32
  <!-- release-install:end -->
package/SPEC.md CHANGED
@@ -449,7 +449,7 @@ files, including development configs, remain exactly as installed.
449
449
  - **dispatcher** — watches the TicketSource for tickets passing the configured
450
450
  ready gate, claims, establishes the final conforming spec, chooses a short
451
451
  immutable build slug, provisions a workspace, and launches build-runners up
452
- to capacity. On process startup it attempts every current build for its
452
+ to capacity, which counts builds running work (§12). On process startup it attempts every current build for its
453
453
  repo, so re-running `ab dispatch` resumes durable work rather than only
454
454
  looking for new tickets. Every ordinary tick also completes queued dispatch
455
455
  records whose pre-run sequence was interrupted: it reconstructs a missing
@@ -484,6 +484,10 @@ files, including development configs, remain exactly as installed.
484
484
  ticket and attempt, whether the claim was confirmed or its provider outcome is
485
485
  unknown, and the recorded reason. If that tick fails for any reason, its
486
486
  failure error carries the diagnostics instead. Later ticks do not repeat it.
487
+ The `abandoned` resolution event records whether the claim was confirmed, and
488
+ default `ab watch` repository attention reports the same line once as it
489
+ lands, whether or not its tick failed; a fresh watch does not replay
490
+ historical abandonments.
487
491
  Recovery failures are
488
492
  reported without preventing janitor, lease sweep, or other dispatch recovery.
489
493
  This is not general process
@@ -2308,10 +2312,13 @@ loops to the configured default. The value is attached only to the matching
2308
2312
  review-limit answer, so unrelated blockers answered in the same command do not
2309
2313
  acquire it and build-phase agents cannot widen their own build's loop.
2310
2314
 
2311
- Every open escalation remains an external judgment gate until an operator answers
2312
- it. The answer may come from the operator agent or a human; build-phase agents
2313
- cannot answer their own escalations. This includes all policy and setup causes;
2314
- human authorization requirements still apply. Starting either `ab dispatch` or
2315
+ Every open phase and policy escalation remains an external judgment gate until an
2316
+ operator answers it. The answer may come from the operator agent or a human;
2317
+ build-phase agents cannot answer their own escalations. This includes all policy
2318
+ and setup causes; human authorization requirements still apply. A janitor
2319
+ escalation (Forge failure recovery) is the exception: ordinary janitor retries
2320
+ continue across startup, a successful attempt closes it without an answer, and a
2321
+ bare retry only brings the next attempt forward. Starting either `ab dispatch` or
2315
2322
  `ab dispatch --once` never appends `escalation.answered` and never re-arms a
2316
2323
  budget. Startup still recovers every actionable current build and delivers
2317
2324
  pending operator commands, whose decisions take precedence over a blocked wait;
@@ -2370,6 +2377,20 @@ creation holds, capacity, intake off and repository pause — so a blocked urgen
2370
2377
  ticket never holds back normal work. Priority never preempts: an urgent ticket
2371
2378
  does not stop, pause or displace a running build.
2372
2379
 
2380
+ **What holds a slot.** `capacity` counts builds running work. A work build that
2381
+ has finished its pipeline (every verify step and every finalize post-step for
2382
+ the current spec) holds no slot while it waits for a merge decision, for merge
2383
+ gates or the forge, or on hold, and the slot goes to the next ready ticket. The
2384
+ dispatcher records the finish as an advisory `pipeline.settled` fact when the
2385
+ engine first decides `wait awaiting-pr`. A build that has not finished keeps its
2386
+ slot, even while paused, blocked or interrupted between `finalize.completed`
2387
+ and its post-steps. When a finished build must restack, re-verify or reconcile,
2388
+ it is admitted before new ticket claims, as a node is: intake reserves a slot
2389
+ for it, and its wait records nothing, consumes no attempt and raises no
2390
+ attention. Abort and pause acknowledgements are not gated. A finished build
2391
+ keeps its workspace until it merges or closes, so retained workspaces can
2392
+ exceed `capacity`; running work cannot.
2393
+
2373
2394
  Additional scheduled ingesters such as `ingest:sentry` remain an open design
2374
2395
  thread and have no shipped config surface. Observation harvest is
2375
2396
  pressure-driven: on the existing one-pass scan of repository build streams, the
@@ -2455,7 +2476,17 @@ event-level mechanics live in the repository catalog and reducer tests):
2455
2476
  has no release and its provider reports it running (or cannot answer),
2456
2477
  dispatch launches no harvest and never judges its open session. Only after
2457
2478
  settlement records the release does the next launch record an interrupted
2458
- session, once, and recovery proceeds.
2479
+ session, once, and recovery proceeds. The guest's authority is its durable
2480
+ `harvest.execution.authorized`, not the launching invocation's repository
2481
+ lease: it never claims, renews or releases that lease, so `--once`
2482
+ teardown and a successor's acquisition neither fence it nor are blocked by
2483
+ it. At durable boundaries, at most once per heartbeat interval, it re-reads
2484
+ one constant-size served value of the current authorization and exits
2485
+ `held` once its execution was released or a later execution was
2486
+ authorized. It fails closed: an unreadable or unsupported value stops it,
2487
+ and transient read failures are tolerated for at most one lease TTL.
2488
+ Before exiting it closes any open session bracket with its transcript, so
2489
+ runner loss is judged only for real interruptions.
2459
2490
  - **The harvester only proposes.** It never claims, grooms, or dispatches a
2460
2491
  proposal, and it files every one into the same configured state rather than
2461
2492
  ranking them. Humans own Triage → Ready by default. A repository that points
@@ -2767,7 +2798,8 @@ node occupancy before the runner starts. This exception never raises the budget
2767
2798
  for new claims. Status and both dashboards report actual occupancy, configured
2768
2799
  capacity, effective display capacity and the nodes using descendant-held slots.
2769
2800
  Status, `ab builds` and both dashboards report each node waiting for a slot
2770
- ahead of new ticket claims. Idle collecting nodes remain free.
2801
+ ahead of new ticket claims, and report a finished work build waiting to run
2802
+ again the same way. Idle collecting nodes remain free.
2771
2803
 
2772
2804
  An empty node has no PR and reports `integration`, `target`, and `empty`.
2773
2805
  Once it holds commits its current parent lacks, the dispatcher opens or adopts
@@ -3153,6 +3185,25 @@ stands in for tick completion. Telemetry survives lease release. Safe shutdown
3153
3185
  uses the matching run's open observation, historical journal boundaries when
3154
3186
  absent, and refuses forced termination when the observation cannot be read.
3155
3187
 
3188
+ The repository dispatch lease lasts `policy.dispatchLeaseTimeoutSeconds`
3189
+ without renewal (60 by default) and is renewed every
3190
+ `policy.dispatchLeaseRenewalSeconds` (20 by default; it must be less than the
3191
+ timeout). A claim stores the timeout with the lease, so a reloaded pair is
3192
+ adopted at the next tick through a same-holder claim. Claims and adoption are
3193
+ serialized, and a renewal answered under an earlier pair is discarded, so the
3194
+ holder's local deadline never outlasts the stored expiry. A holder whose own
3195
+ lease lapsed — a host stall longer than the timeout, or renewals lost to a store
3196
+ outage — starts no ticket claim, launch, execution start, provisioning, forge
3197
+ write, `git push` or status publication, including from a continuation that
3198
+ resumes mid-operation; those effects are fenced where they are called. It then
3199
+ reads the repository record: when the record still names it, expired or not, it
3200
+ claims the lease again and carries on; when the record names another run, or
3201
+ there is no record (only a holder's release clears it), it stops as
3202
+ `superseded`. An expired lease of its own is never treated as a takeover, and it
3203
+ never records a `tick-yielded` naming itself. A store error is retried at the
3204
+ next renewal or tick. An effect already in flight when the stall began
3205
+ completes; cancelling it could tear external state.
3206
+
3156
3207
  Both dashboards show each accepted unfinished generation handoff, naming its source
3157
3208
  and target runtimes (version and abbreviated commit), mode and drain deadline
3158
3209
  (`unknown` for missing historical facts). A drain-mode outstanding execution
@@ -3648,7 +3699,9 @@ non-destructive execution fence for the exact workspace and execution generation
3648
3699
  It preserves unpublished branch commits and distinct detached producer candidates
3649
3700
  under immutable `refs/autobuild/archive/<build>/<sha>` refs, verifies their exact
3650
3701
  readback, and records `workspace.commits-preserved` before cleanup. Replacement
3651
- provisioning restores those exact refs before starting an agent. A preserved
3702
+ provisioning restores those exact refs before starting an agent, reading them
3703
+ from the local repository with the local-git forge and fetching each exact ref
3704
+ from the remote otherwise. A preserved
3652
3705
  branch head that the build's latest 64 replaced heads cover, as the replaced
3653
3706
  head itself or one of its ancestors, is kept only as archived objects: it is
3654
3707
  never preserved or restored as the branch, and provisioning records the skip as
@@ -3775,6 +3828,11 @@ and `verify.config-superseded` (§16.1). These facts do not change reconcile
3775
3828
  identity or its policy snapshot; replay gates still refer to the code/reconcile
3776
3829
  boundary. Superseded receipts remain historical evidence.
3777
3830
 
3831
+ `pipeline.settled { cycle }` is advisory capacity evidence. The dispatcher
3832
+ appends it once per settlement key (the later of the current verify cycle start
3833
+ and the latest `finalize.completed`) when the engine decides `wait awaiting-pr`;
3834
+ no pipeline decision reads it (§12).
3835
+
3778
3836
  ### 15.7 Post-PR lifecycle [D1 — confirmed]
3779
3837
 
3780
3838
  Walking the happy path exposed a gap in the grammar: `finalize` creates the
@@ -4158,7 +4216,7 @@ and default-attribution fields remain replay-compatible but are not new controls
4158
4216
 
4159
4217
  ```toml
4160
4218
  baseBranch = "main"
4161
- capacity = 3 # concurrent builds for this repo
4219
+ capacity = 3 # builds running work at once; builds parked for a merge decision hold no slot
4162
4220
  ticketScanIntervalSeconds = 60 # positive integer; ready scans, with tick spacing as floor
4163
4221
  forge = "github" # builtin: github | local-git; or a plugin name
4164
4222
  plugins = ["./plugins/local.ts", "@acme/autobuild-plugin"]
@@ -4218,6 +4276,8 @@ sessionBudgetSeconds = 7200 # optional role override
4218
4276
 
4219
4277
  [policy]
4220
4278
  upgradeDrainSeconds = 900 # local generation drain deadline, hot-reloaded
4279
+ dispatchLeaseTimeoutSeconds = 60 # repository dispatch lease lifetime without renewal
4280
+ dispatchLeaseRenewalSeconds = 20 # renewal interval; less than the timeout
4221
4281
  sessionBudgetSeconds = 3600 # non-infinite default for build agent sessions
4222
4282
  stallRounds = 3
4223
4283
  maxVerifyAttempts = 3
@@ -4789,11 +4849,22 @@ their existing handling.
4789
4849
  Janitor failures are durable per-build episodes. Eligible failures retry after
4790
4850
  30, 60, 120, 240 seconds, then at the configured cap (300 seconds by default).
4791
4851
  A classified forge rate limit is repository cooldown, not a janitor failure:
4792
- neither the first limited response nor the cooldown that follows starts or ages
4793
- an episode. Skipped polls preserve the episode across restart. After
4794
- `policy.janitorFailureAttentionSeconds` (600 by default), `build.janitor-failing`
4795
- notifies default watchers and appears on the build row. A successful attempt
4796
- clears it. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
4852
+ neither the first limited response nor the cooldown that follows starts an
4853
+ episode or records an attempt, so a build that only waits out cooldown never
4854
+ escalates. Skipped polls preserve the episode across restart. Both thresholds
4855
+ below are wall-clock from the episode's first failed attempt and are checked
4856
+ when an attempt fails, so cooldown inside an episode that already started still
4857
+ counts. After `policy.janitorFailureAttentionSeconds` (600 by default),
4858
+ `build.janitor-failing` notifies default watchers and appears on the build row.
4859
+ After `policy.janitorFailureEscalationSeconds` (3600 by default), the build
4860
+ raises one escalation through `build.janitor-escalated`, naming the failing
4861
+ operation, the last error, the failed attempt count and when the episode
4862
+ started. The build is then blocked and shows wherever open escalations show.
4863
+ The janitor keeps retrying on its backoff underneath; a successful attempt
4864
+ clears the attention, closes the escalation unanswered and the build continues.
4865
+ Answering it with a bare retry makes the janitor attempt on its next tick. An
4866
+ episode raises at most one escalation; a new episode after recovery can raise
4867
+ another. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
4797
4868
  A dispatcher that cannot execute Git for kernel node work (a missing or
4798
4869
  unloadable `git` for the bare clone) records no janitor failures. It records
4799
4870
  one durable `dispatcher.kernel-git-unavailable` repository condition, node work
@@ -36,10 +36,13 @@ normal action. The selected build's full detail names the CLI-only dismissal
36
36
  and revision commands; it does not provide a spec editor.
37
37
 
38
38
  Restarting `ab dispatch` or running `ab dispatch --once` is not an answer or a
39
- retry action. Every open escalation, including every policy and setup cause,
40
- survives dispatcher startup until your operator agent, within your instructions
41
- and authority, or you answer through one of the paths above. Startup
42
- still recovers unblocked work and acknowledges pending operator commands.
39
+ retry action. Every open phase and policy escalation, including every setup
40
+ cause, survives dispatcher startup until your operator agent, within your
41
+ instructions and authority, or you answer through one of the paths above. A
42
+ janitor escalation is the exception: its ordinary retries continue across
43
+ startup, a successful attempt closes it unanswered, and a bare retry only brings
44
+ the next attempt forward. Startup still recovers unblocked work and acknowledges
45
+ pending operator commands.
43
46
 
44
47
  ## Widening an exhausted review loop
45
48
 
@@ -17,9 +17,12 @@ disagree, the code is authoritative.
17
17
  validation and fail-safe fallback.
18
18
  2. **Resumability is not a feature.** Re-running `ab dispatch` attempts every
19
19
  actionable current build; each phase resumes as a function of durable state.
20
- Open escalations remain parked until an external answer, from the operator
21
- agent or you, is recorded; a build-phase agent never answers its own
22
- escalation. Pending operator commands remain actionable.
20
+ Startup is not an answer or a retry. Open phase and policy escalations
21
+ remain parked until an external answer, from the operator agent or you, is
22
+ recorded; a build-phase agent never answers its own escalation. Ordinary
23
+ janitor retries continue across startup, and a successful attempt closes a
24
+ janitor escalation unanswered; a bare retry only brings the next attempt
25
+ forward. Pending operator commands remain actionable.
23
26
  3. **Ingesters propose, humans dispatch.** Nothing auto-generated passes
24
27
  Triage without a human grooming it to Ready, unless the repository waives
25
28
  that gate explicitly with `[tickets].proposalState`.
@@ -633,7 +636,9 @@ non-destructive execution fence for the exact workspace and execution generation
633
636
  It preserves unpublished branch commits and distinct detached producer candidates
634
637
  under immutable `refs/autobuild/archive/<build>/<sha>` refs, verifies their exact
635
638
  readback, and records `workspace.commits-preserved` before cleanup. Replacement
636
- provisioning restores those exact refs before starting an agent. A preserved
639
+ provisioning restores those exact refs before starting an agent, reading them
640
+ from the local repository with the local-git forge and fetching each exact ref
641
+ from the remote otherwise. A preserved
637
642
  branch head that the build's latest 64 replaced heads cover, as the replaced
638
643
  head itself or one of its ancestors, is kept only as archived objects: it is
639
644
  never preserved or restored as the branch, and provisioning records the skip as
@@ -700,6 +705,9 @@ per client and fall back to full artifact reads, never event replay.
700
705
  build-owned identity and source ancestry at settled stage boundaries. Typed
701
706
  `verify.config-captured` and `verify.config-superseded` facts advance the result
702
707
  boundary in the reducer and log index, independently of reconcile identity.
708
+ The advisory `pipeline.settled` fact records that the engine reached a leaf's
709
+ `wait awaiting-pr`; `kernel/dispatch-capacity.ts` reads it so a finished build
710
+ parked for its merge decision holds no slot.
703
711
  The runner refreshes after workspace mutation and before constructing members;
704
712
  concurrent siblings settle before another stage is selected. Recovery and
705
713
  readiness compose live deployment settings onto the captured artifact revision.
@@ -1308,6 +1316,10 @@ that records the abandonment reports one dispatcher diagnostic naming the
1308
1316
  ticket and attempt, whether the claim was confirmed or its provider outcome is
1309
1317
  unknown, and the recorded reason. If that tick fails for any reason, its
1310
1318
  failure error carries the diagnostics instead. Later ticks do not repeat it.
1319
+ The `abandoned` resolution event records whether the claim was confirmed, and
1320
+ default `ab watch` repository attention reports the same line once as it lands,
1321
+ whether or not its tick failed; a fresh watch does not replay historical
1322
+ abandonments.
1311
1323
  Recovery failures are
1312
1324
  reported without preventing janitor, lease sweep, or other dispatch recovery.
1313
1325
  This is not general process
@@ -1486,7 +1498,12 @@ execution and adopted lease holder; the guest resumes only that prepared run.
1486
1498
  Local completion records `harvest.execution.ended`; hosted completion retains
1487
1499
  its provider release fact. While an observable hosted execution is open, the
1488
1500
  dispatcher withholds harvest launch, so runner loss on its open session is
1489
- judged only after its release fact. Recovery controls remain trusted dispatcher work.
1501
+ judged only after its release fact. The guest's authority is that
1502
+ authorization, not the launching invocation's lease, which it never claims,
1503
+ renews or releases: at durable boundaries it re-reads the constant-size
1504
+ `hostedHarvestAuthority` value (`processes/harvest-execution-state.ts`) and
1505
+ exits `held`, closing its open session bracket, once its execution was
1506
+ released or replaced. Recovery controls remain trusted dispatcher work.
1490
1507
  Execution launch auth is transient and separate from serialized identity. Runners
1491
1508
  request exact phase grants after session-start facts and before runtime calls.
1492
1509
  Workspace plugin factories receive an exchange callback and a scrubbed environment,
@@ -1958,11 +1975,22 @@ one more PR create; an abort answer stops retrying so release can proceed.
1958
1975
  Janitor failures are durable per-build episodes. Eligible failures retry after
1959
1976
  30, 60, 120, 240 seconds, then at the configured cap (300 seconds by default).
1960
1977
  A classified forge rate limit is repository cooldown, not a janitor failure:
1961
- neither the first limited response nor the cooldown that follows starts or ages
1962
- an episode. Skipped polls preserve the episode across restart. After
1963
- `policy.janitorFailureAttentionSeconds` (600 by default), `build.janitor-failing`
1964
- notifies default watchers and appears on the build row. A successful attempt
1965
- clears it. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
1978
+ neither the first limited response nor the cooldown that follows starts an
1979
+ episode or records an attempt, so a build that only waits out cooldown never
1980
+ escalates. Skipped polls preserve the episode across restart. Both thresholds
1981
+ below are wall-clock from the episode's first failed attempt and are checked
1982
+ when an attempt fails, so cooldown inside an episode that already started still
1983
+ counts. After `policy.janitorFailureAttentionSeconds` (600 by default),
1984
+ `build.janitor-failing` notifies default watchers and appears on the build row.
1985
+ After `policy.janitorFailureEscalationSeconds` (3600 by default), the build
1986
+ raises one escalation through `build.janitor-escalated`, naming the failing
1987
+ operation, the last error, the failed attempt count and when the episode
1988
+ started. The build is then blocked and shows wherever open escalations show.
1989
+ The janitor keeps retrying on its backoff underneath; a successful attempt
1990
+ clears the attention, closes the escalation unanswered and the build continues.
1991
+ Answering it with a bare retry makes the janitor attempt on its next tick. An
1992
+ episode raises at most one escalation; a new episode after recovery can raise
1993
+ another. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
1966
1994
  A dispatcher that cannot execute Git for kernel node work (a missing or
1967
1995
  unloadable `git` for the bare clone) records no janitor failures. It records
1968
1996
  one durable `dispatcher.kernel-git-unavailable` repository condition, node work
@@ -441,7 +441,7 @@ any table header.
441
441
  - **Required:** Optional
442
442
  - **Reload:** Hot: next dispatcher action captures the accepted value. A running invocation keeps its captured values.
443
443
 
444
- **Description:** Concurrent occupied slots for this repository. Paused and blocked work retains slots. Node reconcile and verification exclude their own blocked/paused descendants at admission; new claims use total occupancy. See [integration capacity](integration-tree.md).
444
+ **Description:** Builds running work at once for this repository. A build that finished its pipeline holds no slot while it waits for a merge decision; it is admitted ahead of new claims when it must run again. Unfinished paused and blocked work retains slots. Node reconcile and verification exclude their own blocked/paused descendants at admission; new claims use total occupancy. See [integration capacity](integration-tree.md).
445
445
 
446
446
  **Constraints:** safe integer; > 0
447
447
 
@@ -2422,6 +2422,32 @@ Optional. Every field receives its own default. All are positive integers except
2422
2422
 
2423
2423
  **Constraints:** safe integer; > 0
2424
2424
 
2425
+ #### `policy.dispatchLeaseTimeoutSeconds`
2426
+
2427
+ **TOML key:** `policy.dispatchLeaseTimeoutSeconds`
2428
+
2429
+ - **Type:** `number`
2430
+ - **Default:** `60`
2431
+ - **Required:** Optional
2432
+ - **Reload:** Hot: next dispatcher action captures the accepted value. A running invocation keeps its captured values.
2433
+
2434
+ **Description:** How long the repository dispatch lease survives without renewal. A dispatcher that stalls longer reclaims it on waking unless another run took it; a standby takes over a dead holder within this bound. A change takes effect at the dispatcher's next tick.
2435
+
2436
+ **Constraints:** safe integer; > 0; Must be greater than `dispatchLeaseRenewalSeconds`.
2437
+
2438
+ #### `policy.dispatchLeaseRenewalSeconds`
2439
+
2440
+ **TOML key:** `policy.dispatchLeaseRenewalSeconds`
2441
+
2442
+ - **Type:** `number`
2443
+ - **Default:** `20`
2444
+ - **Required:** Optional
2445
+ - **Reload:** Hot: next dispatcher action captures the accepted value. A running invocation keeps its captured values.
2446
+
2447
+ **Description:** Interval between repository dispatch lease renewals; adopted together with the timeout.
2448
+
2449
+ **Constraints:** safe integer; > 0; Must be less than `dispatchLeaseTimeoutSeconds`.
2450
+
2425
2451
  #### `policy.sessionBudgetSeconds`
2426
2452
 
2427
2453
  **TOML key:** `policy.sessionBudgetSeconds`
@@ -2552,6 +2578,19 @@ Optional. Every field receives its own default. All are positive integers except
2552
2578
 
2553
2579
  **Constraints:** safe integer; > 0
2554
2580
 
2581
+ #### `policy.janitorFailureEscalationSeconds`
2582
+
2583
+ **TOML key:** `policy.janitorFailureEscalationSeconds`
2584
+
2585
+ - **Type:** `number`
2586
+ - **Default:** `3600`
2587
+ - **Required:** Optional
2588
+ - **Reload:** Hot: next dispatcher action captures the accepted value. A running invocation keeps its captured values.
2589
+
2590
+ **Description:** Consecutive janitor failure duration before the build raises one escalation; the janitor keeps retrying.
2591
+
2592
+ **Constraints:** safe integer; > 0
2593
+
2555
2594
  #### `policy.nodeIdleAfterSeconds`
2556
2595
 
2557
2596
  **TOML key:** `policy.nodeIdleAfterSeconds`
@@ -2661,8 +2700,16 @@ Unclaimed observation pressure is not shown in the dashboard header, which
2661
2700
  reads `triage <count> | queue <depth> | active <current>/<limit>`. A running or
2662
2701
  paused Harvest row shows its run's observations, and `ab harvest status`
2663
2702
  reports Harvest state. Neither `policy.harvestThreshold` nor
2664
- `policy.harvestMaxDrift` is displayed in the header. The repository lease and fixed per-run recovery budget are implementation
2665
- invariants, not additional configuration fields.
2703
+ `policy.harvestMaxDrift` is displayed in the header. The fixed per-run recovery budget is an implementation
2704
+ invariant, not an additional configuration field.
2705
+
2706
+ The repository dispatch lease is configured by
2707
+ `policy.dispatchLeaseTimeoutSeconds` (default 60) and
2708
+ `policy.dispatchLeaseRenewalSeconds` (default 20). The renewal interval must be
2709
+ less than the timeout; configuration that breaks this is refused when it loads.
2710
+ A dispatcher adopts a changed pair at its next tick. A dispatcher that stalls
2711
+ longer than the timeout reclaims its lease on waking unless another dispatcher
2712
+ took it, and a standby takes over from a dead holder within the timeout.
2666
2713
 
2667
2714
  ## `[tickets]`
2668
2715
 
@@ -3563,8 +3610,11 @@ action. Check the gates in this order:
3563
3610
  5. **Dependencies:** every `blockedBy` ticket must exist and be complete in the
3564
3611
  same source. This includes harvest proposals filed directly into the ready
3565
3612
  state. Plain dispatch output reports unresolved ids and cycles.
3566
- 6. **Capacity:** every nonterminal build for this repository—including paused
3567
- and blocked builds—uses a slot. Inspect `ab builds --queued` and
3613
+ 6. **Capacity:** every unfinished build for this repository—including paused
3614
+ and blocked builds—uses a slot. A build that has finished its pipeline and
3615
+ waits for a merge decision holds none, but one that must re-verify or
3616
+ reconcile is admitted ahead of new claims and reserves a slot while it
3617
+ waits. Inspect `ab repository status`, `ab builds --queued` and
3568
3618
  `ab build status <slug>` rather than looking only for a live process.
3569
3619
  7. **Duplicate work:** a ready ticket already represented by an active build is
3570
3620
  deliberately excluded from the queue.
@@ -50,7 +50,7 @@ A ticket is claimed when it passes every gate:
50
50
 
51
51
  Others stay queued. Urgent tickets are claimed before normal ones, each in the source's order; priority never preempts a running build. See [Tickets and specs](tickets.md) for grooming and [Intake and harvest](intake.md) for proposed work.
52
52
 
53
- Each build gets its own workspace (local git worktree or remote sandbox) and a build-runner that owns its pipeline. Capacity caps concurrency: a work build holds a slot while it runs; an integration node holds one only while it verifies, not while collecting children. See [the integration tree](integration-overview.md).
53
+ Each build gets its own workspace (local git worktree or remote sandbox) and a build-runner that owns its pipeline. Capacity caps the builds running work: a work build holds a slot until it finishes its pipeline (verification and finalize), even while paused or blocked. Once it waits for a merge decision it holds none; if its target moves or its PR conflicts, it waits for a slot ahead of new claims to restack, re-verify or reconcile. It keeps its workspace until it merges or closes, so retained workspaces can exceed `capacity` while running work cannot. An integration node holds a slot only while it verifies, not while collecting children. See [the integration tree](integration-overview.md).
54
54
 
55
55
 
56
56
  ## The log is the source of truth
@@ -70,7 +70,7 @@ Agents report through the typed `ab` CLI (`ab done`, `ab verdict`), not their ou
70
70
 
71
71
  A restart loses nothing. The dispatcher continues each build from its recorded phase, completed boundaries, artifacts and feedback, even in a replacement sandbox. Authority boundaries hold:
72
72
 
73
- - Unanswered escalations stay parked until your operator agent answers.
73
+ - Unanswered phase and policy escalations stay parked until your operator agent answers. A janitor escalation keeps retrying and closes unanswered when an attempt succeeds.
74
74
  - Pending operator commands and actionable work proceed.
75
75
  - A restart never grants permission or resets an exhausted retry budget.
76
76
 
package/docs/glossary.md CHANGED
@@ -41,7 +41,7 @@ A deterministic check or evidence-judging agent that tests a build against its c
41
41
 
42
42
  ## Escalation
43
43
 
44
- A durable question or failure that parks work until answered with guidance or a retry through the [answer interface](operating.md#answer-and-pause).
44
+ A durable question or failure that parks work until answered with guidance or a retry through the [answer interface](operating.md#answer-and-pause); a janitor escalation instead keeps retrying and closes unanswered when an attempt succeeds.
45
45
 
46
46
  ## Merge
47
47
 
package/docs/operating.md CHANGED
@@ -99,7 +99,7 @@ Existing attention returns immediately, even with a cursor, so looping `wait` do
99
99
  bun ab answer my-build "Keep the public API compatible"
100
100
  ```
101
101
 
102
- An escalation parks work until answered; guidance feeds the next round. `answer` also accepts a bare retry and spec-revision resolutions for when the contract must change; see `bun ab help answer`.
102
+ A phase or policy escalation parks work until answered; guidance feeds the next round. A janitor escalation keeps retrying across dispatcher restarts and closes unanswered when an attempt succeeds; a bare retry only brings the next attempt forward. `answer` also accepts a bare retry and spec-revision resolutions for when the contract must change; see `bun ab help answer`.
103
103
 
104
104
  ```
105
105
  bun ab pause my-build
@@ -268,6 +268,9 @@ expiry. Successor loss and upgrade-failure/rollback attention remain independent
268
268
  `observation` instead of `event`, with run, observedAt, leaseExpiresAt and available
269
269
  identity, plus the usual repo/build/state/cursor fields. It invents no durable
270
270
  sequence or actor. Retain the cursor to avoid repeat reports across invocations.
271
+ A loss can be transient: a holder that stalled past
272
+ `policy.dispatchLeaseTimeoutSeconds` with no successor reclaims its lease on
273
+ waking and returns to `held`.
271
274
  A watch retains sampled owners after authoritative lease release. Once-run teardown
272
275
  stops heartbeat and releases only its own lease; release is best effort because
273
276
  expiry fences ambiguous ownership. A retained sample or failed release cannot
@@ -282,6 +285,7 @@ The default watch reports actionable conditions only:
282
285
  - `integration.verification-failed`: failed node verification, once per prepared cycle, with failed steps, verified head and parent, and guidance to file a repair child targeting the node. Recovery reports only the latest prepared cycle while its head and parent remain current; superseded failures are not backfilled.
283
286
 
284
287
  - `build.janitor-failing`: a build has reached the configured consecutive-failure threshold; a successful janitor attempt clears it.
288
+ - `build.janitor-escalated`: a build's janitor failure episode outlasted `policy.janitorFailureEscalationSeconds` and raised one escalation naming the operation, last error, attempt count and episode start. The janitor keeps retrying; a successful attempt closes the escalation, and a bare retry answer attempts on the next tick.
285
289
  - `dispatcher.forge-persistent`: forge degradation remains after a completed post-reset retry opportunity; successful recovery clears it.
286
290
 
287
291
  - Build `escalation.raised`, `integration.landed`, `node.item-conflicted`, `target.rewritten`, or
@@ -295,6 +299,13 @@ The default watch reports actionable conditions only:
295
299
  `dispatcher.config-rejected`, `dispatcher.config-reloaded` with nonempty
296
300
  `restartRequired`, `dispatcher.upgrade-failed`, `dispatcher.runtime-rolled-back`,
297
301
  `dispatcher.kernel-git-unavailable`, abnormal `dispatcher.run-stopped`, and `dispatcher.lost`.
302
+ - Repository `ticket-preparation.resolved` with outcome `abandoned`: automatic
303
+ preparation recovery stopped and left the ticket unchanged. The line names the
304
+ ticket, attempt and recorded reason; the payload's `claimed` says whether the
305
+ claim was confirmed. An unconfirmed claim's provider outcome is unknown, and
306
+ events written before `claimed` existed report the certainty as not recorded.
307
+ Each abandonment reports once as it lands; a fresh watch does not replay
308
+ historical ones, and nothing clears or acknowledges it.
298
309
  - `dispatcher.ticket-source-persistent`: degradation past its advertised
299
310
  reset time, once a tick started at or after reset has completed or failed
300
311
  with the episode still open; crossing reset alone is silent. Without a reset,
@@ -377,10 +388,11 @@ HTTP merge controls retain the wire actions `land` and `hold` with acknowledged
377
388
  requires readiness and survives restacks; hold persists until merge. Repository
378
389
  auto-merge settings are retired; configure ordered `[[merge]]` rules.
379
390
 
380
- Default attention includes `build.janitor-failing` and
391
+ Default attention includes `build.janitor-failing`, `build.janitor-escalated` and
381
392
  `dispatcher.forge-persistent`. Raw `dispatcher.forge-degraded` and
382
393
  `dispatcher.forge-recovered` facts are available through explicit event filters.
383
- Active janitor attention clears on a successful attempt. Repository status
394
+ Active janitor attention and an open janitor escalation clear on a successful
395
+ attempt. Repository status
384
396
  includes forge degradation/reset and available request counts; `dispatcher.forge-persistent` requires a completed retry opportunity past
385
397
  the original reset, which later rate limits cannot postpone indefinitely.
386
398
 
@@ -120,6 +120,10 @@ confirmed, absent, or unknown without deleting an environment or its snapshots.
120
120
  Only dispatcher-authorized reap follows the durable fence and preservation/loss
121
121
  receipt. `provision` accepts exact `restoration` heads; branch ancestry must be
122
122
  verified, and detached producer objects must never overwrite the named branch.
123
+ `provision` also receives `restorationArchives`: `local` for the local-git
124
+ forge, whose repository already holds the archive refs and must not be fetched
125
+ from, and `remote` otherwise, in which case a provider sharing the repository
126
+ must fetch each exact archive ref from origin before verifying it.
123
127
  `preserve` receives `replaced`, and `provision` receives `restorationReplaced`:
124
128
  the build's bounded record of the latest 64 shas recorded rewrites replaced.
125
129
  A branch head equal to or contained in one of them is superseded. Preserve
@@ -529,7 +529,7 @@ client version window are unchanged.
529
529
  | Scope | Reducers with no arguments |
530
530
  | --- | --- |
531
531
  | Build | `executionNoProgress`, `summaryRequests`, `build`, `buildDigest`, `currentPrAttachments`, `pendingPrAttachmentReclaims`, `openExecution`, `lastExecutionOutcome`, `infrastructureFailureReset`, `openWorkspace`, `setupStreak`, `openBuildWorkspace`, `currentDeferralObservation`, `dashboardFacts`, `pinnedAssets`, `buildDelegation` |
532
- | Repository | `dispatchPlacement`, `ticketPreparation`, `harvest`, `dispatchSettings`, `sandboxStates`, `openHarvestExecutions`, `autoMergeDefault`, `effectiveConfig`, `harvestDelegation` |
532
+ | Repository | `dispatchPlacement`, `ticketPreparation`, `harvest`, `dispatchSettings`, `sandboxStates`, `openHarvestExecutions`, `hostedHarvestAuthority`, `autoMergeDefault`, `effectiveConfig`, `harvestDelegation` |
533
533
 
534
534
  | Reducer | Scope | Required arguments |
535
535
  | --- | --- | --- |
@@ -542,7 +542,12 @@ another's accumulator. `effectiveConfig` returns an object with optional `run`
542
542
  and `reference: {kind, rev}`. Absence is distinct from an unreadable referenced
543
543
  artifact. Delegation values contain semantic lifecycle facts indexed by prefixed
544
544
  identifiers, not authorization decisions; request time and grace expiry are
545
- always evaluated against those facts on the service.
545
+ always evaluated against those facts on the service. `hostedHarvestAuthority`
546
+ returns `{current?: {execution, run, leaseHolder, released}}`: the latest
547
+ `harvest.execution.authorized` and whether that execution has since ended or
548
+ been released. Its size does not grow with harvest history; a hosted harvest
549
+ guest re-reads it at durable boundaries to decide whether it still holds
550
+ authority, and a server that does not serve it stops the guest.
546
551
 
547
552
  Each remaining registered reducer is explicitly excluded:
548
553
 
@@ -1266,8 +1271,13 @@ or invoke operator APIs. Harvest writes require the exact run in event payloads
1266
1271
  and artifact metadata; artifacts use the harvest kinds. Every artifact in an
1267
1272
  atomic deposit is checked before writing. Harvest streams have an immutable
1268
1273
  `harvest:<run>:<execution>:` label namespace. Addressed streams resolve their actual owner;
1269
- a guessed ID cannot bypass the boundary. Only the runner can heartbeat or re-acquire its exact
1270
- adopted repository lease holder; another current holder still fences it. Recovery acknowledgements remain dispatcher-side.
1274
+ a guessed ID cannot bypass the boundary. A harvest-runner grant may heartbeat or re-acquire
1275
+ only its exact adopted repository lease holder, and another current holder fences those lease
1276
+ calls. That lease permission is not the prepared guest's execution authority: the guest neither
1277
+ heartbeats, reclaims nor releases the invocation lease, so routine `--once` teardown or a
1278
+ successor invocation's lease acquisition alone does not fence it. The guest instead reads
1279
+ `hostedHarvestAuthority` at durable boundaries and stops when its execution authorization is
1280
+ released or replaced, or when that verification fails. Recovery acknowledgements remain dispatcher-side.
1271
1281
 
1272
1282
  Hosted ticket access is gated by grant kind. Build-runner and build-phase grants
1273
1283
  cannot call ticket routes. Harvest-phase grants may call only list-ready,
@@ -258,6 +258,10 @@ that records the abandonment reports one dispatcher diagnostic naming the
258
258
  ticket and attempt, whether the claim was confirmed or its provider outcome is
259
259
  unknown, and the recorded reason. If that tick fails for any reason, its
260
260
  failure error carries the diagnostics instead. Later ticks do not repeat it.
261
+ The `abandoned` resolution event records whether the claim was confirmed, and
262
+ default `ab watch` repository attention reports the same line once as it lands,
263
+ whether or not its tick failed; a fresh watch does not replay historical
264
+ abandonments.
261
265
  Recovery failures are
262
266
  reported without preventing janitor, lease sweep, or other dispatch recovery.
263
267
  This is not general process
package/docs/tickets.md CHANGED
@@ -76,7 +76,7 @@ Moving a ticket back to triage, backlog or ready restores ordinary behavior. "Bu
76
76
  The dispatcher claims only tickets in the ready state with the required labels and any source-specific filter. A ready ticket still waits on:
77
77
 
78
78
  - **Blockers.** Unresolved prerequisite tickets keep it queued; they don't create a blocked build. With nodes, prerequisites with builds must be present at the sampled destination; see [integration and blocker presence](integration-overview.md).
79
- - **Destination and capacity.** Its target must accept new work, and a capacity slot must be free and not reserved for an integration node awaiting verification.
79
+ - **Destination and capacity.** Its target must accept new work, and a capacity slot must be free and not reserved for an integration node awaiting verification or a finished build waiting to re-verify or reconcile.
80
80
 
81
81
  When a slot is free, the dispatcher takes urgent ready tickets first, then normal ones, each in the source's order. Priority changes only that order: a blocked urgent ticket waits like any other while normal work proceeds, and an urgent ticket never stops or pauses a running build. The web dashboard's Queue tab lists tickets in the same order and marks urgent ones `URGENT`; the mark shows priority, not that the ticket will dispatch next.
82
82
 
@@ -57,7 +57,7 @@ bun ab harvest status
57
57
  - **Ready state:** ticket in the exact ready state with every required label.
58
58
  - **Blockers and destination:** blockers done, target node open, required changes in the destination. A target node built by another dispatcher's store never opens here; see [several dispatchers](build-store.md#several-dispatchers-on-one-repository). `ab repository status` lists the queue diagnostics.
59
59
  - **Claims:** claimed tickets aren't reclaimed.
60
- - **Capacity:** paused or blocked work keeps its slot; idle collecting nodes take none. Node verification and reconciliation account specially for descendants' slots.
60
+ - **Capacity:** paused or blocked unfinished work keeps its slot; builds waiting for a merge decision and idle collecting nodes take none. A finished build that must re-verify or reconcile reserves a slot ahead of new claims. Node verification and reconciliation account specially for descendants' slots.
61
61
  - **Harvest:** check the acknowledged harvest gate and unclaimed observations. Harvest triggers at `policy.harvestThreshold` observations, or `policy.harvestMaxDrift` other merged builds since the oldest observation (zero disables drift), and uses no build slot.
62
62
 
63
63
  ## Authentication failures
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defrex/autobuild",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Agent-driven software delivery from groomed ticket to merged PR",
5
5
  "repository": {
6
6
  "type": "git",
@@ -157,8 +157,8 @@
157
157
  },
158
158
  "devDependencies": {
159
159
  "@biomejs/biome": "2.5.5",
160
- "@defrex/autobuild-postgres-store": "1.5.0",
161
- "@defrex/autobuild-vercel-sandbox": "1.5.0",
160
+ "@defrex/autobuild-postgres-store": "1.6.0",
161
+ "@defrex/autobuild-vercel-sandbox": "1.6.0",
162
162
  "@resvg/resvg-js": "2.6.2",
163
163
  "@types/bun": "^1.3.14",
164
164
  "@types/node": "^24.0.0",
@@ -67,6 +67,8 @@ export function repositoryNeedsAttention(event: RepositoryEvent): boolean {
67
67
  return event.payload.restartRequired.length > 0
68
68
  case 'dispatcher.run-stopped':
69
69
  return event.payload.outcome === 'abnormal'
70
+ case 'ticket-preparation.resolved':
71
+ return event.payload.outcome === 'abandoned'
70
72
  default:
71
73
  return false
72
74
  }