@defrex/autobuild 1.10.0 → 1.11.1

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 (255) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +745 -69
  3. package/bin/ab-dispatch-generation.ts +3 -1
  4. package/docs/accounts.md +2 -1
  5. package/docs/answering-blocked-builds.md +20 -0
  6. package/docs/architecture.md +165 -29
  7. package/docs/build-store.md +10 -7
  8. package/docs/cli.md +33 -1
  9. package/docs/configuration-overview.md +4 -1
  10. package/docs/configuration.md +381 -29
  11. package/docs/dispatcher.md +64 -4
  12. package/docs/forges.md +7 -0
  13. package/docs/integration-tree.md +2 -2
  14. package/docs/operating.md +4 -2
  15. package/docs/operator-api.md +134 -6
  16. package/docs/operator-surfaces.md +85 -0
  17. package/docs/optimization-nodes.md +69 -11
  18. package/docs/plugin-authoring.md +37 -1
  19. package/docs/remote-store-protocol.md +94 -13
  20. package/docs/remote-ticket-protocol.md +40 -0
  21. package/docs/restacking.md +20 -4
  22. package/docs/setup.md +14 -2
  23. package/docs/ticket-dependencies.md +10 -3
  24. package/docs/ticket-sources.md +24 -2
  25. package/docs/tickets.md +7 -1
  26. package/docs/troubleshooting.md +8 -0
  27. package/docs/verification.md +4 -3
  28. package/docs/workspaces.md +3 -0
  29. package/package.json +9 -5
  30. package/packages/core/src/cli/accounts.ts +7 -2
  31. package/packages/core/src/cli/attention.ts +3 -1
  32. package/packages/core/src/cli/binary-direct.ts +2 -0
  33. package/packages/core/src/cli/binary-lifecycle.ts +2 -1
  34. package/packages/core/src/cli/build-control.ts +79 -1
  35. package/packages/core/src/cli/context.ts +4 -0
  36. package/packages/core/src/cli/dashboard/facts.ts +49 -53
  37. package/packages/core/src/cli/dashboard/header.ts +111 -0
  38. package/packages/core/src/cli/dashboard/model.ts +31 -39
  39. package/packages/core/src/cli/dashboard/objective-row.ts +46 -14
  40. package/packages/core/src/cli/dashboard/poll.ts +179 -76
  41. package/packages/core/src/cli/dashboard/render.ts +159 -230
  42. package/packages/core/src/cli/dashboard/row-text.ts +538 -0
  43. package/packages/core/src/cli/dashboard/timeline.ts +288 -0
  44. package/packages/core/src/cli/dashboard/vocabulary.ts +188 -0
  45. package/packages/core/src/cli/dispatch-args.ts +44 -1
  46. package/packages/core/src/cli/dispatch-frontend.ts +40 -40
  47. package/packages/core/src/cli/dispatch-launch-stop.ts +18 -0
  48. package/packages/core/src/cli/dispatch-launcher.ts +20 -7
  49. package/packages/core/src/cli/dispatch-web.ts +155 -0
  50. package/packages/core/src/cli/dispatch.ts +202 -38
  51. package/packages/core/src/cli/help.ts +87 -3
  52. package/packages/core/src/cli/init-validation.ts +3 -3
  53. package/packages/core/src/cli/main.ts +70 -6
  54. package/packages/core/src/cli/mcp.ts +35 -3
  55. package/packages/core/src/cli/objective.ts +1 -1
  56. package/packages/core/src/cli/operator-preference.ts +57 -0
  57. package/packages/core/src/cli/repo-lease.ts +2 -0
  58. package/packages/core/src/cli/repo-state.ts +56 -6
  59. package/packages/core/src/cli/repository-status.ts +105 -49
  60. package/packages/core/src/cli/status.ts +82 -1
  61. package/packages/core/src/cli/terminal-restore.ts +32 -7
  62. package/packages/core/src/cli/ticket.ts +98 -36
  63. package/packages/core/src/cli/wait.ts +14 -6
  64. package/packages/core/src/cli/watch.ts +20 -4
  65. package/packages/core/src/cli/web.ts +139 -0
  66. package/packages/core/src/config/live.ts +99 -14
  67. package/packages/core/src/config/load.ts +61 -20
  68. package/packages/core/src/config/local.ts +212 -0
  69. package/packages/core/src/config/pipeline-source.ts +2 -0
  70. package/packages/core/src/config/reference.ts +18 -0
  71. package/packages/core/src/config/schema.ts +45 -10
  72. package/packages/core/src/events/catalog.ts +4 -0
  73. package/packages/core/src/events/payloads.ts +97 -0
  74. package/packages/core/src/events/policy.ts +10 -0
  75. package/packages/core/src/events/repository.ts +46 -3
  76. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +381 -30
  77. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/017d8dd5bb6dd80b.json.gz +0 -0
  78. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/178e12f1759b7552.json.gz +0 -0
  79. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4932c70a2af97faf.json.gz +0 -0
  80. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/536085773daf6b58.json.gz +0 -0
  81. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6bd6275061aaffa5.json.gz +0 -0
  82. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/89625654b02e9ac1.json.gz +0 -0
  83. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a98af134be2da8a9.json.gz +0 -0
  84. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d5d5ccca80a893d8.json.gz +0 -0
  85. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f8155387eb5f375c.json.gz +0 -0
  86. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3c27f918b194e3b3.json +465 -0
  87. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/46196d8f0076496a.json +97 -0
  88. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/79f0e0f4ccd43ba2.json +455 -0
  89. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/859c09edac738823.json +1086 -0
  90. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a283c1f3462b1cc1.json +81 -0
  91. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a6e570fb126991ff.json +36 -0
  92. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a8acf22c968b6e3d.json +81 -0
  93. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/ba7b85895bf6698e.json +1153 -0
  94. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fc66408cde0b6b04.json +637 -0
  95. package/packages/core/src/kernel/build-roster.ts +230 -0
  96. package/packages/core/src/kernel/dispatch-capacity.ts +4 -2
  97. package/packages/core/src/kernel/dispatch-status.ts +139 -0
  98. package/packages/core/src/kernel/engine.ts +43 -5
  99. package/packages/core/src/kernel/execution-intervals.ts +61 -0
  100. package/packages/core/src/kernel/generators/optimization-log.ts +101 -0
  101. package/packages/core/src/kernel/generators/repository-journals.ts +13 -0
  102. package/packages/core/src/kernel/leaf-restack-base.ts +33 -7
  103. package/packages/core/src/kernel/leaf-restack-state.ts +82 -3
  104. package/packages/core/src/kernel/log-index.ts +19 -0
  105. package/packages/core/src/kernel/optimization-admission.ts +244 -3
  106. package/packages/core/src/kernel/optimization.ts +183 -4
  107. package/packages/core/src/kernel/phase-failures.ts +121 -0
  108. package/packages/core/src/kernel/published-branch-head.ts +60 -0
  109. package/packages/core/src/kernel/read-facts.ts +15 -13
  110. package/packages/core/src/kernel/reducer-registry.ts +27 -8
  111. package/packages/core/src/kernel/reducer-revisions.ts +27 -0
  112. package/packages/core/src/kernel/reducer.ts +63 -4
  113. package/packages/core/src/kernel/rollup.ts +61 -0
  114. package/packages/core/src/kernel/setup-streak.ts +38 -0
  115. package/packages/core/src/kernel/step-durations.ts +257 -0
  116. package/packages/core/src/kernel/target-observation.ts +6 -1
  117. package/packages/core/src/kernel/target-rewrite-recovery.ts +116 -0
  118. package/packages/core/src/kernel/verify-diff-base.ts +5 -0
  119. package/packages/core/src/kernel/verify-stages.ts +13 -3
  120. package/packages/core/src/ontology.ts +5 -0
  121. package/packages/core/src/operator/agent-context-serve.ts +631 -0
  122. package/packages/core/src/operator/annotations.ts +75 -5
  123. package/packages/core/src/operator/attention.ts +470 -0
  124. package/packages/core/src/operator/canonical-skills.ts +35 -0
  125. package/packages/core/src/operator/cli-equivalents.ts +270 -0
  126. package/packages/core/src/operator/context-prompts.ts +61 -0
  127. package/packages/core/src/operator/index.ts +49 -1
  128. package/packages/core/src/operator/landings.ts +28 -19
  129. package/packages/core/src/operator/optimization.ts +7 -0
  130. package/packages/core/src/operator/protocol.ts +3 -0
  131. package/packages/core/src/operator/query.ts +129 -74
  132. package/packages/core/src/operator/read-view.ts +5 -2
  133. package/packages/core/src/operator/registry.ts +406 -46
  134. package/packages/core/src/operator/requests.ts +20 -18
  135. package/packages/core/src/operator/sandbox-host.ts +107 -11
  136. package/packages/core/src/operator/sandbox-resolver.ts +253 -0
  137. package/packages/core/src/operator/sandbox.ts +778 -82
  138. package/packages/core/src/operator/ticket-asset-list.ts +77 -0
  139. package/packages/core/src/operator/ticket-assets.ts +167 -0
  140. package/packages/core/src/operator/tickets.ts +33 -2
  141. package/packages/core/src/plugin-sdk/index.ts +22 -0
  142. package/packages/core/src/plugins/manifest.ts +1 -1
  143. package/packages/core/src/ports/forge/fake.ts +92 -1
  144. package/packages/core/src/ports/forge/git-blob.ts +15 -0
  145. package/packages/core/src/ports/forge/github.ts +82 -0
  146. package/packages/core/src/ports/forge/local-git.ts +61 -1
  147. package/packages/core/src/ports/forge-failure.ts +24 -0
  148. package/packages/core/src/ports/runner/antigravity-test.fixture.ts +149 -0
  149. package/packages/core/src/ports/runner/claude-test.fixture.ts +71 -0
  150. package/packages/core/src/ports/runner/codex-test.fixture.ts +63 -0
  151. package/packages/core/src/ports/tickets/contract.ts +71 -0
  152. package/packages/core/src/ports/tickets/fake.ts +11 -0
  153. package/packages/core/src/ports/tickets/file.ts +18 -0
  154. package/packages/core/src/ports/tickets/github-fake.ts +136 -4
  155. package/packages/core/src/ports/tickets/github.ts +387 -30
  156. package/packages/core/src/ports/tickets/hosted-index.ts +10 -0
  157. package/packages/core/src/ports/tickets/linear.ts +130 -0
  158. package/packages/core/src/ports/tickets/priority.ts +9 -0
  159. package/packages/core/src/ports/tickets/remote-protocol.ts +34 -0
  160. package/packages/core/src/ports/tickets/remote.ts +70 -6
  161. package/packages/core/src/ports/tickets/search.ts +139 -0
  162. package/packages/core/src/ports/types.ts +104 -2
  163. package/packages/core/src/ports/workspace/builtin-capabilities.ts +9 -0
  164. package/packages/core/src/ports/workspace/create.ts +15 -1
  165. package/packages/core/src/ports/workspace/fake.ts +340 -12
  166. package/packages/core/src/ports/workspace/git-worktree.ts +833 -42
  167. package/packages/core/src/ports/workspace/operator-sandbox.ts +129 -12
  168. package/packages/core/src/ports/workspace/process-group.ts +48 -0
  169. package/packages/core/src/ports/workspace/vercel-sandbox.ts +1260 -123
  170. package/packages/core/src/processes/agent-context-assemble.ts +576 -0
  171. package/packages/core/src/processes/agent-context.ts +469 -0
  172. package/packages/core/src/processes/build-runner.ts +387 -236
  173. package/packages/core/src/processes/dispatcher.ts +211 -55
  174. package/packages/core/src/processes/execution-no-progress.ts +4 -0
  175. package/packages/core/src/processes/optimization-activity.ts +120 -0
  176. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  177. package/packages/core/src/processes/repo-view.ts +78 -2
  178. package/packages/core/src/processes/sandbox-state.ts +53 -6
  179. package/packages/core/src/processes/tick-publication.ts +2 -0
  180. package/packages/core/src/processes/workspace-preparation.ts +76 -0
  181. package/packages/core/src/scenarios/harness.ts +0 -5
  182. package/packages/core/src/store/account-redaction.ts +1 -0
  183. package/packages/core/src/store/adapter.ts +52 -1
  184. package/packages/core/src/store/agent-context.ts +432 -0
  185. package/packages/core/src/store/build-feed.ts +291 -0
  186. package/packages/core/src/store/build-scope.ts +19 -1
  187. package/packages/core/src/store/contract.ts +911 -14
  188. package/packages/core/src/store/digest.ts +19 -6
  189. package/packages/core/src/store/histogram.ts +113 -0
  190. package/packages/core/src/store/local/schema.ts +62 -0
  191. package/packages/core/src/store/local/store.ts +628 -22
  192. package/packages/core/src/store/local/ticket-asset-heads.ts +23 -0
  193. package/packages/core/src/store/memory.ts +461 -69
  194. package/packages/core/src/store/open-builds.ts +19 -0
  195. package/packages/core/src/store/phase-session.ts +32 -4
  196. package/packages/core/src/store/reduced-reads.ts +14 -4
  197. package/packages/core/src/store/reducer-value-shapes.json +7027 -5751
  198. package/packages/core/src/store/reducer-values.ts +6 -1
  199. package/packages/core/src/store/remote/client.ts +208 -2
  200. package/packages/core/src/store/remote/compatibility.ts +1 -1
  201. package/packages/core/src/store/remote/index.ts +33 -0
  202. package/packages/core/src/store/remote/protocol.ts +69 -0
  203. package/packages/core/src/store/remote/released-clients.json +22 -0
  204. package/packages/core/src/store/remote/released-reducer-values/1.11.0.json +35680 -0
  205. package/packages/core/src/store/remote/released-reducer-values/1.11.1.json +35718 -0
  206. package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
  207. package/packages/core/src/store/retention.ts +23 -1
  208. package/packages/core/src/store/rollups.ts +337 -0
  209. package/packages/core/src/store/session-handle.ts +20 -2
  210. package/packages/core/src/store/snapshots.ts +10 -0
  211. package/packages/core/src/store/types.ts +108 -9
  212. package/packages/core/src/testing/dispatch-journals.ts +117 -0
  213. package/packages/core/src/testing/dispatch-read-budget.ts +1092 -2
  214. package/packages/core/src/testing/git-config-isolation.ts +7 -5
  215. package/packages/core/src/testing/index.ts +27 -0
  216. package/packages/core/src/testing/memory-operator-sandbox.ts +346 -0
  217. package/packages/core/src/testing/reduced-read-budget.ts +1873 -98
  218. package/packages/core/src/web/analytics-source.ts +303 -0
  219. package/packages/core/src/web/assets/Atkinson-OFL.txt +93 -0
  220. package/packages/core/src/web/assets/AtkinsonHyperlegibleNext.latin.woff2 +0 -0
  221. package/packages/core/src/web/assets/JetBrains-OFL.txt +93 -0
  222. package/packages/core/src/web/assets/JetBrainsMono.latin.woff2 +0 -0
  223. package/packages/core/src/web/assets/app.css +1 -0
  224. package/packages/core/src/web/assets/app.js +9 -0
  225. package/packages/core/src/web/assets/manifest.json +31 -0
  226. package/packages/core/src/web/assets/theme.js +1 -0
  227. package/packages/core/src/web/bounded.ts +31 -0
  228. package/packages/core/src/web/http.ts +315 -0
  229. package/packages/core/src/web/hub.ts +160 -0
  230. package/packages/core/src/web/options.ts +38 -0
  231. package/packages/core/src/web/overview-source.ts +322 -0
  232. package/packages/core/src/web/page.ts +56 -0
  233. package/packages/core/src/web/protocol.ts +151 -0
  234. package/packages/core/src/web/read-only.ts +23 -0
  235. package/packages/core/src/web/repository-source.ts +39 -0
  236. package/packages/core/src/web/server.ts +97 -0
  237. package/skills/code-review/SKILL.md +10 -2
  238. package/skills/guide/SKILL.md +376 -54
  239. package/skills/guide/references/accounts.md +2 -1
  240. package/skills/guide/references/integration-tree.md +2 -2
  241. package/skills/guide/references/operator-api.md +134 -6
  242. package/skills/guide/references/optimization-nodes.md +69 -11
  243. package/skills/guide/references/plugin-authoring.md +37 -1
  244. package/skills/guide/references/remote-store-protocol.md +94 -13
  245. package/skills/guide/references/remote-ticket-protocol.md +40 -0
  246. package/skills/guide/references/restacking.md +20 -4
  247. package/skills/guide/references/setup.md +14 -2
  248. package/skills/guide/references/ticket-dependencies.md +10 -3
  249. package/skills/implement/SKILL.md +23 -4
  250. package/skills/operate/SKILL.md +134 -32
  251. package/skills/plan/SKILL.md +10 -4
  252. package/skills/plan-review/SKILL.md +9 -2
  253. package/skills/spec/SKILL.md +34 -8
  254. package/skills/tickets/SKILL.md +51 -5
  255. package/templates/hosted-service/package.json +2 -2
