@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
@@ -511,6 +511,10 @@ The distinctions that change an administrator's answer:
511
511
  logical credentials, or records a reasoned `harvest.session.resume-fallback`
512
512
  and starts fresh. Orderly suspension spends no recovery attempt; real
513
513
  crashes retain recovery accounting.
514
+ A hosted harvest launch that is still preparing stops at its next boundary,
515
+ and teardown joins it before releasing the lease. A harvest that a
516
+ dispatcher launches never claims, renews or releases the repository lease
517
+ on its own behalf.
514
518
  Current, distinct previous, held and live-process runtimes survive pruning.
515
519
  Cached Bun entries disable auto-install and explicitly pin a neutral compiler
516
520
  config. Third-party files remain as installed. `--plain`/non-TTY run directly
@@ -882,8 +886,11 @@ Every effective primary/alternate runtime needs a strict
882
886
  `runtimeProvisioning` entry with pinned `install` and exact-version `preflight`
883
887
  commands; runtime names remain open for plugins. Install/preflight runs before
884
888
  the marker in every fresh/replacement/readiness sandbox, and preflight reruns
885
- before every child. Failures name the runtime, role/alternate, and field and
886
- start no agent. Keep runtime installation out of `commands.setup`. Pi over
889
+ before every child. A relaunch whose preflight fails installs that runtime in
890
+ place and preflights again, so a `[roles]` change takes effect in existing
891
+ workspaces at their next launch; only a failure after that install fails the
892
+ launch. Failures name the runtime, role/alternate, and field (`install` or
893
+ `preflight`) with the command output and start no agent. Keep runtime installation out of `commands.setup`. Pi over
887
894
  `vercel-ai-gateway/...` uses `AI_GATEWAY_API_KEY`; never copy Pi state or Pi OAuth refresh tokens. Claude Code can select named [accounts](references/accounts.md): subscription tokens or region-bound Kimi Code keys stay on the dispatcher, with placeholders in the guest and exact-host/header egress transforms. Use the unmodified runtime, your own subscription and ordinary individual usage. Provision Claude/Kimi credentials manually; Autobuild never invokes `claude setup-token`. Codex can explicitly select a ChatGPT Plus/Pro account authorized with `bun ab accounts login NAME [--local|--project]`; exactly one dispatcher or hosted refreshing secret owns its renewal. The clone identity is upload-pack-only and
888
895
  scrubbed from Git config before an agent starts. Agents cannot push. Remote phase terminals deposit a durable
889
896
  publication request and park; that successful `ab done` is the one terminal and
@@ -927,7 +934,13 @@ build status and the dashboard, stop dependent work, and retry up to
927
934
  `[policy].maxSetupAttempts`; exhaustion raises a setup-targeted escalation
928
935
  without manufacturing a pipeline phase or verdict. An answer from your operator
929
936
  agent or you re-arms the budget, and only a later successful setup, recorded as
930
- a new `runner.attached`, clears the current error. Values are never evaluated as config — they are handed to a
937
+ a new `runner.attached`, clears the current error. Setup must not modify
938
+ tracked files: paths it newly changes outside `[[generated]]` raise a
939
+ `policy/dirty-worktree` escalation naming them before the next phase runs;
940
+ declared generated outputs are tolerated. The check is skipped when that phase
941
+ is a `reconcile`, whose resolver works on its own in-progress replay, and while
942
+ an answered dirty-worktree recovery is pending; restack and reconcile
943
+ preparation still classify tracked dirt before replaying. Values are never evaluated as config — they are handed to a
931
944
  shell as written.
932
945
 
933
946
  Fresh init config deliberately leaves this map empty. The setup agent follows
@@ -964,6 +977,9 @@ index, or leftover conflict markers fails the regeneration; nothing is committed
964
977
  ordinary reconcile with the failure reason in its context. A replay that also
965
978
  conflicts in undeclared files goes straight to reconcile, whose context lists
966
979
  the generated files and commands to run after the other files are resolved.
