@defrex/autobuild 1.16.0 → 1.18.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 (97) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +132 -9
  3. package/docs/answering-blocked-builds.md +34 -1
  4. package/docs/architecture.md +42 -3
  5. package/docs/configuration.md +44 -7
  6. package/docs/dispatcher-hosting.md +5 -3
  7. package/docs/operator-api.md +29 -6
  8. package/docs/plugin-authoring.md +30 -1
  9. package/docs/remote-store-protocol.md +13 -3
  10. package/docs/remote-ticket-protocol.md +37 -2
  11. package/docs/restacking.md +46 -1
  12. package/docs/setup.md +24 -9
  13. package/docs/ticket-sources.md +28 -1
  14. package/docs/troubleshooting.md +54 -2
  15. package/docs/workspaces.md +3 -1
  16. package/package.json +4 -4
  17. package/packages/core/src/cli/accounts.ts +3 -0
  18. package/packages/core/src/cli/binary-direct.ts +14 -1
  19. package/packages/core/src/cli/binary.ts +10 -7
  20. package/packages/core/src/cli/dashboard/refresh.ts +8 -0
  21. package/packages/core/src/cli/dispatch.ts +503 -334
  22. package/packages/core/src/cli/secrets.ts +2 -0
  23. package/packages/core/src/config/schema.ts +17 -3
  24. package/packages/core/src/events/payloads.ts +8 -5
  25. package/packages/core/src/events/repository.ts +37 -1
  26. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/d41044cb2e54809c.json +194 -0
  27. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/e0f89f52e48cbf62.json +197 -0
  28. package/packages/core/src/kernel/engine.ts +118 -0
  29. package/packages/core/src/kernel/reconcile-restack.ts +72 -9
  30. package/packages/core/src/kernel/reducer-revisions.ts +5 -0
  31. package/packages/core/src/kernel/repository-read-facts.ts +9 -2
  32. package/packages/core/src/kernel/ticket-preparation.ts +10 -0
  33. package/packages/core/src/kernel/tracked-dirt.ts +173 -0
  34. package/packages/core/src/ontology.ts +1 -0
  35. package/packages/core/src/operator/index.ts +10 -0
  36. package/packages/core/src/operator/merged-builds.ts +51 -0
  37. package/packages/core/src/operator/registry.ts +254 -110
  38. package/packages/core/src/operator/repo-argument.ts +43 -0
  39. package/packages/core/src/operator/tickets.ts +139 -25
  40. package/packages/core/src/plugin-sdk/index.ts +4 -0
  41. package/packages/core/src/plugins/manifest.ts +1 -1
  42. package/packages/core/src/ports/tickets/completion.ts +71 -0
  43. package/packages/core/src/ports/tickets/contract.ts +73 -0
  44. package/packages/core/src/ports/tickets/github-fake.ts +8 -0
  45. package/packages/core/src/ports/tickets/github-issues.ts +1 -0
  46. package/packages/core/src/ports/tickets/github.ts +18 -6
  47. package/packages/core/src/ports/tickets/grants.ts +2 -0
  48. package/packages/core/src/ports/tickets/hosted-index.ts +8 -0
  49. package/packages/core/src/ports/tickets/linear.ts +18 -2
  50. package/packages/core/src/ports/tickets/remote-protocol.ts +37 -8
  51. package/packages/core/src/ports/tickets/remote.ts +43 -3
  52. package/packages/core/src/ports/tickets/tree.ts +11 -1
  53. package/packages/core/src/ports/types.ts +47 -4
  54. package/packages/core/src/ports/workspace/vercel-command-diagnostics.ts +144 -0
  55. package/packages/core/src/ports/workspace/vercel-sandbox.ts +649 -160
  56. package/packages/core/src/processes/build-child.ts +15 -1
  57. package/packages/core/src/processes/build-runner.ts +349 -20
  58. package/packages/core/src/processes/dispatcher.ts +880 -283
  59. package/packages/core/src/processes/harvest-child.ts +21 -1
  60. package/packages/core/src/processes/harvest-runner.ts +82 -35
  61. package/packages/core/src/processes/pass-stages.ts +32 -6
  62. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  63. package/packages/core/src/processes/provisioning-progress.ts +23 -0
  64. package/packages/core/src/processes/repo-view.ts +25 -4
  65. package/packages/core/src/processes/workspace-preparation.ts +1 -0
  66. package/packages/core/src/store/adapter.ts +34 -5
  67. package/packages/core/src/store/build-feed.ts +148 -22
  68. package/packages/core/src/store/build-scope.ts +12 -3
  69. package/packages/core/src/store/caller-attribution.ts +170 -0
  70. package/packages/core/src/store/contract.ts +1038 -165
  71. package/packages/core/src/store/local/schema.ts +12 -1
  72. package/packages/core/src/store/local/store.ts +260 -25
  73. package/packages/core/src/store/memory.ts +156 -9
  74. package/packages/core/src/store/phase-session.ts +23 -3
  75. package/packages/core/src/store/reducer-value-shapes.json +8196 -8118
  76. package/packages/core/src/store/remote/client.ts +90 -11
  77. package/packages/core/src/store/remote/credentials.ts +2 -0
  78. package/packages/core/src/store/remote/index.ts +31 -5
  79. package/packages/core/src/store/remote/protocol.ts +45 -8
  80. package/packages/core/src/store/remote/released-clients.json +22 -0
  81. package/packages/core/src/store/remote/released-reducer-values/1.17.0.json +36367 -0
  82. package/packages/core/src/store/remote/released-reducer-values/1.18.0.json +36436 -0
  83. package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
  84. package/packages/core/src/store/session-handle.ts +12 -3
  85. package/packages/core/src/store/types.ts +48 -3
  86. package/packages/core/src/testing/dispatch-read-budget.ts +143 -16
  87. package/packages/core/src/testing/index.ts +2 -0
  88. package/packages/core/src/testing/reduced-read-budget.ts +420 -6
  89. package/skills/guide/SKILL.md +67 -13
  90. package/skills/guide/references/operator-api.md +29 -6
  91. package/skills/guide/references/plugin-authoring.md +30 -1
  92. package/skills/guide/references/remote-store-protocol.md +13 -3
  93. package/skills/guide/references/remote-ticket-protocol.md +37 -2
  94. package/skills/guide/references/restacking.md +46 -1
  95. package/skills/guide/references/setup.md +24 -9
  96. package/skills/operate/SKILL.md +42 -4
  97. 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.18.0