package/SPEC.md CHANGED
@@ -100,6 +100,7 @@ Interfaces to the world, each with swappable adapters:
100
100
  | `BuildStore` | per-build streams plus repository journals: events, artifacts, transcripts, leases (see §7) | local; remote HTTP |
101
101
 
102
102
  Ticket sources may optionally provide native `listPage(criteria, page)` windows with a matching total. Paged operator reads use it when present, otherwise slice the exhaustive listing; unpaged and dispatcher reads remain exhaustive.
103
+ Ticket sources may optionally provide `search(query)`: title/body term matching with state/label filters, returning compact hits and an opaque cursor. Callers refuse sources without it and never fall back to listing.
103
104
  Integration-tree sources may optionally provide `listTargeting(nodeId)`, every ticket targeting one node in every state, equal to the exhaustive listing filtered by target. Integration observation uses it when present, otherwise `listAll`.
104
105
 
105
106
  #### 3.2.1 In-process adapter plugins
@@ -131,8 +132,8 @@ Relative, absolute, and `file:` specifiers resolve from the repository root
131
132
  whose config is being read; in a scoped build CLI process, that is the
132
133
  immutable build worktree. Bare package specifiers and package export maps
133
134
  resolve first from the consuming repository's main checkout, so they use that
134
- repository's installed dependencies and remain available when a local store
135
- places linked worktrees outside the checkout's package ancestry; a package the
135
+ repository's installed dependencies and remain available although linked
136
+ worktrees sit outside the checkout's package ancestry; a package the
136
137
  repository lacks then resolves from the Autobuild installation the CLI runs
137
138
  from as a fallback. Install extensions as repository development dependencies
138
139
  with `bun add -d --exact @defrex/autobuild-<extension>`. A
@@ -236,7 +237,11 @@ resident launcher, execution configuration/plugins, account admission and kernel
236
237
  wiring. It never takes or renews a repository lease, starts a child, writes
237
238
  dispatch lifecycle facts, or runs intake scans, janitor, sweep, harvest or builds.
238
239
  Canonical repository facts supply the observed dispatcher's status and effective
239
- configuration, independent of the viewer's operator correlation identity. With no
240
+ configuration, independent of the viewer's operator correlation identity. Every
241
+ frontend's queue count (the terminal dashboard in both modes, the web repository
242
+ header and overview, and the operator dashboard) is the queued depth of the latest
243
+ `dispatcher.ticket-scan-completed` in the repository's reduced facts, whichever run
244
+ recorded it, and 0 before any scan. With no
240
245
  configuration the display waits, polling bounded canonical state. Fresh viewers
241
246
  reuse saved server reductions; missing presentation caches never trigger event
242
247
  history reconstruction. Idle polls read zero event rows. Its one ticket-source
@@ -295,6 +300,8 @@ The versioned v1 launch contract consists of argv, a consumed one-shot
295
300
  `AB_DISPATCH_GENERATION` marker, graceful signals and exit reasons `stopped`,
296
301
  `handoff`, `failed`. Public invocations discard inherited markers. No private
297
302
  operational channel exists; work outcomes still come only from durable state.
303
+ For `--web` without a fixed port, the launcher rewrites that argv once to pin a
304
+ reserved `--port`; it still opens no store.
298
305
  The runtime-owned `--read-upgrade` reader supports an optional independently
299
306
  versioned conditional environment exchange, preserving full v1 answers for old
300
307
  peers. The launcher retains only its current successful answer and pre-read
@@ -874,8 +881,11 @@ to a deterministic title-derived name, so a failed proposal never prevents
874
881
  build creation. The dispatcher then deduplicates the base with `-2`, `-3`, …
875
882
  suffixes against the store and, when the forge can answer, against `ab/` or
876
883
  `ab-node/` build branches already on the remote, so a build never takes a
877
- branch another store owns. That check is not best effort: if a remote branch
878
- lookup fails, or the base and its `-2` … `-100` candidates are all taken, the
884
+ branch another store owns. When the workspace provider creates branches in
885
+ the dispatcher's local checkout, a candidate whose branch already exists
886
+ there locally is skipped the same way, so a stale local branch left by an
887
+ earlier build never becomes a new build's branch. That check is not best
888
+ effort: if a remote or local branch lookup fails, or the base and its `-2` … `-100` candidates are all taken, the
879
889
  claim fails at the naming stage, no build is created, and the ticket returns
880
890
  to configured Ready under the dispatcher's preparation recovery contract
881
891
  (§3.3). The slug and its `ab/<slug>` (or `ab-node/<slug>` for a node) branch
@@ -1052,7 +1062,9 @@ sandbox tools, credential isolation, archive cleanup and dispatcher idle
1052
1062
  settlement. New config rejects the removed `model`, `invocationBudgetSeconds`,
1053
1063
  `approvals` and repository-default `wake` keys. Immutable historical effective
1054
1064
  config artifacts discard only those obsolete keys during validation; stored
1055
- bytes are unchanged and other unknown or malformed settings still fail.
1065
+ bytes are unchanged and other unknown or malformed settings still fail. An
1066
+ unset `enabled` resolves per host: enabled when a hosted deployment serves the
1067
+ project, disabled for local `ab mcp`, dispatch and init; an explicit value wins.
1056
1068
 
1057
1069
  #### 7.1.3 Ticket assets
1058
1070
 
@@ -1100,14 +1112,19 @@ validation alone, so the client enforces the advertised limit before uploading.
1100
1112
  ### 7.2 Interface and adapters
1101
1113
 
1102
1114
  Deliberately narrow: build runners need `append(event)`, `putArtifact`,
1103
- `getArtifact`, `getEvents(since)`; operator UIs add `listBuilds`, `subscribe`.
1115
+ `getArtifact`, `getEvents(since)`; operator UIs add `listBuilds`, `listOpenBuilds`,
1116
+ `subscribe`.
1104
1117
  A build stream also exposes `appendIfCurrent(expectedSeq, event)`: one atomic
1105
1118
  compare-and-append that returns no event when the stream has advanced. It is a
1106
1119
  narrow coordination primitive for deterministic event-log deduplication under
1107
1120
  concurrent processors; the event stream remains authoritative, with no
1108
1121
  snapshot or side ledger. Sequence 0 names an empty stream, candidates receive
1109
1122
  ordinary event validation, unknown builds reject, and a comparison miss leaves
1110
- the log and build timestamps untouched.
1123
+ the log and build timestamps untouched. The repository journal exposes the
1124
+ same primitive as `appendRepoIfCurrent(repo, expectedSeq, event)`, and a
1125
+ session log as `appendSessionEventIfCurrent`; the operator sandbox service
1126
+ records a background attempt's outcome through the repository form so that
1127
+ exactly one process records it.
1111
1128
  Node branch writers use separate `claimNodeWriter`, `renewNodeWriter`, and
1112
1129
  `releaseNodeWriter` operations. Claim permits an absent, expired, or same-holder
1113
1130
  lease; renewal requires the same unexpired holder, and release is holder-checked.
@@ -1135,15 +1152,56 @@ through `GET /builds/:slug/ticket-assets`. `createBuild` optionally takes the
1135
1152
  build's initial `build.created` event and appends it as seq 1 in the same atomic
1136
1153
  step as the record on every adapter. This guard applies identically to every adapter; remote tokens
1137
1154
  carry the same authority over the wire as defense in depth rather than creating
1138
- it. Two implementations of one contract (`packages/core/src/store/contract.ts` is the shared
1155
+ it.
1156
+
1157
+ Repository change positions are ordered, so the contract answers two
1158
+ cross-build questions at a cost proportional to the answer.
1159
+ `listBuildsChangedSince(repo, position)` returns the builds whose latest change
1160
+ position is greater than `position`, ascending by position, each once at its
1161
+ latest position, together with the repository head read in the same snapshot.
1162
+ It reads no event rows, and with nothing changed it does constant work.
1163
+ `listBuildsPage(repo, { cursor?, limit?, kind?, outcome?, activeSince? })`
1164
+ returns one page of builds newest first by creation (slug descending breaks
1165
+ ties), with records identical to `listBuildsForRepo` and an opaque,
1166
+ adapter-issued `next` cursor that continues only a request with the same
1167
+ filters. The optional filters are `kind` (`leaf` or `node`), `outcome: merged`
1168
+ and `activeSince` (an ISO instant with a zone). Each is answered from per-build
1169
+ listing facts written in the same transaction as the write that changes them,
1170
+ never from events or reduced values: `node` from `build.created`'s kind (any
1171
+ other kind is a leaf), merged from the latest `build.completed` and cleared by
1172
+ `build.reopened`, and a mirror of the build's `updatedAt`, which every write
1173
+ bumps. A `kind` or `outcome` page is the filtered subsequence of the creation
1174
+ order. An `activeSince` page holds builds whose `updatedAt` is at or after it,
1175
+ ordered by `updatedAt` then slug, both descending, with an `(updatedAt, slug)`
1176
+ cursor. A span never ends later than its build's latest event, so the matches
1177
+ are a superset of builds whose span overlaps the window. Because `updatedAt`
1178
+ moves, a build written between two page requests can appear twice in one
1179
+ traversal or be skipped once; consumers dedupe by slug. Every filter
1180
+ combination is one bounded range scan: a page reads at most `limit + 1`
1181
+ listing entries whatever the build count or the number of matches. Limits run
1182
+ from 1 to 100 (default 25). Malformed positions, cursors, filters and limits
1183
+ reject, as does a cursor issued for the other order. Unknown repositories
1184
+ answer empty without creating state. A remote server that cannot filter
1185
+ fails a filtered request with `BuildFeedUnsupportedError`; the client never
1186
+ filters an unfiltered page itself. Scoped build and session handles reject both
1187
+ methods. The feed is what derived reducers advance by (§7.7). Two implementations of one contract (`packages/core/src/store/contract.ts` is the shared
1139
1188
  conformance suite):
1140
1189
 
1141
1190
  1. **Local** — one self-contained state tree at `<main-repo>/.autobuild/` by