980
+ Uncommitted changes to declared files, such as outputs setup rewrote, are
981
+ restored to `HEAD` before any restack or reconcile replay; an undeclared
982
+ tracked change refuses preparation with `policy/dirty-worktree` naming it.
967
983
  Declarations come from the dispatcher's live configuration, like `[policy]`.
968
984
  See [Restacking](references/restacking.md) for the recorded facts.
969
985
 
@@ -1260,7 +1276,12 @@ releases it and provisions the next generation. Provisioning cut off by a
1260
1276
  recorded dispatcher teardown is the exception: the next invocation asks the
1261
1277
  provider to verify and finish the same generation (the Vercel provider resumes
1262
1278
  after its last completed stage, at the commit it cloned), and if it cannot,
1263
- the replacement consumes no infrastructure attempt. A preservation or release
1279
+ the replacement consumes no infrastructure attempt. Its `dispatch.failed`
1280
+ names the stage cut off and how long it ran (`provisioning abandoned at
1281
+ dispatcher teardown during <stage> after <N>s`). A Vercel `provisioning` step
1282
+ that exceeds its `timeoutSeconds` is instead an ordinary, charged
1283
+ infrastructure failure. Its message, like every failed sandbox provisioning
1284
+ command's, carries the stage, redacted argv and stderr/stdout tails. A preservation or release
1264
1285
  failure is recorded against its build, as an infrastructure failure or janitor
1265
1286
  attention, and never stops the dispatcher from advancing other builds. The
1266
1287
  recorded error and the infrastructure-limit escalation name the failed recovery
@@ -1281,6 +1302,16 @@ the release, the entry keeps the cut execution's instance, and the next
1281
1302
  invocation fences or releases it before anything else. A carried build keeps
1282
1303
  its slot. Its entry retires without launching anything when the build is
1283
1304
  aborted, discarded, paused or no longer needs the start.
1305
+ Ticket preparations are carried too. Intake starts a preparation only with
1306
+ about 30 s left before the work deadline. Otherwise it records the admission
1307
+ without claiming, logs `ticket <id>: preparation carried by the invocation
1308
+ budget`, counts it as `preparationsCarried` and stops claiming. A preparation
1309
+ the deadline cuts before its build exists is carried the same way. The next
1310
+ invocation prepares the same attempt first, from where it stopped, without
1311
+ re-checking capacity. A carried ticket keeps its slot and is held from other
1312
+ claims until its preparation resolves, even across several invocations, and is
1313
+ never handed back to Ready for the interruption. It is released untouched if it left
1314
+ Ready or gained unresolved blockers before its claim.
1284
1315
  No stage consumes a bounded invocation: each starts items only within its share
1285
1316
  of the time left when it begins (half for deferred work, the janitor and the
1286
1317
  lease sweep, a quarter for the others; intake runs to the work deadline), and
@@ -1291,7 +1322,10 @@ through the latest-only `dispatcher.pass-cursors` fact, so every build is
1291
1322
  visited within a bounded number of passes. Each pass logs `stages:` with time
