@defrex/autobuild 1.13.0 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +38 -11
  3. package/docs/answering-blocked-builds.md +5 -3
  4. package/docs/architecture.md +12 -0
  5. package/docs/configuration.md +16 -8
  6. package/docs/operating.md +8 -0
  7. package/docs/operator-api.md +1 -1
  8. package/docs/operator-surfaces.md +1 -1
  9. package/docs/remote-store-protocol.md +1 -1
  10. package/docs/troubleshooting.md +16 -1
  11. package/package.json +3 -3
  12. package/packages/core/src/cli/dispatch.ts +21 -2
  13. package/packages/core/src/config/schema.ts +2 -2
  14. package/packages/core/src/events/policy.ts +1 -0
  15. package/packages/core/src/events/repository.ts +19 -0
  16. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +4 -0
  17. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/be211f0e31a65006.json.gz +0 -0
  18. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/312cc4090820a612.json +1078 -0
  19. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a2780567b4989fb6.json +105 -0
  20. package/packages/core/src/kernel/done-escalations.ts +8 -4
  21. package/packages/core/src/kernel/reducer-revisions.ts +4 -0
  22. package/packages/core/src/kernel/reducer.ts +15 -1
  23. package/packages/core/src/kernel/repository-read-facts.ts +9 -0
  24. package/packages/core/src/ports/workspace/build-execution.ts +9 -1
  25. package/packages/core/src/ports/workspace/vercel-sandbox.ts +99 -12
  26. package/packages/core/src/processes/dispatcher.ts +312 -33
  27. package/packages/core/src/processes/execution-settlement.ts +24 -3
  28. package/packages/core/src/processes/tick-publication.ts +1 -0
  29. package/packages/core/src/store/contract.ts +7 -0
  30. package/packages/core/src/store/reducer-value-shapes.json +5320 -5210
  31. package/packages/core/src/store/reducer-value-validation.ts +7 -0
  32. package/packages/core/src/store/remote/released-clients.json +11 -0
  33. package/packages/core/src/store/remote/released-reducer-values/1.14.0.json +36076 -0
  34. package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -16
  35. package/packages/core/src/store/repo-state-events.ts +1 -0
  36. package/packages/core/src/testing/dispatch-read-budget.ts +12 -2
  37. package/packages/core/src/testing/reduced-read-budget.ts +208 -1
  38. package/skills/guide/SKILL.md +18 -9
  39. package/skills/guide/references/operator-api.md +1 -1
  40. package/skills/guide/references/remote-store-protocol.md +1 -1
  41. package/skills/operate/SKILL.md +55 -5
  42. 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.13.0
