@defrex/autobuild 1.0.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/README.md +10 -18
  2. package/SPEC.md +499 -238
  3. package/bin/ab-dispatch-generation.ts +11 -2
  4. package/docs/accounts.md +119 -0
  5. package/docs/agent-runtimes.md +4 -4
  6. package/docs/answering-blocked-builds.md +2 -2
  7. package/docs/architecture.md +262 -53
  8. package/docs/assets/headline-wide.png +0 -0
  9. package/docs/build-store.md +3 -41
  10. package/docs/builds.md +4 -4
  11. package/docs/cli.md +18 -4
  12. package/docs/configuration-overview.md +115 -4
  13. package/docs/configuration.md +488 -334
  14. package/docs/dispatcher-hosting.md +19 -34
  15. package/docs/dispatcher.md +1 -1
  16. package/docs/forges.md +5 -5
  17. package/docs/getting-started.md +2 -2
  18. package/docs/glossary.md +6 -6
  19. package/docs/intake.md +2 -0
  20. package/docs/integration-overview.md +15 -15
  21. package/docs/integration-tree.md +45 -38
  22. package/docs/integration.md +6 -6
  23. package/{skills/guide/references/landing-policy.md → docs/merge-policy.md} +40 -24
  24. package/docs/migration-1.0.md +17 -13
  25. package/docs/operating.md +41 -19
  26. package/docs/operator-api.md +180 -51
  27. package/docs/operator-surfaces.md +5 -18
  28. package/docs/overview.md +3 -3
  29. package/docs/plugin-authoring.md +21 -0
  30. package/docs/remote-store-protocol.md +242 -68
  31. package/docs/remote-ticket-protocol.md +30 -50
  32. package/docs/restacking.md +54 -15
  33. package/docs/seams.md +8 -8
  34. package/docs/setup.md +59 -119
  35. package/docs/skills.md +1 -1
  36. package/docs/spec-standard.md +6 -6
  37. package/docs/ticket-dependencies.md +7 -7
  38. package/docs/ticket-sources.md +18 -0
  39. package/docs/tickets.md +8 -2
  40. package/docs/troubleshooting.md +8 -12
  41. package/docs/upgrading.md +9 -4
  42. package/docs/verification.md +60 -14
  43. package/docs/workspaces.md +4 -4
  44. package/package.json +17 -6
  45. package/packages/core/src/accounts/chatgpt-oauth.ts +216 -0
  46. package/packages/core/src/accounts/chatgpt-state.ts +41 -0
  47. package/packages/core/src/accounts/local-credentials.ts +194 -0
  48. package/packages/core/src/accounts/local-inference.ts +106 -0
  49. package/packages/core/src/accounts/local-owner.ts +123 -0
  50. package/packages/core/src/accounts/sensitive.ts +2 -0
  51. package/packages/core/src/cli/accounts.ts +147 -0
  52. package/packages/core/src/cli/binary-direct.ts +13 -1
  53. package/packages/core/src/cli/binary-lifecycle.ts +65 -2
  54. package/packages/core/src/cli/binary.ts +3 -1
  55. package/packages/core/src/cli/build-control.ts +83 -28
  56. package/packages/core/src/cli/connect.ts +3 -3
  57. package/packages/core/src/cli/context.ts +81 -38
  58. package/packages/core/src/cli/dashboard/facts.ts +2 -1
  59. package/packages/core/src/cli/dashboard/integration-detail.ts +8 -8
  60. package/packages/core/src/cli/dashboard/integration-row.ts +40 -13
  61. package/packages/core/src/cli/dashboard/landing-display.ts +25 -0
  62. package/packages/core/src/cli/dashboard/model.ts +56 -33
  63. package/packages/core/src/cli/dashboard/poll.ts +9 -3
  64. package/packages/core/src/cli/dashboard/render.ts +59 -37
  65. package/packages/core/src/cli/dashboard/target-distance.ts +14 -0
  66. package/packages/core/src/cli/dashboard/tree.ts +3 -2
  67. package/packages/core/src/cli/dispatch-args.ts +1 -1
  68. package/packages/core/src/cli/dispatch-frontend.ts +6 -3
  69. package/packages/core/src/cli/dispatch-handoff.ts +125 -44
  70. package/packages/core/src/cli/dispatch-launch-contract.ts +187 -0
  71. package/packages/core/src/cli/dispatch-launcher.ts +54 -21
  72. package/packages/core/src/cli/dispatch-preflight.ts +6 -1
  73. package/packages/core/src/cli/dispatch.ts +106 -11
  74. package/packages/core/src/cli/env.ts +4 -0
  75. package/packages/core/src/cli/help.ts +46 -23
  76. package/packages/core/src/cli/init-readiness-remote.ts +22 -1
  77. package/packages/core/src/cli/init-readiness-shared.ts +5 -1
  78. package/packages/core/src/cli/init-validation.ts +160 -18
  79. package/packages/core/src/cli/main.ts +68 -8
  80. package/packages/core/src/cli/node-verification-provenance.ts +1 -97
  81. package/packages/core/src/cli/publication-settlement.ts +47 -21
  82. package/packages/core/src/cli/repository-status.ts +20 -9
  83. package/packages/core/src/cli/secrets.ts +173 -0
  84. package/packages/core/src/cli/status.ts +42 -5
  85. package/packages/core/src/cli/store-opening.ts +17 -2
  86. package/packages/core/src/cli/terminal.ts +22 -1
  87. package/packages/core/src/cli/terminals.ts +14 -10
  88. package/packages/core/src/cli/upgrade-agent.ts +9 -1
  89. package/packages/core/src/cli/upgrade-landing.ts +70 -30
  90. package/packages/core/src/cli/upgrade.ts +3 -1
  91. package/packages/core/src/cli/wait.ts +15 -7
  92. package/packages/core/src/cli/watch-lifetime.ts +111 -0
  93. package/packages/core/src/cli/watch.ts +635 -510
  94. package/packages/core/src/config/accounts.ts +101 -0
  95. package/packages/core/src/config/effective-artifact.fixture.ts +27 -0
  96. package/packages/core/src/config/effective-artifact.ts +13 -0
  97. package/packages/core/src/config/landing.ts +1 -1
  98. package/packages/core/src/config/live.ts +14 -1
  99. package/packages/core/src/config/load.ts +21 -1
  100. package/packages/core/src/config/pipeline-source.ts +28 -0
  101. package/packages/core/src/config/reference-metadata.ts +2 -0
  102. package/packages/core/src/config/reference.ts +22 -7
  103. package/packages/core/src/config/roles.ts +54 -3
  104. package/packages/core/src/config/schema.ts +146 -162
  105. package/packages/core/src/context-directory.ts +26 -0
  106. package/packages/core/src/distribution-packaging.ts +26 -5
  107. package/packages/core/src/events/catalog.ts +10 -2
  108. package/packages/core/src/events/compatibility.ts +2 -1
  109. package/packages/core/src/events/globs.ts +1 -1
  110. package/packages/core/src/events/payloads.ts +73 -1
  111. package/packages/core/src/events/policy.ts +7 -0
  112. package/packages/core/src/events/repository.ts +4 -4
  113. package/packages/core/src/events/sessions.ts +6 -6
  114. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +574 -0
  115. package/packages/core/src/kernel/auto-merge.ts +2 -2
  116. package/packages/core/src/kernel/engine.ts +255 -26
  117. package/packages/core/src/kernel/generators/leaf-restack-log.ts +10 -0
  118. package/packages/core/src/kernel/integration-landing.ts +3 -3
  119. package/packages/core/src/kernel/integration-state.ts +27 -4
  120. package/packages/core/src/kernel/leaf-restack-state.ts +28 -3
  121. package/packages/core/src/kernel/log-index.ts +13 -1
  122. package/packages/core/src/kernel/node-landing.ts +8 -8
  123. package/packages/core/src/kernel/node-parent.ts +2 -2
  124. package/packages/core/src/kernel/node-restack-transaction.ts +1 -1
  125. package/packages/core/src/kernel/node-verification-context.ts +216 -0
  126. package/packages/core/src/kernel/phases.ts +1 -1
  127. package/packages/core/src/kernel/plan-verify-selection.ts +16 -0
  128. package/packages/core/src/kernel/publication-retry.ts +168 -0
  129. package/packages/core/src/kernel/reconcile-restack.ts +29 -1
  130. package/packages/core/src/kernel/reducer.ts +85 -5
  131. package/packages/core/src/kernel/target-distance.ts +45 -0
  132. package/packages/core/src/kernel/terminal-guard.ts +10 -1
  133. package/packages/core/src/kernel/verify-stage-state.ts +123 -0
  134. package/packages/core/src/kernel/verify-stages.ts +39 -0
  135. package/packages/core/src/ontology.ts +1 -0
  136. package/packages/core/src/operator/annotations.ts +6 -0
  137. package/packages/core/src/operator/control.ts +1 -1
  138. package/packages/core/src/operator/index.ts +3 -7
  139. package/packages/core/src/operator/landings.ts +5 -1
  140. package/packages/core/src/operator/presentation.ts +6 -1
  141. package/packages/core/src/operator/protocol.ts +6 -0
  142. package/packages/core/src/operator/query.ts +14 -18
  143. package/packages/core/src/operator/registry.ts +39 -7
  144. package/packages/core/src/operator/sandbox-host.ts +64 -40
  145. package/packages/core/src/operator/sandbox.ts +3 -0
  146. package/packages/core/src/operator/ticket-source-backend.ts +3 -12
  147. package/packages/core/src/operator/tickets.ts +25 -4
  148. package/packages/core/src/plugins/manifest.ts +2 -1
  149. package/packages/core/src/ports/forge/contract.ts +2 -2
  150. package/packages/core/src/ports/forge/git-rewrite.ts +25 -2
  151. package/packages/core/src/ports/forge/github-readiness.ts +2 -2
  152. package/packages/core/src/ports/forge/github.ts +26 -7
  153. package/packages/core/src/ports/forge/local-git.ts +4 -4
  154. package/packages/core/src/ports/forge/readiness.ts +1 -1
  155. package/packages/core/src/ports/forge-failure.ts +24 -0
  156. package/packages/core/src/ports/runner/account-env.ts +88 -0
  157. package/packages/core/src/ports/runner/chatgpt-provider.ts +85 -0
  158. package/packages/core/src/ports/runner/claude.ts +26 -2
  159. package/packages/core/src/ports/runner/codex.ts +63 -31
  160. package/packages/core/src/ports/runner/one-shot.ts +2 -0
  161. package/packages/core/src/ports/runner/provider-error.ts +5 -0
  162. package/packages/core/src/ports/runner/routing.ts +35 -4
  163. package/packages/core/src/ports/tickets/contract.ts +58 -0
  164. package/packages/core/src/ports/tickets/tree.ts +1 -1
  165. package/packages/core/src/ports/types.ts +28 -7
  166. package/packages/core/src/ports/workspace/account-policy.ts +72 -0
  167. package/packages/core/src/ports/workspace/build-execution.ts +9 -2
  168. package/packages/core/src/ports/workspace/builtin-capabilities.ts +1 -0
  169. package/packages/core/src/ports/workspace/create.ts +2 -0
  170. package/packages/core/src/ports/workspace/git-worktree.ts +6 -1
  171. package/packages/core/src/ports/workspace/phase-scratch.ts +4 -3
  172. package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -0
  173. package/packages/core/src/ports/workspace/vercel-sandbox.ts +182 -72
  174. package/packages/core/src/processes/build-child.ts +6 -8
  175. package/packages/core/src/processes/build-execution-state.ts +8 -5
  176. package/packages/core/src/processes/build-runner.ts +554 -99
  177. package/packages/core/src/processes/dispatcher.ts +209 -101
  178. package/packages/core/src/processes/execution-no-progress.ts +8 -1
  179. package/packages/core/src/processes/execution-settlement.ts +21 -3
  180. package/packages/core/src/processes/harvest-runner.ts +68 -8
  181. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  182. package/packages/core/src/processes/publication-loss.ts +8 -2
  183. package/packages/core/src/processes/publication-state.ts +42 -4
  184. package/packages/core/src/processes/repo-view.ts +14 -0
  185. package/packages/core/src/processes/verify-cycle-config.ts +96 -0
  186. package/packages/core/src/project-secrets.ts +105 -0
  187. package/packages/core/src/{integration → scenarios}/harness.ts +330 -317
  188. package/packages/core/src/secret-name.ts +41 -0
  189. package/packages/core/src/store/account-redaction.ts +156 -0
  190. package/packages/core/src/store/adapter.ts +1 -0
  191. package/packages/core/src/store/build-scope.ts +9 -0
  192. package/packages/core/src/store/contract.ts +116 -2
  193. package/packages/core/src/store/local/schema.ts +13 -0
  194. package/packages/core/src/store/local/store.ts +42 -0
  195. package/packages/core/src/store/memory.ts +47 -0
  196. package/packages/core/src/store/operator-presence.ts +21 -0
  197. package/packages/core/src/store/phase-session.ts +10 -0
  198. package/packages/core/src/store/reducer-value-shapes.json +5185 -4156
  199. package/packages/core/src/store/remote/client.ts +89 -48
  200. package/packages/core/src/store/remote/compatibility.ts +20 -0
  201. package/packages/core/src/store/remote/protocol.ts +4 -0
  202. package/packages/core/src/store/remote/version.ts +3 -1
  203. package/packages/core/src/store/retention.ts +2 -3
  204. package/packages/core/src/store/session-handle.ts +9 -0
  205. package/packages/core/src/store/streams/session-writer.ts +1 -1
  206. package/packages/core/src/store/types.ts +12 -2
  207. package/packages/core/src/testing/dispatch-read-budget.ts +122 -0
  208. package/packages/core/src/testing/index.ts +12 -1
  209. package/packages/core/src/testing/reduced-read-budget.ts +47 -0
  210. package/packages/core/src/testing/temp-directories.ts +58 -0
  211. package/skills/code-review/SKILL.md +23 -9
  212. package/skills/finalize/SKILL.md +15 -7
  213. package/skills/guide/SKILL.md +373 -148
  214. package/skills/guide/references/accounts.md +119 -0
  215. package/skills/guide/references/integration-tree.md +45 -38
  216. package/{docs/landing-policy.md → skills/guide/references/merge-policy.md} +40 -24
  217. package/skills/guide/references/migration-1.0.md +17 -13
  218. package/skills/guide/references/operator-api.md +180 -51
  219. package/skills/guide/references/plugin-authoring.md +21 -0
  220. package/skills/guide/references/remote-store-protocol.md +242 -68
  221. package/skills/guide/references/remote-ticket-protocol.md +30 -50
  222. package/skills/guide/references/restacking.md +54 -15
  223. package/skills/guide/references/setup.md +59 -119
  224. package/skills/guide/references/spec-standard.md +6 -6
  225. package/skills/guide/references/ticket-dependencies.md +7 -7
  226. package/skills/harvest/SKILL.md +3 -1
  227. package/skills/harvest-review/SKILL.md +3 -1
  228. package/skills/implement/SKILL.md +43 -17
  229. package/skills/operate/SKILL.md +118 -118
  230. package/skills/plan/SKILL.md +39 -13
  231. package/skills/plan-review/SKILL.md +15 -10
  232. package/skills/reconcile/SKILL.md +22 -3
  233. package/skills/spec/SKILL.md +20 -20
  234. package/skills/tickets/SKILL.md +12 -9
  235. package/templates/autobuild.toml +1 -1
  236. package/templates/hosted-service/package.json +2 -2
  237. package/docs/hosted-dispatcher-cutover-validation.md +0 -178
  238. package/docs/hosted-dispatcher.md +0 -275
  239. package/docs/hosted-service.md +0 -293
  240. package/docs/mcp.md +0 -149
  241. package/packages/core/src/orchestrator/approvals.ts +0 -115
  242. package/packages/core/src/orchestrator/conversation.ts +0 -167
  243. package/packages/core/src/orchestrator/model.ts +0 -86
  244. package/packages/core/src/orchestrator/prompt.ts +0 -63
  245. package/packages/core/src/orchestrator/tools.ts +0 -117
  246. package/packages/core/src/orchestrator/turn-runner.ts +0 -457
  247. package/packages/core/src/processes/orchestrator-tick.ts +0 -360