30
30
  ```
31
31
 
32
32
  <!-- release-install:end -->
package/SPEC.md CHANGED
@@ -99,7 +99,7 @@ Interfaces to the world, each with swappable adapters:
99
99
  | `TelemetrySource` | production signals | Sentry; later log streams |
100
100
  | `BuildStore` | per-build streams plus repository journals: events, artifacts, transcripts, leases (see §7) | local; remote HTTP |
101
101
 
102
- Ticket sources may optionally provide native `listPage(criteria, page)` windows with a matching total. Paged operator reads use it when present, otherwise slice the exhaustive listing; unpaged and dispatcher reads remain exhaustive.
102
+ Ticket sources may optionally provide native `listPage(criteria, page)` windows with a matching total. Paged operator reads use it when present, otherwise slice the exhaustive listing; unpaged and dispatcher reads remain exhaustive. A source declaring `completionPaging` also honours completion filters (`excludeLabels`, `since`/`until` over `Ticket.resolvedAt`, order `completed`) natively, capped per request; for other sources the operator filters the exhaustive listing.
103
103
  Ticket sources may optionally provide `search(query)`: title/body term matching with state/label filters, returning compact hits and an opaque cursor. Callers refuse sources without it and never fall back to listing.
104
104
  Integration-tree sources may optionally provide `listTargeting(nodeId)`, every ticket targeting one node in every state, equal to the exhaustive listing filtered by target. Integration observation uses it when present, otherwise `listAll`.
105
105
 
@@ -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
@@ -501,7 +505,11 @@ files, including development configs, remain exactly as installed.
501
505
  a won claim, the selected creation slug and, when the build store attests keyed
502
506
  creation, the attempt's creation key are durable boundaries. Caught
503
507
  asset-copy, spec-authoring, naming, and build-creation failures return the ticket
504
- to configured Ready; a nonconforming spec goes to configured Triage. Recovery
508
+ to configured Ready; a nonconforming spec goes to configured Triage. A bounded
509
+ invocation stamps each intent with its work deadline; an attempt that deadline
510
+ interrupted before `build.created`, with no failure or bounce recorded, is not a
511
+ failure and is never returned to Ready: it is carried and resumed (§8.1).
512
+ Recovery
505
513
  point-reads the selected slug and, for a keyed attempt, the canonical slug derived
506
514
  from the repository, selected slug and key: one matching record and atomic
507
515
  `build.created` retain ownership even if creation threw after committing or its
@@ -1219,8 +1227,26 @@ from 1 to 100 (default 25). Malformed positions, cursors, filters and limits
1219
1227
  reject, as does a cursor issued for the other order. Unknown repositories
1220
1228
  answer empty without creating state. A remote server that cannot filter
1221
1229
  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
1230
+ filters an unfiltered page itself.
1231
+ `listMergedBuildsPage(repo, { since?, until?, cursor?, limit? })` returns one
1232
+ page of merged builds, most recently merged first (merge time, then slug, both
1233
+ descending). Each item is the build record with four more listing facts, each
1234
+ written in the same transaction as the event that changes it: `mergedAt`, the
1235
+ latest `build.completed`'s `ts` when merged (a non-merged completion or
1236
+ `build.reopened` clears it, and no later write moves it); `pr`, number and url
1237
+ from the latest `pr.opened` or `finalize.completed`; `target`, from
1238
+ `build.created`, replaced on a node by each `node.parent-accepted`'s
1239
+ `next.target`; and `kind`. `since` is inclusive and `until` exclusive, both ISO
1240
+ instants with a zone on merge time, and the merge-order cursor continues only a
1241
+ request with the same window. A page is one bounded range scan of a merge-time
1242
+ index: at most `limit + 1` entries, zero event rows and zero reduced values,
1243
+ whatever the build count, a build's log length or the writes after its merge.
1244
+ A database that predates these facts gains them in one migration that
1245
+ backfills every row from its latest relevant events; no read path backfills.
1246
+ An invalid window, cursor or limit rejects. A remote server without the route
1247
+ answers `BuildFeedUnsupportedError`; the client never lists builds or reads
1248
+ events instead. Scoped build and session handles reject all three methods. The
1249
+ feed is what derived reducers advance by (§7.7). Two implementations of one contract (`packages/core/src/store/contract.ts` is the shared
1224
1250
  conformance suite):
1225
1251
 
1226
1252
  1. **Local** — one self-contained state tree at `<main-repo>/.autobuild/` by
@@ -1312,7 +1338,9 @@ backfilled once, when its migration creates it; no read path backfills.
1312
1338
  `builds.list` (active and queued), `merges.list`, the dashboard snapshot
1313
1339
  (§16.1) and `repository.status` capacity read it, so their cost follows open
1314
1340
  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
1341
+ read and still lists every build. `builds.list` scope `merged` is one
1342
+ `listMergedBuildsPage` call per page and reads nothing else, so a "what shipped
1343
+ since T" digest costs its page. A remote server without the operation
1316
1344
  answers a typed capability failure, and the client never falls back to
1317
1345
  listing every build or the digest batch.
1318
1346
 
@@ -2025,6 +2053,41 @@ keeps the cut execution's `instance` and the step still owed (`fence` or
2025
2053
  that instance still holds the lease; the lease never waits on its TTL. A
2026
2054
  carried entry retires without launching when its build is aborted, discarded,
2027
2055
  paused or no longer needs the start.
2056
+ Ticket preparations are carried the same way, before `build.created`. Intake
2057
+ does not start a preparation with less time left before the work deadline than
2058
+ a preparation needs (about 30 s, the dispatcher's `preparationEstimateMs`).
2059
+ Once the ticket passes every admission gate, capacity included, intake journals
2060
+ the admission as a preparation intent with `claimDeferred`, makes no tracker
2061
+ call, carries the attempt and stops claiming. A preparation the work deadline
2062
+ cuts before `build.created` is carried too, with no failure recorded, no
2063
+ recovery and no tracker write. Carried attempts are listed, by ticket and
2064
+ attempt, in `dispatcher.work-deferred` and counted as `preparationsCarried`; the
2065
+ dispatch log names each ticket and the pass's stage record lists it as
2066
+ `carried`. The next invocation resumes each attempt first, after the carried
2067
+ builds, from its last durable boundary. An attempt never claimed is claimed
2068
+ now: a second intent for the same attempt, without `claimDeferred`, is
2069
+ journaled before the claim call, and from then on recovery treats the claim as
2070
+ possibly applied. A claim that applied but was never confirmed is confirmed
2071
+ from the ticket's state. A claimed attempt continues from its asset pin, and a
2072
+ selected creation is read back as in recovery. A deferred attempt whose ticket
2073
+ left Ready or reports unresolved blockers, or whose repository turned intake
2074
+ off, resolves `lost-claim` with no tracker write, and intake decides the ticket
2075
+ again. Admission is decided once, when the intent is written: the intent also
2076
+ records the admitted build level (a non-manual start request's own level, or
2077
+ the ticket's claim tier), and a carried attempt's build takes that level even
2078
+ after its start request settles. Finishing a carried attempt never re-measures
2079
+ capacity. Instead, every capacity measurement counts each unresolved carried
2080
+ attempt as an occupied slot until it resolves, however many passes its resume
2081
+ takes (a tracker outage included), so no intake claim, start request or slot
2082
+ admission spends it. A slot request or start request that appears in between
2083
+ waits, as it would behind an in-flight claim. The unresolved attempt withholds
2084
+ its ticket from other claims meanwhile. The
2085
+ work-deadline stamp is the backstop when the hint is lost: preparation recovery
2086
+ resumes an attempt whose stamp has passed and that recorded no failure or
2087
+ bounce, instead of handing it back. A resumed preparation that fails for real
2088
+ takes the ordinary failure path, and one the deadline cuts again is carried
2089
+ again under the same attempt. Start requests get the same estimate gate but
2090
+ journal nothing; their pending request is already the carry.
2028
2091
  No stage consumes a bounded pass. Its stages run in order (deferred work,
2029
2092
  settlement, ticket preparations, janitor, recovery, lease sweep, admission,
2030
2093
  intake), and each may start new items only until its share of the time left
@@ -2566,7 +2629,12 @@ and reads zero event rows when nothing changed since the cursor.
2566
2629
 
2567
2630
  Each registered project also has a per-repository binding at
2568
2631
  `<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
