@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
@@ -77,7 +77,6 @@ remote-store protocol requires matching client and server versions.
77
77
  | `packages/core/src/events/` | Separate build, repository, and operator-session envelopes/catalogs, frozen payload schemas, actor validation, the `via` attribution marker | §15 |
78
78
  | `packages/core/src/harvest/` | Structured occurrence, scan packet, proposal, and ledger schemas | §12 |
79
79
  | `packages/core/src/store/session-reducer.ts` | The operator-session reducer: status, open turn, pending approval, wake settings and cursors, and the turn list, reduced purely from the session event log | §7.1.1 |
80
- | `packages/core/src/orchestrator/` | The embedded orchestrator's turn runner: the canonical-skill system prompt, durable conversation reconstruction, registry entries as AI SDK tools with the session's repository injected, gateway model resolution with the typed failure vocabulary, the approval-list configuration, and the CAS-guarded start/resume loop with budget suspension and step-boundary checkpoints | §7.1.2 |
81
80
  | `packages/core/src/store/` | BuildStore contract spanning builds, the repository journal, and operator sessions; interface-enforced build, operator-session, and local ambient-session scope wrappers; memory, SQLite/blob, and remote HTTP adapters | §7 |
82
81
  | `packages/core/src/store/streams/` | The stream primitive's shared core (§7.6): record/chunk types and the `ai-ui-message-stream/v1` constants, SDK-backed close-time `UIMessage[]` assembly, and the uniform bounded-wait read loop | §7.6 |
83
82
  | `packages/hosted-store-service/` | Environment-only hosted Fetch handler, lazy PostgreSQL/blob composition, offline token binary, the Next.js operator web app (`app/`, `server.ts`, `next.config.ts`, `vercel.json`), tests, and deployment guide | §7.2, §18 |
@@ -88,12 +87,12 @@ remote-store protocol requires matching client and server versions.
88
87
  | `packages/core/src/ports/` | TicketSource / Workspace / Forge / AgentRunner / Telemetry interfaces, adapters, and fakes; registry-aware builtin/plugin construction; eager primary/alternate runtime routing and provider-failure classification, awaited native identity observation and optional fresh-process native resume under `ports/runner/` | §3.2, §9, §13 |
89
88
  | `packages/core/src/plugins/` | Strict versioned plugin manifests, dual-root repository/package Bun loading, owner-aware adapter registration, contract/credential metadata, and runtime-factory materialization | §3.2.1, §9 |
90
89
  | `packages/core/src/plugin-sdk/` | The sole supported `@defrex/autobuild/plugin-sdk` barrel: port/manifest types, contract suites, and reference fakes | §3.2.1 |
91
- | `packages/core/src/processes/` | build-runner and standalone child composition, durable execution config/diagnostics, dispatcher (+ janitor duty, harvest trigger, and the last-step orchestrator resume/reap/wake pass, origin-mode-gated), orchestrator tick step, harvest deterministic core + runner | §3.3, §7.1.2, §12, §15.7 |
90
+ | `packages/core/src/processes/` | build-runner and standalone child composition, durable execution config/diagnostics, dispatcher (+ janitor duty, sandbox idle settlement and harvest trigger), harvest deterministic core + runner | §3.3, §7.1.2, §12, §15.7 |
92
91
  | `packages/core/src/cli/` and `bin/` | The `ab` CLI — the only agent↔store channel — plus the shared presentation-only durable-progress projection, init/upgrade, the filesystem-only dispatch launcher and immutable generation cache, the Store-only dispatch frontend, its private supervised kernel entry, and `bin/ab-build-runner.ts` (one child per build) | §8, §14, §16.3 |
93
92
  | `packages/core/src/cli/dashboard/` | `ab dispatch`'s fixed live frame: pure projection, renderer, poll cache, and deterministic image renderer | §14 |
94
93
  | `bin/agent/ab` | Private launcher placed first on agent-session `PATH`; delegates to the canonical `bin/ab.ts` | §8.1 |
95
94
  | `packages/core/src/config/` | `autobuild.toml` parsing and strict validation, plus the pure role-key consumability diagnostics `ab dispatch` reports at startup (`roles.ts`); user reference in `docs/configuration.md` | §9, §16.1 |
96
- | `packages/core/src/integration/` | End-to-end harness and product scenarios | — |
95
+ | `packages/core/src/scenarios/` | In-memory end-to-end harness and product scenarios | — |
97
96
  | `tools/` | This repository's local maintainer tooling, including verification, dashboard capture, and release cutting; not shipped product behavior | — |
98
97
  | `skills/` | Canonical defaults; `ab init` vendors them to `.agents/skills/ab-*` and links `.claude/skills/ab-*` | §16.3 |
99
98
  | `skills/guide/` | `ab-guide` — the model-invocable reference for the lifecycle and full config surface; `references/` is the shared installed-documentation seam for every vendored skill. Update it when config or shared guidance changes; `packages/core/src/cli/guide-skill.test.ts` guards schema coverage and `packages/core/src/cli/skill-self-containment.test.ts` guards installed references | §16.3 |
@@ -112,7 +111,7 @@ workspace validates its environment,
112
111
  serves health without touching persistence, and lazily retains one
113
112
  `openPostgresBuildStoreFromEnv` promise per warm process. Its Fetch handler has
114
113
  no Vercel branch; the package's `server.ts` is the sole `Bun.serve()` composition point.
115
- The fixed 1 MiB decoded artifact policy is enforced before backing mutation.
114
+ The fixed 2.5 MiB decoded artifact policy is enforced before backing mutation.
116
115
  The `ab-hosted-store` binary signs admin or build/session tokens offline from
117
116
  `AB_STORE_SECRET`; the running service exposes no mint endpoint. Machine routes
118
117
  and later server-session human routes intentionally share one deployment.
@@ -181,15 +180,18 @@ project known payloads before adapting selector rows, while build and repository
181
180
  facts retain compatibility counts across incremental resumes. Unknown facts
