@defrex/autobuild 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +738 -68
  3. package/bin/ab-dispatch-generation.ts +3 -1
  4. package/docs/accounts.md +2 -1
  5. package/docs/answering-blocked-builds.md +20 -0
  6. package/docs/architecture.md +155 -25
  7. package/docs/build-store.md +10 -7
  8. package/docs/cli.md +33 -1
  9. package/docs/configuration-overview.md +4 -1
  10. package/docs/configuration.md +381 -29
  11. package/docs/dispatcher.md +63 -4
  12. package/docs/forges.md +7 -0
  13. package/docs/integration-tree.md +2 -2
  14. package/docs/operating.md +4 -2
  15. package/docs/operator-api.md +134 -6
  16. package/docs/operator-surfaces.md +85 -0
  17. package/docs/optimization-nodes.md +69 -11
  18. package/docs/plugin-authoring.md +37 -1
  19. package/docs/remote-store-protocol.md +94 -13
  20. package/docs/remote-ticket-protocol.md +40 -0
  21. package/docs/restacking.md +20 -4
  22. package/docs/setup.md +14 -2
  23. package/docs/ticket-dependencies.md +10 -3
  24. package/docs/ticket-sources.md +24 -2
  25. package/docs/tickets.md +7 -1
  26. package/docs/troubleshooting.md +8 -0
  27. package/docs/verification.md +4 -3
  28. package/docs/workspaces.md +3 -0
  29. package/package.json +9 -5
  30. package/packages/core/src/cli/accounts.ts +7 -2
  31. package/packages/core/src/cli/attention.ts +3 -1
  32. package/packages/core/src/cli/binary-direct.ts +2 -0
  33. package/packages/core/src/cli/binary-lifecycle.ts +2 -1
  34. package/packages/core/src/cli/build-control.ts +79 -1
  35. package/packages/core/src/cli/context.ts +4 -0
  36. package/packages/core/src/cli/dashboard/facts.ts +49 -53
  37. package/packages/core/src/cli/dashboard/header.ts +101 -0
  38. package/packages/core/src/cli/dashboard/model.ts +31 -39
  39. package/packages/core/src/cli/dashboard/objective-row.ts +46 -14
  40. package/packages/core/src/cli/dashboard/poll.ts +178 -76
  41. package/packages/core/src/cli/dashboard/render.ts +129 -230
  42. package/packages/core/src/cli/dashboard/row-text.ts +538 -0
  43. package/packages/core/src/cli/dashboard/timeline.ts +288 -0
  44. package/packages/core/src/cli/dashboard/vocabulary.ts +188 -0
  45. package/packages/core/src/cli/dispatch-args.ts +44 -1
  46. package/packages/core/src/cli/dispatch-frontend.ts +29 -38
  47. package/packages/core/src/cli/dispatch-launch-stop.ts +18 -0
  48. package/packages/core/src/cli/dispatch-launcher.ts +20 -7
  49. package/packages/core/src/cli/dispatch-web.ts +155 -0
  50. package/packages/core/src/cli/dispatch.ts +200 -34
  51. package/packages/core/src/cli/help.ts +87 -3
  52. package/packages/core/src/cli/init-validation.ts +3 -3
  53. package/packages/core/src/cli/main.ts +70 -6
  54. package/packages/core/src/cli/mcp.ts +35 -3
  55. package/packages/core/src/cli/objective.ts +1 -1
  56. package/packages/core/src/cli/operator-preference.ts +57 -0
  57. package/packages/core/src/cli/repo-lease.ts +2 -0
  58. package/packages/core/src/cli/repo-state.ts +56 -6
  59. package/packages/core/src/cli/repository-status.ts +97 -43
  60. package/packages/core/src/cli/status.ts +82 -1
  61. package/packages/core/src/cli/terminal-restore.ts +32 -7
  62. package/packages/core/src/cli/ticket.ts +98 -36
  63. package/packages/core/src/cli/wait.ts +14 -6
  64. package/packages/core/src/cli/watch.ts +20 -4
  65. package/packages/core/src/cli/web.ts +139 -0
  66. package/packages/core/src/config/live.ts +99 -14
  67. package/packages/core/src/config/load.ts +61 -20
  68. package/packages/core/src/config/local.ts +212 -0
  69. package/packages/core/src/config/pipeline-source.ts +2 -0
  70. package/packages/core/src/config/reference.ts +18 -0
  71. package/packages/core/src/config/schema.ts +45 -10
  72. package/packages/core/src/events/catalog.ts +4 -0
  73. package/packages/core/src/events/payloads.ts +97 -0
  74. package/packages/core/src/events/policy.ts +10 -0
  75. package/packages/core/src/events/repository.ts +46 -3
  76. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +316 -0
  77. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/017d8dd5bb6dd80b.json.gz +0 -0
  78. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/178e12f1759b7552.json.gz +0 -0
  79. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4932c70a2af97faf.json.gz +0 -0
  80. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/536085773daf6b58.json.gz +0 -0
  81. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6bd6275061aaffa5.json.gz +0 -0
  82. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/89625654b02e9ac1.json.gz +0 -0
  83. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a98af134be2da8a9.json.gz +0 -0
  84. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d5d5ccca80a893d8.json.gz +0 -0
  85. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f8155387eb5f375c.json.gz +0 -0
  86. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3c27f918b194e3b3.json +465 -0
  87. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/79f0e0f4ccd43ba2.json +455 -0
  88. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/859c09edac738823.json +1086 -0
  89. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a283c1f3462b1cc1.json +81 -0
  90. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a6e570fb126991ff.json +36 -0
  91. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a8acf22c968b6e3d.json +81 -0
  92. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/ba7b85895bf6698e.json +1153 -0
  93. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fc66408cde0b6b04.json +637 -0
  94. package/packages/core/src/kernel/build-roster.ts +230 -0
  95. package/packages/core/src/kernel/dispatch-capacity.ts +4 -2
  96. package/packages/core/src/kernel/engine.ts +43 -5
  97. package/packages/core/src/kernel/execution-intervals.ts +61 -0
  98. package/packages/core/src/kernel/generators/optimization-log.ts +101 -0
  99. package/packages/core/src/kernel/generators/repository-journals.ts +13 -0
  100. package/packages/core/src/kernel/leaf-restack-base.ts +33 -7
  101. package/packages/core/src/kernel/leaf-restack-state.ts +82 -3
  102. package/packages/core/src/kernel/log-index.ts +19 -0
  103. package/packages/core/src/kernel/optimization-admission.ts +244 -3
  104. package/packages/core/src/kernel/optimization.ts +183 -4
  105. package/packages/core/src/kernel/phase-failures.ts +121 -0
  106. package/packages/core/src/kernel/published-branch-head.ts +60 -0
  107. package/packages/core/src/kernel/reducer-registry.ts +27 -8
  108. package/packages/core/src/kernel/reducer-revisions.ts +25 -0
  109. package/packages/core/src/kernel/reducer.ts +63 -4
  110. package/packages/core/src/kernel/rollup.ts +61 -0
  111. package/packages/core/src/kernel/setup-streak.ts +38 -0
  112. package/packages/core/src/kernel/step-durations.ts +257 -0
  113. package/packages/core/src/kernel/target-observation.ts +6 -1
  114. package/packages/core/src/kernel/target-rewrite-recovery.ts +116 -0
  115. package/packages/core/src/kernel/verify-diff-base.ts +5 -0
  116. package/packages/core/src/kernel/verify-stages.ts +13 -3
  117. package/packages/core/src/ontology.ts +5 -0
  118. package/packages/core/src/operator/agent-context-serve.ts +631 -0
  119. package/packages/core/src/operator/annotations.ts +75 -5
  120. package/packages/core/src/operator/attention.ts +470 -0
  121. package/packages/core/src/operator/canonical-skills.ts +35 -0
  122. package/packages/core/src/operator/cli-equivalents.ts +270 -0
  123. package/packages/core/src/operator/context-prompts.ts +61 -0
  124. package/packages/core/src/operator/index.ts +49 -1
  125. package/packages/core/src/operator/landings.ts +28 -19
  126. package/packages/core/src/operator/optimization.ts +7 -0
  127. package/packages/core/src/operator/protocol.ts +3 -0
  128. package/packages/core/src/operator/query.ts +122 -72
  129. package/packages/core/src/operator/read-view.ts +5 -2
  130. package/packages/core/src/operator/registry.ts +406 -46
  131. package/packages/core/src/operator/requests.ts +20 -18
  132. package/packages/core/src/operator/sandbox-host.ts +107 -11
  133. package/packages/core/src/operator/sandbox-resolver.ts +253 -0
  134. package/packages/core/src/operator/sandbox.ts +778 -82
  135. package/packages/core/src/operator/ticket-asset-list.ts +77 -0
  136. package/packages/core/src/operator/ticket-assets.ts +167 -0
  137. package/packages/core/src/operator/tickets.ts +33 -2
  138. package/packages/core/src/plugin-sdk/index.ts +22 -0
  139. package/packages/core/src/plugins/manifest.ts +1 -1
  140. package/packages/core/src/ports/forge/fake.ts +92 -1
  141. package/packages/core/src/ports/forge/git-blob.ts +15 -0
  142. package/packages/core/src/ports/forge/github.ts +82 -0
  143. package/packages/core/src/ports/forge/local-git.ts +61 -1
  144. package/packages/core/src/ports/forge-failure.ts +24 -0
  145. package/packages/core/src/ports/runner/antigravity-test.fixture.ts +149 -0
  146. package/packages/core/src/ports/runner/claude-test.fixture.ts +71 -0
  147. package/packages/core/src/ports/runner/codex-test.fixture.ts +63 -0
  148. package/packages/core/src/ports/tickets/contract.ts +71 -0
  149. package/packages/core/src/ports/tickets/fake.ts +11 -0
  150. package/packages/core/src/ports/tickets/file.ts +18 -0
  151. package/packages/core/src/ports/tickets/github-fake.ts +136 -4
  152. package/packages/core/src/ports/tickets/github.ts +387 -30
  153. package/packages/core/src/ports/tickets/hosted-index.ts +10 -0
  154. package/packages/core/src/ports/tickets/linear.ts +130 -0
  155. package/packages/core/src/ports/tickets/priority.ts +9 -0
  156. package/packages/core/src/ports/tickets/remote-protocol.ts +34 -0
  157. package/packages/core/src/ports/tickets/remote.ts +70 -6
  158. package/packages/core/src/ports/tickets/search.ts +139 -0
  159. package/packages/core/src/ports/types.ts +104 -2
  160. package/packages/core/src/ports/workspace/builtin-capabilities.ts +9 -0
  161. package/packages/core/src/ports/workspace/create.ts +15 -1
  162. package/packages/core/src/ports/workspace/fake.ts +340 -12
  163. package/packages/core/src/ports/workspace/git-worktree.ts +833 -42
  164. package/packages/core/src/ports/workspace/operator-sandbox.ts +129 -12
  165. package/packages/core/src/ports/workspace/process-group.ts +48 -0
  166. package/packages/core/src/ports/workspace/vercel-sandbox.ts +1260 -123
  167. package/packages/core/src/processes/agent-context-assemble.ts +576 -0
  168. package/packages/core/src/processes/agent-context.ts +469 -0
  169. package/packages/core/src/processes/build-runner.ts +387 -236
  170. package/packages/core/src/processes/dispatcher.ts +211 -55
  171. package/packages/core/src/processes/execution-no-progress.ts +4 -0
  172. package/packages/core/src/processes/optimization-activity.ts +120 -0
  173. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  174. package/packages/core/src/processes/repo-view.ts +78 -2
  175. package/packages/core/src/processes/sandbox-state.ts +53 -6
  176. package/packages/core/src/processes/tick-publication.ts +2 -0
  177. package/packages/core/src/processes/workspace-preparation.ts +76 -0
  178. package/packages/core/src/scenarios/harness.ts +0 -5
  179. package/packages/core/src/store/account-redaction.ts +1 -0
  180. package/packages/core/src/store/adapter.ts +52 -1
  181. package/packages/core/src/store/agent-context.ts +432 -0
  182. package/packages/core/src/store/build-feed.ts +291 -0
  183. package/packages/core/src/store/build-scope.ts +19 -1
  184. package/packages/core/src/store/contract.ts +911 -14
  185. package/packages/core/src/store/digest.ts +19 -6
  186. package/packages/core/src/store/histogram.ts +113 -0
  187. package/packages/core/src/store/local/schema.ts +62 -0
  188. package/packages/core/src/store/local/store.ts +628 -22
  189. package/packages/core/src/store/local/ticket-asset-heads.ts +23 -0
  190. package/packages/core/src/store/memory.ts +461 -69
  191. package/packages/core/src/store/open-builds.ts +19 -0
  192. package/packages/core/src/store/phase-session.ts +32 -4
  193. package/packages/core/src/store/reduced-reads.ts +14 -4
  194. package/packages/core/src/store/reducer-value-shapes.json +6987 -5749
  195. package/packages/core/src/store/reducer-values.ts +6 -1
  196. package/packages/core/src/store/remote/client.ts +208 -2
  197. package/packages/core/src/store/remote/compatibility.ts +1 -1
  198. package/packages/core/src/store/remote/index.ts +33 -0
  199. package/packages/core/src/store/remote/protocol.ts +69 -0
  200. package/packages/core/src/store/remote/released-clients.json +11 -0
  201. package/packages/core/src/store/remote/released-reducer-values/1.11.0.json +35680 -0
  202. package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -16
  203. package/packages/core/src/store/retention.ts +23 -1
  204. package/packages/core/src/store/rollups.ts +337 -0
  205. package/packages/core/src/store/session-handle.ts +20 -2
  206. package/packages/core/src/store/snapshots.ts +10 -0
  207. package/packages/core/src/store/types.ts +108 -9
  208. package/packages/core/src/testing/dispatch-read-budget.ts +1092 -2
  209. package/packages/core/src/testing/git-config-isolation.ts +7 -5
  210. package/packages/core/src/testing/index.ts +27 -0
  211. package/packages/core/src/testing/memory-operator-sandbox.ts +346 -0
  212. package/packages/core/src/testing/reduced-read-budget.ts +1873 -98
  213. package/packages/core/src/web/analytics-source.ts +303 -0
  214. package/packages/core/src/web/assets/Atkinson-OFL.txt +93 -0
  215. package/packages/core/src/web/assets/AtkinsonHyperlegibleNext.latin.woff2 +0 -0
  216. package/packages/core/src/web/assets/JetBrains-OFL.txt +93 -0
  217. package/packages/core/src/web/assets/JetBrainsMono.latin.woff2 +0 -0
  218. package/packages/core/src/web/assets/app.css +1 -0
  219. package/packages/core/src/web/assets/app.js +9 -0
  220. package/packages/core/src/web/assets/manifest.json +31 -0
  221. package/packages/core/src/web/assets/theme.js +1 -0
  222. package/packages/core/src/web/bounded.ts +31 -0
  223. package/packages/core/src/web/http.ts +315 -0
  224. package/packages/core/src/web/hub.ts +160 -0
  225. package/packages/core/src/web/options.ts +38 -0
  226. package/packages/core/src/web/overview-source.ts +322 -0
  227. package/packages/core/src/web/page.ts +56 -0
  228. package/packages/core/src/web/protocol.ts +151 -0
  229. package/packages/core/src/web/read-only.ts +23 -0
  230. package/packages/core/src/web/repository-source.ts +35 -0
  231. package/packages/core/src/web/server.ts +97 -0
  232. package/skills/code-review/SKILL.md +10 -2
  233. package/skills/guide/SKILL.md +366 -52
  234. package/skills/guide/references/accounts.md +2 -1
  235. package/skills/guide/references/integration-tree.md +2 -2
  236. package/skills/guide/references/operator-api.md +134 -6
  237. package/skills/guide/references/optimization-nodes.md +69 -11
  238. package/skills/guide/references/plugin-authoring.md +37 -1
  239. package/skills/guide/references/remote-store-protocol.md +94 -13
  240. package/skills/guide/references/remote-ticket-protocol.md +40 -0
  241. package/skills/guide/references/restacking.md +20 -4
  242. package/skills/guide/references/setup.md +14 -2
  243. package/skills/guide/references/ticket-dependencies.md +10 -3
  244. package/skills/implement/SKILL.md +23 -4
  245. package/skills/operate/SKILL.md +134 -32
  246. package/skills/plan/SKILL.md +10 -4
  247. package/skills/plan-review/SKILL.md +9 -2
  248. package/skills/spec/SKILL.md +34 -8
  249. package/skills/tickets/SKILL.md +51 -5
  250. package/templates/hosted-service/package.json +2 -2
