@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
@@ -17,15 +17,15 @@ session.
17
17
  ## Node tickets and targets
18
18
 
19
19
  Write a node ticket as a **charter**: the integration goal, checkable completion
20
- conditions for the whole, and its destination and landing expectations under the
20
+ conditions for the whole, and its destination and merge expectations under the
21
21
  repository's effective policy. Put evolving feature specifics in child tickets.
22
22
  The charter still follows all four parts of the spec standard: what and why,
23
23
  verifiable acceptance criteria, out of scope, and evidence.
24
24
 
25
25
  For example: “Integrate a coherent account-management flow so users can manage
26
26
  their account in one place. Done means the child-delivered account settings and
27
- account closure flows work together and pass integration verification. Land the
28
- complete flow into its parent under the configured landing policy.” Record the
27
+ account closure flows work together and pass integration verification. Merge the
28
+ complete flow into its parent under the configured merge policy.” Record the
29
29
  scope exclusions and supporting evidence alongside these criteria; describe each
30
30
  flow's detailed requirements in its child spec.
31
31
 
@@ -56,8 +56,8 @@ the split is warranted under the standard's
56
56
  guidance, then explicitly choose root or a node before filing,
57
57
  including when fleshing out an existing ticket splits it into several tickets.
58
58
  Consult the shared destination criteria and read
59
- the repository's effective landing policy in `autobuild.toml`; explain the actual
60
- landing and consent flow to the human in plain terms. Ask the human when the
59
+ the repository's effective merge policy in `autobuild.toml`; explain the actual
60
+ merge and consent flow to the human in plain terms. Ask the human when the
61
61
  choice is unclear from grooming. Root is valid when each ticket can ship alone.
62
62
  Choosing root or a node never changes the requested workflow state or silently
63
63
  promotes tickets; the placement instructions below still apply.
@@ -111,13 +111,15 @@ setting is absent.
111
111
  When the explicitly named destination equals `[tickets].readyState`, tell the
112
112
  human in the completion response that the ticket may be claimed by the next
113
113
  dispatch once the repository's label, dependency, intake, capacity, and other