2632
+ for that one repository: its tool schemas omit `repo`, and a call that
2633
+ passes `repo` (even naming that repository) or `repository` is refused as
2634
+ `validation` with code `repo-argument` and the contract text. Every tool
2635
+ names its repository `repo`, never `repository`; on every binding a
2636
+ `repository` argument or a missing `repo` is refused with that same contract.
2637
+ It offers no
2570
2638
  `repositories.list`, and it lists `sandbox.*` only when that repository's
2571
2639
  latest deposited effective config enables `[orchestrator]`, with one bounded
2572
2640
  latest-artifact read per listing. Its tokens are bound to their RFC 8707
@@ -3009,7 +3077,7 @@ the matching phase and `round`; a missing round cannot broaden either cause.
3009
3077
  `review-round-limit` retains the same matching-round effect.
3010
3078
  `verify-failure-limit` is the explicit phase-level case and re-arms every
3011
3079
  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
3080
+ `setup-failure-limit`, `wait-unresolvable`, `measurement-failed`, `target-rewritten` and `dirty-worktree` have no phase-runner failure-budget effect (setup's own
3013
3081
  answer/retry accounting remains separate). Agent and stall raises, and
3014
3082
  cause-less historical policy raises, retain the legacy shape rule: a matching
3015
3083
  round resets that round and an absent round resets all rounds for the target.
