@defrex/autobuild 1.15.0 → 1.17.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 (80) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +110 -10
  3. package/docs/answering-blocked-builds.md +34 -1
  4. package/docs/architecture.md +41 -7
  5. package/docs/configuration.md +41 -7
  6. package/docs/dispatcher-hosting.md +3 -0
  7. package/docs/operator-api.md +15 -5
  8. package/docs/plugin-authoring.md +1 -0
  9. package/docs/remote-store-protocol.md +13 -3
  10. package/docs/remote-ticket-protocol.md +3 -1
  11. package/docs/restacking.md +41 -1
  12. package/docs/setup.md +15 -6
  13. package/docs/troubleshooting.md +51 -3
  14. package/docs/workspaces.md +4 -1
  15. package/package.json +3 -3
  16. package/packages/core/src/cli/accounts.ts +3 -0
  17. package/packages/core/src/cli/binary-direct.ts +14 -1
  18. package/packages/core/src/cli/binary.ts +10 -7
  19. package/packages/core/src/cli/dispatch.ts +610 -356
  20. package/packages/core/src/cli/secrets.ts +2 -0
  21. package/packages/core/src/config/schema.ts +15 -2
  22. package/packages/core/src/events/payloads.ts +8 -5
  23. package/packages/core/src/events/repository.ts +12 -6
  24. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/e28c68e63cbd265f.json +108 -0
  25. package/packages/core/src/kernel/engine.ts +118 -0
  26. package/packages/core/src/kernel/reconcile-restack.ts +72 -9
  27. package/packages/core/src/kernel/reducer-revisions.ts +1 -0
  28. package/packages/core/src/kernel/tracked-dirt.ts +173 -0
  29. package/packages/core/src/ontology.ts +1 -0
  30. package/packages/core/src/operator/index.ts +10 -0
  31. package/packages/core/src/operator/merged-builds.ts +51 -0
  32. package/packages/core/src/operator/registry.ts +190 -101
  33. package/packages/core/src/operator/repo-argument.ts +43 -0
  34. package/packages/core/src/ports/tickets/grants.ts +2 -0
  35. package/packages/core/src/ports/tickets/remote.ts +2 -0
  36. package/packages/core/src/ports/types.ts +25 -4
  37. package/packages/core/src/ports/workspace/vercel-command-diagnostics.ts +144 -0
  38. package/packages/core/src/ports/workspace/vercel-sandbox.ts +811 -169
  39. package/packages/core/src/processes/build-child.ts +15 -1
  40. package/packages/core/src/processes/build-runner.ts +349 -20
  41. package/packages/core/src/processes/dispatcher.ts +509 -104
  42. package/packages/core/src/processes/harvest-child.ts +21 -1
  43. package/packages/core/src/processes/harvest-runner.ts +82 -35
  44. package/packages/core/src/processes/invocation-budget.ts +6 -0
  45. package/packages/core/src/processes/launch-cut.ts +37 -0
  46. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  47. package/packages/core/src/processes/provisioning-progress.ts +23 -0
  48. package/packages/core/src/processes/repo-view.ts +25 -4
  49. package/packages/core/src/processes/workspace-preparation.ts +1 -0
  50. package/packages/core/src/store/adapter.ts +34 -5
  51. package/packages/core/src/store/build-feed.ts +148 -22
  52. package/packages/core/src/store/build-scope.ts +12 -3
  53. package/packages/core/src/store/caller-attribution.ts +170 -0
  54. package/packages/core/src/store/contract.ts +1038 -165
  55. package/packages/core/src/store/local/schema.ts +12 -1
  56. package/packages/core/src/store/local/store.ts +260 -25
  57. package/packages/core/src/store/memory.ts +156 -9
  58. package/packages/core/src/store/phase-session.ts +23 -3
  59. package/packages/core/src/store/reducer-value-shapes.json +5351 -5338
  60. package/packages/core/src/store/remote/client.ts +90 -11
  61. package/packages/core/src/store/remote/credentials.ts +2 -0
  62. package/packages/core/src/store/remote/index.ts +31 -5
  63. package/packages/core/src/store/remote/protocol.ts +45 -8
  64. package/packages/core/src/store/remote/released-clients.json +22 -0
  65. package/packages/core/src/store/remote/released-reducer-values/1.16.0.json +36358 -0
  66. package/packages/core/src/store/remote/released-reducer-values/1.17.0.json +36367 -0
  67. package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
  68. package/packages/core/src/store/remote/released-value-policy.ts +7 -0
  69. package/packages/core/src/store/session-handle.ts +12 -3
  70. package/packages/core/src/store/types.ts +48 -3
  71. package/packages/core/src/testing/reduced-read-budget.ts +310 -12
  72. package/skills/guide/SKILL.md +58 -9
  73. package/skills/guide/references/operator-api.md +15 -5
  74. package/skills/guide/references/plugin-authoring.md +1 -0
  75. package/skills/guide/references/remote-store-protocol.md +13 -3
  76. package/skills/guide/references/remote-ticket-protocol.md +3 -1
  77. package/skills/guide/references/restacking.md +41 -1
  78. package/skills/guide/references/setup.md +15 -6
  79. package/skills/operate/SKILL.md +31 -7
  80. 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.15.0