@@ -1,9 +1,10 @@
1
1
  # Operator API v1
2
2
 
3
- The hosted service exposes the polling-oriented operator surface at
4
- `/operator/v1/repos/{repo}`. It is versioned with remote store protocol **4**.
3
+ A conforming hosted instance implements this normative polling-oriented operator
4
+ contract at
5
+ `/operator/v1/repos/{repo}`. It is versioned with remote store protocol **6**.
5
6
  Every request must send `X-Autobuild-Version`,
6
- `X-Autobuild-Protocol-Version: 3`, and `Authorization: Bearer …`. Identity is
7
+ `X-Autobuild-Protocol-Version: 6`, and `Authorization: Bearer …`. Identity is
7
8
  checked before authentication or resource lookup.
8
9
 
9
10
  Project credentials are opaque `abp_1_<id>_<secret>` bearer values bound to one
@@ -14,29 +15,26 @@ every request. Revocation takes effect on the next request without affecting
14
15
  other credentials. Unknown, expired or revoked credentials receive `401 auth`;
15
16
  removed projects receive `403 auth` with `project not registered`.
16
17
 
17
- The deployment owner runs these commands locally with database access:
18
-
19
- ```sh
20
- ab-hosted-store credentials issue https://github.com/acme/app --user owner@example.com
21
- ab-hosted-store credentials list https://github.com/acme/app
22
- ab-hosted-store credentials revoke https://github.com/acme/app --id ID --user owner@example.com
23
- ```
24
-
25
- Issue prints the secret once; list contains metadata only. Issue optionally
26
- accepts `--ttl-seconds N` or `--expires-at ISO-8601`. For administrative/non-interactive issuance, set the returned token as
27
- `AB_TOKEN`. Interactive project onboarding uses `ab connect <service-url>`;
28
- it saves the credential outside the repository and commits no secret. Previous `AB_TOKEN` values and `mint operator` / `mint build` are
29
- retired: the service responds that the credential format changed and points
30
- to `credentials issue`. Supported old protocol shapes still work with a new
31
- credential; protocol compatibility does not restore retired authentication.
32
-
33
- `mint admin --ttl-seconds N` creates an explicit versioned, attributed owner
34
- break-glass credential. It can cross project boundaries. Keep it owner-only:
35
- never give it or `AB_STORE_SECRET` to a dispatcher or build agent.
18
+ The hosted cron dispatcher issues a dispatcher-purpose credential per repository
19
+ tick, then deletes that exact row on completion or failure. Its crash-safety
20
+ expiry is capped at the invocation deadline plus 60 seconds and the configured
21
+ `AB_DISPATCHER_TOKEN_TTL_SECONDS` upper bound. Each served tick removes at most
22
+ 100 expired or revoked dispatcher rows through indexed probes. Legacy unexpired
23
+ rows keep their recorded expiry and are pruned afterward. Owner lifetimes are
24
+ unchanged. Build and harvest grants are independent signed authority, governed
25
+ by durable lifecycle facts and the existing evidence grace, not parent credential
26
+ storage or TTL; agents never receive the cron credential.
27
+
28
+ Obtain a project credential with `ab connect <instance-url>` or from the
29
+ instance, and use `AB_TOKEN` on non-interactive clients. Interactive connection
30
+ saves the credential outside the repository. Retired credential formats are
31
+ refused with a credential-format-changed diagnostic; supported old protocol
32
+ shapes still require current credentials. Compatibility does not restore retired
33
+ authentication. Versioned, attributed owner-admin credentials are an explicit
34
+ cross-project exception and must never be supplied to build agents.
36
35
 
