@defrex/autobuild 1.0.1 → 1.2.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 (247) hide show
  1. package/README.md +10 -18
  2. package/SPEC.md +499 -238
  3. package/bin/ab-dispatch-generation.ts +11 -2
  4. package/docs/accounts.md +119 -0
  5. package/docs/agent-runtimes.md +4 -4
  6. package/docs/answering-blocked-builds.md +2 -2
  7. package/docs/architecture.md +262 -53
  8. package/docs/assets/headline-wide.png +0 -0
  9. package/docs/build-store.md +3 -41
  10. package/docs/builds.md +4 -4
  11. package/docs/cli.md +18 -4
  12. package/docs/configuration-overview.md +115 -4
  13. package/docs/configuration.md +488 -334
  14. package/docs/dispatcher-hosting.md +19 -34
  15. package/docs/dispatcher.md +1 -1
  16. package/docs/forges.md +5 -5
  17. package/docs/getting-started.md +2 -2
  18. package/docs/glossary.md +6 -6
  19. package/docs/intake.md +2 -0
  20. package/docs/integration-overview.md +15 -15
  21. package/docs/integration-tree.md +45 -38
  22. package/docs/integration.md +6 -6
  23. package/{skills/guide/references/landing-policy.md → docs/merge-policy.md} +40 -24
  24. package/docs/migration-1.0.md +17 -13
  25. package/docs/operating.md +41 -19
  26. package/docs/operator-api.md +180 -51
  27. package/docs/operator-surfaces.md +5 -18
  28. package/docs/overview.md +3 -3
  29. package/docs/plugin-authoring.md +21 -0
  30. package/docs/remote-store-protocol.md +242 -68
  31. package/docs/remote-ticket-protocol.md +30 -50
  32. package/docs/restacking.md +54 -15
  33. package/docs/seams.md +8 -8
  34. package/docs/setup.md +59 -119
  35. package/docs/skills.md +1 -1
  36. package/docs/spec-standard.md +6 -6
  37. package/docs/ticket-dependencies.md +7 -7
  38. package/docs/ticket-sources.md +18 -0
  39. package/docs/tickets.md +8 -2
  40. package/docs/troubleshooting.md +8 -12
  41. package/docs/upgrading.md +9 -4
  42. package/docs/verification.md +60 -14
  43. package/docs/workspaces.md +4 -4
  44. package/package.json +17 -6
  45. package/packages/core/src/accounts/chatgpt-oauth.ts +216 -0
  46. package/packages/core/src/accounts/chatgpt-state.ts +41 -0
  47. package/packages/core/src/accounts/local-credentials.ts +194 -0
  48. package/packages/core/src/accounts/local-inference.ts +106 -0
  49. package/packages/core/src/accounts/local-owner.ts +123 -0
  50. package/packages/core/src/accounts/sensitive.ts +2 -0
  51. package/packages/core/src/cli/accounts.ts +147 -0
  52. package/packages/core/src/cli/binary-direct.ts +13 -1
  53. package/packages/core/src/cli/binary-lifecycle.ts +65 -2
  54. package/packages/core/src/cli/binary.ts +3 -1
  55. package/packages/core/src/cli/build-control.ts +83 -28
  56. package/packages/core/src/cli/connect.ts +3 -3
  57. package/packages/core/src/cli/context.ts +81 -38
  58. package/packages/core/src/cli/dashboard/facts.ts +2 -1
  59. package/packages/core/src/cli/dashboard/integration-detail.ts +8 -8
  60. package/packages/core/src/cli/dashboard/integration-row.ts +40 -13
  61. package/packages/core/src/cli/dashboard/landing-display.ts +25 -0
  62. package/packages/core/src/cli/dashboard/model.ts +56 -33
  63. package/packages/core/src/cli/dashboard/poll.ts +9 -3
  64. package/packages/core/src/cli/dashboard/render.ts +59 -37
  65. package/packages/core/src/cli/dashboard/target-distance.ts +14 -0
  66. package/packages/core/src/cli/dashboard/tree.ts +3 -2
  67. package/packages/core/src/cli/dispatch-args.ts +1 -1
  68. package/packages/core/src/cli/dispatch-frontend.ts +6 -3
  69. package/packages/core/src/cli/dispatch-handoff.ts +125 -44
  70. package/packages/core/src/cli/dispatch-launch-contract.ts +187 -0
  71. package/packages/core/src/cli/dispatch-launcher.ts +54 -21
  72. package/packages/core/src/cli/dispatch-preflight.ts +6 -1
  73. package/packages/core/src/cli/dispatch.ts +106 -11
  74. package/packages/core/src/cli/env.ts +4 -0
  75. package/packages/core/src/cli/help.ts +46 -23
  76. package/packages/core/src/cli/init-readiness-remote.ts +22 -1
  77. package/packages/core/src/cli/init-readiness-shared.ts +5 -1
  78. package/packages/core/src/cli/init-validation.ts +160 -18
  79. package/packages/core/src/cli/main.ts +68 -8
  80. package/packages/core/src/cli/node-verification-provenance.ts +1 -97
  81. package/packages/core/src/cli/publication-settlement.ts +47 -21
  82. package/packages/core/src/cli/repository-status.ts +20 -9
  83. package/packages/core/src/cli/secrets.ts +173 -0
  84. package/packages/core/src/cli/status.ts +42 -5
  85. package/packages/core/src/cli/store-opening.ts +17 -2
  86. package/packages/core/src/cli/terminal.ts +22 -1
  87. package/packages/core/src/cli/terminals.ts +14 -10
  88. package/packages/core/src/cli/upgrade-agent.ts +9 -1
  89. package/packages/core/src/cli/upgrade-landing.ts +70 -30
  90. package/packages/core/src/cli/upgrade.ts +3 -1
  91. package/packages/core/src/cli/wait.ts +15 -7
  92. package/packages/core/src/cli/watch-lifetime.ts +111 -0
  93. package/packages/core/src/cli/watch.ts +635 -510
  94. package/packages/core/src/config/accounts.ts +101 -0
  95. package/packages/core/src/config/effective-artifact.fixture.ts +27 -0
  96. package/packages/core/src/config/effective-artifact.ts +13 -0
  97. package/packages/core/src/config/landing.ts +1 -1
  98. package/packages/core/src/config/live.ts +14 -1
  99. package/packages/core/src/config/load.ts +21 -1
  100. package/packages/core/src/config/pipeline-source.ts +28 -0
  101. package/packages/core/src/config/reference-metadata.ts +2 -0
  102. package/packages/core/src/config/reference.ts +22 -7
  103. package/packages/core/src/config/roles.ts +54 -3
  104. package/packages/core/src/config/schema.ts +146 -162
  105. package/packages/core/src/context-directory.ts +26 -0
  106. package/packages/core/src/distribution-packaging.ts +26 -5
  107. package/packages/core/src/events/catalog.ts +10 -2
  108. package/packages/core/src/events/compatibility.ts +2 -1
  109. package/packages/core/src/events/globs.ts +1 -1
  110. package/packages/core/src/events/payloads.ts +73 -1
  111. package/packages/core/src/events/policy.ts +7 -0
  112. package/packages/core/src/events/repository.ts +4 -4
  113. package/packages/core/src/events/sessions.ts +6 -6
  114. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +574 -0
  115. package/packages/core/src/kernel/auto-merge.ts +2 -2
  116. package/packages/core/src/kernel/engine.ts +255 -26
  117. package/packages/core/src/kernel/generators/leaf-restack-log.ts +10 -0
  118. package/packages/core/src/kernel/integration-landing.ts +3 -3
  119. package/packages/core/src/kernel/integration-state.ts +27 -4
  120. package/packages/core/src/kernel/leaf-restack-state.ts +28 -3
  121. package/packages/core/src/kernel/log-index.ts +13 -1
  122. package/packages/core/src/kernel/node-landing.ts +8 -8
  123. package/packages/core/src/kernel/node-parent.ts +2 -2
  124. package/packages/core/src/kernel/node-restack-transaction.ts +1 -1
  125. package/packages/core/src/kernel/node-verification-context.ts +216 -0
  126. package/packages/core/src/kernel/phases.ts +1 -1
  127. package/packages/core/src/kernel/plan-verify-selection.ts +16 -0
  128. package/packages/core/src/kernel/publication-retry.ts +168 -0
  129. package/packages/core/src/kernel/reconcile-restack.ts +29 -1
  130. package/packages/core/src/kernel/reducer.ts +85 -5
  131. package/packages/core/src/kernel/target-distance.ts +45 -0
  132. package/packages/core/src/kernel/terminal-guard.ts +10 -1
  133. package/packages/core/src/kernel/verify-stage-state.ts +123 -0
  134. package/packages/core/src/kernel/verify-stages.ts +39 -0
  135. package/packages/core/src/ontology.ts +1 -0
  136. package/packages/core/src/operator/annotations.ts +6 -0
  137. package/packages/core/src/operator/control.ts +1 -1
  138. package/packages/core/src/operator/index.ts +3 -7
  139. package/packages/core/src/operator/landings.ts +5 -1
  140. package/packages/core/src/operator/presentation.ts +6 -1
  141. package/packages/core/src/operator/protocol.ts +6 -0
  142. package/packages/core/src/operator/query.ts +14 -18
  143. package/packages/core/src/operator/registry.ts +39 -7
  144. package/packages/core/src/operator/sandbox-host.ts +64 -40
  145. package/packages/core/src/operator/sandbox.ts +3 -0
  146. package/packages/core/src/operator/ticket-source-backend.ts +3 -12
  147. package/packages/core/src/operator/tickets.ts +25 -4
  148. package/packages/core/src/plugins/manifest.ts +2 -1
  149. package/packages/core/src/ports/forge/contract.ts +2 -2
  150. package/packages/core/src/ports/forge/git-rewrite.ts +25 -2
  151. package/packages/core/src/ports/forge/github-readiness.ts +2 -2
  152. package/packages/core/src/ports/forge/github.ts +26 -7
  153. package/packages/core/src/ports/forge/local-git.ts +4 -4
  154. package/packages/core/src/ports/forge/readiness.ts +1 -1
  155. package/packages/core/src/ports/forge-failure.ts +24 -0
  156. package/packages/core/src/ports/runner/account-env.ts +88 -0
  157. package/packages/core/src/ports/runner/chatgpt-provider.ts +85 -0
  158. package/packages/core/src/ports/runner/claude.ts +26 -2
  159. package/packages/core/src/ports/runner/codex.ts +63 -31
  160. package/packages/core/src/ports/runner/one-shot.ts +2 -0
  161. package/packages/core/src/ports/runner/provider-error.ts +5 -0
  162. package/packages/core/src/ports/runner/routing.ts +35 -4
  163. package/packages/core/src/ports/tickets/contract.ts +58 -0
  164. package/packages/core/src/ports/tickets/tree.ts +1 -1
  165. package/packages/core/src/ports/types.ts +28 -7
  166. package/packages/core/src/ports/workspace/account-policy.ts +72 -0
  167. package/packages/core/src/ports/workspace/build-execution.ts +9 -2
  168. package/packages/core/src/ports/workspace/builtin-capabilities.ts +1 -0
  169. package/packages/core/src/ports/workspace/create.ts +2 -0
  170. package/packages/core/src/ports/workspace/git-worktree.ts +6 -1
  171. package/packages/core/src/ports/workspace/phase-scratch.ts +4 -3
  172. package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -0
  173. package/packages/core/src/ports/workspace/vercel-sandbox.ts +182 -72
  174. package/packages/core/src/processes/build-child.ts +6 -8
  175. package/packages/core/src/processes/build-execution-state.ts +8 -5
  176. package/packages/core/src/processes/build-runner.ts +554 -99
  177. package/packages/core/src/processes/dispatcher.ts +209 -101
  178. package/packages/core/src/processes/execution-no-progress.ts +8 -1
  179. package/packages/core/src/processes/execution-settlement.ts +21 -3
  180. package/packages/core/src/processes/harvest-runner.ts +68 -8
  181. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  182. package/packages/core/src/processes/publication-loss.ts +8 -2
  183. package/packages/core/src/processes/publication-state.ts +42 -4
  184. package/packages/core/src/processes/repo-view.ts +14 -0
  185. package/packages/core/src/processes/verify-cycle-config.ts +96 -0
  186. package/packages/core/src/project-secrets.ts +105 -0
  187. package/packages/core/src/{integration → scenarios}/harness.ts +330 -317
  188. package/packages/core/src/secret-name.ts +41 -0
  189. package/packages/core/src/store/account-redaction.ts +156 -0
  190. package/packages/core/src/store/adapter.ts +1 -0
  191. package/packages/core/src/store/build-scope.ts +9 -0
  192. package/packages/core/src/store/contract.ts +116 -2
  193. package/packages/core/src/store/local/schema.ts +13 -0
  194. package/packages/core/src/store/local/store.ts +42 -0
  195. package/packages/core/src/store/memory.ts +47 -0
  196. package/packages/core/src/store/operator-presence.ts +21 -0
  197. package/packages/core/src/store/phase-session.ts +10 -0
  198. package/packages/core/src/store/reducer-value-shapes.json +5185 -4156
  199. package/packages/core/src/store/remote/client.ts +89 -48
  200. package/packages/core/src/store/remote/compatibility.ts +20 -0
  201. package/packages/core/src/store/remote/protocol.ts +4 -0
  202. package/packages/core/src/store/remote/version.ts +3 -1
  203. package/packages/core/src/store/retention.ts +2 -3
  204. package/packages/core/src/store/session-handle.ts +9 -0
  205. package/packages/core/src/store/streams/session-writer.ts +1 -1
  206. package/packages/core/src/store/types.ts +12 -2
  207. package/packages/core/src/testing/dispatch-read-budget.ts +122 -0
  208. package/packages/core/src/testing/index.ts +12 -1
  209. package/packages/core/src/testing/reduced-read-budget.ts +47 -0
  210. package/packages/core/src/testing/temp-directories.ts +58 -0
  211. package/skills/code-review/SKILL.md +23 -9
  212. package/skills/finalize/SKILL.md +15 -7
  213. package/skills/guide/SKILL.md +373 -148
  214. package/skills/guide/references/accounts.md +119 -0
  215. package/skills/guide/references/integration-tree.md +45 -38
  216. package/{docs/landing-policy.md → skills/guide/references/merge-policy.md} +40 -24
  217. package/skills/guide/references/migration-1.0.md +17 -13
  218. package/skills/guide/references/operator-api.md +180 -51
  219. package/skills/guide/references/plugin-authoring.md +21 -0
  220. package/skills/guide/references/remote-store-protocol.md +242 -68
  221. package/skills/guide/references/remote-ticket-protocol.md +30 -50
  222. package/skills/guide/references/restacking.md +54 -15
  223. package/skills/guide/references/setup.md +59 -119
  224. package/skills/guide/references/spec-standard.md +6 -6
  225. package/skills/guide/references/ticket-dependencies.md +7 -7
  226. package/skills/harvest/SKILL.md +3 -1
  227. package/skills/harvest-review/SKILL.md +3 -1
  228. package/skills/implement/SKILL.md +43 -17
  229. package/skills/operate/SKILL.md +118 -118
  230. package/skills/plan/SKILL.md +39 -13
  231. package/skills/plan-review/SKILL.md +15 -10
  232. package/skills/reconcile/SKILL.md +22 -3
  233. package/skills/spec/SKILL.md +20 -20
  234. package/skills/tickets/SKILL.md +12 -9
  235. package/templates/autobuild.toml +1 -1
  236. package/templates/hosted-service/package.json +2 -2
  237. package/docs/hosted-dispatcher-cutover-validation.md +0 -178
  238. package/docs/hosted-dispatcher.md +0 -275
  239. package/docs/hosted-service.md +0 -293
  240. package/docs/mcp.md +0 -149
  241. package/packages/core/src/orchestrator/approvals.ts +0 -115
  242. package/packages/core/src/orchestrator/conversation.ts +0 -167
  243. package/packages/core/src/orchestrator/model.ts +0 -86
  244. package/packages/core/src/orchestrator/prompt.ts +0 -63
  245. package/packages/core/src/orchestrator/tools.ts +0 -117
  246. package/packages/core/src/orchestrator/turn-runner.ts +0 -457
  247. package/packages/core/src/processes/orchestrator-tick.ts +0 -360