@@ -3017,6 +3085,46 @@ The closed `policyCause` union has an exhaustive reset-scope mapping, so adding
3017
3085
  a policy cause requires choosing matching-round, all-round, or no-reset
3018
3086
  semantics rather than acquiring behavior by omitting `round`.
3019
3087
 
3088
+ **Dirty tracked worktree.** `policy/dirty-worktree` targets `implement` with no
3089
+ `round`. The runner raises it, at most once while one is open, when
3090
+ `[commands].setup` newly modifies tracked files outside `[[generated]]` at
3091
+ attach or after a base move (§15.6-C), and when a restack or reconcile
3092
+ preparation refuses undeclared tracked dirt (§15.7 "Generated-file
3093
+ regeneration"). Its question lists the bounded paths (at most 20, then
3094
+ `(+N more)`) and the origin. Answering it with guidance or a bare retry returns
3095
+ the build to `implement`; Autobuild never commits or discards those files
3096
+ itself:
3097
+
3098
+ - **Nothing frozen:** `implement` runs at the next round. Its feedback is the
3099
+ question with its paths plus the answer.
3100
+ - **A frozen preparation without a publish intent** (an active automatic
3101
+ restack or an open reconcile occurrence) is first superseded with
3102
+ `reconcile.superseded {cause: dirty-worktree}`. The runner returns a
3103
+ workspace a replay left detached to the unchanged build branch, carrying
3104
+ the changes; then `implement` runs. When Git refuses to carry them because
3105
+ the target also changed a dirty file, the runner first sets them aside as
3106
+ below (artifact plus observation, then restore) and the `implement`
3107
+ feedback names the artifact.
3108
+ - **A frozen preparation with a publish intent** settles first: the runner
3109
+ stores the undeclared changes as a byte-exact binary patch artifact
3110
+ (`git diff --binary --no-textconv --no-ext-diff`, re-applied with
3111
+ `git apply --binary`) `dirty-worktree-<escalation>`, records observation
3112
+ `dirty-worktree:<escalation>:set-aside`, restores the paths and publishes the
3113
+ frozen candidate as recorded. The `implement` feedback names the artifact.
3114
+
3115
+ A set-aside that runs again for the same escalation (a stop before the
3116
+ restore, or a later preparation in the same recovery) resets only bytes the
3117
+ artifact's latest revision holds. When the tree differs, for example because
3118
+ setup rewrote a path on relaunch, the runner first stores a new revision with
3119
+ each currently dirty file's change plus every file only an earlier revision
3120
+ held.
3121
+
3122
+ The recovery round is the first `implement` round started after the answer.
3123
+ Until it completes, every rerun is that round with the same feedback, rebuilt
3124
+ from durable facts, and the setup dirt check is skipped for it. A spec
3125
+ revision after the answer cancels the recovery. Once the round completes, the
3126
+ ordinary code loop resumes.
3127
+
3020
3128
  Reconcile has two distinct policy scopes. Runner retry exhaustion and