1292
1323
  and items per stage; a pass the work deadline cuts short logs `tick: work
1293
1324
  deadline reached during <stage>` naming the part in flight, and `ab repository
1294
- status` shows the latest as `last pass stages:`.
1325
+ status` shows the latest as `last pass stages:`. A hosted store service's
1326
+ request logs attribute each store request to its caller and pass stage
1327
+ through the
1328
+ [`X-Autobuild-Caller` header](references/remote-store-protocol.md#1-transport-and-conventions).
1295
1329
  Fencing is revalidated after restart; a saved receipt alone never authorizes
1296
1330
  cleanup of a newer execution. Current recovery notes are linked by the session
1297
1331
  manifest's `workspaceRecovery` field. Recovery notes apply to the next session
@@ -1675,8 +1709,19 @@ while `round` remains occurrence scope. Answering a runner-failure cause re-arms
1675
1709
  only its matching phase and round. The phase-level `verify-failure-limit` cause
1676
1710
  explicitly re-arms all rounds for its verify target, while
1677
1711
  `reconcile-no-progress`, `publication-retry-limit`, `wait-unresolvable`,
1678
- `measurement-failed`, `target-rewritten` and the setup-only cause reset no
1679
- phase-runner failures.
1712
+ `measurement-failed`, `target-rewritten`, `dirty-worktree` and the setup-only
1713
+ cause reset no phase-runner failures.
1714
+
1715
+ `dirty-worktree` targets `implement`. Setup newly modifying tracked files
1716
+ outside `[[generated]]` (except before a `reconcile` session), or a restack or
1717
+ reconcile preparation finding them, raises it with the bounded paths. Guidance or a bare retry returns the build to
1718
+ `implement` with those paths as feedback. A frozen preparation without a publish
1719
+ intent is first superseded (`reconcile.superseded {cause: dirty-worktree}`) and
1720
+ the files stay in the worktree. One with an intent settles first, with the
1721
+ changes stored as artifact `dirty-worktree-<escalation>` for the agent to
1722
+ re-apply. A superseded replay whose target also changed a dirty file stores
1723
+ them the same way, because Git cannot carry them back to the build branch. Autobuild never commits or discards them itself, and the escalation
1724
+ never needs an abort.
1680
1725
  The closed cause map forces every future policy condition to choose one of these
1681
1726
  semantics instead of inheriting behavior from a missing `round`. Runner failures
1682
1727
  while checking progress or refreshing the base therefore remain counted after a
@@ -2597,7 +2642,7 @@ subcommands accept `--json`, which emits one bare JSON value and no prose: a
2597
2642
  `Ticket[]` for `list`, and the complete resulting `Ticket` for `create`,
2598
2643
  `update`, `block`, `unblock`, `show`, or `move`.
2599
2644
 
2600
- Paged operator ticket listings may use the optional API 1.9 `TicketSource.listPage(criteria, page)` capability; without it, the operator reads the full listing and slices it. Native errors propagate. CLI ticket lists and dispatcher ready scans remain exhaustive through `listReady`/`listAll`. PostgreSQL pages natively, and the remote `HostedTicketSource` forwards pages to it through the service's `list-page` operation, falling back only against a service predating it; file, Linear and GitHub retain fallback. The POST list-ready protocol stays exhaustive. See the [custom source contract](references/plugin-authoring.md) for types and contract coverage.
2645
+ Paged operator ticket listings may use the optional API 1.9 `TicketSource.listPage(criteria, page)` capability; without it, the operator reads the full listing and slices it. Native errors propagate. CLI ticket lists and dispatcher ready scans remain exhaustive through `listReady`/`listAll`. PostgreSQL pages natively, and the remote `HostedTicketSource` forwards pages to it through the service's `list-page` operation, falling back only against a service predating it; file, Linear and GitHub retain fallback. The POST list-ready protocol stays exhaustive. Completion filters (`since`/`until` over `resolvedAt`, `excludeLabels`, order `completed`) reach `listPage` only on sources declaring the API 1.13 `completionPaging`; the hosted source answers them with at most two range scans, each bounded at 5,001 rows, and refuses ranges over 5,000 tickets with `completion-range-too-broad`, while other sources are filtered over the full listing. See the [custom source contract](references/plugin-authoring.md) for types and contract coverage.
2601
2646
 
2602
2647
  ### Ticket assets
2603
2648
 
@@ -3179,7 +3224,8 @@ an operator may move it as soon as the event arrives. Act on that event, not on
3179
3224
  `build.aborted` or the build leaving `ab builds`: cleanup is asynchronous. Every
3180
3225
  other non-completion hand-back reports the same event once after its move —
3181
3226
  spec-gate bounces (`spec-bounce`, with `missing`), preparation recovery
3182
- returning a confirmed claim to Ready (`preparation-failed`), closed-unmerged
3227
+ returning a confirmed claim to Ready (`preparation-failed`; never for a
3228
+ preparation the work deadline cut or deferred, which is carried), closed-unmerged
3183
3229
  PRs (`pr-closed`) and discards (`discard`). Missing
3184
3230
  Forge cleanup capabilities or provider outages leave cleanup pending with an
3185
3231
  actionable diagnostic for the next tick.
@@ -3201,7 +3247,8 @@ break.
3201
3247
  `ab answer` answers every escalation that is open when the command runs,
3202
3248
  regardless of `agent`, `stall`, or `policy` source. Its text is joined, trimmed,
3203
3249
  and delivered as authoritative guidance. With no text (or only whitespace), it
3204
- requests a bare retry and supplies no agent guidance. Verify has two explicit
3250
+ requests a bare retry and supplies no agent guidance, except for a ticket wait
3251
+ and a `dirty-worktree` escalation (below). Verify has two explicit
3205
3252
  answer routes: guidance answering an agent verifier's own `ab escalate` returns
3206
3253
  to that same `verify:<step>` on `verify.started.feedback` and materializes as
3207
3254
  `$AB_CONTEXT_DIR/guidance.json`; the cited start carries it durably across any pre-launch
@@ -3246,9 +3293,14 @@ A producer round has one immediate feedback kind: on a guidance round,
3246
3293
  `$AB_CONTEXT_DIR/guidance.json` takes precedence over findings or the legacy
3247
3294
  single-report feedback. A referenced `verifyStageFailure` receipt remains
3248
3295
  available alongside guidance, with every failed report and cancelled/not-run
3249
- member; it is not erased by feedback precedence. Except for a ticket wait, a
3296
+ member; it is not erased by feedback precedence. Except for a ticket wait and a
3297
+ `dirty-worktree` escalation, a
3250
3298
  bare retry writes no `$AB_CONTEXT_DIR/guidance.json` and displaces nothing: the resumed round still gets whatever
3251
- the loop was already routing, such as the last review round's findings.
3299
+ the loop was already routing, such as the last review round's findings. A bare
3300
+ retry of a `dirty-worktree` escalation routes the next `implement` round the
3301
+ dirty-file question, its paths, any set-aside artifact's recovery instructions
3302
+ and a one-line retry summary as `$AB_CONTEXT_DIR/guidance.json`, exactly as
3303
+ guidance would.
3252
3304
 
3253
3305
  `--dismiss` is per escalation. It answers only blockers that cite at least one
3254
3306
  real plan-review or code-review finding; blockers with no such citation remain
@@ -3577,7 +3629,9 @@ The default watch reports actionable conditions only:
3577
3629
  historical ones, and nothing clears or acknowledges it.
3578
3630
  - Repository `ticket.handed-back`: the dispatcher returned a claimed or ready
3579
3631
  ticket other than as completion, and the move is committed. `cause` is
3580
- `abort`, `spec-bounce`, `preparation-failed`, `pr-closed` or `discard`; the
3632
+ `abort`, `spec-bounce`, `preparation-failed`, `pr-closed` or `discard`
3633
+ (`preparation-failed` never for a preparation the work deadline cut or
3634
+ deferred; that one is carried); the
3581
3635
  payload carries the ticket, the build slug (or the preparation attempt), the
3582
3636
  destination `state` and `role`, `requested` when an abort to ready fell back,
3583
3637
  the spec-standard parts `missing`, and the operator's `reason`. Each hand-back
@@ -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,12 +87,13 @@ 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. |
91
94
  | `GET …/harvest/status` | Harvest gate, runs, steps, recovery, and attention projection. |
92
95
  | `GET …/builds/{slug}/artifacts/{kind}?rev=N` | Raw bytes (`application/octet-stream`) plus content-disposition and `X-Autobuild-Artifact-*` metadata headers. Omit `rev` for latest. |
93
- | `GET …/tickets?state=S&label=L&limit=N&offset=K&order=O` | `{states,tickets,diagnostics,criteria,triageState,readyState,doneState,total}`. The three lifecycle names come from effective repository configuration (including provider fallback). With no `state`, `criteria.state` is `triageState`; repeated `label` parameters narrow that state with AND filters. An explicit `state` selects that exact backend workflow state. `limit` (0–200) returns one page, after skipping `offset`, in `order` `oldest` (the default: priority order, urgent, high, normal, then low tickets, each in the source order) or `newest` (newest filed first, regardless of priority; see paging below); `total` counts every match before paging. |
96
+ | `GET …/tickets?state=S&label=L&limit=N&offset=K&order=O` | `{states,tickets,diagnostics,criteria,triageState,readyState,doneState,total}`. The three lifecycle names come from effective repository configuration (including provider fallback). With no `state`, `criteria.state` is `triageState`; repeated `label` parameters narrow that state with AND filters. An explicit `state` selects that exact backend workflow state. `limit` (0–200) returns one page, after skipping `offset`, in `order` `oldest` (the default: priority order, urgent, high, normal, then low tickets, each in the source order) or `newest` (newest filed first, regardless of priority; see paging below); `total` counts every match before paging. Tickets carry `resolvedAt` and, beside `target`, `targetTitle` when known; see completion listings below. |
94
97
  | `GET …/tickets/states` | Full state metadata `{name,tickets,about?}[]`, including empty states (`tickets.states` in MCP). |
95
98
  | `GET …/tickets/{id}` | `{ticket,blockers,build,assets}`. Blockers include native `exists`/`resolved` status; `build` prefers an active matching repository build, otherwise the most recently updated one. `assets` lists the current ticket assets as `{kind,name,revision,size,layout,fileCount}`, as `ab ticket show --json` does. |
96
99
 
@@ -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
@@ -864,6 +874,19 @@ are successful cleanup; provider errors never count as completed deletion.
864
874
 
865
875
  Paged ticket listings use the source's optional native `listPage(criteria, page)` capability when present, otherwise read the full listing, order it, and slice it: by default priority order (urgent, high, normal, then low tickets, each in source order); for `newest`, the reversed listing. `newest` means newest filed first, regardless of priority, with a stable tie-break; it is not the reverse of priority order. A source that lists in filing order (file, GitHub, Linear) gets exactly that from the reversed listing. The remote `HostedTicketSource` pages natively through the service's `list-page` operation, and uses the fallback only against a service predating it. Native errors propagate. PostgreSQL counts matches without bodies and reads only the requested window. Zero limits and offsets past the end still report the full matching total. Unpaged listings remain exhaustive; the wire payload is the same for both paths.
866
876
 
877
+ Completion listings (`tickets.list` in MCP) answer "what shipped" digests:
878
+
879
+ | Input | Effect |
880
+ |---|---|
881
+ | `since`, `until` | ISO-8601 with offset; half-open `since <= resolvedAt < until`. Tickets without `resolvedAt` never match. Either one defaults `state` to the effective done state. `since` must precede `until`. |
882
+ | `order: "completed"` | Most recently completed first, ties newest filed first; tickets without a completion time follow, newest filed first. |
883
+ | `excludeLabels` | Drops any ticket carrying any named label; ANDed with `labels`, `state` and the range; `total` counts after it. |
884
+ | `summary: true` | Omits each ticket's `body` and `comments`; every other field, `revision` included, stays. |
885
+
886
+ - **Paging.** `order` and `offset` apply with or without `limit`. Any of `offset`, `order`, `since`, `until` or `excludeLabels` without `limit` pages at 200, the maximum; `total` still counts every match. A call with none of them stays exhaustive.
887
+ - **Fields.** `resolvedAt` is the ISO-8601 completion time, present only on resolved tickets whose source knows it (hosted, GitHub, Linear; never the file source). `targetTitle` is the target node's title, returned when resolvable: from the source's own read, a parent already in the listing, or one `get` per distinct remaining parent. A parent that is missing or whose read fails leaves `targetTitle` absent. `criteria` echoes the state, labels, `excludeLabels`, `since` and `until` applied.
888
+ - **Cost.** A source declaring completion paging (hosted) answers natively with at most two index range scans of the state and range, each stopping at 5,001 tickets: one counts the matches, a second reads the requested window. A zero `limit` or a refusal stops after the first. A range holding more than 5,000 tickets refuses with `code: "completion-range-too-broad"`; narrow `since`/`until`. `excludeLabels` or `order: "completed"` alone on a state holding more than 5,000 tickets refuses too. Other sources, and hosted services that predate completion listing, filter their full state listing and never refuse.
889
+
867
890
 
868
891
  ### Forge cooldown admission and explicit recovery
869
892
 
@@ -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`
@@ -251,6 +252,7 @@ A plugin relying on a capability declares an `apiVersion` range containing its v
251
252
  - **1.10** Optional ticket-source ready-assignee capability (`readyAssignee`, with `prepareReadyAssignee`, `readyAssigneeRefusal` and `describeReadyAssignee`); sources without it refuse `[tickets].readyAssignee`. Also optional targeted ticket listing (`listTargeting`); older tree sources are observed through `listAll`.
