@defrex/autobuild 1.16.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 (72) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +91 -7
  3. package/docs/answering-blocked-builds.md +34 -1
  4. package/docs/architecture.md +15 -1
  5. package/docs/configuration.md +33 -4
  6. package/docs/operator-api.md +15 -5
  7. package/docs/plugin-authoring.md +1 -0
  8. package/docs/remote-store-protocol.md +13 -3
  9. package/docs/remote-ticket-protocol.md +3 -1
  10. package/docs/restacking.md +41 -1
  11. package/docs/setup.md +15 -6
  12. package/docs/troubleshooting.md +39 -2
  13. package/docs/workspaces.md +2 -0
  14. package/package.json +3 -3
  15. package/packages/core/src/cli/accounts.ts +3 -0
  16. package/packages/core/src/cli/binary-direct.ts +14 -1
  17. package/packages/core/src/cli/binary.ts +10 -7
  18. package/packages/core/src/cli/dispatch.ts +503 -334
  19. package/packages/core/src/cli/secrets.ts +2 -0
  20. package/packages/core/src/config/schema.ts +15 -2
  21. package/packages/core/src/events/payloads.ts +8 -5
  22. package/packages/core/src/kernel/engine.ts +118 -0
  23. package/packages/core/src/kernel/reconcile-restack.ts +72 -9
  24. package/packages/core/src/kernel/tracked-dirt.ts +173 -0
  25. package/packages/core/src/ontology.ts +1 -0
  26. package/packages/core/src/operator/index.ts +10 -0
  27. package/packages/core/src/operator/merged-builds.ts +51 -0
  28. package/packages/core/src/operator/registry.ts +190 -101
  29. package/packages/core/src/operator/repo-argument.ts +43 -0
  30. package/packages/core/src/ports/tickets/grants.ts +2 -0
  31. package/packages/core/src/ports/tickets/remote.ts +2 -0
  32. package/packages/core/src/ports/types.ts +15 -0
  33. package/packages/core/src/ports/workspace/vercel-command-diagnostics.ts +144 -0
  34. package/packages/core/src/ports/workspace/vercel-sandbox.ts +576 -140
  35. package/packages/core/src/processes/build-child.ts +15 -1
  36. package/packages/core/src/processes/build-runner.ts +349 -20
  37. package/packages/core/src/processes/dispatcher.ts +28 -7
  38. package/packages/core/src/processes/harvest-child.ts +21 -1
  39. package/packages/core/src/processes/harvest-runner.ts +82 -35
  40. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  41. package/packages/core/src/processes/provisioning-progress.ts +23 -0
  42. package/packages/core/src/processes/repo-view.ts +25 -4
  43. package/packages/core/src/processes/workspace-preparation.ts +1 -0
  44. package/packages/core/src/store/adapter.ts +34 -5
  45. package/packages/core/src/store/build-feed.ts +148 -22
  46. package/packages/core/src/store/build-scope.ts +12 -3
  47. package/packages/core/src/store/caller-attribution.ts +170 -0
  48. package/packages/core/src/store/contract.ts +1038 -165
  49. package/packages/core/src/store/local/schema.ts +12 -1
  50. package/packages/core/src/store/local/store.ts +260 -25
  51. package/packages/core/src/store/memory.ts +156 -9
  52. package/packages/core/src/store/phase-session.ts +23 -3
  53. package/packages/core/src/store/reducer-value-shapes.json +3184 -3175
  54. package/packages/core/src/store/remote/client.ts +90 -11
  55. package/packages/core/src/store/remote/credentials.ts +2 -0
  56. package/packages/core/src/store/remote/index.ts +31 -5
  57. package/packages/core/src/store/remote/protocol.ts +45 -8
  58. package/packages/core/src/store/remote/released-clients.json +11 -0
  59. package/packages/core/src/store/remote/released-reducer-values/1.17.0.json +36367 -0
  60. package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -16
  61. package/packages/core/src/store/session-handle.ts +12 -3
  62. package/packages/core/src/store/types.ts +48 -3
  63. package/packages/core/src/testing/reduced-read-budget.ts +222 -4
  64. package/skills/guide/SKILL.md +46 -8
  65. package/skills/guide/references/operator-api.md +15 -5
  66. package/skills/guide/references/plugin-authoring.md +1 -0
  67. package/skills/guide/references/remote-store-protocol.md +13 -3
  68. package/skills/guide/references/remote-ticket-protocol.md +3 -1
  69. package/skills/guide/references/restacking.md +41 -1
  70. package/skills/guide/references/setup.md +15 -6
  71. package/skills/operate/SKILL.md +24 -3
  72. 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.16.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
 
@@ -2566,7 +2590,12 @@ and reads zero event rows when nothing changed since the cursor.
2566
2590
 