3021
3129
  non-retryable failures at progress-check or base-refresh boundaries are scoped
3022
3130
  to a concrete reconcile `round`. Unchanged-base no-progress exhaustion is
@@ -5120,7 +5228,8 @@ catalog lookup. Hosted reads use one GET `/repos/:repo/change-position`
5120
5228
  returning only `{ position: string }`; `/repos/:repo/builds` returns scoped
5121
5229
  build records; `/repos/:repo/changed-builds?since=` and
5122
5230
  `/repos/:repo/build-page?limit=&cursor=&kind=&outcome=&activeSince=` serve the
5123
- feed and the paged listing. All four routes authorize the repository
5231
+ feed and the paged listing, and `/repos/:repo/merged-build-page?limit=&cursor=&since=&until=`
5232
+ the merged listing. All five routes authorize the repository
5124
5233
  before reading and support repositories with builds but no journal.
5125
5234
 
5126
5235
  Durable operator settings (intake, repository pause, harvest gate) and pending
@@ -5449,7 +5558,7 @@ with illustrative members:
5449
5558
  | 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
5559
  | Head path facts | advisory `head.paths-recorded {source, head, destination, mergeBase, total, preview, resolution?, artifact}` |
5451
5560
  | 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") |
5561
+ | 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
5562
  | Cross-cutting | `observation.recorded`, `escalation.raised`, `phase.failed`, `session.build-read-failed`, `session.build-read-recovered`, `phase.deferred`, `phase.deferral-escalated` |
5454
5563
  | 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
5564
  | 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 +6242,11 @@ post-restack failure follows the same path as an attach failure: it appends
6133
6242
  `runner.setup-failed` with the next attempt, counts toward
6134
6243
  `policy.maxSetupAttempts`, ends the runner unattached, and only a later
6135
6244
  successful setup's `runner.attached {resumedFromSeq}` clears it.
6245
+ A successful setup is followed by a tracked-dirt check: tracked paths setup
6246
+ newly modified outside `[[generated]]` raise `policy/dirty-worktree` (§11)
6247
+ before any phase runs. Dirt present before setup is never blamed on it,
6248
+ declared generated outputs are left for the phase, and the check is skipped
6249
+ for a reconcile and while an answered dirty-worktree recovery is pending.
6136
6250
  The setup target belongs only to escalation metadata and is not a pipeline `Phase`.
6137
6251
 
6138
6252
  **D — runner loss and sandbox death:** local git-worktrees first attempt the
@@ -6566,6 +6680,15 @@ and restore the recorded conflict for reconcile, whose context names the
6566
6680
  conflicted generated files with their commands (`generated`) and a failure's
6567
6681
  `regeneration.reason`, both read from the recorded fact's `commands`, never
6568
6682
  from the checkout's `autobuild.toml`. Repositories that declare nothing are unaffected.
6683
+ Before a replay, every clean-tree gate classifies uncommitted tracked changes:
6684
+ when every dirty path is declared, the runner restores them to `HEAD` and
6685
+ records one deduplicated `followup` observation. The same classification runs
6686
+ before a completed automatic replay or a frozen intended candidate publishes,
6687
+ whatever recovery path reached it; when any path is undeclared,
6688
+ preparation refuses without touching anything and raises
6689
+ `policy/dirty-worktree` naming those paths (§11). A fresh automatic restack
6690
+ and a fresh epilogue reconcile check before `restack.prepared` or
6691
+ `reconcile.started`, so that refusal freezes nothing.
6569
6692
  Resolver completion links back to the automatic transaction. Retained commit bytes
6570
6693
  and replay object packs recover disposable-workspace objects before publication.
6571
6694
  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
@@ -862,6 +866,27 @@ holder before anything else. Starts are tracked in flight, and bounded
862
866
  teardown awaits `Dispatcher.settleCutStarts()` as a racer beside provisioning
863
867
  abandonment, before the repository lease is released; it prints each deferral