29
+ bun add -d --exact @defrex/autobuild@1.17.0
30
30
  ```
31
31
 
32
32
  <!-- release-install:end -->
package/SPEC.md CHANGED
@@ -378,6 +378,10 @@ clean stop. The next generation resumes eligible native sessions with fresh
378
378
  logical credentials, or records a reasoned `harvest.session.resume-fallback`
379
379
  and starts fresh. Orderly suspension spends no recovery attempt; real crashes
380
380
  retain recovery accounting.
381
+ A hosted harvest launch that is still preparing stops at its next boundary, and
382
+ teardown joins it before releasing the lease. A harvest that a dispatcher
383
+ launches never claims, renews or releases the repository lease on its own
384
+ behalf.
381
385
 
382
386
  The predecessor serializes acceptance with ticks and launch admission, joins
383
387
  repository-owned harvest and provisioning work, and records the exact local
@@ -1219,8 +1223,26 @@ from 1 to 100 (default 25). Malformed positions, cursors, filters and limits
1219
1223
  reject, as does a cursor issued for the other order. Unknown repositories
1220
1224
  answer empty without creating state. A remote server that cannot filter
1221
1225
  fails a filtered request with `BuildFeedUnsupportedError`; the client never
1222
- filters an unfiltered page itself. Scoped build and session handles reject both
1223
- methods. The feed is what derived reducers advance by (§7.7). Two implementations of one contract (`packages/core/src/store/contract.ts` is the shared
1226
+ filters an unfiltered page itself.
1227
+ `listMergedBuildsPage(repo, { since?, until?, cursor?, limit? })` returns one
1228
+ page of merged builds, most recently merged first (merge time, then slug, both
1229
+ descending). Each item is the build record with four more listing facts, each
1230
+ written in the same transaction as the event that changes it: `mergedAt`, the
1231
+ latest `build.completed`'s `ts` when merged (a non-merged completion or
1232
+ `build.reopened` clears it, and no later write moves it); `pr`, number and url
1233
+ from the latest `pr.opened` or `finalize.completed`; `target`, from
1234
+ `build.created`, replaced on a node by each `node.parent-accepted`'s
1235
+ `next.target`; and `kind`. `since` is inclusive and `until` exclusive, both ISO
1236
+ instants with a zone on merge time, and the merge-order cursor continues only a
1237
+ request with the same window. A page is one bounded range scan of a merge-time
1238
+ index: at most `limit + 1` entries, zero event rows and zero reduced values,
1239
+ whatever the build count, a build's log length or the writes after its merge.
1240
+ A database that predates these facts gains them in one migration that
1241
+ backfills every row from its latest relevant events; no read path backfills.
1242
+ An invalid window, cursor or limit rejects. A remote server without the route
1243
+ answers `BuildFeedUnsupportedError`; the client never lists builds or reads
1244
+ events instead. Scoped build and session handles reject all three methods. The
1245
+ feed is what derived reducers advance by (§7.7). Two implementations of one contract (`packages/core/src/store/contract.ts` is the shared
1224
1246
  conformance suite):
1225
1247
 
1226
1248
  1. **Local** — one self-contained state tree at `<main-repo>/.autobuild/` by
@@ -1312,7 +1334,9 @@ backfilled once, when its migration creates it; no read path backfills.
1312
1334
  `builds.list` (active and queued), `merges.list`, the dashboard snapshot
1313
1335
  (§16.1) and `repository.status` capacity read it, so their cost follows open
1314
1336
  builds and never settled history. `builds.list --all` is an explicit history
1315
- read and still lists every build. A remote server without the operation
1337
+ read and still lists every build. `builds.list` scope `merged` is one
1338
+ `listMergedBuildsPage` call per page and reads nothing else, so a "what shipped
1339
+ since T" digest costs its page. A remote server without the operation
1316
1340
  answers a typed capability failure, and the client never falls back to
1317
1341
  listing every build or the digest batch.
1318
1342
 
@@ -2005,11 +2029,26 @@ attempt. A tick that defers such work counts it as `provisioningDeferred` or
2005
2029
  reported idle. It records those builds in the latest-only, advisory
2006
2030
  `dispatcher.work-deferred` fact (a deferral noted after the work deadline is
2007
2031
  written in teardown, under the cleanup deadline, while the repository lease is
2008
- still held), and the next invocation sweeps them before its
2032
+ still held), and the next invocation serves them before its
2009
2033
  other stages, re-deriving every decision from build state. The fact is a
2010
2034
  scheduling hint, never authority; an entry leaves it only after its own pass
2011
2035
  finishes without deferring again. Carried recoveries start within half of the
2012
2036
  window that remains.
2037
+ Every start a bounded pass admits but does not finish is carried this way, so a
2038
+ held slot always has its start in progress or first in the next pass. A first
2039
+ provision the budget defers right after a claim is carried as `provision`, and
2040
+ the next invocation serves a carried build that is still queued by completing
2041
+ its dispatch. A launch the work deadline cuts after claiming the build's
2042
+ execution lease is carried as `launch`. Bounded teardown awaits it before the
2043
+ repository lease is released. A start never requested releases the exact-holder
2044
+ lease. A requested start is fenced first and released only after the fence is
2045
+ confirmed, because a released but running guest could re-claim the lease beside
2046
+ a replacement. When teardown cannot confirm the fence or the release, the entry
2047
+ keeps the cut execution's `instance` and the step still owed (`fence` or
2048
+ `launch`). The next invocation finishes that exact work first, and only while
2049
+ that instance still holds the lease; the lease never waits on its TTL. A
2050
+ carried entry retires without launching when its build is aborted, discarded,
2051
+ paused or no longer needs the start.
2013
2052
  No stage consumes a bounded pass. Its stages run in order (deferred work,
2014
2053
  settlement, ticket preparations, janitor, recovery, lease sweep, admission,
2015
2054
  intake), and each may start new items only until its share of the time left
@@ -2551,7 +2590,12 @@ and reads zero event rows when nothing changed since the cursor.
2551
2590
 
2552
2591
  Each registered project also has a per-repository binding at
2553
2592
  `<resource>/<host><path>`, derived from its identity. It serves the same table
2554
- for that one repository: its tool schemas omit `repo`, it offers no
2593
+ for that one repository: its tool schemas omit `repo`, and a call that
2594
+ passes `repo` (even naming that repository) or `repository` is refused as
2595
+ `validation` with code `repo-argument` and the contract text. Every tool
2596
+ names its repository `repo`, never `repository`; on every binding a
2597
+ `repository` argument or a missing `repo` is refused with that same contract.
2598
+ It offers no
2555
2599
  `repositories.list`, and it lists `sandbox.*` only when that repository's
2556
2600
  latest deposited effective config enables `[orchestrator]`, with one bounded
2557
2601
  latest-artifact read per listing. Its tokens are bound to their RFC 8707
@@ -2994,7 +3038,7 @@ the matching phase and `round`; a missing round cannot broaden either cause.
2994
3038
  `review-round-limit` retains the same matching-round effect.
2995
3039
  `verify-failure-limit` is the explicit phase-level case and re-arms every
2996
3040
  phase-runner failure round for its verify target. `reconcile-no-progress`,
2997
- `setup-failure-limit`, `wait-unresolvable`, `measurement-failed` and `target-rewritten` have no phase-runner failure-budget effect (setup's own
3041
+ `setup-failure-limit`, `wait-unresolvable`, `measurement-failed`, `target-rewritten` and `dirty-worktree` have no phase-runner failure-budget effect (setup's own
2998
3042
  answer/retry accounting remains separate). Agent and stall raises, and
2999
3043
  cause-less historical policy raises, retain the legacy shape rule: a matching
3000
3044
  round resets that round and an absent round resets all rounds for the target.
@@ -3002,6 +3046,46 @@ The closed `policyCause` union has an exhaustive reset-scope mapping, so adding
3002
3046
  a policy cause requires choosing matching-round, all-round, or no-reset
3003
3047
  semantics rather than acquiring behavior by omitting `round`.
3004
3048
 
3049
+ **Dirty tracked worktree.** `policy/dirty-worktree` targets `implement` with no
3050
+ `round`. The runner raises it, at most once while one is open, when
3051
+ `[commands].setup` newly modifies tracked files outside `[[generated]]` at
3052
+ attach or after a base move (§15.6-C), and when a restack or reconcile
3053
+ preparation refuses undeclared tracked dirt (§15.7 "Generated-file
3054
+ regeneration"). Its question lists the bounded paths (at most 20, then
3055
+ `(+N more)`) and the origin. Answering it with guidance or a bare retry returns
3056
+ the build to `implement`; Autobuild never commits or discards those files
3057
+ itself:
3058
+
3059
+ - **Nothing frozen:** `implement` runs at the next round. Its feedback is the
3060
+ question with its paths plus the answer.
3061
+ - **A frozen preparation without a publish intent** (an active automatic
3062
+ restack or an open reconcile occurrence) is first superseded with
3063
+ `reconcile.superseded {cause: dirty-worktree}`. The runner returns a
3064
+ workspace a replay left detached to the unchanged build branch, carrying
3065
+ the changes; then `implement` runs. When Git refuses to carry them because
3066
+ the target also changed a dirty file, the runner first sets them aside as
3067
+ below (artifact plus observation, then restore) and the `implement`
3068
+ feedback names the artifact.
3069
+ - **A frozen preparation with a publish intent** settles first: the runner
3070
+ stores the undeclared changes as a byte-exact binary patch artifact
3071
+ (`git diff --binary --no-textconv --no-ext-diff`, re-applied with
3072
+ `git apply --binary`) `dirty-worktree-<escalation>`, records observation
3073
+ `dirty-worktree:<escalation>:set-aside`, restores the paths and publishes the
3074
+ frozen candidate as recorded. The `implement` feedback names the artifact.
3075
+
3076
+ A set-aside that runs again for the same escalation (a stop before the
3077
+ restore, or a later preparation in the same recovery) resets only bytes the
3078
+ artifact's latest revision holds. When the tree differs, for example because
3079
+ setup rewrote a path on relaunch, the runner first stores a new revision with
3080
+ each currently dirty file's change plus every file only an earlier revision
3081
+ held.
3082
+
3083
+ The recovery round is the first `implement` round started after the answer.
3084
+ Until it completes, every rerun is that round with the same feedback, rebuilt
3085
+ from durable facts, and the setup dirt check is skipped for it. A spec
3086
+ revision after the answer cancels the recovery. Once the round completes, the
3087
+ ordinary code loop resumes.
3088
+
3005
3089
  Reconcile has two distinct policy scopes. Runner retry exhaustion and
3006
3090
  non-retryable failures at progress-check or base-refresh boundaries are scoped
3007
3091
  to a concrete reconcile `round`. Unchanged-base no-progress exhaustion is
@@ -5105,7 +5189,8 @@ catalog lookup. Hosted reads use one GET `/repos/:repo/change-position`
5105
5189
  returning only `{ position: string }`; `/repos/:repo/builds` returns scoped
5106
5190
  build records; `/repos/:repo/changed-builds?since=` and
5107
5191
  `/repos/:repo/build-page?limit=&cursor=&kind=&outcome=&activeSince=` serve the
5108
- feed and the paged listing. All four routes authorize the repository
5192
+ feed and the paged listing, and `/repos/:repo/merged-build-page?limit=&cursor=&since=&until=`
5193
+ the merged listing. All five routes authorize the repository
5109
5194
  before reading and support repositories with builds but no journal.
5110
5195
 
5111
5196
  Durable operator settings (intake, repository pause, harvest gate) and pending
@@ -5434,7 +5519,7 @@ with illustrative members:
5434
5519
  | Leaf restacking | `target.moved {branch, sha, lineage?}`, `target.rewritten {branch, previousSha, sha}`, `target.rewrite-cleared {branch, sha, lineage?}`, kernel `target.rewrite-reprovision-prepared {branch, previousSha, base, from, sha}` and `target.rewrite-recovered {branch, previousSha, sha, base, recovery: reprovisioned \| accepted, escalation?, pendingLocal?}`, advisory `target.distance {branch, sha, head, count}`, `restack.prepared`, `restack.replayed`, `restack.publish-intended`, `restack.rewritten`, `restack.contended`, `restack.completed` (trigger `verify-entry`, `wait-resume` or `awaiting-landing`; an awaiting-landing intent, rewrite and completion may carry a frozen `cleanRestackPolicy {steps}`), `restack.advanced {trigger: wait-resume, cycle, observation, branch, from, to}`, kernel `restack.regenerated {id, files, commands, outcome, head?, reason?}`, kernel or dispatcher decisive `history.retained {operation: restack \| reconcile, id, base, store, target, unretained}` (leaf restacks and reconciles, §15.7) |
5435
5520
  | Head path facts | advisory `head.paths-recorded {source, head, destination, mergeBase, total, preview, resolution?, artifact}` |
5436
5521
  | Propose (§5, §13.1.1) | Kernel `propose.started {round, request}`; agent `propose.completed {round, request, proposals, artifact}` (the deposited proposal ids and the `attempts` artifact) |
5437
- | Post-PR [D1] | `pr.merged`, `pr.conflicted`, advisory dispatcher `pr.checks-failed {pr, head, buildHead, checks, total, digest}` and `pr.checks-cleared {pr, head, cause}` (forge CI on finished leaves, §15.7), `reconcile.progress-checked`, `reconcile.started`, `reconcile.prepared`, `reconcile.replayed`, `reconcile.publish-intended`, `reconcile.rewritten`, `reconcile.contended`, `reconcile.completed`, kernel `reconcile.superseded {attempt, cycle, cause: wait-resume, restackId?}` (§11 "Ticket waits") |
5522
+ | Post-PR [D1] | `pr.merged`, `pr.conflicted`, advisory dispatcher `pr.checks-failed {pr, head, buildHead, checks, total, digest}` and `pr.checks-cleared {pr, head, cause}` (forge CI on finished leaves, §15.7), `reconcile.progress-checked`, `reconcile.started`, `reconcile.prepared`, `reconcile.replayed`, `reconcile.publish-intended`, `reconcile.rewritten`, `reconcile.contended`, `reconcile.completed`, kernel `reconcile.superseded {attempt, cycle, cause: wait-resume \| dirty-worktree, restackId?}` (§11 "Ticket waits", "Dirty tracked worktree") |
5438
5523
  | Cross-cutting | `observation.recorded`, `escalation.raised`, `phase.failed`, `session.build-read-failed`, `session.build-read-recovered`, `phase.deferred`, `phase.deferral-escalated` |
5439
5524
  | Ticket waits (§11) | Agent `wait.requested {id, phase, round, tickets, reason, publication?: {branch, base, sha, settlement: published \| requested}}`; dispatcher `wait.published {id, sha}`, `wait.refused {id, cause: unknown-ticket \| own-ticket \| completed \| no-source-ticket \| publication-lost, tickets, message}` and `wait.entered {id, escalation, tickets, reason, question}`; dispatcher, kernel or human `wait.ended {id, cause: operator \| automatic, message}`; dispatcher policy `escalation.raised {policyCause: wait-unresolvable}` ends an open wait whose ticket was rejected or deleted |
5440
5525
  | Optimization (§13.1.1) | Dispatcher `optimization.objective-accepted {objective, revision, harnessPin, specRev}`; human `optimization.objective-revised {changes, revision}` (revision ≥ 2; `changes` a nonempty subset of threshold, epsilon, maxAttempts, maxHours, plateau, stopMode, concurrency); `optimization.baseline-measured {revision, head, harnessPin, samples, median, spread, report?}` (a panel records its self-comparison win rate and that rate's distance from 0.5); advisory `optimization.noise-exceeded {revision, head, harnessPin, median, spread, epsilon, effectiveEpsilon}`; dispatcher `optimization.proposal-requested {id, head, room, budgetUsed: {attempts, hours}}` (`hours` is active hours); dispatcher `optimization.proposal-deferred {reason: paused \| blocked \| command \| restack \| integration \| landing \| compatibility}`; dispatcher `optimization.proposal-withdrawn {request, reason: stopped \| budget \| concurrency}`, which clears an undeposited request and never counts as an empty proposal; dispatcher `optimization.attempts-proposed {request, proposals: [{id, ticket, title, strategy}], reason?}`, written after ticket creation, with `reason` required when `proposals` is empty; `attempt.measurement-requested {id, node, candidate, baseline, harnessPin, revision, metric?, purpose?}` (`metric` the node's command or panel metric; `purpose` the objective purpose, required with a panel metric); kernel `attempt.sampled {request, candidate, baseline, harnessPin, revision, samples, medians?: {candidate, baseline}, winRate?, report}` with exactly one of `medians` and `winRate` (`samples` is a panel's judge count); `attempt.measured {request, candidate, baseline, harnessPin, revision, samples, medians?: {candidate, baseline}, winRate?, delta, decision: improved \| no-improvement \| non-regressing \| regressed, spread?, report?}` with exactly one of `medians` and `winRate`; `optimization.progress-measured {revision, head, start, winRate, judges}`; `attempt.settled {attempt: {proposal, ticket, build?, branch?}, outcome: accepted \| no-improvement \| declined \| stopped \| aborted \| merged-unmeasured, measurement?: {revision, baseline, candidate, delta}, policy?: release-unmeasured, mergedSha?, note?, head?}`, with `measurement` required for `accepted` and `no-improvement`, `policy` required and `measurement` forbidden for `merged-unmeasured` (human actor), `policy` and `mergedSha` allowed only with it, `head` (the landed node head) only for `accepted`, and `attempt.branch` only for `declined` and `no-improvement`; `attempt.merged-unmeasured {proposal, ticket, build, sha?, reason: absent \| stale-head \| unrelated \| unresolvable, measuredCandidate?}`, with `sha` absent exactly for `unresolvable`; dispatcher `attempt.ticket-rejected {proposal, ticket, state}`, recording a settled attempt ticket move to rejected; dispatcher `attempt.branch-deleted {proposal, build, branch}` and `attempt.branch-cleanup-failed {proposal, build?, branch, error}` for a settled attempt's branch cleanup obligation; `optimization.stopped {cause: threshold \| plateau \| budget \| exhausted \| operator, mode: abort \| drain}`; dispatcher `optimization.activity-recorded {facts: [{build, n, instance, kind: started \| ended, at}], accounted, released?, watermark, starts?, settles?}`, at most 200 facts sorted by `at`, with `watermark` the bound through which the clock compacts, which records attempt execution facts into the active-hours clock; dispatcher `execution.accounted {count}`, advisory, acknowledging that a node accounted a build's first `count` execution facts. `execution.accounted`, `attempt.measurement-requested`, `attempt.sampled` and `attempt.measured` are on the attempt's log; every other member, including `attempt.settled`, is on the node's log. The dispatcher records `exhausted` after two consecutive empty proposals. All are decisive except advisory `optimization.noise-exceeded` and `execution.accounted`. A measurement failure is a kernel or dispatcher `escalation.raised {phase: measurement, source: policy, policyCause: measurement-failed}`. |
@@ -6118,6 +6203,11 @@ post-restack failure follows the same path as an attach failure: it appends
6118
6203
  `runner.setup-failed` with the next attempt, counts toward
6119
6204
  `policy.maxSetupAttempts`, ends the runner unattached, and only a later
6120
6205
  successful setup's `runner.attached {resumedFromSeq}` clears it.
6206
+ A successful setup is followed by a tracked-dirt check: tracked paths setup
6207
+ newly modified outside `[[generated]]` raise `policy/dirty-worktree` (§11)
6208
+ before any phase runs. Dirt present before setup is never blamed on it,
6209
+ declared generated outputs are left for the phase, and the check is skipped
6210
+ for a reconcile and while an answered dirty-worktree recovery is pending.
6121
6211
  The setup target belongs only to escalation metadata and is not a pipeline `Phase`.
6122
6212
 
6123
6213
  **D — runner loss and sandbox death:** local git-worktrees first attempt the
@@ -6157,8 +6247,9 @@ down. A workspace
6157
6247
  flagged by `workspace.cleanup-required` is never launched into: the dispatcher
6158
6248
  releases it and provisions the next generation. Provisioning cut off by a
6159
6249
  recorded dispatcher teardown is the exception: the next invocation asks the
6160
- provider to verify and finish the same generation, and if it cannot, the
6161
- replacement consumes no infrastructure attempt. A preservation or release
6250
+ provider to verify and finish the same generation (the Vercel provider resumes
6251
+ after its last completed stage, at the commit it cloned), and if it cannot,
6252
+ the replacement consumes no infrastructure attempt. A preservation or release
6162
6253
  failure is recorded against its build, as an infrastructure failure or janitor
6163
6254
  attention, and never stops the dispatcher from advancing other builds.
6164
6255
  Fencing is revalidated after restart; a saved receipt alone never authorizes
@@ -6550,6 +6641,15 @@ and restore the recorded conflict for reconcile, whose context names the
6550
6641
  conflicted generated files with their commands (`generated`) and a failure's
6551
6642
  `regeneration.reason`, both read from the recorded fact's `commands`, never
6552
6643
  from the checkout's `autobuild.toml`. Repositories that declare nothing are unaffected.
6644
+ Before a replay, every clean-tree gate classifies uncommitted tracked changes:
6645
+ when every dirty path is declared, the runner restores them to `HEAD` and
6646
+ records one deduplicated `followup` observation. The same classification runs
6647
+ before a completed automatic replay or a frozen intended candidate publishes,
6648
+ whatever recovery path reached it; when any path is undeclared,
6649
+ preparation refuses without touching anything and raises
6650
+ `policy/dirty-worktree` naming those paths (§11). A fresh automatic restack
6651
+ and a fresh epilogue reconcile check before `restack.prepared` or
6652
+ `reconcile.started`, so that refusal freezes nothing.
6553
6653
  Resolver completion links back to the automatic transaction. Retained commit bytes
6554
6654
  and replay object packs recover disposable-workspace objects before publication.
6555
6655
  Replay retention (`replay-objects-<sha>`) and leaf history retention (`history-objects-<sha>`) store thin Git packs in bounded binary chunks, with a fixed-size completion manifest written only after every chunk is acknowledged. Digest-keyed chunks make interrupted writes retryable; incomplete uploads are never restored. Recovery validates all chunk sizes and the pack digest before installation, and requires the base objects (restoring node prefixes in order). Existing single-artifact base64 packs remain readable. Retained replay and history artifacts are read only when the requested commit is missing locally, never by idle polling.
@@ -16,11 +16,12 @@ until the revision lands.
16
16
  | Need | Command | Effect |
17
17
  |---|---|---|
18
18
  | Give the phase a decision or missing information | `ab answer <slug> <text>` | Records `guidance`. In a review loop it feeds the next producer round; a ticket wait's answer instead resumes the phase that declared it, including the same review round. |
19
- | Try again without guidance | `ab answer <slug>` | Records a bare `retry`; no prose is delivered to an agent, except that a ticket wait's declaring phase, resumed at its original round or attempt, still gets a one-line summary and its `wait` block. A verify or finalize wait that restacked re-runs verification at a new attempt without that block; see [Ending a ticket wait](#ending-a-ticket-wait). |
19
+ | Try again without guidance | `ab answer <slug>` | Records a bare `retry`; no prose is delivered to an agent, with two exceptions. A ticket wait's declaring phase, resumed at its original round or attempt, still gets a one-line summary and its `wait` block; a verify or finalize wait that restacked re-runs verification at a new attempt without that block (see [Ending a ticket wait](#ending-a-ticket-wait)). A `dirty-worktree` escalation's next `implement` round gets the dirty-file question, its paths, any recovery instructions and a one-line retry summary as guidance (see [Dirty tracked worktree](#dirty-tracked-worktree)). |
20
20
  | Widen an exhausted review loop | `ab answer <slug> [<text>] --review-round-ceiling <n>` | Answers the open `review-round-limit` escalation and replaces the configured cap with absolute ceiling `n` for that loop and spec revision only. |
21
21
  | Retire a review disagreement | `ab answer <slug> --dismiss` | Records `dismiss-finding` for each escalation that cites a real finding id. The next reviewer is told not to re-raise that chain. |
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
+ | Recover a dirty tracked worktree | `ab answer <slug> [<text>]` | Answers a `dirty-worktree` escalation; the build returns to `implement` with the dirty paths. See [Dirty tracked worktree](#dirty-tracked-worktree). |
24
25
  | 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
26
  | 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
27
 
@@ -72,6 +73,38 @@ answer forms skip this escalation. If the accept finds unpublished local
72
73
  commits that no open phase owns, it is refused with a fresh escalation listing
73
74
  them.
74
75
 
76
+ ## Dirty tracked worktree
77
+
78
+ A `policy/dirty-worktree` escalation means tracked files have uncommitted
79
+ changes outside `[[generated]]`. Its question names the paths (at most 20, then
80
+ `(+N more)`) and the origin:
81
+
82
+ - **Setup.** `[commands].setup` newly modified them at attach or after a base
83
+ move, before the next phase ran. Code review never sees them. The check is
84
+ skipped when that phase is a `reconcile`, whose resolver works on its own
85
+ in-progress replay; restack and reconcile preparation still classify tracked
86
+ dirt before replaying.
87
+ - **Restack or reconcile preparation.** They were present when a replay was
88
+ about to start. Changes confined to `[[generated]]` never get here; they are
89
+ discarded before the replay.
90
+
91
+ Autobuild never commits or discards these files on its own. Answer with
92
+ guidance (`ab answer <slug> <text>`) or a bare retry (`ab answer <slug>`); both
93
+ return the build to `implement`, whose feedback is the question, its paths and
94
+ your answer:
95
+
96
+ | State when answered | What happens before `implement` |
97
+ |---|---|
98
+ | Nothing frozen | Nothing; `implement` runs at the next round. |
99
+ | A frozen restack or reconcile with no publish intent | `reconcile.superseded {cause: dirty-worktree}`; the workspace returns to the build branch with the files still changed. When the target also changed one of them, the changes are first stored as artifact `dirty-worktree-<escalation>` and restored, as in the next row. |
100
+ | A frozen candidate with a publish intent | The changes are stored as artifact `dirty-worktree-<escalation>`, restored, and the candidate publishes as recorded. The feedback tells the agent to fetch it with `ab artifact download` and `git apply --binary --3way`. |
101
+
102
+ The agent commits, reverts or regenerates each file, or fixes
103
+ `[commands].setup` or `[[generated]]`. A crash during that round reruns the
104
+ same round with the same feedback, and setup's dirt check is skipped for it.
105
+ The build then continues through code review and a fresh restack. Do not
106
+ abort; aborting discards the build's work for a recoverable condition.
107
+
75
108
  ## Ending a ticket wait
76
109
 
77
110
  A build whose agent ran `ab wait-on` asks to wait on other tickets. Until the
@@ -702,6 +702,10 @@ clean stop. The next generation resumes eligible native sessions with fresh
702
702
  logical credentials, or records a reasoned `harvest.session.resume-fallback`
703
703
  and starts fresh. Orderly suspension spends no recovery attempt; real crashes
704
704
  retain recovery accounting.
705
+ A hosted harvest launch that is still preparing stops at its next boundary, and
706
+ teardown joins it before releasing the lease. A harvest that a dispatcher
707
+ launches never claims, renews or releases the repository lease on its own
708
+ behalf.
705
709
 
706
710
  The advisory
707
711
  `dispatcher.upgrade-target-resolved` fact independently retains each run's latest
@@ -826,8 +830,9 @@ down. A workspace
826
830
  flagged by `workspace.cleanup-required` is never launched into: the dispatcher
827
831
  releases it and provisions the next generation. Provisioning cut off by a
828
832
  recorded dispatcher teardown is the exception: the next invocation asks the
829
- provider to verify and finish the same generation, and if it cannot, the
830
- replacement consumes no infrastructure attempt. A preservation or release
833
+ provider to verify and finish the same generation (the Vercel provider resumes
834
+ after its last completed stage, at the commit it cloned), and if it cannot,
835
+ the replacement consumes no infrastructure attempt. A preservation or release
831
836
  failure is recorded against its build, as an infrastructure failure or janitor
832
837
  attention, and never stops the dispatcher from advancing other builds.
833
838
  Work a bounded invocation defers for budget (a provision, or a stopped-sandbox
@@ -837,11 +842,30 @@ counted as `provisioningDeferred` or `recoveryDeferred` with one diagnostic line
837
842
  per build, and carried in the latest-only `dispatcher.work-deferred` fact; one
838
843
  noted after the work signal aborts is written through the tick's
839
844
  `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`
845
+ next tick's first stage, `serviceDeferredWork`, serves those builds before
846
+ settlement and the janitor through `serviceCarriedStart`: a carried cut
847
+ holder first, then `attemptDispatchCompletion` for a build still queued (a
848
+ first provision the budget gate deferred after a claim), and the ordinary
849
+ `sweepBuild` pass otherwise, with the facts it already read and without the
850
+ first-claim grace. Settlement, dispatch recovery (`recoverDispatches`) and the
851
+ lease sweep skip what it took up. A resume the deadline cuts short is stopped
852
+ or left uncertain, and observation reports a budget deferral as a `running`
844
853
  observation marked `deferred`.
854
+ A launch the work deadline cuts after `DispatchLoop.launchRunner` claimed the
855
+ build's execution lease records nothing itself: it throws `LaunchCutByDeadline`
856
+ (`processes/launch-cut.ts`) carrying the instance and whether the provider
857
+ start was requested, and `launchRunner` re-checks `acceptingBuildLaunches`
858
+ immediately before that start. `Dispatcher.startRunner` catches it and runs
859
+ `settleCutLaunch`, and `settleCutHolder` does the work through the tick's
860
+ teardown scope: it fences a requested start with the owning provider's
861
+ `recovery.fence` (passing `{ teardown: true }`, so Vercel bounds the calls by
862
+ its operation timeout and the cleanup scope), then releases the exact-holder
863
+ lease. What it cannot finish is noted with the cut `instance` and the step
864
+ still owed, and the next invocation's `serviceCarriedStart` settles that exact
865
+ holder before anything else. Starts are tracked in flight, and bounded
866
+ teardown awaits `Dispatcher.settleCutStarts()` as a racer beside provisioning
867
+ abandonment, before the repository lease is released; it prints each deferral
868
+ line the tick has not reported, and the cut pass's partial summary counts them.
845
869
  Stage fairness lives in `processes/pass-stages.ts` (pure: shares, rotation,
846
870
  the stage record and its rendering). `Dispatcher.runTick` wraps each stage in
847
871
  `runStage`, which hands its helpers a copy of the tick options whose
@@ -1590,7 +1614,7 @@ listing every build.
1590
1614
 
1591
1615
  Positions are ordered. `packages/core/src/store/build-feed.ts` holds the shared
1592
1616
  changed-builds feed and paged-listing vocabulary (`listBuildsChangedSince`,
1593
- `listBuildsPage`, cursor and position codecs). Each build's latest position
1617
+ `listBuildsPage`, `listMergedBuildsPage`, windows, cursor and position codecs). Each build's latest position
1594
1618
  lives in `build_change_positions`, written by the same trigger that advances
1595
1619
  the counter (memory: a one-node-per-build linked list); its first creation
1596
1620
  backfills existing builds once at a bumped head. The paged listing's filters
@@ -1609,6 +1633,16 @@ adapter keeps the same classes as sorted slug lists, moved in the step that
1609
1633
  writes the fact or `updatedAt`. Its first creation backfills existing builds
1610
1634
  once from their latest relevant events. The PostgreSQL DDL is additive, like
1611
1635
  the counter's, and must be migrated before the service rollout.
1636
+ The merged listing (`listMergedBuildsPage`, behind `builds.list` scope
1637
+ `merged`) reads four more `build_listing_facts` columns added by guarded
1638
+ `ALTER`s: `merged_at` (the merging `build.completed`'s `ts`), `pr_number`,
1639
+ `pr_url` and `target`, kept by their own separately named triggers so an older
1640
+ release's migrate never strips them. One partial index on `(repo, merged_at,
1641
+ slug)` makes a page one backward range scan in merge-time order; the memory
1642
+ adapter keeps a sorted merged-slug list. Adding the columns backfills every row
1643
+ once. `operator/merged-builds.ts` maps one page into the tool answer with no
1644
+ further read, and `operator/repo-argument.ts` holds the `repo` argument
1645
+ contract every operator binding reports.
1612
1646
  `detail.ts` projects chronological session history from the same retained log,
1613
1647
  including a distinct transcriptless `reclaimed` ending, and `transcript.ts`
1614
1648
  heuristically presents ordinary opaque transcript artifacts with a raw
@@ -1213,7 +1213,7 @@ environmentVariables = ["AI_GATEWAY_API_KEY"]
1213
1213
  provisioning = [
1214
1214
  { name = "system-install", command = """apt-get update
1215
1215
  DEBIAN_FRONTEND=noninteractive apt-get install -y chromium""" },
1216
- { name = "browser-smoke", command = "CHROMIUM_BIN=/usr/bin/chromium ./scripts/browser-smoke.sh" },
1216
+ { name = "browser-smoke", command = "CHROMIUM_BIN=/usr/bin/chromium ./scripts/browser-smoke.sh", timeoutSeconds = 300 },
1217
1217
  ]
1218
1218
  # Private repositories only:
1219
1219
  gitUsernameEnv = "AB_GIT_READ_USER"
@@ -1376,7 +1376,7 @@ preflight = "test \"$(pi --version)\" = \"0.84.4\" && pi update --models"
1376
1376
  - **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.
1377
1377
  - **Local override:** Committed only: set in autobuild.toml.
1378
1378
 
1379
- **Description:** ordered strict inline tables `{ name, command }`; names and commands are nonblank and names are unique
1379
+ **Description:** ordered strict inline tables `{ name, command, timeoutSeconds? }`; names and commands are nonblank and names are unique
1380
1380
 
1381
1381
  **Constraints:** None beyond the input type.
1382
1382
 
@@ -1408,6 +1408,20 @@ preflight = "test \"$(pi --version)\" = \"0.84.4\" && pi update --models"
1408
1408
 
1409
1409
  **Constraints:** provisioning step command must be nonblank
1410
1410
 
1411
+ #### `workspace.config.provisioning[].timeoutSeconds`
1412
+
1413
+ **TOML key:** `workspace.config.provisioning[].timeoutSeconds`
1414
+
1415
+ - **Type:** `number`
1416
+ - **Default:** `omitted`
1417
+ - **Required:** Optional
1418
+ - **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.
1419
+ - **Local override:** Committed only: set in autobuild.toml.
1420
+
1421
+ **Description:** Optional per-step timeout in seconds (default 600, at most 840). The sandbox kills the step when it elapses, and provisioning fails with the step name, command, elapsed time, and output so far.
1422
+
1423
+ **Constraints:** safe integer; ≥ 1; ≤ 840
1424
+
1411
1425
  #### `workspace.config.runtimeProvisioning`
1412
1426
 
1413
1427
  **TOML key:** `workspace.config.runtimeProvisioning`
@@ -1628,7 +1642,10 @@ treated as running:
1628
1642
  the tick counts it as `recoveryDeferred`, logs
1629
1643
  `build <slug>: <step> deferred by the invocation budget`, and records the
1630
1644
  build in the latest-only `dispatcher.work-deferred` fact. The next
1631
- invocation sweeps those builds first, within half of the window.
1645
+ invocation runs those builds first, within half of the window. A launch the
1646
+ work deadline cuts after claiming the build's execution lease is carried
1647
+ the same way, as step `launch`: teardown fences the sandbox if the start was
1648
+ requested, then releases the lease, or the next invocation does both first.
1632
1649
  - **No redundant stops.** Fence and cleanup skip `stop()` for a sandbox the
1633
1650
  provider already reports stopped.
1634
1651
  - **Failures name their step.** `infrastructure.failed` and the exhaustion
@@ -1653,11 +1670,13 @@ The dispatcher releases it automatically, recording an empty
1653
1670
  checkout that never started executing lacks its objects, and provisions
1654
1671
  the next generation. A sandbox whose provisioning a dispatcher teardown cut off
1655
1672
  is different: the next invocation verifies it and finishes it in the same
1656
- generation. If it cannot be finished, it is released and replaced without
1673
+ generation, resuming after its last completed stage at the commit it cloned. If it cannot be finished, it is released and replaced without
1657
1674
  consuming `maxInfrastructureAttempts`. A bounded dispatcher invocation does not
1658
1675
  start provisioning with less than about 150 s of budget left; it records
1659
1676
  `provisioningDeferred` in the tick report, logs the build, and records it in
1660
- `dispatcher.work-deferred`, so the next invocation provisions it first.
1677
+ `dispatcher.work-deferred`, so the next invocation provisions it first. That
1678
+ includes the first provision of a build intake just claimed: the build keeps
1679
+ its slot, and the next invocation completes its dispatch first.
1661
1680
 
1662
1681
  The representative actual-provider check is opt-in and must point at an
1663
1682
  independent consuming repository whose `autobuild.toml` selects the universal
@@ -1761,7 +1780,14 @@ exit status, attempt, and output. Retries are bounded by
1761
1780
  `policy.maxSetupAttempts`; exhaustion blocks on a setup-targeted policy
1762
1781
  escalation without creating a phase or verification result. A failure after a
1763
1782
  base move stops dependent work the same way. Only a later successful attachment
1764
- clears the current error projection. Other names run only when
1783
+ clears the current error projection. Setup must not modify tracked files: paths
1784
+ it newly changes outside `[[generated]]` raise `policy/dirty-worktree` naming
1785
+ them before the next phase runs (see
1786
+ [Answering blocked builds](answering-blocked-builds.md#dirty-tracked-worktree)).
1787
+ The check is skipped when that phase is a `reconcile`, whose resolver works on
1788
+ its own in-progress replay, and while an answered dirty-worktree recovery is
1789
+ pending; restack and reconcile preparation still classify tracked dirt before
1790
+ replaying. Other names run only when
1765
1791
  referenced by a configured check. A check's `command` value is the key in this
1766
1792
  map, not an inline shell command. The kernel passes the mapped string to a shell
1767
1793
  as written.
@@ -1784,7 +1810,7 @@ declares nothing, and restacks behave exactly as they do without it.
1784
1810
  - **Reload:** Hot: next dispatcher action captures the accepted value. A running invocation keeps its captured values.
1785
1811
  - **Local override:** Committed only: set in autobuild.toml.
1786
1812
 
1787
- **Description:** Generated files that a declared command rebuilds. Restack replays that conflict only in these files are regenerated instead of reconciled by an agent.
1813
+ **Description:** Generated files that a declared command rebuilds. Restack replays that conflict only in these files are regenerated instead of reconciled by an agent, and uncommitted changes to them are discarded before a replay.
1788
1814
 
1789
1815
  **Constraints:** A path selector string may be declared by only one entry.
1790
1816
 
@@ -1851,6 +1877,10 @@ automatic restack and to every item of a node restack. The rules:
1851
1877
  to the agent as well; its context lists the generated files and their
1852
1878
  commands, and the agent rebuilds them with the command instead of
1853
1879
  hand-merging them.
1880
+ - Uncommitted changes to declared files, such as outputs `[commands].setup`
1881
+ rewrote, are restored to `HEAD` before any restack or reconcile replay. Any
1882
+ undeclared tracked change refuses preparation instead; see
1883
+ [Tracked dirt before preparation](restacking.md#tracked-dirt-before-preparation).
1854
1884
 
1855
1885
  See [Generated-file conflicts](restacking.md#generated-file-conflicts) for the
1856
1886
  recorded facts and how status reports them.
@@ -5113,6 +5143,10 @@ clean stop. The next generation resumes eligible native sessions with fresh
5113
5143
  logical credentials, or records a reasoned `harvest.session.resume-fallback`
5114
5144
  and starts fresh. Orderly suspension spends no recovery attempt; real crashes
5115
5145
  retain recovery accounting.
5146
+ A hosted harvest launch that is still preparing stops at its next boundary, and
5147
+ teardown joins it before releasing the lease. A harvest that a dispatcher
5148
+ launches never claims, renews or releases the repository lease on its own
5149
+ behalf.
5116
5150
 
5117
5151
  The predecessor serializes acceptance with ticks and launch admission, joins
5118
5152
  repository-owned harvest and provisioning work, and records the exact local
@@ -96,6 +96,9 @@ invocation after the last item they started; priority-ordered loops (node
96
96
  admission, start requests, ready tickets, ticket waits) keep their order. Each
97
97
  pass logs a `stages:` line; see
98
98
  [a stage keeps stopping at the work deadline](troubleshooting.md#a-stage-keeps-stopping-at-the-work-deadline).
99
+ Deferred work is every start a pass admitted but didn't finish (a provision, a
100
+ launch the work deadline cut, or a stopped-sandbox recovery); the next
101
+ invocation runs it first.
99
102
 
100
103
  ### Origin-mode dispatcher with remote workspaces
101
104
 
@@ -5,7 +5,9 @@ contract at
5
5
  `/operator/v1/repos/{repo}`. It is versioned with remote store protocol **7**.
6
6
  Every request must send `X-Autobuild-Version`,
7
7
  `X-Autobuild-Protocol-Version: 7`, and `Authorization: Bearer …`. Identity is
8
- checked before authentication or resource lookup.
8
+ checked before authentication or resource lookup. The optional, diagnostic
9
+ `X-Autobuild-Caller` header follows the remote store protocol's transport
10
+ conventions.
9
11
 
10
12
  Project credentials are opaque `abp_1_<id>_<secret>` bearer values bound to one
11
13
  registered normalized repository. The service stores only a SHA-256 digest of
@@ -85,6 +87,7 @@ raw session-event append. External operator harnesses own agent execution.
85
87
  | Method and path | Result |
86
88
  |---|---|
87
89
  | `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. |
