@defrex/autobuild 1.10.0 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +745 -69
  3. package/bin/ab-dispatch-generation.ts +3 -1
  4. package/docs/accounts.md +2 -1
  5. package/docs/answering-blocked-builds.md +20 -0
  6. package/docs/architecture.md +165 -29
  7. package/docs/build-store.md +10 -7
  8. package/docs/cli.md +33 -1
  9. package/docs/configuration-overview.md +4 -1
  10. package/docs/configuration.md +381 -29
  11. package/docs/dispatcher.md +64 -4
  12. package/docs/forges.md +7 -0
  13. package/docs/integration-tree.md +2 -2
  14. package/docs/operating.md +4 -2
  15. package/docs/operator-api.md +134 -6
  16. package/docs/operator-surfaces.md +85 -0
  17. package/docs/optimization-nodes.md +69 -11
  18. package/docs/plugin-authoring.md +37 -1
  19. package/docs/remote-store-protocol.md +94 -13
  20. package/docs/remote-ticket-protocol.md +40 -0
  21. package/docs/restacking.md +20 -4
  22. package/docs/setup.md +14 -2
  23. package/docs/ticket-dependencies.md +10 -3
  24. package/docs/ticket-sources.md +24 -2
  25. package/docs/tickets.md +7 -1
  26. package/docs/troubleshooting.md +8 -0
  27. package/docs/verification.md +4 -3
  28. package/docs/workspaces.md +3 -0
  29. package/package.json +9 -5
  30. package/packages/core/src/cli/accounts.ts +7 -2
  31. package/packages/core/src/cli/attention.ts +3 -1
  32. package/packages/core/src/cli/binary-direct.ts +2 -0
  33. package/packages/core/src/cli/binary-lifecycle.ts +2 -1
  34. package/packages/core/src/cli/build-control.ts +79 -1
  35. package/packages/core/src/cli/context.ts +4 -0
  36. package/packages/core/src/cli/dashboard/facts.ts +49 -53
  37. package/packages/core/src/cli/dashboard/header.ts +111 -0
  38. package/packages/core/src/cli/dashboard/model.ts +31 -39
  39. package/packages/core/src/cli/dashboard/objective-row.ts +46 -14
  40. package/packages/core/src/cli/dashboard/poll.ts +179 -76
  41. package/packages/core/src/cli/dashboard/render.ts +159 -230
  42. package/packages/core/src/cli/dashboard/row-text.ts +538 -0
  43. package/packages/core/src/cli/dashboard/timeline.ts +288 -0
  44. package/packages/core/src/cli/dashboard/vocabulary.ts +188 -0
  45. package/packages/core/src/cli/dispatch-args.ts +44 -1
  46. package/packages/core/src/cli/dispatch-frontend.ts +40 -40
  47. package/packages/core/src/cli/dispatch-launch-stop.ts +18 -0
  48. package/packages/core/src/cli/dispatch-launcher.ts +20 -7
  49. package/packages/core/src/cli/dispatch-web.ts +155 -0
  50. package/packages/core/src/cli/dispatch.ts +202 -38
  51. package/packages/core/src/cli/help.ts +87 -3
  52. package/packages/core/src/cli/init-validation.ts +3 -3
  53. package/packages/core/src/cli/main.ts +70 -6
  54. package/packages/core/src/cli/mcp.ts +35 -3
  55. package/packages/core/src/cli/objective.ts +1 -1
  56. package/packages/core/src/cli/operator-preference.ts +57 -0
  57. package/packages/core/src/cli/repo-lease.ts +2 -0
  58. package/packages/core/src/cli/repo-state.ts +56 -6
  59. package/packages/core/src/cli/repository-status.ts +105 -49
  60. package/packages/core/src/cli/status.ts +82 -1
  61. package/packages/core/src/cli/terminal-restore.ts +32 -7
  62. package/packages/core/src/cli/ticket.ts +98 -36
  63. package/packages/core/src/cli/wait.ts +14 -6
  64. package/packages/core/src/cli/watch.ts +20 -4
  65. package/packages/core/src/cli/web.ts +139 -0
  66. package/packages/core/src/config/live.ts +99 -14
  67. package/packages/core/src/config/load.ts +61 -20
  68. package/packages/core/src/config/local.ts +212 -0
  69. package/packages/core/src/config/pipeline-source.ts +2 -0
  70. package/packages/core/src/config/reference.ts +18 -0
  71. package/packages/core/src/config/schema.ts +45 -10
  72. package/packages/core/src/events/catalog.ts +4 -0
  73. package/packages/core/src/events/payloads.ts +97 -0
  74. package/packages/core/src/events/policy.ts +10 -0
  75. package/packages/core/src/events/repository.ts +46 -3
  76. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +381 -30
  77. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/017d8dd5bb6dd80b.json.gz +0 -0
  78. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/178e12f1759b7552.json.gz +0 -0
  79. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4932c70a2af97faf.json.gz +0 -0
  80. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/536085773daf6b58.json.gz +0 -0
  81. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6bd6275061aaffa5.json.gz +0 -0
  82. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/89625654b02e9ac1.json.gz +0 -0
  83. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a98af134be2da8a9.json.gz +0 -0
  84. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d5d5ccca80a893d8.json.gz +0 -0
  85. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f8155387eb5f375c.json.gz +0 -0
  86. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3c27f918b194e3b3.json +465 -0
  87. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/46196d8f0076496a.json +97 -0
  88. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/79f0e0f4ccd43ba2.json +455 -0
  89. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/859c09edac738823.json +1086 -0
  90. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a283c1f3462b1cc1.json +81 -0
  91. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a6e570fb126991ff.json +36 -0
  92. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a8acf22c968b6e3d.json +81 -0
  93. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/ba7b85895bf6698e.json +1153 -0
  94. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fc66408cde0b6b04.json +637 -0
  95. package/packages/core/src/kernel/build-roster.ts +230 -0
  96. package/packages/core/src/kernel/dispatch-capacity.ts +4 -2
  97. package/packages/core/src/kernel/dispatch-status.ts +139 -0
  98. package/packages/core/src/kernel/engine.ts +43 -5
  99. package/packages/core/src/kernel/execution-intervals.ts +61 -0
  100. package/packages/core/src/kernel/generators/optimization-log.ts +101 -0
  101. package/packages/core/src/kernel/generators/repository-journals.ts +13 -0
  102. package/packages/core/src/kernel/leaf-restack-base.ts +33 -7
  103. package/packages/core/src/kernel/leaf-restack-state.ts +82 -3
  104. package/packages/core/src/kernel/log-index.ts +19 -0
  105. package/packages/core/src/kernel/optimization-admission.ts +244 -3
  106. package/packages/core/src/kernel/optimization.ts +183 -4
  107. package/packages/core/src/kernel/phase-failures.ts +121 -0
  108. package/packages/core/src/kernel/published-branch-head.ts +60 -0
  109. package/packages/core/src/kernel/read-facts.ts +15 -13
  110. package/packages/core/src/kernel/reducer-registry.ts +27 -8
  111. package/packages/core/src/kernel/reducer-revisions.ts +27 -0
  112. package/packages/core/src/kernel/reducer.ts +63 -4
  113. package/packages/core/src/kernel/rollup.ts +61 -0
  114. package/packages/core/src/kernel/setup-streak.ts +38 -0
  115. package/packages/core/src/kernel/step-durations.ts +257 -0
  116. package/packages/core/src/kernel/target-observation.ts +6 -1
  117. package/packages/core/src/kernel/target-rewrite-recovery.ts +116 -0
  118. package/packages/core/src/kernel/verify-diff-base.ts +5 -0
  119. package/packages/core/src/kernel/verify-stages.ts +13 -3
  120. package/packages/core/src/ontology.ts +5 -0
  121. package/packages/core/src/operator/agent-context-serve.ts +631 -0
  122. package/packages/core/src/operator/annotations.ts +75 -5
  123. package/packages/core/src/operator/attention.ts +470 -0
  124. package/packages/core/src/operator/canonical-skills.ts +35 -0
  125. package/packages/core/src/operator/cli-equivalents.ts +270 -0
  126. package/packages/core/src/operator/context-prompts.ts +61 -0
  127. package/packages/core/src/operator/index.ts +49 -1
  128. package/packages/core/src/operator/landings.ts +28 -19
  129. package/packages/core/src/operator/optimization.ts +7 -0
  130. package/packages/core/src/operator/protocol.ts +3 -0
  131. package/packages/core/src/operator/query.ts +129 -74
  132. package/packages/core/src/operator/read-view.ts +5 -2
  133. package/packages/core/src/operator/registry.ts +406 -46
  134. package/packages/core/src/operator/requests.ts +20 -18
  135. package/packages/core/src/operator/sandbox-host.ts +107 -11
  136. package/packages/core/src/operator/sandbox-resolver.ts +253 -0
  137. package/packages/core/src/operator/sandbox.ts +778 -82
  138. package/packages/core/src/operator/ticket-asset-list.ts +77 -0
  139. package/packages/core/src/operator/ticket-assets.ts +167 -0
  140. package/packages/core/src/operator/tickets.ts +33 -2
  141. package/packages/core/src/plugin-sdk/index.ts +22 -0
  142. package/packages/core/src/plugins/manifest.ts +1 -1
  143. package/packages/core/src/ports/forge/fake.ts +92 -1
  144. package/packages/core/src/ports/forge/git-blob.ts +15 -0
  145. package/packages/core/src/ports/forge/github.ts +82 -0
  146. package/packages/core/src/ports/forge/local-git.ts +61 -1
  147. package/packages/core/src/ports/forge-failure.ts +24 -0
  148. package/packages/core/src/ports/runner/antigravity-test.fixture.ts +149 -0
  149. package/packages/core/src/ports/runner/claude-test.fixture.ts +71 -0
  150. package/packages/core/src/ports/runner/codex-test.fixture.ts +63 -0
  151. package/packages/core/src/ports/tickets/contract.ts +71 -0
  152. package/packages/core/src/ports/tickets/fake.ts +11 -0
  153. package/packages/core/src/ports/tickets/file.ts +18 -0
  154. package/packages/core/src/ports/tickets/github-fake.ts +136 -4
  155. package/packages/core/src/ports/tickets/github.ts +387 -30
  156. package/packages/core/src/ports/tickets/hosted-index.ts +10 -0
  157. package/packages/core/src/ports/tickets/linear.ts +130 -0
  158. package/packages/core/src/ports/tickets/priority.ts +9 -0
  159. package/packages/core/src/ports/tickets/remote-protocol.ts +34 -0
  160. package/packages/core/src/ports/tickets/remote.ts +70 -6
  161. package/packages/core/src/ports/tickets/search.ts +139 -0
  162. package/packages/core/src/ports/types.ts +104 -2
  163. package/packages/core/src/ports/workspace/builtin-capabilities.ts +9 -0
  164. package/packages/core/src/ports/workspace/create.ts +15 -1
  165. package/packages/core/src/ports/workspace/fake.ts +340 -12
  166. package/packages/core/src/ports/workspace/git-worktree.ts +833 -42
  167. package/packages/core/src/ports/workspace/operator-sandbox.ts +129 -12
  168. package/packages/core/src/ports/workspace/process-group.ts +48 -0
  169. package/packages/core/src/ports/workspace/vercel-sandbox.ts +1260 -123
  170. package/packages/core/src/processes/agent-context-assemble.ts +576 -0
  171. package/packages/core/src/processes/agent-context.ts +469 -0
  172. package/packages/core/src/processes/build-runner.ts +387 -236
  173. package/packages/core/src/processes/dispatcher.ts +211 -55
  174. package/packages/core/src/processes/execution-no-progress.ts +4 -0
  175. package/packages/core/src/processes/optimization-activity.ts +120 -0
  176. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  177. package/packages/core/src/processes/repo-view.ts +78 -2
  178. package/packages/core/src/processes/sandbox-state.ts +53 -6
  179. package/packages/core/src/processes/tick-publication.ts +2 -0
  180. package/packages/core/src/processes/workspace-preparation.ts +76 -0
  181. package/packages/core/src/scenarios/harness.ts +0 -5
  182. package/packages/core/src/store/account-redaction.ts +1 -0
  183. package/packages/core/src/store/adapter.ts +52 -1
  184. package/packages/core/src/store/agent-context.ts +432 -0
  185. package/packages/core/src/store/build-feed.ts +291 -0
  186. package/packages/core/src/store/build-scope.ts +19 -1
  187. package/packages/core/src/store/contract.ts +911 -14
  188. package/packages/core/src/store/digest.ts +19 -6
  189. package/packages/core/src/store/histogram.ts +113 -0
  190. package/packages/core/src/store/local/schema.ts +62 -0
  191. package/packages/core/src/store/local/store.ts +628 -22
  192. package/packages/core/src/store/local/ticket-asset-heads.ts +23 -0
  193. package/packages/core/src/store/memory.ts +461 -69
  194. package/packages/core/src/store/open-builds.ts +19 -0
  195. package/packages/core/src/store/phase-session.ts +32 -4
  196. package/packages/core/src/store/reduced-reads.ts +14 -4
  197. package/packages/core/src/store/reducer-value-shapes.json +7027 -5751
  198. package/packages/core/src/store/reducer-values.ts +6 -1
  199. package/packages/core/src/store/remote/client.ts +208 -2
  200. package/packages/core/src/store/remote/compatibility.ts +1 -1
  201. package/packages/core/src/store/remote/index.ts +33 -0
  202. package/packages/core/src/store/remote/protocol.ts +69 -0
  203. package/packages/core/src/store/remote/released-clients.json +22 -0
  204. package/packages/core/src/store/remote/released-reducer-values/1.11.0.json +35680 -0
  205. package/packages/core/src/store/remote/released-reducer-values/1.11.1.json +35718 -0
  206. package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
  207. package/packages/core/src/store/retention.ts +23 -1
  208. package/packages/core/src/store/rollups.ts +337 -0
  209. package/packages/core/src/store/session-handle.ts +20 -2
  210. package/packages/core/src/store/snapshots.ts +10 -0
  211. package/packages/core/src/store/types.ts +108 -9
  212. package/packages/core/src/testing/dispatch-journals.ts +117 -0
  213. package/packages/core/src/testing/dispatch-read-budget.ts +1092 -2
  214. package/packages/core/src/testing/git-config-isolation.ts +7 -5
  215. package/packages/core/src/testing/index.ts +27 -0
  216. package/packages/core/src/testing/memory-operator-sandbox.ts +346 -0
  217. package/packages/core/src/testing/reduced-read-budget.ts +1873 -98
  218. package/packages/core/src/web/analytics-source.ts +303 -0
  219. package/packages/core/src/web/assets/Atkinson-OFL.txt +93 -0
  220. package/packages/core/src/web/assets/AtkinsonHyperlegibleNext.latin.woff2 +0 -0
  221. package/packages/core/src/web/assets/JetBrains-OFL.txt +93 -0
  222. package/packages/core/src/web/assets/JetBrainsMono.latin.woff2 +0 -0
  223. package/packages/core/src/web/assets/app.css +1 -0
  224. package/packages/core/src/web/assets/app.js +9 -0
  225. package/packages/core/src/web/assets/manifest.json +31 -0
  226. package/packages/core/src/web/assets/theme.js +1 -0
  227. package/packages/core/src/web/bounded.ts +31 -0
  228. package/packages/core/src/web/http.ts +315 -0
  229. package/packages/core/src/web/hub.ts +160 -0
  230. package/packages/core/src/web/options.ts +38 -0
  231. package/packages/core/src/web/overview-source.ts +322 -0
  232. package/packages/core/src/web/page.ts +56 -0
  233. package/packages/core/src/web/protocol.ts +151 -0
  234. package/packages/core/src/web/read-only.ts +23 -0
  235. package/packages/core/src/web/repository-source.ts +39 -0
  236. package/packages/core/src/web/server.ts +97 -0
  237. package/skills/code-review/SKILL.md +10 -2
  238. package/skills/guide/SKILL.md +376 -54
  239. package/skills/guide/references/accounts.md +2 -1
  240. package/skills/guide/references/integration-tree.md +2 -2
  241. package/skills/guide/references/operator-api.md +134 -6
  242. package/skills/guide/references/optimization-nodes.md +69 -11
  243. package/skills/guide/references/plugin-authoring.md +37 -1
  244. package/skills/guide/references/remote-store-protocol.md +94 -13
  245. package/skills/guide/references/remote-ticket-protocol.md +40 -0
  246. package/skills/guide/references/restacking.md +20 -4
  247. package/skills/guide/references/setup.md +14 -2
  248. package/skills/guide/references/ticket-dependencies.md +10 -3
  249. package/skills/implement/SKILL.md +23 -4
  250. package/skills/operate/SKILL.md +134 -32
  251. package/skills/plan/SKILL.md +10 -4
  252. package/skills/plan-review/SKILL.md +9 -2
  253. package/skills/spec/SKILL.md +34 -8
  254. package/skills/tickets/SKILL.md +51 -5
  255. package/templates/hosted-service/package.json +2 -2