252
253
  - **1.11** Optional ticket-source search (`search`); callers refuse sources without it and never fall back to a listing.
253
254
  - **1.12** Host-provided factory-context `fetch` and `invocationSignal` for bounded-invocation cancellation.
255
+ - **1.13** Optional ticket completion listing (`completionPaging`, with `TicketPageCriteria`, order `completed` and the `TicketCompletionRangeTooBroad` refusal), and the listing-time `Ticket.resolvedAt` and `Ticket.targetTitle`; callers filter the exhaustive listing for sources without it.
254
256
 
255
257
  ## 2. Create a repository-local module
256
258
 
@@ -650,7 +652,7 @@ for any other label.
650
652
  ## Optional ticket paging capability
651
653
 
652
654
  Native paging is an optional API 1.9 ticket-source capability:
653
- `listPage?(criteria: TicketCriteria, page: TicketPage): Promise<TicketPageListing>`.
655
+ `listPage?(criteria: TicketPageCriteria, page: TicketPage): Promise<TicketPageListing>`.
654
656
  The SDK exports these types; the result is `TicketListing & { total: number }`.
655
657
  Criteria retain state, labels (AND), and assignee semantics. The page has a
656
658
  nonnegative integer `limit`, optional nonnegative integer `offset` (default 0),
@@ -674,6 +676,33 @@ File, Linear and GitHub retain fallback; the remote `HostedTicketSource`
674
676
  forwards pages to the service's native paging (`list-page`), falling back only