90
+ | `GET …/builds?scope=merged&since=T&until=T&limit=N&cursor=C` | `{builds, next}`: merged builds, most recently merged first, each `{slug, mergedAt, kind, ticket?, pr?, target?}`. `mergedAt` is when the build merged, never a later cleanup write; `kind` is `leaf` or `node`; `pr` is `{number, url}`; `target` is `{build, ticket}` for a child of a node. `since` (inclusive) and `until` (exclusive) are ISO instants with a zone; `limit` is 1–100 (default 25); pass `next` back as `cursor` with the same window. One indexed page read, no event rows. These four parameters on another scope are a `400 validation`; a bad window, limit or cursor is `400 validation` with code `invalid-page`. |
88
91
  | `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
92
  | `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
93
  | `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. |
@@ -194,7 +197,8 @@ both refusals record nothing.
194
197
 
195
198
  One generic route executes any entry of the agent tool registry (the same
196
199
  closed table `ab mcp` serves over stdio): the body is the tool's validated input — `repo`
197
- included and required to equal the URL's repository — and the response is the
200
+ included and required to equal the URL's repository; a `repository` key is
201
+ refused as `400 validation` with code `repo-argument` — and the response is the
198
202
  registry result verbatim. The verified operator token supplies the acting
199
203
  identity and, when minted with one, the `via` attribution marker; the body
200
204
  never does. Failures keep the shared `{kind,error,code?,progress?,state?}` shape
@@ -208,7 +212,10 @@ deployment can host operator sandboxes, and each call is gated per repository
208
212
  on the latest deposited effective config. A closed gate is a `409 refusal`
209
213
  with code `sandbox-orchestrator-disabled`, `sandbox-no-effective-config`,
210
214
  `sandbox-effective-config-invalid`, `sandbox-credentials-missing` or
211
- `sandbox-backend-unavailable`.
215
+ `sandbox-backend-unavailable`. Hosted `/mcp` tool calls reach this route
216
+ with the caller attribution `X-Autobuild-Caller: kind=operator;client=mcp`
217
+ (see the remote store protocol's transport conventions), so the service's
218
+ request logs can tell them apart.
212
219
 
213
220
  ### Per-repository MCP URLs
214
221
 
@@ -220,7 +227,8 @@ URL. Adding it to an agent harness connects that harness to one repository.
220
227
  | URL | `<resource>` | `<resource>/<host><path>`, e.g. `https://ops.example/mcp/github.com/acme/widgets` for `https://github.com/acme/widgets` |
