@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
@@ -1,3 +1,5 @@
1
+ import { AgentContextCapture } from '../processes/agent-context'
2
+ import { formatAgentContextDiagnostic } from '../store/agent-context'
1
3
  import {
2
4
  assertCreateAssigneeAccepted,
3
5
  assertReadyAssigneeAccepted,
@@ -21,6 +23,9 @@ import { recordRuntimeRollback } from './dispatch-handoff'
21
23
  import { syncRollbackRetention } from './dispatch-runtime-use'
22
24
  import { dirname as runtimeDirname } from 'node:path'
23
25
  import { releaseDispatchPresentation } from './dispatch-presentation-ownership'
26
+ import type { DispatchWebArgs } from './dispatch-args'
27
+ import { startDispatchWeb, type DispatchWeb } from './dispatch-web'
28
+ import type { WebServerStarter } from '../web/server'
24
29
  import { validateWorkspaceDispatchConfiguration } from './dispatch-readiness'
25
30
  import { releasePreparedRuntime } from './dispatch-runtime-use'
26
31
  import { authorizeRemoteHandoffs, recoverDispatchDrain } from '../kernel/dispatch-drain-recovery'
@@ -47,7 +52,12 @@ import {
47
52
  } from '../ports/forge/readiness'
48
53
  import { createReadinessRedactor } from './init-readiness-shared'
49
54
  import { RepositoryPollCache } from './dashboard/repository-poll'
50
- import { DashboardRefresh, interactionRead, presentationReader } from './dashboard/refresh'
55
+ import {
56
+ DashboardRefresh,
57
+ interactionRead,
58
+ presentationReader,
59
+ type RefreshScheduler,
60
+ } from './dashboard/refresh'
51
61
  import { FOCUS_REPORTING_MODE, installPresentationSuspension } from './terminal-restore'
52
62
  import type { BuildState } from '../kernel/reducer'
53
63
  import {
@@ -101,7 +111,13 @@ import { createHash } from 'node:crypto'
101
111
  import { tmpdir } from 'node:os'
102
112
  import { join, resolve } from 'node:path'
103
113
  import semver from 'semver'
104
- import { ConfigError, parseConfig } from '../config/load'
114
+ import { ConfigError, loadConfig, parseConfig } from '../config/load'
115
+ import {
116
+ localConfigPath,
117
+ parseLayeredConfig,
118
+ readLocalConfig,
119
+ type LocalOverrideRecord,
120
+ } from '../config/local'
105
121
  import {
106
122
  composeBuildConfig,
107
123
  DISPATCHER_CONFIG_ARTIFACT,
@@ -120,7 +136,7 @@ import {
120
136
  roleKeyWarnings,
121
137
  SLUG_ROLE,
122
138
  } from '../config/roles'
123
- import type { Config } from '../config/schema'
139
+ import { orchestratorEnabled, type Config, type OrchestratorHost } from '../config/schema'
124
140
  import { loadPlugins, pluginResolutionKind } from '../plugins/load'
125
141
  import type { PluginRegistry } from '../plugins/registry'
126
142
  import { materializePluginRuntimes } from '../plugins/runtimes'
@@ -143,6 +159,7 @@ import {
143
159
  type DashboardView,
144
160
  } from './dashboard/model'
145
161
  import { DashboardBuildPollCache } from './dashboard/poll'
162
+ import { repositoryQueueDepth } from './dashboard/header'
146
163
  import {
147
164
  dashboardContentWidth,
148
165
  detailScrollLimit,
@@ -180,7 +197,7 @@ import type {
180
197
  WorkspaceReapOutcome,
181
198
  } from '../ports/types'
182
199
  import { createWorkspaceRuntime, type WorkspaceRuntime } from '../ports/workspace/create'
183
- import { GitWorktreeProvider } from '../ports/workspace/git-worktree'
200
+ import { GitWorktreeProvider, worktreeIsolationNotice } from '../ports/workspace/git-worktree'
184
201
  import { LocalBuildExecution } from '../ports/workspace/local-build-execution'
185
202
  import {
186
203
  BUILD_EXECUTION_LEASE_TTL_MS,
@@ -378,6 +395,9 @@ export interface DispatchWiring {
378
395
  plugins?: PluginRegistry
379
396
  /** Keeps workspace-owned runtime preflights aligned with accepted hot role reloads. */
380
397
  updateRuntimeReferences?: (config: Config) => void
398
+ /** Wiring-time startup notices (a workspace destination that cannot take
399
+ * new builds), shown with the configuration-level startup warnings. */
400
+ startupNotices?: readonly string[]
381
401
  }
382
402
 
383
403
  export type DispatchNonStoreWiring = Omit<DispatchWiring, 'store' | 'storeRef' | 'token'>
@@ -440,6 +460,9 @@ export interface DispatchOpts {
440
460
  stderr: (line: string) => void
441
461
  /** Single pass then drain in-flight runners and exit; default is a loop. */
442
462
  once?: boolean
463
+ /** Test seam: the dashboard's presentation refresh timers. Unset keeps the
464
+ * real scheduler; kernel timers never use it. */
465
+ refreshScheduler?: RefreshScheduler
443
466
  /** Watch-loop cadence in ms (§3.3); default DEFAULT_INTERVAL_MS. */
444
467
  intervalMs?: number
445
468
  /** Explicit durable repository intake override. Omission reuses stored state,
@@ -527,9 +550,23 @@ export interface DispatchOpts {
527
550
  * config error at startup and on reload, never silently ignored. URL hooks
528
551
  * are delivered either way. */
529
552
  localCommands?: false
553
+ /** Where `[orchestrator].enabled` is resolved (`orchestratorEnabled`): an
554
+ * unset value is enabled for `hosted` and disabled for `local`. Default
555
+ * `local`; the hosted dispatcher passes `hosted`. */
556
+ orchestratorHost?: OrchestratorHost
530
557
  /** Test seam for configured hook delivery; defaults to running the hook's
531
558
  * command or POSTing to its URL (`processes/hook-webhook.ts`). */
532
559
  invokeHook?: HookInvoke
560
+ /** `--web`: serve the read-only web UI from this process. It binds before
561
+ * the repository lease, and frames come from the refresh this dispatcher
562
+ * already runs; only the kernel path adds one change-position read per
563
+ * frame while a browser is connected. `start` is a test seam that replaces
564
+ * the real socket bind. */
565
+ web?: DispatchWebArgs & { start?: WebServerStarter }
566
+ /** Private: closes this generation's web server. `abDispatch` sets it; the
567
+ * loop awaits it before `dispatcher.terminal-released`, so a successor can
568
+ * bind the same port. */
569
+ releaseWeb?: () => Promise<void>
533
570
  }
534
571
 
535
572
  /** Reject hooks this dispatcher cannot deliver: command hooks where local
@@ -699,12 +736,15 @@ async function defaultWire(
699
736
  accountRedactor(() => allAccounts, opts.env),
700
737
  )
701
738
  let runtimeReferences = effectiveRuntimeReferences(config, { includeUnusedAccounts: false })
702
- // A local override relocates the whole tree. Remote stores still need local
703
- // scratch beneath the repository default. Plugin factories receive only
704
- // their explicit config plus repository/environment context.
739
+ // The builtin provider places build worktrees outside the checkout's
740
+ // package ancestry: the state tree's own worktrees/ when that resolves
741
+ // outside the checkout, else the per-checkout isolated root. Plugin
742
+ // factories receive only their explicit config plus repository/environment
743
+ // context.
705
744
  const workspaceRuntime = await createWorkspaceRuntime(config.workspace, {
706
745
  registry: plugins,
707
746
  worktreeRoot: opened.worktreeRoot,
747
+ isolatedWorktreeRoot: opened.isolatedWorktreeRoot,
708
748
  // Plugin factories always get the filesystem checkout (the physical path
709
749
  // or the origin-mode scratch root) — never the store identity.
710
750
  repoRoot: state.checkout,
@@ -716,7 +756,8 @@ async function defaultWire(
716
756
  sandboxSetupCommand: config.commands.setup,
717
757
  sandboxRoot: resolve(join(opened.localStateRoot, 'orchestrator-sandboxes')),
718
758
  sandboxEnvironmentVariables: config.orchestrator.sandbox.environmentVariables,
719
- orchestratorSandboxEnabled: config.orchestrator.enabled,
759
+ sandboxIdleMinutes: config.orchestrator.sandbox.idleMinutes,
760
+ orchestratorSandboxEnabled: orchestratorEnabled(config, opts.orchestratorHost ?? 'local'),
720
761
  ...providerSeams,
721
762
  ...(refusedArchive !== undefined ? { refusedArchive } : {}),
722
763
  ...(opened.token !== undefined ? { storeToken: opened.token } : {}),
@@ -729,11 +770,24 @@ async function defaultWire(
729
770
  ? []
730
771
  : [
731
772
  {
732
- provider: new GitWorktreeProvider({ root: resolve(opened.worktreeRoot) }),
773
+ provider: new GitWorktreeProvider({
774
+ root: resolve(opened.worktreeRoot),
775
+ isolatedRoot: opened.isolatedWorktreeRoot,
776
+ }),
733
777
  execution: new LocalBuildExecution({ env: opts.env }),
734
778
  },
735
779
  ]
736
780
 
781
+ // Once per process start, a few lstat calls and no store reads: a host with
782
+ // no isolated destination is told why at startup. Never a gate — fresh
783
+ // provisioning fails per build, and recorded or legacy worktrees continue.
784
+ const isolationNotice =
785
+ !originMode &&
786
+ config.workspace.provider === 'git-worktree' &&
787
+ workspaceRuntime.provider instanceof GitWorktreeProvider
788
+ ? await worktreeIsolationNotice(workspaceRuntime.provider, state.checkout)
789
+ : undefined
790
+
737
791
  return {
738
792
  store: opened.store,
739
793
  renewAccounts,
@@ -745,6 +799,7 @@ async function defaultWire(
745
799
  workspaces: workspaceRuntime.provider,
746
800
  retiredWorkspaces,
747
801
  buildExecution: workspaceRuntime.execution,
802
+ ...(isolationNotice !== undefined ? { startupNotices: [isolationNotice] } : {}),
748
803
  // Shipped registrations are shared with other non-phase judgment paths.
749
804
  // Model ids stay in config; production.ts owns adapter compatibility data.
750
805
  runtimes,
@@ -904,8 +959,6 @@ class DispatchLoop {
904
959
  private configWarnings: readonly string[] = []
905
960
  /** Deprecation notices of an autobuild.toml change that is not adopted. */
906
961
  private candidateWarnings: readonly string[] = []
907
- /** Last intake-enabled tick's standing queue depth, for the dashboard header. */
908
- private queuedCount = 0
909
962
  /** Display-only triage count, sampled between ticks at most once per
910
963
  * `TRIAGE_COUNT_REFRESH_MS`. Present only for interactive dashboards and
911
964
  * frontend-status kernels; its value is undefined until a read succeeds. */
@@ -1111,6 +1164,7 @@ class DispatchLoop {
1111
1164
  missingAccounts: () => this.missingAccounts(),
1112
1165
  accountCredentialSource: opts.repository ? 'project-secrets' : 'environment',
1113
1166
  repairBuildConfig: (slug) => this.publishBuildConfig(slug),
1167
+ ...(opts.orchestratorHost !== undefined ? { orchestratorHost: opts.orchestratorHost } : {}),
1114
1168
  repo: this.repoIdentity,
1115
1169
  // Origin mode: the forge answers remote base-branch questions; no
1116
1170
  // checkout git is probed for the served repository's origin.
@@ -1130,6 +1184,14 @@ class DispatchLoop {
1130
1184
  // skip foreign-execution settlement for builds this process supervises.
1131
1185
  settlePublication: (slug) => this.settlePendingPublication(slug),
1132
1186
  activeExecutions: () => new Set(this.activeBuildRuns.keys()),
1187
+ // Both modes read the base branch through the forge, so a checkout
1188
+ // dispatcher and an origin-mode one record the same agent context.
1189
+ agentContext: new AgentContextCapture({
1190
+ store: this.repoView,
1191
+ repo: this.repoIdentity,
1192
+ forge: wiring.forge,
1193
+ now: () => wiring.clock().getTime(),
1194
+ }),
1133
1195
  opts: {
1134
1196
  maxHarvestRecoveryAttempts: this.maxHarvestRecoveryAttempts,
1135
1197
  },
@@ -1513,7 +1575,6 @@ class DispatchLoop {
1513
1575
  invalidTickets: readyObservation?.invalidTickets ?? report.invalidTickets,
1514
1576
  ticketDiagnostics: readyObservation?.ticketDiagnostics ?? report.ticketDiagnostics,
1515
1577
  }
1516
- this.queuedCount = publishedReport.queued
1517
1578
  const triage = this.triageSampler?.value
1518
1579
  this.lastTickStatus = {
1519
1580
  queued: publishedReport.queued,
@@ -3242,6 +3303,7 @@ class DispatchLoop {
3242
3303
  ticketDiagnostics: _ticketDiagnostics,
3243
3304
  creationDiagnostics: _creationDiagnostics,
3244
3305
  dependencyDiagnostics: _dependencyDiagnostics,
3306
+ agentContextDiagnostics: _agentContextDiagnostics,
3245
3307
  ...counters
3246
3308
  } = merged
3247
3309
  const completed = {
@@ -3895,14 +3957,21 @@ class DispatchLoop {
3895
3957
  this.paint()
3896
3958
  }
3897
3959
 
3960
+ /** Plain/non-TTY `--web`: the web UI is the only presentation, so routine
3961
+ * line-oriented stdout is suppressed. Warnings and diagnostics stay on
3962
+ * stderr. */
3963
+ private get webPresents(): boolean {
3964
+ return !this.dashboard && this.opts.web !== undefined
3965
+ }
3966
+
3898
3967
  private say(line: string): void {
3899
- if (this.presentationReleased) return
3968
+ if (this.presentationReleased || this.webPresents) return
3900
3969
  if (!this.dashboard && this.opts.silent !== true) this.opts.stdout(line)
3901
3970
  }
3902
3971
 
3903
3972
  /** Routine acknowledgement: line-oriented stdout, dashboard-silent. */
3904
3973
  private announce(line: string): void {
3905
- if (!this.dashboard) this.opts.stdout(line)
3974
+ if (!this.dashboard && !this.webPresents) this.opts.stdout(line)
3906
3975
  }
3907
3976
 
3908
3977
  private hooks: HookSupervisor | undefined
@@ -3987,11 +4056,14 @@ class DispatchLoop {
3987
4056
  else if (this.opts.silent !== true) this.opts.stderr(line)
3988
4057
  }
3989
4058
 
3990
- /** Failure-severity dashboard notice whose historical plain sink is stdout. */
4059
+ /** Failure-severity dashboard notice whose historical plain sink is stdout;
4060
+ * under `--web` it moves to stderr so stdout carries only the URL. */
3991
4061
  private failureNotice(line: string): void {
3992
4062
  if (this.presentationReleased) return
3993
4063
  if (this.dashboard) this.setWarning(line)
3994
- else if (this.opts.silent !== true) this.opts.stdout(line)
4064
+ else if (this.opts.silent === true) return
4065
+ else if (this.webPresents) this.opts.stderr(line)
4066
+ else this.opts.stdout(line)
3995
4067
  }
3996
4068
 
3997
4069
  /** Routine diagnostic whose historical line-oriented sink is stderr. */
@@ -4070,6 +4142,7 @@ class DispatchLoop {
4070
4142
  const lines = [
4071
4143
  ...this.liveConfig.deprecations(),
4072
4144
  ...startupWarnings(this.currentConfig().config, this.wiring.forge),
4145
+ ...(this.wiring.startupNotices ?? []),
4073
4146
  ]
4074
4147
  if (this.dashboard) {
4075
4148
  this.configWarnings = lines
@@ -4107,10 +4180,13 @@ class DispatchLoop {
4107
4180
  ticketDiagnostics,
4108
4181
  creationDiagnostics,
4109
4182
  dependencyDiagnostics,
4183
+ agentContextDiagnostics,
4110
4184
  queued: _queued,
4111
4185
  ...counts
4112
4186
  } = report
4113
4187
  for (const line of janitorDiagnostics) this.routineDiagnostic(line)
4188
+ for (const diagnostic of agentContextDiagnostics)
4189
+ this.routineDiagnostic(formatAgentContextDiagnostic(diagnostic))
4114
4190
  for (const line of blockedDiagnostics) this.say(line)
4115
4191
  for (const line of ticketDiagnostics) this.routineDiagnostic(line)
4116
4192
  for (const line of creationDiagnostics) this.say(line)
@@ -4127,11 +4203,12 @@ class DispatchLoop {
4127
4203
  blockedDiagnostics.length > 0 ||
4128
4204
  ticketDiagnostics.length > 0 ||
4129
4205
  creationDiagnostics.length > 0 ||
4130
- dependencyDiagnostics.length > 0
4206
+ dependencyDiagnostics.length > 0 ||
4207
+ agentContextDiagnostics.length > 0
4131
4208
  if (reportedDiagnostic) return true
4132
4209
  // A tick that did something is worth a plain line. Interactive mode
4133
4210
  // suppresses both action counts and the every-10s idle noise.
4134
- if (!this.dashboard && printIdle) {
4211
+ if (!this.dashboard && !this.webPresents && printIdle) {
4135
4212
  this.opts.stdout('tick: idle')
4136
4213
  return true
4137
4214
  }
@@ -4229,7 +4306,7 @@ class DispatchLoop {
4229
4306
  buildSnapshot.builds,
4230
4307
  {
4231
4308
  repo: this.repoIdentity,
4232
- queued: this.queuedCount,
4309
+ queued: repositoryQueueDepth(repositoryEvents),
4233
4310
  activeCount: [...buildSnapshot.states.values()].filter(
4234
4311
  (state) => state.kind !== 'node' && state.status !== 'done' && state.status !== 'aborted',
4235
4312
  ).length,
@@ -4379,7 +4456,7 @@ class DispatchLoop {
4379
4456
  throw error
4380
4457
  }
4381
4458
  },
4382
- undefined,
4459
+ this.opts.refreshScheduler,
4383
4460
  this.presentationStore.networkReads,
4384
4461
  )
4385
4462
  if (this.opts.once !== true) {
@@ -4950,6 +5027,8 @@ class DispatchLoop {
4950
5027
  // Interactive kernels have no terminal authority. Their frontend must
4951
5028
  // acknowledge removal and joining of input/render work itself.
4952
5029
  if (this.opts.kernelRunId === undefined) {
5030
+ // Free the web port before the successor may bind it.
5031
+ await this.opts.releaseWeb?.()
4953
5032
  await this.repoView.appendRepo(this.repoIdentity, {
4954
5033
  actor: DISPATCHER,
4955
5034
  type: 'dispatcher.terminal-released',
@@ -4998,8 +5077,9 @@ class DispatchLoop {
4998
5077
  // Read-only policy supervision: never another tick or config fan-out.
4999
5078
  try {
5000
5079
  // Deprecations were reported at startup/reload; this re-read stays quiet.
5080
+ // Layered with the checkout's local override file, like the snapshot.
5001
5081
  const path = join(this.opts.targetRepo, 'autobuild.toml')
5002
- const config = parseConfig(await Bun.file(path).text(), path, () => {})
5082
+ const config = await loadConfig(path, () => {})
5003
5083
  const { createRuntimeResolver } = await import('../ports/runner/routing')
5004
5084
  createRuntimeResolver(
5005
5085
  this.wiring.runtimes,
@@ -5481,16 +5561,23 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5481
5561
  ? { AB_TOKEN: projectToken(state.storeRef, state.repo, opts.env) }
5482
5562
  : {}),
5483
5563
  }
5484
- const opened = openStoreForRepoState(state, { env })
5564
+ const web = await startOptionalDispatchWeb(opts, opts.repo ?? state.repo)
5565
+ let opened: ReturnType<typeof openStoreForRepoState> | undefined
5485
5566
  try {
5567
+ opened = openStoreForRepoState(state, { env })
5486
5568
  const interactive =
5487
5569
  opts.plain !== true && opts.terminal?.interactive === true && opts.input !== undefined
5570
+ // Without a TTY the web UI is the only presentation: the viewer reads
5571
+ // exactly as it would, and its text frames are discarded.
5572
+ const plainOutput = web !== undefined ? () => {} : opts.stdout
5573
+ const store = opened
5574
+ web?.attachStore(store.store)
5488
5575
  await new DispatchFrontend({
5489
5576
  viewer: { ...(opts.dispatchedBy !== undefined ? { dispatchedBy: opts.dispatchedBy } : {}) },
5490
5577
  repo: opts.repo ?? state.repo,
5491
5578
  checkout: state.checkout,
5492
- store: opened.store,
5493
- storeRef: opened.storeRef,
5579
+ store: store.store,
5580
+ storeRef: store.storeRef,
5494
5581
  env,
5495
5582
  terminal: opts.terminal ?? {
5496
5583
  columns: 100,
@@ -5503,7 +5590,8 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5503
5590
  ),
5504
5591
  },
5505
5592
  input: opts.input ?? { start: () => () => {} },
5506
- ...(!interactive ? { plainOutput: opts.stdout } : {}),
5593
+ ...(!interactive ? { plainOutput } : {}),
5594
+ ...(web !== undefined ? { web: { dispatch: web } } : {}),
5507
5595
  controlTickets: () =>
5508
5596
  lazyTicketSource(() =>
5509
5597
  openTicketSource(
@@ -5511,7 +5599,7 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5511
5599
  targetRepo: state.checkout,
5512
5600
  exec: opts.exec,
5513
5601
  env,
5514
- storeRef: opened.storeRef,
5602
+ storeRef: store.storeRef,
5515
5603
  stdout: opts.stdout,
5516
5604
  },
5517
5605
  'ab merge',
@@ -5525,7 +5613,8 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5525
5613
  : {}),
5526
5614
  }).run()
5527
5615
  } finally {
5528
- await opened.store.close()
5616
+ await web?.close()
5617
+ await opened?.store.close()
5529
5618
  }
5530
5619
  return
5531
5620
  }
@@ -5594,13 +5683,18 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5594
5683
  'interactive dashboard: pass --plain or run it without a TTY',
5595
5684
  )
5596
5685
  }
5597
- const opened = openStoreForRepoState(state, { env: resolvedOpts.env })
5686
+ const web = await startOptionalDispatchWeb(resolvedOpts, state.repo)
5687
+ let opened: ReturnType<typeof openStoreForRepoState> | undefined
5598
5688
  try {
5689
+ opened = openStoreForRepoState(state, { env: resolvedOpts.env })
5690
+ const store = opened
5691
+ web?.attachStore(store.store)
5599
5692
  const frontend = new DispatchFrontend({
5600
5693
  repo: state.repo,
5601
5694
  checkout: state.checkout,
5602
- storeRef: opened.storeRef,
5603
- store: opened.store,
5695
+ storeRef: store.storeRef,
5696
+ store: store.store,
5697
+ ...(web !== undefined ? { web: { dispatch: web } } : {}),
5604
5698
  controlTickets: () =>
5605
5699
  lazyTicketSource(() =>
5606
5700
  openTicketSource(
@@ -5608,7 +5702,7 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5608
5702
  targetRepo: state.checkout,
5609
5703
  exec: resolvedOpts.exec,
5610
5704
  env: resolvedOpts.env,
5611
- storeRef: opened.storeRef,
5705
+ storeRef: store.storeRef,
5612
5706
  stdout: resolvedOpts.stdout,
5613
5707
  },
5614
5708
  'ab merge',
@@ -5630,14 +5724,55 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5630
5724
  })
5631
5725
  await frontend.run()
5632
5726
  } finally {
5633
- await opened.store.close()
5727
+ await web?.close()
5728
+ await opened?.store.close()
5634
5729
  }
5635
5730
  return
5636
5731
  }
5637
5732
 
5733
+ // The plain kernel's web UI binds before config, wiring and any lease, and
5734
+ // is fed by the repository view's own journal refreshes.
5735
+ const web = await startOptionalDispatchWeb(resolvedOpts, state.repo)
5736
+ if (web !== undefined) resolvedOpts.releaseWeb = web.close
5737
+ try {
5738
+ await runDispatchKernel(opts, resolvedOpts, state, originConfig, web)
5739
+ } finally {
5740
+ await web?.close()
5741
+ }
5742
+ }
5743
+
5744
+ async function startOptionalDispatchWeb(
5745
+ opts: DispatchOpts,
5746
+ repo: string,
5747
+ ): Promise<DispatchWeb | undefined> {
5748
+ if (opts.web === undefined) return undefined
5749
+ const { start, ...options } = opts.web
5750
+ return startDispatchWeb({
5751
+ options,
5752
+ repo,
5753
+ env: opts.env,
5754
+ stdout: opts.stdout,
5755
+ stderr: opts.stderr,
5756
+ ...(start !== undefined ? { start } : {}),
5757
+ })
5758
+ }
5759
+
5760
+ /** The in-process kernel path of `abDispatch`: plain/non-TTY dispatch,
5761
+ * private kernel children and injected wiring. */
5762
+ async function runDispatchKernel(
5763
+ opts: DispatchOpts,
5764
+ resolvedOpts: DispatchOpts,
5765
+ state: RepoStatePaths,
5766
+ originConfig: Awaited<ReturnType<typeof fetchOriginModeConfig>> | undefined,
5767
+ web: DispatchWeb | undefined,
5768
+ ): Promise<void> {
5638
5769
  const configPath = join(resolvedOpts.targetRepo, 'autobuild.toml')
5639
5770
  let configContent: string
5640
5771
  let config: Config
5772
+ // Checkout mode only: the local override file layered over autobuild.toml.
5773
+ let localContent: string | undefined
5774
+ let localSource: string | undefined
5775
+ let startupLocalOverrides: LocalOverrideRecord | undefined
5641
5776
  // Collected, never written at parse time: the dispatcher reports them once
5642
5777
  // with its other configuration notices (`reportRoleDiagnostics`).
5643
5778
  let startupDeprecations: readonly string[] = []
@@ -5675,8 +5810,16 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5675
5810
  } else {
5676
5811
  try {
5677
5812
  configContent = await Bun.file(configPath).text()
5813
+ localSource = localConfigPath(resolvedOpts.targetRepo)
5814
+ const local = await readLocalConfig(resolvedOpts.targetRepo)
5815
+ localContent = local?.text
5678
5816
  const deprecations: string[] = []
5679
- config = parseConfig(configContent, configPath, (line) => deprecations.push(line))
5817
+ const layered = parseLayeredConfig(
5818
+ { committed: { text: configContent, source: configPath }, local },
5819
+ (line) => deprecations.push(line),
5820
+ )
5821
+ config = layered.config
5822
+ startupLocalOverrides = layered.localOverrides
5680
5823
  startupDeprecations = deprecations
5681
5824
  } catch (error) {
5682
5825
  if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
@@ -5752,21 +5895,29 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5752
5895
  const liveConfig = new LiveConfig(
5753
5896
  configPath,
5754
5897
  config,
5755
- configContent,
5898
+ localContent === undefined ? configContent : { committed: configContent, local: localContent },
5756
5899
  wiring.runtimes,
5757
- async ({ content, effectiveConfig, restartRequired, effectiveChanged }) => {
5900
+ async ({ content, localOverrides, effectiveConfig, restartRequired, effectiveChanged }) => {
5758
5901
  await wiring.store.appendRepoWithArtifacts(
5759
5902
  state.repo,
5760
5903
  [
5761
5904
  {
5762
5905
  kind: DISPATCHER_CONFIG_ARTIFACT,
5763
5906
  content,
5764
- metadata: { restartRequired: [...restartRequired], effectiveChanged },
5907
+ metadata: {
5908
+ restartRequired: [...restartRequired],
5909
+ effectiveChanged,
5910
+ ...(localOverrides ? { localOverrides } : {}),
5911
+ },
5765
5912
  },
5766
5913
  {
5767
5914
  kind: _effectiveConfigKind,
5768
5915
  content: effectiveBuildConfigContent(effectiveConfig),
5769
- metadata: { run: runId, effectiveChanged },
5916
+ metadata: {
5917
+ run: runId,
5918
+ effectiveChanged,
5919
+ ...(localOverrides ? { localOverrides } : {}),
5920
+ },
5770
5921
  },
5771
5922
  ],
5772
5923
  (deposited) => {
@@ -5800,6 +5951,10 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5800
5951
  assertCreateAssigneeAccepted(next.tickets, wiring.tickets)
5801
5952
  assertHooksDeliverable(next, resolvedOpts)
5802
5953
  },
5954
+ {
5955
+ ...(localSource !== undefined ? { localSource } : {}),
5956
+ ...(startupLocalOverrides ? { startupLocalOverrides } : {}),
5957
+ },
5803
5958
  )
5804
5959
 
5805
5960
  // Launch flags are durable repository setters. Omission writes nothing, so
@@ -5813,7 +5968,12 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5813
5968
  // The loop's store-keyed identity (an explicit `repo` pins it).
5814
5969
  repo: resolvedOpts.repo ?? resolvedOpts.targetRepo,
5815
5970
  resident: resolvedOpts.once !== true,
5971
+ // `--web` shows what these journal refreshes read. Their frames carry no
5972
+ // change position, so while a browser is connected each one reads one
5973
+ // `getRepoChangePosition` for the page's refetch signal; nothing else.
5974
+ ...(web !== undefined ? { onRepositoryFacts: (facts) => web.publishFacts(facts) } : {}),
5816
5975
  })
5976
+ web?.attachStore(wiring.store)
5817
5977
  await view.startJournal()
5818
5978
  const actor = humanActor(buildControlUser(resolvedOpts.env))
5819
5979
  if (resolvedOpts.intake !== undefined) {
@@ -5830,7 +5990,11 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5830
5990
  {
5831
5991
  kind: _effectiveConfigKind,
5832
5992
  content: effectiveBuildConfigContent(config),
5833
- metadata: { run: runId, revision: 0 },
5993
+ metadata: {
5994
+ run: runId,
5995
+ revision: 0,
5996
+ ...(startupLocalOverrides ? { localOverrides: startupLocalOverrides } : {}),
5997
+ },
5834
5998
  },
5835
5999
  ],
5836
6000
  (deposited) => {