@@ -1,3 +1,8 @@
1
+ import { LocalCredentials } from '../accounts/local-credentials'
2
+ import { LocalAccountOwner, renewLocalAccounts } from '../accounts/local-owner'
3
+ import { accountRedactor, redactAccountStore } from '../store/account-redaction'
4
+ import { capturedBuildConfig } from '../processes/verify-cycle-config'
5
+ import { ForgeRequestDeferred } from '../ports/forge-request-context'
1
6
  import { migrationIdentity } from '../kernel/ticket-migrations'
2
7
  import { recordRuntimeRollback } from './dispatch-handoff'
3
8
  import { syncRollbackRetention } from './dispatch-runtime-use'
@@ -247,7 +252,10 @@ export function slugNamingPrompt(spec: string): string {
247
252
  function definedEnv(env: Record<string, string | undefined>): Record<string, string> {
248
253
  const defined: Record<string, string> = {}
249
254
  for (const [key, value] of Object.entries(env)) {
250
- if (value !== undefined && !['AB_TOKEN', 'AB_TICKET_TOKEN', 'AB_TICKET_URL'].includes(key))
255
+ if (
256
+ value !== undefined &&
257
+ !['AB_TOKEN', 'AB_TICKET_TOKEN', 'AB_TICKET_URL', 'AB_PROJECT_SECRETS_KEY'].includes(key)
258
+ )
251
259
  defined[key] = value
252
260
  }
253
261
  return defined
@@ -292,6 +300,9 @@ interface ResumePrompt {
292
300
  /** The real adapters the loop drives — resolved by `wire` (default: the
293
301
  * production ports; tests inject fakes). */
294
302
  export interface DispatchWiring {
303
+ renewAccounts?: (authority: { repo: string; run: string }) => Promise<void>
304
+ releaseAccounts?: () => Promise<void>
305
+
295
306
  credentialIssuer?: typeof delegateCredential
296
307
  store: BuildStore
297
308
  tickets: TicketSource
@@ -515,8 +526,12 @@ async function defaultWire(
515
526
  remoteBranchHead: async (branch: string): Promise<string | undefined> => {
516
527
  const remoteBranchSha = forge.remoteBranchSha
517
528
  if (remoteBranchSha === undefined) return undefined
529
+ // The provider pushes through the guest, bypassing the forge's read
530
+ // invalidation, so each head read takes a fresh scope: a post-push
531
+ // readback must never replay the tick's pre-push answer.
532
+ const read = () => remoteBranchSha.call(forge, branch)
518
533
  try {
519
- return await remoteBranchSha.call(forge, branch)
534
+ return await (forge.withReadScope ? forge.withReadScope(read) : read())
520
535
  } catch (error) {
521
536
  if (error instanceof GitHubApiError && error.status === 404) return undefined
522
537
  throw error
@@ -534,6 +549,51 @@ async function defaultWire(
534
549
  plugins,
535
550
  )
536
551
  const { runtimes } = createProductionRuntimes()
552
+ if (opts.env.AB_PROJECT_SECRETS_FAILED === '1')
553
+ for (const name of JSON.parse(opts.env.AB_PROJECT_SECRETS_UNAVAILABLE ?? '[]') as string[])
554
+ delete opts.env[name]
555
+ let accounts = config.accounts
556
+ const credentials = new LocalCredentials(join(state.checkout, '.autobuild'))
557
+ const owner = new LocalAccountOwner(credentials)
558
+ const claimed = new Set<string>()
559
+ let renewal: Promise<void> | undefined
560
+ let accountTimer: ReturnType<typeof setInterval> | undefined
561
+ const renewAccounts = async (authority: { repo: string; run: string }) => {
562
+ if (opts.repository || !Object.values(accounts).some((a) => a.kind === 'chatgpt-subscription'))
563
+ return
564
+ if (!accountTimer) {
565
+ accountTimer = setInterval(() => {
566
+ void (async () => {
567
+ const held = await opened.store.getRepo(authority.repo)
568
+ if (
569
+ held?.lease?.holder !== authority.run ||
570
+ Date.parse(held.lease.expiresAt) <= Date.now()
571
+ ) {
572
+ await releaseAccounts()
573
+ return
574
+ }
575
+ await renewAccounts(authority)
576
+ })().catch(() => {})
577
+ }, 15000)
578
+ accountTimer.unref()
579
+ }
580
+ if (renewal) return renewal
581
+ renewal = renewLocalAccounts(owner, accounts, opts.env, claimed).finally(() => {
582
+ renewal = undefined
583
+ })
584
+ return renewal
585
+ }
586
+ const releaseAccounts = async () => {
587
+ if (accountTimer) clearInterval(accountTimer)
588
+ accountTimer = undefined
589
+ await renewal
590
+ for (const name of claimed) owner.release(name)
591
+ claimed.clear()
592
+ }
593
+ opened.store = redactAccountStore(
594
+ opened.store,
595
+ accountRedactor(() => accounts, opts.env),
596
+ )
537
597
  let runtimeReferences = effectiveRuntimeReferences(config)
538
598
  // A local override relocates the whole tree. Remote stores still need local
539
599
  // scratch beneath the repository default. Plugin factories receive only
@@ -547,6 +607,7 @@ async function defaultWire(
547
607
  env: opts.env,
548
608
  storeRef: opened.storeRef,
549
609
  runtimeReferences: () => runtimeReferences,
610
+ accounts: () => accounts,
550
611
  sandboxSetupCommand: config.commands.setup,
551
612
  sandboxRoot: resolve(join(opened.localStateRoot, 'orchestrator-sandboxes')),
552
613
  sandboxEnvironmentVariables: config.orchestrator.sandbox.environmentVariables,
@@ -569,6 +630,8 @@ async function defaultWire(
569
630
 
570
631
  return {
571
632
  store: opened.store,
633
+ renewAccounts,
634
+ releaseAccounts,
572
635
  tickets,
573
636
  forge,
574
637
  workspaces: workspaceRuntime.provider,
@@ -584,6 +647,7 @@ async function defaultWire(
584
647
  clock: systemClock,
585
648
  plugins,
586
649
  updateRuntimeReferences: (effectiveConfig) => {
650
+ accounts = effectiveConfig.accounts
587
651
  runtimeReferences = effectiveRuntimeReferences(effectiveConfig)
588
652
  },
589
653
  }
@@ -808,6 +872,7 @@ class DispatchLoop {
808
872
  signal,
809
873
  ...(resolvedSlug.model !== undefined ? { model: resolvedSlug.model } : {}),
810
874
  args: resolvedSlug.args,
875
+ account: resolvedSlug.account,
811
876
  })
812
877
  return result.text
813
878
  }
@@ -924,6 +989,12 @@ class DispatchLoop {
924
989
  * naming the failed attempts; the documented fallbacks (an unpublished
925
990
  * branch, an unreadable legacy base) stay quiet. */
926
991
  private async publishBuildConfig(slug: string, snapshot = this.currentConfig()): Promise<void> {
992
+ const state = (await readBuildFacts(this.wiring.store, slug)).value.state
993
+ if (state.verify.configPin) {
994
+ const config = await capturedBuildConfig(this.wiring.store, slug, state, snapshot.config)
995
+ await this.depositBuildConfig(slug, snapshot, config, state.verify.configPin.source)
996
+ return
997
+ }
927
998
  const { source, failures, observations } = await this.resolveBuildPipeline(slug)
928
999
  if (source !== undefined) {
929
1000
  await this.depositBuildConfig(
@@ -1026,8 +1097,8 @@ class DispatchLoop {
1026
1097
  /** Re-deposit deployment-owned sections to active builds on a reload. The
1027
1098
  * build-owned sections are reused verbatim from the build's last deposit, so
1028
1099
  * a base-branch reload can never retarget an in-flight build's pipeline; a
1029
- * build picks up pipeline changes only from its own branch at its next
1030
- * launch (SPEC §16.1). */
1100
+ * runner refreshes the execution checkout at settled verification boundaries.
1101
+ * A cycle capture's exact revision outranks latest-artifact races (SPEC §16.1). */
1031
1102
  private async publishActiveBuildConfigs(snapshot: ConfigSnapshot): Promise<void> {
1032
1103
  await Promise.all(
1033
1104
  [...this.activeBuildRuns.keys()].map(async (slug) => {
@@ -1046,11 +1117,17 @@ class DispatchLoop {
1046
1117
  return
1047
1118
  }
1048
1119
  const meta = parseBuildConfigMetadata(artifact)
1120
+ const state = (await readBuildFacts(this.wiring.store, slug)).value.state
1049
1121
  await this.depositBuildConfig(
1050
1122
  slug,
1051
1123
  snapshot,
1052
- composeBuildConfig(existing, snapshot.config),
1053
- meta.pipelineSource,
1124
+ await capturedBuildConfig(
1125
+ this.wiring.store,
1126
+ slug,
1127
+ state,
1128
+ composeBuildConfig(existing, snapshot.config),
1129
+ ),
1130
+ state.verify.configPin?.source ?? meta.pipelineSource,
1054
1131
  )
1055
1132
  }),
1056
1133
  )
@@ -1192,10 +1269,12 @@ class DispatchLoop {
1192
1269
  settings.intake || (!this.dashboard && this.opts.kernelRunId === undefined)
1193
1270
  ? undefined
1194
1271
  : await this.dispatcher.observeReady({ viewRefreshed: true })
1272
+ await this.wiring.renewAccounts?.({ repo: this.repoIdentity, run: this.runId })
1195
1273
  const report = await this.dispatcher.tick({
1196
1274
  resumeCurrent,
1197
1275
  viewRefreshed: true,
1198
1276
  acceptNewWork: settings.intake,
1277
+ observationOnly: this.opts.env.AB_PROJECT_SECRETS_FAILED === '1',
1199
1278
  defaultAutoMerge: settings.defaultAutoMerge,
1200
1279
  autoMergeUser: buildControlUser(this.opts.env),
1201
1280
  // Invocation bound forwarded into the tick: per-item loops inside the
@@ -1764,9 +1843,7 @@ class DispatchLoop {
1764
1843
  throw new Error('build-control returned an invalid auto-merge toggle result')
1765
1844
  }
1766
1845
  this.say(
1767
- `build ${slug}: landing ${
1768
- result.command === 'hold' ? 'hold requested' : 'consent requested'
1769
- }`,
1846
+ `build ${slug}: merge ${result.command === 'hold' ? 'hold requested' : 'consent requested'}`,
1770
1847
  )
1771
1848
  await this.renderOnce()
1772
1849
  }
@@ -3068,6 +3145,7 @@ class DispatchLoop {
3068
3145
  publication: this.wiring.workspaces.publication,
3069
3146
  forge: this.wiring.forge,
3070
3147
  workspacePath: this.opts.targetRepo,
3148
+ checkoutless: this.opts.repository !== undefined,
3071
3149
  exec: this.opts.exec,
3072
3150
  ids: this.wiring.ids,
3073
3151
  runId: this.runId,
@@ -3087,6 +3165,15 @@ class DispatchLoop {
3087
3165
  })
3088
3166
  }
3089
3167
 
3168
+ /** A parked publication is durable work for a later tick, not a failed guest. */
3169
+ private async settleEndedPublication(slug: string): Promise<void> {
3170
+ try {
3171
+ await this.settlePendingPublication(slug)
3172
+ } catch (error) {
3173
+ if (!(error instanceof ForgeRequestDeferred)) throw error
3174
+ }
3175
+ }
3176
+
3090
3177
  private async recordInfrastructureFailure(input: {
3091
3178
  slug: string
3092
3179
  instance: string
@@ -3263,7 +3350,7 @@ class DispatchLoop {
3263
3350
  this.warn(`build ${slug} runner failed: ${detail}`)
3264
3351
  } finally {
3265
3352
  await this.repoView.releaseLease(slug, instance)
3266
- if (!this.retirement) await this.settlePendingPublication(slug)
3353
+ if (!this.retirement) await this.settleEndedPublication(slug)
3267
3354
  }
3268
3355
  },
3269
3356
  async (error) => {
@@ -3300,6 +3387,11 @@ class DispatchLoop {
3300
3387
  if (this.activeBuildRuns.get(slug)?.reservation === reservation) {
3301
3388
  this.activeBuildRuns.delete(slug)
3302
3389
  }
3390
+ if (error instanceof ForgeRequestDeferred) {
3391
+ if (leaseClaimed) await this.repoView.releaseLease(slug, instance)
3392
+ await this.repoView.refreshBuild(slug)
3393
+ return 'already-active'
3394
+ }
3303
3395
  if (leaseClaimed) {
3304
3396
  // The runner appended through its own handle: take the delta.
3305
3397
  await this.repoView.refreshBuild(slug)
@@ -4158,6 +4250,7 @@ class DispatchLoop {
4158
4250
  cacheId: request.cacheId,
4159
4251
  target: request.target,
4160
4252
  }
4253
+ await this.wiring.releaseAccounts?.()
4161
4254
  let acceptanceError: unknown
4162
4255
  try {
4163
4256
  await this.repoView.appendRepo(this.repoIdentity, {
@@ -4338,6 +4431,7 @@ class DispatchLoop {
4338
4431
  this.wiring.runtimes,
4339
4432
  config.roles,
4340
4433
  config.policy.sessionBudgetSeconds,
4434
+ config.accounts,
4341
4435
  )
4342
4436
  const deadline = new Date(
4343
4437
  Date.parse(retirement.startedAt) + config.policy.upgradeDrainSeconds * 1000,
@@ -4843,7 +4937,7 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
4843
4937
  storeRef: opened.storeRef,
4844
4938
  stdout: resolvedOpts.stdout,
4845
4939
  },
4846
- 'ab land',
4940
+ 'ab merge',
4847
4941
  )
4848
4942
  ).source,
4849
4943
  env: resolvedOpts.env,
@@ -5123,6 +5217,7 @@ export async function abDispatch(opts: DispatchOpts): Promise<void> {
5123
5217
  // view; leave the reduced state behind so the next cold process reads
5124
5218
  // only what is newer than it.
5125
5219
 
5220
+ await wiring.releaseAccounts?.()
5126
5221
  if (resolvedOpts.wire === undefined) await wiring.store.close()
5127
5222
  }
5128
5223
  }
@@ -1,3 +1,4 @@
1
+ import { resolveContextDirectory } from '../context-directory'
1
2
  /**
2
3
  * Ambient auth resolution (SPEC §8.1, D8): the runner launches every session
3
4
  * with `AB_STORE`, `AB_BUILD`, `AB_PHASE`, `AB_SESSION` (and `AB_TOKEN` for a
@@ -21,6 +22,8 @@ export interface HarvestCliEnv {
21
22
  }
22
23
 
23
24
  export interface CliEnv {
25
+ /** Workspace-relative session scratch directory (`AB_CONTEXT_DIR`); phase-derived when omitted. */
26
+ contextDir?: string
24
27
  /** Store URL or local path (`AB_STORE`). */
25
28
  store: string
26
29
  /** Build slug (`AB_BUILD`). */
@@ -162,6 +165,7 @@ export function resolveCliEnv(env: Record<string, string | undefined>): CliEnv {
162
165
  return {
163
166
  store,
164
167
  build,
168
+ contextDir: resolveContextDirectory(phase, env.AB_CONTEXT_DIR),
165
169
  phase,
166
170
  round,
167
171
  session,
@@ -71,6 +71,22 @@ export const HELP_CATALOG: readonly HelpEntry[] = [
71
71
  'locally. --validate cannot be combined with --force.',
72
72
  ]),
73
73
  },
74
+ {
75
+ name: 'accounts',
76
+ summary: 'Sign in with ChatGPT for a Codex billing account',
77
+ audience: 'human',
78
+ detail: page([
79
+ 'Usage: ab accounts login NAME [--local|--project]',
80
+ 'Runs outside sessions. Local stores protected repository credentials for the dispatcher. Project transfers credentials to the connected refreshing secret and retains none locally. The browser completes OpenAI authorization; tokens are never printed.',
81
+ ]),
82
+ },
83
+ {
84
+ name: 'secrets',
85
+ summary: 'Manage write-only secrets for a connected project',
86
+ audience: 'human',
87
+ detail:
88
+ 'Usage: ab secrets list [--json] | ab secrets set NAME | ab secrets remove NAME. Uses the saved owner credential from ab connect. Set reads hidden terminal input or redirected stdin; values are never returned. List reports owner, set time, fingerprint, status and last supply time. Runs outside sessions.',
89
+ },
74
90
  {
75
91
  name: 'connect',
76
92
  audience: 'human',
@@ -148,8 +164,8 @@ export const HELP_CATALOG: readonly HelpEntry[] = [
148
164
  ' Up/Down Select the global, Harvest, or a build row.',
149
165
  ' h Toggle harvesting when the global row is selected.',
150
166
  ' i Toggle intake when the global row is selected.',
151
- ' l Land the selected ready build.',
152
- ' o Hold the selected landing.',
167
+ ' l Merge the selected ready build.',
168
+ ' o Hold the selected merge.',
153
169
  ' p On the global row, pause every pausable build and turn intake',
154
170
  ' off. On a build, pause or cancel a pending pause; on Harvest,',
155
171
  ' resume or acknowledge the run.',
@@ -199,7 +215,7 @@ names a same-source node; --no-target clears it to the baseBranch root.
199
215
  Targets cannot form cycles, and nodes with targeting tickets cannot become work.
200
216
  tree shows all tickets nested by target, including completed work and empty nodes;
201
217
  --json returns {root, children} with recursive {ticket, children} entries.
202
- These fields describe intent; dispatch and landing behavior are unchanged.`,
218
+ These fields describe intent; dispatch and merge behavior are unchanged.`,
203
219
  '--state overrides [tickets].createState (or the provider default) for that',
204
220
  'create only; it is passed through unchanged and validated by the source.',
205
221
  'update partially replaces editable fields: omitted fields survive, --labels',
@@ -250,8 +266,8 @@ These fields describe intent; dispatch and landing behavior are unchanged.`,
250
266
  '',
251
267
  'Report the durable ticket-intake setting and repository-wide pause from',
252
268
  'the same journal projection used by dispatch and the dashboard.',
253
- 'The defaults are intake on and repository pause off. Landing policy is',
254
- 'configured with [[landing]] rules in autobuild.toml.',
269
+ 'The defaults are intake on and repository pause off. Merge policy is',
270
+ 'configured with [[merge]] rules in autobuild.toml.',
255
271
  '',
256
272
  '--json emits one bare object for scripts. --store overrides AB_STORE, which',
257
273
  'overrides the repository-local .autobuild store. This sessionless command',
@@ -259,13 +275,13 @@ These fields describe intent; dispatch and landing behavior are unchanged.`,
259
275
  ]),
260
276
  },
261
277
  {
262
- name: 'landings',
278
+ name: 'merges',
263
279
  audience: 'human',
264
- summary: 'List ready landings awaiting consent.',
280
+ summary: 'List ready merges awaiting consent.',
265
281
  detail: page([
266
- 'Usage: ab landings [--json] [--store <ref>]',
267
- 'Shows ready consent and held landings with effective target, branch, verification and node children.',
268
- 'Use ab land <slug> to consent or ab hold <slug> to withdraw consent. Land rechecks readiness.',
282
+ 'Usage: ab merges [--json] [--store <ref>]',
283
+ 'Shows ready consent and held merges with effective target, branch, verification and node children.',
284
+ 'Use ab merge <slug> to consent or ab hold <slug> to withdraw consent. Merge rechecks readiness.',
269
285
  'Source ancestry is available separately through ab ticket tree or MCP tickets.tree.',
270
286
  ]),
271
287
  },
@@ -317,7 +333,7 @@ These fields describe intent; dispatch and landing behavior are unchanged.`,
317
333
  summary: 'Stream build and repository events as they land, with a resumable cursor.',
318
334
  detail: page([
319
335
  'Usage:',
320
- ' ab watch [<slug>...] [--repository] [--event <glob>]... [--since <cursor>] [--timeout <duration>] [--interval <duration>] [--count <n>] [--json] [--store <ref>]',
336
+ ' ab watch [<slug>...] [--repository] [--operator] [--event <glob>]... [--since <cursor>] [--timeout <duration>] [--interval <duration>] [--count <n>] [--json] [--store <ref>]',
321
337
  '',
322
338
  'Follow the event logs of one, several, or all active builds in this repository —',
323
339
  'the repository journal by default with no slugs — and emit one record per matching event as it',
@@ -353,7 +369,7 @@ These fields describe intent; dispatch and landing behavior are unchanged.`,
353
369
  'integration.verification-failed (failed node verification), build.janitor-failing, build.compatibility-deferred,',
354
370
  'node.item-conflicted, conflicted restack.replayed, derived build.consent-ready and',
355
371
  'build.merge-decision (a current actionable merge-gate deferral or unsafe forge outcome).',
356
- 'Consent and held ready landings use only build.consent-ready, once per readiness episode.',
372
+ 'Consent and held ready merges use only build.consent-ready, once per readiness episode.',
357
373
  'Unready or stale consent candidates stay silent; one merge gate decision per build/PR.',
358
374
  'Repository: harvest.escalated, harvest.recovery-exhausted, dispatcher.config-rejected, dispatcher.forge-readiness-failed,',
359
375
  'dispatcher.config-reloaded with restartRequired, abnormal dispatcher.run-stopped,',
@@ -390,8 +406,15 @@ These fields describe intent; dispatch and landing behavior are unchanged.`,
390
406
  'streak — and retried at the next interval without ending the watch or duplicating or',
391
407
  'skipping any event.',
392
408
  '',
393
- 'This command is read-only: it appends no event, takes no lease, and creates no build or',
394
- 'repository record, and requires no session identity for operator use. Inside a phase, a',
409
+ '--operator registers advisory presence for a repository-wide watch with no named slugs.',
410
+ 'It is rejected inside a build or scoped session. Multiple registrations may coexist;',
411
+ 'presence grants no authority or exclusive lock. Only flagged watches write liveness',
412
+ 'state, renewed every 30 seconds and live for 5 minutes after the last heartbeat.',
413
+ 'Re-arm with --operator --since using this standing watch’s own cursor to retain its',
414
+ 'registration. ab wait does not renew presence or carry registration identity.',
415
+ 'Without --operator this command is read-only. Either form appends no event, takes no',
416
+ 'lease, and creates no build or repository record. It requires no session identity.',
417
+ 'For an unflagged watch inside a phase, a',
395
418
  'complete ambient tuple permits only the ambient build: the no-slug form, a foreign slug,',
396
419
  'and --repository are rejected, as are malformed or partial identity.',
397
420
  ]),
@@ -414,9 +437,9 @@ These fields describe intent; dispatch and landing behavior are unchanged.`,
414
437
  'error before waiting begins.',
415
438
  '',
416
439
  'Conditions (--for, repeatable): blocked, paused, running, done, aborted, terminal (done',
417
- 'or aborted), pr=open, pr=merged, pr=closed, consent, node-landed, restack-conflicted, pr=conflicted, phase=<phase> (a core phase —',
440
+ 'or aborted), pr=open, pr=merged, pr=closed, consent, node-merged, restack-conflicted, pr=conflicted, phase=<phase> (a core phase —',
418
441
  'plan, plan-review, implement, code-review, finalize, reconcile — or verify:<step>), and',
419
- 'attention (an open escalation, failed node verification, consent readiness, a node landing or restack conflict,',
442
+ 'attention (an open escalation, failed node verification, consent readiness, a node merge or restack conflict,',
420
443
  'or a build waiting for a merge decision). Merge attention',
421
444
  'requires a current actionable gate deferral or an unsafe forge outcome;',
422
445
  'armed pending consent, routine outcomes and self-healing failures stay silent.',
@@ -584,7 +607,7 @@ These fields describe intent; dispatch and landing behavior are unchanged.`,
584
607
  'the next spec revision. Leaves require an open escalation and restart from plan.',
585
608
  'Idle collecting or verification-failed nodes need no escalation: they recollect',
586
609
  'and verify again, even on the same head. Active work, pause, pending controls and',
587
- 'landing intent refuse node revision. Non-conforming bodies are refused before anything is',
610
+ 'merge intent refuse node revision. Non-conforming bodies are refused before anything is',
588
611
  'recorded. Retrying an interrupted revision completes the exact body authorized by',
589
612
  'the earlier recorded answer, not a newly supplied body.',
590
613
  '',
@@ -621,15 +644,14 @@ These fields describe intent; dispatch and landing behavior are unchanged.`,
621
644
  'and nodes without an open branch are refused. This command is sessionless.',
622
645
  ]),
623
646
  },
624
- ...(['hold', 'land'] as const).map((name) => ({
647
+ ...(['hold', 'merge'] as const).map((name) => ({
625
648
  name,
626
649
  audience: 'human' as const,
627
- summary:
628
- name === 'hold' ? 'Hold a landing and withdraw consent.' : 'Consent to a ready landing.',
650
+ summary: name === 'hold' ? 'Hold a merge and withdraw consent.' : 'Consent to a ready merge.',
629
651
  detail: page([
630
652
  `Usage: ab ${name} <slug> [--store <ref>]`,
631
653
  '',
632
- 'Landing consent survives restacks and verification; hold persists until land.',
654
+ 'Merge consent survives restacks and verification; hold persists until merge.',
633
655
  'These sessionless controls never bypass merge gates.',
634
656
  ]),
635
657
  })),
@@ -673,7 +695,7 @@ These fields describe intent; dispatch and landing behavior are unchanged.`,
673
695
  'Usage:',
674
696
  ' ab context [--json]',
675
697
  '',
676
- "Hydrate .ab/ with the current phase's inputs and print the context manifest.",
698
+ "Hydrate $AB_CONTEXT_DIR/ with the current phase's inputs and print the context manifest.",
677
699
  '--json prints the manifest as JSON instead of the human summary. This command',
678
700
  'runs inside a build session and uses the runner-provided AB_* phase context.',
679
701
  ]),
@@ -836,7 +858,8 @@ export function renderTopLevelHelp(): string {
836
858
  }
837
859
 
838
860
  export function renderCommandHelp(command: string): string {
839
- const entry = ENTRY_BY_NAME.get(command === 'update' ? 'upgrade' : command)
861
+ const canonical = command === 'land' ? 'merge' : command === 'landings' ? 'merges' : command
862
+ const entry = ENTRY_BY_NAME.get(canonical === 'update' ? 'upgrade' : canonical)
840
863
  if (entry === undefined) {
841
864
  throw new Error(`unknown help command "${command}"`)
842
865
  }
@@ -17,6 +17,21 @@ export async function validateRemoteReadiness(
17
17
  ctx: WorkspaceReadinessContext,
18
18
  ): Promise<InitValidationReport> {
19
19
  const vercel = ctx.providerConfig as VercelSandboxConfig
20
+ const hostChecks = Object.entries(ctx.accounts ?? {}).map(([name, descriptor]) => ({
21
+ name: `host account ${JSON.stringify(name)}`,
22
+ status: ctx.env[descriptor.credentialEnv] ? ('pass' as const) : ('fail' as const),
23
+ detail: ctx.env[descriptor.credentialEnv]
24
+ ? `${descriptor.credentialEnv} is present`
25
+ : `${descriptor.credentialEnv} is missing; ${descriptor.kind === 'claude-subscription' ? 'run claude setup-token and set the dispatcher variable' : 'provision the Kimi membership key'}`,
26
+ }))
27
+ if (hostChecks.some((check) => check.status === 'fail'))
28
+ return {
29
+ provider: 'vercel-sandbox',
30
+ context: 'Vercel Sandbox',
31
+ checks: hostChecks,
32
+ exitCode: 1,
33
+ }
34
+
20
35
  const remoteLine = await gitText(
21
36
  ctx.exec,
22
37
  ctx.repo,
@@ -69,6 +84,7 @@ export async function validateRemoteReadiness(
69
84
  exec: ctx.exec,
70
85
  ...(ctx.packageArchive !== undefined ? { packageArchive: ctx.packageArchive } : {}),
71
86
  runtimeReferences: [...ctx.runtimeReferences],
87
+ accounts: ctx.accounts,
72
88
  ...(ctx.signal !== undefined ? { signal: ctx.signal } : {}),
73
89
  onSandbox: (name) => ctx.stdout(`Disposable Vercel Sandbox: ${name} (active)`),
74
90
  })
@@ -103,8 +119,13 @@ export async function validateRemoteReadiness(
103
119
  ? 'no workspace.config.provisioning steps declared'
104
120
  : `completed: ${remote.provisioning.join(', ')}`,
105
121
  },
122
+ ...hostChecks,
106
123
  ...guest.checks,
107
124
  ],
108
- exitCode: guest.checks.some((check) => check.status === 'fail') ? 1 : 0,
125
+ exitCode:
126
+ guest.checks.some((check) => check.status === 'fail') ||
127
+ Object.values(ctx.accounts ?? {}).some((account) => !ctx.env[account.credentialEnv])
128
+ ? 1
129
+ : 0,
109
130
  }
110
131
  }
@@ -1,3 +1,4 @@
1
+ import { sensitiveAccountValues } from '../accounts/sensitive'
1
2
  /**
2
3
  * Readiness-probe helpers shared by the local-worktree and remote validation
3
4
  * paths (AUT-516). Moved out of `cli/init-validation.ts` so the remote
@@ -39,7 +40,10 @@ export function createReadinessRedactor(
39
40
  ].sort((left, right) => right.length - left.length)
40
41
  return (value) => {
41
42
  let text = message(value)
42
- for (const secret of secrets) text = text.split(secret).join('[REDACTED]')
43
+ for (const secret of [...sensitiveAccountValues, ...secrets].sort(
44
+ (a, b) => b.length - a.length,
45
+ ))
46
+ text = text.split(secret).join('[REDACTED]')
43
47
  return text
44
48
  }
45
49
  }