221
228
  | Tool schemas | every tool requires `repo` | no `repo` field; the URL's repository is supplied |
222
229
  | `repositories.list` | offered | not offered |
223
- | A `repo` argument | names the repository | equal to the URL's repository is ignored; any other is a `validation` result |
230
+ | A `repo` argument | names the repository | refused, even the URL's own repository: a `validation` result with code `repo-argument` |
231
+ | A `repository` argument | refused: `validation`, code `repo-argument` (the argument is `repo`) | refused: `validation`, code `repo-argument` |
224
232
  | `sandbox.*` listed | when the deployment can host sandboxes | also needs the repository's latest deposited effective config to enable `[orchestrator]` (one latest-artifact read per listing) |
225
233
  | Instructions | describe the deployment, with each accessible repository's agent context | name only that repository, with its agent context |
226
234
  | Prompts | one per skill per accessible repository, `<label>.<skill>` | one per skill, named for the skill |
@@ -327,7 +335,9 @@ the browser user's human actor while no token or signing secret reaches client
327
335
  code. Responses are private/no-store; 401 requires reauthentication.
328
336
  Polling clients may use a two-second interval. The gateway provides no
329
337
  streaming transport; `ab watch` polls store event reads client-side. Delegated bearer tokens remain
330
- server-side.
338
+ server-side. Delegated requests carry `X-Autobuild-Caller:
339
+ kind=operator;client=web`, set by the gateway; a browser cannot choose its
340
+ own attribution.
331
341
 