37
36
  Owner-purpose project credentials attribute every write to their recorded creator.
38
- Dispatcher-purpose credentials are refused. Signed-in owners in the dashboard
39
- and MCP receive short-lived internal signatures with an explicit version,
37
+ Dispatcher-purpose credentials are refused. Internal operator credentials use short-lived internal signatures with an explicit version,
40
38
  selected repository, signed user, expiry and MCP `via`. Only the service holds
41
39
  the signing key. These signatures authorize operator routes only and require a
42
40
  registered project; replay against another project is refused.
@@ -46,13 +44,12 @@ tool execution. Body repositories and secondary build/session identifiers are
46
44
  also checked inside that project. Explicit project mismatches return `403 auth:
47
45
  wrong project`; removal returns `403 auth: project not registered`. Encode each
48
46
  repository, build, session and artifact kind as a separate URL path segment.
49
- Registration changes use the database-local `projects list|add|remove` owner
50
- commands; see [owner workflow](setup.md#connected-projects).
47
+ Registration is instance-owned; project credentials cannot administer it.
51
48
 
52
49
  ## Operator sessions
53
50
 
54
51
  Operator sessions are the signed-in user's durable orchestrator
55
- conversations: a hosted-only third store resource. A session
52
+ conversations: a third store resource. A session
56
53
  belongs to the user who created it; other members of the same repository
57
54
  can read it and cannot write to it (`403 auth` on non-owner writes). Every
58
55
  write is attributed to the token's signed user — never a client-supplied
@@ -73,8 +70,13 @@ archived status is terminal.
73
70
 
74
71
  Session state is a reduction of the session's event log, never a stored
75
72
  column; a `GET …/sessions/{sid}` response therefore always reflects the
76
- session's full history. The API never exposes raw session-event append: the
77
- turn runner (a later ticket) is the only producer of turn facts.
73
+ session's full history. Message, explicit wake and approval writes return
74
+ `{ok:true}` without turn or stream ids. They record facts only: the service
75
+ never starts or resumes an agent, executes an approved call, or reaps a turn.
76
+ New sessions have no inherited wake settings. Historical turn events and
77
+ streams remain readable; an approval answer clears the matching pending
78
+ approval without changing its suspended turn or stream. The API never exposes
79
+ raw session-event append. External operator harnesses own agent execution.
78
80
 
79
81
  ## Reads
80
82
 
@@ -86,7 +88,7 @@ turn runner (a later ticket) is the only producer of turn facts.
86
88
  | `GET …/status` | Repository intake, pause, and default-auto-merge projection. |
87
89
  | `GET …/harvest/status` | Harvest gate, runs, steps, recovery, and attention projection. |
88
90
  | `GET …/builds/{slug}/artifacts/{kind}?rev=N` | Raw bytes (`application/octet-stream`) plus content-disposition and `X-Autobuild-Artifact-*` metadata headers. Omit `rev` for latest. |
89
- | `GET …/tickets?state=S&label=L` | `{states,tickets,diagnostics,criteria,triageState,readyState}`. The two lifecycle names come from effective repository configuration (including provider fallback). With no `state`, `criteria.state` is `triageState`; repeated `label` parameters narrow that state with AND filters. An explicit `state` selects that exact backend workflow state. |
91
+ | `GET …/tickets?state=S&label=L&limit=N&offset=K&order=O` | `{states,tickets,diagnostics,criteria,triageState,readyState,doneState,total}`. The three lifecycle names come from effective repository configuration (including provider fallback). With no `state`, `criteria.state` is `triageState`; repeated `label` parameters narrow that state with AND filters. An explicit `state` selects that exact backend workflow state. `limit` (0–200) returns one page, after skipping `offset`, in `order` `oldest` (the source order, the default) or `newest`; `total` counts every match before paging. |
90
92
  | `GET …/tickets/states` | Full state metadata `{name,tickets,about?}[]`, including empty states (`tickets.states` in MCP). |
91
93
  | `GET …/tickets/{id}` | `{ticket,blockers,build}`. Blockers include native `exists`/`resolved` status; `build` prefers an active matching repository build, otherwise the most recently updated one. |
92
94
 
@@ -99,11 +101,13 @@ Dashboard reads use the latest durable, run-correlated `effectiveConfig`
99
101
  repository artifact. Missing, corrupt, or invalid configuration returns a typed
100
102
  `409 effective-config-unavailable`; the service never guesses from a checkout.
101
103
  Clients poll these reads — the operator HTTP API exposes no push or long-poll
102
- event transport. Streaming is provided as a CLI read surface: `ab watch`
104
+ event transport. Streaming is provided by `ab watch`; unflagged watches are read-only.
105
+ Only CLI `--operator` watches write advisory liveness, never events or authority;
106
+ MCP presence registration is deferred. `ab watch`
103
107
  streams build and repository events by polling the same event logs client-side
104
108
  (the store protocol's `GET /builds/{slug}/events` and `GET /repos/{repo}/events`
105
109
  reads), not as a transport on this API. `triageState`, `readyState`,
106
- and every entry in `states` are backend state names and must be sent back verbatim
110
+ `doneState`, and every entry in `states` are backend state names and must be sent back verbatim
107
111
  when used with the move control.
108
112
 
109
113
  ## Controls
@@ -141,7 +145,7 @@ The retry object is deliberately bare: adding `text` is a `400 validation`
141
145
  rather than silently changing the resolution to guidance. A revision object may
142
146
  also carry `ceiling` only to receive the shared `incompatible-answer-options`
143
147
  refusal; a ceiling and spec revision cannot be performed together.
144
- The hosted service has no ticket-provider credentials. For ticket-origin
148
+ The protocol does not supply ticket-provider credentials. For ticket-origin
145
149
  revision, a trusted caller fetches the current ticket body and supplies it; the
146
150
  build must still have a recorded ticket. Revision conformance, lazy retry,
147
151
  artifact metadata, event ordering, and refusal rules are the same as the CLI.
@@ -156,10 +160,10 @@ Each kernel `spec.revised` records the exact artifact and operator identity
156
160
  Ticket-origin revisions re-pin assets; supplied bodies preserve asset pins.
157
161
  The node recollects and verifies the new revision, including on the same head
158
162
  and parent after a failed cycle. Earlier cycles remain historical evidence
159
- and cannot block or authorize landing under the replacement. Children keep
163
+ and cannot block or authorize merge under the replacement. Children keep
160
164
  their specs, claims and targets; contributions are not restarted.
161
165
  Active verification/reconcile or writer work, restack/reparent work, pause,
162
- pending controls, landing intent and ended PRs refuse the no-escalation path.
166
+ pending controls, merge intent and ended PRs refuse the no-escalation path.
163
167
  A concurrent state change refuses publication with a retry explanation;
164
168
  uncited artifacts are inert. Leaves still require an open escalation and
165
169
  restart from `plan`.
@@ -167,8 +171,7 @@ restart from `plan`.
167
171
  ## The registry's protocol face: `POST …/tools/{tool}`
168
172
 
169
173
  One generic route executes any entry of the agent tool registry (the same
170
- closed table `ab mcp` serves over stdio and the hosted `/mcp` endpoint serves
171
- over Streamable HTTP): the body is the tool's validated input — `repo`
174
+ closed table `ab mcp` serves over stdio): the body is the tool's validated input — `repo`
172
175
  included and required to equal the URL's repository — and the response is the