864
868
  line the tick has not reported, and the cut pass's partial summary counts them.
869
+ Ticket preparations are carried before `build.created` too (#1431). Intake's
870
+ claim loop calls `Dispatcher.prepareTicket`, the one preparation path from the
871
+ `intended` append to the first dispatch, tracked as a start in flight. In a
872
+ bounded pass `appendIntended` stamps `workDeadlineAt` and the admitted `level`,
873
+ which a resumed attempt reuses; `preparationWontFit`
874
+ compares the time left with `preparationEstimateMs` (default 30 s), and
875
+ `deferPreparation` journals the admission as `intended` with `claimDeferred`
876
+ and no tracker call. A preparation the deadline cuts takes `prepareTicket`'s
877
+ cut branch instead of `failPreparation`. Both note the attempt through
878
+ `notePreparationCarry`, which writes the hint's `tickets` list beside its
879
+ builds and records the ticket on the pass's stage part (`PassStageTracker.carry`).
880
+ `serviceDeferredWork` resumes carried attempts after carried builds through
881
+ `resumeCarriedPreparation`, which re-reads the ticket, confirms or claims as
882
+ the attempt's durable boundaries require (journaling a second `intended` as
883
+ the claim-started boundary of a deferred claim), and re-enters `prepareTicket`
884
+ with `resume`. It uses `creationReadback`, the readback it shares with
885
+ `recoverTicketPreparation`.
886
+ Every capacity measurement goes through `measureCapacity`, which adds
887
+ `reservedPreparations()` (unresolved, deadline-stamped attempts with no failure
888
+ or bounce) to the occupied slots, so a carried admission keeps its slot until
889
+ it resolves.
865
890
  Stage fairness lives in `processes/pass-stages.ts` (pure: shares, rotation,
866
891
  the stage record and its rendering). `Dispatcher.runTick` wraps each stage in
867
892
  `runStage`, which hands its helpers a copy of the tick options whose
@@ -1052,7 +1077,7 @@ dispatch is tolerated. `Ticket.creationKey` is the optional stable external
1052
1077
  create/adoption correlation, distinct from `Ticket.ref.id`; Linear projects its
1053
1078
  issue UUID and file/fake preserve their idempotency metadata through create,
1054
1079
  adoption, get, and list paths. Legacy/plugin tickets may omit it and dispatch
1055
- unchanged. The ticket-source port optionally exposes `listPage(criteria, page)` for paged operator reads. PostgreSQL counts matches and applies SQL LIMIT/OFFSET; the remote hosted client forwards pages over the `list-page` ticket operation; other sources retain exhaustive-read slicing. CLI and dispatcher reads stay exhaustive. The optional `search(query)` serves `tickets.search` and `ab ticket search`; PostgreSQL answers it with one keyset-paged bounded statement, the remote hosted client forwards it over the `search` ticket operation, and the Linear source answers it with one team-filtered GraphQL `issues` request per page; the GitHub source answers it with one GitHub issue-search request per page on GitHub's separate search quota; `ports/tickets/search.ts` holds the shared matcher and cursor pager, the `TicketSearchUnsupported` refusal for sources without it, and `searchTickets`, the caller entry point. See [ticket source contract](ticket-sources.md#writing-your-own).
1080
+ unchanged. The ticket-source port optionally exposes `listPage(criteria, page)` for paged operator reads, with completion filters (`ports/tickets/completion.ts`) for sources declaring `completionPaging`. PostgreSQL counts matches and applies SQL LIMIT/OFFSET, answering completion filters with at most two range scans over its completion index (a count and a window), each stopping at 5,001 rows, and refusing a state and range over 5,000 tickets; the remote hosted client forwards pages over the `list-page` ticket operation; other sources retain exhaustive-read slicing. CLI and dispatcher reads stay exhaustive. The optional `search(query)` serves `tickets.search` and `ab ticket search`; PostgreSQL answers it with one keyset-paged bounded statement, the remote hosted client forwards it over the `search` ticket operation, and the Linear source answers it with one team-filtered GraphQL `issues` request per page; the GitHub source answers it with one GitHub issue-search request per page on GitHub's separate search quota; `ports/tickets/search.ts` holds the shared matcher and cursor pager, the `TicketSearchUnsupported` refusal for sources without it, and `searchTickets`, the caller entry point. See [ticket source contract](ticket-sources.md#writing-your-own).
1056
1081
 
1057
1082
  The `github` source spans four modules. `ports/tickets/github.ts` is the
1058
1083
  adapter: REST over the forge's `GitHubRequest` transport and credential order,
@@ -1610,7 +1635,7 @@ listing every build.
1610
1635
 