332
342
  The API does not expose phase-session commands, runner startup, a push or
333
343
  long-poll streaming transport, or a generic event-append operation; event
@@ -50,6 +50,7 @@ Declare served model prefixes and a default. Optional tool-free `oneShot` sits b
50
50
  - Resume an intact branch non-destructively, never silently re-cut from a newer base. Rematerialize a lost copy. Make release idempotent.
51
51
  - Optional `provision.publication` supplies a durable confirmed SHA and known cache tips for authoritative readback and cache repair. Preserve unknown unpublished work.
52
52
  - Optional `provision.fresh: { owner }` marks a build's first provision. A pre-existing branch of that name is not the build's work: never return it as the base unless you hold your own creation receipt for `owner` (stable across that build's retries). Cut from `baseBranch` and keep the old tip recoverable. Providers that ignore it rely on claim-time deduplication.
53
+ - Optional `provision.signal` is the invocation's teardown token: abort in-flight provisioning promptly and record nothing; the dispatcher records the abandonment. Optional `provision.onProgress({ stage, step? })` reports each stage just before it runs, so a teardown can name it; it must never block or throw.
53
54
  - Optional `localBranchExists(repo, branch)` reports a local `refs/heads/<branch>` in the checkout you create branches in, and throws when the probe fails. Dispatch calls it only at claim time and skips such a slug. Omit it when your branches aren't local; `remoteBranchExists` covers those.
54
55
 
55
56
  ### `forge`
@@ -114,6 +114,15 @@ Placement is informational and does not change `ab dispatch` behavior.
114
114
  body parsing, or resource lookup, the server validates the release-line window and known protocol identity.
115
115
  Unsupported or missing values receive `409 {"kind":"conflict","error":"…"}`;
116
116
  the diagnostic names the client and server package and protocol versions.
117
+ - Clients may send `X-Autobuild-Caller`, a diagnostic attribution of who made
118
+ the request: `key=value` pairs joined by `;`, at most 512 characters. Keys
119
+ are `kind` (`dispatcher`, `runner` or `operator`), `client`, `runner`,
120
+ `invocation`, `run`, `stage`, `build`, `harvest`, `execution`, `session`,
121
+ `phase` and `command`; each value is at most 96 characters of
122
+ `[A-Za-z0-9._:@+/-]`. The shipped client sends it on store, ticket, grant
123
+ and credential requests. A server must accept requests without it, must
124
+ treat it as untrusted (bound, sanitize, ignore unknown keys), and must never
125
+ use it for authorization or routing.
117
126
  - Clients send `Content-Type: application/json` for requests with bodies. Every
118
127
  response, including errors and `null` artifact results, has
119
128
  `Content-Type: application/json`.
@@ -763,7 +772,7 @@ artifacts, and leases. `{repo}` is one percent-encoded repository id; encode
763
772
  embedded `/` characters. All resource routes authorize and require the
764
773
  repository to exist. An unknown repository returns `404 not-found` — except
765
774
  for the build-record reads of this section (`change-position`, `builds`,
766
- `changed-builds`, `build-page`, `build-digests`, `open-builds` and `rollup-values`), which are keyed
775
+ `changed-builds`, `build-page`, `merged-build-page`, `build-digests`, `open-builds` and `rollup-values`), which are keyed
767
776
  to build records, not the repository journal record, so they authorize the