173
176
  registry result verbatim. The verified operator token supplies the acting
174
177
  identity and, when minted with one, the `via` attribution marker; the body
@@ -215,19 +218,16 @@ progress and unattempted builds. Unexpected failures are `500 internal`.
215
218
 
216
219
  ## Browser gateway
217
220
 
218
- The same deployment serves the web dashboard through `/api/web/repos/{repo}/…`.
221
+ The cookie-authenticated gateway contract uses `/api/web/repos/{repo}/…`.
219
222
  That route is not a second public bearer-token API: it requires a current
220
- Better Auth HTTP-only cookie, rechecks the deployment email and repository
221
- allowlists, rejects cross-origin JSON controls, and delegates only the dashboard,
223
+ Better Auth HTTP-only cookie, rechecks the instance’s current organization membership and project registration, rejects cross-origin JSON controls, and delegates only the dashboard,
222
224
  build, settings, and harvest operator suffixes listed above. It replaces caller-supplied authorization/version
223
225
  headers with a server-minted token that expires after 30 seconds and carries
224
226
  the normalized signed-in email. Consequently every durable control event has
225
227
  the browser user's human actor while no token or signing secret reaches client
226
- code. Responses are private/no-store; a 401 sends the application back to sign
227
- in. Browser clients poll the visible dashboard every two seconds; the browser
228
- surface offers no streaming of its own — live transcript streaming remains
229
- absent here, and the streaming read surface is the CLI's `ab watch`, which
230
- polls the store's event reads client-side. Delegated bearer tokens remain
228
+ code. Responses are private/no-store; 401 requires reauthentication.
229
+ Polling clients may use a two-second interval. The gateway provides no
230
+ streaming transport; `ab watch` polls store event reads client-side. Delegated bearer tokens remain
231
231
  server-side.