114
- readiness gates are satisfied, and that you will operate it from there (see
115
- [After filing: operate what you queued](#after-filing-operate-what-you-queued)).
114
+ readiness gates are satisfied. Before ready filing, follow
115
+ [After filing: check operator presence](#after-filing-check-operator-presence):
116
+ with a live operator, say the existing operator will pick it up; without one,
117
+ say you will operate it. The human's explicit instructions override either default.
116
118
 
117
119
  If grooming established prerequisites, follow the complete
118
120
  [safe blocker-filing workflow](../ab-guide/references/ticket-dependencies.md).
119
121
  A single `ab ticket create --blocked-by` invocation does not publish atomically:
120
- Linear (including hosted Linear) exposes the issue before separate blocker writes.
122
+ Linear exposes the issue before separate blocker writes.
121
123
  For a ready destination, create in a known non-ready staging state, pass all
122
124
  blockers at creation, read back and verify them, then move to ready last. The
123
125
  human's requested final placement still wins; temporary staging needs no new
@@ -226,20 +228,18 @@ files over the store's size limit), keep the external link in Evidence and say
226
228
  plainly, in the spec and to the human, that builds cannot read it, so the
227
229
  planner does not treat it as a contract.
228
230
 
229
- ## After filing: operate what you queued
231
+ ## After filing: check operator presence
230
232
 
231
- Once work you specified sits in the ready state, its builds start without
232
- anyone watching them. By default, the agent that wrote the spec becomes their
233
- operator agent. You hold the context an escalation asks about — the intent, the
234
- alternatives the human rejected, what was ruled out of scope — and a build
235
- blocked on a question you could answer should not wait for a human.
233
+ Before leaving work in the ready state, run `ab repository status --json` and
234
+ inspect `operator.registrations`. If a live operator is present, record the
235
+ operating context in the ticket body: intent, rejected alternatives, and why
236
+ things were ruled out of scope. File the work, tell the human the existing
237
+ operator will pick it up, and stop without arming a watch.
236
238
 
237
- So when this conversation leaves work in the ready state, say in the
238
- completion response that you will shepherd it, then load the `ab-operate`
239
- skill and follow it: arm the standing watch, reconcile status, resolve
240
- attention, and report each outcome until every build you queued has merged or
241
- otherwise ended. Shepherd what this conversation queued unless the human
242
- widens the scope.
239
+ If no operator is present, say you will operate, load `ab-operate`, and follow
240
+ its startup check and standing watch. The role covers the builds the repository's dispatcher dispatches,
241
+ including newly dispatched builds, rather than only this conversation's tickets.
242
+ The human's explicit instructions override either default.
243
243
 
244
244
  This is the default, not a requirement:
245
245
 
@@ -12,7 +12,7 @@ content and blocker relationships. The default file source needs no secret.
12
12
  ## Node tickets and targets
13
13
 
14
14
  Use a spec-standard charter for the node's integration goal, whole-level
15
- completion and policy-controlled landing; put feature specifics in children.
15
+ completion and policy-controlled merge; put feature specifics in children.
16
16
  While the node is open, iterate by adding spec-standard children targeting its
17
17
  ticket id, pushing small maintainer-authorized tweaks to its recorded branch
18
18
  with meaningful intent in commit messages, or explicitly revising its charter.
@@ -52,7 +52,8 @@ When `[tickets].source = "hosted"`, use readable ids such as `ENG-12` with
52
52
  `ab ticket show`, `update`, `move`, `block`, and `unblock`. Inputs accept any
53
53
  letter case and old UUID ids remain aliases. Output shows canonical readable
54
54
  ids; blocker references use the same identity. Numbering belongs to each project
55
- and never resets or reuses deleted numbers. A `teamKey` change affects future
55
+ and never resets or reuses deleted numbers within a project lifetime. Permanent
56
+ project deletion removes the counter; browser-approved reconnection starts at 1. A `teamKey` change affects future
56
57
  prefixes only. File and Linear id rules are unchanged. See the
57
58
  [hosted ticket protocol](../ab-guide/references/remote-ticket-protocol.md).
58
59
 
@@ -97,7 +98,7 @@ succeeds.
97
98
 
98
99
  For dependencies on any source, follow the
99
100
  [safe blocker-filing workflow](../ab-guide/references/ticket-dependencies.md).
100
- Direct and hosted Linear record blockers after creating the issue, so a ready
101
+ Direct Linear record blockers after creating the issue, so a ready
101
102
  issue can be claimed before `create --blocked-by` returns. Stage dependents in a
102
103
  known non-ready state, verify all blockers with `ab ticket show --json`, then use
103
104
  `ab ticket move` to publish the intended ready destination. Do not use the local
@@ -169,12 +170,14 @@ bounces.
169
170
  **Don't hand-move anything out of `doing/`** — a build owns it. If you need to
170
171
  stop a build, that's `ab` (or a human), not `mv`.
171
172
 
172
- When a conversation queues work by moving it into `ready/` (or the configured
173
- ready state of any source), the agent that queued it becomes its operator agent by
174
- default, as the `ab-spec` skill describes under "After filing": load the
175
- `ab-operate` skill and shepherd those builds to completion unless the human
176
- says they will operate them, hands them to another agent, or the session
177
- cannot keep a long-running watch.
173
+ Before moving work into `ready/` (or any source's configured ready state),
174
+ check `ab repository status --json` for live `operator.registrations`. If an
175
+ operator is present, preserve intent, rejected alternatives and out-of-scope
176
+ reasons in the ticket body, file, tell the human the existing operator will
177
+ pick it up, and stop without a watch. Otherwise load `ab-operate` and take the
178
+ role for the builds the repository's dispatcher dispatches. Explicit human
179
+ instructions override these defaults; non-ready filing needs no watch. See
180
+ [After filing](../ab-spec/SKILL.md#after-filing-check-operator-presence).
178
181
 
179
182
  ## Icebox
180
183
 
@@ -6,7 +6,7 @@ baseBranch = "main"
6
6
  capacity = 4
7
7
 
8
8
  # First matching rule wins. Empty rules: leaves auto, nodes consent.
9
- landing = []
9
+ merge = []
10
10
 
11
11
  # Commands are derived by the setup agent from this repository's actual toolchain.
12
12
  [commands]
@@ -4,8 +4,8 @@
4
4
  "build": "ab-hosted-service-build"
5
5
  },
6
6
  "dependencies": {
7
- "@defrex/autobuild-hosted-store-service": "1.0.1",
8
- "@defrex/autobuild": "1.0.1",
7
+ "@defrex/autobuild-hosted-store-service": "1.2.0",
8
+ "@defrex/autobuild": "1.2.0",
9
9
  "next": "16.1.6",
10
10
  "react": "19.2.4",
11
11
  "react-dom": "19.2.4"
@@ -1,178 +0,0 @@
1
- # Hosted dispatcher cutover validation — AUT-320
2
-
3
- - **Validation run:** 2026-09-11, window 19:06:24Z – 19:41:52Z; verification re-derived from fresh Store snapshots at 22:41Z and again at 23:29Z after the implement phase re-ran in a fresh workspace (the durable log below is live and keeps accumulating)
4
- - **Build:** `validate-hosted-dispatcher` on `https://autobuild.defrex.com` (durable event log: `GET /builds/validate-hosted-dispatcher/events` or the web dashboard)
5
- - **Branch:** `ab/validate-hosted-dispatcher` (PR publication requested with auto-merge; publication and merge happen after the implement session — the build slug carries the final merged state)
6
- - **Tickets:** [AUT-320](https://linear.app/issue/AUT-320) (this validation), [AUT-304](https://linear.app/issue/AUT-304) (acceptance evidence attached to its body)
7
- - **Method note:** all numbers below were re-derived from fresh Store snapshots at implement time, at the guidance round (repository journal seq 1–926, build event log seq 1–45, as of 2026-09-11T22:41Z), and again at 23:29Z on the re-run implement session (journal seq 1–1117, build event log seq 1–60). Snapshots are labeled as-of; the durable event log is authoritative.
8
-
9
- ## Checklist verdicts
10
-
11
- | Checklist item | Verdict | Evidence |
12
- | --- | --- | --- |
13
- | Environment variables set | ✅ | Hosted ticks deposit `dispatcher-effective-config` artifacts (rev 50 as of 19:54:50Z) declaring workspace provider `vercel-sandbox`, env var `AI_GATEWAY_API_KEY`, AI-gateway model sessions (`vercel-ai-gateway/zai/glm-5.3-flash`, `vercel-ai-gateway/meta/muse-spark-1.3`), and runtime provisioning with preflight checks. Every hosted tick since 19:06 completes and deposits the artifact. |
14
- | Cron live | ✅ | 265 `dispatcher.run-started` events at ≈60 s median cadence from 19:06:24Z through 23:28:50Z (latest snapshot), all run ids `hosted-dispatcher-<uuid>`, all 265 ending `run-stopped outcome=normal`. |
15
- | Harvest gate off | ✅ | Last `harvest.completed` at 03:05:04Z (journal seq 59); no `harvest.*` event since. |
16
- | Local `ab-dispatch-kernel` stopped on every maintainer machine | ✅ (store-side layers + maintainer attestation with attached evidence) | Three-layer verification below. The store-side layers prove no interactive local dispatcher ever wrote to this repository and no dispatcher of any mode claimed build work in the window; the process-level residue on maintainer machines is covered by the maintainer's attestation with attached command output (see Process evidence). |
17
-
18
- ## Three-layer verification
19
-
20
- The journal alone cannot prove absence of local dispatchers: only the interactive
21
- frontend's child kernel carries a `kernelRunId`, so a headless local run
22
- (`ab dispatch --once --plain`) writes no `dispatcher.run-started`/tick events at
23
- all. The verification therefore stacks three bounded layers.
24
-
25
- ### Layer 1 — Repository journal (proves: hosted cadence live; no *interactive* local dispatcher)
26
-
27
- Journal seq 1–1117, complete from 2026-09-11T02:17:59Z (no gaps; the hosted
28
- repository store came up that morning). Re-derived 22:41Z and again 23:29Z.
29
- Findings:
30
-
31
- - 265 `dispatcher.run-started` events — **every one** with run id prefixed
32
- `hosted-dispatcher-`; zero bare-UUID (interactive local) run ids in the
33
- entire journal history.
34
- - Cadence ≈60 s median (min 11 s, max 63 s; first 19:06:24Z, last in snapshot
35
- 23:28:50Z); 265/265 `run-stopped` with `outcome=normal`.
36
- - The only two `dispatcher.tick-yielded` events (seq 144, 19:25:50Z; seq 1111,
37
- 23:27:52Z) are both hosted→hosted (run/holder ids all `hosted-dispatcher-*`).
38
- - No `harvest.*` event after 03:05:04Z (none after the window opened).
39
- - Zero journal events mention any maintainer hostname (`aron-desktop` does not
40
- appear anywhere in the journal).
41
-
42
- **Bound:** proves nothing about headless local dispatchers, which never write
43
- journal events.
44
-
45
- ### Layer 2 — Build-scoped execution facts (proves: no dispatcher of *any* mode claimed work in the window)
46
-
47
- A dispatcher that actually claims and works a build writes build-scoped facts
48
- regardless of interactive/headless mode: `workspace.provision-started` and,
49
- decisively, `execution.started` whose `instance` is
50
- `${hostname()}-${slug}-inst_<id>` — a plain store append, never gated on
51
- `kernelRunId`. The hosted deployment stamps the Vercel function's hostname
52
- (link-local `169.254.x.x` form); a maintainer machine's dispatcher would stamp
53
- its own hostname.
54
-
55
- - Build census (store `GET /builds`): the only build created after the window
56
- opened is `validate-hosted-dispatcher` (19:06:33Z); no older build was
57
- updated during the window (re-derived 22:41Z and again 23:29Z).
58
- - This build's `execution.started` events both stamp hosted instances:
59
- seq 21 (19:26:06Z, generation 0)
60
- `instance=169.254.67.163-validate-hosted-dispatcher-inst_e031dd81`,
61
- `provider=vercel-sandbox`, `sessionId=sbx_d4pBpd0TAJQyKxBW0setr3e8F7sE`;
62
- seq 56 (23:28:09Z, generation 1)
63
- `instance=169.254.30.93-validate-hosted-dispatcher-inst_d69843ce` —
64
- the hosted host component in both cases.
65
- - Zero `execution.started` events with a foreign hostname in the window;
66
- zero `workspace.provision-started` events anywhere in the store's builds
67
- outside this build during the window.
68
-
69
- **Bound:** an idle local dispatcher that claims nothing still leaves no trace;
70
- that residue is covered by Layer 3.
71
-
72
- **Recovery-fact caveat (recorded for honesty):** `infrastructure.failed`
73
- recovery facts carry the fixed instance name `dispatcher-recovery` and are
74
- attributed to the supervising (hosted) tick, so they are bounded by the hosted
75
- tick cadence rather than their own instance string. This build's three
76
- `infrastructure.failed` events are all provision failures of the incident
77
- below.
78
-
79
- ### Layer 3 — Maintainer-machine process evidence (supplied by the maintainer)
80
-
81
- An idle local `ab dispatch` process that claims nothing leaves no store trace,
82
- so this layer cannot be derived from the Store. The implementer escalated
83
- (`esc_e93b2831`, raised from this build) asking the maintainer to run, on every
84
- maintainer machine during the window, `pgrep -fl "ab-dispatch-kernel|ab
85
- dispatch"` plus scheduler listings (launchd/cron/systemd user timers) and
86
- attach the output to the escalation answer. The maintainer answered with a
87
- full attestation **and attached command output**, folded into the Process
88
- evidence section below.
89
-
90
- ## Process evidence (maintainer attestation, escalation esc_e93b2831)
91
-
92
- The maintainer collected the evidence at 2026-09-11T19:49Z on **aron-desktop**
93
- — the **only** maintainer machine (Linux; there is no macOS or Windows
94
- maintainer machine, so launchd/launchctl and PowerShell checks do not apply).
95
- Summary of the attached evidence:
96
-
97
- 1. **Processes.** `pgrep -fl "ab-dispatch-kernel|ab dispatch"` found exactly
98
- two processes (1096539 `bun …/bin/ab.ts dispatch`, 1096573
99
- `bun …/bin/ab-dispatch-kernel.ts`), both started 19:39:54Z, both with
100
- working directory `/home/defrex/code/parakeeto` — a **different
101
- repository's checkout** with its own Store repository identity. They cannot
102
- claim or supervise builds for `https://github.com/defrex/autobuild`. No `ab
103
- dispatch` process with cwd `/home/defrex/code/autobuild` exists.
104
- 2. **Last local dispatcher for this repository.** A headless `ab dispatch
105
- --plain --auto-merge` (kernel run id prefix `aron-desktop-*`) exited at
106
- 18:06:13Z — its log ends "dispatcher superseded by another invocation —
107
- detaching / ab dispatch stopped" — 60 minutes **before** the validation
108
- window opened at 19:06Z. It was never restarted.
109
- 3. **User schedulers.** `crontab -l` → crontab is not installed on the machine
110
- (no user cron entries possible); `systemctl --user list-timers --all` → "0
111
- timers listed". No launchd (not macOS).
112
- 4. **Corroborating durable evidence.** Every `dispatcher.run-started` /
113
- tick / `run-stopped` fact for this repository from 19:06:24Z onward carries
114
- a `hosted-dispatcher-<uuid>` run id (first:
115
- `hosted-dispatcher-c5fa724f-fa11-4250-8dbb-3274510a2022`); no
116
- `aron-desktop-*` holder appears in the journal after 18:06Z. This build's
117
- own `execution.started` (seq 21) names instance
118
- `169.254.67.163-validate-hosted-dispatcher-inst_e031dd81` — a hosted
119
- function address, not a maintainer host.
120
-
121
- **Maintainer conclusion (verbatim intent):** no local `ab dispatch` process for
122
- this repository was running during 19:06–19:42Z, and none is running now.
123
- Recorded as maintainer attestation with the attached outputs; the store-side
124
- Layers 1–2 independently prove no dispatcher of any mode claimed or executed
125
- build work in the window.
126
-
127
- ## Provision incident (honest record)
128
-
129
- The first three provision attempts failed with
130
- `Executable not found in $PATH: "bun"` (19:06–19:15Z) — the exact symptom
131
- `docs/hosted-dispatcher.md` documents for a deployment that skipped
132
- `pack-distribution`. After `maxInfrastructureAttempts` (3) was exhausted the
133
- kernel raised escalation `esc_84b0cddf` (19:15:51Z, policy guard
134
- `infrastructure-failure-limit`); the operator answered with a bare retry at
135
- 19:24:37Z, and provisioning succeeded at 19:25:51Z on the next hosted tick.
136
- The generation-1 re-provision (23:26:54Z → 23:27:53Z, after the publication
137
- note below) succeeded with no operator intervention.
138
- **Verdict: the cutover works, with one operator intervention.** A follow-up
139
- observation was recorded for the deployment's build/pack step.
140
-
141
- ## Publication note (honest record)
142
-
143
- The implement phase requested publication at 22:43:01Z (event seq 49,
144
- `publication.requested`; auto-merge had been requested at build creation,
145
- seq 2). That first publication did not complete before the implement
146
- workspace's environment lifetime ended: `execution.ended` at 23:26:51Z
147
- (seq 51), the workspace was released, and a fresh generation-1 workspace was
148
- provisioned for the re-run implement session. The prior workspace's un-pushed
149
- commits were lost with it; store-side deposits (build artifacts, observations,
150
- the escalation answer, the AUT-304 evidence section) persisted. This session
151
- re-committed the repository deliverable (this document) and re-requests
152
- publication. Publication, verify, review, and merge happen after this
153
- session; the build slug `validate-hosted-dispatcher` carries the final state.
154
- A follow-up observation was recorded for the publication path.
155
-
156
- ## Cutover outcome (as of implement time)
157
-
158
- - Ticket moved to Todo → claimed and built by the hosted deployment alone:
159
- **confirmed** (Layers 1–2; single active build, hosted execution instances).
160
- - Published as a PR, and merged: PR publication is **requested** (auto-merge
161
- requested at build creation; publication re-requested by this session) from
162
- branch `ab/validate-hosted-dispatcher` into `main`; verify, review,
163
- publication, and merge happen after this session, and the build slug
164
- `validate-hosted-dispatcher` on the dashboard carries the final state. This
165
- document deliberately does not claim "published" or "merged".
166
-
167
- ## Evidence index
168
-
169
- - Build event log (durable, live): `https://autobuild.defrex.com` → build
170
- `validate-hosted-dispatcher` (API: `GET /builds/validate-hosted-dispatcher/events`)
171
- - Repository journal (durable, live): `GET /repos/https%3A%2F%2Fgithub.com%2Fdefrex%2Fautobuild/events`
172
- - Deposited build artifacts: `cutover-build-event-log`, `cutover-repository-journal`,
173
- `cutover-validation-report` (attached to the PR description at finalize)
174
- - Dispatcher effective config: repository artifact kind
175
- `dispatcher-effective-config`, rev 50 as of 2026-09-11T19:54:50Z
176
- - Branch: `ab/validate-hosted-dispatcher` → PR into `main` (auto-merge requested)
177
- - Tickets: [AUT-320](https://linear.app/issue/AUT-320),
178
- [AUT-304](https://linear.app/issue/AUT-304) (evidence section appended to body)
@@ -1,275 +0,0 @@
1
- # The hosted dispatcher
2
-
3
- The optional [`@defrex/autobuild-hosted-dispatcher`](../packages/hosted-dispatcher/README.md)
4
- package lets a deployment own the dispatch kernel. Installing it and mounting
5
- its route — `GET /api/dispatch`, backed by the package's
6
- `dispatcherEndpoint()` singleton — makes the hosted deployment the kernel
7
- owner. One authenticated HTTP invocation runs, for each configured
8
- repository, one bounded origin-mode dispatcher
9
- tick: the kernel claims ready tickets, provisions and launches sandboxes,
10
- observes running builds, settles publications, opens and merges PRs, and runs
11
- the janitor, exactly as a local `ab dispatch --once --repository <origin>`
12
- pass does. The schedule is what you attach to that endpoint (Vercel Cron calls
13
- it once a minute by default), so builds no longer depend on a maintainer's
14
- machine. A deployment that does not install the package serves the hosted
15
- store, ticket, operator, and web endpoints and never attempts a dispatch tick.
16
-
17
- The [minimal hosted service deployment](hosted-service.md) defaults to store-only
18
- mode and supplies no cron. The source-checkout deployment below retains the
19
- opt-in dispatcher packing and shipping pipeline.
20
-
21
- For a dispatcher running as a local user or service manager, first
22
- [connect the project](hosted-service.md#connect-a-project). Origin-mode dispatch
23
- can read the committed `[store] url` and the same user credential by origin.
24
- A deployment running under another identity needs its own project credential;
25
- `AB_TOKEN` remains the explicit CI override.
26
-
27
- ## Enabling the schedule
28
-
29
- 1. Deploy the hosted service with the dispatcher package installed and the
30
- dispatcher variables from
31
- [its README](../packages/hosted-dispatcher/README.md)
32
- — `AB_DISPATCHER_ORIGIN`, the repository set, `CRON_SECRET`, and the forge
33
- credentials the kernel needs (`GITHUB_TOKEN` or `GH_TOKEN`, plus any
34
- guest-forwarded variables such as `AI_GATEWAY_API_KEY`). A deployment
35
- serving repositories across GitHub identities configures per-repository
36
- tokens with `AB_DISPATCHER_GITHUB_TOKENS`; repositories without an
37
- override keep using the shared credential. A served repository with
38
- neither fails its tick: origin-mode dispatch requires an exported token
39
- and never falls back to the gh CLI login of whoever runs the service.
40
- 2. Schedule the route by adding a `crons` entry to the deployment's
41
- `vercel.json` and redeploying. Vercel issues a plain GET with
42
- `Authorization: Bearer <CRON_SECRET>` once per minute:
43
-
44
- ```json
45
- {
46
- "crons": [{ "path": "/api/dispatch", "schedule": "* * * * *" }]
47
- }
48
- ```
49
-
50
- 3. Verify: `curl -H "Authorization: Bearer $CRON_SECRET" https://YOUR_ORIGIN/api/dispatch`
51
- returns `200 {"ok":true,"repositories":[{"repository":"…","outcome":"ticked","runId":"hosted-dispatcher-…"}]}`.
52
- Unauthenticated or wrongly authorized calls are rejected (401) and do no
53
- work; a deployment without `CRON_SECRET` answers 403 with the endpoint
54
- disabled. One repository's failure never prevents another's tick.
55
-
56
- ## Shipping the guest distribution
57
-
58
- Every sandbox installs the Autobuild distribution the launching dispatcher
59
- runs. A local dispatcher packs it from its source checkout with `bun pm pack`;
60
- a bundled deployment has neither `bun` nor a source tree at runtime, so it
61
- must pack the archive while both exist — in its build step — and carry it into
62
- the function bundle. The script lives in the hosted store service package
63
- (`packages/hosted-store-service/package.json`), whose directory is the Next.js
64
- project directory and the deployment build's working directory:
65
-
66
- ```json
67
- { "scripts": { "deploy:build": "bun ../../packages/hosted-dispatcher/src/bin.ts pack-distribution --root . && bun ../../packages/postgres-store/src/bin.ts migrate && bun run build && bun ../../packages/hosted-dispatcher/src/ship-packed-distribution.ts && bun ../../packages/hosted-dispatcher/src/ship-provider-plugin.ts" } }
68
- ```
69
-
70
- `pack-distribution` (the `ab-hosted-dispatcher` bin) writes
71
- `.autobuild-dist/autobuild-<version>.tgz` under the
72
- distribution root (`--root DIR` overrides) — this deployment passes
73
- `--root .`, because the packer's default root is the repository's distribution
74
- root while the trace step below and the Next config's
75
- `outputFileTracingIncludes: { '/api/dispatch': ['./.autobuild-dist/**'] }`
76
- resolve against the deployment build's working directory, where the archive
77
- must land beside the built output. The Next.js config's
78
- `outputFileTracingIncludes` records the intent to include that directory in the cron route's bundle, but
79
- Next 16's default Turbopack builds never apply `outputFileTracingIncludes`
80
- (only webpack builds do), so a deployment cannot rely on the config alone. The
81
- autobuild-api pipeline therefore ends `deploy:build` with a post-build trace
82
- step (`bun ../../packages/hosted-dispatcher/src/ship-packed-distribution.ts`) that appends the archive to the
83
- dispatch route's `route.js.nft.json` — the trace file Vercel's Next builder
84
- consumes when assembling the function bundle — and fails the deploy loudly if
85
- nothing was packed or the trace file is missing. The same step appends the
86
- distribution root's `package.json`, which provisioning reads for the running
87
- version and which no import traces once the Next.js project directory sits
88
- below the repository root. A deployment using this
89
- pipeline cannot ship without the archive; deployments that skip both packing
90
- and the trace step still fail at runtime.
91
-
92
- A second post-build trace step ships the provider plugin package (AUT-517):
93
- `bun ../../packages/hosted-dispatcher/src/ship-provider-plugin.ts` locates the
94
- plugin's source through the repository root's `workspaces` tree (never through
95
- `node_modules`, so a previous run's staged directory cannot shadow the source),
96
- bundles its entrypoint with `bun build --target=bun --format=esm` into a
97
- single self-contained module (the plugin-sdk closure inlines — the
98
- deployment's repository-root `node_modules` carries no `@defrex/autobuild`
99
- either — while node builtins stay external), stages it into
100
- `<repoRoot>/node_modules/@defrex/autobuild-vercel-sandbox/` (replacing the
101
- workspace symlink a local `bun install` leaves there — or a previous run's
102
- staged directory, which `bun install` does not relink; the deployment never
103
- runs `bun install` again), and appends the staged files to the dispatch
104
- route's trace at the same repository-root depth as the existing
105
- `node_modules/.bun/**` entries. A bare plugin specifier resolves only
106
- through a `node_modules/` path, and the compiled dispatcher's
107
- `distributionRoot()` is the repository root, so only this staging makes
108
- `plugins = ["@defrex/autobuild-vercel-sandbox"]` loadable inside the
109
- deployed function. The step is idempotent across runs — including in a
110
- fresh process after an earlier run consumed the workspace link — and fails
111
- the deploy loudly when the package, its entrypoint, or the trace file is
112
- missing. The npm published package remains the real `src` — only the
113
- deployment stages the bundle.
114
-
115
- What the staged directory does afterwards depends on the build environment.
116
- Inside a Vercel deployment build (which always sets `VERCEL`, including a
117
- local `vercel build` run) the staged directory stays: the deployment never
118
- runs `bun install` again and the function bundle's runtime resolution needs
119
- it — a deployment building outside Vercel must set `VERCEL=1` in its build
120
- environment to keep the staged bundle. A plain local `bun run deploy:build`
121
- (no `VERCEL` environment) removes the staged directory afterwards and
122
- restores the workspace symlink, so a local run leaves the checkout exactly
123
- as `bun install` had it and local test runs keep resolving the workspace
124
- source (the capability parity test's reference equality holds). On checkouts
125
- of older versions the staged directory stayed behind and survived `bun
126
- install` — it reports "no changes" because the staged package satisfies the
127
- manifest — so later local runs resolved the plugin to the self-contained
128
- bundle and the parity test failed on its reference-equality assertion; the
129
- recovery is `rm -rf node_modules/@defrex/autobuild-vercel-sandbox && bun
130
- install`, or simply re-run `deploy:build` locally on a version with this
131
- fix, which restores the symlink itself.
132
-
133
- At runtime the kernel takes, in order: `AB_DISTRIBUTION_ARCHIVE` (an explicit
134
- archive path), the single archive under `.autobuild-dist/` of the
135
- distribution root or working directory, a source checkout packed on the spot,
136
- and finally the running version's published distribution — the npm registry
137
- tarball, else the GitHub release asset. A tick that
138
- reports `Executable not found in $PATH: "bun"` during `provision` is a
139
- deployment that skipped the pack step (or, outside this pipeline, the trace
140
- step that ships the archive).
141
-
142
- ## Bounding the invocation
143
-
144
- The endpoint is pinned to `maxDuration = 300` seconds (Vercel Pro's default
145
- function duration). `AB_DISPATCHER_BUDGET_SECONDS` (default 240) bounds the
146
- kernel's work inside that: an already-expired budget skips the tick, a budget
147
- reached mid-drain stops awaiting running builds, and a repository whose budget
148
- no longer covers a minimum-remaining floor is answered as `skipped`. Unfinished
149
- work resumes on the next invocation: guests keep running while the supervising
150
- function detaches, and the next tick settles their completion from the Store
151
- plus provider liveness. Raise `maxDuration` and the budget **together** (e.g.
152
- `"maxDuration": 800` with a budget of 780 — the parser clamps 10–780); keep the
153
- budget at least ~20 s below the function duration so the response always
154
- returns.
155
-
156
- ## Overlap and missed ticks
157
-
158
- Invocations are serialized by the durable repository supervisor lease: a second
159
- overlapping invocation yields (it records `dispatcher.tick-yielded` naming the
160
- holder in the repository journal and performs no claims, launches, or
161
- publications), and the loser's response still answers 200. A missed or late
162
- invocation is never incorrect: a build whose guest finished while no invocation
163
- ran is settled — completion facts, lease, publication — by the next
164
- invocation's settlement stage, and a build whose sandbox timed out is recovered
165
- by the lease sweep as with any dispatcher.
166
-
167
- One provider behavior matters for that settlement: Vercel's plain command
168
- lookup reports no exit code for a command that finished while no client was
169
- waiting on it, and keeps reporting none until some client issues a wait on the
170
- command. The dispatcher's execution observation therefore issues one bounded
171
- (~5 s) wait on the recorded command whenever the lookup shows no exit: a wait
172
- that resolves proves the guest's end (with its exit code) and the build settles
173
- in that same tick, while a timed-out wait leaves the guest running — one
174
- observation never approaches the tick's operation timeout, and the next tick
175
- retries. Settlement of a guest that exited after the launching invocation
176
- detached is expected within one tick of its exit.
177
-
178
- ## Pausing during an incident
179
-
180
- - **Stop the schedule**: remove the `crons` entry (or disable the cron in the
181
- Vercel dashboard) and redeploy.
182
- - **Revoke the credential**: rotate `CRON_SECRET` — every in-flight schedule
183
- call starts answering 401.
184
- - **Soft stop**: turn repository intake OFF (operator API `PUT
185
- /operator/v1/repos/{repo}/settings/intake` with `{"enabled": false}`, or the
186
- web dashboard) — running builds finish their current phases but no new ticket
187
- is claimed. A repository-wide or per-build pause holds queued work the same
188
- way and takes effect on the next invocation.
189
-
190
- ## Observing the hosted dispatcher
191
-
192
- Every invocation is durable: tick reports
193
- (`dispatcher.tick-started`/`-completed`/`-yielded`), run boundaries
194
- (`dispatcher.run-started`/`-stopped`), and a per-minute
195
- `dispatcher-effective-config` artifact deposit all carry the
196
- `hosted-dispatcher-<uuid>` run id, so the web dashboard's repository journal
197
- and the operator API show hosted activity exactly as they show a local
198
- dispatcher. Expect the repository journal to grow by roughly one config
199
- artifact per minute per repository; the dispatcher run/config artifacts
200
- themselves are retention-bounded (see below), while the journal's events keep
201
- accumulating by design.
202
-
203
- This is true of *every* dispatcher, not only the hosted one. A local `ab
204
- dispatch` pointed at the hosted Store — a watch, an operator cron on a host,
205
- a manual one-shot — synthesizes its own `<host>-dispatch-<id>` run id and
206
- journals the same run boundaries and tick facts under it. That makes cutover
207
- verification answerable from the journal alone:
208
-
209
- - Every `dispatcher.*` event with a non-`hosted-dispatcher` run id is direct
210
- evidence that another dispatcher was writing to the hosted Store.
211
- - A journal window with no `dispatcher.*` events at all means no dispatcher
212
- ran against the Store in that window.
213
- - The launch-flag facts (`dispatcher.intake-set`,
214
- `dispatcher.auto-merge-default-set`) carry the writing invocation's run id
215
- alongside their human actor, so even those writes identify the dispatcher
216
- that performed them.
217
-
218
- ### Runtime logs
219
-
220
- Every invocation also writes to the deployment's runtime logs (Vercel's
221
- **Logs** tab, or `vercel logs`), which is where to look first when the journal
222
- shows no hosted activity at all — a rejected or misconfigured invocation never
223
- reaches the journal. Every line starts with `hosted-dispatcher <invocation id>`
224
- so one invocation's lines can be filtered together:
225
-
226
- - the request line (`GET /api/dispatch agent="vercel-cron/1.0"`) — the user
227
- agent tells a cron call apart from an operator's curl;
228
- - `rejected 401|403|405 <kind>: <reason>` at error level, with whether the
229
- authorization header was absent or present-but-wrong (never its value);
230
- - `500 configuration invalid: <error>` naming the offending variable;
231
- - `tick start repositories=N budgetSeconds=S origin=…`, then per repository
232
- `tick run=hosted-dispatcher-…`, `ticked … ms=…`, `skipped`, or
233
- `failed … : <error with stack>` at error level, then
234
- `tick complete ticked=… failed=… skipped=…` and `200 ok ms=…`;
235
- - the kernel's own report lines (the same lines `ab dispatch --plain` prints
236
- locally) prefixed `<repository> [kernel]`, warnings at error level.
237
-
238
- Secrets, forge tokens, and minted guest tokens never appear in any line.
239
-
240
- ## Artifact retention
241
-
242
- Dispatcher-generated run/config artifacts — the repository-scoped
243
- `dispatcher-effective-config` and `dispatcher-config` kinds and the
244
- build-scoped `build-runner-effective-config` kind — keep the **latest 200
245
- revisions per kind** (per repository, respectively per build). When a new
246
- revision of one of these kinds is deposited, the store prunes the older
247
- revisions past the bound at deposit time, inside the same transaction.
248
- Events and journal entries are never pruned, so historical event payloads may
249
- reference a pruned revision; the current run's snapshot is always among the
250
- newest deposits and stays retrievable, and every existing read surface
251
- (latest-by-default artifact reads, listings) works unchanged. The bound is
252
- overridable per deployment with `AB_ARTIFACT_RETENTION_MAX_REVISIONS` (a
253
- positive integer; see the store environment documentation). All other
254
- artifact kinds (build logs, `pr-description`, phase artifacts) are not
255
- subject to retention.
256
-
257
- ## Sandbox authentication
258
-
259
- Inside a Vercel Function the Sandbox SDK authenticates with the deployment's
260
- own OIDC identity: Vercel hands each invocation its token on the
261
- `x-vercel-oidc-token` request header (not as a `VERCEL_OIDC_TOKEN` environment
262
- variable), and the endpoint passes it to the kernel under that name for the
263
- duration of the tick. The tick log line reports which credential the kernel
264
- presents (`sandboxAuth=oidc-header`, `oidc-env`, `token`, or `none`); `none`
265
- means the project has OIDC federation disabled (Settings → Security). No
266
- long-lived `VERCEL_TOKEN` belongs on the service. Guests never receive a Vercel
267
- token or forge credential; they authenticate to the Store with the short-TTL
268
- stored project credential the dispatcher issues for each repository tick
269
- (`AB_DISPATCHER_TOKEN_TTL_SECONDS`, default 7 days — keep it longer than your
270
- largest `timeoutSeconds` guest lifetime). Its immutable dispatcher purpose
271
- permits raw Store and hosted tickets only, never operator controls. The service
272
- checks registration and revocation on each request. Tick return does not revoke
273
- it; spawned builds may outlive the tick. Owner-issued project credentials and
274
- the owner-only break-glass admin are documented in the
275
- [remote Store protocol](remote-store-protocol.md#7-authentication-and-project-authority).