@@ -534,7 +534,7 @@ client version window are unchanged.
534
534
 
535
535
  | Scope | Reducers with no arguments |
536
536
  | --- | --- |
537
- | Build | `executionNoProgress`, `summaryRequests`, `build`, `buildDigest`, `currentPrAttachments`, `pendingPrAttachmentReclaims`, `openExecution`, `lastExecutionOutcome`, `infrastructureFailureReset`, `openWorkspace`, `setupStreak`, `openBuildWorkspace`, `currentDeferralObservation`, `dashboardFacts`, `pinnedAssets`, `buildDelegation` |
537
+ | Build | `executionNoProgress`, `summaryRequests`, `build`, `buildDigest`, `currentPrAttachments`, `pendingPrAttachmentReclaims`, `openExecution`, `lastExecutionOutcome`, `infrastructureFailureReset`, `openWorkspace`, `setupStreak`, `openBuildWorkspace`, `currentDeferralObservation`, `dashboardFacts`, `buildTimeline`, `buildRosterEntry`, `pinnedAssets`, `buildDelegation` |
538
538
  | Repository | `dispatchPlacement`, `ticketPreparation`, `harvest`, `dispatchSettings`, `sandboxStates`, `openHarvestExecutions`, `hostedHarvestAuthority`, `autoMergeDefault`, `effectiveConfig`, `harvestDelegation` |