2567
2591
  Each registered project also has a per-repository binding at
2568
2592
  `<resource>/<host><path>`, derived from its identity. It serves the same table
2569
- 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
2570
2599
  `repositories.list`, and it lists `sandbox.*` only when that repository's
2571
2600
  latest deposited effective config enables `[orchestrator]`, with one bounded
2572
2601
  latest-artifact read per listing. Its tokens are bound to their RFC 8707
@@ -3009,7 +3038,7 @@ the matching phase and `round`; a missing round cannot broaden either cause.
3009
3038
  `review-round-limit` retains the same matching-round effect.
3010
3039
  `verify-failure-limit` is the explicit phase-level case and re-arms every
3011
3040
  phase-runner failure round for its verify target. `reconcile-no-progress`,
3012
- `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
3013
3042
  answer/retry accounting remains separate). Agent and stall raises, and
3014
3043
  cause-less historical policy raises, retain the legacy shape rule: a matching
3015
3044
  round resets that round and an absent round resets all rounds for the target.
@@ -3017,6 +3046,46 @@ The closed `policyCause` union has an exhaustive reset-scope mapping, so adding
3017
3046
  a policy cause requires choosing matching-round, all-round, or no-reset
3018
3047
  semantics rather than acquiring behavior by omitting `round`.
3019
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
+
3020
3089
  Reconcile has two distinct policy scopes. Runner retry exhaustion and
3021
3090
  non-retryable failures at progress-check or base-refresh boundaries are scoped
3022
3091
  to a concrete reconcile `round`. Unchanged-base no-progress exhaustion is
@@ -5120,7 +5189,8 @@ catalog lookup. Hosted reads use one GET `/repos/:repo/change-position`
5120
5189
  returning only `{ position: string }`; `/repos/:repo/builds` returns scoped
5121
5190
  build records; `/repos/:repo/changed-builds?since=` and
5122
5191
  `/repos/:repo/build-page?limit=&cursor=&kind=&outcome=&activeSince=` serve the
5123
- 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
5124
5194
  before reading and support repositories with builds but no journal.
5125
5195
 
5126
5196
  Durable operator settings (intake, repository pause, harvest gate) and pending
@@ -5449,7 +5519,7 @@ with illustrative members:
5449
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) |
5450
5520
  | Head path facts | advisory `head.paths-recorded {source, head, destination, mergeBase, total, preview, resolution?, artifact}` |
5451
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) |
5452
- | 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") |
5453
5523
  | Cross-cutting | `observation.recorded`, `escalation.raised`, `phase.failed`, `session.build-read-failed`, `session.build-read-recovered`, `phase.deferred`, `phase.deferral-escalated` |
5454
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 |
5455
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}`. |
@@ -6133,6 +6203,11 @@ post-restack failure follows the same path as an attach failure: it appends
6133
6203
  `runner.setup-failed` with the next attempt, counts toward
6134
6204
  `policy.maxSetupAttempts`, ends the runner unattached, and only a later
6135
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.
6136
6211
  The setup target belongs only to escalation metadata and is not a pipeline `Phase`.
6137
6212
 
6138
6213
  **D — runner loss and sandbox death:** local git-worktrees first attempt the
@@ -6566,6 +6641,15 @@ and restore the recorded conflict for reconcile, whose context names the
6566
6641
  conflicted generated files with their commands (`generated`) and a failure's
6567
6642
  `regeneration.reason`, both read from the recorded fact's `commands`, never
6568
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.
6569
6653
  Resolver completion links back to the automatic transaction. Retained commit bytes
6570
6654
  and replay object packs recover disposable-workspace objects before publication.
6571
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
@@ -1610,7 +1614,7 @@ listing every build.
1610
1614
 
1611
1615
  Positions are ordered. `packages/core/src/store/build-feed.ts` holds the shared
1612
1616
  changed-builds feed and paged-listing vocabulary (`listBuildsChangedSince`,
1613
- `listBuildsPage`, cursor and position codecs). Each build's latest position
1617
+ `listBuildsPage`, `listMergedBuildsPage`, windows, cursor and position codecs). Each build's latest position
1614
1618
  lives in `build_change_positions`, written by the same trigger that advances
1615
1619
  the counter (memory: a one-node-per-build linked list); its first creation
1616
1620
  backfills existing builds once at a bumped head. The paged listing's filters
@@ -1629,6 +1633,16 @@ adapter keeps the same classes as sorted slug lists, moved in the step that
1629
1633
  writes the fact or `updatedAt`. Its first creation backfills existing builds
1630
1634
  once from their latest relevant events. The PostgreSQL DDL is additive, like
1631
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.
1632
1646
  `detail.ts` projects chronological session history from the same retained log,