182
181
  still advance sequence cursors. `kernel/mixed-version.ts` guards affected build
183
182
  decisions and deduplicates the default-watch attention fact. Other builds and
184
- read-only queries continue. The [hosted upgrade guarantee](hosted-service.md#reading-across-upgrades)
183
+ read-only queries continue. The [hosted upgrade guarantee](remote-store-protocol.md)
185
184
  describes recovery and the supported-window boundary.
186
185
 
187
186
  All event-derived checkpoints include the combined read-catalog fingerprint in
188
187
  their keys, independently of numeric reducer versions. Snapshot envelopes validate
189
188
  that fingerprint; another catalog's rows remain untouched. Remote named values
190
- use `x-autobuild-catalog-identity` for cache acceptance, keeping their strict
191
- three-field JSON body unchanged. Missing or mismatching identity, version or
192
- finished shape causes bounded local replay without a remote cache write.
189
+ are canonical regardless of `x-autobuild-catalog-identity`, keeping their strict
190
+ three-field JSON body unchanged. A reducer version mismatch, invalid envelope or
191
+ unrepresentable finished shape raises `ReducerValueIncompatibilityError` with
192
+ client/server versions and validation detail. No remote named read replays events.
193
+ Repository digest batches likewise return the server batch with one scoped
194
+ request and no discovery or per-build fallback.
193
195
 
194
196
  **Named reducer values.** `BuildStore.getReducerValue(scope, {reducer, args?})`
195
197
  returns `{version, cursor, value}` for each eligible entry in the executable
@@ -353,7 +355,14 @@ restart and decision replay agree.
353
355
  `finalize` and `reconcile` have no producer round, so
354
356
  `PHASE_SPECS.inputs.answeredGuidance` makes `ab context` their delivery channel
355
357
  for the latest answer addressed to that phase. On every receiving path,
356
- `packages/core/src/cli/context.ts` materializes `.ab/guidance.json` with the escalation id and
358
+ Build agent environments carry `AB_CONTEXT_DIR`, a workspace-relative directory
359
+ under `.ab/`: core phases use their phase name, agent verifiers use
360
+ `verify-<step>`, and agent finalize post-steps use `finalize-<step>`. Hydration
361
+ replaces only the receiving directory's disposable files. The manifest records
362
+ `contextDir`; `materialized` keys are directory-relative, while manifest path
363
+ fields remain workspace-relative. Sibling contexts remain readable.
364
+
365
+ `packages/core/src/cli/context.ts` materializes `$AB_CONTEXT_DIR/guidance.json` with the escalation id and
357
366
  answer text. For producer and verifier feedback routes, `packages/core/src/kernel/engine.ts`
358
367
  indexes each guidance-bearing phase start as a durable carrier and pairs only
359
368
  the latest carrier for an exact phase plus round/attempt with a subsequent
@@ -361,7 +370,7 @@ matching `session.started`. An unpaired carrier remains deliverable across
361
370
  recovery; the matching launch consumes it once without process-local state. A
362
371
  producer round's feedback is a discriminated union — findings, a
363
372
  failed verify report, or guidance — and a round may carry none, so a round with
364
- guidance writes no `.ab/findings.json`. The receiving skills document their
373
+ guidance writes no `$AB_CONTEXT_DIR/findings.json`. The receiving skills document their
365
374
  corresponding input, and `packages/core/src/cli/skill-guidance.test.ts` derives that
366
375
  requirement from the phase table.
367
376
 
@@ -386,7 +395,7 @@ restores ordinary verification. Policy exclusions precede plan/path applicabilit
386
395
  and carry `skipCause: "post-reconcile-policy"` plus a setting-specific reason.
387
396
  The shared dashboard model renders that reason, as does the PR summary.
388
397
  Excluded steps do not re-verify merged code, so combination-only breakage can
389
- land; forge requirements and reconcile budgets remain independent.
398
+ merge; forge requirements and reconcile budgets remain independent.
390
399
  For enabled steps,
391
400
  `packages/core/src/kernel/plan-verify-selection.ts` resolves an approved plan's front-matter
392
401
  selection (applied at the planner's `ab done` in `packages/core/src/cli/terminals.ts`,
@@ -400,7 +409,7 @@ queryable skipped outcome; Git failure is infrastructure and fails closed,
400
409
  never a synthetic skip. Verify escalation routing is also explicit in the
401
410
  engine: guidance answering an agent verifier's own `ab escalate` returns to the
402
411
  same step on `verify.started.feedback`, which `ab context` materializes as
403
- `.ab/guidance.json`; that cited start remains recoverable before launch, and the
412
+ `$AB_CONTEXT_DIR/guidance.json`; that cited start remains recoverable before launch, and the
404
413
  matching `session.started` for the same step and attempt consumes the answer
405
414
  once. Guidance answering the policy escalation after failed-report exhaustion
406
415
  instead routes to `implement` and outranks the pending report. A bare retry carries no
@@ -458,6 +467,20 @@ The runtime-owned `dispatch-handoff.ts` reader lets the filesystem-only launcher
458
467
  supervise overlapping generations without owning Store or config decisions.
459
468
  A runtime-owned repository-record projection binds the journal transport before
460
469
  initial spawn and across handoffs, including when later config edits are invalid.
470
+ The optional conditional `--read-upgrade` environment extension in
471
+ `dispatch-launch-contract.ts` is versioned independently of launch/overlap v1.
472
+ The launcher caches only the current successful projection, guard inputs and
473
+ pre-read position for each exact runtime/journal/run/lineage/recovery query.
474
+ `dispatch-handoff.ts` checks `getRepoChangePosition` before any metadata or
475
+ reducer reads on a bound query: unchanged helpers make one request and read zero
476
+ event rows, including with cold process/store facades. Changed helpers share one
477
+ store handle and attach the earlier position, so concurrent appends invalidate
478
+ the following check. Durable handoff selection is separate from local target
479
+ identity and rollback-retention guards, which run on every check. Errors clear
480
+ conditional state; a separate predecessor-reader cache uses the active run's
481
+ journal context when the target cannot load. Old peers keep full v1 responses.
482
+ Polling stays at 1 second idle / 250 ms pending, and cached projections still
483
+ pass through ordinary child-exit, pending-preflight and recovery handling.
461
484
  `dispatch-frontend.ts` acknowledges terminal release only after joining input
462
485
  and rendering. The old kernel releases repository authority but retains local
463
486
  execution supervision until completion or the hot policy deadline. Build-log
@@ -574,6 +597,18 @@ and workspace adapter fields stay pinned; changed values are durable restart
574
597
  notices rather than partial adapter swaps. `--once` retains static startup
575
598
  configuration.
576
599
 
600
+ `config/pipeline-source.ts` strictly reads the runner's execution checkout.
601
+ `processes/verify-cycle-config.ts` deposits immutable cycle config and checks
602
+ build-owned identity and source ancestry at settled stage boundaries. Typed
603
+ `verify.config-captured` and `verify.config-superseded` facts advance the result
604
+ boundary in the reducer and log index, independently of reconcile identity.
605
+ The runner refreshes after workspace mutation and before constructing members;
606
+ concurrent siblings settle before another stage is selected. Recovery and
607
+ readiness compose live deployment settings onto the captured artifact revision.
608
+ `kernel/plan-verify-selection.ts` keeps strict plan deposit validation separate
609
+ from runtime drift resolution: unknown approved names select all optional steps
610
+ and an explicit engine action deposits a deduplicated observation.
611
+
577
612
  **Harvest.** The dispatcher owns the threshold trigger and starts runs
578
613
  fire-and-forget; `packages/core/src/processes/harvest.ts` is the deterministic core (scan,
579
614
  source-aware originating-ticket lifecycle projection, filing-time blocker
@@ -645,7 +680,10 @@ so the detached SDK command plus VM stop owns full teardown. Scoped Store facts
645
680
  are the only state channel. Remote terminals append `publication.requested` and
646
681
  park. Only confirmed VM teardown plus execution-lease release permits the local
647
682
  supervisor to use the provider's exact SHA/branch publication capability; a
648
- rejected/uncertain executor completion leaves the request pending. The supervisor
683
+ rejected/uncertain executor completion leaves the request pending. Recovery from
684
+ supervisor loss applies the same gate: observing guest exit must stop the entire
685
+ sandbox before returning terminal evidence. Stop failure retains the open
686
+ execution and its lease for retry. The supervisor
649
687
  verifies the remote head and records the ordinary completion; PR API operations
650
688
  remain on the dispatcher. A failed finalize post-step publication records the
651
689
  ordinary failure-tolerant step outcome and follow-up observation rather than
@@ -678,7 +716,17 @@ dispatcher — requires an exported token before any side effect and never consu
678
716
  a checkout-less host has neither gh nor a keyring, and `vercel-sandbox` publication
679
717
  injects that same token.
680
718
 
681
- **Stable build identity.** The forge landing seam accepts optional build identity at operation time. Both
719
+ **Hosted sandbox lifetime.** `createHostedOperatorSandboxService` owns its default
720
+ local scratch root and removes it on construction failure or asynchronous,
721
+ idempotent `dispose()`. Explicit caller scratch remains caller-owned. Disposal
722
+ cleans local composition resources, independently of durable remote sandbox
723
+ `release`. The operator archive handler disposes a backend acquired through
724
+ `sandboxFor` after each request, including failure; a static backend retains its
725
+ caller's lifetime. Distribution packing likewise protects both temporary roots
726
+ from allocation onward and awaits both cleanup attempts before returning bytes
727
+ or reporting failure.
728
+
729
+ **Stable build identity.** The forge merge seam accepts optional build identity at operation time. Both
682
730
  built-in adapters preserve their squash message and normalize a final
683
731
  `Autobuild-Build: <slug>` trailer through `packages/core/src/kernel/build-identity.ts`. The GitHub
684
732
  adapter reads the viewer's squash headline/body and head in one GraphQL query;
@@ -690,7 +738,7 @@ any repair. Body comparison tolerates provider trimming of trailing whitespace
690
738
  while preserving the complete headline, body content, and squash method.
691
739
 
692
740
  Optional `Forge.readCommitMessage` and `Forge.containsBuild` capabilities expose
693
- actual landed messages and exact trailer presence in reachable branch history.
741
+ actual merged messages and exact trailer presence in reachable branch history.
694
742
  The janitor records optional `pr.merged.buildTrailerPresent` for normal and abort
695
743
  cleanup observations. Unsupported or failed inspection leaves evidence unknown;
696
744
  a read failure also records an observation without preventing completion. Old
@@ -702,10 +750,10 @@ Its branch hint is checked against the PR's actual base, with a bounded re-query
702
750
  after a retarget rather than assuming the repository default is the base.
703
751
  Kernel auto-merge therefore
704
752
  returns an actionable `unproven-gate-state` deferral for queue-protected bases;
705
- it never bypasses the queue. Human queue landings still settle normally with
753
+ it never bypasses the queue. Human queue merges still settle normally with
706
754
  inspected trailer evidence when available. Expected-head guards and recurring
707
755
  polls bound native message freshness, but cannot prevent a push and automatic
708
- landing from both completing between polls.
756
+ merge from both completing between polls.
709
757
 
710
758
  **Agent runtimes.** `packages/core/src/ports/runner/`: `runtime.ts` (capability-carrying
711
759
  registry plus boundary validation), `routing.ts` (eager role resolver),
@@ -742,16 +790,16 @@ factory, and preserves the returned adapter's optional capabilities. The
742
790
  local-git adapter in `packages/core/src/ports/forge/local-git.ts` stores versioned JSON PR
743
791
  records as blobs behind private `refs/autobuild/local-git/` refs in the shared
744
792
  Git database. It computes mergeability with `git merge-tree`, leaves the build
745
- branch reachable, and lands a guarded single-parent squash locally. Immediately
746
- before offering an ungated landing candidate, `git var GIT_AUTHOR_IDENT` and
793
+ branch reachable, and merges a guarded single-parent squash locally. Immediately
794
+ before offering an ungated merge candidate, `git var GIT_AUTHOR_IDENT` and
747
795
  `git var GIT_COMMITTER_IDENT` prove that ordinary Git identity resolution can
748
796
  succeed; a failure becomes a reason-bearing, retryable consent deferral. The
749
797
  `git commit-tree` seam inherits that resolved identity without injecting an
750
- Autobuild author or committer, while `-c commit.gpgSign=false` keeps the landing
798
+ Autobuild author or committer, while `-c commit.gpgSign=false` keeps the merge
751
799
  unsigned. For a checked-out base, dry-run and real
752
- `git read-tree -m -u <old> <landed>` calls
800
+ `git read-tree -m -u <old> <merged>` calls
753
801
  let Git carry forward non-overlapping operator changes and report colliding
754
- paths. The pending landing precedes the guarded ref update; a later poll retries
802
+ paths. The pending merge precedes the guarded ref update; a later poll retries
755
803
  the same two-tree checkout transition across the crash window and observes the
756
804
  PR as merged only after synchronization succeeds. Forge-native base snapshotting lets
757
805
  it pin the current local base without `origin`, while capability-less adapters
@@ -866,7 +914,13 @@ admission at every asynchronous read stage; the kernel uses its original store
866
914
  and independent tick timers. Cached clock paints perform no reads. The mode
867
915
  ledger owns focus reporting through teardown and catchable faults; job-control
868
916
  suspension restores modes and input before stopping and reactivates with assumed
869
- focus on resume. Plain, non-TTY, and once runs never enable focus reporting.
917
+ focus on resume. Plain, non-TTY, and once runs never enable focus reporting. The active
918
+ `processTerminalInput` subscription synchronously reasserts raw mode on activation
919
+ and every 100 ms with adjacent false/true calls, bypassing Bun's cached `isRaw`
920
+ after a retired generation restores shared termios at exit. Its unreferenced
921
+ timer is disarmed before cleanup restores prior raw/flow state; release,
922
+ suspension and shutdown therefore leave no raw-mode maintenance behind. Timer
923
+ failures tear down the subscription best-effort; activation failures propagate.
870
924
 
871
925
  `packages/core/src/cli/build-progress.ts` projects the exact last-event, heartbeat, and lease
872
926
  inputs shared by the diagnostic `ab builds` and `ab build status` surfaces. Its
@@ -920,7 +974,7 @@ proven per tool by `operator/registry.contract.test.ts`. Every binding is genera
920
974
  from the table and never widens beyond the operator services: the shipped one is
921
975
  `packages/core/src/cli/mcp.ts` (`ab mcp`, a stdio MCP server over the registry that
922
976
  fails closed inside a phase, exactly as repository-wide `ab builds` does); the
923
- embedded orchestrator and later transports register from the same table. Checked-in
977
+ hosted HTTP and MCP transports register from the same table. Checked-in
924
978
  risk classes live in `operator/annotations.ts` (SPEC §8.9).
925
979
 
926
980
  **Init and upgrade.** `packages/core/src/cli/init.ts` owns deterministic skill vendoring,
@@ -1001,7 +1055,7 @@ A claim freezes the ticket's current assets into the build (SPEC §6.3):
1001
1055
  `build.created.assets` (and, when a spec is revised from the ticket,
1002
1056
  `spec.revised.assets`) record the pinned revisions, `state.pinnedAssets` in the
1003
1057
  reducer projects them, `getPinnedTicketAsset` reads them back by pinned revision,
1004
- and `ab context` writes them under `.ab/assets/`.
1058
+ and `ab context` writes them under `$AB_CONTEXT_DIR/assets/`.
1005
1059
 
1006
1060
  For hosted tickets, `store/ticket-asset-snapshots.ts` copies exact revisions
1007
1061
  into chunked immutable repository artifacts in the build store before pinning.
@@ -1011,19 +1065,30 @@ and attachments in old local stores are not moved.
1011
1065
 
1012
1066
  In node `verify:*` context, `nodeVerification` in the manifest identifies the frozen
1013
1067
  `range`, `indexPath`, `contributions`, `handPushedCommits` and `unattributedCommits`. Each contribution
1014
- has `build`, its current stored `ticket` identity, `spec: {kind: 'spec', rev}`,
1068
+ has `build`, its preparation-time stored `ticket` identity, `spec: {kind: 'spec', rev}`,
1015
1069
  `specPath` and `commits`. The JSON index repeats this metadata and adds the
1016
1070
  exhaustive ordered `commits: [{sha, build?}]` mapping. Paths are workspace-relative
1017
1071
  and reflect scratch allocation, including legacy tracked-file collisions.
1018
- Contribution specs normally live at `.ab/contributions/<build>/spec.md`; the index
1019
- normally lives at `.ab/node-verification.json`. These files are marked `derived`
1072
+ Contribution specs normally live at `$AB_CONTEXT_DIR/contributions/<build>/spec.md`; the index
1073
+ normally lives at `$AB_CONTEXT_DIR/node-verification.json`. These files are marked `derived`
1020
1074
  in `materialized`, with their source build and revision recorded in the metadata.
1021
1075
 
1022
1076
  Membership comes from build identity trailers on every commit reachable in the
1023
1077
  frozen parent-to-head range, including earlier cycles and merge side history.
1024
- Specs use the current event-authorized revision, never an unsanctioned latest
1025
- deposit or mutable ticket body. Unknown identities, ambiguous or invalid trailers,
1026
- and missing source data fail hydration. Commits without a build trailer are
1078
+ The dispatcher gathers contributor material with repository authority while
1079
+ preparing the exact cycle head, before launching verification. Specs use the
1080
+ event-authorized revision at preparation, never an unsanctioned latest deposit
1081
+ or mutable ticket body. Unknown identities, ambiguous or invalid trailers, and
1082
+ missing source data prevent preparation. A versioned node-owned
1083
+ `node-verification-context` artifact is deposited atomically with
1084
+ `integration.prepared`, which cites its exact revision. Context hydration reads
1085
+ only that citation, validates its cycle and range, and allocates public paths;
1086
+ it needs no contributor reads or Git provenance discovery. Concurrent members
1087
+ and resumed sessions retain the same frozen specs; a new cycle collects fresh
1088
+ inputs. Missing, corrupt or mismatched inputs fail without publishing a manifest.
1089
+ Historical agent cycles without a citation require a new prepared cycle;
1090
+ check-only cycles do not require contributor inputs. Session and build scope
1091
+ permissions remain unchanged. Commits without a build trailer are
1027
1092
  listed as unattributed, a mechanical absence of a trailer rather than an authorization verdict.
1028
1093
  `handPushedCommits: [{sha, originalSha, message}]` identifies node-owned hand-pushed
1029
1094
  commits in the frozen range. Ownership uses the durable first-parent contribution
@@ -1033,7 +1098,7 @@ These messages express maintainer-authorized intent: judge quality and consisten
1033
1098
  never fail these commits solely for lacking a covering spec.
1034
1099
  Other node changes are authorized when the node spec or the spec of the contribution
1035
1100
  that introduced it covers it; use the commit mapping to find that spec.
1036
- Leaf verification context is unchanged.
1101
+ Leaf verification omits node provenance.
1037
1102
 
1038
1103
  Both `ab dispatch` and sessionless `ab ticket` load the repository's plugins
1039
1104
  before selecting their TicketSource; dispatch passes that one adapter instance
@@ -1160,7 +1225,7 @@ metadata, not ordering. Runtime opens assert schema and never run DDL.
1160
1225
  The service exposes one lazy live reader to the operator server, web gateway,
1161
1226
  MCP and server-rendered repository picker. Initialization failures clear the
1162
1227
  cached promise for retry. The dispatcher opens its own shared pool and queries
1163
- membership each invocation. See [owner workflow](setup.md#connected-projects).
1228
+ membership each invocation. See [owner workflow](remote-store-protocol.md#7-authentication-and-project-authority).
1164
1229
 
1165
1230
  ## Delegated execution authority
1166
1231
 
@@ -1192,9 +1257,13 @@ Service requests reread durable state; detached executions need neither renewal
1192
1257
  secrets nor their original dispatcher. Local stores retain their existing path.
1193
1258
  Project onboarding uses `cli/connect.ts`, user-level `cli/project-credentials.ts`,
1194
1259
  the shared `connection.ts` wire types, and Postgres `connections.ts`. Approval
1195
- commits registry membership, a credential digest, and the outcome atomically.
1260
+ commits registry membership, organization assignment, a credential digest, and
1261
+ the outcome atomically. Assignment classification is independent of registry
1262
+ history; every unassigned approval requires an explicit eligible organization.
1196
1263
  The web connection routes authenticate the existing Better Auth session and
1197
- reuse the sign-in/consent layout; CLI polling uses a separate private capability.
1264
+ reuse the sign-in/consent layout. Valid code links look up approval immediately,
1265
+ including on return from sign-in; the view shows selected destinations or the
1266
+ read-only assigned organization. CLI polling uses a separate private capability.
1198
1267
 
1199
1268
  ## Revision-checked ticket writes
1200
1269
 
@@ -1251,7 +1320,7 @@ compatibility facade. Metadata is excluded from hosted persistence/protocols.
1251
1320
  ### Integration node dispatch
1252
1321
 
1253
1322
  The product dispatcher owns the workspace-free node lifecycle:
1254
- spec → node.opening → node.opened → collecting → complete → verify:* → consent → land.
1323
+ spec → node.opening → node.opened → collecting → complete → verify:* → consent → merge.
1255
1324
  The ordinary work pipeline is unchanged. `build.created` freezes kind, target
1256
1325
  ticket/build identity and resolved parent in `baseBranch`. Integration facts
1257
1326
  are projected by the shared reducer and digests, including collecting/empty
@@ -1297,7 +1366,10 @@ and session settlement fence mutation. Transaction targets stay frozen while
1297
1366
  later moves coalesce. `publication.requested` carries automatic transaction
1298
1367
  identity through trusted remote teardown and publication. The runner settles
1299
1368
  local resolver intent only after its session ends. Verification facts
1300
- cite the cycle's base/head, and clean waiting rewrites preserve those results.
1369
+ cite the cycle's base/head. Clean waiting leaf rewrites preserve completed
1370
+ verification when build-owned config is unchanged, even when the old pin commit
1371
+ is no longer an ancestor. Changed config still supersedes while waiting.
1372
+ Ancestry gates cycles that run further steps; those cycles capture fresh config.
1301
1373
  Object packs retain newly introduced replay trees/blobs as well as commit bytes.
1302
1374
 
1303
1375
  GitHub archive push/fresh-fetch and rewrite contracts are manual opt-in cases in
@@ -1334,8 +1406,8 @@ revision, target and reason fields so JSONB key ordering cannot defeat deduplica
1334
1406
  preserving its history.
1335
1407
 
1336
1408
  Accepted parent facts update node target/base projections while creation facts
1337
- remain provenance. Pending requests and moves fence verification, child landing
1338
- and source landing, and count against both parents' completeness. Existing writer
1409
+ remain provenance. Pending requests and moves fence verification, child merge
1410
+ and source merge, and count against both parents' completeness. Existing writer
1339
1411
  reservations settle before activation. The existing replay transaction freezes the
1340
1412
  new destination and retains the old contribution boundary until completion, even
1341
1413
  for distinct parents at the same SHA. Afterwards the dispatcher retargets the same
@@ -1360,8 +1432,8 @@ receive-pack path.
1360
1432
  `kernel/node-landing.ts` shares the node writer lease and reservation with
1361
1433
  restacking. It cancels native auto-merge, refreshes actual PR refs, proves the
1362
1434
  exact destination ungated and fast-forwards the canonical child commit under
1363
- CAS. The destination write proves landing; provider PR reconciliation is
1364
- best-effort and never decides or retries that write. Root landing retains squash
1435
+ CAS. The destination write proves merge; provider PR reconciliation is
1436
+ best-effort and never decides or retries that write. Root merge retains squash
1365
1437
  semantics. Store adapters expose node writer claim, renewal and holder-checked
1366
1438
  release separately from execution leases; Postgres schema version 15 adds their
1367
1439
  columns. Reservations live in the event stream and survive lease expiry.
@@ -1375,11 +1447,11 @@ both inventory and active items, retaining original identities after rewrites.
1375
1447
 
1376
1448
  Integration completion is sampled by `kernel/integration-completeness.ts` from
1377
1449
  exhaustive source listings, frozen claims and retained contribution identities.
1378
- `integration.*` events retain observations, immutable cycle inputs, landing
1450
+ `integration.*` events retain observations, immutable cycle inputs, merge
1379
1451
  intents, provenance and tree audits. The build reducer projects these facts and
1380
1452
  `engine.ts` routes nodes directly through verification, without producer phases.
1381
1453
  The shared `cli/dashboard/integration-detail.ts` projection supplies both
1382
- dashboards with all child titles/states, current verification outcomes, landing
1454
+ dashboards with all child titles/states, current verification outcomes, merge
1383
1455
  rule explanations and restack files. Optional `integration.observed.children`
1384
1456
  metadata stores source/id, title and contribution identity without changing the
1385
1457
  authoritative membership arrays. Completed build records supply legacy title
@@ -1389,7 +1461,7 @@ NUL-delimited unmerged Git paths; historical missing filenames remain explicit.
1389
1461
  Repository enrichment refreshes live child phases even without a parent delta.
1390
1462
  Failed cycles park for repair children. The dispatcher temporarily provisions
1391
1463
  verification resources and rechecks head, parent, controls and completeness
1392
- before publication. `integration-landing.ts` owns source-reserved root landing
1464
+ before publication. `integration-landing.ts` owns source-reserved root merge
1393
1465
  and immutable result audits; nested nodes use the destination writer transaction
1394
1466
  in `node-landing.ts`. GitHub uses guarded PR rebase; local-git validates
1395
1467
  fast-forward shape against the frozen parent. Exact authoritative head readback
@@ -1398,14 +1470,14 @@ acknowledge an unconfirmed candidate. Shared status vocabulary exposes provenanc
1398
1470
  and mismatch attention in both frontends. Human forge merges remain observable
1399
1471
  escape hatches independent of completeness and verification.
1400
1472
 
1401
- ### Landing authorization
1473
+ ### Merge authorization
1402
1474
 
1403
1475
  The pure evaluator in `kernel/landing-policy.ts` chooses the first matching
1404
- `[[landing]]` rule. `kernel/landing-state.ts` reduces immutable candidate
1405
- decisions and persistent hold/land commands. The dispatcher owns readiness,
1476
+ `[[merge]]` rule. `kernel/landing-state.ts` reduces immutable candidate
1477
+ decisions and persistent hold/merge commands. The dispatcher owns readiness,
1406
1478
  ticket label sampling and native-state convergence. `kernel/landing-publication.ts`
1407
1479
  confirms native cancellation at local and trusted remote head-publication seams.
1408
- Node landings retain the existing writer serialization and gate proof.
1480
+ Node merges retain the existing writer serialization and gate proof.
1409
1481
 
1410
1482
  Build native session handles are kernel-authored `session.native-handle-recorded`
1411
1483
  facts. The build reducer retains them by bracket session id after session end;
@@ -1482,6 +1554,25 @@ execution and unchanged-base progress budgets retain their existing accounting.
1482
1554
 
1483
1555
  ## Forge failure recovery
1484
1556
 
1557
+ `kernel/publication-retry.ts` selects eligibility from the publication ledger
1558
+ and shares the policy between `processes/build-runner.ts` and trusted
1559
+ `cli/publication-settlement.ts`. The lease sweep skips ineligible retained intents;
1560
+ `ForgeRequestDeferred` also prevents release from recording publication loss.
1561
+
1562
+ Leaf restack and reconcile publication retry classified transient forge or transport
1563
+ failures six times after the initial attempt, waiting 30, 60, 120, 240, 300 and
1564
+ 300 seconds. `publication.retry-scheduled` records the operation, frozen rewrite
1565
+ identity, episode anchor, failure ordinal, last error and absolute retry time;
1566
+ restart resumes that schedule without rerunning the resolver. These retries do
1567
+ not consume `maxPhaseAttempts`. A seventh transient failure records
1568
+ `publication.retry-exhausted` and raises `publication-retry-limit`, naming the last
1569
+ error and six retries. Answering that escalation opens a fresh publication episode
1570
+ for the same retained intent without resetting agent phase failures. Pending
1571
+ publication keeps its workspace through backoff and unresolved exhaustion.
1572
+ Classified rate limits retain repository cooldown and consume no publication
1573
+ retry allowance. Rejected pushes, lease conflicts, dirty trees and unclassified
1574
+ errors retain their existing behavior.
1575
+
1485
1576
  Janitor failures are durable per-build episodes. Eligible failures retry after
1486
1577
  30, 60, 120, 240 seconds, then at the configured cap (300 seconds by default).
1487
1578
  Skipped polls preserve the episode across restart. After
@@ -1492,7 +1583,7 @@ clears it. `policy.janitorBackoffMaxSeconds` sets the positive integer cap.
1492
1583
  A classified forge rate limit records repository degradation with `resetAt`.
1493
1584
  Forge work waits during cooldown; passing the deadline permits a recovery
1494
1585
  request, and only success clears degradation. A further limit extends cooldown.
1495
- Native landing application failures keep candidate-specific retry eligibility,
1586
+ Native merge application failures keep candidate-specific retry eligibility,
1496
1587
  including automatic decisions without a human command. Retries recheck consent,
1497
1588
  holds, verification and the exact candidate. Uncertain enables remain pending
1498
1589
  until cancellation can be confirmed after cooldown. Publication retries reuse
@@ -1516,7 +1607,7 @@ using exact-resource ETags; authenticated 304s spare the REST primary quota.
1516
1607
  Adapter caches are bounded and restart/eviction falls back to fresh reads.
1517
1608
  Writes, including Git publication and rewrites, invalidate observations before
1518
1609
  attempting the mutation so acknowledgement reads remain fresh. Leaf PR polling
1519
- keeps its existing cadence. Readiness and landing inspections remain fresh.
1610
+ keeps its existing cadence. Readiness and merge inspections remain fresh.
1520
1611
 
1521
1612
  For node cadence, durable wakes, restart behavior and CLI evidence, see
1522
1613
  [node polling and status](integration-tree.md#polling-and-status).
@@ -1535,7 +1626,7 @@ mappings; current-operation resolvers leave build records and old events intact.
1535
1626
 
1536
1627
  A failed node verification cycle records `integration.verification-failed` with its prepared cycle id, failed steps, exact head and parent, and guidance to file a repair child targeting the node. The kernel reports durable failed receipts; dispatcher housekeeping recovers missing reports for the current cycle using a per-cycle CAS guard. Superseded cycles are never backfilled with repair instructions: recovery requires the latest prepared cycle to match the node’s observed head and parent. This fact is decisive evidence and bookkeeping, and does not change verification or leaf routing.
1537
1628
 
1538
- Default watch and new hosted wake settings include this event. Watch cursors deliver each failed cycle once and baseline failures when first armed; reconcile build status after arming. `ab wait --for attention` also detects a current failed node cycle before the report is written. Historical facts remain queryable after repair without retaining current attention. Explicit event globs and existing stored wake choices are preserved.
1629
+ Default `ab watch` includes this event. Watch cursors deliver each failed cycle once and baseline failures when first armed; reconcile build status after arming. `ab wait --for attention` also detects a current failed node cycle before the report is written. Historical facts remain queryable after repair without retaining current attention. Explicit event globs and existing stored wake choices are preserved.
1539
1630
 
1540
1631
  `packages/core/src/kernel/integration-state.ts` retains reported cycle identities and selects missing failures from exact receipts. `kernel/integration-attention.ts` owns their CAS append; `processes/build-runner.ts` reports after verification and `processes/dispatcher.ts` recovers missing facts before per-build janitor gates. The shared `cli/dashboard/model.ts` projects current failure as blocked attention for both frontends.
1541
1632
 
@@ -1551,10 +1642,128 @@ Each kernel `spec.revised` records the exact artifact and operator identity
1551
1642
  Ticket-origin revisions re-pin assets; supplied bodies preserve asset pins.
1552
1643
  The node recollects and verifies the new revision, including on the same head
1553
1644
  and parent after a failed cycle. Earlier cycles remain historical evidence
1554
- and cannot block or authorize landing under the replacement. Children keep
1645
+ and cannot block or authorize merge under the replacement. Children keep
1555
1646
  their specs, claims and targets; contributions are not restarted.
1556
1647
  Active verification/reconcile or writer work, restack/reparent work, pause,
1557
- pending controls, landing intent and ended PRs refuse the no-escalation path.
1648
+ pending controls, merge intent and ended PRs refuse the no-escalation path.
1558
1649
  A concurrent state change refuses publication with a retry explanation;
1559
1650
  uncited artifacts are inert. Leaves still require an open escalation and
1560
1651
  restart from `plan`.
1652
+
1653
+ Verification stages are planned purely in `kernel/verify-stages.ts`, shared by
1654
+ leaf and integration decisions in `kernel/engine.ts`. The build runner keeps
1655
+ only live per-member handles and recovery contexts; durable starts, outcomes,
1656
+ cancellations and failed-stage receipts drive every barrier and restart.
1657
+ Fail-fast cancellation records facts before whole-execution teardown and
1658
+ replacement. `kernel/verify-stage-state.ts` owns occurrence/session associations,
1659
+ including escalation supersession and complete implement feedback references.
1660
+
1661
+ Human access uses `postgres-store/src/organizations.ts` and the shared hosted
1662
+ `web/access.ts` policy. Auth schema v4 adds Better Auth organizations/member rows,
1663
+ an authoritative normalized-email grant ledger and one project-to-org assignment.
1664
+ Successful identity persistence materializes grants into member rows without
1665
+ placeholder users or invitations. Mutations and connection decisions serialize
1666
+ through the project registry singleton (after the connection row where relevant).
1667
+ Admission and project filtering read durable state on each browser request and
1668
+ MCP callback; session claims and activeOrganizationId confer no authority.
1669
+
1670
+ ## Operator presence
1671
+
1672
+ A standing CLI operator operates the builds the repository's dispatcher dispatches.
1673
+ `ab watch --operator` upserts mutable `(repo, id)` liveness rows in each BuildStore
1674
+ adapter; a cursor carries the registration ID and original start time. Heartbeats
1675
+ run independently of watch discovery and held reads. A final best-effort renewal
1676
+ anchors orderly-exit grace; rows expire after 300,000ms. Neither registration,
1677
+ renewal nor removal appends events, creates a repository journal or claims a lease.
1678
+ SIGINT, SIGTERM, SIGHUP and stdout EPIPE cancel pending presence writes and attempt
1679
+ one idempotent repository/ID removal within a shared two-second shutdown budget.
1680
+ Failures retain TTL fallback (silently for an unsupported remote route); SIGKILL
1681
+ remains TTL-only. Timeout/count completion retains presence for routine re-arming.
1682
+ Reads on an unknown repository return an empty collection. Status loads presence separately
1683
+ from fact reduction. Build/session/phase authority cannot register; remote routes
1684
+ require repository operator authority. Concurrent advisory registrations coexist.
1685
+ Unflagged watch and `ab wait` remain read-only; MCP and dashboards do not register.
1686
+
1687
+ Dashboard destination distance is projected from durable `target.distance`
1688
+ (work) and `node.parent-distance` (integration) observations. Shared suffixes
1689
+ are `+N`, empty when current, and `+?` when unknown, suppressed after merge or
1690
+ close. Terminal headers reserve space for the destination before the slug;
1691
+ web views keep their own layout and share the wording.
1692
+
1693
+
1694
+ ## Project-secret boundary
1695
+
1696
+ `packages/core/src/project-secrets.ts` owns the write-only DTO; browser-safe reserved-name
1697
+ rules and the shared public explanation live in `packages/core/src/secret-name.ts`. `packages/postgres-store/src/project-secrets.ts` stores authenticated encrypted
1698
+ payloads outside the BuildStore namespace, with metadata, mutation audit, a deployment
1699
+ key verifier and generation/revision fences. Short transactions implement refresh
1700
+ claim/completion CAS; provider HTTP occurs after the claim commits, with no backend
1701
+ session affinity. An expired pending rotation fails without token reuse.
1702
+
1703
+ The separate `packages/hosted-store-service/src/web/project-secrets.ts` handler
1704
+ uses fresh cookie-session organization membership or super-user authority for
1705
+ Settings metadata and static writes. Its durable effective-config projection
1706
+ returns only account names, kinds, credential slots and readiness. Browser writes
1707
+ use the same transaction and project lock through `setStaticOnly`, refusing an
1708
+ existing refreshing kind atomically. The Settings client fences stale polls and
1709
+ keeps write acknowledgments separate from failed metadata rereads.
1710
+
1711
+ `packages/hosted-store-service/src/project-secrets.ts` authenticates owner-purpose
1712
+ credentials and fresh membership before reading write bodies. It returns metadata
1713
+ or acknowledgments and fixed safe errors. `ab secrets` uses saved connection
1714
+ credentials directly and hidden input. The hosted dispatcher internally resolves
1715
+ the complete set per tick, validates the handoff under the mutation lock, overlays
1716
+ a fresh project environment, strips the encryption key, and redacts supplied
1717
+ values in output/errors. Effective-config artifacts serialize declarative config,
1718
+ not the process environment. Empty snapshots bypass decryption/key validation only
1719
+ after reading and validating the complete version set under the project lock;
1720
+ new secrets invalidate an earlier empty handoff. Writes always validate the key.
1721
+ No operator/MCP/raw-store accessor resolves plaintext.
1722
+
1723
+ ### Named billing accounts
1724
+
1725
+ Deployment-owned `[accounts.<name>]` descriptors contain `kind` and
1726
+ `credentialEnv`, plus the closed Kimi `region` (`overseas` by default or `china`).
1727
+ Role and alternate `account` axes inherit independently. Claude routes default
1728
+ to the sole Claude subscription account; ambiguity, unknown references and
1729
+ incompatible runtimes fail configuration. No accounts preserves legacy behavior.
1730
+ Claude and Kimi accounts require the unmodified Claude Code runtime; ChatGPT
1731
+ subscription accounts require explicit Codex selection. Use the user's own plan
1732
+ for ordinary individual usage. Claude and Kimi credentials are provisioned
1733
+ manually. ChatGPT credentials are authorized with `ab accounts login NAME
1734
+ [--local|--project]`. The local dispatcher or hosted refreshing project secret
1735
+ is the sole refresh owner; no sandbox refreshes. Local Codex uses a protected
1736
+ loopback inference transport and isolated CODEX_HOME, preserving the shell HOME
1737
+ and leaving ambient login untouched.
1738
+ Hosted validation uses write-only metadata and states that the first hosted
1739
+ build is the live check; local validation makes a minimal runtime request.
1740
+
1741
+ Local sessions resolve host credentials after ambient merging. Remote sessions
1742
+ receive account placeholders; exact provider hostname and placeholder header
1743
+ matches broker real credentials on the host. Both Kimi endpoint and host derive
1744
+ from one closed regional mapping, without cross-region retry. Observation ticks
1745
+ refresh the live egress policy from dispatcher environment values. Selected
1746
+ account descriptors persist with sessions for continuation; configuration and
1747
+ launch artifacts contain no secret values. Credential rejections require renewal
1748
+ and bypass alternates; quota and availability retain existing fallback behavior.
1749
+ Account secrets are redacted at persistence boundaries, including split streamed
1750
+ deltas and prior values retained across rotation.
1751
+
1752
+
1753
+ ### Hosted project deletion
1754
+
1755
+ The Projects web surface allows super users and organization owners to preview
1756
+ counts and permanently delete their authorized projects with the shared confirmation dialog.
1757
+ PostgreSQL fences the registration generation before physical blob cleanup and
1758
+ retains durable pending inventory for restart/retry. Upload ownership is reserved
1759
+ in a separate committed transaction before provider I/O; transaction-scoped shared
1760
+ blob locks cover upload/publication, and exclusive locks cover reference checks
1761
+ and physical deletion. Other projects' references and reservations preserve shared
1762
+ bytes. Completion removes all project rows except repository, actor, deletion time
1763
+ and an opaque generation id in the deletion audit. Old credentials receive 401;
1764
+ repository-established requests receive 403 project not registered. Approval of a
1765
+ fresh connection starts empty and resets hosted ticket numbering. `ab disconnect`
1766
+ revokes credentials only; admin `projects remove` unregisters without purging.
1767
+ See [project deletion protocol](operator-api.md#permanent-project-deletion).
1768
+
1769
+ The ticket-source port optionally exposes `listPage(criteria, page)` for paged operator reads. PostgreSQL counts matches and applies SQL LIMIT/OFFSET; other sources retain exhaustive-read slicing. CLI and dispatcher reads stay exhaustive. See [ticket source contract](ticket-sources.md#writing-your-own).
Binary file