232
232
 
233
233
  The API does not expose phase-session commands, runner startup, a push or
@@ -246,7 +246,10 @@ invocation hides the holder start or the latest stop. Other state reads retain
246
246
  their bounded semantics.
247
247
 
248
248
  Repository-following `ab watch` additionally emits a read-only `dispatcher.lost`
249
- observation when an observed lease expires without a matching stop. JSON carries
249
+ observation when an observed lease expires without a matching stop or validated
250
+ successor takeover. A completed ownership transfer suppresses predecessor loss
251
+ even while its sessions drain; a handoff without takeover still reports loss on
252
+ expiry. Successor loss and upgrade-failure/rollback attention remain independent. JSON carries
250
253
  `observation` instead of `event`, with run, observedAt, leaseExpiresAt and available
251
254
  identity, plus the usual repo/build/state/cursor fields. It invents no durable
252
255
  sequence or actor. Retain the cursor to avoid repeat reports across invocations.
@@ -264,7 +267,7 @@ The default watch reports actionable conditions only:
264
267
 
265
268
  - Build `escalation.raised`, `integration.landed`, `node.item-conflicted`, or
266
269
  conflicted `restack.replayed` events. `build.consent-ready` is the single
267
- signal for a ready consent or held landing, including first repository-wide
270
+ signal for a ready consent or held merge, including first repository-wide
268
271
  discovery. Its target has the queue entry shape `{kind, branch, ticket?, build?}`.
