@defrex/autobuild 1.15.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +110 -10
  3. package/docs/answering-blocked-builds.md +34 -1
  4. package/docs/architecture.md +41 -7
  5. package/docs/configuration.md +41 -7
  6. package/docs/dispatcher-hosting.md +3 -0
  7. package/docs/operator-api.md +15 -5
  8. package/docs/plugin-authoring.md +1 -0
  9. package/docs/remote-store-protocol.md +13 -3
  10. package/docs/remote-ticket-protocol.md +3 -1
  11. package/docs/restacking.md +41 -1
  12. package/docs/setup.md +15 -6
  13. package/docs/troubleshooting.md +51 -3
  14. package/docs/workspaces.md +4 -1
  15. package/package.json +3 -3
  16. package/packages/core/src/cli/accounts.ts +3 -0
  17. package/packages/core/src/cli/binary-direct.ts +14 -1
  18. package/packages/core/src/cli/binary.ts +10 -7
  19. package/packages/core/src/cli/dispatch.ts +610 -356
  20. package/packages/core/src/cli/secrets.ts +2 -0
  21. package/packages/core/src/config/schema.ts +15 -2
  22. package/packages/core/src/events/payloads.ts +8 -5
  23. package/packages/core/src/events/repository.ts +12 -6
  24. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/e28c68e63cbd265f.json +108 -0
  25. package/packages/core/src/kernel/engine.ts +118 -0
  26. package/packages/core/src/kernel/reconcile-restack.ts +72 -9
  27. package/packages/core/src/kernel/reducer-revisions.ts +1 -0
  28. package/packages/core/src/kernel/tracked-dirt.ts +173 -0
  29. package/packages/core/src/ontology.ts +1 -0
  30. package/packages/core/src/operator/index.ts +10 -0
  31. package/packages/core/src/operator/merged-builds.ts +51 -0
  32. package/packages/core/src/operator/registry.ts +190 -101
  33. package/packages/core/src/operator/repo-argument.ts +43 -0
  34. package/packages/core/src/ports/tickets/grants.ts +2 -0
  35. package/packages/core/src/ports/tickets/remote.ts +2 -0
  36. package/packages/core/src/ports/types.ts +25 -4
  37. package/packages/core/src/ports/workspace/vercel-command-diagnostics.ts +144 -0
  38. package/packages/core/src/ports/workspace/vercel-sandbox.ts +811 -169
  39. package/packages/core/src/processes/build-child.ts +15 -1
  40. package/packages/core/src/processes/build-runner.ts +349 -20
  41. package/packages/core/src/processes/dispatcher.ts +509 -104
  42. package/packages/core/src/processes/harvest-child.ts +21 -1
  43. package/packages/core/src/processes/harvest-runner.ts +82 -35
  44. package/packages/core/src/processes/invocation-budget.ts +6 -0
  45. package/packages/core/src/processes/launch-cut.ts +37 -0
  46. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  47. package/packages/core/src/processes/provisioning-progress.ts +23 -0
  48. package/packages/core/src/processes/repo-view.ts +25 -4
  49. package/packages/core/src/processes/workspace-preparation.ts +1 -0
  50. package/packages/core/src/store/adapter.ts +34 -5
  51. package/packages/core/src/store/build-feed.ts +148 -22
  52. package/packages/core/src/store/build-scope.ts +12 -3
  53. package/packages/core/src/store/caller-attribution.ts +170 -0
  54. package/packages/core/src/store/contract.ts +1038 -165
  55. package/packages/core/src/store/local/schema.ts +12 -1
  56. package/packages/core/src/store/local/store.ts +260 -25
  57. package/packages/core/src/store/memory.ts +156 -9
  58. package/packages/core/src/store/phase-session.ts +23 -3
  59. package/packages/core/src/store/reducer-value-shapes.json +5351 -5338
  60. package/packages/core/src/store/remote/client.ts +90 -11
  61. package/packages/core/src/store/remote/credentials.ts +2 -0
  62. package/packages/core/src/store/remote/index.ts +31 -5
  63. package/packages/core/src/store/remote/protocol.ts +45 -8
  64. package/packages/core/src/store/remote/released-clients.json +22 -0
  65. package/packages/core/src/store/remote/released-reducer-values/1.16.0.json +36358 -0
  66. package/packages/core/src/store/remote/released-reducer-values/1.17.0.json +36367 -0
  67. package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
  68. package/packages/core/src/store/remote/released-value-policy.ts +7 -0
  69. package/packages/core/src/store/session-handle.ts +12 -3
  70. package/packages/core/src/store/types.ts +48 -3
  71. package/packages/core/src/testing/reduced-read-budget.ts +310 -12
  72. package/skills/guide/SKILL.md +58 -9
  73. package/skills/guide/references/operator-api.md +15 -5
  74. package/skills/guide/references/plugin-authoring.md +1 -0
  75. package/skills/guide/references/remote-store-protocol.md +13 -3
  76. package/skills/guide/references/remote-ticket-protocol.md +3 -1
  77. package/skills/guide/references/restacking.md +41 -1
  78. package/skills/guide/references/setup.md +15 -6
  79. package/skills/operate/SKILL.md +31 -7
  80. package/templates/hosted-service/package.json +2 -2
@@ -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
@@ -927,7 +931,13 @@ build status and the dashboard, stop dependent work, and retry up to
927
931
  `[policy].maxSetupAttempts`; exhaustion raises a setup-targeted escalation