1611
1636
  Positions are ordered. `packages/core/src/store/build-feed.ts` holds the shared
1612
1637
  changed-builds feed and paged-listing vocabulary (`listBuildsChangedSince`,
1613
- `listBuildsPage`, cursor and position codecs). Each build's latest position
1638
+ `listBuildsPage`, `listMergedBuildsPage`, windows, cursor and position codecs). Each build's latest position
1614
1639
  lives in `build_change_positions`, written by the same trigger that advances
1615
1640
  the counter (memory: a one-node-per-build linked list); its first creation
1616
1641
  backfills existing builds once at a bumped head. The paged listing's filters
@@ -1629,6 +1654,16 @@ adapter keeps the same classes as sorted slug lists, moved in the step that
1629
1654
  writes the fact or `updatedAt`. Its first creation backfills existing builds
1630
1655
  once from their latest relevant events. The PostgreSQL DDL is additive, like
1631
1656
  the counter's, and must be migrated before the service rollout.
1657
+ The merged listing (`listMergedBuildsPage`, behind `builds.list` scope
1658
+ `merged`) reads four more `build_listing_facts` columns added by guarded
1659
+ `ALTER`s: `merged_at` (the merging `build.completed`'s `ts`), `pr_number`,
1660
+ `pr_url` and `target`, kept by their own separately named triggers so an older
1661
+ release's migrate never strips them. One partial index on `(repo, merged_at,
1662
+ slug)` makes a page one backward range scan in merge-time order; the memory
1663
+ adapter keeps a sorted merged-slug list. Adding the columns backfills every row
1664
+ once. `operator/merged-builds.ts` maps one page into the tool answer with no
1665
+ further read, and `operator/repo-argument.ts` holds the `repo` argument
1666
+ contract every operator binding reports.
1632
1667
  `detail.ts` projects chronological session history from the same retained log,
1633
1668
  including a distinct transcriptless `reclaimed` ending, and `transcript.ts`
1634
1669
  heuristically presents ordinary opaque transcript artifacts with a raw
@@ -1763,7 +1798,11 @@ and `ab context` writes them under `$AB_CONTEXT_DIR/assets/`.
1763
1798
 
1764
1799
  `kernel/ticket-preparation.ts` projects unfinished `ticket-preparation.*` facts
1765
1800
  through `repositoryReadFacts`; `processes/dispatcher.ts` retries them under the
1766
- existing repository ownership before intake. This pre-record recovery differs
1801
+ existing repository ownership before intake. An attempt stamped with a passed
1802
+ `workDeadlineAt` and no recorded failure or bounce was interrupted by its
1803
+ bounded invocation's deadline: `recoverTicketPreparations` resumes it through
1804
+ `resumeCarriedPreparation` instead of handing it back, unless the deferred
1805
+ stage already did this tick. This pre-record recovery differs
1767
1806
  from `dispatch.failed`, which completes an already established build.
1768
1807
  `kernel/ticket-starts.ts` reduces operator single-ticket start requests
1769
1808
  (`ticket.start-*`) and the durable canonical identities of hosted active builds
@@ -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`
@@ -1446,7 +1460,7 @@ preflight = "test \"$(pi --version)\" = \"0.84.4\" && pi update --models"
1446
1460
  - **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.
1447
1461
  - **Local override:** Committed only: set in autobuild.toml.
1448
1462
 
1449
- **Description:** required nonblank shell command; use an immutable package version, digest, or commit
1463
+ **Description:** required nonblank shell command; use an immutable package version, digest, or commit; also reruns in place when the runtime's preflight fails at a relaunch, so it must be safe to run over an existing install
1450
1464
 
1451
1465
  **Constraints:** install must be nonblank
1452
1466
 
@@ -1547,7 +1561,10 @@ Autobuild distribution and dependency bootstrap. Then runtime provisioning runs
1547
1561
  each referenced runtime's `install` and `preflight` commands in sorted
1548
1562
  runtime-name order from the checkout. Only `environmentVariables` values enter
1549
1563
  runtime commands. The same sequence runs in fresh readiness sandboxes and every
1550
- replacement sandbox. Provisioning writes its readiness marker only after all
1564
+ replacement sandbox. A relaunch into an existing sandbox reruns each selected
1565
+ runtime's `preflight`; when one fails, that runtime's `install` runs in place
1566
+ and its `preflight` runs again, so a `[roles]` change that selects a new
1567
+ runtime reaches existing sandboxes at their next launch. Provisioning writes its readiness marker only after all
1551
1568
  scrubbing, Bun verification, system steps, distribution installation,
1552
1569
  dependency bootstrap, and runtime preflights complete; distribution
