@defrex/autobuild 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +738 -68
  3. package/bin/ab-dispatch-generation.ts +3 -1
  4. package/docs/accounts.md +2 -1
  5. package/docs/answering-blocked-builds.md +20 -0
  6. package/docs/architecture.md +155 -25
  7. package/docs/build-store.md +10 -7
  8. package/docs/cli.md +33 -1
  9. package/docs/configuration-overview.md +4 -1
  10. package/docs/configuration.md +381 -29
  11. package/docs/dispatcher.md +63 -4
  12. package/docs/forges.md +7 -0
  13. package/docs/integration-tree.md +2 -2
  14. package/docs/operating.md +4 -2
  15. package/docs/operator-api.md +134 -6
  16. package/docs/operator-surfaces.md +85 -0
  17. package/docs/optimization-nodes.md +69 -11
  18. package/docs/plugin-authoring.md +37 -1
  19. package/docs/remote-store-protocol.md +94 -13
  20. package/docs/remote-ticket-protocol.md +40 -0
  21. package/docs/restacking.md +20 -4
  22. package/docs/setup.md +14 -2
  23. package/docs/ticket-dependencies.md +10 -3
  24. package/docs/ticket-sources.md +24 -2
  25. package/docs/tickets.md +7 -1
  26. package/docs/troubleshooting.md +8 -0
  27. package/docs/verification.md +4 -3
  28. package/docs/workspaces.md +3 -0
  29. package/package.json +9 -5
  30. package/packages/core/src/cli/accounts.ts +7 -2
  31. package/packages/core/src/cli/attention.ts +3 -1
  32. package/packages/core/src/cli/binary-direct.ts +2 -0
  33. package/packages/core/src/cli/binary-lifecycle.ts +2 -1
  34. package/packages/core/src/cli/build-control.ts +79 -1
  35. package/packages/core/src/cli/context.ts +4 -0
  36. package/packages/core/src/cli/dashboard/facts.ts +49 -53
  37. package/packages/core/src/cli/dashboard/header.ts +101 -0
  38. package/packages/core/src/cli/dashboard/model.ts +31 -39
  39. package/packages/core/src/cli/dashboard/objective-row.ts +46 -14
  40. package/packages/core/src/cli/dashboard/poll.ts +178 -76
  41. package/packages/core/src/cli/dashboard/render.ts +129 -230
  42. package/packages/core/src/cli/dashboard/row-text.ts +538 -0
  43. package/packages/core/src/cli/dashboard/timeline.ts +288 -0
  44. package/packages/core/src/cli/dashboard/vocabulary.ts +188 -0
  45. package/packages/core/src/cli/dispatch-args.ts +44 -1
  46. package/packages/core/src/cli/dispatch-frontend.ts +29 -38
  47. package/packages/core/src/cli/dispatch-launch-stop.ts +18 -0
  48. package/packages/core/src/cli/dispatch-launcher.ts +20 -7
  49. package/packages/core/src/cli/dispatch-web.ts +155 -0
  50. package/packages/core/src/cli/dispatch.ts +200 -34
  51. package/packages/core/src/cli/help.ts +87 -3
  52. package/packages/core/src/cli/init-validation.ts +3 -3
  53. package/packages/core/src/cli/main.ts +70 -6
  54. package/packages/core/src/cli/mcp.ts +35 -3
  55. package/packages/core/src/cli/objective.ts +1 -1
  56. package/packages/core/src/cli/operator-preference.ts +57 -0
  57. package/packages/core/src/cli/repo-lease.ts +2 -0
  58. package/packages/core/src/cli/repo-state.ts +56 -6
  59. package/packages/core/src/cli/repository-status.ts +97 -43
  60. package/packages/core/src/cli/status.ts +82 -1
  61. package/packages/core/src/cli/terminal-restore.ts +32 -7
  62. package/packages/core/src/cli/ticket.ts +98 -36
  63. package/packages/core/src/cli/wait.ts +14 -6
  64. package/packages/core/src/cli/watch.ts +20 -4
  65. package/packages/core/src/cli/web.ts +139 -0
  66. package/packages/core/src/config/live.ts +99 -14
  67. package/packages/core/src/config/load.ts +61 -20
  68. package/packages/core/src/config/local.ts +212 -0
  69. package/packages/core/src/config/pipeline-source.ts +2 -0
  70. package/packages/core/src/config/reference.ts +18 -0
  71. package/packages/core/src/config/schema.ts +45 -10
  72. package/packages/core/src/events/catalog.ts +4 -0
  73. package/packages/core/src/events/payloads.ts +97 -0
  74. package/packages/core/src/events/policy.ts +10 -0
  75. package/packages/core/src/events/repository.ts +46 -3
  76. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +316 -0
  77. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/017d8dd5bb6dd80b.json.gz +0 -0
  78. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/178e12f1759b7552.json.gz +0 -0
  79. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4932c70a2af97faf.json.gz +0 -0
  80. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/536085773daf6b58.json.gz +0 -0
  81. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6bd6275061aaffa5.json.gz +0 -0
  82. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/89625654b02e9ac1.json.gz +0 -0
  83. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a98af134be2da8a9.json.gz +0 -0
  84. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d5d5ccca80a893d8.json.gz +0 -0
  85. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f8155387eb5f375c.json.gz +0 -0
  86. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3c27f918b194e3b3.json +465 -0
  87. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/79f0e0f4ccd43ba2.json +455 -0
  88. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/859c09edac738823.json +1086 -0
  89. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a283c1f3462b1cc1.json +81 -0
  90. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a6e570fb126991ff.json +36 -0
  91. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a8acf22c968b6e3d.json +81 -0
  92. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/ba7b85895bf6698e.json +1153 -0
  93. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fc66408cde0b6b04.json +637 -0
  94. package/packages/core/src/kernel/build-roster.ts +230 -0
  95. package/packages/core/src/kernel/dispatch-capacity.ts +4 -2
  96. package/packages/core/src/kernel/engine.ts +43 -5
  97. package/packages/core/src/kernel/execution-intervals.ts +61 -0
  98. package/packages/core/src/kernel/generators/optimization-log.ts +101 -0
  99. package/packages/core/src/kernel/generators/repository-journals.ts +13 -0
  100. package/packages/core/src/kernel/leaf-restack-base.ts +33 -7
  101. package/packages/core/src/kernel/leaf-restack-state.ts +82 -3
  102. package/packages/core/src/kernel/log-index.ts +19 -0
  103. package/packages/core/src/kernel/optimization-admission.ts +244 -3
  104. package/packages/core/src/kernel/optimization.ts +183 -4
  105. package/packages/core/src/kernel/phase-failures.ts +121 -0
  106. package/packages/core/src/kernel/published-branch-head.ts +60 -0
  107. package/packages/core/src/kernel/reducer-registry.ts +27 -8
  108. package/packages/core/src/kernel/reducer-revisions.ts +25 -0
  109. package/packages/core/src/kernel/reducer.ts +63 -4
  110. package/packages/core/src/kernel/rollup.ts +61 -0
  111. package/packages/core/src/kernel/setup-streak.ts +38 -0
  112. package/packages/core/src/kernel/step-durations.ts +257 -0
  113. package/packages/core/src/kernel/target-observation.ts +6 -1
  114. package/packages/core/src/kernel/target-rewrite-recovery.ts +116 -0
  115. package/packages/core/src/kernel/verify-diff-base.ts +5 -0
  116. package/packages/core/src/kernel/verify-stages.ts +13 -3
  117. package/packages/core/src/ontology.ts +5 -0
  118. package/packages/core/src/operator/agent-context-serve.ts +631 -0
  119. package/packages/core/src/operator/annotations.ts +75 -5
  120. package/packages/core/src/operator/attention.ts +470 -0
  121. package/packages/core/src/operator/canonical-skills.ts +35 -0
  122. package/packages/core/src/operator/cli-equivalents.ts +270 -0
  123. package/packages/core/src/operator/context-prompts.ts +61 -0
  124. package/packages/core/src/operator/index.ts +49 -1
  125. package/packages/core/src/operator/landings.ts +28 -19
  126. package/packages/core/src/operator/optimization.ts +7 -0
  127. package/packages/core/src/operator/protocol.ts +3 -0
  128. package/packages/core/src/operator/query.ts +122 -72
  129. package/packages/core/src/operator/read-view.ts +5 -2
  130. package/packages/core/src/operator/registry.ts +406 -46
  131. package/packages/core/src/operator/requests.ts +20 -18
  132. package/packages/core/src/operator/sandbox-host.ts +107 -11
  133. package/packages/core/src/operator/sandbox-resolver.ts +253 -0
  134. package/packages/core/src/operator/sandbox.ts +778 -82
  135. package/packages/core/src/operator/ticket-asset-list.ts +77 -0
  136. package/packages/core/src/operator/ticket-assets.ts +167 -0
  137. package/packages/core/src/operator/tickets.ts +33 -2
  138. package/packages/core/src/plugin-sdk/index.ts +22 -0
  139. package/packages/core/src/plugins/manifest.ts +1 -1
  140. package/packages/core/src/ports/forge/fake.ts +92 -1
  141. package/packages/core/src/ports/forge/git-blob.ts +15 -0
  142. package/packages/core/src/ports/forge/github.ts +82 -0
  143. package/packages/core/src/ports/forge/local-git.ts +61 -1
  144. package/packages/core/src/ports/forge-failure.ts +24 -0
  145. package/packages/core/src/ports/runner/antigravity-test.fixture.ts +149 -0
  146. package/packages/core/src/ports/runner/claude-test.fixture.ts +71 -0
  147. package/packages/core/src/ports/runner/codex-test.fixture.ts +63 -0
  148. package/packages/core/src/ports/tickets/contract.ts +71 -0
  149. package/packages/core/src/ports/tickets/fake.ts +11 -0
  150. package/packages/core/src/ports/tickets/file.ts +18 -0
  151. package/packages/core/src/ports/tickets/github-fake.ts +136 -4
  152. package/packages/core/src/ports/tickets/github.ts +387 -30
  153. package/packages/core/src/ports/tickets/hosted-index.ts +10 -0
  154. package/packages/core/src/ports/tickets/linear.ts +130 -0
  155. package/packages/core/src/ports/tickets/priority.ts +9 -0
  156. package/packages/core/src/ports/tickets/remote-protocol.ts +34 -0
  157. package/packages/core/src/ports/tickets/remote.ts +70 -6
  158. package/packages/core/src/ports/tickets/search.ts +139 -0
  159. package/packages/core/src/ports/types.ts +104 -2
  160. package/packages/core/src/ports/workspace/builtin-capabilities.ts +9 -0
  161. package/packages/core/src/ports/workspace/create.ts +15 -1
  162. package/packages/core/src/ports/workspace/fake.ts +340 -12
  163. package/packages/core/src/ports/workspace/git-worktree.ts +833 -42
  164. package/packages/core/src/ports/workspace/operator-sandbox.ts +129 -12
  165. package/packages/core/src/ports/workspace/process-group.ts +48 -0
  166. package/packages/core/src/ports/workspace/vercel-sandbox.ts +1260 -123
  167. package/packages/core/src/processes/agent-context-assemble.ts +576 -0
  168. package/packages/core/src/processes/agent-context.ts +469 -0
  169. package/packages/core/src/processes/build-runner.ts +387 -236
  170. package/packages/core/src/processes/dispatcher.ts +211 -55
  171. package/packages/core/src/processes/execution-no-progress.ts +4 -0
  172. package/packages/core/src/processes/optimization-activity.ts +120 -0
  173. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  174. package/packages/core/src/processes/repo-view.ts +78 -2
  175. package/packages/core/src/processes/sandbox-state.ts +53 -6
  176. package/packages/core/src/processes/tick-publication.ts +2 -0
  177. package/packages/core/src/processes/workspace-preparation.ts +76 -0
  178. package/packages/core/src/scenarios/harness.ts +0 -5
  179. package/packages/core/src/store/account-redaction.ts +1 -0
  180. package/packages/core/src/store/adapter.ts +52 -1
  181. package/packages/core/src/store/agent-context.ts +432 -0
  182. package/packages/core/src/store/build-feed.ts +291 -0
  183. package/packages/core/src/store/build-scope.ts +19 -1
  184. package/packages/core/src/store/contract.ts +911 -14
  185. package/packages/core/src/store/digest.ts +19 -6
  186. package/packages/core/src/store/histogram.ts +113 -0
  187. package/packages/core/src/store/local/schema.ts +62 -0
  188. package/packages/core/src/store/local/store.ts +628 -22
  189. package/packages/core/src/store/local/ticket-asset-heads.ts +23 -0
  190. package/packages/core/src/store/memory.ts +461 -69
  191. package/packages/core/src/store/open-builds.ts +19 -0
  192. package/packages/core/src/store/phase-session.ts +32 -4
  193. package/packages/core/src/store/reduced-reads.ts +14 -4
  194. package/packages/core/src/store/reducer-value-shapes.json +6987 -5749
  195. package/packages/core/src/store/reducer-values.ts +6 -1
  196. package/packages/core/src/store/remote/client.ts +208 -2
  197. package/packages/core/src/store/remote/compatibility.ts +1 -1
  198. package/packages/core/src/store/remote/index.ts +33 -0
  199. package/packages/core/src/store/remote/protocol.ts +69 -0
  200. package/packages/core/src/store/remote/released-clients.json +11 -0
  201. package/packages/core/src/store/remote/released-reducer-values/1.11.0.json +35680 -0
  202. package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -16
  203. package/packages/core/src/store/retention.ts +23 -1
  204. package/packages/core/src/store/rollups.ts +337 -0
  205. package/packages/core/src/store/session-handle.ts +20 -2
  206. package/packages/core/src/store/snapshots.ts +10 -0
  207. package/packages/core/src/store/types.ts +108 -9
  208. package/packages/core/src/testing/dispatch-read-budget.ts +1092 -2
  209. package/packages/core/src/testing/git-config-isolation.ts +7 -5
  210. package/packages/core/src/testing/index.ts +27 -0
  211. package/packages/core/src/testing/memory-operator-sandbox.ts +346 -0
  212. package/packages/core/src/testing/reduced-read-budget.ts +1873 -98
  213. package/packages/core/src/web/analytics-source.ts +303 -0
  214. package/packages/core/src/web/assets/Atkinson-OFL.txt +93 -0
  215. package/packages/core/src/web/assets/AtkinsonHyperlegibleNext.latin.woff2 +0 -0
  216. package/packages/core/src/web/assets/JetBrains-OFL.txt +93 -0
  217. package/packages/core/src/web/assets/JetBrainsMono.latin.woff2 +0 -0
  218. package/packages/core/src/web/assets/app.css +1 -0
  219. package/packages/core/src/web/assets/app.js +9 -0
  220. package/packages/core/src/web/assets/manifest.json +31 -0
  221. package/packages/core/src/web/assets/theme.js +1 -0
  222. package/packages/core/src/web/bounded.ts +31 -0
  223. package/packages/core/src/web/http.ts +315 -0
  224. package/packages/core/src/web/hub.ts +160 -0
  225. package/packages/core/src/web/options.ts +38 -0
  226. package/packages/core/src/web/overview-source.ts +322 -0
  227. package/packages/core/src/web/page.ts +56 -0
  228. package/packages/core/src/web/protocol.ts +151 -0
  229. package/packages/core/src/web/read-only.ts +23 -0
  230. package/packages/core/src/web/repository-source.ts +35 -0
  231. package/packages/core/src/web/server.ts +97 -0
  232. package/skills/code-review/SKILL.md +10 -2
  233. package/skills/guide/SKILL.md +366 -52
  234. package/skills/guide/references/accounts.md +2 -1
  235. package/skills/guide/references/integration-tree.md +2 -2
  236. package/skills/guide/references/operator-api.md +134 -6
  237. package/skills/guide/references/optimization-nodes.md +69 -11
  238. package/skills/guide/references/plugin-authoring.md +37 -1
  239. package/skills/guide/references/remote-store-protocol.md +94 -13
  240. package/skills/guide/references/remote-ticket-protocol.md +40 -0
  241. package/skills/guide/references/restacking.md +20 -4
  242. package/skills/guide/references/setup.md +14 -2
  243. package/skills/guide/references/ticket-dependencies.md +10 -3
  244. package/skills/implement/SKILL.md +23 -4
  245. package/skills/operate/SKILL.md +134 -32
  246. package/skills/plan/SKILL.md +10 -4
  247. package/skills/plan-review/SKILL.md +9 -2
  248. package/skills/spec/SKILL.md +34 -8
  249. package/skills/tickets/SKILL.md +51 -5
  250. package/templates/hosted-service/package.json +2 -2