928
932
  without manufacturing a pipeline phase or verdict. An answer from your operator
929
933
  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
934
+ a new `runner.attached`, clears the current error. Setup must not modify
935
+ tracked files: paths it newly changes outside `[[generated]]` raise a
936
+ `policy/dirty-worktree` escalation naming them before the next phase runs;
937
+ declared generated outputs are tolerated. The check is skipped when that phase
938
+ is a `reconcile`, whose resolver works on its own in-progress replay, and while
939
+ an answered dirty-worktree recovery is pending; restack and reconcile
940
+ preparation still classify tracked dirt before replaying. Values are never evaluated as config — they are handed to a
931
941
  shell as written.
932
942
 
933
943
  Fresh init config deliberately leaves this map empty. The setup agent follows
@@ -964,6 +974,9 @@ index, or leftover conflict markers fails the regeneration; nothing is committed
964
974
  ordinary reconcile with the failure reason in its context. A replay that also
965
975
  conflicts in undeclared files goes straight to reconcile, whose context lists
966
976
  the generated files and commands to run after the other files are resolved.
977
+ Uncommitted changes to declared files, such as outputs setup rewrote, are
978
+ restored to `HEAD` before any restack or reconcile replay; an undeclared
979
+ tracked change refuses preparation with `policy/dirty-worktree` naming it.
967
980
  Declarations come from the dispatcher's live configuration, like `[policy]`.
968
981
  See [Restacking](references/restacking.md) for the recorded facts.
969
982
 
@@ -1258,8 +1271,14 @@ down. A workspace
1258
1271
  flagged by `workspace.cleanup-required` is never launched into: the dispatcher
1259
1272
  releases it and provisions the next generation. Provisioning cut off by a
1260
1273
  recorded dispatcher teardown is the exception: the next invocation asks the
1261
- provider to verify and finish the same generation, and if it cannot, the
1262
- replacement consumes no infrastructure attempt. A preservation or release
1274
+ provider to verify and finish the same generation (the Vercel provider resumes
1275
+ after its last completed stage, at the commit it cloned), and if it cannot,
1276
+ the replacement consumes no infrastructure attempt. Its `dispatch.failed`
1277
+ names the stage cut off and how long it ran (`provisioning abandoned at
1278
+ dispatcher teardown during <stage> after <N>s`). A Vercel `provisioning` step
1279
+ that exceeds its `timeoutSeconds` is instead an ordinary, charged
1280
+ infrastructure failure. Its message, like every failed sandbox provisioning
1281
+ command's, carries the stage, redacted argv and stderr/stdout tails. A preservation or release
1263
1282
  failure is recorded against its build, as an infrastructure failure or janitor
1264
1283
  attention, and never stops the dispatcher from advancing other builds. The
1265
1284
  recorded error and the infrastructure-limit escalation name the failed recovery
@@ -1270,6 +1289,16 @@ build as `recoveryDeferred` (or `provisioningDeferred` for a provision that
1270
1289
  needs about 150 s), logs `build <slug>: <step> deferred by the invocation
1271
1290
  budget`, never reports idle, and records it in `dispatcher.work-deferred`, so
1272
1291
  the next invocation runs that build first, within half of its window.
1292
+ Every start a bounded invocation admits but does not finish is carried this
1293
+ way. That includes the first provision of a build intake just claimed, which
1294
+ the next invocation runs by completing the build's dispatch. It also includes a
1295
+ launch the work deadline cuts after its execution lease was claimed, logged as
1296
+ step `launch`. Teardown releases that lease, after fencing the sandbox when the
1297
+ provider start was already requested. When teardown cannot confirm the fence or
1298
+ the release, the entry keeps the cut execution's instance, and the next
1299
+ invocation fences or releases it before anything else. A carried build keeps
1300
+ its slot. Its entry retires without launching anything when the build is
1301
+ aborted, discarded, paused or no longer needs the start.
1273
1302
  No stage consumes a bounded invocation: each starts items only within its share
1274
1303
  of the time left when it begins (half for deferred work, the janitor and the
1275
1304
  lease sweep, a quarter for the others; intake runs to the work deadline), and
@@ -1280,7 +1309,10 @@ through the latest-only `dispatcher.pass-cursors` fact, so every build is
1280
1309
  visited within a bounded number of passes. Each pass logs `stages:` with time