1142
- default: database, content-addressed blobs, Git worktrees, and the file
1143
- ticket source's default directory. The main checkout is derived from Git's
1191
+ default: database, content-addressed blobs, and the file ticket source's
1192
+ default directory. Build Git worktrees go to a destination outside the
1193
+ checkout's package ancestry: the state tree's own `worktrees/` when it
1194
+ resolves outside the checkout, else a per-checkout root under the host state
1195
+ home (`$XDG_STATE_HOME`, default `~/.local/state`). The destination is
1196
+ validated on real paths before each fresh provision: it must not resolve
1197
+ inside the checkout, and no directory from it up to `/` may hold
1198
+ `node_modules`. When none qualifies, fresh provisioning fails explicitly per
1199
+ build and dispatch shows a startup notice; recorded workspaces still resume
1200
+ and release, and registrations at the legacy in-checkout `worktrees/` are
1201
+ adopted in place. The main checkout is derived from Git's
1144
1202
  repository/worktree topology, so a command run inside a linked worktree
1145
- resolves the same state. There is no home-directory fallback or
1146
- machine-global state. Store selection is uniform: explicit `--store` >
1203
+ resolves the same state. Store state has no home-directory fallback or
1204
+ machine-global location. Store selection is uniform: explicit `--store` >
1147
1205
  nonempty `AB_STORE` > repository default. When a phase or Harvest CLI
1148
1206
  process reopens this store, a handle wrapper derives exact build-or-repository
1149
1207
  authority and agent-event session attribution from its validated ambient
@@ -1191,12 +1249,11 @@ headers, or available backend.
1191
1249
  `subscribe` is specced in the interface; the current implementation is polling
1192
1250
  `getEvents(since)`. True push comes later.
1193
1251
 
1194
- Operator UIs additionally have a repository-scoped batch read,
1195
- `getRepoBuildDigests(repo)`: the projection of every build's log onto its
1252
+ The dispatcher and harvest runner additionally have a repository-scoped batch
1253
+ read, `getRepoBuildDigests(repo)`: the projection of every build's log onto its
1196
1254
  terminal fact, its `observation.recorded` occurrences with their event
1197
1255
  timestamps, and the ts of its latest `pr.merged`, derived from the event log on
1198
- each call. It lets a dashboard snapshot gate rows without reading the full
1199
- history of finished builds (§16.1), and it backs the harvest-launch pressure gate (dispatcher and harvest runner alike): launch
1256
+ each call. It backs the harvest-launch pressure gate (dispatcher and harvest runner alike): launch
1200
1257
  decisions evaluate from digests and the repository journal alone, so
1201
1258
  gate-evaluation cost is flat in accumulated build history, with the full
1202
1259
  per-build scan paid only when a gate actually trips and a scan packet is built.
@@ -1206,6 +1263,23 @@ digests and reads full facts only for builds that name that node. Optimization
1206
1263
  nodes add an `optimization` signal from which the dispatcher's proposer stage
1207
1264
  selects work (§13.1.1).
1208
1265
 
1266
+ Operator reads of active work use `listOpenBuilds(repo)` instead: the records
1267
+ and persisted digests of the repository's open builds, ordered by creation
1268
+ time and slug. A build is open while its latest terminal fact is not
1269
+ `build.completed`, so the set holds queued, running, paused, blocked and
1270
+ settled-awaiting-merge builds, plus aborted builds whose cleanup saga has not
1271
+ finished. Every adapter maintains the set in the transaction that inserts a
1272
+ build or appends its `build.completed`, `build.aborted` or `build.reopened`;
1273
+ the SQL adapters use triggers, so every append path and every older binary
1274
+ writing the same database keeps it exact. A database that predates the set is
1275
+ backfilled once, when its migration creates it; no read path backfills.
1276
+ `builds.list` (active and queued), `merges.list`, the dashboard snapshot
1277
+ (§16.1) and `repository.status` capacity read it, so their cost follows open
1278
+ builds and never settled history. `builds.list --all` is an explicit history
1279
+ read and still lists every build. A remote server without the operation
1280
+ answers a typed capability failure, and the client never falls back to
1281
+ listing every build or the digest batch.
1282
+
1209
1283
  Stateless repository-level readers also have a bounded journal read,
1210
1284
  `getRepoStateEvents(repo)` (AUT-489): every durable, slow-growing event type