768
777
  project credential but answer `200` (possibly empty) even for an unknown
769
778
  repository, a repository without a journal record, or a repository without
@@ -787,6 +796,7 @@ builds.
787
796
  | `listBuildsForRepo` | `GET /repos/{repo}/builds` | none | `200` + `BuildRecord[]` ordered by creation time, then slug |
788
797
  | `listBuildsChangedSince` | `GET /repos/{repo}/changed-builds?since={p}` | required `since`, a canonical unsigned decimal no greater than 9223372036854775807; anything else is `400 validation` | `200 {"position": string, "builds": [{"slug": string, "position": string}]}`: the builds whose latest change position is greater than `since`, ascending by position and each once, with the repository head read in the same snapshot. Reads no event rows. An unknown repository answers `{"position": "0", "builds": []}` |
789
798
  | `listBuildsPage` | `GET /repos/{repo}/build-page?limit={n}&cursor={c}&kind={k}&outcome=merged&activeSince={t}` | optional `limit`, a decimal integer from 1 to 100 (default 25); optional `cursor`, a `next` value this server issued for the same filters; optional `kind`, `leaf` or `node`; optional `outcome`, only `merged`; optional `activeSince`, an ISO instant with a zone. A bad limit, a malformed cursor, a cursor of the other order, or an empty or invalid filter is `400 validation` | `200 {"builds": BuildRecord[], "next": string \| null, "filters"?: {"kind"?, "outcome"?, "activeSince"?}}`: one page newest first by creation time, slug descending to break ties, with records as `builds` returns them; `next` is `null` on the last page. `kind` and `outcome` keep that order. `activeSince` keeps builds whose `updatedAt` is at or after it, ordered by `updatedAt` then slug, both descending, a superset of builds active in the window; a build written between two requests can appear twice or be skipped once, so dedupe by slug. A filtered answer echoes the normalized filters it applied as `filters`. Every page, filtered or not, costs at most `limit + 1` index entries and no event rows |