1281
1310
  and items per stage; a pass the work deadline cuts short logs `tick: work
1282
1311
  deadline reached during <stage>` naming the part in flight, and `ab repository
1283
- status` shows the latest as `last pass stages:`.
1312
+ status` shows the latest as `last pass stages:`. A hosted store service's
1313
+ request logs attribute each store request to its caller and pass stage
1314
+ through the
1315
+ [`X-Autobuild-Caller` header](references/remote-store-protocol.md#1-transport-and-conventions).
1284
1316
  Fencing is revalidated after restart; a saved receipt alone never authorizes
1285
1317
  cleanup of a newer execution. Current recovery notes are linked by the session
1286
1318
  manifest's `workspaceRecovery` field. Recovery notes apply to the next session
@@ -1664,8 +1696,19 @@ while `round` remains occurrence scope. Answering a runner-failure cause re-arms
1664
1696
  only its matching phase and round. The phase-level `verify-failure-limit` cause
1665
1697
  explicitly re-arms all rounds for its verify target, while
1666
1698
  `reconcile-no-progress`, `publication-retry-limit`, `wait-unresolvable`,
1667
- `measurement-failed`, `target-rewritten` and the setup-only cause reset no
1668
- phase-runner failures.
1699
+ `measurement-failed`, `target-rewritten`, `dirty-worktree` and the setup-only
1700
+ cause reset no phase-runner failures.
1701
+
1702
+ `dirty-worktree` targets `implement`. Setup newly modifying tracked files
1703
+ outside `[[generated]]` (except before a `reconcile` session), or a restack or
1704
+ reconcile preparation finding them, raises it with the bounded paths. Guidance or a bare retry returns the build to
1705
+ `implement` with those paths as feedback. A frozen preparation without a publish
1706
+ intent is first superseded (`reconcile.superseded {cause: dirty-worktree}`) and
1707
+ the files stay in the worktree. One with an intent settles first, with the
1708
+ changes stored as artifact `dirty-worktree-<escalation>` for the agent to
1709
+ re-apply. A superseded replay whose target also changed a dirty file stores
1710
+ them the same way, because Git cannot carry them back to the build branch. Autobuild never commits or discards them itself, and the escalation
1711
+ never needs an abort.
1669
1712
  The closed cause map forces every future policy condition to choose one of these
1670
1713
  semantics instead of inheriting behavior from a missing `round`. Runner failures
1671
1714
  while checking progress or refreshing the base therefore remain counted after a
@@ -3190,7 +3233,8 @@ break.
3190
3233
  `ab answer` answers every escalation that is open when the command runs,
3191
3234
  regardless of `agent`, `stall`, or `policy` source. Its text is joined, trimmed,
3192
3235
  and delivered as authoritative guidance. With no text (or only whitespace), it
3193
- requests a bare retry and supplies no agent guidance. Verify has two explicit
3236
+ requests a bare retry and supplies no agent guidance, except for a ticket wait
3237
+ and a `dirty-worktree` escalation (below). Verify has two explicit
3194
3238
  answer routes: guidance answering an agent verifier's own `ab escalate` returns
3195
3239
  to that same `verify:<step>` on `verify.started.feedback` and materializes as
3196
3240
  `$AB_CONTEXT_DIR/guidance.json`; the cited start carries it durably across any pre-launch
@@ -3235,9 +3279,14 @@ A producer round has one immediate feedback kind: on a guidance round,
3235
3279
  `$AB_CONTEXT_DIR/guidance.json` takes precedence over findings or the legacy
3236
3280
  single-report feedback. A referenced `verifyStageFailure` receipt remains
3237
3281
  available alongside guidance, with every failed report and cancelled/not-run
3238
- member; it is not erased by feedback precedence. Except for a ticket wait, a
3282
+ member; it is not erased by feedback precedence. Except for a ticket wait and a
3283
+ `dirty-worktree` escalation, a
3239
3284
  bare retry writes no `$AB_CONTEXT_DIR/guidance.json` and displaces nothing: the resumed round still gets whatever
3240
- the loop was already routing, such as the last review round's findings.
3285
+ the loop was already routing, such as the last review round's findings. A bare
3286
+ retry of a `dirty-worktree` escalation routes the next `implement` round the
3287
+ dirty-file question, its paths, any set-aside artifact's recovery instructions
3288
+ and a one-line retry summary as `$AB_CONTEXT_DIR/guidance.json`, exactly as
3289
+ guidance would.
3241
3290
 
3242
3291
  `--dismiss` is per escalation. It answers only blockers that cite at least one
3243
3292
  real plan-review or code-review finding; blockers with no such citation remain
@@ -5,7 +5,9 @@ contract at
5
5
  `/operator/v1/repos/{repo}`. It is versioned with remote store protocol **7**.
6
6
  Every request must send `X-Autobuild-Version`,
7
7
  `X-Autobuild-Protocol-Version: 7`, and `Authorization: Bearer …`. Identity is
8
- checked before authentication or resource lookup.
8
+ checked before authentication or resource lookup. The optional, diagnostic
9
+ `X-Autobuild-Caller` header follows the remote store protocol's transport
10
+ conventions.
9
11
 
10
12
  Project credentials are opaque `abp_1_<id>_<secret>` bearer values bound to one
11
13
  registered normalized repository. The service stores only a SHA-256 digest of
@@ -85,6 +87,7 @@ raw session-event append. External operator harnesses own agent execution.
85
87
  | Method and path | Result |
86
88
  |---|---|
87
89
  | `GET …/builds?scope=active\|queued\|all` | Build summaries, newest update first. `queued` means active plus queued, matching `ab builds --queued`. Each nonterminal summary's `slot` is `{state: "held"}`, `{state: "requested", request, priority?: "urgent" \| "high" \| "low"}` or `{state: "none"}`; absent means unknown (an older server), never `none`. Its `statusWord` is `{word, tone, note?}`, the status word every surface shows; `status` stays the reducer's lifecycle status. |
90
+ | `GET …/builds?scope=merged&since=T&until=T&limit=N&cursor=C` | `{builds, next}`: merged builds, most recently merged first, each `{slug, mergedAt, kind, ticket?, pr?, target?}`. `mergedAt` is when the build merged, never a later cleanup write; `kind` is `leaf` or `node`; `pr` is `{number, url}`; `target` is `{build, ticket}` for a child of a node. `since` (inclusive) and `until` (exclusive) are ISO instants with a zone; `limit` is 1–100 (default 25); pass `next` back as `cursor` with the same window. One indexed page read, no event rows. These four parameters on another scope are a `400 validation`; a bad window, limit or cursor is `400 validation` with code `invalid-page`. |
88
91
  | `GET …/builds/{slug}` | `{detail, dashboardRow}`; `detail.slot` and `dashboardRow.slot` carry the build's slot state, shaped as in `GET …/builds`; `detail.runnerAttaches` records chronological attach boundaries and their runtime identity (version, commit, source kind/location), with null runtime for unrecorded historical attaches; `dashboardRow` remains a `CLEANING` row after `build.aborted` and becomes `null` only when the dashboard stops listing it: at `build.completed` when no escalation is open. A completed build with an open escalation keeps, or regains, a `BLOCKED` row (note `done`), including one raised during abort cleanup; abort itself closes the escalations open when it is accepted. The row becomes `null` once the escalation is acknowledged; neither step reopens its lifecycle state. |
89
92
  | `GET …/dashboard` | `{generatedAt, model, settingsHeader}`. `model` is the dashboard's rows, steps, elapsed timing inputs, harvest row, triage (when the dispatcher published one)/queue/capacity and settings projection. `model.capacity.slots` maps each build to its slot state, and each `model.builds[].slot` repeats it; absent means unknown. `model.configuration` is `"no-dispatcher-run"` when the repository records no dispatcher run, and absent otherwise. Optional `rollback` contains `correlation`, `lineage`, full `failed` and `restored` runtime identities and rollback event `ts` for the authoritative dispatcher lineage’s unresolved hold. Both dashboards name failed, restored and held runtime plus timestamp. Matching durable different-target hold clearance removes it; a fresh operator lineage hides it only after a committed operational tick or accepted takeover. Run-started and yielded ticks alone cannot replace authority; same-lineage generations retain the notice. Historical rollback records are not fallback notices. Optional `handoffs` lists all accepted unfinished handoffs with predecessor `run`, optional `successor`, `correlation`, full `from`/`to` runtimes, `mode` and optional `deadline`. Outstanding drain-mode builds carry `draining: true`, also on build-detail `dashboardRow`; matching settlement removes it. Accepted completion removes the handoff; neither takeover nor the clock does. Missing historical mode means cutover and missing deadline displays unknown. |
90
93
  | `GET …/status` | Repository intake, pause, and default-auto-merge projection, plus `ticketStarts` (`{pending, recent}`, each entry with its `priority`) when single-ticket start requests are pending or recently settled. `capacity.slots`, when the held configuration is readable, maps each nonterminal build to its slot state; `capacity.occupied` counts its `held` entries. Its `operator` is `{presence: "unavailable", reason}`: this route does not load presence registrations, so it is not evidence that no operator is present. |
@@ -194,7 +197,8 @@ both refusals record nothing.
194
197
 
195
198
  One generic route executes any entry of the agent tool registry (the same
196
199
  closed table `ab mcp` serves over stdio): the body is the tool's validated input — `repo`
197
- included and required to equal the URL's repository — and the response is the
200
+ included and required to equal the URL's repository; a `repository` key is
201
+ refused as `400 validation` with code `repo-argument` — and the response is the
198
202
  registry result verbatim. The verified operator token supplies the acting
199
203
  identity and, when minted with one, the `via` attribution marker; the body
200
204
  never does. Failures keep the shared `{kind,error,code?,progress?,state?}` shape
@@ -208,7 +212,10 @@ deployment can host operator sandboxes, and each call is gated per repository
208
212
  on the latest deposited effective config. A closed gate is a `409 refusal`
209
213
  with code `sandbox-orchestrator-disabled`, `sandbox-no-effective-config`,
210
214
  `sandbox-effective-config-invalid`, `sandbox-credentials-missing` or
211
- `sandbox-backend-unavailable`.
215
+ `sandbox-backend-unavailable`. Hosted `/mcp` tool calls reach this route
216
+ with the caller attribution `X-Autobuild-Caller: kind=operator;client=mcp`
217
+ (see the remote store protocol's transport conventions), so the service's
218
+ request logs can tell them apart.
212
219
 
213
220
  ### Per-repository MCP URLs
214
221
 
@@ -220,7 +227,8 @@ URL. Adding it to an agent harness connects that harness to one repository.
220
227
  | URL | `<resource>` | `<resource>/<host><path>`, e.g. `https://ops.example/mcp/github.com/acme/widgets` for `https://github.com/acme/widgets` |