675
677
  against a service predating it. The POST list-ready protocol stays exhaustive.
676
678
 
679
+ Completion listing is an optional API 1.13 extension of native paging.
680
+ `listPage` takes `TicketPageCriteria`: the criteria above plus
681
+ `excludeLabels` (drop any ticket carrying any named label), and `since`
682
+ (inclusive) and `until` (exclusive) bounds on `Ticket.resolvedAt`; tickets
683
+ without a completion time never match. `TicketPage.order` adds `completed`:
684
+ tickets with `resolvedAt` first, most recent first, ties newest filed first,
685
+ then the rest newest filed first. Declare `completionPaging: true` only when
686
+ `listPage` honours all of these; callers send them only to sources declaring it
687
+ and otherwise filter the exhaustive listing with the SDK's shared semantics. A
688
+ native source may refuse a range broader than its per-request cap with
689
+ `TicketCompletionRangeTooBroad` (the SDK exports it and
690
+ `TICKET_COMPLETION_SCAN_LIMIT`); callers surface it as the
691
+ `completion-range-too-broad` refusal and never fall back. The shared contract
692
+ suite checks declared completion paging.
693
+
694
+ Tickets may carry two listing-time facts outside `revision`: `resolvedAt`, the
695
+ ISO-8601 time the ticket entered its completed state (only when `resolved`),
696
+ and `targetTitle`, the target node's title (only beside `target`). Return them
697
+ when your read already has them. The hosted PostgreSQL source records
698
+ `resolvedAt` when a ticket enters the done state, uses the last update for done
699
+ tickets that predate it, and projects `targetTitle` in its listing statements.
700
+ GitHub reports `closed_at` for completed issues and the parent title it reads
701
+ for targeting; Linear reports `completedAt` (or `canceledAt`) and the parent's
702
+ title. The file source reports no `resolvedAt`; operator listings fill a
703
+ missing `targetTitle` from tickets already listed, then with one `get` per
704
+ remaining parent.
705
+
677
706
  ## Optional ticket search capability
