@defrex/autobuild 1.10.0 → 1.11.0

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