539
539
 
540
540
  | Reducer | Scope | Required arguments |
@@ -579,6 +579,40 @@ names retain their existing behavior. The value cache key format is versioned;
579
579
  checkpoints from the former publicly writable format are ignored and rebuilt
580
580
  from the log after upgrading.
581
581
 
582
+ ### Rollup values
583
+
584
+ `POST /repos/{repo}/rollup-values` answers a derived reducer: a value across the
585
+ repository's builds. The body is a named-value request of at most
586
+ 4 KiB, whose optional `read` record carries read-time arguments:
587
+
588
+ ```json
589
+ {"reducer":"stepDurations","args":{"outcome":"all"},"read":{"window":"30d"}}
590
+ ```
591
+
592
+ - `args` are key arguments: each combination, after defaults, is its own
593
+ rollup. `read` shapes only the finished value and never creates a key.
594
+ Named-value requests that carry `read` are `400 validation`.
595
+ - The response is the strict envelope `200 {"version", "cursor", "value"}`.
596
+ `cursor` is always `0`; `value.position` names the repository change
597
+ position the answer reflects.
598
+ - The server advances the rollup by the builds changed since its saved
599
+ position, serialized per key, and answers canonically. The client sends one
600
+ request and never reconstructs the value from events, the changed-builds
601
+ feed or build values.
602
+ - Rollups have no released projection catalog. A client requires the server's
603
+ `version` to equal its own; a different version, an absent route (`404` or
604
+ `405` from an older server), `400 validation` for a rollup the server does
605
+ not know (an older server), an invalid envelope or a value outside the
606
+ rollup's schema raises `ReducerValueIncompatibilityError`.
607
+ - Unknown rollup names, invalid arguments and extra fields are
608
+ `400 validation`. An unknown repository answers the empty value and creates
609
+ nothing. The operation is read-only authority, like `reducer-values`.
610
+
611
+ | Rollup | Key arguments | Read-time arguments | Value |
612
+ | --- | --- | --- | --- |
613
+ | `stepDurations` | `outcome`: `merged` (default) or `all`; `kind`: `leaf` (default), `node` or `all` | `window`: `24h`, `7d` (default), `30d` or `all` | `{"position": string, "window": string, "steps": [{"step", "count", "meanMs", "p50Ms", "p90Ms", "p99Ms", "totalMs"}]}`, steps in pipeline order with waits last |
614
+ | `buildRoster` | none | none | `{"position": string, "live": [{"slug", "kind", "createdAt"?}], "finished": [{"slug", "kind", "outcome", "completedAt"}]}`: every live build, oldest first; up to 10 of the newest finished builds, newest first, with `outcome` `merged`, `closed` or `aborted` |
615
+
582
616
  ### Reducer snapshots