29
+ bun add -d --exact @defrex/autobuild@1.14.0
30
30
  ```
31
31
 
32
32
  <!-- release-install:end -->
package/SPEC.md CHANGED
@@ -1873,8 +1873,10 @@ open builds until an operator acknowledges them (§14).
1873
1873
 
1874
1874
  - **Contribution:** a build whose status is `done` and which has at least one
1875
1875
  open escalation contributes `{slug, kind}`. Any other build contributes
1876
- nothing. Completion closes no escalation, so a build completed while blocked,
1877
- abort cleanup included, is listed until its escalation is answered.
1876
+ nothing. Completion closes no escalation, but the first `build.aborted`
1877
+ closes every escalation open then, so an aborted build is listed only for an
1878
+ escalation raised after its abort, such as a cleanup failure that escalates,
1879
+ until it is answered or the janitor recovers.
1878
1880
  - **Arguments:** none, so each repository has one key. Nothing expires.
1879
1881
  - **Answer:** `{position, builds: [{slug, kind}]}` by slug, with `cursor: 0`.
1880
1882
  Readers confirm each listed build against its build-reducer state.
@@ -1993,6 +1995,21 @@ workspace requests are cancelled, at the work deadline, which is the budget minu
1993
1995
  a teardown reserve of `min(30 s, budget/4)`. Teardown (provisioning abandonment,
1994
1996
  repository-lease release, `dispatcher.run-stopped`) is bounded by the budget end;
1995
1997
  a write storage cannot finish by then is abandoned and the lease left to expire.
1998
+ Deadline-gated work starts only when it fits before the work deadline: a remote
1999
+ provision needs the provider's estimate (about 150 s), and a stopped-sandbox
2000
+ recovery needs a realistic resume (about 45 s) plus the cleanup reserve, with
2001
+ `recoveryTimeoutMs` as its ceiling. A recovery the deadline cuts short stops the
2002
+ sandbox, or leaves it uncertain for a later fence, and consumes no infrastructure
2003
+ attempt. A tick that defers such work counts it as `provisioningDeferred` or
2004
+ `recoveryDeferred`, logs one line per build naming the step, and is never
2005
+ reported idle. It records those builds in the latest-only, advisory
2006
+ `dispatcher.work-deferred` fact (a deferral noted after the work deadline is
2007
+ written in teardown, under the cleanup deadline, while the repository lease is
2008
+ still held), and the next invocation sweeps them before its
2009
+ other stages, re-deriving every decision from build state. The fact is a
2010
+ scheduling hint, never authority; an entry leaves it only after its own pass
2011
+ finishes without deferring again. Several carried recoveries can use most of
2012
+ that invocation's window before the janitor runs.
1996
2013
  A budget stop is a normal run stop. Credential deletion then gets the remaining
1997
2014
  budget and at least 5 seconds; issuance or deletion unsettled by then is
1998
2015
  reported and left to the capped expiry. Each served tick
@@ -5219,8 +5236,8 @@ effective configuration only, so heartbeat or lease renewal without an event
5219
5236
  does not alter them. Every nonterminal build, including `queued`, has a
5220
5237
  dashboard row; a pre-run row names its pending dispatch boundary or latest
5221
5238
  durable failure. A `done` build with an open escalation, such as a
5222
- post-landing integration audit raised after it completed or a question still
5223
- open when abort cleanup completed, also has a row, `BLOCKED` with the note
5239
+ post-landing integration audit raised after it completed or an escalation
5240
+ raised during abort cleanup, also has a row, `BLOCKED` with the note
5224
5241
  `done` and its question, until an operator acknowledges it with `ab answer`;
5225
5242
  it holds no slot and offers no other control. A human may discard only such a queued build. Discard is
5226
5243
  dispatcher cleanup, returns the ticket to its
@@ -5404,7 +5421,11 @@ with illustrative members:
5404
5421
  Abort cleanup is a dispatcher-owned ordered saga. A runner acknowledges abort
5405
5422
  for a running leaf; for a queued, paused or blocked leaf with no live execution
5406
5423
  lease, and for a node, the dispatcher appends `build.aborted` itself and runs
5407
- the saga, never provisioning a workspace or starting a runner first. While an
5424
+ the saga, never provisioning a workspace or starting a runner first. The first
5425
+ `build.aborted` accepts the abort and closes, unanswered, every escalation open
5426
+ at that moment. It also ends any janitor failure episode, so a cleanup failure
5427
+ after it starts a new episode and escalates under a new id. A repeated
5428
+ `build.aborted` closes nothing. While an
5408
5429
  execution lease is live, the janitor defers the saga so it cannot race
5409
5430
  process-tree teardown. Once that supervisor releases the lease, or an abruptly
5410
5431
  orphaned lease expires, cleanup closes an open unmerged PR without overriding a
@@ -5814,7 +5835,10 @@ carries the measured delta. The read-budget harness in
5814
5835
  lastEvent}`. `blocked` ≡ an open escalation: an `escalation.raised` (or the
5815
5836
  escalation a `phase.deferral-escalated` or `wait.entered` opens) without a
5816
5837
  matching `escalation.answered`, matched by id; a ticket wait's escalation also
5817
- closes on `wait.ended` and on a `wait-unresolvable` raise. `waitRequest` and
5838
+ closes on `wait.ended` and on a `wait-unresolvable` raise. The first
5839
+ `build.aborted` closes every escalation open then, without an
5840
+ `escalation.answered` and without entering `answeredEscalations`; one raised
5841
+ after it stays open. `waitRequest` and
5818
5842
  `wait` project the latest ticket-wait request and entered wait (§11 "Ticket
5819
5843
  waits"); `wait.ended?: {cause: operator | automatic | unresolvable, seq,
5820
5844
  message}` is the wait's first end. `reviewRoundCeilings` projects valid
@@ -5905,8 +5929,8 @@ rollup (§7.7): the build's `kind` (from `build.created`, default `work`), its
5905
5929
  `doneEscalations` rollup (§7.7): the build's `kind`, its latest terminal fact
5906
5930
  (`done` or `aborted`) and its open escalation ids in raise order. It applies the build reducer's open-escalation
5907
5931
  rules exactly: raises, deferrals, janitor escalations and entered ticket waits
5908
- open; answers, wait ends, janitor recovery, `wait-unresolvable` and verify
5909
- supersession close. Its ids always equal the build reducer's
5932
+ open; answers, wait ends, janitor recovery, `wait-unresolvable`, verify
5933
+ supersession and the first abort close. Its ids always equal the build reducer's
5910
5934
  `openEscalations`.
5911
5935
 
5912
5936
  ### 15.6 Walkthroughs
@@ -5946,7 +5970,9 @@ A discard request is honored only while the build remains queued; one that races
5946
5970
  attachment is inert and cannot tear down live work. A human discard waits out
5947
5971
  any unexpired execution lease, then releases a partial workspace and stale
5948
5972
  lease, returns the ticket to Ready, and appends `build.completed {outcome:
5949
- discarded}` last. No runner is required.
5973
+ discarded}` last. No runner is required. A queued build has no open escalation,
5974
+ so a discard closes none; an escalation its cleanup raises stays open until it
5975
+ is answered or the janitor recovers.
5950
5976
 
5951
5977
  **A — grouped verification:** a failing member waits at its stage barrier for
5952
5978
  all siblings unless a fail-fast member fails. After cancellation and confirmed
@@ -6981,7 +7007,7 @@ automatic = true # immediate/60-second target checks; false requi
6981
7007
  #vcpus = 4