1553
1570
  packing/install disables package lifecycle scripts so
@@ -1662,7 +1679,12 @@ start provisioning with less than about 150 s of budget left; it records
1662
1679
  `provisioningDeferred` in the tick report, logs the build, and records it in
1663
1680
  `dispatcher.work-deferred`, so the next invocation provisions it first. That
1664
1681
  includes the first provision of a build intake just claimed: the build keeps
1665
- its slot, and the next invocation completes its dispatch first.
1682
+ its slot, and the next invocation completes its dispatch first. Intake starts a
1683
+ ticket preparation (claim, spec import, build creation) only with about 30 s
1684
+ left. Otherwise it holds the admitted ticket, logs
1685
+ `ticket <id>: preparation carried by the invocation budget`, and the next
1686
+ invocation prepares it first. A preparation the work deadline cuts is carried
1687
+ the same way. Neither is handed back to Ready.
1666
1688
 
1667
1689
  The representative actual-provider check is opt-in and must point at an
1668
1690
  independent consuming repository whose `autobuild.toml` selects the universal
@@ -1766,7 +1788,14 @@ exit status, attempt, and output. Retries are bounded by
1766
1788
  `policy.maxSetupAttempts`; exhaustion blocks on a setup-targeted policy
1767
1789
  escalation without creating a phase or verification result. A failure after a
1768
1790
  base move stops dependent work the same way. Only a later successful attachment
1769
- clears the current error projection. Other names run only when
1791
+ clears the current error projection. Setup must not modify tracked files: paths
1792
+ it newly changes outside `[[generated]]` raise `policy/dirty-worktree` naming
1793
+ them before the next phase runs (see
1794
+ [Answering blocked builds](answering-blocked-builds.md#dirty-tracked-worktree)).
1795
+ The check is skipped when that phase is a `reconcile`, whose resolver works on
1796
+ its own in-progress replay, and while an answered dirty-worktree recovery is
1797
+ pending; restack and reconcile preparation still classify tracked dirt before
1798
+ replaying. Other names run only when
1770
1799
  referenced by a configured check. A check's `command` value is the key in this
1771
1800
  map, not an inline shell command. The kernel passes the mapped string to a shell
1772
1801
  as written.
@@ -1789,7 +1818,7 @@ declares nothing, and restacks behave exactly as they do without it.
1789
1818
  - **Reload:** Hot: next dispatcher action captures the accepted value. A running invocation keeps its captured values.
1790
1819
  - **Local override:** Committed only: set in autobuild.toml.
1791
1820
 
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.
1821
+ **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
1822
 
1794
1823
  **Constraints:** A path selector string may be declared by only one entry.
1795
1824
 
@@ -1856,6 +1885,10 @@ automatic restack and to every item of a node restack. The rules:
1856
1885
  to the agent as well; its context lists the generated files and their
1857
1886
  commands, and the agent rebuilds them with the command instead of
1858
1887
  hand-merging them.
1888
+ - Uncommitted changes to declared files, such as outputs `[commands].setup`
1889
+ rewrote, are restored to `HEAD` before any restack or reconcile replay. Any
1890
+ undeclared tracked change refuses preparation instead; see
1891
+ [Tracked dirt before preparation](restacking.md#tracked-dirt-before-preparation).
1859
1892
 
1860
1893
  See [Generated-file conflicts](restacking.md#generated-file-conflicts) for the
1861
1894
  recorded facts and how status reports them.
@@ -5118,6 +5151,10 @@ clean stop. The next generation resumes eligible native sessions with fresh
5118
5151
  logical credentials, or records a reasoned `harvest.session.resume-fallback`
5119
5152
  and starts fresh. Orderly suspension spends no recovery attempt; real crashes
5120
5153
  retain recovery accounting.
5154
+ A hosted harvest launch that is still preparing stops at its next boundary, and
5155
+ teardown joins it before releasing the lease. A harvest that a dispatcher
5156
+ launches never claims, renews or releases the repository lease on its own
5157
+ behalf.
5121
5158
 
5122
5159
  The predecessor serializes acceptance with ticks and launch admission, joins
5123
5160
  repository-owned harvest and provisioning work, and records the exact local
@@ -96,9 +96,11 @@ 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
+ Deferred work is every start a pass admitted but didn't finish (a ticket
100
+ preparation, a provision, a launch the work deadline cut, or a stopped-sandbox
101
+ recovery); the next invocation runs it first. A ticket preparation that won't
102
+ fit, or that the deadline cuts, keeps its ticket and is never handed back to
103
+ Ready.
102
104
 
103
105
  ### Origin-mode dispatcher with remote workspaces
104
106