583
617
 
584
618
  A reducer snapshot is one registered reducer's serialized state as of a log
@@ -716,17 +750,20 @@ waits apply. There is no push transport; a held request is the whole mechanism.
716
750
  Repository journals are separate resources with independent event sequences,
717
751
  artifacts, and leases. `{repo}` is one percent-encoded repository id; encode
718
752
  embedded `/` characters. All resource routes authorize and require the
719
- repository to exist. An unknown repository returns `404 not-found` — with one
720
- carve-out: the build-digest batch read of this section is keyed to build
721
- records, not the repository journal record, so it authorizes the project credential
722
- but answers `200` (possibly empty) even for an unknown repository, a repository
723
- without a journal record, or a repository without builds.
753
+ repository to exist. An unknown repository returns `404 not-found` — except
754
+ for the build-record reads of this section (`change-position`, `builds`,
755
+ `changed-builds`, `build-page`, `build-digests`, `open-builds` and `rollup-values`), which are keyed
756
+ to build records, not the repository journal record, so they authorize the
757
+ project credential but answer `200` (possibly empty) even for an unknown
758
+ repository, a repository without a journal record, or a repository without
759
+ builds.
724
760
 
725
761
  | BuildStore operation | HTTP route | Request | Success |
726
762
  |---|---|---|---|
727
763
  | `ensureRepo` | `POST /repos` | `{"repo": string}` with a nonempty id | `200` + `RepositoryRecord`; idempotently returns the existing record |
728
764
  | `getRepo` | `GET /repos/{repo}` | none | `200` + `RepositoryRecord`; absent is `404` (the shipped client maps this to `null`) |
729
765
  | `appendRepo` | `POST /repos/{repo}/events` | event write | `201` + repository event envelope |