6982
7008
  #timeoutSeconds = 2700
6983
7009
  #operationTimeoutMs = 30000 # provider calls, not VM/session lifetime
6984
- #recoveryTimeoutMs = 120000 # one stopped-sandbox resume plus guest git
7010
+ #recoveryTimeoutMs = 120000 # ceiling: one stopped-sandbox resume plus guest git
6985
7011
  #environmentVariables = ["ANTHROPIC_API_KEY"]
6986
7012
 
6987
7013
  #[pr.imageHost] # optional public inline rendering for attached images
@@ -7708,7 +7734,8 @@ The janitor keeps retrying on its backoff underneath; a successful attempt
7708
7734
  clears the attention, closes the escalation unanswered and the build continues.
7709
7735
  Answering it with a bare retry makes the janitor attempt on its next tick. An
7710
7736
  episode raises at most one escalation; a new episode after recovery can raise
7711
- another. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
7737
+ another. The first `build.aborted` also ends the episode and closes its
7738
+ escalation, so abort cleanup failures start a new episode with a new id. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
7712
7739
  A pending control the janitor can act on wakes it during backoff: an abort, a
7713
7740
  pause, a resume of a paused build, a queued discard or an unacknowledged landing
7714
7741
  command. A leaf's resume that only cancelled a never-acknowledged pause is not
@@ -22,7 +22,7 @@ until the revision lands.
22
22
  | Replace the build contract from a file | `ab answer <slug> --revise-spec <file>` | Records the replacement as the next spec revision and restarts leaves at `plan`; nodes recollect and verify. |
23
23
  | Re-import an amended ticket | `ab answer <slug> --revise-spec-from-ticket` | Reads the build's recorded ticket and performs the same revision. |
24
24
  | Accept a rewritten target | `ab answer <slug> --accept-target` | Answers only a `target-rewritten` escalation; the build's own commits restack onto the current target. See [A rewritten target](#a-rewritten-target). |