221
228
  | Tool schemas | every tool requires `repo` | no `repo` field; the URL's repository is supplied |
222
229
  | `repositories.list` | offered | not offered |
223
- | A `repo` argument | names the repository | equal to the URL's repository is ignored; any other is a `validation` result |
230
+ | A `repo` argument | names the repository | refused, even the URL's own repository: a `validation` result with code `repo-argument` |
231
+ | A `repository` argument | refused: `validation`, code `repo-argument` (the argument is `repo`) | refused: `validation`, code `repo-argument` |
224
232
  | `sandbox.*` listed | when the deployment can host sandboxes | also needs the repository's latest deposited effective config to enable `[orchestrator]` (one latest-artifact read per listing) |
225
233
  | Instructions | describe the deployment, with each accessible repository's agent context | name only that repository, with its agent context |
226
234
  | Prompts | one per skill per accessible repository, `<label>.<skill>` | one per skill, named for the skill |
@@ -327,7 +335,9 @@ the browser user's human actor while no token or signing secret reaches client
327
335
  code. Responses are private/no-store; 401 requires reauthentication.
328
336
  Polling clients may use a two-second interval. The gateway provides no
329
337
  streaming transport; `ab watch` polls store event reads client-side. Delegated bearer tokens remain
330
- server-side.
338
+ server-side. Delegated requests carry `X-Autobuild-Caller:
339
+ kind=operator;client=web`, set by the gateway; a browser cannot choose its
340
+ own attribution.
331
341
 