766
+ | `appendRepoIfCurrent` | `POST /repos/{repo}/events/conditional` | `{"expectedSeq": nonnegative integer, "event": event write}` | appended: `201` + repository event envelope; journal advanced: `200 null` (mirroring section 3's build compare-and-append). A server without the route answers `404`; callers report it and never fall back to an unconditional append |
730
767
  | `getRepoEvents` / `getRepositoryTail` | `GET /repos/{repo}/events?since={n}&through={n}&wait={s}` | optional `since` query value, parsed as in section 3; absence defaults to `0`. Optional `wait` in whole seconds, per the event-wait rules of section 3 | `200` + envelopes with `seq > since`, up to the frozen head; optional `through` caps the response at `seq <= through`; `409 cursor-too-old` below `max(0, head - 1000)` |
731
768
  | `getRepoStateEvents` | `GET /repos/{repo}/state-events` | none | `200` + the bounded repository-journal subset (AUT-489): every durable event type (`ticket-preparation.*`, `harvest.*`, `orchestrator.sandbox.*`, the three dispatcher setting types, and cross-generation handoff correlation facts: target-prepared, yield-requested, upgrade-failed, handoff-started, terminal-released, takeover, drain-deadline, drain-settled and handoff-completed) plus the latest-only `dispatcher.ticket-scan-completed` and `dispatcher.placement-set` facts and, when the journal has one, the tail from the latest `dispatcher.run-started`, in increasing sequence order; served inside the repository-existence gate like `GET events`, so an unknown repository is `404` |
732
769
  | `getReducerSnapshot` (repo scope) | `GET /repos/{repo}/snapshots/{reducer}?version={n}` | required `version` query value, a positive integer; `reducer` is a registry name (`^[A-Za-z][A-Za-z0-9._-]{0,63}$`) | `200` + `{"version", "cursor", "state"}` or `200 null` when absent, written by another reducer version, ahead of the journal's tail, or the repository has no journal record; an unknown repository is `404`, which the shipped client also maps to `null` |
@@ -735,11 +772,28 @@ without a journal record, or a repository without builds.
735
772
  | `putRepoArtifact` | `POST /repos/{repo}/artifacts` | artifact input | `201` + repository artifact metadata |
736
773
  | `getRepoArtifact` | `GET /repos/{repo}/artifacts?kind={kind}&rev={n}` | required nonempty `kind`; optional `rev` is parsed as in section 3 | `200` + artifact read; latest only when the `rev` parameter is absent; missing kind/revision is `200 null` |
737
774
  | `listRepoArtifacts` | `GET /repos/{repo}/artifact-list?kind={kind}` | optional `kind`; absence means all kinds | `200` + metadata ordered by kind and then increasing revision |
775
+ | `getRepoChangePosition` | `GET /repos/{repo}/change-position` | none | `200 {"position": string}`: the canonical unsigned decimal change position, `"0"` for an unknown repository. Positions are ordered: a later build creation, build event, repository event or repository lease holder change yields a strictly greater value, compared numerically |
776
+ | `listBuildsForRepo` | `GET /repos/{repo}/builds` | none | `200` + `BuildRecord[]` ordered by creation time, then slug |
777
+ | `listBuildsChangedSince` | `GET /repos/{repo}/changed-builds?since={p}` | required `since`, a canonical unsigned decimal no greater than 9223372036854775807; anything else is `400 validation` | `200 {"position": string, "builds": [{"slug": string, "position": string}]}`: the builds whose latest change position is greater than `since`, ascending by position and each once, with the repository head read in the same snapshot. Reads no event rows. An unknown repository answers `{"position": "0", "builds": []}` |
778
+ | `listBuildsPage` | `GET /repos/{repo}/build-page?limit={n}&cursor={c}&kind={k}&outcome=merged&activeSince={t}` | optional `limit`, a decimal integer from 1 to 100 (default 25); optional `cursor`, a `next` value this server issued for the same filters; optional `kind`, `leaf` or `node`; optional `outcome`, only `merged`; optional `activeSince`, an ISO instant with a zone. A bad limit, a malformed cursor, a cursor of the other order, or an empty or invalid filter is `400 validation` | `200 {"builds": BuildRecord[], "next": string \| null, "filters"?: {"kind"?, "outcome"?, "activeSince"?}}`: one page newest first by creation time, slug descending to break ties, with records as `builds` returns them; `next` is `null` on the last page. `kind` and `outcome` keep that order. `activeSince` keeps builds whose `updatedAt` is at or after it, ordered by `updatedAt` then slug, both descending, a superset of builds active in the window; a build written between two requests can appear twice or be skipped once, so dedupe by slug. A filtered answer echoes the normalized filters it applied as `filters`. Every page, filtered or not, costs at most `limit + 1` index entries and no event rows |
779
+ | `getReducerValue` (rollup scope) | `POST /repos/{repo}/rollup-values` | a named-value request with optional `read`; see [Rollup values](#rollup-values) | `200 {"version", "cursor": 0, "value"}`: the canonical rollup; an unknown repository answers the empty value |
738
780
  | `getRepoBuildDigests` | `GET /repos/{repo}/build-digests` | none | `200` + `BuildDigest[]`, one entry per build record of the repository (possibly empty), ordered by slug; handled before the repository-existence gate, so an unknown or journal-less repository answers `200 []` |
781
+ | `listOpenBuilds` | `GET /repos/{repo}/open-builds` | none | `200` + `[{"record", "digest"}]`, a build record and its `BuildDigest` for every open build of the repository (possibly empty), ordered by `createdAt` and then slug; handled before the repository-existence gate, so an unknown or journal-less repository answers `200 []` |
739
782
  | `claimRepoLease` | `POST /repos/{repo}/lease/claim` | claim request | `200 {"ok": boolean}` |
740
783
  | `heartbeatRepo` | `POST /repos/{repo}/lease/heartbeat` | holder request | `200 {"ok": boolean}` |
741
784
  | `releaseRepoLease` | `POST /repos/{repo}/lease/release` | holder request | `200 {"ok": true}`; a wrong holder is a successful no-op |
742
785
 
786
+ The `changed-builds` and `build-page` routes are additive and keep the
787
+ protocol version. A server on the same release line that lacks them answers
788
+ `501 unsupported-operation` or `404 not-found`; the shipped client reports
789
+ that as a typed `BuildFeedUnsupportedError` and never falls back to listing
790
+ builds or reading events. The `build-page` filters are additive too. A server
791
+ that predates them ignores the parameters and answers an unfiltered page
792
+ without `filters`, so the client requires an echo equal to the filters it sent
793
+ and otherwise raises `BuildFeedUnsupportedError` with capability
794
+ `buildPageFilters`. It never filters an unfiltered page client-side and never
795
+ retries without the filters.
796
+
743
797
  There is no repository-list operation. `ensureRepo` is the only repository
744
798
  creation operation and must not reset timestamps, events, artifacts, or lease
745
799
  state when the repository already exists. Event sequence numbering starts at 1
@@ -799,8 +853,11 @@ field from events.
799
853
  `false` for a plain node. For an optimization node it is a bounded summary of
800
854
  the node's own optimization facts: `stopped?` and `measured?` (each `true` when
801
855
  set), `inFlight`, `concurrency`, `attemptRoom?` (absent without an attempts
802
- budget), `emptyProposals`, `openedAt`, `maxHours?`, `proposal?: {request,
803
- deposited?: {ids, at}}`, and `wakeSeq?` and `deferredSeq?`, the sequences of
856
+ budget), `emptyProposals`, `openedAt`, `maxHours?`, `clock?: {activeMs,
857
+ spans, open, stoppedAt?, settled?}` (the active-hours clock: activity
858
+ compacted before the last batch, closed spans since, and the start time of
859
+ each open run), `proposal?: {request, deposited?: {ids, at}}`, and `wakeSeq?`
860
+ and `deferredSeq?`, the sequences of
804
861
  the latest fact that can clear a proposer deferral and of the latest