678
707
 
679
708
  Text search is an optional API 1.11 ticket-source capability:
@@ -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
@@ -183,7 +185,7 @@ The operation names and `input` values are:
183
185
  | `state-counts` | `{names: string[]}` (1–16) | `{name, tickets}[]` for the names that resolve |
184
186
  | `list-ready` | `{labels?: string[], state?: string}` | `TicketListing` |
185
187
  | `list-targeting` | `{nodeId: string}` | `TicketListing` of every state |
186
- | `list-page` | `{criteria: {labels?, state?}, page: {limit, offset?, order?}}` | `TicketPageListing` (`{tickets, diagnostics, total}`) |
188
+ | `list-page` | `{criteria: {labels?, state?, excludeLabels?, since?, until?}, page: {limit, offset?, order?}}` | `TicketPageListing` (`{tickets, diagnostics, total}`) |
187
189
  | `search` | `{text, state?, labels?, limit, cursor?}` | `{tickets: {id, title, state?, labels, kind, target?, priority?}[], cursor?, diagnostics}` |
188
190
  | `get` | `{id}` | `Ticket \| null` |
189
191
  | `claim` | `{id}` | `{claimed: boolean}` |
@@ -530,6 +532,39 @@ listing takes the `list-ready` path by that explicit decision.
530
532
  The capability is additive. It does not change the remote BuildStore protocol