332
342
  The API does not expose phase-session commands, runner startup, a push or
333
343
  long-poll streaming transport, or a generic event-append operation; event
@@ -50,6 +50,7 @@ Declare served model prefixes and a default. Optional tool-free `oneShot` sits b
50
50
  - Resume an intact branch non-destructively, never silently re-cut from a newer base. Rematerialize a lost copy. Make release idempotent.
51
51
  - Optional `provision.publication` supplies a durable confirmed SHA and known cache tips for authoritative readback and cache repair. Preserve unknown unpublished work.
52
52
  - Optional `provision.fresh: { owner }` marks a build's first provision. A pre-existing branch of that name is not the build's work: never return it as the base unless you hold your own creation receipt for `owner` (stable across that build's retries). Cut from `baseBranch` and keep the old tip recoverable. Providers that ignore it rely on claim-time deduplication.
53
+ - Optional `provision.signal` is the invocation's teardown token: abort in-flight provisioning promptly and record nothing; the dispatcher records the abandonment. Optional `provision.onProgress({ stage, step? })` reports each stage just before it runs, so a teardown can name it; it must never block or throw.
53
54
  - Optional `localBranchExists(repo, branch)` reports a local `refs/heads/<branch>` in the checkout you create branches in, and throws when the probe fails. Dispatch calls it only at claim time and skips such a slug. Omit it when your branches aren't local; `remoteBranchExists` covers those.
54
55
 
55
56
  ### `forge`
@@ -114,6 +114,15 @@ Placement is informational and does not change `ab dispatch` behavior.
114
114
  body parsing, or resource lookup, the server validates the release-line window and known protocol identity.
115
115
  Unsupported or missing values receive `409 {"kind":"conflict","error":"…"}`;
116
116
  the diagnostic names the client and server package and protocol versions.
117
+ - Clients may send `X-Autobuild-Caller`, a diagnostic attribution of who made
118
+ the request: `key=value` pairs joined by `;`, at most 512 characters. Keys
119
+ are `kind` (`dispatcher`, `runner` or `operator`), `client`, `runner`,
120
+ `invocation`, `run`, `stage`, `build`, `harvest`, `execution`, `session`,
121
+ `phase` and `command`; each value is at most 96 characters of
122
+ `[A-Za-z0-9._:@+/-]`. The shipped client sends it on store, ticket, grant
123
+ and credential requests. A server must accept requests without it, must
124
+ treat it as untrusted (bound, sanitize, ignore unknown keys), and must never
125
+ use it for authorization or routing.
117
126
  - Clients send `Content-Type: application/json` for requests with bodies. Every
118
127
  response, including errors and `null` artifact results, has
119
128
  `Content-Type: application/json`.
@@ -763,7 +772,7 @@ artifacts, and leases. `{repo}` is one percent-encoded repository id; encode
763
772
  embedded `/` characters. All resource routes authorize and require the
764
773
  repository to exist. An unknown repository returns `404 not-found` — except
765
774
  for the build-record reads of this section (`change-position`, `builds`,
766
- `changed-builds`, `build-page`, `build-digests`, `open-builds` and `rollup-values`), which are keyed
775
+ `changed-builds`, `build-page`, `merged-build-page`, `build-digests`, `open-builds` and `rollup-values`), which are keyed
767
776
  to build records, not the repository journal record, so they authorize the
768
777
  project credential but answer `200` (possibly empty) even for an unknown
769
778
  repository, a repository without a journal record, or a repository without
@@ -787,6 +796,7 @@ builds.
787
796
  | `listBuildsForRepo` | `GET /repos/{repo}/builds` | none | `200` + `BuildRecord[]` ordered by creation time, then slug |
788
797
  | `listBuildsChangedSince` | `GET /repos/{repo}/changed-builds?since={p}` | required `since`, a canonical unsigned decimal no greater than 9223372036854775807; anything else is `400 validation` | `200 {"position": string, "builds": [{"slug": string, "position": string}]}`: the builds whose latest change position is greater than `since`, ascending by position and each once, with the repository head read in the same snapshot. Reads no event rows. An unknown repository answers `{"position": "0", "builds": []}` |
789
798
  | `listBuildsPage` | `GET /repos/{repo}/build-page?limit={n}&cursor={c}&kind={k}&outcome=merged&activeSince={t}` | optional `limit`, a decimal integer from 1 to 100 (default 25); optional `cursor`, a `next` value this server issued for the same filters; optional `kind`, `leaf` or `node`; optional `outcome`, only `merged`; optional `activeSince`, an ISO instant with a zone. A bad limit, a malformed cursor, a cursor of the other order, or an empty or invalid filter is `400 validation` | `200 {"builds": BuildRecord[], "next": string \| null, "filters"?: {"kind"?, "outcome"?, "activeSince"?}}`: one page newest first by creation time, slug descending to break ties, with records as `builds` returns them; `next` is `null` on the last page. `kind` and `outcome` keep that order. `activeSince` keeps builds whose `updatedAt` is at or after it, ordered by `updatedAt` then slug, both descending, a superset of builds active in the window; a build written between two requests can appear twice or be skipped once, so dedupe by slug. A filtered answer echoes the normalized filters it applied as `filters`. Every page, filtered or not, costs at most `limit + 1` index entries and no event rows |