805
862
  `optimization.proposal-deferred`. A dispatcher selects nodes to request
806
863
  proposals for, file proposals from and stop as exhausted from this member
@@ -808,7 +865,18 @@ alone. The member is additive and keeps the protocol version. A node digest
808
865
  without it is an older service's answer: the client fails the proposer stage
809
866
  and the attempt-creation hold closed with a typed capability error, proposing
810
867
  nothing and withholding every ready ticket that carries a creation key for
811
- that pass, and it never falls back to reading each node's facts.
868
+ that pass, and it never falls back to reading each node's facts. A node digest
869
+ whose signal lacks `clock` skips the hours condition of a proposal request,
870
+ which the build read then confirms.
871
+
872
+ `executionFacts` is present on every build digest: the count of the build's
873
+ `execution.started` and `execution.ended` facts. The dispatcher's
874
+ optimization activity pass compares it with what a node's clock has
875
+ accounted, and reads the build's served `executionIntervals` value, which
876
+ holds only the execution facts no node has acknowledged, only when it grew.
877
+ The member is additive and keeps the protocol version. A digest without it is
878
+ an older service's answer: the activity pass fails closed with a typed
879
+ capability error and never reads the build's events instead.
812
880
 
813
881
  The digest is derived from the event log on every call — the server persists
814
882
  nothing and there is no refresh step. Protocol version `3` reshaped the
@@ -823,6 +891,18 @@ This is the same discipline the transport's supported-window rules promise:
823
891
  wire shapes that independently implemented servers must reproduce update this
824
892
  document and the protocol version together.
825
893
 
894
+ An open build is one whose latest terminal fact is not `build.completed`:
895
+ queued, running, paused, blocked and settled-awaiting-merge builds, plus
896
+ aborted builds whose cleanup has not finished. The server maintains the set
897
+ in the same transaction that inserts a build or appends its
898
+ `build.completed`, `build.aborted` or `build.reopened`, so answering costs one
899
+ entry per open build and never grows with settled history. Operator reads of
900
+ active work use it. The route is additive and keeps the protocol version. A
901
+ server without it answers the generic `no route` `404`, or its
902
+ repository-existence gate's `unknown repo` `404` for a journal-less
903
+ repository; a client surfaces either as a typed capability error and never
904
+ answers from `build-digests` or the build list instead.
905
+
826
906
  The build-stream query, artifact, ordering, timestamp, and validation rules
827
907
  apply symmetrically to repository journals, including the event-read bounded
828
908
  wait of section 3.
@@ -1487,8 +1567,8 @@ Beyond leases, the backing store must maintain:
1487
1567
 
1488
1568
  - per-build and per-repository monotonically assigned event sequences starting
1489
1569
  at 1, preserving append order and continuity across server restarts;
1490
- - atomic build-stream conditional append, including a mutation-free stale
1491
- comparison result;
1570
+ - atomic build-stream and repository-journal conditional append, including a
1571
+ mutation-free stale comparison result;
1492
1572
  - server-assigned event, record, artifact, lease, and heartbeat times;
1493
1573
  - 0-based revisions independently per resource and artifact kind, including
1494
1574
  distinct concurrent assignments;
@@ -1559,8 +1639,9 @@ Four shipped behaviors do not add `BuildStore` routes:
1559
1639
  not a deeper backing-store transaction or migration check. The example shows anonymous health on the 1.3 line; an admitted same-line protocol-7 probe sees 7 instead.
1560
1640
 
1561
1641
  There is no push/WebSocket subscription protocol, repository listing, artifact
1562
- deletion, or server deployment API. The one repo-scoped batch read is the
1563
- build-digest route of section 4; no other batch-read route exists.
1642
+ deletion, or server deployment API. The repo-scoped batch reads are the
1643
+ build-digest and open-build routes of section 4; no other batch-read route
1644
+ exists.
1564
1645
 
1565
1646
  ## 12. Conformance
1566
1647
 
@@ -184,6 +184,7 @@ The operation names and `input` values are:
184
184
  | `list-ready` | `{labels?: string[], state?: string}` | `TicketListing` |
185
185
  | `list-targeting` | `{nodeId: string}` | `TicketListing` of every state |
186
186
  | `list-page` | `{criteria: {labels?, state?}, page: {limit, offset?, order?}}` | `TicketPageListing` (`{tickets, diagnostics, total}`) |