@@ -27,7 +27,9 @@ bun ab dispatch --viewer --dispatched-by app.autobuild.run
27
27
 
28
28
  The optional label is descriptive input. Every frame says `viewer · dispatched by
29
29
  <label>`, or simply `viewer` when omitted. Plain/non-TTY output states the mode
30
- at startup and prints state changes. `--once` reads one snapshot; `--interval <s>`
30
+ at startup and prints state changes. With `--web`, a TTY viewer shows the web UI's
31
+ URL at the right of its `viewer` line, and plain/non-TTY output prints only the URL
32
+ and the web UI is the presentation. `--once` reads one snapshot; `--interval <s>`
31
33
  sets the polling cadence. Without a recorded configuration it waits for the dispatcher.
32
34
 
33
35
  The viewer takes no repository lease and starts no build, harvest, scan, janitor,
@@ -37,8 +39,9 @@ intake and harvest gates, harvest resume/acknowledgement, queued discard and
37
39
  confirmed abort. Navigation and session inspection work as usual. These record
38
40
  operator intent for the dispatcher to execute. No current control needs a local
39
41
  dispatcher. Startup intake flags and `--repository` are rejected; use a local
40
- checkout with its configured Store or `--store`. Operator agents still must not
41
- run `ab dispatch`, including `--viewer`.
42
+ checkout with its configured Store or `--store`. Operator agents follow the
43
+ [dispatcher ownership boundaries](#dispatcher-ownership) for startup and process
44
+ management; `ab web` is always available for read-only viewing.
42
45
 
43
46
  ## Ready work becomes a build
44
47
 
@@ -64,7 +67,7 @@ A free slot goes, in order, to:
64
67
  4. normal parked work;
65
68
  5. normal ticket claims: `ab start --priority normal` requests, then normal ready tickets.
66
69
 
67
- Each tier keeps its usual order, start requests oldest first. A pending start request reserves its slot ahead of the tiers below it until it settles or is cancelled. A build takes its ticket's priority when it is claimed; a build started by an `urgent` request is urgent, and `manual` never becomes a build priority. `ab priority <slug> urgent|normal` (or the `builds.control` action `priority`) changes an active build's priority, for example to expedite a waiting reconcile that now blocks other work; it never changes the ticket. While urgent tickets are ready, normal parked work waits for a slot until the dispatcher has offered urgent tickets the free slots that tick. An urgent ticket blocked on a dependency reserves nothing. Priority orders free slots only: it never interrupts a running build. `ab repository status`, `ab builds` and both dashboards mark urgent waiters, pending start requests by tier and urgent ticket claims waiting ahead of normal parked work.
70
+ Each tier keeps its usual order, start requests oldest first. A pending start request reserves its slot ahead of the tiers below it until it settles or is cancelled. An ordinary build takes its ticket's priority when it is claimed; a build started by an `urgent` request is urgent, and `manual` never becomes a build priority. An [optimization node's attempts](optimization-nodes.md#attempts) claim at the node's current priority instead: a later `ab priority` on the node affects attempts claimed afterwards, while an already claimed attempt keeps its build priority. `ab priority <slug> urgent|normal` (or the `builds.control` action `priority`) changes an active build's priority, for example to expedite a waiting reconcile that now blocks other work; it never changes the ticket. While urgent tickets are ready, normal parked work waits for a slot until the dispatcher has offered urgent tickets the free slots that tick. An urgent ticket blocked on a dependency reserves nothing. Priority orders free slots only: it never interrupts a running build. `ab repository status`, `ab builds` and both dashboards mark urgent waiters, pending start requests by tier and urgent ticket claims waiting ahead of normal parked work.
68
71
 
69
72
 
70
73
  ## The log is the source of truth
@@ -80,6 +83,33 @@ State is reduced from those events; a snapshot is only a cache.
80
83
  Agents report through the typed `ab` CLI (`ab done`, `ab verdict`), not their output; code validates the deposit, applies the gates and records the transition.
81
84
 
82
85
 
86
+ ## Repository agent context
87
+
88
+ Every dispatcher, in checkout or origin mode, keeps a record of the repository's agent context in the store. It reads the committed tree at the base-branch head through the forge, never the working copy, so both modes record identical content for the same commit.
89
+
90
+ | Captured | Selection |
91
+ | --- | --- |
92
+ | Skills | Every directory under `.agents/skills/` or `.claude/skills/` holding a `SKILL.md`, with all its files: shipped, customized and repository-local skills alike. Symlinked or byte-identical copies appear once with every install path; dot-directories such as `.ab-pristine` are skipped. |
93
+ | Instructions | Every `AGENTS.md` and `CLAUDE.md`, root and nested. The two collapse into one entry per directory when identical. |
94
+ | Imports | Files the instructions import by `@path`, followed transitively, stored as separate entries. Paths outside the repository are listed as omitted. |
95
+
96
+ - **Revisions.** The record is a repository artifact, `agent-context`. A new revision is written only when the captured content changes, not on every base-branch commit. It is retention-managed like the dispatcher's run and config artifacts: the newest 200 revisions survive (`AB_ARTIFACT_RETENTION_MAX_REVISIONS` overrides the bound).
97
+ - **Pacing.** Each dispatcher process checks the base head on its first tick, then at most once a minute. An unchanged head reads no tree, blob, record or event. A capture cut short by an invocation deadline keeps the bytes it fetched and resumes on the next invocation.
98
+ - **Bounds.** A record over 2.25 MiB encoded (`oversize`) or 32 MiB uncompressed (`raw-oversize`) is not written. The last good revision stays, and the diagnostic names the largest contributors.
99
+ - **Scope.** The dispatcher captures only. Connected agents read the record through the [agent-context tools and prompts](operator-api.md#agent-context).
100
+
101
+ `ab dispatch` prints each diagnostic once:
102
+
103
+ | Diagnostic | Meaning | Next attempt |
104
+ | --- | --- | --- |
105
+ | `oversize`, `raw-oversize` | Bound exceeded; last good revision kept | When the base head moves |
106
+ | `tree-unlistable` | The forge cannot list a directory completely; last good revision kept | When the base head moves |
107
+ | `capture-failed` | Unexpected read or write failure | After five minutes, or when the base head moves |
108
+ | `unavailable` | The forge cannot read trees or blobs | None; dispatching continues |
109
+
110
+ A repository with no base branch yet has nothing to capture and reports nothing.
111
+
112
+
83
113
  ## Resume the work, not the chat
84
114
 
85
115
  A restart loses nothing. The dispatcher continues each build from its recorded phase, completed boundaries, artifacts and feedback, even in a replacement sandbox. Authority boundaries hold:
@@ -117,3 +147,33 @@ startup reports it as a repository resolution error naming its cause, and
117
147
  neither explicit mode bypasses it. Origin mode (`--repository` or
118
148
  `AB_REPOSITORY`) and hosted cron dispatch bypass this check. Placement is a startup snapshot, not a
119
149
  liveness probe or a polling input.
150
+
151
+ ## Dispatcher ownership
152
+
153
+ Read `ab repository status --json` before starting a dispatcher. The shared
154
+ `dispatcherRunning` field (also in the `repository.status` operator tool) is true
155
+ when a holder, expired holder or unfinished handoff names a draining predecessor.
156
+ An empty drain map does not prove retirement. Missing or unreadable running
157
+ status fails closed: never start while running or while that fact is unknown.
158
+
159
+ `ab operator dispatcher --json` reads the checkout's preference; save a choice
160
+ with `ab operator dispatcher human` or `ab operator dispatcher agent`. The optional
161
+ `[operator] dispatcher = "human" | "agent"` lives only in `.autobuild/local.toml`;
162
+ no choice is assumed when unset. Even an empty `[operator]` is rejected in
163
+ `autobuild.toml`. Saving preserves other settings semantically and may normalize
164
+ TOML formatting. It needs no store or credential, writes no event, and is refused
165
+ inside build or harvest sessions. Reading a missing local file creates nothing.
166
+
167
+ Repository instructions take precedence. With none running, follow the saved
168
+ preference or ask who should run it and offer to save the answer. For human
169
+ ownership, give startup instructions and wait. For agent ownership, start
170
+ `ab dispatch --web --plain --json` under the harness's managed background lifetime
171
+ and give the person its URL. Stop only a dispatcher this session started, only
172
+ when requested, using a clean stop with drain. Never adopt, restart, kill or manage
173
+ another session's process; a preference does not authorize takeover.
174
+
175
+ `ab web [--json]` is always allowed, even while a dispatcher exists: it serves a
176
+ read-only UI without acquiring a dispatcher lease. `ab dispatch --web` serves the
177
+ same UI alongside dispatch; `--plain` keeps the URL on stdout and diagnostics on
178
+ stderr; a TTY dashboard keeps it on its top line. Both default to loopback. Serving beyond loopback has no access control;
179
+ see [operator surfaces](operator-surfaces.md) for binding and refresh details.
package/docs/forges.md CHANGED
@@ -109,6 +109,13 @@ An adapter must provide:
109
109
 
110
110
  Reconciliation needs the optional `Forge.rewrite` group: immutable exact-SHA archives, branch snapshots and head-guarded replacement. Archives are best effort: throw a plain error for a refusal (the kernel keeps a BuildStore copy instead) and `ArchiveConflictError` when the immutable ref names a different SHA. Report lease mismatches separately and preserve unknown work. Without it, reconciliation fails with an actionable refusal, never an ordinary push.
111
111
 
112
+ [Repository agent context](dispatcher.md#repository-agent-context) capture needs `remoteBranchSha` and two optional read capabilities:
113
+
114
+ - `readTree(commit)` returns the commit's complete recursive tree, directories included, each entry with its object id and each blob with its exact byte size. Never return a partial listing: throw `ForgeTreeUnlistable` (SDK, with `isForgeTreeUnlistable`) naming the directory you cannot list completely.
115
+ - `readBlob(oid)` returns the blob's exact bytes, verified against `oid`.
116
+
117
+ Without them the dispatcher still dispatches; it reports `unavailable` once and captures no agent context.
118
+
112
119
  Classify failures with `ForgeFailure` (API 1.8):
113
120
 
114
121
  ```ts
@@ -202,7 +202,7 @@ A node becomes an optimization node when its spec carries exactly one fenced
202
202
  block whose info string is exactly `autobuild-objective`, holding a TOML
203
203
  objective: a purpose, a command metric with a direction or a judge panel, a
204
204
  harness of path selectors, an epsilon, and a budget of `maxAttempts`,
205
- `maxHours` or both. A threshold and a plateau are optional; the stop mode
205
+ `maxHours` (active hours, not wall-clock time) or both. A threshold and a plateau are optional; the stop mode
206
206
  defaults to `abort` and proposer concurrency to 1. The ticket's kind stays
207
207
  `node`; no label or state marks it. A heading named "Objective", a `toml` block,
208
208
  prose, inline code, a fence nested inside another fence (a Markdown example of
@@ -232,7 +232,7 @@ effective objective and marks each field that differs from the ticket's block
232
232
 
233
233
  Progress is derived from the node's log: starting value and noise spread,
234
234
  current and best values, attempts filed, accepted, rejected and running, the
235
- plateau counter, elapsed hours and attempts against the budget, and stop
235
+ plateau counter, active hours and attempts against the budget, and stop
236
236
  eligibility by threshold, plateau and budget. A child is an attempt only when
237
237
  its ticket was created from a recorded proposal of the node; a repair child
238
238
  filed by hand counts toward neither budget nor plateau. Rejected attempts are
package/docs/operating.md CHANGED
@@ -10,8 +10,8 @@ order: 6
10
10
 
11
11
  Your operator agent keeps work moving through `ab` or MCP. Under your instructions it writes specs, files and grooms tickets, operates the builds the repository's dispatcher dispatches, answers bounded escalations, pauses or aborts work, and authorizes merge.
12
12
 
13
- - **You own** goals, scope, tradeoffs and authority, and you run the dispatcher and upgrades.
14
- - **The agent never** starts, stops or restarts dispatch; it reports dispatcher trouble to you.
13
+ - **You own** goals, scope, tradeoffs, authority and upgrades. Dispatcher ownership is a local preference, subject to repository instructions.
14
+ - **The agent checks** fresh running status before startup and follows your saved preference, or asks who should run the dispatcher and offers to save the answer. With agent ownership it starts `ab dispatch --web --plain --json` and gives you the URL. It cleanly stops only a dispatcher this session started, only on request; it never adopts, restarts, kills or manages another session's dispatcher. See [dispatcher ownership](dispatcher.md#dispatcher-ownership).
15
15
  - **Autobuild doesn't** host or start the agent. There's no orchestrator setup step.
16
16
 
17
17
  ## Choose a harness
@@ -19,6 +19,8 @@ Your operator agent keeps work moving through `ab` or MCP. Under your instructio
19
19
  - **A local coding agent** at the repository root with the installed `ab-operate` skill, using the CLI or `bun ab mcp` (operator tools over stdio).
20
20
  - **An API client** using the authenticated [Operator API contract](operator-api.md).
21
21
 
22
+ An agent connected over MCP has no checkout of its own. It calls `context.list` first, then loads `ab-operate` and the repository's agent instructions with `context.read` or the matching MCP prompt; see [agent context](operator-api.md#agent-context).
23
+
22
24
  We recommend the same model as your reviewer roles, since the agent interprets findings and escalation answers.
23
25
 
24
26
  ## Give the agent memory
@@ -90,7 +90,7 @@ raw session-event append. External operator harnesses own agent execution.
90
90
  | `GET …/builds/{slug}/artifacts/{kind}?rev=N` | Raw bytes (`application/octet-stream`) plus content-disposition and `X-Autobuild-Artifact-*` metadata headers. Omit `rev` for latest. |
91
91
  | `GET …/tickets?state=S&label=L&limit=N&offset=K&order=O` | `{states,tickets,diagnostics,criteria,triageState,readyState,doneState,total}`. The three lifecycle names come from effective repository configuration (including provider fallback). With no `state`, `criteria.state` is `triageState`; repeated `label` parameters narrow that state with AND filters. An explicit `state` selects that exact backend workflow state. `limit` (0–200) returns one page, after skipping `offset`, in `order` `oldest` (the default: dispatch order, urgent tickets first, then the source order) or `newest` (newest filed first, regardless of urgency; see paging below); `total` counts every match before paging. |
92
92
  | `GET …/tickets/states` | Full state metadata `{name,tickets,about?}[]`, including empty states (`tickets.states` in MCP). |
93
- | `GET …/tickets/{id}` | `{ticket,blockers,build}`. Blockers include native `exists`/`resolved` status; `build` prefers an active matching repository build, otherwise the most recently updated one. |
93
+ | `GET …/tickets/{id}` | `{ticket,blockers,build,assets}`. Blockers include native `exists`/`resolved` status; `build` prefers an active matching repository build, otherwise the most recently updated one. `assets` lists the current ticket assets as `{kind,name,revision,size,layout,fileCount}`, as `ab ticket show --json` does. |
94
94
 
95
95
  For artifact reads, an absent `rev` selects the latest revision. A supplied value
96
96
  must match `[0-9]+` (one or more ASCII base-10 digits) and represent an integer
@@ -146,6 +146,7 @@ Answer variants:
146
146
  {"resolution":"guidance","text":"…"}
147
147
  {"resolution":"retry"}
148
148
  {"resolution":"dismiss","text":"optional audit text"}
149
+ {"resolution":"accept-target","text":"optional audit text"}
149
150
  {"resolution":"review-round-ceiling","ceiling":4,"text":"optional guidance"}
150
151
  {"resolution":"revise-spec","origin":"body","body":"replacement spec","text":"optional guidance"}
151
152
  {"resolution":"revise-spec","origin":"ticket","body":"current amended ticket body","text":"optional guidance"}
@@ -190,11 +191,78 @@ closed table `ab mcp` serves over stdio): the body is the tool's validated input
190
191
  included and required to equal the URL's repository — and the response is the
191
192
  registry result verbatim. The verified operator token supplies the acting
192
193
  identity and, when minted with one, the `via` attribution marker; the body
193
- never does. Failures keep the shared `{kind,error,code?,progress?}` shape:
194
+ never does. Failures keep the shared `{kind,error,code?,progress?,state?}` shape
195
+ (`state` names the sandbox lifecycle state on a `sandbox-not-ready` refusal):
194
196
  validation is `400`, auth `403`, not-found `404`, conflict and refusal `409`,
195
197
  internal `500`. The route adds no authority of its own — it is the registry
196
- behind the token check — so a tool available here is exactly the tool table,
197
- and the table's contract suite is the single gate.
198
+ behind the token check — so a tool available here is exactly the deployment's
199
+ served table, and the table's contract suite is the single gate. The hosted
200
+ `/mcp` binding advertises that same table. Sandbox tools are in it when the
201
+ deployment can host operator sandboxes, and each call is gated per repository
202
+ on the latest deposited effective config. A closed gate is a `409 refusal`
203
+ with code `sandbox-orchestrator-disabled`, `sandbox-no-effective-config`,
204
+ `sandbox-effective-config-invalid`, `sandbox-credentials-missing` or
205
+ `sandbox-backend-unavailable`.
206
+
207
+ ### Per-repository MCP URLs
208
+
209
+ Beside the deployment-wide `/mcp`, each registered project has its own MCP
210
+ URL. Adding it to an agent harness connects that harness to one repository.
211
+
212
+ | | `/mcp` | `/mcp/<host><path>` |
213
+ |---|---|---|
214
+ | URL | `<resource>` | `<resource>/<host><path>`, e.g. `https://ops.example/mcp/github.com/acme/widgets` for `https://github.com/acme/widgets` |
215
+ | Tool schemas | every tool requires `repo` | no `repo` field; the URL's repository is supplied |
216
+ | `repositories.list` | offered | not offered |
217
+ | A `repo` argument | names the repository | equal to the URL's repository is ignored; any other is a `validation` result |
218
+ | `sandbox.*` listed | when the deployment can host sandboxes | also needs the repository's latest deposited effective config to enable `[orchestrator]` (one latest-artifact read per listing) |
219
+ | Instructions | describe the deployment, with each accessible repository's agent context | name only that repository, with its agent context |
220
+ | Prompts | one per skill per accessible repository, `<label>.<skill>` | one per skill, named for the skill |
221
+
222
+ `<resource>` is `AB_WEB_MCP_RESOURCE`, by default `<origin>/mcp`. The URL is
223
+ derived from the repository identity, so it is stable across deploys and
224
+ sign-ins, and only its canonical spelling is served: a trailing slash, `.git`
225
+ or an encoded character is `404`. An unregistered project, or one the signed-in
226
+ operator cannot reach, is also `404`, checked after authentication. Admission
227
+ and repository access are rechecked on every tool call, and writes carry the
228
+ same operator and `via` attribution as `/mcp`.
229
+
230
+ OAuth is discovered from the URL alone. Its protected-resource metadata lives at
231
+ the RFC 9728 path-inserted location,
232
+ `<origin>/.well-known/oauth-protected-resource/mcp/<host><path>`, and names the
233
+ per-repository URL as its `resource`. The token endpoint honors RFC 8707
234
+ `resource`:
235
+
236
+ - A token issued for a per-repository URL is accepted only there. At another
237
+ project's URL or at `/mcp` it gets `401` with `error="invalid_token"`, so
238
+ the client signs in again for that URL.
239
+ - A token issued for `/mcp`, or without a `resource`, is accepted at every URL.
240
+ - Refreshing a per-repository token keeps its resource, whether the refresh
241
+ omits `resource` or names `/mcp`. Naming another per-repository URL on that
242
+ refresh is refused with `invalid_target`.
243
+ - Refreshing a `/mcp` or resource-less token may name one per-repository URL.
244
+ The new token is then bound to that URL only.
245
+ - Any request naming a resource this deployment does not serve is refused
246
+ with `invalid_target`.
247
+
248
+ ### Agent context
249
+
250
+ `context.list` and `context.read` are registry tools, so they appear on both
251
+ endpoints and on this route. They serve the repository's captured skills and
252
+ agent instructions, or the canonical skills bundled with the serving Autobuild
253
+ when none are captured. Each read prepends a generated preamble mapping the `ab`
254
+ commands the file mentions to tools; agent instructions are framed as the
255
+ repository's own rules.
256
+
257
+ - Both endpoints expose one MCP prompt per skill whose message is the
258
+ `context.read` text of its `SKILL.md`. On `/mcp` the name is
259
+ `<label>.<skill>`, where `<label>` is the identity without its scheme and
260
+ with every character outside `[A-Za-z0-9_-]` as `_`; colliding names gain a
261
+ `~<hash>` suffix. An unknown name is `InvalidParams`.
262
+ - The agent-context section of the server instructions is built only for an
263
+ `initialize` request: one latest-revision record read per repository in
264
+ scope. `tools/list`, `tools/call` and other requests read nothing for it, and
265
+ prompt indexes load only for `prompts/list` and `prompts/get`.
198
266
 
199
267
  ### Success results
200
268
 
@@ -207,7 +275,8 @@ Build control returns one of:
207
275
  a blocked build. This is a successful prompt transition but **does not append
208
276
  an event**; submit one of the answer requests next.
209
277
  - `{kind:"answered",slug,count,resolution,resumed,...}` from the answer route.
210
- `resolution` is `guidance`, `retry`, `dismiss-finding`, or `revise-spec`.
278
+ `resolution` is `guidance`, `retry`, `dismiss-finding`, `revise-spec`, or
279
+ `accept-target` (answers only a leaf's target-rewritten escalation).
211
280
  Depending on the operation, the result also includes `remainingOpen`,
212
281
  `reviewRoundCeiling:{loop,value}`, `specRev`, `authorizedEarlier`, or a
213
282
  `terminalSignal` describing a terminal status, pending abort, or ended PR.
@@ -299,7 +368,8 @@ The default watch reports actionable conditions only:
299
368
  - `dispatcher.forge-degraded`: the dispatcher's own rate-limit cooldown opened, with its reset; once per episode. Extensions marked `continued` are silent.
300
369
  - `dispatcher.forge-persistent`: forge degradation remains after a completed post-reset retry opportunity; successful recovery clears it.
301
370
 
302
- - Build `escalation.raised`, `integration.landed`, `node.item-conflicted`, `target.rewritten`,
371
+ - Build `escalation.raised`, `integration.landed`, `node.item-conflicted`,
372
+ `target.rewritten` (a node's, once per rejected base; a leaf recovers or escalates),
303
373
  `landing.consent-revoked` (protected merge consent revoked by a reconcile's
304
374
  edits, naming the matched files and both heads),
305
375
  `pr.checks-failed` (failing forge CI at a finished leaf's live PR head, once
@@ -428,6 +498,27 @@ repository records the CLI default watch reports, or every event with
428
498
  advances past filtered events. Omitting `cursor` returns no events and a
429
499
  baseline cursor; an expired cursor fails with `code: "cursor-too-old"`.
430
500
 
501
+ The MCP `repository.attention` tool is a connected agent's first call of each
502
+ operator round. It takes `{repo, cursor?}` and returns everything currently
503
+ waiting on the operator:
504
+
505
+ | Section | Contents |
506
+ |---|---|
507
+ | `escalations` | Open builds with open escalations, as `builds.get` reports them; wait-only builds are excluded |
508
+ | `merges` | The `merges.list` entries, each with its build's PR |
509
+ | `events` | The `repository.events` attention page after `cursor`: `{items, cursor, hasMore}` |
510
+ | `waiting` | Builds `paused`, `stalled`, failing node verification (`verification-failed`) or failing forge CI (`ci-failing`), each with a `detail` |
511
+ | `dispatcher` | No holder, a current upgrade failure, a rollback hold or a forge cooldown, from `repository.status` |
512
+
513
+ Every item carries `resolve: [{tool, input, by, note?}]`, primary first: a real
514
+ registry tool and a partial input. `by: "human"` marks a condition no agent call
515
+ fixes; the named tool reads the evidence to report. Cursor rules match
516
+ `repository.events`: an omitted cursor returns no events and a baseline cursor
517
+ beside every current-state section, and an expired cursor fails with
518
+ `code: "cursor-too-old"`. The call never waits. Its cost is bounded: one open-build
519
+ listing pass, the `repository.status` reads and at most 256 journal positions,
520
+ with zero event rows when nothing changed.
521
+
431
522
 
432
523
  Hosted ticket tools resolve independent project ticket policy, including its
433
524
  backlog and rejected roles for role moves, before legacy uploaded configuration. Queue, detail, state discovery and mutations work before any build
@@ -537,6 +628,33 @@ blocked (use `builds.answer`) are refused with `not-reopenable`; a pending abort
537
628
  or discard is refused with `abort-pending` or `discard-pending`. Ownership is
538
629
  enforced. The tool has no HTTP route.
539
630
 
631
+ ### Ticket assets
632
+
633
+ Three tools carry the `ab ticket attach`, `ab ticket asset get` and
634
+ `ab ticket asset rm` surface; `tickets.get` lists the current assets. Bytes
635
+ cross the wire as strict, padded standard base64 (`""` is an empty file).
636
+
637
+ | Tool | Input | Receipt |
638
+ |---|---|---|
639
+ | `tickets.asset.attach` | `{repo, id, kind, name, layout, entries}`; `layout` is `file` (exactly one file entry) or `tree` (a folder, possibly empty); each entry is `{type:"file", path, contentBase64}` or `{type:"dir", path}` | `{asset, replaced, activeBuilds, noteError?}`: `asset` is the stored revision's metadata as `ab ticket attach --json` prints it |
640
+ | `tickets.asset.get` | `{repo, id, kind, name, rev?}`; without `rev`, the latest revision | `{asset, entries}`: entries in manifest order, each `{type:"file", path, size, contentBase64}` or `{type:"dir", path}` |
641
+ | `tickets.asset.remove` | `{repo, id, kind, name}` | `{removed, activeBuilds, noteError?}`: the metadata of the revision that was current |
642
+
643
+ - **Same rules as the CLI.** Each attach stores a new revision; earlier
644
+ revisions, including those of a removed asset, stay readable by `rev`. The
645
+ store's limits apply (25 MiB of file bytes by default).
646
+ - **Failures.** A naming, path, layout or size violation is `validation` with
647
+ code `ticket-asset-invalid`, and stores nothing. An unknown ticket, a missing
648
+ asset or revision, or removing an asset with no current revision is
649
+ `not-found`.
650
+ - **Notes.** Attach and remove leave a note on the ticket after the store
651
+ write. A failed note does not fail the call: the receipt carries `noteError`,
652
+ and retrying an attach would store another revision.
653
+ - **Active builds.** `activeBuilds` names the ticket's running builds; each
654
+ keeps the assets it froze at the claim.
655
+ - Attach and remove require an attributed identity; `tickets.asset.remove` is
656
+ annotated destructive. The tools have no HTTP route.
657
+
540
658
  ### Node restack request
541
659
 
542
660
  `builds.restack` accepts `{repo, slug}`. `POST /operator/v1/repos/:repo/builds/:slug/restack`
@@ -754,3 +872,13 @@ proof of provider success. A clear appends once without reading history, even
754
872
  when already healthy; later degradation wins by ordinary journal order.
755
873
  Existing dispatcher/kernel automatic recovery and old payloads remain valid;
756
874
  the recovered payload additionally accepts an optional nonblank `reason`.
875
+
876
+ ### Dispatcher running evidence
877
+
878
+ `repository.status` returns required `dispatcherRunning`: true for a lease holder,
879
+ an expired holder, or an unfinished handoff naming a draining predecessor (even
880
+ with an empty drain map). This uses already loaded projections without extra reads.
881
+ Missing or unreadable status is not permission to start. Ownership is local-only:
882
+ `ab operator dispatcher [human|agent] [--json]` reads/saves the optional preference
883
+ in `.autobuild/local.toml`; there is no remote preference endpoint. Repository
884
+ instructions take precedence. See `ab-operate` for ownership and clean-stop limits.
@@ -63,6 +63,42 @@ readyState = "ready"
63
63
 
64
64
  `bun ab connect https://builds.example.com` approves the registered project and saves its credential outside the checkout; CI sets `AB_TOKEN` instead. It authorizes the project only, not forge or runtime access. See [Build store](build-store.md).
65
65
 
66
+ ### Web UI (`ab web`)
67
+
68
+ ```sh
69
+ bun ab web
70
+ ```
71
+
72
+ - Read-only: it appends no event, takes no dispatcher lease and registers no operator presence.
73
+ - Binds `127.0.0.1` on a free port (`--port` picks one) and refuses requests whose Host is not loopback or the bound address.
74
+ - `--host <addr>` serves beyond loopback with no access control; `ab web` warns that anyone who can reach the port can read the repository's builds.
75
+ - `--json` prints one line, `{"url":"http://127.0.0.1:<port>/"}`, for agents that open or hand off the page.
76
+ - Reads nothing from the store while no browser is connected; open tabs share one refresh loop.
77
+ - While idle, each poll reads only the repository change position.
78
+ - A fresh process starts the overview from the build roster. It reads each live build plus each aborted build among the roster's 10 newest finished builds, to show aborts still cleaning up. An older abort still cleaning up appears at its next change. Startup never scans history.
79
+ - A build change reads that build only, plus one roster read when a build starts, finishes or aborts. The overview never lists builds, and nothing reads event history.
80
+ - A remote store server too old to serve the roster, the changed-builds feed or the filtered listing fails the read with a typed error instead of falling back.
81
+ - Pages:
82
+ - The overview (`/`) shows the dispatcher's mode, capacity, what needs attention, and active, queued and recently finished builds. Each row links to its build page.
83
+ - A build page (`/builds/<slug>`) shows an active or queued build's ticket, phase, steps and attention. A recently finished build's page shows only its outcome, kind and completion time, because the roster keeps no finished tickets. Every build page ends with that build's timeline, including builds the overview does not list.
84
+ - Analytics (`/analytics`) shows the Gantt of builds and the step-duration table; see [Timeline and analytics](#timeline-and-analytics).
85
+ - Pages update live and offer no actions.
86
+ - Analytics and timelines are explicit reads from `/api/analytics` and `/api/builds/<slug>/timeline`, never polled:
87
+ - A page fetches on load and on every filter, window or page change. For the same query, it fetches again only when the change position moves.
88
+ - Every request reads the change position. When the position has moved, it also reads the changed-builds feed, and the builds the feed names leave the in-memory timeline cache.
89
+ - An analytics answer that is not in memory reads one rollup value, one listing page and at most 25 saved timelines (only the builds not in memory).
90
+ - A build timeline that is not in memory reads the build and its saved timeline.
91
+
92
+ `ab dispatch --web` and `ab dispatch --viewer --web` serve the same UI from the dispatcher or viewer process:
93
+
94
+ - `--port`, `--host` and `--json` work as for `ab web` and require `--web`; `--json` changes only the URL announcement line.
95
+ - A TTY keeps the terminal dashboard, which keeps the URL right-aligned on its top line in every view, viewer mode included. Under `--plain` or without a TTY, the web UI is the only presentation: stdout carries only the URL line, and warnings and diagnostics stay on stderr.
96
+ - Shows what the dispatcher's own refresh reads: the repository header without the overview. In plain mode the page updates each dispatcher tick (`--interval`, default 10 s).
97
+ - Frames from the terminal dashboard add no store reads. A plain dispatcher reads one change position per tick while a browser is connected, and nothing while none is.
98
+ - Analytics and build timelines work once the dispatcher's store is open, as explicit reads.
99
+ - Binds before the repository lease; a taken port fails dispatch before it claims anything.
100
+ - The URL keeps working across automatic runtime upgrades. Only the first generation announces it on stdout; a TTY dashboard keeps showing it on its top line, successors included. Ctrl-C closes it. `--once` is refused.
101
+
66
102
  ### Local stdio MCP
67
103
 
68
104
  For an agent with an MCP client but no convenient shell, configure the client to launch:
@@ -117,3 +153,52 @@ proof of provider success. A clear appends once without reading history, even
117
153
  when already healthy; later degradation wins by ordinary journal order.
118
154
  Existing dispatcher/kernel automatic recovery and old payloads remain valid;
119
155
  the recovered payload additionally accepts an optional nonblank `reason`.
156
+
157
+ ## Dispatcher ownership
158
+
159
+ Read `ab repository status --json` before starting a dispatcher. The shared
160
+ `dispatcherRunning` field (also in the `repository.status` operator tool) is true
161
+ when a holder, expired holder or unfinished handoff names a draining predecessor.
162
+ An empty drain map does not prove retirement. Missing or unreadable running
163
+ status fails closed: never start while running or while that fact is unknown.
164
+
165
+ `ab operator dispatcher --json` reads the checkout's preference; save a choice
166
+ with `ab operator dispatcher human` or `ab operator dispatcher agent`. The optional
167
+ `[operator] dispatcher = "human" | "agent"` lives only in `.autobuild/local.toml`;
168
+ no choice is assumed when unset. Even an empty `[operator]` is rejected in
169
+ `autobuild.toml`. Saving preserves other settings semantically and may normalize
170
+ TOML formatting. It needs no store or credential, writes no event, and is refused
171
+ inside build or harvest sessions. Reading a missing local file creates nothing.
172
+
173
+ Repository instructions take precedence. With none running, follow the saved
174
+ preference or ask who should run it and offer to save the answer. For human
175
+ ownership, give startup instructions and wait. For agent ownership, start
176
+ `ab dispatch --web --plain --json` under the harness's managed background lifetime
177
+ and give the person its URL. Stop only a dispatcher this session started, only
178
+ when requested, using a clean stop with drain. Never adopt, restart, kill or manage
179
+ another session's process; a preference does not authorize takeover.
180
+
181
+ `ab web [--json]` is always allowed, even while a dispatcher exists: it serves a
182
+ read-only UI without acquiring a dispatcher lease. `ab dispatch --web` serves the
183
+ same UI alongside dispatch; `--plain` keeps the URL on stdout and diagnostics on
184
+ stderr; a TTY dashboard keeps it on its top line. Both default to loopback. Serving beyond loopback has no access control;
185
+ see [operator surfaces](operator-surfaces.md) for binding and refresh details.
186
+
187
+ ## Timeline and analytics
188
+
189
+ The analytics page (`/analytics`) shows where build time goes. A window and two filters apply to both charts:
190
+
191
+ | Control | Choices |
192
+ |---|---|
193
+ | Window | 24 hours, 7 days (default), 30 days, all retained history (400 days) |
194
+ | Outcome | merged (default), all |
195
+ | Kind | leaf (default), node, all |
196
+
197
+ - **Gantt.** One row per build, coloured by phase and wait, 25 builds to a page, most recently active first. A page holds builds the store wrote to during the window, including writes that are not events, such as an artifact or a lease release. Newer and Older page through them.
198
+ - **Axis.** Clock aligns actual times across builds; from start aligns each build's start.
199
+ - **Rows.** A build expands into one row per segment. Hovering a segment, or focusing its bar, shows its step, round, build, start, end and duration.
200
+ - **Segments.** Repeated phase rounds stay separate segments, and parallel verify steps may overlap. Queued, ticket-wait, paused, escalated and awaiting-merge segments show waiting rather than execution. Open segments grow with the clock.
201
+ - **Step durations.** Steps in pipeline order, waits last. Per run shows the mean bar with P50, P90 and P99 markers; total time shows the summed time and its share. Totals reveal where work adds up; a slow run and a large total answer different questions.
202
+ - **Build timeline.** Each build page ends with the same chart for that build, expanded to its segments.
203
+
204
+ The window starts at UTC midnight of the first day it overlaps, the same day the step-duration rollup reads from.
@@ -218,10 +218,23 @@ not the code under improvement, so leave that code out. Keep selectors narrow:
218
218
  a harness that covers the code being optimized pins the very code attempts are
219
219
  meant to change.
220
220
 
221
+ ### Measuring where builds run
222
+
223
+ Measure the evidence, the threshold and ε in the environment builds run in.
224
+
225
+ - With a remote workspace such as a sandbox, get the benchmark run there.
226
+ - If you can't, say so in the evidence. Leave the threshold out, and set it
227
+ with `ab objective <node> --threshold n` once the node reports its starting
228
+ value.
229
+ - Why: absolute timings from a workstation don't transfer to a sandbox. The
230
+ node's opening measurement and noise check run in the build environment, so
231
+ a threshold or ε from elsewhere may be unreachable or below the noise.
232
+
221
233
  ### Choosing ε and the noise check
222
234
 
223
235
  Choose ε above the noise. ε is the smallest gain worth landing. Run the
224
- command several times on the same tree first. If the median moves by more than
236
+ command several times on the same tree first, in the environment builds run
237
+ in. If the median moves by more than
225
238
  your ε between identical runs, raise ε or `samples`. The node checks this when
226
239
  it opens: its starting measurement raises `optimization.noise-exceeded` when ε
227
240
  is below the measured spread. A panel node judges its opening head against
@@ -254,8 +267,10 @@ should not decide an ε of 0.1. See [judge panels](#judge-panels).
254
267
  ### Choosing a budget
255
268
 
256
269
  Choose a budget you would sign off on unattended. It is the limit a human
257
- approves once for the whole run. `maxAttempts` bounds cost; `maxHours` bounds wall-clock
258
- time. Set a plateau when a run of failed strategies should end the search
270
+ approves once for the whole run. `maxAttempts` bounds cost; `maxHours` bounds
271
+ [active hours](#active-hours): time the node's attempts, proposer or
272
+ measurements actually run, not wall-clock time since opening. Time an attempt
273
+ spends queued for a slot, parked on an escalation or paused is not charged. Set a plateau when a run of failed strategies should end the search
259
274
  early. Set a threshold only when there is a value at which you would stop
260
275
  looking. Use `concurrency` above 1 only when attempts are independent enough to
261
276
  run side by side.
@@ -590,7 +605,7 @@ blinded order.
590
605
  | `optimization.objective-revised` | node | changes, revision (human) |
591
606
  | `optimization.baseline-measured` | node | revision, head, harnessPin, samples, median, spread, report |
592
607
  | `optimization.noise-exceeded` | node | revision, head, harnessPin, median, spread, epsilon, effective ε (advisory) |
593
- | `optimization.proposal-requested` | node | id, node head, room, budget used (attempts, hours) (dispatcher) |
608
+ | `optimization.proposal-requested` | node | id, node head, room, budget used (attempts, active hours) (dispatcher) |
594
609
  | `optimization.attempts-proposed` | node | request, proposals (id, ticket, title, strategy), reason when empty; recorded after every ticket exists (dispatcher) |
595
610
  | `attempt.measurement-requested` | attempt | id, node, candidate, baseline, harnessPin, revision, metric, purpose (panel) |
596
611
  | `attempt.sampled` | attempt | request, candidate, baseline, harnessPin, revision, samples (judges for a panel), medians or win rate, report |
@@ -604,6 +619,8 @@ blinded order.
604
619
  | `attempt.settled` | node | attempt (proposal, ticket, build, branch?), outcome, measurement (revision, baseline, candidate, delta), policy?, mergedSha?, note, head (accepted only) |
605
620
  | `attempt.merged-unmeasured` | node | proposal, ticket, build, merged head (sha?), reason, measuredCandidate? |
606
621
  | `optimization.stopped` | node | cause, mode |
622
+ | `optimization.activity-recorded` | node | attempt execution facts (build, n, instance, started or ended, at), accounted counts, released builds?, watermark, starts?, settles? (dispatcher) |
623
+ | `execution.accounted` | attempt | count: execution facts the node has accounted (dispatcher, advisory) |
607
624
  | `attempt.ticket-rejected` | node | proposal, ticket, rejected state the ticket moved to |
608
625
  | `attempt.branch-deleted` | node | proposal, build, branch |
609
626
  | `attempt.branch-cleanup-failed` | node | proposal, build?, branch, error |
@@ -661,7 +678,7 @@ Progress is derived from the node's log, never recorded:
661
678
  unmeasured (slot held)` while any remain.
662
679
  - **Plateau counter**: consecutive `no-improvement` or `declined` settlements
663
680
  since the last `accepted`; `stopped` and `aborted` leave it unchanged.
664
- - **Elapsed budget**: hours since the first acceptance, against `maxHours`, and
681
+ - **Budget used**: [active hours](#active-hours), against `maxHours`, and
665
682
  attempts filed, against `maxAttempts`.
666
683
  - **Stop eligibility** by threshold, plateau and budget, and whether the node
667
684
  has stopped. Once stopped, `ab objective` also shows what still blocks
@@ -689,14 +706,16 @@ Every surface shows the same objective row, read from the node's digest alone:
689
706
  ```text
690
707
  objective 50 → 44 (minimize) · threshold 35 · noise ±1.5
691
708
  attempts 1 accepted · 3 rejected · 0 running
692
- budget 4/60 attempts · 3.1/24 hours
709
+ budget 4/60 attempts · 3.1/24 active hours
693
710
  stopped plateau (drain)
694
711
  ```
695
712
 
696
713
  A panel shows `win rate 50% → 70%` instead. Only configured budgets appear,
697
714
  `no threshold` and `objective not measured` stand in for absent values, and
698
- the `stopped` segment appears once the node stops. Budget hours stop at the
699
- stop time; a watch record evaluates them at its own timestamp. `ab objective`
715
+ the `stopped` segment appears once the node stops. Budget hours are active
716
+ hours and stop growing at the stop; `(settling)` follows them until the
717
+ dispatcher has accounted attempt runs from before the stop. A watch record
718
+ evaluates them at its own timestamp. `ab objective`
700
719
  remains the full view, with the best value, plateau and stop eligibility.
701
720
 
702
721
  ## Proposer phase
@@ -724,7 +743,7 @@ deferred for runtime compatibility gets `optimization.proposal-deferred` with
724
743
  that reason instead, and is reconsidered once a fact that can clear it lands.
725
744
  The request takes a slot ahead of normal ticket claims, like node reconcile and
726
745
  verification. Before the session starts, the dispatcher re-checks the request:
727
- when the node stopped, the hours budget expired, or room fell below the
746
+ when the node stopped, the active-hours budget is spent, or room fell below the
728
747
  recorded room, it records `optimization.proposal-withdrawn`, which clears the
729
748
  request and never counts as an empty proposal. A session that already started
730
749
  keeps the room it was granted.
@@ -736,7 +755,10 @@ out detached. `ab context` writes:
736
755
  quick-revised since its latest acceptance;
737
756
  - `progress.json`: starting, current, best and threshold values, attempt
738
757
  counts, attempts in flight, the plateau counter, consecutive empty proposals,
739
- the opening time and the request (`id`, `head`, `room`);
758
+ the opening time (`openedAt`), `activeHours` and the request (`id`, `head`,
759
+ `room`). `activeHours` is the active-hours budget used so far, evaluated when
760
+ the context is materialized; `openedAt` is opening metadata, not the budget
761
+ clock;
740
762
  - `ledger.json`: `settled`, one entry per settled attempt with `nearMiss: true`
741
763
  on a near miss, and `inFlight`, the running attempts with their titles and
742
764
  strategies;
@@ -809,6 +831,12 @@ build as an ordinary child.
809
831
  An attempt keeps the ordinary work grammar: plan, plan review, implement, code
810
832
  review, verify and finalize.
811
833
 
834
+ An attempt claims at its node's priority. `ab priority <node> urgent` puts
835
+ the node's attempts claimed afterwards in the urgent tier; an attempt already
836
+ claimed keeps its build's priority. Nothing is reserved: an attempt waits for
837
+ a free slot like any ready ticket, preempts nothing, and follows the source's
838
+ order within its tier.
839
+
812
840
  ### Attempt context
813
841
 
814
842
  In every phase of an attempt, `ab context` writes a derived `objective.md` and
@@ -969,6 +997,36 @@ slot, and retries on later polls without changing the settlement. An attempt
969
997
  that never published needs no deletion. Aborted and stopped attempts keep abort
970
998
  cleanup's own branch deletion.
971
999
 
1000
+ ## Active hours
1001
+
1002
+ `maxHours` counts the time the node's optimization work actually runs:
1003
+
1004
+ - **What counts.** An attempt from its `execution.started` to its
1005
+ `execution.ended`, and the node's own runs that started while its proposer
1006
+ or a measurement was due. Overlapping runs count once.
1007
+ - **What doesn't.** An attempt queued for a slot has no execution. A runner
1008
+ ends its execution whenever the build waits: paused, blocked on an
1009
+ escalation, on a ticket wait or awaiting merge. Other node runs, such as a
1010
+ branch reconcile, don't count.
1011
+ - **How it is kept.** The node's digest holds an exact union of execution
1012
+ intervals. Its own runs fold from its log. Attempt runs arrive in
1013
+ `optimization.activity-recorded` batches: on each tick the dispatcher reads
1014
+ an attempt build's `executionIntervals` value only when the build's digest
1015
+ shows new execution facts, records them on the node, then acknowledges them
1016
+ on the build with `execution.accounted`. An idle tick reads nothing. The
1017
+ first pass over a node starts its clock with a `starts` batch, so an
1018
+ attempt that settles before the dispatcher saw it run is still charged.
1019
+ - **At a stop.** `optimization.stopped` closes every interval at the stop
1020
+ time, so the value never grows afterwards. The next tick records one
1021
+ settling batch with every attempt run from before the stop the node had not
1022
+ yet accounted; a large one is chunked, and only its last chunk settles. Until then surfaces show `settling`, because that batch may
1023
+ change the value once.
1024
+ - **Nodes opened before active hours.** Their own past proposer and
1025
+ measurement runs count. Attempts still in flight are charged their whole
1026
+ run history once the dispatcher first sees them; attempts that settled
1027
+ before the clock's starting batch are not charged. A completed node reports its own runs,
1028
+ clipped at its stop.
1029
+
972
1030
  ## Stopping and completion
973
1031
 
974
1032
  An optimization node is done when the number is good enough, when it stops
@@ -982,7 +1040,7 @@ any point lands real, verified progress.
982
1040
  |---|---|
983
1041
  | `threshold` | The node head's current value has reached `target.threshold` in the objective's direction; for a panel, the head's recorded win rate against the starting head. |
984
1042
  | `plateau` | `stop.plateau.attempts` consecutive `no-improvement` or `declined` settlements. |
985
- | `budget` | Attempts filed reached `maxAttempts`, or hours since the first acceptance reached `maxHours`. |
1043
+ | `budget` | Attempts filed reached `maxAttempts`, or [active hours](#active-hours) reached `maxHours`. |
986
1044
  | `exhausted` | The proposer has nothing left to try. |
987
1045
  | `operator` | A human stopped it with `ab objective <node> --stop` or `optimization.stop`. |
988
1046