799
+ | `listMergedBuildsPage` | `GET /repos/{repo}/merged-build-page?limit={n}&cursor={c}&since={t}&until={t}` | optional `limit`, as for `build-page`; optional `cursor`, a `next` value this server issued for the same window; optional `since` (inclusive) and `until` (exclusive), ISO instants with a zone. A bad limit, a malformed cursor, a cursor of another order, an empty or invalid instant, or `since` after `until` is `400 validation` | `200 {"builds": [{"record": BuildRecord, "mergedAt": string, "kind": "leaf" \| "node", "pr"?: {"number", "url"}, "target"?: {"build", "ticket"}}], "next": string \| null}`: merged builds, most recently merged first (merge time, then slug, both descending). `mergedAt` is the merging `build.completed`'s `ts`; `pr` comes from the latest `pr.opened` or `finalize.completed`; `target` from `build.created`, replaced on a node by `node.parent-accepted`. Every page costs at most `limit + 1` index entries, no event rows and no reduced values |
790
800
  | `getReducerValue` (rollup scope) | `POST /repos/{repo}/rollup-values` | a named-value request with optional `read`; see [Rollup values](#rollup-values) | `200 {"version", "cursor": 0, "value"}`: the canonical rollup; an unknown repository answers the empty value |
791
801
  | `getRepoBuildDigests` | `GET /repos/{repo}/build-digests` | none | `200` + `BuildDigest[]`, one entry per build record of the repository (possibly empty), ordered by slug; handled before the repository-existence gate, so an unknown or journal-less repository answers `200 []` |
792
802
  | `listOpenBuilds` | `GET /repos/{repo}/open-builds` | none | `200` + `[{"record", "digest"}]`, a build record and its `BuildDigest` for every open build of the repository (possibly empty), ordered by `createdAt` and then slug; handled before the repository-existence gate, so an unknown or journal-less repository answers `200 []` |
@@ -794,8 +804,8 @@ builds.
794
804
  | `heartbeatRepo` | `POST /repos/{repo}/lease/heartbeat` | holder request | `200 {"ok": boolean}` |
795
805
  | `releaseRepoLease` | `POST /repos/{repo}/lease/release` | holder request | `200 {"ok": true}`; a wrong holder is a successful no-op |
796
806
 
797
- The `changed-builds` and `build-page` routes are additive and keep the
798
- protocol version. A server on the same release line that lacks them answers
807
+ The `changed-builds`, `build-page` and `merged-build-page` routes are additive
808
+ and keep the protocol version. A server on the same release line that lacks them answers
799
809
  `501 unsupported-operation` or `404 not-found`; the shipped client reports
800
810
  that as a typed `BuildFeedUnsupportedError` and never falls back to listing
801
811
  builds or reading events. The `build-page` filters are additive too. A server