1633
1647
  including a distinct transcriptless `reclaimed` ending, and `transcript.ts`
1634
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`
@@ -1766,7 +1780,14 @@ exit status, attempt, and output. Retries are bounded by
1766
1780
  `policy.maxSetupAttempts`; exhaustion blocks on a setup-targeted policy
1767
1781
  escalation without creating a phase or verification result. A failure after a
1768
1782
  base move stops dependent work the same way. Only a later successful attachment
1769
- 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
1770
1791
  referenced by a configured check. A check's `command` value is the key in this
1771
1792
  map, not an inline shell command. The kernel passes the mapped string to a shell
1772
1793
  as written.
@@ -1789,7 +1810,7 @@ declares nothing, and restacks behave exactly as they do without it.
1789
1810
  - **Reload:** Hot: next dispatcher action captures the accepted value. A running invocation keeps its captured values.
1790
1811
  - **Local override:** Committed only: set in autobuild.toml.
1791
1812
 
1792
- **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.
1793
1814
 
1794
1815
  **Constraints:** A path selector string may be declared by only one entry.
1795
1816
 
@@ -1856,6 +1877,10 @@ automatic restack and to every item of a node restack. The rules:
1856
1877
  to the agent as well; its context lists the generated files and their
1857
1878
  commands, and the agent rebuilds them with the command instead of
1858
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).
1859
1884
 
1860
1885
  See [Generated-file conflicts](restacking.md#generated-file-conflicts) for the
1861
1886
  recorded facts and how status reports them.
@@ -5118,6 +5143,10 @@ clean stop. The next generation resumes eligible native sessions with fresh
5118
5143
  logical credentials, or records a reasoned `harvest.session.resume-fallback`
5119
5144
  and starts fresh. Orderly suspension spends no recovery attempt; real crashes
5120
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.
5121
5150
 
5122
5151
  The predecessor serializes acceptance with ticks and launch admission, joins
5123
5152
  repository-owned harvest and provisioning work, and records the exact local
@@ -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
@@ -35,7 +35,9 @@ Every request is `POST /tickets/<operation>`, has `Content-Type: application/jso
35
35
  and requires `Authorization: Bearer <project credential>`. Authentication and
36
36
  registration checks precede body parsing and source construction. Owner admin
37
37
  is the explicit cross-project exception; internal operator signatures have no
38
- ticket authority.
38
+ ticket authority. Clients may also send the optional, diagnostic
39
+ `X-Autobuild-Caller` attribution header described in the remote store
40
+ protocol's transport conventions; the service never authorizes on it.
39
41
 
40
42
  Project credentials are opaque `abp_1_<id>_<secret>` bearer values bound to one
41
43
  registered normalized repository. The service stores only a SHA-256 digest of
@@ -159,7 +159,8 @@ applies to nodes: a stale node cannot verify or merge; inventory and child merge
159
159
  continue while it collects.
160
160
 
161
161
  Restack and reconcile publication reject tracked modifications with the existing