799
+ | `listMergedBuildsPage` | `GET /repos/{repo}/merged-build-page?limit={n}&cursor={c}&since={t}&until={t}` | optional `limit`, as for `build-page`; optional `cursor`, a `next` value this server issued for the same window; optional `since` (inclusive) and `until` (exclusive), ISO instants with a zone. A bad limit, a malformed cursor, a cursor of another order, an empty or invalid instant, or `since` after `until` is `400 validation` | `200 {"builds": [{"record": BuildRecord, "mergedAt": string, "kind": "leaf" \| "node", "pr"?: {"number", "url"}, "target"?: {"build", "ticket"}}], "next": string \| null}`: merged builds, most recently merged first (merge time, then slug, both descending). `mergedAt` is the merging `build.completed`'s `ts`; `pr` comes from the latest `pr.opened` or `finalize.completed`; `target` from `build.created`, replaced on a node by `node.parent-accepted`. Every page costs at most `limit + 1` index entries, no event rows and no reduced values |
790
800
  | `getReducerValue` (rollup scope) | `POST /repos/{repo}/rollup-values` | a named-value request with optional `read`; see [Rollup values](#rollup-values) | `200 {"version", "cursor": 0, "value"}`: the canonical rollup; an unknown repository answers the empty value |
791
801
  | `getRepoBuildDigests` | `GET /repos/{repo}/build-digests` | none | `200` + `BuildDigest[]`, one entry per build record of the repository (possibly empty), ordered by slug; handled before the repository-existence gate, so an unknown or journal-less repository answers `200 []` |
792
802
  | `listOpenBuilds` | `GET /repos/{repo}/open-builds` | none | `200` + `[{"record", "digest"}]`, a build record and its `BuildDigest` for every open build of the repository (possibly empty), ordered by `createdAt` and then slug; handled before the repository-existence gate, so an unknown or journal-less repository answers `200 []` |
@@ -794,8 +804,8 @@ builds.
794
804
  | `heartbeatRepo` | `POST /repos/{repo}/lease/heartbeat` | holder request | `200 {"ok": boolean}` |
795
805
  | `releaseRepoLease` | `POST /repos/{repo}/lease/release` | holder request | `200 {"ok": true}`; a wrong holder is a successful no-op |
796
806
 
797
- The `changed-builds` and `build-page` routes are additive and keep the
798
- protocol version. A server on the same release line that lacks them answers
807
+ The `changed-builds`, `build-page` and `merged-build-page` routes are additive
808
+ and keep the protocol version. A server on the same release line that lacks them answers
799
809
  `501 unsupported-operation` or `404 not-found`; the shipped client reports
800
810
  that as a typed `BuildFeedUnsupportedError` and never falls back to listing
801
811
  builds or reading events. The `build-page` filters are additive too. A server
@@ -35,7 +35,9 @@ Every request is `POST /tickets/<operation>`, has `Content-Type: application/jso
35
35
  and requires `Authorization: Bearer <project credential>`. Authentication and
36
36
  registration checks precede body parsing and source construction. Owner admin
37
37
  is the explicit cross-project exception; internal operator signatures have no
38
- ticket authority.
38
+ ticket authority. Clients may also send the optional, diagnostic
39
+ `X-Autobuild-Caller` attribution header described in the remote store
40
+ protocol's transport conventions; the service never authorizes on it.
39
41
 
40
42
  Project credentials are opaque `abp_1_<id>_<secret>` bearer values bound to one
41
43
  registered normalized repository. The service stores only a SHA-256 digest of
@@ -159,7 +159,8 @@ applies to nodes: a stale node cannot verify or merge; inventory and child merge
159
159
  continue while it collects.
160
160
 
161
161
  Restack and reconcile publication reject tracked modifications with the existing
162
- clean-worktree error. Nonignored untracked files do not block publication and
162
+ clean-worktree error. Before a replay, preparation handles them as described in
163
+ [Tracked dirt before preparation](#tracked-dirt-before-preparation). Nonignored untracked files do not block publication and
163
164
  remain unpublished and untouched; each publication that encounters them records
164
165
  a path-bearing `observation.recorded` followup, deduplicated by operation,
165
166
  transaction, candidate SHA and exact path list on recovery. The phase-terminal
@@ -342,6 +343,45 @@ and `· N regenerated` or `· regeneration failed` to a node's restack lines.
342
343
  `ab watch --event 'restack.*'` or `--event 'node.item-*'` shows each outcome.
343
344
  Repositories that declare nothing restack exactly as before.
344
345
 
346
+ ## Tracked dirt before preparation
347
+
348
+ Uncommitted changes to tracked files, typically left by `[commands].setup` on
349
+ a relaunch, never strand a restack or reconcile preparation:
350
+
351
+ | Dirt | Outcome |
352
+ |---|---|
353
+ | Only declared `[[generated]]` paths | Restored to `HEAD`, one `followup` observation recorded, replay proceeds |
354
+ | Any undeclared path | Preparation refuses, touches nothing, raises `policy/dirty-worktree` naming the undeclared paths |
355
+
356
+ The same classification runs again just before a completed automatic replay
357
+ or an intended candidate publishes, so a relaunch or crash at any point of the
358
+ replay cannot reach publication with dirt. A fresh automatic restack and a
359
+ fresh epilogue reconcile check before
360
+ `restack.prepared` or `reconcile.started`, so a refusal freezes nothing and
361
+ spends no phase-failure budget. Answering the escalation with guidance or a
362
+ bare retry returns the build to `implement`:
363
+
364
+ - **Nothing frozen.** `implement` runs with the question, its paths and the
365
+ answer as feedback.
366
+ - **Frozen, no publish intent.** The kernel records `reconcile.superseded
367
+ {cause: dirty-worktree}`, returns a workspace the replay left detached to
368
+ the build branch with the changes intact, then runs `implement`. If the
369
+ target also changed a dirty file, so Git cannot carry it, the changes are
370
+ first set aside as artifact `dirty-worktree-<escalation>`, as below. The
371
+ abandoned restack is decided again from the new head.
372
+ - **Frozen, publish intent recorded.** The candidate settles first: the
373
+ undeclared changes are stored as artifact `dirty-worktree-<escalation>` (a
374
+ byte-exact binary patch, captured without textconv or external diff
375
+ drivers) with observation `dirty-worktree:<escalation>:set-aside`,
376
+ restored, and the frozen candidate publishes as recorded. The `implement`
377
+ feedback names the artifact and how to re-apply it. If the set-aside runs
378
+ again before the restore (after a stop, or when relaunch setup rewrote a
379
+ path), a changed tree is stored as a new artifact revision first; it keeps
380
+ every file an earlier revision held, so the latest revision is complete.
381
+
382
+ Autobuild never commits or discards undeclared changes on its own, and the
383
+ escalation never needs an abort.
384
+
345
385
  ## Foreign merges
346
386
 
347
387
  Before any replay or publication, inspect every merge's non-first-parent history,
@@ -101,10 +101,12 @@ Use the supported `vercel/sandbox/universal` image. Other managed images and
101
101
  custom VCR images are rejected. Autobuild remains stack-neutral. For Vercel,
102
102
  put repository-specific operating-system packages and machine-level tooling in
103
103
  the ordered `[workspace.config].provisioning` list. Each strict `{ name,
104
- command }` entry runs from the checkout through `sh -c` with provider root
105
- authority after pinned Bun is verified and before dependency bootstrap,
106
- `[commands].setup`, or an agent. It runs once per fresh environment and repeats
107
- on every replacement. Commands are declarative TOML string data, not evaluated
104
+ command, timeoutSeconds? }` entry runs from the checkout through `sh -c` with
105
+ provider root authority after pinned Bun is verified and before dependency
106
+ bootstrap, `[commands].setup`, or an agent. It runs once per fresh environment
107
+ and repeats on every replacement. A step runs under `timeoutSeconds` (default
108
+ 600, at most 840); one that fails reports its name, redacted command and
109
+ output tails, and one that overruns also reports its elapsed time. Commands are declarative TOML string data, not evaluated
108
110
  configuration logic. Local git worktrees never run this list; ensure their host
109
111
  already has required system tooling.
110
112
 
@@ -121,7 +123,14 @@ allowlist entry; their real credentials remain on the dispatcher host.
121
123
 
122
124
  Keep package-level and checkout-level bootstrap in an idempotent
123
125
  `[commands].setup`. It runs after system provisioning and must remain safe to
124
- rerun on attachment and after every restack onto a new base. Do not repeatedly install OS packages there. Expose only
126
+ rerun on attachment and after every restack onto a new base. It must not modify
127
+ tracked files: tracked paths it newly changes outside `[[generated]]` block the
128
+ build with `policy/dirty-worktree` before the next phase runs, naming the paths.
129
+ The check is skipped when that phase is a `reconcile`, whose resolver works on
130
+ its own in-progress replay, and while an answered dirty-worktree recovery is
131
+ pending. A restack or reconcile preparation still classifies any tracked dirt
132
+ before it replays. Declare tracked codegen outputs it rewrites in
133
+ `[[generated]]`; those are tolerated and discarded before any replay. Do not repeatedly install OS packages there. Expose only
125
134
  required runtime credentials through
126
135
  `[workspace.config].environmentVariables`, keep generated caches disposable,
127
136
  and lock dependencies in the repository. A browser-capable repository should
@@ -162,7 +171,7 @@ For Vercel it identifies and permanently deletes a fresh unnamed sandbox, even
162
171
  when system or runtime provisioning, setup, or a probe fails; cleanup failures
163
172
  name the environment for manual deletion. Its `system provisioning` check lists
164
173
  completed step names (or says none were declared) before guest setup checks. A
165
- failed step reports its name, command, status, labeled stdout/stderr, and
174
+ failed step reports its name, command, status or timeout, stderr/stdout tails, and
166
175
  remediation without marking the environment ready. It provisions/preflights
167
176
  every effective primary and alternate runtime, then runs `commands.setup`, loads
168
177
  repository plugins, and checks every
@@ -334,6 +334,10 @@ Read events with a cursor or a small `--events` count; logs are long.
334
334
  target was force-pushed while it had work of its own. It restacks the build's
335
335
  own commits onto the current target; abort is the alternative. A leaf with no
336
336
  work recovers from a rewritten target by itself and raises nothing.
337
+ A `dirty-worktree` escalation names tracked files changed outside
338
+ `[[generated]]`, usually by `[commands].setup`; answer with guidance or a bare
339
+ retry, never abort: the build returns to implement to commit, revert or
340
+ regenerate them.
337
341
  Idle collecting or verification-failed nodes need no escalation and recollect
338
342
  for verification on the same head; children and contributions remain intact.
339
343
  Active work, pause, pending controls and merge intent refuse revision. Leaves
@@ -510,11 +514,14 @@ operator tools. Which repository you act on depends on the connector:
510
514
 
511
515
  - **Per-repository connector** (a URL such as `<origin>/mcp/github.com/acme/widgets`,
512
516
  copied from the project's Settings tab): it serves that one repository. Its
513
- tools have no `repo` argument; do not add one, because a `repo` naming
514
- another repository is refused.
517
+ tools have no `repo` argument; do not add one, because any `repo`, even
518
+ naming that repository, is refused with code `repo-argument`.
515
519
  - **Deployment-wide connector** (`<origin>/mcp`): every tool requires `repo`.
516
520
  Call `repositories.list` to find the identities you can reach.
517
521
 
522
+ The argument is `repo`, never `repository`; a `repository` argument is
523
+ refused on both connectors.
524
+
518
525
  Either way, follow each advertised tool schema exactly.
519
526
 
520
527
  ### Load context first
@@ -587,7 +594,12 @@ Your tools are the operator registry. The read-only ones are always safe:
587
594
  - `repository.attention` — the attention digest: everything waiting on the
588
595
  operator, each item naming its resolving tool call. The first call of each
589
596
  round.
590
- - `builds.list` — active, queued, or all builds, with effective status.
597
+ - `builds.list` — active, queued, or all builds, with effective status. Scope
598
+ `merged` answers "what shipped": merged builds, most recently merged first,
599
+ each with `mergedAt`, `kind`, `ticket`, `pr` and the node `target` of a child
600
+ build. Narrow it with `since` (inclusive) and `until` (exclusive) instants
601
+ and page with `limit` and the returned `next` as `cursor`. Use `active` and
602
+ `queued` for what lands next.
591
603
  - `builds.get` — one build's detail.
592
604
  - `builds.events` — one build's event log from a cursor (use a cursor; logs
593
605
  are long).
@@ -885,6 +897,10 @@ waits, end the message with one line saying so, such as
885
897
  logical credentials, or records a reasoned `harvest.session.resume-fallback`
886
898
  and starts fresh. Orderly suspension spends no recovery attempt; real
887
899
  crashes retain recovery accounting.
900
+ A hosted harvest launch that is still preparing stops at its next boundary,
901
+ and teardown joins it before releasing the lease. A harvest that a
902
+ dispatcher launches never claims, renews or releases the repository lease
903
+ on its own behalf.
888
904
  - Human checkout dispatch defaults to viewer for hosted placement. Humans can use
889
905
  `--takeover` to dispatch locally with a displacement warning; unreadable placement
890
906
  fails closed and names `--viewer` and `--takeover` as explicit recovery choices.
@@ -1131,10 +1147,13 @@ slow cold resume of a stopped sandbox: retry, or suggest raising
1131
1147
  `at step cleanup` points at sandbox or provider state worth checking before a
1132
1148
  retry; `at step preserve` at the checkout, forge credentials or branch.
1133
1149
  A dispatch log line `build X: resume deferred by the invocation budget` (or
1134
- `provision deferred`), counted as `recoveryDeferred` or `provisioningDeferred`,
1135
- is normal: nothing is charged and the next invocation runs that build first.
1136
- The same build deferring across several invocations means the hosted budget
1137
- cannot fit that work: report it, and do not retry it.
1150
+ `provision deferred`, or `launch deferred` for a launch the work deadline cut),
1151
+ counted as `recoveryDeferred` or `provisioningDeferred`, is normal: nothing is
1152
+ charged, the build keeps its slot, and the next invocation runs that build
1153
+ first. The same build deferring across several invocations means the hosted
1154
+ budget cannot fit that work: report it, and do not retry it. A `fence` line that
1155
+ repeats with an infrastructure failure at step `fence` means the provider
1156
+ cannot confirm the sandbox stopped: check the sandbox.
1138
1157
  Each hosted invocation logs `stages:` with time and items per stage, and `ab
1139
1158
  repository status` shows the latest as `last pass stages:`. `(share)` on a