25
- | Abandon the build | `ab abort <slug> [--to ready] [--reason <text>]` | Irrevocably requests abort; cleanup returns the ticket to Triage, or with `--to ready` to Ready with its blockers kept, and then reports `ticket.handed-back`. Ready requires the current ticket to meet the spec standard; otherwise cleanup returns it to Triage, and the comment and event name the requested destination and the missing parts. An [optimization attempt](optimization-nodes.md#landing-and-settlement) is the exception: its abort settles `aborted`, ignores `--to`, reports no `ticket.handed-back`, and the node moves the ticket to Rejected after cleanup. |
25
+ | Abandon the build | `ab abort <slug> [--to ready] [--reason <text>]` | Irrevocably requests abort. Abort closes the build's open escalations without answering them. Cleanup returns the ticket to Triage, or with `--to ready` to Ready with its blockers kept, and then reports `ticket.handed-back`. Ready requires the current ticket to meet the spec standard; otherwise cleanup returns it to Triage, and the comment and event name the requested destination and the missing parts. An [optimization attempt](optimization-nodes.md#landing-and-settlement) is the exception: its abort settles `aborted`, ignores `--to`, reports no `ticket.handed-back`, and the node moves the ticket to Rejected after cleanup. |
26
26
 
27
27
  The dashboard's blocked-build `r` shortcut requests an inline answer step that
28
28
  supports guidance and a blank retry. While that step is open, it is exclusive
@@ -209,5 +209,7 @@ with nothing open.
209
209
  dashboards, `ab web` and `operator.attention` show the escalation while it is
210
210
  open and drop it once acknowledged. On a dashboard the build reads red
211
211
  `BLOCKED` with the note `done` and its question, and holds no slot. Completion
212
- closes no escalation, so a question still open when abort cleanup completed
213
- shows the same way until it is acknowledged.
212
+ closes nothing, but accepting an abort closes every escalation open then, so an
213
+ aborted build appears here only for an escalation raised afterwards, such as a
214
+ cleanup failure. A discard is accepted only while the build is queued, when
215
+ nothing is open.
@@ -830,6 +830,18 @@ provider to verify and finish the same generation, and if it cannot, the
830
830
  replacement consumes no infrastructure attempt. A preservation or release
831
831
  failure is recorded against its build, as an infrastructure failure or janitor
832
832
  attention, and never stops the dispatcher from advancing other builds.
833
+ Work a bounded invocation defers for budget (a provision, or a stopped-sandbox
834
+ recovery the Vercel provider admits on a realistic resume estimate rather than
835
+ the `recoveryTimeoutMs` ceiling) is noted per tick by `Dispatcher.noteDeferral`,
836
+ counted as `provisioningDeferred` or `recoveryDeferred` with one diagnostic line
837
+ per build, and carried in the latest-only `dispatcher.work-deferred` fact; one
838
+ noted after the work signal aborts is written through the tick's
839
+ `teardownWrite` scope under the cleanup signal. The
840
+ next tick's first stage, `serviceDeferredWork`, runs the ordinary `sweepBuild`
841
+ pass for those builds before settlement and the janitor; the lease sweep and
842
+ settlement skip what it took up. A resume the deadline cuts short is stopped or
843
+ left uncertain, and observation reports a budget deferral as a `running`
844
+ observation marked `deferred`.
833
845
  Fencing is revalidated after restart; a saved receipt alone never authorizes
834
846
  cleanup of a newer execution. Current recovery notes are linked by the session
835
847
  manifest's `workspaceRecovery` field. Recovery notes apply to the next session
@@ -1306,7 +1306,7 @@ preflight = "test \"$(pi --version)\" = \"0.84.4\" && pi update --models"
1306
1306
  - **Reload:** Dispatcher restart required; startup adapters retain their configuration. Build-owned pipeline: captured from the execution checkout each verify cycle; later base-branch edits do not replace it. Workspace provisioning applies at the next build launch. A running invocation keeps its captured values.
1307
1307
  - **Local override:** Committed only: set in autobuild.toml.
1308
1308
 
1309
- **Description:** Budget in milliseconds for one stopped-sandbox recovery: an explicit cold resume plus the guest git work that follows it, including a push. Any invocation deadline bounds it further. Separate from operationTimeoutMs.
1309
+ **Description:** Ceiling in milliseconds for one stopped-sandbox recovery: an explicit cold resume plus the guest git work that follows it, including a push. A bounded invocation starts a recovery when a realistic resume (about 45 s) plus its cleanup reserve still fits, and its deadline bounds the recovery further. Separate from operationTimeoutMs.
1310
1310
 
1311
1311
  **Constraints:** safe integer; ≥ 1000; ≤ 600000
1312
1312
 
@@ -1615,12 +1615,20 @@ treated as running:
1615
1615
  record, and stops it again, so a finished session's `publication.requested`
1616
1616
  is published instead of the execution being declared lost.
1617
1617
  - **Resume has its own budget.** Preservation and publication resume a
1618
- stopped sandbox explicitly under `recoveryTimeoutMs` (default 120 s), which
1619
- covers the cold resume plus the guest git work and push.
1618
+ stopped sandbox explicitly. `recoveryTimeoutMs` (default 120 s) is the
1619
+ ceiling for the cold resume plus the guest git work and push.
1620
1620
  `operationTimeoutMs` still bounds each metadata acknowledgement.
1621
- - **The invocation deadline wins.** A hosted invocation stops recovery early
1622
- enough to restore policy and stop the sandbox before it ends. Work that
1623
- cannot fit is deferred to the next invocation with nothing recorded.
1621
+ - **The invocation deadline wins.** A hosted invocation starts a recovery
1622
+ only while a realistic resume (about 45 s) plus the cleanup reserve
1623
+ (`2 × operationTimeoutMs`) still fits, and stops recovery early enough to
1624
+ restore policy and stop the sandbox before it ends. A resume the deadline
1625
+ cuts short is stopped, or left uncertain until a later fence, and charges
1626
+ no infrastructure attempt.
1627
+ - **Deferred work runs first next time.** Work that cannot fit is deferred:
1628
+ the tick counts it as `recoveryDeferred`, logs
1629
+ `build <slug>: <step> deferred by the invocation budget`, and records the
1630
+ build in the latest-only `dispatcher.work-deferred` fact. The next
1631
+ invocation sweeps those builds before anything else.
1624
1632
  - **No redundant stops.** Fence and cleanup skip `stop()` for a sandbox the
1625
1633
  provider already reports stopped.
1626
1634
  - **Failures name their step.** `infrastructure.failed` and the exhaustion
@@ -1648,8 +1656,8 @@ is different: the next invocation verifies it and finishes it in the same
1648
1656
  generation. If it cannot be finished, it is released and replaced without
1649
1657
  consuming `maxInfrastructureAttempts`. A bounded dispatcher invocation does not
1650
1658
  start provisioning with less than about 150 s of budget left; it records
1651
- `provisioningDeferred` in the tick report and leaves the build to the next
1652
- invocation.
1659
+ `provisioningDeferred` in the tick report, logs the build, and records it in
1660
+ `dispatcher.work-deferred`, so the next invocation provisions it first.
1653
1661
 
1654
1662
  The representative actual-provider check is opt-in and must point at an
1655
1663
  independent consuming repository whose `autobuild.toml` selects the universal
package/docs/operating.md CHANGED
@@ -37,6 +37,14 @@ Agree on boundaries before the agent acts: moving a ticket to ready can start a
37
37
 
38
38
  The agent answers questions your instructions settle and escalates ambiguous goals, scope or compatibility tradeoffs, consequential or destructive choices, missing authority or access, and dispatcher trouble.
39
39
 
40
+ While it waits on you, the agent keeps operating everything else. Later updates would bury the request, so the agent repeats it, locally and over MCP alike:
41
+
42
+ - This is operator behavior, not something every agent does. It applies only to the agent holding the operator role and running the standing watch or `repository.attention` rounds, not to build sessions, spec or ticket sessions, or a one-off question.
43
+ - Every status message, whether a round summary, an outcome report or a reply, ends with a **Waiting on you** section.
44
+ - The section lists each open escalation or decision, merge awaiting your consent, question put to you, and attention it must report rather than fix, such as a forge-only merge, a missing credential or a maintainer-only dispatcher restart.
45
+ - Each item is restated in full: ticket and build, what is needed, the options and the agent's recommendation. You can act on the latest message alone. The agent checks each item against current state first, so a resolved one is never repeated from memory.
46
+ - Resolved items drop out. When nothing waits, the message ends with one line saying so, such as `Waiting on you: nothing.`
47
+
40
48
  ## Watch for attention
41
49
 
42
50
  ```
@@ -85,7 +85,7 @@ raw session-event append. External operator harnesses own agent execution.
85
85
  | Method and path | Result |
86
86
  |---|---|
87
87
  | `GET …/builds?scope=active\|queued\|all` | Build summaries, newest update first. `queued` means active plus queued, matching `ab builds --queued`. Each nonterminal summary's `slot` is `{state: "held"}`, `{state: "requested", request, priority?: "urgent" \| "high" \| "low"}` or `{state: "none"}`; absent means unknown (an older server), never `none`. Its `statusWord` is `{word, tone, note?}`, the status word every surface shows; `status` stays the reducer's lifecycle status. |
88
- | `GET …/builds/{slug}` | `{detail, dashboardRow}`; `detail.slot` and `dashboardRow.slot` carry the build's slot state, shaped as in `GET …/builds`; `detail.runnerAttaches` records chronological attach boundaries and their runtime identity (version, commit, source kind/location), with null runtime for unrecorded historical attaches; `dashboardRow` remains a `CLEANING` row after `build.aborted` and becomes `null` only when the dashboard stops listing it: at `build.completed` when no escalation is open. A completed build with an open escalation keeps, or regains, a `BLOCKED` row (note `done`), including after abort cleanup, and the row becomes `null` once the escalation is acknowledged; neither step reopens its lifecycle state. |
88
+ | `GET …/builds/{slug}` | `{detail, dashboardRow}`; `detail.slot` and `dashboardRow.slot` carry the build's slot state, shaped as in `GET …/builds`; `detail.runnerAttaches` records chronological attach boundaries and their runtime identity (version, commit, source kind/location), with null runtime for unrecorded historical attaches; `dashboardRow` remains a `CLEANING` row after `build.aborted` and becomes `null` only when the dashboard stops listing it: at `build.completed` when no escalation is open. A completed build with an open escalation keeps, or regains, a `BLOCKED` row (note `done`), including one raised during abort cleanup; abort itself closes the escalations open when it is accepted. The row becomes `null` once the escalation is acknowledged; neither step reopens its lifecycle state. |
89
89
  | `GET …/dashboard` | `{generatedAt, model, settingsHeader}`. `model` is the dashboard's rows, steps, elapsed timing inputs, harvest row, triage (when the dispatcher published one)/queue/capacity and settings projection. `model.capacity.slots` maps each build to its slot state, and each `model.builds[].slot` repeats it; absent means unknown. `model.configuration` is `"no-dispatcher-run"` when the repository records no dispatcher run, and absent otherwise. Optional `rollback` contains `correlation`, `lineage`, full `failed` and `restored` runtime identities and rollback event `ts` for the authoritative dispatcher lineage’s unresolved hold. Both dashboards name failed, restored and held runtime plus timestamp. Matching durable different-target hold clearance removes it; a fresh operator lineage hides it only after a committed operational tick or accepted takeover. Run-started and yielded ticks alone cannot replace authority; same-lineage generations retain the notice. Historical rollback records are not fallback notices. Optional `handoffs` lists all accepted unfinished handoffs with predecessor `run`, optional `successor`, `correlation`, full `from`/`to` runtimes, `mode` and optional `deadline`. Outstanding drain-mode builds carry `draining: true`, also on build-detail `dashboardRow`; matching settlement removes it. Accepted completion removes the handoff; neither takeover nor the clock does. Missing historical mode means cutover and missing deadline displays unknown. |
90
90
  | `GET …/status` | Repository intake, pause, and default-auto-merge projection, plus `ticketStarts` (`{pending, recent}`, each entry with its `priority`) when single-ticket start requests are pending or recently settled. `capacity.slots`, when the held configuration is readable, maps each nonterminal build to its slot state; `capacity.occupied` counts its `held` entries. Its `operator` is `{presence: "unavailable", reason}`: this route does not load presence registrations, so it is not evidence that no operator is present. |
91
91
  | `GET …/harvest/status` | Harvest gate, runs, steps, recovery, and attention projection. |
@@ -75,7 +75,7 @@ Every nonterminal build row on both dashboards, `ab builds` and `ab build status
75
75
  | `MERGING` | amber | none | A finished pipeline with merge consent, waiting for merge gates or the forge. |
76
76
  | `PAUSED` | amber | none | An acknowledged pause. |
77
77
  | `COLLECTING` | amber | none | An integration build collecting child work. |
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 a question still open when abort cleanup completed; the row stays until `ab answer` acknowledges it. |
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. |
79
79
  | `CLEANING` | dim | none | Abort cleanup. |
80
80
 
81
81
  - Green means held: the active counter `<occupied>/<capacity>` counts the green rows.
@@ -776,7 +776,7 @@ builds.
776
776
  | `appendRepo` | `POST /repos/{repo}/events` | event write | `201` + repository event envelope |
777
777
  | `appendRepoIfCurrent` | `POST /repos/{repo}/events/conditional` | `{"expectedSeq": nonnegative integer, "event": event write}` | appended: `201` + repository event envelope; journal advanced: `200 null` (mirroring section 3's build compare-and-append). A server without the route answers `404`; callers report it and never fall back to an unconditional append |
778
778
  | `getRepoEvents` / `getRepositoryTail` | `GET /repos/{repo}/events?since={n}&through={n}&wait={s}` | optional `since` query value, parsed as in section 3; absence defaults to `0`. Optional `wait` in whole seconds, per the event-wait rules of section 3 | `200` + envelopes with `seq > since`, up to the frozen head; optional `through` caps the response at `seq <= through`; `409 cursor-too-old` below `max(0, head - 1000)` |
779
- | `getRepoStateEvents` | `GET /repos/{repo}/state-events` | none | `200` + the bounded repository-journal subset (AUT-489): every durable event type (`ticket-preparation.*`, `harvest.*`, `orchestrator.sandbox.*`, the three dispatcher setting types, and cross-generation handoff correlation facts: target-prepared, yield-requested, upgrade-failed, handoff-started, terminal-released, takeover, drain-deadline, drain-settled and handoff-completed) plus the latest-only `dispatcher.ticket-scan-completed` and `dispatcher.placement-set` facts and, when the journal has one, the tail from the latest `dispatcher.run-started`, in increasing sequence order; served inside the repository-existence gate like `GET events`, so an unknown repository is `404` |
779
+ | `getRepoStateEvents` | `GET /repos/{repo}/state-events` | none | `200` + the bounded repository-journal subset (AUT-489): every durable event type (`ticket-preparation.*`, `harvest.*`, `orchestrator.sandbox.*`, the three dispatcher setting types, and cross-generation handoff correlation facts: target-prepared, yield-requested, upgrade-failed, handoff-started, terminal-released, takeover, drain-deadline, drain-settled and handoff-completed) plus the latest-only `dispatcher.ticket-scan-completed`, `dispatcher.placement-set` and `dispatcher.work-deferred` facts and, when the journal has one, the tail from the latest `dispatcher.run-started`, in increasing sequence order; served inside the repository-existence gate like `GET events`, so an unknown repository is `404` |
780
780
  | `getReducerSnapshot` (repo scope) | `GET /repos/{repo}/snapshots/{reducer}?version={n}` | required `version` query value, a positive integer; `reducer` is a registry name (`^[A-Za-z][A-Za-z0-9._-]{0,63}$`) | `200` + `{"version", "cursor", "state"}` or `200 null` when absent, written by another reducer version, ahead of the journal's tail, or the repository has no journal record; an unknown repository is `404`, which the shipped client also maps to `null` |
781
781
  | `putReducerSnapshot` (repo scope) | `PUT /repos/{repo}/snapshots/{reducer}` | `{"version": int >= 1, "cursor": int >= 0, "state": JSON}`, at most 16 MiB (`413` above) | `200 {"written": boolean}`; the stored cursor never decreases, so a write at an equal or lower cursor (or an equal cursor at an equal or lower version) and one past the journal's tail answer `written: false` |
782
782
  | `appendRepoWithArtifacts` | `POST /repos/{repo}/deposits` | atomic deposit request | `201` + `{event, artifacts}` using repository shapes |
@@ -127,7 +127,22 @@ See [answering blocked builds](operating.md#answer-and-pause). Preserve event lo
127
127
  | `preserve` | Inspecting or pushing the sandbox's commits | Check forge credentials and the branch, then retry. |
128
128
  | `cleanup` | Stop, snapshot purge or delete | Check the sandbox and its snapshots in the provider, then retry. |
129
129
 
130
- A deadline-deferred step records nothing and retries on the next invocation. See [Vercel sandbox recovery](configuration.md#vercel-sandbox).
130
+ A step the invocation deadline defers is not a failure:
131
+
132
+ - It charges no infrastructure attempt.
133
+ - The dispatch log names it: `build <slug>: <step> deferred by the invocation budget`.
134
+ - The tick counts it as `recoveryDeferred` (or `provisioningDeferred`) and never reports `tick: idle`.
135
+ - The next invocation runs that build first.
136
+
137
+ See [Vercel sandbox recovery](configuration.md#vercel-sandbox).
138
+
139
+ ## A build stays STARTING with repeated deferral lines
140
+
141
+ **Symptom.** The same build logs `resume deferred by the invocation budget` or `provision deferred by the invocation budget` on several invocations in a row, and stays STARTING.
142
+
143
+ **Cause.** Even with the build served first, the hosted invocation budget can't fit the work. A provision needs about 150 s; a resume needs about 105 s by default (a realistic resume plus the cleanup reserve).
144
+
145
+ **Action.** Report it to the instance operator: the invocation budget is too small for this work. Retrying the build doesn't help.
131
146
 
132
147
  ## Remote project access
133
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defrex/autobuild",
3
- "version": "1.13.0",
3
+ "version": "1.14.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.13.0",
166
- "@defrex/autobuild-vercel-sandbox": "1.13.0",
165
+ "@defrex/autobuild-postgres-store": "1.14.0",
166
+ "@defrex/autobuild-vercel-sandbox": "1.14.0",
167
167
  "@resvg/resvg-js": "2.6.2",
168
168
  "@types/bun": "^1.3.14",
169
169
  "@types/node": "^24.0.0",
@@ -1661,7 +1661,10 @@ class DispatchLoop {
1661
1661
  // transport call). Watch mode has no deadline ⇒ absent ⇒ unbounded.
1662
1662
  ...(this.opts.deadlineAt !== undefined ? { deadlineAt: this.opts.deadlineAt } : {}),
1663
1663
  ...(this.opts.invocationBudget !== undefined
1664
- ? { workSignal: this.opts.invocationBudget.work }
1664
+ ? {
1665
+ workSignal: this.opts.invocationBudget.work,
1666
+ teardownWrite: this.teardownWrite(this.opts.invocationBudget),
1667
+ }
1665
1668
  : {}),
1666
1669
  })
1667
1670
  const publishedReport: TickReport = {
@@ -3430,6 +3433,7 @@ class DispatchLoop {
3430
3433
  creationDiagnostics: _creationDiagnostics,
3431
3434
  dependencyDiagnostics: _dependencyDiagnostics,
3432
3435
  agentContextDiagnostics: _agentContextDiagnostics,
3436
+ deferredDiagnostics: _deferredDiagnostics,
3433
3437
  ...counters
3434
3438
  } = merged
3435
3439
  const completed = {
@@ -3942,6 +3946,9 @@ class DispatchLoop {
3942
3946
  if (error instanceof ForgeRequestDeferred || isRecoveryDeferred(error)) {
3943
3947
  if (leaseClaimed) await this.repoView.releaseLease(slug, instance)
3944
3948
  await this.repoView.refreshBuild(slug)
3949
+ // The dispatcher's guarded launch entry records a recovery deferral
3950
+ // (its step and build) and reports it as `already-active`.
3951
+ if (isRecoveryDeferred(error)) throw error
3945
3952
  return 'already-active'
3946
3953
  }
3947
3954
  if (leaseClaimed) {
@@ -4336,6 +4343,7 @@ class DispatchLoop {
4336
4343
  creationDiagnostics,
4337
4344
  dependencyDiagnostics,
4338
4345
  agentContextDiagnostics,
4346
+ deferredDiagnostics,
4339
4347
  queued: _queued,
4340
4348
  ...counts
4341
4349
  } = report
@@ -4346,6 +4354,7 @@ class DispatchLoop {
4346
4354
  for (const line of ticketDiagnostics) this.routineDiagnostic(line)
4347
4355
  for (const line of creationDiagnostics) this.say(line)
4348
4356
  for (const line of dependencyDiagnostics) this.say(line)
4357
+ for (const line of deferredDiagnostics) this.say(line)
4349
4358
  const parts = Object.entries(counts)
4350
4359
  .filter(([, count]) => typeof count === 'number' && count > 0)
4351
4360
  .map(([name, count]) => `${name}=${count}`)
@@ -4359,7 +4368,8 @@ class DispatchLoop {
4359
4368
  ticketDiagnostics.length > 0 ||
4360
4369
  creationDiagnostics.length > 0 ||
4361
4370
  dependencyDiagnostics.length > 0 ||
4362
- agentContextDiagnostics.length > 0
4371
+ agentContextDiagnostics.length > 0 ||
4372
+ deferredDiagnostics.length > 0
4363
4373
  if (reportedDiagnostic) return true
4364
4374
  // A tick that did something is worth a plain line. Interactive mode
4365
4375
  // suppresses both action counts and the every-10s idle noise.
@@ -5547,6 +5557,15 @@ class DispatchLoop {
5547
5557
  }
5548
5558
  }
5549
5559
 
5560
+ /** The deferral hint's late-write scope: one write under the cleanup
5561
+ * signal, refused once that deadline has passed. */
5562
+ private teardownWrite(budget: InvocationBudget) {
5563
+ return <T>(write: () => Promise<T>): Promise<T> =>
5564
+ budget.cleanup.aborted
5565
+ ? Promise.reject(budget.cleanup.reason)
5566
+ : withInvocationSignal(budget.cleanup, write)
5567
+ }
5568
+
5550
5569
  private async boundedTeardown(budget: InvocationBudget): Promise<void> {
5551
5570
  // Whether or not the deadline fired, no launch may start during
5552
5571
  // teardown: provisioning abandonment runs beside execution teardown.
@@ -242,7 +242,7 @@ export const vercelSandboxConfigSchema = z
242
242
  timeoutSeconds: z.number().int().min(60).max(86_400),
243
243
  /** Deadline for each provider acknowledgement; distinct from VM lifetime. */
244
244
  operationTimeoutMs: z.number().int().min(1_000).max(300_000).default(30_000),
245
- /** Budget for one stopped-sandbox recovery: explicit resume plus guest git. */
245
+ /** Ceiling for one stopped-sandbox recovery: explicit resume plus guest git. */
246
246
  recoveryTimeoutMs: z.number().int().min(1_000).max(600_000).default(120_000),
247
247
  /** Billing safety net: snapshots created for this environment expire after
248
248
  * this duration instead of the provider's 30-day default. Absent means the
@@ -333,7 +333,7 @@ documentFields(vercelSandboxConfigSchema, {
333
333
  operationTimeoutMs:
334
334
  'Deadline in milliseconds for each provider acknowledgement, independent of session lifetime.',
335
335
  recoveryTimeoutMs:
336
- 'Budget in milliseconds for one stopped-sandbox recovery: an explicit cold resume plus the guest git work that follows it, including a push. Any invocation deadline bounds it further. Separate from operationTimeoutMs.',
336
+ 'Ceiling in milliseconds for one stopped-sandbox recovery: an explicit cold resume plus the guest git work that follows it, including a push. A bounded invocation starts a recovery when a realistic resume (about 45 s) plus its cleanup reserve still fits, and its deadline bounds the recovery further. Separate from operationTimeoutMs.',
337
337
  snapshotExpirationSeconds:
338
338
  'Snapshot expiration in seconds. Omission uses the provider expiration policy.',
339
339
  region: 'Primary region; omission uses the provider region selection.',
@@ -328,6 +328,7 @@ export const repositoryEventPolicy = {
328
328
  'dispatcher.tick-started': 'decisive',
329
329
  'dispatcher.tick-completed': 'advisory',
330
330
  'dispatcher.ticket-scan-completed': 'advisory',
331
+ 'dispatcher.work-deferred': 'advisory',
331
332
  'dispatcher.ticket-source-dependency-limited': 'decisive',
332
333
  'dispatcher.forge-degraded': 'decisive',
333
334
  'dispatcher.forge-recovered': 'decisive',
@@ -85,6 +85,9 @@ const tickCountersSchema = z.strictObject({
85
85
  * invocation's remaining budget was shorter than the provider's
86
86
  * provisioning estimate. Optional so historical tick facts replay. */
87
87
  provisioningDeferred: z.number().int().nonnegative().optional(),
88
+ /** Builds whose stopped-sandbox recovery (or a launch waiting on one) the
89
+ * invocation budget deferred. Optional so historical tick facts replay. */
90
+ recoveryDeferred: z.number().int().nonnegative().optional(),
88
91
  /** Operator sandboxes idly stopped this tick. Added with the operator
89
92
  * sandbox; optional so historical tick facts replay. */
90
93
  sandboxIdleStops: z.number().int().nonnegative().optional(),
@@ -500,6 +503,21 @@ export const orchestratorSandboxEventPayloadSchemas = {
500
503
  } as const
501
504
 
502
505
  export const dispatcherStatusEventPayloadSchemas = {
506
+ /** A latest-only scheduling hint: the builds whose deadline-gated work
507
+ * (a provision or a stopped-sandbox recovery step) a bounded invocation
508
+ * deferred for budget. The next tick sweeps these builds first, re-deriving
509
+ * every decision from fresh build state; it is never authority. An empty
510
+ * list clears it. */
511
+ 'dispatcher.work-deferred': z.strictObject({
512
+ builds: z
513
+ .array(
514
+ z.strictObject({
515
+ slug: z.string().min(1),
516
+ step: z.enum(['provision', 'resume', 'fence', 'preserve', 'cleanup']),
517
+ }),
518
+ )
519
+ .max(64),
520
+ }),
503
521
  /** Completed ticket-source measurement, independent of dispatcher runs. */
504
522
  'dispatcher.ticket-scan-completed': z.strictObject({
505
523
  startedAt: z.iso.datetime(),
@@ -1247,6 +1265,7 @@ const allowedActorKinds: Record<RepositoryEventType, readonly ActorKind[]> = {
1247
1265
  'dispatcher.tick-started': ['dispatcher'],
1248
1266
  'dispatcher.tick-completed': ['dispatcher'],
1249
1267
  'dispatcher.ticket-scan-completed': ['dispatcher'],
1268
+ 'dispatcher.work-deferred': ['dispatcher'],
1250
1269
  'dispatcher.ticket-source-dependency-limited': ['dispatcher'],
1251
1270
  'dispatcher.forge-degraded': ['dispatcher', 'kernel'],
1252
1271
  'dispatcher.forge-recovered': ['dispatcher', 'kernel', 'human'],
@@ -9880,6 +9880,10 @@
9880
9880
  "$.lastWillRetry: boolean",
9881
9881
  "$.owners.s_stage: string",
9882
9882
  "$.owners: object",
9883
+ "$.raised.answered.phase: string",
9884
+ "$.raised.answered.session: string",
9885
+ "$.raised.answered.source: string",
9886
+ "$.raised.answered: object",
9883
9887
  "$.raised.e_1.phase: string",
9884
9888
  "$.raised.e_1.policyCause: string",
9885
9889
  "$.raised.e_1.session: string",