269
272
  Unready and stale candidates stay silent. `build.merge-decision` remains for
270
273
  current actionable merge-gate deferrals and unsafe forge outcomes, once per
@@ -309,7 +312,7 @@ learn their outcomes from status reconciliation at exit.
309
312
 
310
313
  `ab wait --for attention` is build-only and uses the same build conditions:
311
314
  current failed node verification, an open escalation, janitor failure attention,
312
- consent readiness, landing/conflict attention or a merge decision. Current failed
315
+ consent readiness, merge/conflict attention or a merge decision. Current failed
313
316
  verification satisfies attention even before its notification is written. Existing conditions return immediately,
314
317
  even with `--since`; live and backlog matches ignore routine outcomes and
315
318
  self-healing failures. A merge match uses the watch observation with
@@ -326,9 +329,9 @@ Metadata-only patches are accepted. Target validation and demotion guards apply
326
329
  to CLI, HTTP and MCP alike; unsupported sources refuse even explicit defaults
327
330
  or clears before changing other fields. Dispatch routing is unchanged.
328
331
 
329
- Landing controls use `land` and `hold` with acknowledged durable state. Land
330
- requires readiness and survives restacks; hold persists until land. Repository
331
- auto-merge settings are retired; configure ordered `[[landing]]` rules.
332
+ HTTP merge controls retain the wire actions `land` and `hold` with acknowledged durable state. Merge
333
+ requires readiness and survives restacks; hold persists until merge. Repository
334
+ auto-merge settings are retired; configure ordered `[[merge]]` rules.
332
335
 