1211
1285
  (all harvest facts, operator-sandbox facts, cross-generation handoff correlation
@@ -1336,6 +1410,17 @@ The base-selection invariants make this safe with Git:
1336
1410
  after checkout; a provider that reuses a completed environment from a
1337
1411
  failed attempt records that environment's checkout, never a target head
1338
1412
  read separately. A target that moved since is a restack concern.
1413
+ - **A first provision never adopts a branch it did not create.** A leaf
1414
+ build with no prior provision cuts from the base even when a branch of its
1415
+ name already exists. A node is exempt: the kernel opens its branch before
1416
+ any provision, and that branch holds the node's merged children. Creation is proven only by the provider's own receipt,
1417
+ written atomically with the build's branch write once nothing foreign
1418
+ holds the branch; ancestry is never evidence. A local provider sets the
1419
+ old tip aside under `refs/autobuild/displaced/<branch>/<sha>` and cuts
1420
+ from the base. A worktree that has the foreign branch checked out is
1421
+ detached in place, and is moved under `.displaced/` when it occupies the
1422
+ build's own path; its files are kept. Resume after a prior provision is
1423
+ unchanged.
1339
1424
  - **Re-provisioning resumes; eligible restacks rewrite.** Provisioning alone
1340
1425
  resumes the published branch. The kernel collapses and restacks at verify
1341
1426
  entry, at a ticket-wait resume, and after target moves while awaiting merge. The first
@@ -1384,8 +1469,11 @@ The base-selection invariants make this safe with Git:
1384
1469
  Sampling never provisions a workspace, renders Git reads, or gates restacking.
1385
1470
  - **Observation never mutates a running workspace.** `target.moved` records an
1386
1471
  accepted remote head, even during a session. Non-descendant observations without
1387
- indexed kernel publication lineage record `target.rewritten` and attention
1388
- without changing the accepted target. Transactions freeze their target;
1472
+ indexed kernel publication lineage record `target.rewritten` without changing
1473
+ the accepted target. A node waits with attention once per episode; a leaf's
1474
+ next runner reprovisions it from the target when it has no work of its own,
1475
+ else raises one `policy/target-rewritten` escalation that `--accept-target`
1476
+ or abort resolves (see "Forge failure recovery"). Transactions freeze their target;
1389
1477
  later observations coalesce into one follow-on transaction for the newest
1390
1478
  snapshot at the next eligible point. Session and execution settlement fence
1391
1479
  rewrites, and trusted publication waits for remote guest teardown.
@@ -1565,6 +1653,138 @@ Explicit harvest history uses reverse indexed filtered pages rather than a
1565
1653
  journal replay. See `docs/remote-store-protocol.md` for the wire contract,
1566
1654
  initial migration bootstrap and generation-retirement recovery.
1567
1655
 
1656
+ ### 7.7 Derived reducers
1657
+
1658
+ A derived reducer answers a question across builds, such as P90 plan time over
1659
+ the last week, without reading every build's history on every request. It has
1660
+ three parts:
1661
+
1662
+ 1. **A build reducer**: a registered build-scope named value, saved per build
1663
+ and advanced by delta like any other.
1664
+ 2. **A contribution function**: pure, from that build's slug and finished
1665
+ value to its share of the rollup.
1666
+ 3. **A rollup**: a repository accumulator with `add` and `subtract`. Its value
1667
+ is the sum of the contributions of every build it has absorbed.
1668
+
1669
+ **Contributions must be invertible.** When a build changes again (a new closed
1670
+ segment, a reopen), the rollup subtracts the contribution it absorbed from that
1671
+ build last time and adds the new one. Counts, sums and histograms invert;
1672
+ minimum and maximum are expressed through histograms.
1673
+
1674
+ **Scope and arguments.** A rollup is requested through `getReducerValue` with
1675
+ the scope `{kind: 'rollup', repo}`. Rollups live in `ROLLUPS` beside
1676
+ `REDUCERS` in the registry and version through the revision ledger; a rollup's
1677
+ version adds its build reducer's, so a build-reducer revision changes the
1678
+ rollup's key too. Key arguments (`args`) are parsed with their defaults before
1679
+ hashing, so each distinct combination is its own rollup with its own
1680
+ accumulator. Read-time arguments (`read`) shape only the finished value and
1681
+ never create a key; named reducers reject a request that carries them.
1682
+
1683
+ **Advance.** The saved rollup holds its accumulator and the repository change
1684
+ position it reflects.
1685
+
1686
+ - A read whose saved position equals the repository head, and whose
1687
+ accumulator holds nothing retention drops, returns the saved value: two
1688
+ constant reads, no event rows and no feed query.
1689
+ - Otherwise the reader asks `listBuildsChangedSince` for builds changed since
1690
+ the saved position, reads each changed build's saved build-reducer value,
1691
+ reads that build's **absorbed contribution** for this rollup key, subtracts
1692
+ old and adds new. It commits the accumulator, the feed's snapshot head and
1693
+ every changed absorbed contribution together.
1694
+ - An answer with no changed builds but a moved head (repository events and
1695
+ creations move the position too) saves only the position.
1696
+ - A saved value holding an expired day is pruned and saved at the same
1697
+ position, with no feed query and no event read.
1698
+
1699
+ Every advance is serialized per rollup key, across store instances and
1700
+ processes, from the re-read of the saved row through the commit, and the
1701
+ commit is conditional on the row the advance read. Two readers never count a
1702
+ build twice; a reader whose commit loses returns the winner's value. Memory
1703
+ serializes with a per-key mutex, SQLite with a lease row every instance
1704
+ contends on (expiry by the store clock, renewal after every 16 build reads,
1705
+ commit conditioned on still holding it), and Postgres with one transaction
1706
+ holding a transaction-scoped advisory lock on which every query of the advance
1707
+ runs.
1708
+
1709
+ **First computation.** With no valid saved row (a new key, a version change, a
1710
+ corrupt row, or a saved position above the head, which means the repository was
1711
+ reset) the rollup starts empty at position `0`, so the feed lists every build
1712
+ once; existing absorbed contributions for the key are overwritten, never
1713
+ subtracted. A build whose build-reducer value is already saved costs one value
1714
+ read; otherwise its log is reduced once and saved. That is the once-per-key
1715
+ reduction: serialized, saved durably, and never repeated.
1716
+
1717
+ **Storage.** Rollup rows and absorbed contributions sit in the private
1718
+ `value.` namespace of the reduced-value storage: the rollup row under the
1719
+ rollup scope at `value.rollup.v1.<digest>`, each absorbed contribution under its
1720
+ build's scope at `value.absorbed.v1.<digest>`. The public snapshot API refuses
1721
+ both. An unknown repository answers the empty value and creates nothing.
1722
+
1723
+ **Remote.** The server's rollup value is canonical. A client sends one
1724
+ `POST /repos/:repo/rollup-values` and never rebuilds the value from events, the
1725
+ feed or build values. Rollups have no released projection catalog, so a client
1726
+ requires the server's version to equal its own: a different version, an absent
1727
+ route, an older server's `400 validation` refusal of a rollup name it does not
1728
+ know, or a value outside the rollup's schema fails with
1729
+ `ReducerValueIncompatibilityError`. A rollup revision therefore makes older
1730
+ clients fail with that typed error until they upgrade.
1731
+
1732
+ #### `stepDurations`
1733
+
1734
+ The first rollup folds every build's `buildTimeline` (§15.5) into duration
1735
+ histograms per step and UTC day.
1736
+
1737
+ - **Contribution:** each closed segment adds its `durationMs` to the histogram
1738
+ for its step on the UTC day it ended. Open and abandoned segments add
1739
+ nothing. A merged segment adds its occurrence count at the bucket of its mean
1740
+ occurrence, so count and total stay exact.
1741
+ - **Histogram:** bucket `i` covers `[1000·1.1^i, 1000·1.1^(i+1))` ms, 140
1742
+ buckets from 1 second to about 7 days; shorter and longer durations clamp to
1743
+ the end buckets. Buckets are sparse and each keeps a count and an exact sum.
1744
+ Percentiles use nearest rank and the geometric midpoint of the bucket, within
1745
+ 5% of exact; the clamping end buckets answer their mean.
1746
+ - **Key arguments:** `outcome` is `merged` (default; the latest
1747
+ `build.completed` outcome is `merged`) or `all`. `kind` is `leaf` (default;
1748
+ any build whose kind is not `node`), `node` or `all`.
1749
+ - **Read-time argument:** `window` is `24h`, `7d` (default), `30d` or `all`. A
1750
+ window selects every UTC day it overlaps.
1751
+ - **Retention:** days before the UTC day 400 days ago are dropped, at
1752
+ contribution time and from the accumulator; a later reopen subtracts nothing
1753
+ for a dropped day. The saved row is bounded by 400 days × steps × 140
1754
+ buckets, a few megabytes for a busy repository, read only on explicit
1755
+ requests.
1756
+ - **Answer:** `{position, window, steps: [{step, count, meanMs, p50Ms, p90Ms,
1757
+ p99Ms, totalMs}]}`, with `cursor: 0`. Steps run in pipeline order (phases,
1758
+ `verify:*` by name, finalize, reconcile, then waits) and zero-count steps are
1759
+ omitted. Its size grows with steps, not with retained history.
1760
+
1761
+ #### `buildRoster`
1762
+
1763
+ The roster folds every build's `buildRosterEntry` (§15.5) into the
1764
+ repository's live builds and its most recently finished ones.
1765
+
1766
+ - **Contribution:** a finished build (its build-reducer status is `done` or
1767
+ `aborted`) contributes `{slug, kind, outcome, completedAt}`, where `outcome`
1768
+ is `merged`, `closed` (any other `build.completed` outcome) or `aborted`, and
1769
+ `completedAt` is the latest terminal event's timestamp. Any other build
1770
+ contributes `{slug, kind, createdAt}`. The terminal rule is the build
1771
+ reducer's: `build.completed` and `build.aborted` overwrite each other in log
1772
+ order, latest wins, and nothing else clears them.
1773
+ - **History:** the accumulator keeps every live entry and the newest 50
1774
+ finished entries, newest completion first (slug breaks ties). A completion
1775
+ beyond the cap prunes the oldest. A build that leaves the history, by
1776
+ becoming live again or by an older completion being pruned, is not replaced:
1777
+ the history never back-fills from older builds, so after many such moves
1778
+ without new completions the answer can show fewer than 10 finished builds.
1779
+ - **Arguments:** none, so each repository has one roster key.
1780
+ - **Answer:** `{position, live: [{slug, kind, createdAt?}], finished: [{slug,
1781
+ kind, outcome, completedAt}]}`, with `cursor: 0`. `live` lists every live
1782
+ build, oldest `createdAt` first (missing first), then by slug; `finished`
1783
+ holds up to 10 of the retained entries, newest first.
1784
+ - **Cost:** a read with nothing changed is the two constant reads, and the
1785
+ saved row is O(live builds + 50) bytes however many builds the repository
1786
+ has ever had.
1787
+
1568
1788
  ## 8. The `ab` CLI
1569
1789
 
1570
1790
  The **only** channel between agents and the store — and the enforcement
@@ -2026,14 +2246,15 @@ implementer: ab context (findings.json now materialized) → …
2026
2246
  ### 8.8 Outer-loop namespace
2027
2247
 
2028
2248
  Human/pre-build ticket grooming uses one configured-source namespace
2029
- (`ab ticket create|update|block|unblock|list|show|move`, plus the ticket-asset
2249
+ (`ab ticket create|update|block|unblock|list|search|show|move`, plus the ticket-asset
2030
2250
  forms below). Migration adds `ab ticket export <dir>` and
2031
2251
  `ab ticket import <dir> [--states <state,…>]`,
2032
2252
  plus `ab ticket migration record <dir>`
2033
2253
  (see [Ticket source migration](#ticket-source-migration)). These commands are
2034
2254
  sessionless, source-agnostic, and never available as a mid-build spec
2035
2255
  mutation path. The CRUD subcommands accept `--json` and then writes exactly one
2036
- bare value: `list` emits `Ticket[]`; every other form emits the complete
2256
+ bare value: `list` emits `Ticket[]`; `search` emits
2257
+ `{tickets, cursor?, diagnostics}`; every other form emits the complete
2037
2258
  created, read, or post-mutation `Ticket`. Human-readable confirmations are not
2038
2259
  a data format and callers must not parse ids from them.
2039
2260
 
@@ -2069,6 +2290,10 @@ selected BuildStore:
2069
2290
  assets; revisions a build has pinned stay retrievable.
2070
2291
  - `ab ticket show <id>` lists the current assets (kind/name, revision, size);
2071
2292
  with `--json` the `Ticket` is extended with an `assets` array.
2293
+ - The agent tool registry (§8.9) offers `tickets.asset.attach`,
2294
+ `tickets.asset.get` and `tickets.asset.remove` with the same rules, limits
2295
+ and notes, carrying bytes as base64, and `tickets.get` carries the same
2296
+ `assets` array.
2072
2297
 
2073
2298
  Observation harvest uses a separate typed, repository-scoped namespace
2074
2299
  (`ab harvest context|submit|verdict|status`), mirroring the build session
@@ -2087,7 +2312,11 @@ the runner records it. Inside a judge session `ab` is the judge-only launcher,
2087
2312
  which runs these two commands and refuses every other.
2088
2313
 
2089
2314
  `ab repository status [--json] [--store <ref>]` is the sessionless read-only
2090
- projection of the repository journal's dispatcher controls: ticket intake, the
2315
+ projection of the repository journal's dispatcher controls. Its shared
2316
+ `dispatcherRunning` boolean is true for a holder, expired holder or unfinished
2317
+ handoff naming a draining predecessor, even with an empty drain map. It uses
2318
+ existing projections and adds no reads; only durable retirement clears evidence.
2319
+ The controls include: ticket intake, the
2091
2320
  repository-wide pause, and the harvest gate, plus pending and recently settled
2092
2321
  single-ticket start requests with their priority (`ticketStarts`, present when either is nonempty). It uses the same
2093
2322
  dispatch-settings reducer as dispatcher decisions and the dashboard. An absent
@@ -2158,6 +2387,47 @@ be narrowed to the ambient build — and `--repo` constrains every call to one
2158
2387
  repository. Mutating tools attribute their writes to the sessionless operator
2159
2388
  identity, exactly as the other operator commands do.
2160
2389
 
2390
+ The hosted `/mcp` binding advertises exactly the table the hosted operator
2391
+ server dispatches: a filtered tool is neither advertised nor served. Its
2392
+ repo-gated `sandbox.*` tools are listed when the deployment can host operator
2393
+ sandboxes, and each call is refused with a typed reason when the repository's
2394
+ latest deposited effective config does not enable them.
2395
+
2396
+ The registry's `repository.attention` digest is a connected agent's first read
2397
+ of each operator round. It composes the operator services the dedicated tools
2398
+ call — the open escalations `builds.get` reports, the `merges.list` consent
2399
+ queue, the attention page of `repository.events` and the `repository.status`
2400
+ projection — adds the builds waiting on operator action (paused, stalled,
2401
+ failing node verification or forge CI), and names a resolving registry tool per
2402
+ item. It takes the `repository.events` cursor, never waits, reads only open
2403
+ builds, and reads zero event rows when nothing changed since the cursor.
2404
+
2405
+ Each registered project also has a per-repository binding at
2406
+ `<resource>/<host><path>`, derived from its identity. It serves the same table
2407
+ for that one repository: its tool schemas omit `repo`, it offers no
2408
+ `repositories.list`, and it lists `sandbox.*` only when that repository's
2409
+ latest deposited effective config enables `[orchestrator]`, with one bounded
2410
+ latest-artifact read per listing. Its tokens are bound to their RFC 8707
2411
+ resource: it accepts only tokens issued for it or for `/mcp`.
2412
+
2413
+ Connected agents discover how to work from the captured agent context (§12)
2414
+ through the registry's `context.list` and `context.read` tools, so every
2415
+ binding serves it. The index names the skills with descriptions, the agent
2416
+ instructions with scopes, and which to load before operating and before ticket
2417
+ work. A read returns one file, found by path or by a relative link from another
2418
+ file. Each skill file that mentions `ab` commands starts with a generated
2419
+ preamble that maps every command to the tool that performs it, or marks it as
2420
+ build-session only, runnable in the sandbox, or a host task. The mapping comes
2421
+ from a checked-in CLI-equivalence table that a test holds to the registry and
2422
+ the help catalog. Agent instructions get a preamble framing them as the
2423
+ repository's own file, written for a checkout, whose conventions bind tickets,
2424
+ specs and answers and which win over Autobuild skills. Each binding also offers
2425
+ one MCP prompt per skill, with the same text, and appends the context to its
2426
+ server instructions. Hosted endpoints build those instructions only for an
2427
+ `initialize` request, at one latest-revision record read per repository in
2428
+ scope. A repository with no captured record is served the canonical skills
2429
+ bundled with the serving Autobuild, and the index and every preamble say so.
2430
+
2161
2431
  ### 8.10 Hosted project connection
2162
2432
 
2163
2433
  `ab connect <service-url>` requests owner browser approval for the normalized
@@ -2577,7 +2847,7 @@ the matching phase and `round`; a missing round cannot broaden either cause.
2577
2847
  `review-round-limit` retains the same matching-round effect.
2578
2848
  `verify-failure-limit` is the explicit phase-level case and re-arms every
2579
2849
  phase-runner failure round for its verify target. `reconcile-no-progress`,
2580
- `setup-failure-limit`, `wait-unresolvable` and `measurement-failed` have no phase-runner failure-budget effect (setup's own
2850
+ `setup-failure-limit`, `wait-unresolvable`, `measurement-failed` and `target-rewritten` have no phase-runner failure-budget effect (setup's own
2581
2851
  answer/retry accounting remains separate). Agent and stall raises, and
2582
2852
  cause-less historical policy raises, retain the legacy shape rule: a matching
2583
2853
  round resets that round and an absent round resets all rounds for the target.
@@ -2801,6 +3071,10 @@ does not stop, pause or displace a running build.
2801
3071
  5. normal ticket claims: `normal` start requests, then ordinary normal ready
2802
3072
  tickets while intake is on.
2803
3073
 
3074
+ An optimization attempt's ready ticket claims in its node's tier: the node's
3075
+ current build priority, decided at claim. Nothing is reserved for attempts,
3076
+ and they never jump ahead of other work in their tier.
3077
+
2804
3078
  Each tier keeps its own order: start requests oldest first, parked leaves in
2805
3079
  the tick's visit order, nodes in slug order, tickets in the source's listing
2806
3080
  order. Start requests bypass intake off and open-PR backpressure; ordinary
@@ -2993,6 +3267,38 @@ event-level mechanics live in the repository catalog and reducer tests):
2993
3267
  closed-unmerged PRs must still merge where the next tick will not reclaim
2994
3268
  them — a bounce filed into Ready is claimed and bounced again forever.
2995
3269
 
3270
+
3271
+ **Repository agent context.** At the end of every tick that still has budget
3272
+ and repository authority, the dispatcher keeps one repository-level record of
3273
+ the agent context at the base-branch head. It covers every skill directory
3274
+ under `.agents/skills/` and `.claude/skills/` with all its files (deduplicated
3275
+ by real directory and by identical content), every root and nested `AGENTS.md`
3276
+ and `CLAUDE.md`, and the files those import by `@path`, captured as separate
3277
+ entries. The record names its base commit. Both checkout and origin mode read
3278
+ the tree through the forge (`readTree`, `readBlob`), so they record identical
3279
+ content for one commit.
3280
+
3281
+ - **Artifacts.** The `agent-context` repository artifact holds the record as
3282
+ gzip JSON, with a new revision only when its content digest changes. A small
3283
+ `agent-context-head` pointer names the last base head handled, the input
3284
+ fingerprint and any standing diagnostic. `agent-context-cache.<i>` slots hold
3285
+ blob bytes an interrupted capture already fetched, so a later invocation
3286
+ resumes rather than refetching. All three are retention-managed.
3287
+ - **Cost.** Each process reads the base head at most once a minute, always on
3288
+ its first tick. An unchanged head then costs one pointer read per process.
3289
+ Nothing else is read, and no repository event is read or written. A failed
3290
+ capture is retried after five minutes, or as soon as the head moves. A head
3291
+ change reads the tree; only a changed input fingerprint reads the latest
3292
+ record and the blobs it lacks. Readers take the latest revision only.
3293
+ - **Bounds.** The encoded record may not exceed 2.25 MiB (`oversize`), and the
3294
+ record may not exceed 32 MiB uncompressed (`raw-oversize`), the same ceiling
3295
+ every reader decodes to. Both diagnostics name the bound and the largest
3296
+ contributors, keep the last good revision, and appear in the tick report
3297
+ once per base head.
3298
+
3299
+ Connected agents read the record through the context tools, prompts and server
3300
+ instructions of §8.9.
3301
+
2996
3302
  ## 13. Ticket source policy
2997
3303
 
2998
3304
  **Hosted tickets are project-scoped.** A project credential selects one registered
@@ -3023,7 +3329,13 @@ state, or a fixed `not-planned` state, never ready and never resolving a
3023
3329
  blocker, when no rejected role is configured. Reopening an issue on GitHub
3024
3330
  returns it to triage, and the adapter strips a stale pre-reopen state label the
3025
3331
  first time it reads the issue. Blockers are GitHub's native issue dependencies,
3026
- and a blocker in another repository never resolves. Assets live in the
3332
+ and a blocker in another repository never resolves. Because GitHub's
3333
+ dependency summary lags the edges, reads that feed a claim decision read the
3334
+ dependency list, and claim re-reads it fresh, refusing without a write any
3335
+ unresolved blocker the dispatcher's dependency check did not evaluate; the
3336
+ dispatcher counts that ticket as dependency-blocked for the tick. A create into
3337
+ the ready state with blockers opens in triage and moves to ready only after
3338
+ every blocker is recorded. Assets live in the
3027
3339
  BuildStore, with notes posted as issue comments, and `get` carries no comment
3028
3340
  history; export and import read it explicitly. A ticket's own issue is an implicit `closes` link. A node is an issue
3029
3341
  with the exact `node` label, and a ticket targets a node by being a sub-issue
@@ -3140,7 +3452,14 @@ normal. Urgent ready work is claimed before normal ready work, and ahead of
3140
3452
  normal parked work (§12 "Slot admission order"); a claimed ticket's priority
3141
3453
  becomes its build's priority, and nothing else changes. A single-ticket start
3142
3454
  request has its own admission tier (§11); an `urgent` request also makes its
3143
- build urgent. Sources declare support. The file source stores
3455
+ build urgent. An optimization attempt (§13.1.1) is the exception: an in-flight
3456
+ attempt of an open, unstopped optimization node claims at the node's current
3457
+ build priority, whatever its ticket says and whether or not its source stores
3458
+ priority. `ab priority <node> urgent|normal` therefore reaches the node's
3459
+ attempts claimed afterwards; an attempt already claimed keeps its build's
3460
+ priority, as any build does. No slot is reserved for attempts, they preempt
3461
+ nothing, and within a tier the source's order applies. Sources declare
3462
+ support. The file source stores
3144
3463
  `priority = "urgent"` in its frontmatter, writes no key for normal, and covers
3145
3464
  urgent priority in its revisions; the in-memory fake behaves the same way.
3146
3465
  The hosted source stores priority in the hosted ticket store, covers it in its
@@ -3749,11 +4068,12 @@ marked. `ab ticket tree` labels such a ticket
3749
4068
  node an objective row (RFC 0005 §12): the starting and current value against
3750
4069
  the threshold, with the baseline's noise; accepted, rejected and running
3751
4070
  attempts; the budget used; and the stop cause once stopped. A panel objective
3752
- shows win rates. Budget hours stop at the stop time. The terminal dashboard
4071
+ shows win rates. Budget hours are active hours, and they stop growing at the
4072
+ stop; a stopped node whose clock is not yet settled says `settling`. The terminal dashboard
3753
4073
  prints the row under the node's progress bar and in its detail view; `ab
3754
4074
  status` prints it on a continuation line and `ab build status <node>` under
3755
4075
  the `optimization node` label. `--json` summaries, `builds.list`, `builds.get`
3756
- and `ab watch --json` records (`state.objective`, with elapsed hours evaluated
4076
+ and `ab watch --json` records (`state.objective`, with active hours evaluated
3757
4077
  at the record's own timestamp) carry the same fields under `objective`, and
3758
4078
  the dashboard row under `objectiveRow`, in the same terms. Each is projected
3759
4079
  from the digest in the build state the surface already reads. The web app's
@@ -4005,8 +4325,8 @@ runtime compatibility is not requested; the dispatcher instead records
4005
4325
  node only after a fact that can clear the blocker lands on its log. The
4006
4326
  request is the node's `propose` slot request, admitted ahead of normal ticket
4007
4327
  claims (§13.1, §12 "Slot admission order"). Before admission the dispatcher re-checks it against current
4008
- state: a request whose node has stopped, whose hours budget expired, whose
4009
- room fell to zero or below the recorded room, or whose node has no free
4328
+ state: a request whose node has stopped, whose active-hours budget is spent,
4329
+ whose room fell to zero or below the recorded room, or whose node has no free
4010
4330
  concurrency slot, and for which no session has started, records
4011
4331
  `optimization.proposal-withdrawn {request, reason: stopped|budget|concurrency}`.
4012
4332
  A withdrawal clears the request and never counts as an empty proposal. A
@@ -4051,9 +4371,14 @@ mode belongs to the stop policy, not to the proposer.
4051
4371
  Discovery reads only build digests. Each build digest carries an
4052
4372
  `optimization` signal, `false` for a plain node and a bounded summary for an
4053
4373
  optimization node (stop, measurement, attempts in flight, concurrency,
4054
- attempt room, empty proposals, opening time, hours budget, the open request
4055
- and its deposit, and the latest wake and deferral sequences), from which the
4056
- dispatcher selects nodes to request, file or stop. A store service whose digest
4374
+ attempt room, empty proposals, opening time, hours budget, the active-hours
4375
+ `clock` view, the open request and its deposit, and the latest wake and
4376
+ deferral sequences), from which the dispatcher selects nodes to request, file
4377
+ or stop. Every build digest also carries `executionFacts`, the count of its
4378
+ `execution.started` and `execution.ended` facts. A service whose digest lacks
4379
+ the `clock` view skips the hours condition of a proposal request, which the
4380
+ build read then confirms; one whose digest lacks `executionFacts` fails the
4381
+ activity pass closed with the same typed capability error. A store service whose digest
4057
4382
  lacks the member fails the proposer stage and the creation hold closed with a
4058
4383
  typed capability error: nothing is proposed and every ready ticket carrying a
4059
4384
  creation key is withheld that pass. There is no per-node fallback read.
@@ -4068,8 +4393,8 @@ stop at any point lands real, verified progress. The node records
4068
4393
  `target.threshold` in the objective's direction;
4069
4394
  - `plateau`: `stop.plateau.attempts` consecutive `no-improvement` or `declined`
4070
4395
  settlements;
4071
- - `budget`: attempts filed reached `budget.maxAttempts`, or the hours since the
4072
- first acceptance reached `budget.maxHours`;
4396
+ - `budget`: attempts filed reached `budget.maxAttempts`, or the node's active
4397
+ hours reached `budget.maxHours`;
4073
4398
  - `exhausted`: recorded by the proposer when it has nothing left to try;
4074
4399
  - `operator`: recorded by a human through `ab objective <node> --stop` or the
4075
4400
  operator tool `optimization.stop`.
@@ -4087,6 +4412,69 @@ build that is not a node, a node with no objective, a terminal node and a node
4087
4412
  that has already stopped. `--stop` does not combine with revision flags. A stop
4088
4413
  is final: a later revision is recorded but never resumes proposing.
4089
4414
 
4415
+ **Active hours.** `budget.maxHours` counts the time the node's optimization
4416
+ work actually runs, never wall-clock time since opening. The clock runs while
4417
+ at least one of the node's attempts is executing, or while the node runs its
4418
+ proposer or a measurement; overlapping runs count once. Executing means an
4419
+ execution is open: from its `execution.started` to its `execution.ended`. A
4420
+ queued attempt has no build, and a runner ends its execution on every wait
4421
+ (paused, blocked on an escalation, a ticket wait, awaiting merge), so time
4422
+ spent queued, parked or paused is never charged.
4423
+
4424
+ The value is an exact union of execution intervals, kept in the node digest's
4425
+ `clock` (§15.5):
4426
+
4427
+ - The node's own `execution.started` counts when, at that moment, the node has
4428
+ an undeposited proposal, has no starting value, or has a panel head waiting
4429
+ for its progress panel. Its matching end closes the interval. Other node
4430
+ runs, such as a branch reconcile, are not counted.
4431
+ - Attempt runs reach the node in dispatcher batches,
4432
+ `optimization.activity-recorded`. Every build has an `executionIntervals`
4433
+ reduced value holding its execution facts no node has acknowledged yet, each
4434
+ numbered from 1. On every tick the dispatcher compares each relevant attempt
4435
+ build's digest `executionFacts` with the count the node's clock has
4436
+ accounted, reads the value only for a build whose count grew, and records
4437
+ the new facts. After the node's batch lands it appends the advisory
4438
+ `execution.accounted {count}` to the build, whose value then drops those
4439
+ facts. An idle tick reads and writes nothing.
4440
+ - Relevant builds are each in-flight attempt's newest build and the builds the
4441
+ clock tracks. The dispatcher's first pass over a node writes a batch with
4442
+ `starts: true`, before the node can file an attempt. From then on a build is
4443
+ tracked from its first batch, or from its attempt's `attempt.settled`, so an
4444
+ attempt that ends and settles between two ticks is still charged to its
4445
+ real end. The
4446
+ dispatcher releases a tracked build once no in-flight attempt runs on it, it
4447
+ has no open execution, and every fact is accounted.
4448
+ - Closed activity before a batch's watermark is compacted into a running
4449
+ total, so the clock stays bounded. Each build's digest is read on its own,
4450
+ so a pass can miss a fact on one build that is stamped before a fact it saw
4451
+ on another. The watermark is therefore not the batch's latest fact but the
4452
+ store time the node recorded its previous batch: that pass wrote it before
4453
+ this one read any digest, so every fact stamped before it is visible. Facts
4454
+ may follow the watermark. Compaction also never passes the start of an open
4455
+ interval, so an end that a pass missed still unions exactly with the spans
4456
+ recorded after it.
4457
+
4458
+ `optimization.stopped` records the stop time `T` and closes the node's own
4459
+ open interval there. From then on every surface evaluates active hours at
4460
+ `min(now, T)`, so the value never grows after a stop. The next dispatcher pass
4461
+ over a stopped node reads every relevant build's value once and writes a
4462
+ final batch, `settles: true`, with every unaccounted fact at or before `T`;
4463
+ an interval still open at `T` ends there. A settlement too large for one event
4464
+ is chunked: earlier chunks add their pre-stop facts, as any batch after a stop
4465
+ does, and only the last chunk settles. The clock ignores everything after
4466
+ that settlement. Until it lands, which is normally the next tick, a surface
4467
+ shows the value as `settling`: it may change once more, by attempt runs from
4468
+ before the stop the node had not yet accounted.
4469
+
4470
+ A node opened before active hours keeps a defined budget. Its log reduces once
4471
+ under the revised fold, so its own past proposer and measurement runs count.
4472
+ Its in-flight attempts' builds enter tracking when the upgraded dispatcher
4473
+ first sees them, with their whole execution history; attempts that settled
4474
+ before its clock's starting batch are not charged. A stopped node that has not completed
4475
+ gets one settlement, which adds its still in-flight attempts' runs up to its
4476
+ stop. A node that already completed reports its own runs, clipped at its stop.
4477
+
4090
4478
  Every stop, whatever its cause, is enforced the same way on each tick until no
4091
4479
  attempt is in flight:
4092
4480
 
@@ -4241,8 +4629,119 @@ events, render, send commands** — commands being events appended to the
4241
4629
  applicable build or repository log (§15.2.7). The event vocabulary *is* the
4242
4630
  UI API; forge mutation remains kernel/dispatcher plumbing. Anything a UI
4243
4631
  displays is a reduction of the logs, and anything it does is an event — so
4244
- every frontend (terminal today, web later) is the same adapter pattern
4245
- against the same store, and a dead runner still receives commands on resume.
4632
+ every frontend (the terminal dashboard and the web UIs) is the same adapter
4633
+ pattern against the same store, and a dead runner still receives commands on
4634
+ resume.
4635
+
4636
+ The standalone web UI, `ab web`, is a store-only, read-only frontend. It binds
4637
+ loopback by default and refuses a request whose `Host` is not the bound
4638
+ address, `localhost` or `127.0.0.1`; `--host` widens the bind with a warning
4639
+ that the server has no access control. Every page carries the CSP
4640
+ `default-src 'self'` with a fresh per-response style nonce, and the page loads
4641
+ only a client bundle prebuilt from `packages/ui` and committed with the
4642
+ package, so serving it adds no runtime dependency. One refresh loop, alive
4643
+ only while at least one browser is subscribed, fans each changed model out
4644
+ over one server-sent event stream. It appends nothing, takes no lease and
4645
+ registers no presence.
4646
+
4647
+ Its frame is the repository header and notice plus the overview. A fresh
4648
+ process starts the overview from the `buildRoster` rollup (§7.7) and targeted
4649
+ reads of its live builds, then advances it by the changed-builds feed. Its
4650
+ recurring reads, made only while a browser is subscribed:
4651
+
4652
+ | Occurrence | Reads | Cost |
4653
+ |---|---|---|
4654
+ | Every tick | `getRepoChangePosition` | 1 call, 0 event rows |
4655
+ | Position moved | `repositoryReadFacts` (with `getRepo`), `listBuildsChangedSince` | 3 calls; the feed returns only builds changed since the last poll |
4656
+ | Per changed build | `getBuild`, `buildReadFacts`, and while the build is visible `listStreams` and its pinned effective-config artifact | 4 calls, that build's new rows |
4657
+ | A changed build started, finished, aborted or is done | `buildRoster` | 1 call per poll |
4658
+ | New effective-config ref | `getRepoArtifact` | 1 call per ref |
4659
+ | Cold start: first read, repository reset | `buildRoster`, the per-build reads for each live build and each aborted entry among the roster's newest finished builds | O(live builds), independent of history |
4660
+
4661
+ No read grows with history, build count or tab count, and nothing is read
4662
+ while no browser is connected. The overview never lists builds, analytics
4663
+ requests read one listing page, and nothing reads events. A
4664
+ remote store that lacks the roster or the feed fails the read with its typed
4665
+ error and never falls back to either. Until the dispatcher records an
4666
+ effective configuration the frame has no `overview` and makes no build read.
4667
+ The web protocol's overview and rows carry the shared dashboard projection's
4668
+ terms: status, phase, attention, waits, step timers, finished outcomes, the
4669
+ dispatcher mode and the attention list. The terminal dashboard renders the
4670
+ same values. For `ab web` the dispatcher mode is `running`, `stopped` or
4671
+ `handoff`, never `viewer`.
4672
+
4673
+ The UI has three pages. The overview at `/` shows the dispatcher mode,
4674
+ capacity, the attention list, and the active, queued and recently finished
4675
+ build rows. The build page at `/builds/<slug>` shows one build's header,
4676
+ ticket, phase, steps and attention, then its timeline. The analytics page at
4677
+ `/analytics` shows where build time goes (RFC 0007 §7): a Gantt of builds,
4678
+ one row per build coloured by phase and wait, and a step-duration table with
4679
+ each step's mean, P50, P90 and P99 per run, or its total time. A window (24
4680
+ hours, 7 days by default, 30 days, or all retained history) and filters for
4681
+ outcome (merged by default, or all) and kind (leaf by default, node or all)
4682
+ apply to both charts. The overview and build page render the frame's shared
4683
+ projection values and update from the event stream. The page HTML carries the hub's current frame as
4684
+ a layout hint, which the page renders masked as its loading skeleton, never as
4685
+ facts. A page request reads nothing while the hub holds a frame; otherwise it
4686
+ waits for the hub's one shared read to deliver its first frame, data or a
4687
+ failure notice, bounded at 10 s. Live changes never move on-screen content:
4688
+ reserved slots take timer ticks and step changes, and any other change fades
4689
+ out, relayouts and fades back in from its first changed block.
4690
+
4691
+ Analytics and build timelines are explicit reads, never pushed or polled
4692
+ (RFC 0007 §9.3). Two read-only JSON routes serve them:
4693
+ `GET /api/analytics?window=&outcome=&kind=&page=` answers both charts for
4694
+ one query, and `GET /api/builds/<slug>/timeline` answers one build's
4695
+ `buildTimeline` value. Every frame carries the repository change position it
4696
+ was read at; the page fetches on load and on every query change, and fetches
4697
+ again only when a frame's position differs from the one its last answer was
4698
+ asked at. An unknown value answers 400, an unknown build 404, a server
4699
+ without an open store 503, and a store failure, including a remote server too
4700
+ old to filter the listing, 502 with its message; nothing falls back to an
4701
+ unfiltered listing or to events.
4702
+
4703
+ The Gantt's page is 25 builds matching the filters that the store wrote to
4704
+ during the window (`listBuildsPage` with `activeSince`), most recently active
4705
+ first. That set includes builds whose only write in the window was not an
4706
+ event, such as an artifact or a lease release. The window starts where the
4707
+ step-duration rollup's read does: UTC midnight of the first day the window
4708
+ overlaps, or the retention cutoff for all retained history. One analytics
4709
+ source per server process serializes requests and keeps settled timelines in
4710
+ memory, so its reads are:
4711
+
4712
+ | Occurrence | Reads | Cost |
4713
+ |---|---|---|
4714
+ | Every request | `getRepoChangePosition` | 1 call, 0 event rows |
4715
+ | Position moved since the last request | `listBuildsChangedSince` | 1 call; the builds it names leave the timeline cache |
4716
+ | New query, page or UTC day | the `stepDurations` rollup value, one `listBuildsPage` | 2 calls, at most 26 index entries, 0 event rows |
4717
+ | Per listed build not in memory | its saved `buildTimeline` value | at most 25 per page, that build's new rows only |
4718
+ | Timeline request, build not in memory | `getBuild`, its saved `buildTimeline` value | 2 calls |
4719
+
4720
+ A repeated request on the same UTC day while nothing changed costs one
4721
+ `getRepoChangePosition`.
4722
+
4723
+ `ab dispatch --web` serves the same server from the dispatcher process, in
4724
+ push mode: the hub owns no refresh loop. Its frames carry the repository
4725
+ header, notice and change position, not the overview. Frames from the
4726
+ dashboard frontend carry the position its refresh already sampled and add no
4727
+ store reads. A kernel-only dispatcher's journal refresh samples none, so
4728
+ while a browser is connected each of its frames reads one
4729
+ `getRepoChangePosition`, and nothing while none is. Analytics and timeline
4730
+ requests are explicit reads once its store is open, and answer 503 before. It shows the
4731
+ repository facts that a refresh the dispatcher already makes has read: the
4732
+ frontend's refresh loop under a TTY, the kernel's repository-view journal
4733
+ refreshes in plain mode (so frames update at the dispatcher's tick cadence),
4734
+ and the viewer loop for `--viewer`. A TTY keeps the terminal dashboard, which
4735
+ shows the URL right-aligned on its first line in every generation;
4736
+ under `--plain` or without a TTY the web UI is the only presentation. The
4737
+ server binds before the repository lease, so a taken port fails dispatch
4738
+ before it claims anything. For `--web` without a fixed port, the launcher
4739
+ reserves a free port once and pins `--port` into every generation's argv. A
4740
+ generation closes its server before it appends `dispatcher.terminal-released`,
4741
+ and its successor, which already holds the lease, rebinds the same port, so
4742
+ the URL survives automatic runtime upgrades. Only a first generation announces
4743
+ the URL on stdout; a TTY dashboard shows it on its first line in every
4744
+ generation.
4246
4745
 
4247
4746
  Within the immutable generation, interactive `ab dispatch` owns the terminal in a frontend process and supervises
4248
4747
  one private child containing the dispatcher, build runners, Harvest, config and
@@ -4267,9 +4766,11 @@ sampling. Repository polling advances from the last observed sequence rather
4267
4766
  than replaying the growing journal on every frame. SIGINT, SIGHUP, SIGQUIT, and
4268
4767
  SIGTERM restore terminal modes immediately and ask the child to stop; repeated
4269
4768
  signals remain graceful while a dispatcher tick is crossing the ticket-claim
4270
- boundary. The frontend reaps the child before finishing, and for SIGHUP,
4271
- SIGQUIT, or SIGTERM only then restores the default disposition by re-signalling
4272
- itself. A child also stops when its terminal-owning parent dies. A timed-out
4769
+ boundary. The frontend reaps the child before finishing, and for SIGHUP or
4770
+ SIGTERM it only then restores the default disposition by re-signalling itself.
4771
+ A drained SIGQUIT stop instead exits with status 131 (128 + 3), because
4772
+ SIGQUIT's default action dumps core. A launcher-supervised generation reports
4773
+ that stop through its stopped exit and leaves the 131 to the launcher. A child also stops when its terminal-owning parent dies. A timed-out
4273
4774
  child is terminated unless such a tick is open, in which case that tick first
4274
4775
  reaches a recoverable durable boundary. The run-stopped fact and frontend result
4275
4776
  distinguish a graceful drain, an actual forced termination requested by the
@@ -4294,12 +4795,16 @@ reporting even when no frame painted, with synchronous process restoration for
4294
4795
  catchable faults. Plain, non-TTY, and once runs never enable focus reporting.
4295
4796
 
4296
4797
  Interactive frames first read `BuildStore.getRepoChangePosition(repo)`, a canonical
4297
- unsigned decimal string used only for invalidation. Unknown repositories return
4798
+ unsigned decimal string. Unknown repositories return
4298
4799
  `"0"` without creating state. Each repository's durable position advances in the
4299
4800
  same transaction as build creation, build/repository event insertion (including
4300
4801
  artifact-backed and tick writes), or a stored dispatcher lease holder transition.
4301
4802
  Other repositories, failed writes, denied claims, same-holder renewals, heartbeats,
4302
4803
  and passive expiry do not advance it. It is separate from journal sequence cursors.
4804
+ Positions are ordered: a later advancing write yields a strictly greater value,
4805
+ compared numerically. Build creation and every build event also record the new
4806
+ position as that build's latest change position, in the same transaction, which
4807
+ the changed-builds feed (§7.2) reads.
4303
4808
  Unchanged positions reuse the complete presentation snapshot; an ordinary refresh, focused or unfocused,
4304
4809
  then makes exactly one store request. Discovery uses required exact-repo
4305
4810
  `listBuildsForRepo(repo)`, never a global listing. Initial hydration, position or
@@ -4311,11 +4816,20 @@ independently; kernel ticks and watch/wait retain their existing reads.
4311
4816
  SQLite installs an additive counter table and transactional triggers on open.
4312
4817
  PostgreSQL installs the corresponding additive table/functions/triggers through
4313
4818
  explicit migration before deploying the new service; the core schema version
4314
- and checksum stay unchanged. Existing data starts at zero, with no replay or
4315
- backfill, and migration reruns preserve counters. Hosted reads use one GET
4316
- `/repos/:repo/change-position` returning only `{ position: string }`, and
4317
- `/repos/:repo/builds` returns scoped build records. Both routes authorize the
4318
- repository before reading and support repositories with builds but no journal.
4819
+ and checksum stay unchanged. Existing counters start at zero, with no replay,
4820
+ and migration reruns preserve counters. The per-build positions live in a
4821
+ separate additive table. When it is first created, in the same transaction,
4822
+ each repository with builds advances by one and every existing build is
4823
+ recorded at that new head, so the feed reports pre-existing builds once and
4824
+ never misses one. The paged listing's per-build facts live in another
4825
+ additive, trigger-maintained table, backfilled once from each build's latest
4826
+ relevant events when it is first created. Later opens and migrations cost one
4827
+ catalog lookup. Hosted reads use one GET `/repos/:repo/change-position`
4828
+ returning only `{ position: string }`; `/repos/:repo/builds` returns scoped
4829
+ build records; `/repos/:repo/changed-builds?since=` and
4830
+ `/repos/:repo/build-page?limit=&cursor=&kind=&outcome=&activeSince=` serve the
4831
+ feed and the paged listing. All four routes authorize the repository
4832
+ before reading and support repositories with builds but no journal.
4319
4833
 
4320
4834
  Durable operator settings (intake, repository pause, harvest gate) and pending
4321
4835
  single-ticket start requests survive restarts through the repository journal. Per-merge hold and merge commands
@@ -4329,15 +4843,54 @@ build workspace and exposed to operator agents only through those tools. The
4329
4843
  typed tools are the only route to state from inside it — the environment
4330
4844
  receives no store, forge, ticket-provider, or model credential, and
4331
4845
  `[orchestrator].sandbox.environmentVariables` may never name one. Its lifecycle
4332
- is repository-journal fact: provisioned/resumed/activity/stopped/released facts
4333
- bracket one deterministic environment per session owner × repository, the
4334
- dispatcher tick's idle settlement stops an environment whose evidence is
4335
- stale (settling an orphan exactly as harvest executions are settled), and
4336
- `ab repository status` reports each session owner's sandbox. A session owner's work
4846
+ is repository-journal fact: provisioning/provisioned/resumed/provision-failed/
4847
+ activity/refreshed/stopped/closed/released facts bracket one deterministic
4848
+ environment per session owner × repository, the dispatcher tick's idle
4849
+ settlement stops an environment whose evidence is stale (settling an orphan
4850
+ exactly as harvest executions are settled), and `ab repository status` reports
4851
+ each session owner's sandbox. `sandbox.open` returns at once and starts
4852
+ provisioning or resuming in the background of the serving process, journaling
4853
+ `provisioning` and then the attempt's outcome; every other tool refuses typed
4854
+ `sandbox-not-ready`, naming the state, until the environment is live, and
4855
+ never provisions. `sandbox.status` is a bounded poll: one reduced repository
4856
+ read plus one provider probe. Its only write records a finished background
4857
+ attempt's outcome the journal still lacks, exactly once across processes,
4858
+ through the repository compare-and-append; a `provisioning` journal whose
4859
+ provider reports no environment, with no attempt in the serving process, is
4860
+ failed once its grace period passes. Failure evidence in the provider is
4861
+ destroyed only after the journal records the failure: `sandbox.open` probes
4862
+ first and records a reported failure before the provider may replace the
4863
+ environment, refusing with nothing discarded when it cannot.
4864
+
4865
+ On `vercel-sandbox` the provisioning state lives in the guest, so any
4866
+ process can read it with one probe. `sandbox.open` returns after a lookup, at
4867
+ most one probe and one update. The short host-driven phase (create, checkout,
4868
+ credential scrub, Bun, system provisioning, distribution) runs in the serving
4869
+ process's background seam (`waitUntil`, Next's `after()` on a hosted
4870
+ deployment); the slow tail (dependency install, runtimes, setup, marker) runs
4871
+ as one detached guest command, bounded by the session timer rather than the
4872
+ function limit. The sandbox is created and resumed with a provider timeout of
4873
+ `[orchestrator.sandbox].idleMinutes`, and every tool call extends it, so the
4874
+ provider's own timer stops an idle sandbox with no dispatcher tick; the
4875
+ dispatcher's idle settlement remains a second stop. A timer-stopped sandbox
4876
+ refuses tools as `stopped` until `sandbox.open` resumes it with its committed
4877
+ and uncommitted state intact; `sandbox.status` never resumes one. A failed
4878
+ environment is kept, stopped by its timer or by `sandbox.close`, until the
4879
+ next `sandbox.open` records the failure and replaces it, or until
4880
+ `sandbox.reset` or release.
4881
+
4882
+ `sandbox.close` stops
4883
+ the environment and keeps its checkout (`closed`); `sandbox.refresh`
4884
+ fast-forwards a clean checkout to the current base head (`refreshed`, which
4885
+ moves the publication base) and refuses a dirty or diverged one unchanged. A session owner's work
4337
4886
  leaves the sandbox only through `sandbox.publish`, which takes the checkout's
4338
4887
  head (or an explicit commit) to a deterministic operator branch and a pull
4339
4888
  request against the base branch and records published/publish-failed journal
4340
- facts.
4889
+ facts. On a hosted deployment only the `vercel-sandbox` provider can host the
4890
+ environment, so a project with any other workspace provider gets it from the
4891
+ deployment's Vercel Sandbox provider, cloned in the guest with the deployment's
4892
+ forge token placed only in the host-side upload-pack egress transform; without
4893
+ those deployment credentials the tools refuse `sandbox-credentials-missing`.
4341
4894
 
4342
4895
  Successful dispatcher ticks with no effects, counters, diagnostics, queue change,
4343
4896
  sampled triage-count change, or attention transition append no tick boundary
@@ -4540,13 +5093,13 @@ with illustrative members:
4540
5093
  | Integration attention | Kernel/dispatcher `integration.verification-failed {id, head, parent, steps, guidance}`: one durable failed-cycle notification, recovered from exact verification receipts |
4541
5094
  | PR summary | Kernel-authored `pr-summary.requested {occurrence, boundary}`, `pr-summary.attempted {occurrence, boundary, pr}`, `pr-summary.result {attempt, outcome, eligibleAfter?}`, `pr-summary.settled {request, disposition}`; sequence identities correlate durable starts, completed boundaries, attempts, and handoffs (§7.5) |
4542
5095
  | PR attachments | `pr-attachment.designated`, `pr-attachment.hosted`, `pr-attachment.reclaimed`, `pr-attachment.reclaim-failed` |
4543
- | Leaf restacking | `target.moved {branch, sha, lineage?}`, `target.rewritten {branch, previousSha, sha}`, `target.rewrite-cleared {branch, sha, lineage?}`, advisory `target.distance {branch, sha, head, count}`, `restack.prepared`, `restack.replayed`, `restack.publish-intended`, `restack.rewritten`, `restack.contended`, `restack.completed` (trigger `verify-entry`, `wait-resume` or `awaiting-landing`), `restack.advanced {trigger: wait-resume, cycle, observation, branch, from, to}`, kernel `restack.regenerated {id, files, commands, outcome, head?, reason?}`, kernel or dispatcher decisive `history.retained {operation: restack \| reconcile, id, base, store, target, unretained}` (leaf restacks and reconciles, §15.7) |
5096
+ | Leaf restacking | `target.moved {branch, sha, lineage?}`, `target.rewritten {branch, previousSha, sha}`, `target.rewrite-cleared {branch, sha, lineage?}`, kernel `target.rewrite-reprovision-prepared {branch, previousSha, base, from, sha}` and `target.rewrite-recovered {branch, previousSha, sha, base, recovery: reprovisioned \| accepted, escalation?, pendingLocal?}`, advisory `target.distance {branch, sha, head, count}`, `restack.prepared`, `restack.replayed`, `restack.publish-intended`, `restack.rewritten`, `restack.contended`, `restack.completed` (trigger `verify-entry`, `wait-resume` or `awaiting-landing`), `restack.advanced {trigger: wait-resume, cycle, observation, branch, from, to}`, kernel `restack.regenerated {id, files, commands, outcome, head?, reason?}`, kernel or dispatcher decisive `history.retained {operation: restack \| reconcile, id, base, store, target, unretained}` (leaf restacks and reconciles, §15.7) |
4544
5097
  | Head path facts | advisory `head.paths-recorded {source, head, destination, mergeBase, total, preview, resolution?, artifact}` |
4545
5098
  | Propose (§5, §13.1.1) | Kernel `propose.started {round, request}`; agent `propose.completed {round, request, proposals, artifact}` (the deposited proposal ids and the `attempts` artifact) |
4546
5099
  | Post-PR [D1] | `pr.merged`, `pr.conflicted`, advisory dispatcher `pr.checks-failed {pr, head, buildHead, checks, total, digest}` and `pr.checks-cleared {pr, head, cause}` (forge CI on finished leaves, §15.7), `reconcile.progress-checked`, `reconcile.started`, `reconcile.prepared`, `reconcile.replayed`, `reconcile.publish-intended`, `reconcile.rewritten`, `reconcile.contended`, `reconcile.completed`, kernel `reconcile.superseded {attempt, cycle, cause: wait-resume, restackId?}` (§11 "Ticket waits") |
4547
5100
  | Cross-cutting | `observation.recorded`, `escalation.raised`, `phase.failed`, `session.build-read-failed`, `session.build-read-recovered`, `phase.deferred`, `phase.deferral-escalated` |
4548
5101
  | Ticket waits (§11) | Agent `wait.requested {id, phase, round, tickets, reason, publication?: {branch, base, sha, settlement: published \| requested}}`; dispatcher `wait.published {id, sha}`, `wait.refused {id, cause: unknown-ticket \| own-ticket \| completed \| no-source-ticket \| publication-lost, tickets, message}` and `wait.entered {id, escalation, tickets, reason, question}`; dispatcher, kernel or human `wait.ended {id, cause: operator \| automatic, message}`; dispatcher policy `escalation.raised {policyCause: wait-unresolvable}` ends an open wait whose ticket was rejected or deleted |
4549
- | Optimization (§13.1.1) | Dispatcher `optimization.objective-accepted {objective, revision, harnessPin, specRev}`; human `optimization.objective-revised {changes, revision}` (revision ≥ 2; `changes` a nonempty subset of threshold, epsilon, maxAttempts, maxHours, plateau, stopMode, concurrency); `optimization.baseline-measured {revision, head, harnessPin, samples, median, spread, report?}` (a panel records its self-comparison win rate and that rate's distance from 0.5); advisory `optimization.noise-exceeded {revision, head, harnessPin, median, spread, epsilon, effectiveEpsilon}`; dispatcher `optimization.proposal-requested {id, head, room, budgetUsed: {attempts, hours}}`; dispatcher `optimization.proposal-deferred {reason: paused \| blocked \| command \| restack \| integration \| landing \| compatibility}`; dispatcher `optimization.proposal-withdrawn {request, reason: stopped \| budget \| concurrency}`, which clears an undeposited request and never counts as an empty proposal; dispatcher `optimization.attempts-proposed {request, proposals: [{id, ticket, title, strategy}], reason?}`, written after ticket creation, with `reason` required when `proposals` is empty; `attempt.measurement-requested {id, node, candidate, baseline, harnessPin, revision, metric?, purpose?}` (`metric` the node's command or panel metric; `purpose` the objective purpose, required with a panel metric); kernel `attempt.sampled {request, candidate, baseline, harnessPin, revision, samples, medians?: {candidate, baseline}, winRate?, report}` with exactly one of `medians` and `winRate` (`samples` is a panel's judge count); `attempt.measured {request, candidate, baseline, harnessPin, revision, samples, medians?: {candidate, baseline}, winRate?, delta, decision: improved \| no-improvement \| non-regressing \| regressed, spread?, report?}` with exactly one of `medians` and `winRate`; `optimization.progress-measured {revision, head, start, winRate, judges}`; `attempt.settled {attempt: {proposal, ticket, build?, branch?}, outcome: accepted \| no-improvement \| declined \| stopped \| aborted \| merged-unmeasured, measurement?: {revision, baseline, candidate, delta}, policy?: release-unmeasured, mergedSha?, note?, head?}`, with `measurement` required for `accepted` and `no-improvement`, `policy` required and `measurement` forbidden for `merged-unmeasured` (human actor), `policy` and `mergedSha` allowed only with it, `head` (the landed node head) only for `accepted`, and `attempt.branch` only for `declined` and `no-improvement`; `attempt.merged-unmeasured {proposal, ticket, build, sha?, reason: absent \| stale-head \| unrelated \| unresolvable, measuredCandidate?}`, with `sha` absent exactly for `unresolvable`; dispatcher `attempt.ticket-rejected {proposal, ticket, state}`, recording a settled attempt ticket move to rejected; dispatcher `attempt.branch-deleted {proposal, build, branch}` and `attempt.branch-cleanup-failed {proposal, build?, branch, error}` for a settled attempt's branch cleanup obligation; `optimization.stopped {cause: threshold \| plateau \| budget \| exhausted \| operator, mode: abort \| drain}`. `attempt.measurement-requested`, `attempt.sampled` and `attempt.measured` are on the attempt's log; every other member, including `attempt.settled`, is on the node's log. The dispatcher records `exhausted` after two consecutive empty proposals. All are decisive except advisory `optimization.noise-exceeded`. A measurement failure is a kernel or dispatcher `escalation.raised {phase: measurement, source: policy, policyCause: measurement-failed}`. |
5102
+ | Optimization (§13.1.1) | Dispatcher `optimization.objective-accepted {objective, revision, harnessPin, specRev}`; human `optimization.objective-revised {changes, revision}` (revision ≥ 2; `changes` a nonempty subset of threshold, epsilon, maxAttempts, maxHours, plateau, stopMode, concurrency); `optimization.baseline-measured {revision, head, harnessPin, samples, median, spread, report?}` (a panel records its self-comparison win rate and that rate's distance from 0.5); advisory `optimization.noise-exceeded {revision, head, harnessPin, median, spread, epsilon, effectiveEpsilon}`; dispatcher `optimization.proposal-requested {id, head, room, budgetUsed: {attempts, hours}}` (`hours` is active hours); dispatcher `optimization.proposal-deferred {reason: paused \| blocked \| command \| restack \| integration \| landing \| compatibility}`; dispatcher `optimization.proposal-withdrawn {request, reason: stopped \| budget \| concurrency}`, which clears an undeposited request and never counts as an empty proposal; dispatcher `optimization.attempts-proposed {request, proposals: [{id, ticket, title, strategy}], reason?}`, written after ticket creation, with `reason` required when `proposals` is empty; `attempt.measurement-requested {id, node, candidate, baseline, harnessPin, revision, metric?, purpose?}` (`metric` the node's command or panel metric; `purpose` the objective purpose, required with a panel metric); kernel `attempt.sampled {request, candidate, baseline, harnessPin, revision, samples, medians?: {candidate, baseline}, winRate?, report}` with exactly one of `medians` and `winRate` (`samples` is a panel's judge count); `attempt.measured {request, candidate, baseline, harnessPin, revision, samples, medians?: {candidate, baseline}, winRate?, delta, decision: improved \| no-improvement \| non-regressing \| regressed, spread?, report?}` with exactly one of `medians` and `winRate`; `optimization.progress-measured {revision, head, start, winRate, judges}`; `attempt.settled {attempt: {proposal, ticket, build?, branch?}, outcome: accepted \| no-improvement \| declined \| stopped \| aborted \| merged-unmeasured, measurement?: {revision, baseline, candidate, delta}, policy?: release-unmeasured, mergedSha?, note?, head?}`, with `measurement` required for `accepted` and `no-improvement`, `policy` required and `measurement` forbidden for `merged-unmeasured` (human actor), `policy` and `mergedSha` allowed only with it, `head` (the landed node head) only for `accepted`, and `attempt.branch` only for `declined` and `no-improvement`; `attempt.merged-unmeasured {proposal, ticket, build, sha?, reason: absent \| stale-head \| unrelated \| unresolvable, measuredCandidate?}`, with `sha` absent exactly for `unresolvable`; dispatcher `attempt.ticket-rejected {proposal, ticket, state}`, recording a settled attempt ticket move to rejected; dispatcher `attempt.branch-deleted {proposal, build, branch}` and `attempt.branch-cleanup-failed {proposal, build?, branch, error}` for a settled attempt's branch cleanup obligation; `optimization.stopped {cause: threshold \| plateau \| budget \| exhausted \| operator, mode: abort \| drain}`; dispatcher `optimization.activity-recorded {facts: [{build, n, instance, kind: started \| ended, at}], accounted, released?, watermark, starts?, settles?}`, at most 200 facts sorted by `at`, with `watermark` the bound through which the clock compacts, which records attempt execution facts into the active-hours clock; dispatcher `execution.accounted {count}`, advisory, acknowledging that a node accounted a build's first `count` execution facts. `execution.accounted`, `attempt.measurement-requested`, `attempt.sampled` and `attempt.measured` are on the attempt's log; every other member, including `attempt.settled`, is on the node's log. The dispatcher records `exhausted` after two consecutive empty proposals. All are decisive except advisory `optimization.noise-exceeded` and `execution.accounted`. A measurement failure is a kernel or dispatcher `escalation.raised {phase: measurement, source: policy, policyCause: measurement-failed}`. |
4550
5103
  | Judge panels (§13.1.1) | Kernel `panel.started {panel, candidate, baseline, harnessPin, purpose, rubric, harness, judges}` (judges 1–20); kernel `panel.judge-started {panel, judge, session, order: candidate-first \| baseline-first, runner, model?, account?, stream?, substitution?}`; agent (judge) `panel.preferred {panel, judge, session, preference: A \| B \| tie, reason}` (nonblank reason, no order); kernel `panel.judged {panel, judge, session, order, preference, reason}`; kernel `panel.judge-ended {panel, judge, session, outcome: completed \| no-terminal \| failed \| expired \| interrupted \| reclaimed, error?, transcript?}`. All live on the log of the build that runs the panel, and all are decisive. |
4551
5104
  | Repository journal | dispatcher setting facts; run lifecycle, effective config, tick/queue diagnostics, reload and runner outcomes; the `harvest.*` workflow, recovery, and ledger facts; `ticket-preparation.*` claim boundaries; `ticket.handed-back` and `ticket.handback-settled`; `ticket.start-requested`, `ticket.start-cancelled`, `ticket.start-settled` and the advisory `ticket.identity-recorded`; configured hook health `hook.failing`, `hook.recovered` and `hook.skipped` (advisory attention, §16.1) |
4552
5105
 
@@ -4701,8 +5254,8 @@ records the header identity sent by each published client. Remote clients never
4701
5254
  reconstruct named answers from event logs. Catalog identity travels in response
4702
5255
  header `x-autobuild-catalog-identity`; strict JSON bodies remain exactly
4703
5256
  `{version, cursor, value}`. Missing/malformed headers do not reject an answer.
4704
- Repository digest batches are also canonical, with no client discovery or
4705
- per-build fallback.
5257
+ Repository digest batches and open-build listings are also canonical, with no
5258
+ client discovery or per-build fallback.
4706
5259
  A service omits identity for a backend without one. This guarantee excludes
4707
5260
  readers predating this contract and does not widen the supported client window.
4708
5261
 
@@ -4763,8 +5316,14 @@ dispatcher's settlement completes the build, and `done` then wins.
4763
5316
  an optimization node's own log, absent until the first
4764
5317
  `optimization.objective-accepted` (§13.1.1). It holds:
4765
5318
 
4766
- - the latest acceptance with its time; `openedAt`, the first acceptance's time
4767
- and the start of the hours budget; the effective `objective`, which is the
5319
+ - the latest acceptance with its time; `openedAt`, the first acceptance's
5320
+ time; `clock`, the active-hours clock (§13.1.1 "Active hours"): `activeMs`,
5321
+ the union of activity before its `watermark`; `recordedAt`, when the node
5322
+ recorded its latest batch; `spans`, the closed active spans since, sorted
5323
+ and disjoint; `open`, the running executions, the node's
5324
+ own under `''` and each attempt's under its build slug; `builds`, the tracked
5325
+ attempt builds with the execution facts accounted of each; and, once
5326
+ stopped, `stoppedAt` and `settled`; the effective `objective`, which is the
4768
5327
  latest accepted objective with every later quick revision applied in order;
4769
5328
  `revision`; `revisedFields`, the fields quick-revised since the latest
4770
5329
  acceptance; and `rulerRevision`;
@@ -4809,12 +5368,13 @@ an optimization node's own log, absent until the first
4809
5368
  `optimization.attempts-proposed` closes it; `optimization.proposal-withdrawn`
4810
5369
  closes it only while it is undeposited. At most one request is open.
4811
5370
 
4812
- Pure selectors over the digest take the current time. Elapsed hours run from
4813
- `openedAt`. Stop eligibility is computed per cause: threshold when `current` has
5371
+ Pure selectors over the digest take the current time. Active hours at `now`
5372
+ are `activeMs` plus the length of the union of `spans` and the open intervals,
5373
+ each running to `now`, everything clipped at `stoppedAt`. Stop eligibility is computed per cause: threshold when `current` has
4814
5374
  reached `target.threshold` in the objective's direction (a panel compares its
4815
5375
  recorded progress, the head's win rate against the starting head, which it
4816
5376
  maximizes); plateau when `plateau` ≥ `stop.plateau.attempts`;
4817
- budget when `filed` ≥ `maxAttempts` or elapsed hours ≥ `maxHours`. Admission
5377
+ budget when `filed` ≥ `maxAttempts` or active hours ≥ `maxHours`. Admission
4818
5378
  reports whether the node stopped, the attempts the budget still allows (none
4819
5379
  without `maxAttempts`), and the concurrency slots held neither by an in-flight
4820
5380
  attempt nor by a pending rejection. A tracker that keeps refusing the move
@@ -4856,7 +5416,7 @@ proposals and has positive room, and that no non-optimization blocker holds
4856
5416
  (paused, blocked, pending commands, compatibility deferral, active or
4857
5417
  conflicted node restack, landing intent, merged or closed PR).
4858
5418
  `proposalEligible` re-checks an open request against current state: not
4859
- stopped, hours budget not expired, attempt room and a free concurrency slot
5419
+ stopped, active-hours budget not spent, attempt room and a free concurrency slot
4860
5420
  remaining, and the request's room no larger than the current room.
4861
5421
  `proposalWithdrawalDue` names the reason (`stopped`, `budget` or
4862
5422
  `concurrency`) an undeposited request fails it. `exhaustedStopDue` holds when
@@ -4967,6 +5527,55 @@ append-only log. Separate reducers
4967
5527
  derive dispatcher settings and harvest state from the repository journal; each
4968
5528
  ignores the other's facts.
4969
5529
 
5530
+ #### Build timeline: segments and steps
5531
+
5532
+ `buildTimeline` is a registered build-scope value: the build's **segments** of
5533
+ phase and wait time, for Gantt rows and the `stepDurations` rollup (§7.7).
5534
+ Phase segments pair the same start and terminal events the dashboard's phase
5535
+ intervals pair.
5536
+
5537
+ | Category | Opens | Closes |
5538
+ |---|---|---|
5539
+ | `plan`, `plan-review`, `implement`, `code-review` | `*.started` | `plan.completed`, `*.verdict`, `implement.completed` |
5540
+ | `verify:<step>` | `verify.started` | `verify.completed`, `verify.cancelled` |
5541
+ | `finalize`, `reconcile` | `*.started` | `*.completed` |
5542
+ | `queued` | `build.created` | first `execution.started`; never reopens |
5543
+ | `escalated` | first `escalation.raised` while none is open | the `escalation.answered` that leaves no raised escalation unanswered |
5544
+ | `paused` | `build.paused` | `build.resumed` |
5545
+ | `ticket-wait` | `wait.entered` | `wait.ended`, or `escalation.answered` for the wait's escalation |
5546
+ | `awaiting-merge` | `pr.opened` or `finalize.completed`, whichever first | `pr.merged`, `pr.closed`, `build.completed`, `build.aborted` |
5547
+
5548
+ - A phase start while that category is open replaces the open start; the
5549
+ replaced attempt leaves no segment. A wait opening while its category is open
5550
+ is ignored, so waits never lose time.
5551
+ - Each segment carries `category`, `start`, `end` (absent while open),
5552
+ `durationMs`, the `opened` and `closed` events (`{type, seq}`), `round` or
5553
+ `attempt` from the opening payload, `state` (`open`, `closed` or
5554
+ `abandoned`) and, when merged, `merged`.
5555
+ - At `build.completed` or `build.aborted`, every other open segment closes as
5556
+ `abandoned` at the terminal event: the row stops growing, and abandoned
5557
+ segments contribute nothing to step durations.
5558
+ - The value also carries the build's `kind` (`work` or `node`), its `outcome`
5559
+ (the latest `build.completed` outcome, cleared by `build.reopened`) and
5560
+ `createdAt`. Segments are ordered by opening seq.
5561
+ - **Cap.** At most 200 closed segments. Past it, the earliest segment that has
5562
+ a later segment of the same category and state absorbs that segment: it keeps
5563
+ its own start, takes the later end and close, adds the durations and counts
5564
+ the merged occurrences. The list is bounded by max(200, distinct
5565
+ category-state pairs), so a retry loop cannot grow it without limit.
5566
+
5567
+ A **step** is a category; durations are per step. Waits are steps too and may
5568
+ overlap phases: an escalation raised during implement counts in both.
5569
+ Uncovered time between segments is idle and is not a segment.
5570
+
5571
+ #### Build roster entry
5572
+
5573
+ `buildRosterEntry` is a registered build-scope value for the `buildRoster`
5574
+ rollup (§7.7): the build's `kind` (from `build.created`, default `work`), its
5575
+ `createdAt` (the first event's timestamp) and, once terminal, `finished:
5576
+ {outcome, completedAt}`. It applies the build reducer's terminal rule, so
5577
+ `finished` is present exactly when the build's status is `done` or `aborted`.
5578
+
4970
5579
  ### 15.6 Walkthroughs
4971
5580
 
4972
5581
  **Happy path** (elided: `session.started/ended` brackets around every agent
@@ -5042,9 +5651,12 @@ round-matched rule. A bare retry reruns the verifier with no feedback.
5042
5651
  verdict's finding marks `persists: [f1]` → round 3 again → kernel:
5043
5652
  `escalation.raised {source: "stall", refs: [chain]}`; status → `blocked`.
5044
5653
  `escalation.answered` uses the resolution vocabulary `guidance`,
5045
- `dismiss-finding`, `revise-spec`, `abort`, or `retry`. Operators produce
5046
- `dismiss-finding` and `revise-spec` through `ab answer`; a `revise-spec` answer
5047
- names the exact replacement artifact it authorizes. `guidance` feeds the answer
5654
+ `dismiss-finding`, `revise-spec`, `abort`, `retry`, or `accept-target`. Operators produce
5655
+ `dismiss-finding`, `revise-spec` and `accept-target` through `ab answer`; a `revise-spec` answer
5656
+ names the exact replacement artifact it authorizes. `accept-target` answers only
5657
+ a leaf's `policy/target-rewritten` escalation (§7.4): it waives the rejected base
5658
+ and restacks the build's own commits onto the current target; other answer forms
5659
+ skip that escalation. `guidance` feeds the answer
5048
5660
  into the next producer round as authoritative feedback; `dismiss-finding`
5049
5661
  marks the chain human-resolved and the next reviewer round is told so. Engine-routed
5050
5662
  guidance is latest-only per destination (`plan`, `code`, or one exact agent
@@ -5110,6 +5722,17 @@ however, a runner honors an engine-selected pause or abort acknowledgement befor
5110
5722
  setup-failure gating, even while that escalation is open. This control-only path
5111
5723
  executes no setup, appends no `runner.attached`, and starts no phase or session.
5112
5724
  Resume and all decisions that use the workspace still require successful setup.
5725
+ Setup is keyed to the base the runner prepared: when a restack, wait-resume
5726
+ advance or completed reconcile moves the build's verify diff base (a node's
5727
+ integration cycle parent) inside one runner process, the runner reruns setup
5728
+ before the next workspace-using decision (a non-reconcile phase, check, verify
5729
+ stage, finalize step or measurement). Every base move counts as a dependency
5730
+ change, because the kernel cannot see which files setup reads; agent commits do
5731
+ not move the base, and a reconcile replay in progress is not prepared. A
5732
+ post-restack failure follows the same path as an attach failure: it appends
5733
+ `runner.setup-failed` with the next attempt, counts toward
5734
+ `policy.maxSetupAttempts`, ends the runner unattached, and only a later
5735
+ successful setup's `runner.attached {resumedFromSeq}` clears it.
5113
5736
  The setup target belongs only to escalation metadata and is not a pipeline `Phase`.
5114
5737
 
5115
5738
  **D — runner loss and sandbox death:** local git-worktrees first attempt the
@@ -5900,6 +6523,43 @@ The dispatcher emits an actionable operator notice without repeating it for the
5900
6523
  same failure. Restoring a valid `autobuild.toml` clears the rejection and
5901
6524
  ordinary boundary reload resumes.
5902
6525
 
6526
+ **Local overrides.** A checkout may carry an uncommitted `.autobuild/local.toml`
6527
+ beside `autobuild.toml`. Every process that reads configuration from that
6528
+ checkout, including a checkout-mode dispatcher's startup and every reload,
6529
+ layers it over the committed file: the raw TOML tables merge key by key (scalars
6530
+ and arrays replace whole) before schema validation, so defaults and
6531
+ cross-validation run on the merged input and an invalid local value gets the
6532
+ committed file's message naming the local file. Every root key carries an
6533
+ exhaustive local-override classification. Only `capacity`,
6534
+ `ticketScanIntervalSeconds`, `[upgrade]`, `[hooks]`, `[roles]`, `[accounts]` and
6535
+ `[operator]` are local; every other key, including the build-owned sections, is
6536
+ committed-only, and a local file that sets one is a rejected candidate under the
6537
+ rules above. The dispatcher reads both files as one candidate with the same
6538
+ hot/restart treatment per field. It records the dotted settings it took from the
6539
+ local file as `localOverrides` in the metadata of its effective-config artifact,
6540
+ which `ab repository status` reports. Build-owned sections still come from the
6541
+ build's own branch, and origin-mode and hosted dispatchers never read a local
6542
+ file.
6543
+
6544
+ **Local dispatcher ownership preference.**
6545
+
6546
+ `[operator] dispatcher = "human" | "agent"` is optional with no default and is
6547
+ local-only: committed input rejects even an empty `[operator]` with advice to use
6548
+ `.autobuild/local.toml`. Effective configuration and artifacts accept it. Changes
6549
+ are hot and do not command a dispatcher. `ab operator dispatcher [human|agent]
6550
+ [--json]` reads or saves only that preference, without a store or event write;
6551
+ phase authority cannot save it. Saving validates existing and candidate config,
6552
+ preserves other settings semantically and atomically replaces the local file.
6553
+
6554
+ Operator agents check fresh `dispatcherRunning` and never start while it is true
6555
+ or unknown. With none running they honor repository instructions and the saved
6556
+ preference, or ask and offer to save it. Human ownership means instructions and
6557
+ waiting; agent ownership uses `ab dispatch --web --plain --json` under managed
6558
+ background lifetime and shares the URL. Only a dispatcher this session started
6559
+ may be stopped, on request, with a clean drain. Another session's process cannot
6560
+ be adopted, restarted or killed. `ab web` is always permitted as a read-only
6561
+ surface, including while dispatch runs.
6562
+
5903
6563
  Merge policy is an ordered `[[merge]]` array. Each rule requires
5904
6564
  `mode = "auto" | "consent"` and may match `into = "root" | "node" | <node-ticket-id>`,
5905
6565
  `from = "leaf" | "node"`, an exact, case-sensitive `label`, and changed-path
@@ -5982,7 +6642,7 @@ automatic = true # immediate/60-second target checks; false requi
5982
6642
  #releaseId = 123456
5983
6643
 
5984
6644
  [commands] # deterministic verbs the kernel may run
5985
- setup = "bun install" # after provision / sandbox rehydrate (§15.6-C)
6645
+ setup = "bun install" # at attach, and after a restack moves the base (§15.6-C)
5986
6646
  typecheck = "bun run type-check"
5987
6647
  test = "bun run test"
5988
6648
  publish = "bun run publish"
@@ -6548,10 +7208,26 @@ heads require immutable commit ancestry proof against the accepted target and
6548
7208
  the destination base already used by replay. Missing capability or failed proof
6549
7209
  defers new replay. A non-descendant without kernel lineage records
6550
7210
  `target.rewritten` with branch,
6551
- previous SHA and observed SHA, retains the accepted target, and raises watch/wait
6552
- attention. Repeated rewrite pairs are deduplicated. Returning to a safe target
6553
- clears attention (`target.rewrite-cleared` when the accepted tip is unchanged).
6554
- Upstream force-pushes are never adopted automatically. Accepted node reparenting
7211
+ previous SHA and observed SHA, and retains the accepted target. Repeated rewrite
7212
+ pairs are deduplicated. Returning to a safe target clears the wait
7213
+ (`target.rewrite-cleared` when the accepted tip is unchanged). Upstream
7214
+ force-pushes are never adopted on top of existing work automatically:
7215
+
7216
+ - A leaf with no work of its own (no published head, no PR, no commits beyond
7217
+ its base in use) is reprovisioned from the current target by its next runner,
7218
+ without operator action: `target.rewrite-reprovision-prepared`, a branch
7219
+ reset, then `target.rewrite-recovered` (`reprovisioned`). A runner that dies
7220
+ mid-reset completes it forward.
7221
+ - A leaf with work raises one `policy/target-rewritten` escalation per episode
7222
+ (a run of rewrites of the same rejected base), naming that base, the new
7223
+ target head and its own commits. `ab answer <slug> --accept-target` waives
7224
+ the rejected base (`target.rewrite-recovered`, `accepted`) and restacks its
7225
+ own commits onto the target at the next replay boundary; `ab abort` is the
7226
+ other way out.
7227
+ - A node waits, and raises watch/wait attention once per episode.
7228
+
7229
+ `ab build status` names a leaf's recovery state, and the base when the build's
7230
+ first provision adopted it from a pre-existing branch. Accepted node reparenting
6555
7231
  starts a new branch scope; frozen transactions recover their retained inputs.
6556
7232
 
6557
7233
  Kernel restacks of a node are admitted through durable guarded publication