531
533
  version, and released clients, which never send `list-page`, are unaffected.
532
534
 
535
+ ## Completion listing
536
+
537
+ Recently completed work is listed through `list-page` with completion criteria,
538
+ negotiated by `x-autobuild-ticket-completion: 1`:
539
+
540
+ - **Ticket fields.** `resolvedAt` (ISO-8601, when the ticket entered its done
541
+ state) and `targetTitle` (the target node's title, beside `target`) appear on
542
+ tickets in every operation's answer, only for clients that send the header.
543
+ Released strict decoders never see them. PostgreSQL stamps the completion time
544
+ on entering the done state and clears it on leaving; a done ticket written
545
+ before that completes at its last update.
546
+ - **Criteria.** `excludeLabels` drops any ticket carrying any named label.
547
+ `since` (inclusive) and `until` (exclusive) bound `resolvedAt`, ISO-8601 with
548
+ an offset; tickets without a completion time never match. `order: "completed"`
549
+ is most recently completed first, ties newest filed first, then tickets
550
+ without a completion time, newest filed first. Any of them requires
551
+ `criteria.state`, or the request is a `400` validation error.
552
+ - **Cap.** The PostgreSQL backend accepts a state and range holding at most
553
+ 5,000 tickets. It answers with up to two index range scans, each stopping at
554
+ 5,001 rows: one counts the matches, the second reads the requested window. A
555
+ zero `limit` or a refusal stops after the first. When the count scan reaches
556
+ the 5,001st row, the request answers
557
+ `409 {kind: "conflict", code: "completion-range-too-broad", error, limit}`;
558
+ the client reports `TicketCompletionRangeTooBroad` with the `limit`. Narrow
559
+ `since`/`until`. Within the cap, `total` is exact.
560
+ - **Refusal.** A backing source that cannot honour completion criteria answers
561
+ `409` with `code: "paging-unsupported"`.
562
+ - **Negotiation.** Every `/tickets/*` response, including errors, carries the
563
+ header. A client sends completion criteria only after a response carried it
564
+ and `list-page` is declared; otherwise it fails with `HostedTicketPagingError`
565
+ (`service-predates`) before any request, and operator listings filter
566
+ `list-ready` instead.
567
+
533
568
  ## Search
534
569
 
535
570
  `search` answers one page of compact hits from the backing source's own search,
@@ -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,
@@ -417,6 +457,11 @@ point-reads the selected slug and, for a keyed attempt, the canonical slug deriv
417
457
  from the repository, selected slug and key: one matching record and atomic
418
458
  `build.created` retain ownership even if creation threw after committing or its
419
459
  response was lost.
460
+ A bounded hosted invocation may journal an admission without a claim, when the
461
+ preparation would not fit before its work deadline, and stamps every intent with
462
+ that deadline. An attempt the deadline interrupted, with no failure or bounce
463
+ recorded, is carried: the next invocation resumes it first from its durable
464
+ boundaries, and it is never returned to Ready.
420
465
  Unavailable or conflicting readback never authorizes release or a replacement
421
466
  build. Pending attempts retain the original failure, latest recovery error and
422
467
  retry deadline in the canonical repository reduced value; resolved attempts
@@ -101,19 +101,27 @@ 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
 
111
113
  Put each selected runtime's immutable install and executable/version check in
112
114
  its `runtimeProvisioning` entry. Autobuild runs install then preflight after
113
115
  checkout dependencies in every fresh/replacement sandbox and before the
114
- readiness probe, writes the marker only after success, and reruns every
115
- preflight before each build runner. A failure names the runtime, selecting
116
- role/alternate, and field and starts no agent. Runtime provisioning receives
116
+ readiness probe, and writes the marker only after success. Every build-runner
117
+ launch and harvest relaunch reruns each selected runtime's preflight. A
118
+ preflight that fails in an existing sandbox runs that runtime's install and
119
+ then its preflight again; only a failure after that install fails the launch.
120
+ A failure names the runtime, selecting role/alternate, and the failed field
121
+ (`install` or `preflight`) with the command output, and starts no agent. A
122
+ `[roles]` change that selects a new runtime, or a changed pin, takes effect in
123
+ existing workspaces at their next launch; no abort is needed, so keep each
124
+ install safe to run over an older install. Runtime provisioning receives
117
125
  allowlisted legacy API credentials named by
118
126
  `[workspace.config].environmentVariables` and automatically supplied placeholders
119
127
  for every declared account credential variable. Account variables need no
@@ -121,7 +129,14 @@ allowlist entry; their real credentials remain on the dispatcher host.
121
129
 
122
130
  Keep package-level and checkout-level bootstrap in an idempotent
123
131
  `[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
132
+ rerun on attachment and after every restack onto a new base. It must not modify
133
+ tracked files: tracked paths it newly changes outside `[[generated]]` block the
134
+ build with `policy/dirty-worktree` before the next phase runs, naming the paths.
135
+ The check is skipped when that phase is a `reconcile`, whose resolver works on
136
+ its own in-progress replay, and while an answered dirty-worktree recovery is
137
+ pending. A restack or reconcile preparation still classifies any tracked dirt
138
+ before it replays. Declare tracked codegen outputs it rewrites in
139
+ `[[generated]]`; those are tolerated and discarded before any replay. Do not repeatedly install OS packages there. Expose only
125
140
  required runtime credentials through
126
141
  `[workspace.config].environmentVariables`, keep generated caches disposable,
127
142
  and lock dependencies in the repository. A browser-capable repository should
@@ -162,7 +177,7 @@ For Vercel it identifies and permanently deletes a fresh unnamed sandbox, even
162
177
  when system or runtime provisioning, setup, or a probe fails; cleanup failures
163
178
  name the environment for manual deletion. Its `system provisioning` check lists
164
179
  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
180
+ failed step reports its name, command, status or timeout, stderr/stdout tails, and
166
181
  remediation without marking the environment ready. It provisions/preflights
167
182
  every effective primary and alternate runtime, then runs `commands.setup`, loads
168
183
  repository plugins, and checks every