333
336
  Default attention includes `build.janitor-failing` and
334
337
  `dispatcher.forge-persistent`. Raw `dispatcher.forge-degraded` and
@@ -373,3 +376,129 @@ repository attention. `dispatcher.rollback-hold-cleared` records a different
373
376
  successfully resolved target. The rollback hold survives store compatibility
374
377
  changes, resolution errors and upgrade opt-out; a new operator-launch lineage
375
378
  ignores old holds. Preflight failure suppression above remains separate.
379
+
380
+
381
+ ## Organization management (browser)
382
+
383
+ These same-origin cookie-session routes are the management contract. Mutations
384
+ require the exact configured instance origin as Origin and `application/json`, accept at most
385
+ 8192 characters of JSON, and reject unsupported fields. Responses are private,
386
+ no-store. No client-supplied actor or role is trusted. Raw Better Auth
387
+ `/api/auth/organization/*` routes are disabled, including invitations.
388
+
389
+ ### Discovery and creation
390
+
391
+ `GET /api/web/orgs` returns
392
+ `{isSuperUser,organizations:[{id,name,slug,ownerEmail,membershipRole}]}`.
393
+ Every admitted operator can discover their own organizations. Super users see
394
+ all organizations; their membershipRole is null where they are not members.
395
+ Roles are `owner` and `member`; ownerEmail is null for an ownerless organization.
396
+ Results sort by slug then ID. Members may inspect and read rosters in their own
397
+ organizations, including member emails. Foreign organizations return 403 before
398
+ resource detail. A multi-org member uses these IDs for explicit connect selection.
399
+
400
+ Only super users may POST `{name,slug}` to `/api/web/orgs`.
401
+ The response is 201 `{organization}` in the discovery shape. Names are nonblank
402
+ and at most 100 characters; slugs are unique lowercase kebab strings of at most
403
+ 100 characters. Creation grants no membership.
404
+
405
+ Super users and the organization’s members can GET `/api/web/orgs/:orgId` for
406
+ `{organization,projects:[repo]}` with active owned projects and the caller’s actual
407
+ membershipRole. Only super users can GET `/api/web/projects/unassigned` for `{projects:[repo]}`. The latter
408
+ contains every active registered project without an assignment, including legacy
409
+ registrations; removed entries are excluded. Projects sort lexically.
410
+
411
+ ### Members and owner
412
+
413
+ Super users and the organization's members can GET
414
+ `/api/web/orgs/:orgId/members` for `{members:[{email,role,name,status}]}`.
415
+ `name` is a known persisted identity name or null; `status` is `joined` when a
416
+ normalized-email auth identity exists, otherwise `pending`. Grants are the roster
417
+ source; identities enrich them without duplicating rows. An existing identity
418
+ added to another organization is joined immediately.
419
+ Only super users and owners may POST `{email}` to that path for `{member}` or
420
+ DELETE `{email}` for `{removed:true}`.
421
+ Emails normalize before matching, grants work before first sign-in, and duplicate
422
+ adds preserve the existing role. An owner cannot remove themselves. Ordinary
423
+ members can read their own rosters but cannot mutate membership.
424
+
425
+ Only super users can PUT `{email:string|null}` to
426
+ `/api/web/orgs/:orgId/owner`, returning `{organization}`. A non-null owner must
427
+ already be a member. Transfer demotes the previous owner; null clears ownership.
428
+ Removing an owner as a super user also clears ownership. An org can have no owner.
429
+
430
+ ### Project assignment and errors
431
+
432
+ Only super users can PUT `{repo}` to `/api/web/orgs/:orgId/projects`, returning
433
+ `{repo,organizationId}`. The repo must be actively registered. This atomically
434
+ assigns or moves it. Registry removal retains assignment and history, but hides
435
+ the inactive project; re-registration restores that assignment.
436
+
437
+ Status codes are 401 for absent, malformed or expired sessions; 403 for admission
438
+ or role refusal; 400 for invalid inputs; 404 for missing resources after role
439
+ checks; 409 for duplicate slugs; and sanitized 503 for store outages. Foreign
440
+ projects return the same unknown-repository result as absent projects. Machine credentials retain their separate authority.
441
+
442
+
443
+ ### Permanent project deletion
444
+
445
+ Super users and the owner of a project's organization can delete it from the
446
+ Projects page. Owners see only projects in organizations they own; Move and
447
+ Assign remain super-user operations. The shared confirmation dialog names the project,
448
+ shows current build, hosted ticket, secret and subscription-account counts, and
449
+ requires a second, destructive action. Local files and configuration are unaffected.
450
+
451
+ Authenticated human sessions can use `GET /api/web/projects/deletion?repo=<encoded repository>`
452
+ for the authorized preview. It returns `repo`, an opaque `token`, `builds`,
453
+ `tickets`, `secrets`, and `subscriptionAccounts`. Send that token unchanged in
454
+ `If-Match` to `DELETE /api/web/projects/deletion`, with exactly `{repo}` as JSON.
455
+ The write requires the configured same origin. Missing tokens return 428;
456
+ a token for another live generation returns 412 without changing anything.
457
+ A token for an already-deleted generation is an idempotent no-op, including after
458
+ reconnection, for the initiating actor or a super user. Success returns
459
+ `{deleted:true}` only after cleanup completes. Unauthorized callers receive no counts.
460
+
461
+ Deletion cuts off access before purging builds, events, sessions, streams,
462
+ artifacts, hosted tickets and assets, secrets, subscription accounts, credentials,
463
+ connections, presence and organization assignment. Blobs another project references
464
+ or reserves survive. The only retained project record contains the repository,
465
+ initiating actor, deletion time and one opaque generation id. Provider failure
466
+ leaves access refused and durable cleanup pending. The Projects page lists
467
+ unfinished deletions with a **Finish deletion…** action, including after reloading,
468
+ opening another tab or restarting the service. Reopen its confirmation dialog to
469
+ retry cleanup with the original operation's preview token, even though the live
470
+ generation was invalidated at the initial purge. A pending preview returns that
471
+ same original token. Deletion waits only for mutation transactions already holding
472
+ the project generation row, never for an entire HTTP request. Subsequent mutation
473
+ transactions in an admitted request fail with `403 project not registered` and
474
+ roll back; operations committed before the purge remain permissible.
475
+ Cancel only closes the confirmation and does not undo the cutoff.
476
+ `GET /api/web/projects/deletions` returns `{projects: string[]}` for pending
477
+ cleanup authorized to the current owner or super user, including unassigned
478
+ projects for super users. Members and outsiders receive no pending project names.
479
+ This management-only list does not restore projects to builds selectors or normal
480
+ organization discovery. Cleanup commits progress in batches of at most 32 blobs,
481
+ using provider batch deletion where supported; a failed batch remains retryable. Registration is blocked until cleanup
482
+ finishes. Legacy untraceable orphan blobs with no ownership record or retained
483
+ project reference are excluded from deletion.
484
+
485
+ Old credentials return `401` as unknown or revoked, including repository-free
486
+ connection status calls; routes that otherwise establish the repository return
487
+ `403 project not registered`. No credential tombstones are retained. Browser
488
+ approval of a fresh `ab connect` registers an empty project; proposing a connection
489
+ alone does not register it. Old credentials and grants remain invalid. Hosted
490
+ ticket numbering starts again at 1.
491
+
492
+ `ab disconnect` only revokes the saved credential and retains project data.
493
+ The admin `projects remove` command only unregisters access and retains data;
494
+ it is a separate operation from permanent web project deletion.
495
+
496
+
497
+ S3 cleanup requires `s3:DeleteObject`, `s3:ListBucketVersions` and
498
+ `s3:DeleteObjectVersion` for the configured bucket and exact prefixed content
499
+ keys. It removes stored versions and delete markers as well as current objects;
500
+ permission or retention failures leave deletion pending. Vercel Blob cleanup uses
501
+ the same store identity, token and prefixed pathname as uploads. Missing objects
502
+ are successful cleanup; provider errors never count as completed deletion.
503
+
504
+ Paged ticket listings use the source's optional native `listPage(criteria, page)` capability when present, otherwise read the full listing and reverse/slice it. Native errors propagate. PostgreSQL counts matches without bodies and reads only the requested window. Zero limits and offsets past the end still report the full matching total. Unpaged listings remain exhaustive; the wire payload is the same for both paths.
@@ -139,6 +139,7 @@ A plugin relying on a capability declares an `apiVersion` range containing its v
139
139
  - **1.5** `path` is the path in the workspace environment; set optional `localPath` only when the dispatcher can reach that same copy directly. Workspace-owned executors receive the durable provider locator as `BuildExecutionStart.workspaceRef`; local PID supervision stays host-owned.