@@ -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'
@@ -180,7 +196,7 @@ import type {
180
196
  WorkspaceReapOutcome,
181
197
  } from '../ports/types'
182
198
  import { createWorkspaceRuntime, type WorkspaceRuntime } from '../ports/workspace/create'
183
- import { GitWorktreeProvider } from '../ports/workspace/git-worktree'
199
+ import { GitWorktreeProvider, worktreeIsolationNotice } from '../ports/workspace/git-worktree'
184
200
  import { LocalBuildExecution } from '../ports/workspace/local-build-execution'
185
201
  import {
186
202
  BUILD_EXECUTION_LEASE_TTL_MS,
@@ -378,6 +394,9 @@ export interface DispatchWiring {
378
394
  plugins?: PluginRegistry
379
395
  /** Keeps workspace-owned runtime preflights aligned with accepted hot role reloads. */
380
396
  updateRuntimeReferences?: (config: Config) => void
397
+ /** Wiring-time startup notices (a workspace destination that cannot take
398
+ * new builds), shown with the configuration-level startup warnings. */
399
+ startupNotices?: readonly string[]
381
400
  }
382
401
 
383
402
  export type DispatchNonStoreWiring = Omit<DispatchWiring, 'store' | 'storeRef' | 'token'>
@@ -440,6 +459,9 @@ export interface DispatchOpts {
440
459
  stderr: (line: string) => void
441
460
  /** Single pass then drain in-flight runners and exit; default is a loop. */
442
461
  once?: boolean
462
+ /** Test seam: the dashboard's presentation refresh timers. Unset keeps the
463
+ * real scheduler; kernel timers never use it. */
464
+ refreshScheduler?: RefreshScheduler
443
465
  /** Watch-loop cadence in ms (§3.3); default DEFAULT_INTERVAL_MS. */
444
466
  intervalMs?: number
445
467
  /** Explicit durable repository intake override. Omission reuses stored state,
@@ -527,9 +549,23 @@ export interface DispatchOpts {
527
549
  * config error at startup and on reload, never silently ignored. URL hooks
528
550
  * are delivered either way. */
529
551
  localCommands?: false
552
+ /** Where `[orchestrator].enabled` is resolved (`orchestratorEnabled`): an
553
+ * unset value is enabled for `hosted` and disabled for `local`. Default
554
+ * `local`; the hosted dispatcher passes `hosted`. */
555
+ orchestratorHost?: OrchestratorHost
530
556
  /** Test seam for configured hook delivery; defaults to running the hook's
531
557
  * command or POSTing to its URL (`processes/hook-webhook.ts`). */
532
558
  invokeHook?: HookInvoke
559
+ /** `--web`: serve the read-only web UI from this process. It binds before
560
+ * the repository lease, and frames come from the refresh this dispatcher
561
+ * already runs; only the kernel path adds one change-position read per
562
+ * frame while a browser is connected. `start` is a test seam that replaces
563
+ * the real socket bind. */
564
+ web?: DispatchWebArgs & { start?: WebServerStarter }
565
+ /** Private: closes this generation's web server. `abDispatch` sets it; the
566
+ * loop awaits it before `dispatcher.terminal-released`, so a successor can
567
+ * bind the same port. */
568
+ releaseWeb?: () => Promise<void>
533
569
  }
534
570
 
535
571
  /** Reject hooks this dispatcher cannot deliver: command hooks where local
@@ -699,12 +735,15 @@ async function defaultWire(
699
735
  accountRedactor(() => allAccounts, opts.env),
700
736
  )
701
737
  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.
738
+ // The builtin provider places build worktrees outside the checkout's
739
+ // package ancestry: the state tree's own worktrees/ when that resolves
740
+ // outside the checkout, else the per-checkout isolated root. Plugin
741
+ // factories receive only their explicit config plus repository/environment
742
+ // context.
705
743
  const workspaceRuntime = await createWorkspaceRuntime(config.workspace, {
706
744
  registry: plugins,
707
745
  worktreeRoot: opened.worktreeRoot,
746
+ isolatedWorktreeRoot: opened.isolatedWorktreeRoot,
708
747
  // Plugin factories always get the filesystem checkout (the physical path
709
748
  // or the origin-mode scratch root) — never the store identity.
710
749
  repoRoot: state.checkout,
@@ -716,7 +755,8 @@ async function defaultWire(
716
755
  sandboxSetupCommand: config.commands.setup,
717
756
  sandboxRoot: resolve(join(opened.localStateRoot, 'orchestrator-sandboxes')),
718
757
  sandboxEnvironmentVariables: config.orchestrator.sandbox.environmentVariables,
719
- orchestratorSandboxEnabled: config.orchestrator.enabled,
758
+ sandboxIdleMinutes: config.orchestrator.sandbox.idleMinutes,
759
+ orchestratorSandboxEnabled: orchestratorEnabled(config, opts.orchestratorHost ?? 'local'),
720
760
  ...providerSeams,
721
761
  ...(refusedArchive !== undefined ? { refusedArchive } : {}),
722
762
  ...(opened.token !== undefined ? { storeToken: opened.token } : {}),
@@ -729,11 +769,24 @@ async function defaultWire(
729
769
  ? []
730
770
  : [
731
771
  {
732
- provider: new GitWorktreeProvider({ root: resolve(opened.worktreeRoot) }),
772
+ provider: new GitWorktreeProvider({
773
+ root: resolve(opened.worktreeRoot),
774
+ isolatedRoot: opened.isolatedWorktreeRoot,
775
+ }),
733
776
  execution: new LocalBuildExecution({ env: opts.env }),
734
777
  },
735
778
  ]
736
779
 
780
+ // Once per process start, a few lstat calls and no store reads: a host with
781
+ // no isolated destination is told why at startup. Never a gate — fresh
782
+ // provisioning fails per build, and recorded or legacy worktrees continue.
783
+ const isolationNotice =
784
+ !originMode &&
785
+ config.workspace.provider === 'git-worktree' &&
786
+ workspaceRuntime.provider instanceof GitWorktreeProvider
787
+ ? await worktreeIsolationNotice(workspaceRuntime.provider, state.checkout)
788
+ : undefined
789
+
737
790
  return {
738
791
  store: opened.store,
739
792
  renewAccounts,
@@ -745,6 +798,7 @@ async function defaultWire(
745
798
  workspaces: workspaceRuntime.provider,
746
799
  retiredWorkspaces,
747
800
  buildExecution: workspaceRuntime.execution,
801
+ ...(isolationNotice !== undefined ? { startupNotices: [isolationNotice] } : {}),
748
802
  // Shipped registrations are shared with other non-phase judgment paths.
749
803
  // Model ids stay in config; production.ts owns adapter compatibility data.
750
804
  runtimes,
@@ -1111,6 +1165,7 @@ class DispatchLoop {
1111
1165
  missingAccounts: () => this.missingAccounts(),
1112
1166
  accountCredentialSource: opts.repository ? 'project-secrets' : 'environment',
1113
1167
  repairBuildConfig: (slug) => this.publishBuildConfig(slug),
1168
+ ...(opts.orchestratorHost !== undefined ? { orchestratorHost: opts.orchestratorHost } : {}),
1114
1169
  repo: this.repoIdentity,
1115
1170
  // Origin mode: the forge answers remote base-branch questions; no
1116
1171
  // checkout git is probed for the served repository's origin.
@@ -1130,6 +1185,14 @@ class DispatchLoop {
1130
1185
  // skip foreign-execution settlement for builds this process supervises.
1131
1186
  settlePublication: (slug) => this.settlePendingPublication(slug),
1132
1187
  activeExecutions: () => new Set(this.activeBuildRuns.keys()),
1188
+ // Both modes read the base branch through the forge, so a checkout
1189
+ // dispatcher and an origin-mode one record the same agent context.
1190
+ agentContext: new AgentContextCapture({
1191
+ store: this.repoView,
1192
+ repo: this.repoIdentity,
1193
+ forge: wiring.forge,
1194
+ now: () => wiring.clock().getTime(),
1195
+ }),
1133
1196
  opts: {
1134
1197
  maxHarvestRecoveryAttempts: this.maxHarvestRecoveryAttempts,
1135
1198
  },
@@ -3242,6 +3305,7 @@ class DispatchLoop {
3242
3305
  ticketDiagnostics: _ticketDiagnostics,
3243
3306
  creationDiagnostics: _creationDiagnostics,
3244
3307
  dependencyDiagnostics: _dependencyDiagnostics,
3308
+ agentContextDiagnostics: _agentContextDiagnostics,
3245
3309
  ...counters
3246
3310
  } = merged
3247
3311
  const completed = {
@@ -3895,14 +3959,21 @@ class DispatchLoop {
3895
3959
  this.paint()
3896
3960
  }
3897
3961
 
3962
+ /** Plain/non-TTY `--web`: the web UI is the only presentation, so routine
3963
+ * line-oriented stdout is suppressed. Warnings and diagnostics stay on
3964
+ * stderr. */
3965
+ private get webPresents(): boolean {
3966
+ return !this.dashboard && this.opts.web !== undefined
3967
+ }
3968
+
3898
3969
  private say(line: string): void {
3899
- if (this.presentationReleased) return
3970
+ if (this.presentationReleased || this.webPresents) return
3900
3971
  if (!this.dashboard && this.opts.silent !== true) this.opts.stdout(line)
3901
3972
  }
3902
3973
 
3903
3974
  /** Routine acknowledgement: line-oriented stdout, dashboard-silent. */
3904
3975
  private announce(line: string): void {
3905
- if (!this.dashboard) this.opts.stdout(line)
3976
+ if (!this.dashboard && !this.webPresents) this.opts.stdout(line)
3906
3977
  }
3907
3978
 
3908
3979
  private hooks: HookSupervisor | undefined
@@ -3987,11 +4058,14 @@ class DispatchLoop {
3987
4058
  else if (this.opts.silent !== true) this.opts.stderr(line)
3988
4059
  }
3989
4060
 
3990
- /** Failure-severity dashboard notice whose historical plain sink is stdout. */
4061
+ /** Failure-severity dashboard notice whose historical plain sink is stdout;
4062
+ * under `--web` it moves to stderr so stdout carries only the URL. */
3991
4063
  private failureNotice(line: string): void {
3992
4064
  if (this.presentationReleased) return
3993
4065
  if (this.dashboard) this.setWarning(line)
3994
- else if (this.opts.silent !== true) this.opts.stdout(line)
4066
+ else if (this.opts.silent === true) return
4067
+ else if (this.webPresents) this.opts.stderr(line)
4068
+ else this.opts.stdout(line)
3995
4069
  }
3996
4070
 
3997
4071
  /** Routine diagnostic whose historical line-oriented sink is stderr. */
@@ -4070,6 +4144,7 @@ class DispatchLoop {
4070
4144
  const lines = [
4071
4145
  ...this.liveConfig.deprecations(),
4072
4146
  ...startupWarnings(this.currentConfig().config, this.wiring.forge),
4147
+ ...(this.wiring.startupNotices ?? []),
4073
4148
  ]
4074
4149
  if (this.dashboard) {
4075
4150
  this.configWarnings = lines
@@ -4107,10 +4182,13 @@ class DispatchLoop {
4107
4182
  ticketDiagnostics,
4108
4183
  creationDiagnostics,
4109
4184
  dependencyDiagnostics,
4185
+ agentContextDiagnostics,
4110
4186
  queued: _queued,
4111
4187
  ...counts
4112
4188
  } = report
4113
4189
  for (const line of janitorDiagnostics) this.routineDiagnostic(line)
4190
+ for (const diagnostic of agentContextDiagnostics)
4191
+ this.routineDiagnostic(formatAgentContextDiagnostic(diagnostic))
4114
4192
  for (const line of blockedDiagnostics) this.say(line)
4115
4193
  for (const line of ticketDiagnostics) this.routineDiagnostic(line)
4116
4194
  for (const line of creationDiagnostics) this.say(line)
@@ -4127,11 +4205,12 @@ class DispatchLoop {
4127
4205
  blockedDiagnostics.length > 0 ||
4128
4206
  ticketDiagnostics.length > 0 ||
4129
4207
  creationDiagnostics.length > 0 ||
4130
- dependencyDiagnostics.length > 0
4208
+ dependencyDiagnostics.length > 0 ||
4209
+ agentContextDiagnostics.length > 0
4131
4210
  if (reportedDiagnostic) return true
4132
4211
  // A tick that did something is worth a plain line. Interactive mode
4133
4212
  // suppresses both action counts and the every-10s idle noise.
4134
- if (!this.dashboard && printIdle) {
4213
+ if (!this.dashboard && !this.webPresents && printIdle) {
4135
4214
  this.opts.stdout('tick: idle')
4136
4215
  return true
4137
4216
  }
@@ -4379,7 +4458,7 @@ class DispatchLoop {
4379
4458
  throw error
4380
4459
  }
4381
4460
  },
4382
- undefined,
4461
+ this.opts.refreshScheduler,
4383
4462
  this.presentationStore.networkReads,
4384
4463
  )
4385
4464
  if (this.opts.once !== true) {
@@ -4950,6 +5029,8 @@ class DispatchLoop {
4950
5029
  // Interactive kernels have no terminal authority. Their frontend must
4951
5030
  // acknowledge removal and joining of input/render work itself.
4952
5031
  if (this.opts.kernelRunId === undefined) {
5032
+ // Free the web port before the successor may bind it.
5033
+ await this.opts.releaseWeb?.()
4953
5034
  await this.repoView.appendRepo(this.repoIdentity, {
4954
5035
  actor: DISPATCHER,
4955
5036
  type: 'dispatcher.terminal-released',
@@ -4998,8 +5079,9 @@ class DispatchLoop {
4998
5079
  // Read-only policy supervision: never another tick or config fan-out.
4999
5080
  try {
5000
5081
  // Deprecations were reported at startup/reload; this re-read stays quiet.
5082
+ // Layered with the checkout's local override file, like the snapshot.
5001
5083
  const path = join(this.opts.targetRepo, 'autobuild.toml')
5002
- const config = parseConfig(await Bun.file(path).text(), path, () => {})
5084
+ const config = await loadConfig(path, () => {})
5003
5085
  const { createRuntimeResolver } = await import('../ports/runner/routing')
5004
5086
  createRuntimeResolver(
5005
5087
  this.wiring.runtimes,
@@ -5481,16 +5563,23 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5481
5563
  ? { AB_TOKEN: projectToken(state.storeRef, state.repo, opts.env) }
5482
5564
  : {}),
5483
5565
  }
5484
- const opened = openStoreForRepoState(state, { env })
5566
+ const web = await startOptionalDispatchWeb(opts, opts.repo ?? state.repo)
5567
+ let opened: ReturnType<typeof openStoreForRepoState> | undefined
5485
5568
  try {
5569
+ opened = openStoreForRepoState(state, { env })
5486
5570
  const interactive =
5487
5571
  opts.plain !== true && opts.terminal?.interactive === true && opts.input !== undefined
5572
+ // Without a TTY the web UI is the only presentation: the viewer reads
5573
+ // exactly as it would, and its text frames are discarded.
5574
+ const plainOutput = web !== undefined ? () => {} : opts.stdout
5575
+ const store = opened
5576
+ web?.attachStore(store.store)
5488
5577
  await new DispatchFrontend({
5489
5578
  viewer: { ...(opts.dispatchedBy !== undefined ? { dispatchedBy: opts.dispatchedBy } : {}) },
5490
5579
  repo: opts.repo ?? state.repo,
5491
5580
  checkout: state.checkout,
5492
- store: opened.store,
5493
- storeRef: opened.storeRef,
5581
+ store: store.store,
5582
+ storeRef: store.storeRef,
5494
5583
  env,
5495
5584
  terminal: opts.terminal ?? {
5496
5585
  columns: 100,
@@ -5503,7 +5592,8 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5503
5592
  ),
5504
5593
  },
5505
5594
  input: opts.input ?? { start: () => () => {} },
5506
- ...(!interactive ? { plainOutput: opts.stdout } : {}),
5595
+ ...(!interactive ? { plainOutput } : {}),
5596
+ ...(web !== undefined ? { web: { dispatch: web } } : {}),
5507
5597
  controlTickets: () =>
5508
5598
  lazyTicketSource(() =>
5509
5599
  openTicketSource(
@@ -5511,7 +5601,7 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5511
5601
  targetRepo: state.checkout,
5512
5602
  exec: opts.exec,
5513
5603
  env,
5514
- storeRef: opened.storeRef,
5604
+ storeRef: store.storeRef,
5515
5605
  stdout: opts.stdout,
5516
5606
  },
5517
5607
  'ab merge',
@@ -5525,7 +5615,8 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5525
5615
  : {}),
5526
5616
  }).run()
5527
5617
  } finally {
5528
- await opened.store.close()
5618
+ await web?.close()
5619
+ await opened?.store.close()
5529
5620
  }
5530
5621
  return
5531
5622
  }
@@ -5594,13 +5685,18 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5594
5685
  'interactive dashboard: pass --plain or run it without a TTY',
5595
5686
  )
5596
5687
  }
5597
- const opened = openStoreForRepoState(state, { env: resolvedOpts.env })
5688
+ const web = await startOptionalDispatchWeb(resolvedOpts, state.repo)
5689
+ let opened: ReturnType<typeof openStoreForRepoState> | undefined
5598
5690
  try {
5691
+ opened = openStoreForRepoState(state, { env: resolvedOpts.env })
5692
+ const store = opened
5693
+ web?.attachStore(store.store)
5599
5694
  const frontend = new DispatchFrontend({
5600
5695
  repo: state.repo,
5601
5696
  checkout: state.checkout,
5602
- storeRef: opened.storeRef,
5603
- store: opened.store,
5697
+ storeRef: store.storeRef,
5698
+ store: store.store,
5699
+ ...(web !== undefined ? { web: { dispatch: web } } : {}),
5604
5700
  controlTickets: () =>
5605
5701
  lazyTicketSource(() =>
5606
5702
  openTicketSource(
@@ -5608,7 +5704,7 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5608
5704
  targetRepo: state.checkout,
5609
5705
  exec: resolvedOpts.exec,
5610
5706
  env: resolvedOpts.env,
5611
- storeRef: opened.storeRef,
5707
+ storeRef: store.storeRef,
5612
5708
  stdout: resolvedOpts.stdout,
5613
5709
  },
5614
5710
  'ab merge',
@@ -5630,14 +5726,55 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5630
5726
  })
5631
5727
  await frontend.run()
5632
5728
  } finally {
5633
- await opened.store.close()
5729
+ await web?.close()
5730
+ await opened?.store.close()
5634
5731
  }
5635
5732
  return
5636
5733
  }
5637
5734
 
5735
+ // The plain kernel's web UI binds before config, wiring and any lease, and
5736
+ // is fed by the repository view's own journal refreshes.
5737
+ const web = await startOptionalDispatchWeb(resolvedOpts, state.repo)
5738
+ if (web !== undefined) resolvedOpts.releaseWeb = web.close
5739
+ try {
5740
+ await runDispatchKernel(opts, resolvedOpts, state, originConfig, web)
5741
+ } finally {
5742
+ await web?.close()
5743
+ }
5744
+ }
5745
+
5746
+ async function startOptionalDispatchWeb(
5747
+ opts: DispatchOpts,
5748
+ repo: string,
5749
+ ): Promise<DispatchWeb | undefined> {
5750
+ if (opts.web === undefined) return undefined
5751
+ const { start, ...options } = opts.web
5752
+ return startDispatchWeb({
5753
+ options,
5754
+ repo,
5755
+ env: opts.env,
5756
+ stdout: opts.stdout,
5757
+ stderr: opts.stderr,
5758
+ ...(start !== undefined ? { start } : {}),
5759
+ })
5760
+ }
5761
+
5762
+ /** The in-process kernel path of `abDispatch`: plain/non-TTY dispatch,
5763
+ * private kernel children and injected wiring. */
5764
+ async function runDispatchKernel(
5765
+ opts: DispatchOpts,
5766
+ resolvedOpts: DispatchOpts,
5767
+ state: RepoStatePaths,
5768
+ originConfig: Awaited<ReturnType<typeof fetchOriginModeConfig>> | undefined,
5769
+ web: DispatchWeb | undefined,
5770
+ ): Promise<void> {
5638
5771
  const configPath = join(resolvedOpts.targetRepo, 'autobuild.toml')
5639
5772
  let configContent: string
5640
5773
  let config: Config
5774
+ // Checkout mode only: the local override file layered over autobuild.toml.
5775
+ let localContent: string | undefined
5776
+ let localSource: string | undefined
5777
+ let startupLocalOverrides: LocalOverrideRecord | undefined
5641
5778
  // Collected, never written at parse time: the dispatcher reports them once
5642
5779
  // with its other configuration notices (`reportRoleDiagnostics`).
5643
5780
  let startupDeprecations: readonly string[] = []
@@ -5675,8 +5812,16 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5675
5812
  } else {
5676
5813
  try {
5677
5814
  configContent = await Bun.file(configPath).text()
5815
+ localSource = localConfigPath(resolvedOpts.targetRepo)
5816
+ const local = await readLocalConfig(resolvedOpts.targetRepo)
5817
+ localContent = local?.text
5678
5818
  const deprecations: string[] = []
5679
- config = parseConfig(configContent, configPath, (line) => deprecations.push(line))
5819
+ const layered = parseLayeredConfig(
5820
+ { committed: { text: configContent, source: configPath }, local },
5821
+ (line) => deprecations.push(line),
5822
+ )
5823
+ config = layered.config
5824
+ startupLocalOverrides = layered.localOverrides
5680
5825
  startupDeprecations = deprecations
5681
5826
  } catch (error) {
5682
5827
  if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
@@ -5752,21 +5897,29 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5752
5897
  const liveConfig = new LiveConfig(
5753
5898
  configPath,
5754
5899
  config,
5755
- configContent,
5900
+ localContent === undefined ? configContent : { committed: configContent, local: localContent },
5756
5901
  wiring.runtimes,
5757
- async ({ content, effectiveConfig, restartRequired, effectiveChanged }) => {
5902
+ async ({ content, localOverrides, effectiveConfig, restartRequired, effectiveChanged }) => {
5758
5903
  await wiring.store.appendRepoWithArtifacts(
5759
5904
  state.repo,
5760
5905
  [
5761
5906
  {
5762
5907
  kind: DISPATCHER_CONFIG_ARTIFACT,
5763
5908
  content,
5764
- metadata: { restartRequired: [...restartRequired], effectiveChanged },
5909
+ metadata: {
5910
+ restartRequired: [...restartRequired],
5911
+ effectiveChanged,
5912
+ ...(localOverrides ? { localOverrides } : {}),
5913
+ },
5765
5914
  },
5766
5915
  {
5767
5916
  kind: _effectiveConfigKind,
5768
5917
  content: effectiveBuildConfigContent(effectiveConfig),
5769
- metadata: { run: runId, effectiveChanged },
5918
+ metadata: {
5919
+ run: runId,
5920
+ effectiveChanged,
5921
+ ...(localOverrides ? { localOverrides } : {}),
5922
+ },
5770
5923
  },
5771
5924
  ],
5772
5925
  (deposited) => {
@@ -5800,6 +5953,10 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5800
5953
  assertCreateAssigneeAccepted(next.tickets, wiring.tickets)
5801
5954
  assertHooksDeliverable(next, resolvedOpts)
5802
5955
  },
5956
+ {
5957
+ ...(localSource !== undefined ? { localSource } : {}),
5958
+ ...(startupLocalOverrides ? { startupLocalOverrides } : {}),
5959
+ },
5803
5960
  )
5804
5961
 
5805
5962
  // Launch flags are durable repository setters. Omission writes nothing, so
@@ -5813,7 +5970,12 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5813
5970
  // The loop's store-keyed identity (an explicit `repo` pins it).
5814
5971
  repo: resolvedOpts.repo ?? resolvedOpts.targetRepo,
5815
5972
  resident: resolvedOpts.once !== true,
5973
+ // `--web` shows what these journal refreshes read. Their frames carry no
5974
+ // change position, so while a browser is connected each one reads one
5975
+ // `getRepoChangePosition` for the page's refetch signal; nothing else.
5976
+ ...(web !== undefined ? { onRepositoryFacts: (facts) => web.publishFacts(facts) } : {}),
5816
5977
  })
5978
+ web?.attachStore(wiring.store)
5817
5979
  await view.startJournal()
5818
5980
  const actor = humanActor(buildControlUser(resolvedOpts.env))
5819
5981
  if (resolvedOpts.intake !== undefined) {
@@ -5830,7 +5992,11 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5830
5992
  {
5831
5993
  kind: _effectiveConfigKind,
5832
5994
  content: effectiveBuildConfigContent(config),
5833
- metadata: { run: runId, revision: 0 },
5995
+ metadata: {
5996
+ run: runId,
5997
+ revision: 0,
5998
+ ...(startupLocalOverrides ? { localOverrides: startupLocalOverrides } : {}),
5999
+ },
5834
6000
  },
5835
6001
  ],
5836
6002
  (deposited) => {