162
- clean-worktree error. Nonignored untracked files do not block publication and
162
+ clean-worktree error. Before a replay, preparation handles them as described in
163
+ [Tracked dirt before preparation](#tracked-dirt-before-preparation). Nonignored untracked files do not block publication and
163
164
  remain unpublished and untouched; each publication that encounters them records
164
165
  a path-bearing `observation.recorded` followup, deduplicated by operation,
165
166
  transaction, candidate SHA and exact path list on recovery. The phase-terminal
@@ -342,6 +343,45 @@ and `· N regenerated` or `· regeneration failed` to a node's restack lines.
342
343
  `ab watch --event 'restack.*'` or `--event 'node.item-*'` shows each outcome.
343
344
  Repositories that declare nothing restack exactly as before.
344
345
 
346
+ ## Tracked dirt before preparation
347
+
348
+ Uncommitted changes to tracked files, typically left by `[commands].setup` on
349
+ a relaunch, never strand a restack or reconcile preparation:
350
+
351
+ | Dirt | Outcome |
352
+ |---|---|
353
+ | Only declared `[[generated]]` paths | Restored to `HEAD`, one `followup` observation recorded, replay proceeds |
354
+ | Any undeclared path | Preparation refuses, touches nothing, raises `policy/dirty-worktree` naming the undeclared paths |
355
+
356
+ The same classification runs again just before a completed automatic replay
357
+ or an intended candidate publishes, so a relaunch or crash at any point of the
358
+ replay cannot reach publication with dirt. A fresh automatic restack and a
359
+ fresh epilogue reconcile check before
360
+ `restack.prepared` or `reconcile.started`, so a refusal freezes nothing and
361
+ spends no phase-failure budget. Answering the escalation with guidance or a
362
+ bare retry returns the build to `implement`:
363
+
364
+ - **Nothing frozen.** `implement` runs with the question, its paths and the
365
+ answer as feedback.
366
+ - **Frozen, no publish intent.** The kernel records `reconcile.superseded
367
+ {cause: dirty-worktree}`, returns a workspace the replay left detached to
368
+ the build branch with the changes intact, then runs `implement`. If the
369
+ target also changed a dirty file, so Git cannot carry it, the changes are
370
+ first set aside as artifact `dirty-worktree-<escalation>`, as below. The
371
+ abandoned restack is decided again from the new head.
372
+ - **Frozen, publish intent recorded.** The candidate settles first: the
373
+ undeclared changes are stored as artifact `dirty-worktree-<escalation>` (a
374
+ byte-exact binary patch, captured without textconv or external diff
375
+ drivers) with observation `dirty-worktree:<escalation>:set-aside`,
376
+ restored, and the frozen candidate publishes as recorded. The `implement`
377
+ feedback names the artifact and how to re-apply it. If the set-aside runs
378
+ again before the restore (after a stop, or when relaunch setup rewrote a
379
+ path), a changed tree is stored as a new artifact revision first; it keeps
380
+ every file an earlier revision held, so the latest revision is complete.
381
+
382
+ Autobuild never commits or discards undeclared changes on its own, and the
383
+ escalation never needs an abort.
384
+
345
385
  ## Foreign merges
346
386
 
347
387
  Before any replay or publication, inspect every merge's non-first-parent history,
package/docs/setup.md CHANGED
@@ -101,10 +101,12 @@ Use the supported `vercel/sandbox/universal` image. Other managed images and
101
101
  custom VCR images are rejected. Autobuild remains stack-neutral. For Vercel,
102
102
  put repository-specific operating-system packages and machine-level tooling in
103
103
  the ordered `[workspace.config].provisioning` list. Each strict `{ name,
104
- command }` entry runs from the checkout through `sh -c` with provider root
105
- authority after pinned Bun is verified and before dependency bootstrap,
106
- `[commands].setup`, or an agent. It runs once per fresh environment and repeats
107
- on every replacement. Commands are declarative TOML string data, not evaluated
104
+ command, timeoutSeconds? }` entry runs from the checkout through `sh -c` with
105
+ provider root authority after pinned Bun is verified and before dependency
106
+ bootstrap, `[commands].setup`, or an agent. It runs once per fresh environment
107
+ and repeats on every replacement. A step runs under `timeoutSeconds` (default
108
+ 600, at most 840); one that fails reports its name, redacted command and
109
+ output tails, and one that overruns also reports its elapsed time. Commands are declarative TOML string data, not evaluated
108
110
  configuration logic. Local git worktrees never run this list; ensure their host
109
111
  already has required system tooling.
110
112
 
@@ -121,7 +123,14 @@ allowlist entry; their real credentials remain on the dispatcher host.
121
123
 
122
124
  Keep package-level and checkout-level bootstrap in an idempotent
123
125
  `[commands].setup`. It runs after system provisioning and must remain safe to
124
- rerun on attachment and after every restack onto a new base. Do not repeatedly install OS packages there. Expose only
126
+ rerun on attachment and after every restack onto a new base. It must not modify
127
+ tracked files: tracked paths it newly changes outside `[[generated]]` block the
128
+ build with `policy/dirty-worktree` before the next phase runs, naming the paths.
129
+ The check is skipped when that phase is a `reconcile`, whose resolver works on
130
+ its own in-progress replay, and while an answered dirty-worktree recovery is
131
+ pending. A restack or reconcile preparation still classifies any tracked dirt
132
+ before it replays. Declare tracked codegen outputs it rewrites in
133
+ `[[generated]]`; those are tolerated and discarded before any replay. Do not repeatedly install OS packages there. Expose only
125
134
  required runtime credentials through
126
135
  `[workspace.config].environmentVariables`, keep generated caches disposable,
127
136
  and lock dependencies in the repository. A browser-capable repository should
@@ -162,7 +171,7 @@ For Vercel it identifies and permanently deletes a fresh unnamed sandbox, even
162
171
  when system or runtime provisioning, setup, or a probe fails; cleanup failures
163
172
  name the environment for manual deletion. Its `system provisioning` check lists
164
173
  completed step names (or says none were declared) before guest setup checks. A
165
- failed step reports its name, command, status, labeled stdout/stderr, and
174
+ failed step reports its name, command, status or timeout, stderr/stdout tails, and
166
175
  remediation without marking the environment ready. It provisions/preflights
167
176
  every effective primary and alternate runtime, then runs `commands.setup`, loads
168
177
  repository plugins, and checks every