140
140
  - **1.7** Workspace factory seams.
141
141
  - **1.8** Forge failure classification and request observers.
142
+ - **1.9** Optional native ticket-source paging (`listPage`); older sources retain operator slicing.
142
143
 
143
144
  ## 2. Create a repository-local module
144
145
 
@@ -424,3 +425,23 @@ An adapter opts in with `integrationTree: true` and must:
424
425
  - expose kind and target in revisions
425
426
 
426
427
  Don't opt in unless the source preserves these semantics. Legacy sources get ordinary CRUD; the compatibility facade refuses metadata writes before legacy methods run, and unsupported sources should also refuse metadata at their own write boundary.
428
+
429
+ ## Optional ticket paging capability
430
+
431
+ Native paging is an optional API 1.9 ticket-source capability:
432
+ `listPage?(criteria: TicketCriteria, page: TicketPage): Promise<TicketPageListing>`.
433
+ The SDK exports these types; the result is `TicketListing & { total: number }`.
434
+ Criteria retain state, labels (AND), and assignee semantics. The page has a
435
+ nonnegative integer `limit`, optional nonnegative integer `offset` (default 0),
436
+ and optional `order: 'oldest' | 'newest'` (default oldest). Newest reverses the
437
+ entire source order before offset and limit. Total counts all matches, even
438
+ with limit zero or an offset past the end. Records, diagnostics and errors
439
+ match the exhaustive listing. The shared `describeTicketSourceContract` suite
440
+ automatically compares declared native paging with full-read windows.
441
+
442
+ Only paged operator listings select this capability. Sources without it retain
443
+ the full-read/reverse/slice fallback; native errors propagate. Unpaged operator
444
+ listings, CLI ticket lists and dispatcher ready scans remain exhaustive through
445
+ `listReady`/`listAll`. The hosted PostgreSQL source counts matches without
446
+ bodies and reads only the SQL-bounded window. File, Linear and the remote
447
+ `HostedTicketSource` retain fallback; the POST list-ready protocol stays exhaustive.