187
+ | `search` | `{text, state?, labels?, limit, cursor?}` | `{tickets: {id, title, state?, labels, kind, target?}[], cursor?, diagnostics}` |
187
188
  | `get` | `{id}` | `Ticket \| null` |
188
189
  | `claim` | `{id}` | `{claimed: boolean}` |
189
190
  | `comment` | `{id, body}` | `{ok: true}` |
@@ -482,3 +483,42 @@ listing takes the `list-ready` path by that explicit decision.
482
483
 
483
484
  The capability is additive. It does not change the remote BuildStore protocol
484
485
  version, and released clients, which never send `list-page`, are unaffected.
486
+
487
+ ## Search
488
+
489
+ `search` answers one page of compact hits from the backing source's own search,
490
+ for duplicate checks before filing:
491
+
492
+ - **Matching.** `text` is nonblank. Every whitespace-separated term must occur,
493
+ case-insensitively, in the title or the body; each term may hit either field.
494
+ `%`, `_` and `\` are literal. `state` resolves as in `list-ready` (exact, else
495
+ one case-insensitive match); `labels` are ANDed. Absent `state` searches every
496
+ state.
497
+ - **Paging.** `limit` is an integer from 1 to 100. Order is source-defined and
498
+ stable across pages: the PostgreSQL backend answers newest ticket number
499
+ first. `cursor` is opaque; pass the previous page's `cursor` with the same
500
+ text and filters. It is absent on the last page.
501
+ - **Hits.** `id`, `title`, `state`, `labels`, `kind` and `target` come from the
502
+ search read itself. Bodies are never returned, and there is no read per hit.
503
+ - **Refusals.** A backing source without search answers `409` with
504
+ `code: "search-unsupported"`. A malformed or foreign cursor answers `400` with
505
+ `code: "search-cursor-invalid"` and the `cursor`. Clients report them as
506
+ `TicketSearchUnsupported` and `TicketSearchCursorInvalid`. The service never
507
+ filters a full listing instead.
508
+ - **Authority.** `search` is an operator read: it requires project or owner
509
+ authority, and ticket grants and harvest delegations receive `403`.
510
+ - **Cost.** One request per page, answered by PostgreSQL in one bounded
511
+ statement. Cost follows the page, not the project's ticket count.
512
+
513
+ Every `/tickets/*` response, including errors, carries
514
+ `x-autobuild-ticket-search: 1`. A current client declares `search` only after a
515
+ response from the service has carried that header, settled on the response that
516
+ already finishes source construction, with no extra probe. Against a service
517
+ predating the operation (an ok response without the header) the client never
518
+ declares `search`, so callers refuse with `TicketSearchUnsupported` before any
519
+ request and nothing is listed. A `search` request that the service later refuses
520
+ with `404` or `400` and no header fails with `TicketSearchUnsupported`, with no
521
+ fallback, and the client stops declaring `search`.
522
+
523
+ The capability is additive. It does not change the remote BuildStore protocol
524
+ version, and released clients, which never send `search`, are unaffected.
@@ -27,10 +27,26 @@ heads require immutable commit ancestry proof against the accepted target and
27
27
  the destination base already used by replay. Missing capability or failed proof
28
28
  defers new replay. A non-descendant without kernel lineage records
29
29
  `target.rewritten` with branch,
30
- previous SHA and observed SHA, retains the accepted target, and raises watch/wait
31
- attention. Repeated rewrite pairs are deduplicated. Returning to a safe target
32
- clears attention (`target.rewrite-cleared` when the accepted tip is unchanged).
33
- Upstream force-pushes are never adopted automatically. Accepted node reparenting
30
+ previous SHA and observed SHA, and retains the accepted target. Repeated rewrite
31
+ pairs are deduplicated. Returning to a safe target clears the wait
32
+ (`target.rewrite-cleared` when the accepted tip is unchanged). Upstream
33
+ force-pushes are never adopted on top of existing work automatically:
34
+
35
+ - A leaf with no work of its own (no published head, no PR, no commits beyond
36
+ its base in use) is reprovisioned from the current target by its next runner,
37
+ without operator action: `target.rewrite-reprovision-prepared`, a branch
38
+ reset, then `target.rewrite-recovered` (`reprovisioned`). A runner that dies
39
+ mid-reset completes it forward.
40
+ - A leaf with work raises one `policy/target-rewritten` escalation per episode
41
+ (a run of rewrites of the same rejected base), naming that base, the new
42
+ target head and its own commits. `ab answer <slug> --accept-target` waives
43
+ the rejected base (`target.rewrite-recovered`, `accepted`) and restacks its
44
+ own commits onto the target at the next replay boundary; `ab abort` is the
45
+ other way out.
46
+ - A node waits, and raises watch/wait attention once per episode.
47
+
48
+ `ab build status` names a leaf's recovery state, and the base when the build's
49
+ first provision adopted it from a pre-existing branch. Accepted node reparenting
34
50
  starts a new branch scope; frozen transactions recover their retained inputs.
35
51
 
36
52
  Kernel restacks of a node are admitted through durable guarded publication
@@ -24,6 +24,16 @@ Keep the default `git-worktree` provider unless the maintainer explicitly opts
24
24
  into remote builds. It creates local disposable worktrees and uses the tools,
25
25
  network, and credentials available to the dispatcher machine.
26
26
 
27
+ Local worktrees live outside the checkout, under
28
+ `$XDG_STATE_HOME/autobuild/worktrees/` (default `~/.local/state/…`), or in the
29
+ store's own `worktrees/` when a local store lies outside the checkout. They do
30
+ not inherit the checkout's `node_modules`, so `[commands].setup` must install
31
+ dependencies. If the destination resolves inside the checkout or has a
32
+ `node_modules` directory above it, new builds fail to provision and dispatch
33
+ shows a startup notice: set `XDG_STATE_HOME` to an absolute directory outside
34
+ the checkout with no `node_modules` above it, or select a local store outside
35
+ the checkout.
36
+
27
37
  For remote execution, set `[workspace].provider = "vercel-sandbox"`. A Vercel
28
38
  Sandbox is a fresh independent machine; a runtime that works on the setup
29
39
  machine is not evidence that it works there. Confirm all of these with the
@@ -111,7 +121,7 @@ allowlist entry; their real credentials remain on the dispatcher host.
111
121
 
112
122
  Keep package-level and checkout-level bootstrap in an idempotent
113
123
  `[commands].setup`. It runs after system provisioning and must remain safe to
114
- rerun on attachment. Do not repeatedly install OS packages there. Expose only
124
+ rerun on attachment and after every restack onto a new base. Do not repeatedly install OS packages there. Expose only
115
125
  required runtime credentials through
116
126
  `[workspace.config].environmentVariables`, keep generated caches disposable,
117
127
  and lock dependencies in the repository. A browser-capable repository should
@@ -141,7 +151,9 @@ exits nonzero on failure. Then:
141
151
  `bun ab dispatch`, then open their coding agent at the repository root with
142
152
  `ab-operate` loaded to specify, create and groom the first ticket. Check operator
143
153
  presence before taking the role; an existing operator picks up ready work.
144
- The setup agent must not start dispatch itself.
154
+ For dispatcher startup after setup, follow `ab-operate` ownership boundaries: check
155
+ fresh `dispatcherRunning`, honor repository instructions and the saved local
156
+ preference, or ask who should run it when unset.
145
157
 
146
158
  Validation is explicit and noninteractive. It does not dispatch, claim a
147
159
  ticket, or create build, phase, session, event, transcript, or artifact history.
@@ -1,14 +1,21 @@
1
1
  # Filing tickets with blockers safely
2
2
 
3
3
  `ab ticket create --blocked-by` validates prerequisite ids and records blocking
4
- relationships, but a single CLI command is **not an atomic publication guarantee**.
5
- In particular, direct Linear and GitHub create the issue first and add
6
- its blocker relationships in separate requests. If the issue is already in the
4
+ relationships, but on most sources a single CLI command is **not an atomic
5
+ publication guarantee**. Direct Linear creates the issue first and adds its
6
+ blocker relationships in separate requests. If the issue is already in the
7
7
  ready state, a dispatcher can see it before those relationships exist. A
8
8
  successful create response containing every blocker does not prove that no build
9
9
  was claimed during the request. Harvest's durable creation reservations protect
10
10
  its own filing workflow; ordinary interactive ticket creation has no such hold.
11
11
 
12
+ GitHub stages for you. A ready-bound create with blockers opens in triage,
13
+ records every blocker, and only then moves to ready. Claim also re-reads
14
+ blockers fresh, so one `create --blocked-by` never exposes an unblocked ready
15
+ ticket and needs no manual staging. A partial failure leaves the ticket in
16
+ triage, so reading it back still matters. The workflow below is the portable
17
+ procedure for any source whose create order you do not know.
18
+
12
19
  ## Safe interactive workflow
13
20
 
14
21
  For tickets with prerequisites, determine the intended final state from the
@@ -61,9 +61,28 @@ manifest-directed artifact paths remain authoritative. Never commit scratch.
61
61
  code review and hands any failure back to you, so running them here only
62
62
  doubles their cost on every build. To confirm a fix for a failure a verify
63
63
  report names, rerun just the failing tests.
64
- 4. Write the manifest's `notesPath` (normally `$AB_CONTEXT_DIR/implement-notes.md`) — what
64
+ 4. Slim the committed tests before finishing. Write as many tests as you need
65
+ to check your work while you build, but every test you commit runs on every
66
+ later build's verify cycle, forever. Before `ab done`, cut the tests this
67
+ build adds or changes down to the set that would catch a regression in this
68
+ change's behavior. Delete or merge the rest:
69
+ - tests that duplicate coverage another test already gives;
70
+ - scaffolding that pinned an intermediate step of the build;
71
+ - assertions on implementation details (private helpers, call order,
72
+ internal shapes) rather than observable behavior;
73
+ - slow tests where a faster one at a narrower seam would fail on the same
74
+ regression.
75
+
76
+ Prefer fewer, faster tests at the narrowest seam that still fails when the
77
+ behavior breaks, and a unit test over an integration test when both would
78
+ catch the regression. Keep every test the spec or plan names as a lasting
79
+ regression test unless you record why it was dropped. Touch only tests in
80
+ this build's own diff; low-value tests elsewhere in the suite are out of
81
+ scope, so record them with `ab observe --kind refactor`.
82
+ 5. Write the manifest's `notesPath` (normally `$AB_CONTEXT_DIR/implement-notes.md`) — what
65
83
  you did, where you deviated from the plan and why, what the reviewer should
66
- look at hardest — then run `ab done --notes <notesPath>`. The notes bytes
84
+ look at hardest, and which tests you slimmed (what you deleted or merged and
85
+ why) — then run `ab done --notes <notesPath>`. The notes bytes
67
86
  reach the store only through this flag; the file is never committed.
68
87
 
69
88
  `ab done` requires a **clean worktree** (everything committed) and the
@@ -124,8 +143,8 @@ first: it says why the number matters and what must not change while it moves.
124
143
  ## Ground rules for this phase
125
144
 
126
145
  - **The spec bounds your work.** When you spot something outside its scope —
127
- a neighbouring bug, a refactor that would pay off later, tests missing
128
- elsewhere — log it instead of fixing it:
146
+ a neighbouring bug, a refactor that would pay off later, tests missing or
147
+ low-value elsewhere — log it instead of fixing it:
129
148
 
130
149
  ```
131
150
  ab observe --kind latent-bug --files src/auth.ts "…"