1140
1159
  stage is normal under load. Settlement, janitor, hand-back, recovery, resume
@@ -1144,6 +1163,11 @@ started; priority-ordered admission and intake loops keep their order.
1144
1163
  deadline stopped. The same stage or part stopping at the deadline on
1145
1164
  invocation after invocation means one visit there outlasts the window: report
1146
1165
  it with those lines.
1166
+ The hosted store service logs one `autobuild.store-request` line per request
1167
+ naming its caller: dispatcher invocation, run and stage, build or harvest
1168
+ runner, or operator client (`cli`, `mcp`, `web`). For a store traffic burst or
1169
+ database pressure, report the callers and stages that dominate those lines;
1170
+ `caller: null` is an older client.
1147
1171
 
1148
1172
  Leaf restack and reconcile publication retry classified transient forge or transport
1149
1173
  failures six times after the initial attempt, waiting 30, 60, 120, 240, 300 and
@@ -4,8 +4,8 @@
4
4
  "build": "ab-hosted-service-build"
5
5
  },
6
6
  "dependencies": {
7
- "@defrex/autobuild-hosted-store-service": "1.15.0",
8
- "@defrex/autobuild": "1.15.0",
7
+ "@defrex/autobuild-hosted-store-service": "1.17.0",
8
+ "@defrex/autobuild": "1.17.0",
9
9
  "next": "16.1.6",
10
10
  "react": "19.2.4",
11
11
  "react-dom": "19.2.4"