@defrex/autobuild 1.8.1 → 1.10.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 (429) hide show
  1. package/README.md +3 -3
  2. package/SPEC.md +1602 -134
  3. package/bin/ab-dispatch-generation.ts +2 -0
  4. package/docs/agent-runtimes.md +30 -3
  5. package/docs/answering-blocked-builds.md +15 -7
  6. package/docs/architecture.md +320 -53
  7. package/docs/builds.md +5 -0
  8. package/docs/cli.md +7 -1
  9. package/docs/configuration-overview.md +1 -0
  10. package/docs/configuration.md +515 -49
  11. package/docs/dispatcher-hosting.md +4 -0
  12. package/docs/dispatcher.md +17 -3
  13. package/docs/forges.md +1 -1
  14. package/docs/getting-started.md +1 -1
  15. package/docs/integration-overview.md +4 -2
  16. package/docs/integration-tree.md +102 -11
  17. package/docs/merge-policy.md +70 -14
  18. package/docs/migration-1.0.md +2 -1
  19. package/docs/operating.md +53 -4
  20. package/docs/operator-api.md +128 -16
  21. package/docs/optimization-nodes.md +1042 -0
  22. package/docs/overview.md +1 -1
  23. package/docs/plugin-authoring.md +50 -13
  24. package/docs/remote-store-protocol.md +46 -7
  25. package/docs/remote-ticket-protocol.md +50 -2
  26. package/docs/restacking.md +102 -10
  27. package/docs/seams.md +2 -2
  28. package/docs/setup.md +16 -3
  29. package/docs/skills.md +4 -2
  30. package/docs/spec-standard.md +2 -1
  31. package/docs/ticket-dependencies.md +5 -0
  32. package/docs/ticket-migration.md +4 -2
  33. package/docs/ticket-sources.md +30 -12
  34. package/docs/tickets.md +15 -6
  35. package/docs/troubleshooting.md +3 -2
  36. package/docs/verification.md +18 -6
  37. package/docs/workspaces.md +3 -1
  38. package/package.json +4 -3
  39. package/packages/core/src/accounts/chatgpt-oauth.ts +7 -5
  40. package/packages/core/src/cli/attempt.ts +103 -0
  41. package/packages/core/src/cli/attention.ts +11 -1
  42. package/packages/core/src/cli/binary-direct.ts +52 -1
  43. package/packages/core/src/cli/binary.ts +5 -3
  44. package/packages/core/src/cli/build-control.ts +328 -66
  45. package/packages/core/src/cli/context.ts +268 -15
  46. package/packages/core/src/cli/dashboard/detail.ts +26 -2
  47. package/packages/core/src/cli/dashboard/facts.ts +40 -3
  48. package/packages/core/src/cli/dashboard/integration-detail.ts +7 -2
  49. package/packages/core/src/cli/dashboard/landing-display.ts +24 -3
  50. package/packages/core/src/cli/dashboard/model.ts +127 -33
  51. package/packages/core/src/cli/dashboard/objective-row.ts +189 -0
  52. package/packages/core/src/cli/dashboard/render.ts +49 -3
  53. package/packages/core/src/cli/dashboard/reopen-display.ts +39 -0
  54. package/packages/core/src/cli/dashboard/tree.ts +12 -1
  55. package/packages/core/src/cli/dispatch-frontend.ts +9 -1
  56. package/packages/core/src/cli/dispatch-launch-stop.ts +55 -0
  57. package/packages/core/src/cli/dispatch-launcher.ts +26 -44
  58. package/packages/core/src/cli/dispatch-repository-feed.ts +1 -1
  59. package/packages/core/src/cli/dispatch.ts +136 -5
  60. package/packages/core/src/cli/env.ts +42 -0
  61. package/packages/core/src/cli/help.ts +212 -11
  62. package/packages/core/src/cli/init-agent.ts +4 -1
  63. package/packages/core/src/cli/init-readiness-remote.ts +3 -2
  64. package/packages/core/src/cli/init-validation.ts +2 -2
  65. package/packages/core/src/cli/init.ts +3 -2
  66. package/packages/core/src/cli/judge-entry.ts +82 -0
  67. package/packages/core/src/cli/judge.ts +233 -0
  68. package/packages/core/src/cli/landings.ts +3 -2
  69. package/packages/core/src/cli/main.ts +412 -143
  70. package/packages/core/src/cli/measurement-text.ts +19 -0
  71. package/packages/core/src/cli/objective.ts +154 -0
  72. package/packages/core/src/cli/publication-settlement.ts +106 -22
  73. package/packages/core/src/cli/repo-lease.ts +1 -0
  74. package/packages/core/src/cli/repository-status.ts +179 -19
  75. package/packages/core/src/cli/status.ts +195 -17
  76. package/packages/core/src/cli/store-opening.ts +4 -0
  77. package/packages/core/src/cli/terminals.ts +205 -8
  78. package/packages/core/src/cli/ticket-start.ts +53 -0
  79. package/packages/core/src/cli/ticket.ts +68 -2
  80. package/packages/core/src/cli/upgrade-agent.ts +12 -8
  81. package/packages/core/src/cli/wait.ts +8 -2
  82. package/packages/core/src/cli/watch.ts +1325 -628
  83. package/packages/core/src/config/create-labels.ts +23 -0
  84. package/packages/core/src/config/live.ts +3 -0
  85. package/packages/core/src/config/load.ts +19 -0
  86. package/packages/core/src/config/pipeline-source.ts +1 -3
  87. package/packages/core/src/config/roles.ts +182 -73
  88. package/packages/core/src/config/schema.ts +226 -9
  89. package/packages/core/src/events/catalog.ts +41 -3
  90. package/packages/core/src/events/compatibility.ts +7 -1
  91. package/packages/core/src/events/payloads.ts +610 -1
  92. package/packages/core/src/events/policy.ts +62 -0
  93. package/packages/core/src/events/repository.ts +147 -21
  94. package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +1512 -199
  95. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/0ab2a90d0305dc9d.json.gz +0 -0
  96. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/10a4657408d4e121.json.gz +0 -0
  97. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1152a2e97ee81728.json.gz +0 -0
  98. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/13ca84752c5f8b54.json.gz +0 -0
  99. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1411d1cdbdd9911e.json.gz +0 -0
  100. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1444fe1fa7fc802c.json.gz +0 -0
  101. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1491ac0600349391.json.gz +0 -0
  102. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1921f86f752428c9.json.gz +0 -0
  103. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/1972c1d66008ef6b.json.gz +0 -0
  104. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/19e8e43e7f3f1a06.json.gz +0 -0
  105. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/20a85c143c3e8164.json.gz +0 -0
  106. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/21ce2c0bf58318e1.json.gz +0 -0
  107. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/293dcb3a94fb3470.json.gz +0 -0
  108. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/2ab7436356267118.json.gz +0 -0
  109. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/2d084641735caaff.json.gz +0 -0
  110. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3237bcecf68e5db9.json.gz +0 -0
  111. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/33d0cc593610e56f.json.gz +0 -0
  112. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3451ed2136dcc356.json.gz +0 -0
  113. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/358ec8693f2237e6.json.gz +0 -0
  114. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/35cf9ccc4478b2d2.json.gz +0 -0
  115. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3649e7bd1203f154.json.gz +0 -0
  116. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/378da6dece82202a.json.gz +0 -0
  117. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/38c75099d9191471.json.gz +0 -0
  118. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/398952f1f01db1a3.json.gz +0 -0
  119. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3b64d352d56c9121.json.gz +0 -0
  120. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/3dc486226c05372d.json.gz +0 -0
  121. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/431c9bb2ee8838e0.json.gz +0 -0
  122. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4400dffca929e2f0.json.gz +0 -0
  123. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/49064fc079964a5c.json.gz +0 -0
  124. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4edded75f17742f4.json.gz +0 -0
  125. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4f00c0f2c8afd159.json.gz +0 -0
  126. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/516a5a7aadf97587.json.gz +0 -0
  127. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/516dc6ea85d67cd7.json.gz +0 -0
  128. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/584e2ba74608e051.json.gz +0 -0
  129. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/59ffaa6974094c72.json.gz +0 -0
  130. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/5bb43afb121674c6.json.gz +0 -0
  131. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/5f0ca42af862c4ee.json.gz +0 -0
  132. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6118031132db9bfc.json.gz +0 -0
  133. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/63107a8d58776b63.json.gz +0 -0
  134. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/63546b08d4d6fa11.json.gz +0 -0
  135. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/643d70429ce03dad.json.gz +0 -0
  136. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/677ea92572c29082.json.gz +0 -0
  137. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6ae5bf60504d6467.json.gz +0 -0
  138. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6efdc8defc75fccb.json.gz +0 -0
  139. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/71c53d33f09d8204.json.gz +0 -0
  140. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/7267ca2757cffba7.json.gz +0 -0
  141. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/76b7d4244082b3f9.json.gz +0 -0
  142. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/7749f918c6f10968.json.gz +0 -0
  143. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/7833e42d16301424.json.gz +0 -0
  144. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/7d4edad0614adaf1.json.gz +0 -0
  145. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/837365898d04f45a.json.gz +0 -0
  146. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/85f9f0c921b8b5bb.json.gz +0 -0
  147. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8879f57a24733897.json.gz +0 -0
  148. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/88cb9e71bdec972d.json.gz +0 -0
  149. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8a0cd6dd06cc155e.json.gz +0 -0
  150. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8aa9ca8609dc051d.json.gz +0 -0
  151. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8c8640255bd61658.json.gz +0 -0
  152. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8cc15eb1807c0157.json.gz +0 -0
  153. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8ced97c44bc0af3a.json.gz +0 -0
  154. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8d4144004720b9f8.json.gz +0 -0
  155. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8db633ead1807f8b.json.gz +0 -0
  156. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/8e42cdbd0994ab0c.json.gz +0 -0
  157. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9011d0f6ff955ef9.json.gz +0 -0
  158. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/916ebc5433801c41.json.gz +0 -0
  159. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9539b995af5c54a9.json.gz +0 -0
  160. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/95f391bfd7b7dbd7.json.gz +0 -0
  161. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9613e8fa568a9281.json.gz +0 -0
  162. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9a68f8753bd9038d.json.gz +0 -0
  163. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9b25e58227080094.json.gz +0 -0
  164. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/9ee3919fbd4f9458.json.gz +0 -0
  165. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a04a34cc2717147b.json.gz +0 -0
  166. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a0b32c12e4e6edb6.json.gz +0 -0
  167. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a55218252707bdd3.json.gz +0 -0
  168. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a732fd08b31522a6.json.gz +0 -0
  169. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a9d206a01f9039e5.json.gz +0 -0
  170. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/abf7fe3c92c82f2d.json.gz +0 -0
  171. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ac928b04842c00db.json.gz +0 -0
  172. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/af953392d81911da.json.gz +0 -0
  173. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/b0d877c44810ecb0.json.gz +0 -0
  174. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/b0f7c6ebb2db57fc.json.gz +0 -0
  175. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/b905c22ec17eed31.json.gz +0 -0
  176. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/bce0c54e865f4b79.json.gz +0 -0
  177. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/c68b7ee2e2610f30.json.gz +0 -0
  178. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/c7f7e0378aeea237.json.gz +0 -0
  179. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/c98cb1659eb142b6.json.gz +0 -0
  180. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ca830adf06ed55a1.json.gz +0 -0
  181. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/cb3a219f33e437ca.json.gz +0 -0
  182. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/cf1e0c0d82567e0c.json.gz +0 -0
  183. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d008d86d9ff77b30.json.gz +0 -0
  184. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d1432a819d8e48c5.json.gz +0 -0
  185. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d185ed6aa9192aff.json.gz +0 -0
  186. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d873fad29d6c7e55.json.gz +0 -0
  187. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/db84b12316e2da4a.json.gz +0 -0
  188. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ddf6dc967d898767.json.gz +0 -0
  189. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/dfc64de6e7bfc0a0.json.gz +0 -0
  190. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e2f18fa32fe1f6d0.json.gz +0 -0
  191. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e37393fed29e84c5.json.gz +0 -0
  192. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e6a8585e2a054ff6.json.gz +0 -0
  193. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e7e9e327baca6903.json.gz +0 -0
  194. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/e86447af0571672c.json.gz +0 -0
  195. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ea819202d22122e5.json.gz +0 -0
  196. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/eb4535585f2e84f6.json.gz +0 -0
  197. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/eb7ddd5319d09e27.json.gz +0 -0
  198. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/eca4959b2b87ae15.json.gz +0 -0
  199. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ee10d7959ec4843c.json.gz +0 -0
  200. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/ef1b68347966ab26.json.gz +0 -0
  201. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f3e55425cc41f230.json.gz +0 -0
  202. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f40042c1cdb9fd43.json.gz +0 -0
  203. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f48466215c790a3f.json.gz +0 -0
  204. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f5b9ace9b59351e7.json.gz +0 -0
  205. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/fa8f1475a55be935.json.gz +0 -0
  206. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/fb21116a15d0b1f1.json.gz +0 -0
  207. package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/fe95444fbeabe592.json.gz +0 -0
  208. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/09bf0a1611d07363.json +984 -0
  209. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/10eac4988d66e161.json +1067 -0
  210. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/1a436b5fb45aee3e.json +1116 -0
  211. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/249db6f7a41f90e2.json +161 -0
  212. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/25dcb2fb6eaa83f4.json +858 -0
  213. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/2e1bdc763924616f.json +4932 -0
  214. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/30e9dabce3c4263d.json +399 -0
  215. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/4898ef339c68fa36.json +83 -0
  216. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/51816c0ffa62af6e.json +417 -0
  217. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/561bf45320062a44.json +83 -0
  218. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/5672d0233085d050.json +84 -0
  219. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/5e39f42cbdbf35ef.json +163 -0
  220. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/7771a7a2250f9964.json +868 -0
  221. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/881c491321bec99a.json +1074 -0
  222. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/965f25c3af1d2cdc.json +160 -0
  223. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/9b76d89da575ca90.json +20 -0
  224. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/9eb485320a72a9ff.json +233 -0
  225. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a60448c01016135e.json +18 -0
  226. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a6584fb61b6679bd.json +97 -0
  227. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/c88365c25b3186d3.json +543 -0
  228. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/e8f0481b23f90056.json +711 -0
  229. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/ee55782ed40ebbac.json +110 -0
  230. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fc5082fac8167f3d.json +98 -0
  231. package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fd55c329cfe921cc.json +1069 -0
  232. package/packages/core/src/kernel/attempt-creation-key.ts +20 -0
  233. package/packages/core/src/kernel/attempt-settlement.ts +125 -0
  234. package/packages/core/src/kernel/auto-merge-default.ts +1 -3
  235. package/packages/core/src/kernel/auto-merge.ts +34 -3
  236. package/packages/core/src/kernel/dispatch-capacity.ts +312 -38
  237. package/packages/core/src/kernel/dispatch-placement.ts +1 -1
  238. package/packages/core/src/kernel/dispatch-settings.ts +1 -4
  239. package/packages/core/src/kernel/dispatch-status.ts +3 -5
  240. package/packages/core/src/kernel/dispatch-upgrade.ts +1 -1
  241. package/packages/core/src/kernel/engine.ts +109 -13
  242. package/packages/core/src/kernel/forge-checks.ts +140 -0
  243. package/packages/core/src/kernel/forge-health.ts +2 -2
  244. package/packages/core/src/kernel/generated-files.ts +43 -0
  245. package/packages/core/src/kernel/generated-regeneration.ts +254 -0
  246. package/packages/core/src/kernel/generators/build-log.ts +30 -2
  247. package/packages/core/src/kernel/generators/optimization-log.ts +578 -0
  248. package/packages/core/src/kernel/generators/panel-log.ts +133 -0
  249. package/packages/core/src/kernel/generators/repository-journals.ts +18 -0
  250. package/packages/core/src/kernel/guarded-forge.ts +76 -11
  251. package/packages/core/src/kernel/harvest.ts +1 -4
  252. package/packages/core/src/kernel/head-paths.ts +4 -1
  253. package/packages/core/src/kernel/history-retention.ts +337 -0
  254. package/packages/core/src/kernel/incremental-fixtures.ts +6 -0
  255. package/packages/core/src/kernel/incremental.ts +14 -4
  256. package/packages/core/src/kernel/integration-landing.ts +64 -13
  257. package/packages/core/src/kernel/integration-stack.ts +123 -20
  258. package/packages/core/src/kernel/integration-state.ts +39 -2
  259. package/packages/core/src/kernel/janitor-failure.ts +2 -0
  260. package/packages/core/src/kernel/kernel-git.ts +1 -1
  261. package/packages/core/src/kernel/landing-measurement.ts +275 -0
  262. package/packages/core/src/kernel/landing-readiness.ts +2 -0
  263. package/packages/core/src/kernel/landing-state.ts +76 -1
  264. package/packages/core/src/kernel/leaf-restack-state.ts +17 -1
  265. package/packages/core/src/kernel/log-index-value.ts +2 -0
  266. package/packages/core/src/kernel/log-index.ts +81 -3
  267. package/packages/core/src/kernel/measurement.ts +406 -0
  268. package/packages/core/src/kernel/mixed-version.ts +6 -3
  269. package/packages/core/src/kernel/node-landing.ts +92 -18
  270. package/packages/core/src/kernel/node-restack-state.ts +27 -1
  271. package/packages/core/src/kernel/node-restack-transaction.ts +80 -23
  272. package/packages/core/src/kernel/node-verification-context.ts +14 -4
  273. package/packages/core/src/kernel/open-pr-backpressure-state.ts +24 -0
  274. package/packages/core/src/kernel/open-pr-backpressure.ts +133 -0
  275. package/packages/core/src/kernel/optimization-admission.ts +249 -0
  276. package/packages/core/src/kernel/optimization.ts +774 -0
  277. package/packages/core/src/kernel/panel.ts +225 -0
  278. package/packages/core/src/kernel/phases.ts +42 -6
  279. package/packages/core/src/kernel/pr-attachments.ts +4 -16
  280. package/packages/core/src/kernel/pr-summary.ts +2 -2
  281. package/packages/core/src/kernel/read-deferrals.ts +2 -2
  282. package/packages/core/src/kernel/read-facts.ts +69 -31
  283. package/packages/core/src/kernel/reconcile-restack.ts +352 -103
  284. package/packages/core/src/kernel/reducer-identity.ts +659 -0
  285. package/packages/core/src/kernel/reducer-registry.ts +37 -3
  286. package/packages/core/src/kernel/reducer-revisions.ts +50 -0
  287. package/packages/core/src/kernel/reducer.ts +208 -9
  288. package/packages/core/src/kernel/reopen-state.ts +48 -0
  289. package/packages/core/src/kernel/reopen.ts +143 -0
  290. package/packages/core/src/kernel/replay-retention.ts +208 -39
  291. package/packages/core/src/kernel/repository-attention.ts +1 -1
  292. package/packages/core/src/kernel/service-facts.ts +19 -7
  293. package/packages/core/src/kernel/terminal-guard.ts +13 -5
  294. package/packages/core/src/kernel/ticket-handbacks.ts +1 -1
  295. package/packages/core/src/kernel/ticket-migrations.ts +1 -1
  296. package/packages/core/src/kernel/ticket-preparation.ts +1 -1
  297. package/packages/core/src/kernel/ticket-source-health.ts +1 -1
  298. package/packages/core/src/kernel/ticket-starts.ts +118 -0
  299. package/packages/core/src/kernel/ticket-wait.ts +37 -2
  300. package/packages/core/src/kernel/verify-diff-base.ts +62 -0
  301. package/packages/core/src/kernel/verify-stage-state.ts +1 -0
  302. package/packages/core/src/kernel/verify-stages.ts +41 -1
  303. package/packages/core/src/objective.ts +532 -0
  304. package/packages/core/src/ontology.ts +49 -6
  305. package/packages/core/src/operator/annotations.ts +35 -4
  306. package/packages/core/src/operator/control.ts +2 -1
  307. package/packages/core/src/operator/index.ts +12 -0
  308. package/packages/core/src/operator/optimization.ts +307 -0
  309. package/packages/core/src/operator/protocol.ts +30 -1
  310. package/packages/core/src/operator/query.ts +15 -1
  311. package/packages/core/src/operator/registry.ts +219 -13
  312. package/packages/core/src/operator/requests.ts +25 -2
  313. package/packages/core/src/operator/ticket-start.ts +152 -0
  314. package/packages/core/src/operator/tickets.ts +3 -2
  315. package/packages/core/src/plugin-sdk/index.ts +9 -1
  316. package/packages/core/src/plugins/registry.ts +1 -0
  317. package/packages/core/src/ports/forge/contract.ts +9 -0
  318. package/packages/core/src/ports/forge/fake.ts +151 -10
  319. package/packages/core/src/ports/forge/git-rewrite.ts +38 -5
  320. package/packages/core/src/ports/forge/github-readiness.ts +1 -1
  321. package/packages/core/src/ports/forge/github-squash-message.ts +89 -0
  322. package/packages/core/src/ports/forge/github-transport.ts +186 -1
  323. package/packages/core/src/ports/forge/github.ts +846 -239
  324. package/packages/core/src/ports/forge/readiness.ts +15 -3
  325. package/packages/core/src/ports/forge-failure.ts +22 -0
  326. package/packages/core/src/ports/forge-request-context.ts +23 -1
  327. package/packages/core/src/ports/forge-telemetry.ts +16 -0
  328. package/packages/core/src/ports/runner/antigravity.ts +1071 -0
  329. package/packages/core/src/ports/runner/claude.ts +6 -1
  330. package/packages/core/src/ports/runner/codex.ts +11 -2
  331. package/packages/core/src/ports/runner/contract.ts +25 -1
  332. package/packages/core/src/ports/runner/fake.ts +2 -2
  333. package/packages/core/src/ports/runner/native-cli-fixture.ts +40 -5
  334. package/packages/core/src/ports/runner/native-process-fixture.ts +4 -1
  335. package/packages/core/src/ports/runner/pi.ts +23 -7
  336. package/packages/core/src/ports/runner/production.ts +19 -2
  337. package/packages/core/src/ports/runner/session-env.ts +65 -5
  338. package/packages/core/src/ports/runner/start-prompt.ts +6 -4
  339. package/packages/core/src/ports/tickets/contract.ts +4 -2
  340. package/packages/core/src/ports/tickets/github.ts +20 -5
  341. package/packages/core/src/ports/tickets/hosted-index.ts +6 -1
  342. package/packages/core/src/ports/tickets/labels.ts +21 -0
  343. package/packages/core/src/ports/tickets/linear.ts +33 -0
  344. package/packages/core/src/ports/tickets/migration.ts +2 -0
  345. package/packages/core/src/ports/tickets/priority.ts +11 -0
  346. package/packages/core/src/ports/tickets/remote-protocol.ts +71 -6
  347. package/packages/core/src/ports/tickets/remote.ts +138 -16
  348. package/packages/core/src/ports/tickets/tree.ts +17 -4
  349. package/packages/core/src/ports/types.ts +145 -7
  350. package/packages/core/src/ports/workspace/builtin-capabilities.ts +7 -4
  351. package/packages/core/src/ports/workspace/commit-preservation.ts +182 -64
  352. package/packages/core/src/ports/workspace/create.ts +3 -0
  353. package/packages/core/src/ports/workspace/git-worktree.ts +13 -1
  354. package/packages/core/src/ports/workspace/vercel-sandbox.ts +242 -61
  355. package/packages/core/src/processes/build-execution-state.ts +5 -6
  356. package/packages/core/src/processes/build-runner.ts +1435 -132
  357. package/packages/core/src/processes/dispatch-failure-budget.ts +1 -1
  358. package/packages/core/src/processes/dispatcher-selectors.ts +15 -13
  359. package/packages/core/src/processes/dispatcher.ts +2874 -266
  360. package/packages/core/src/processes/execution-no-progress.ts +38 -1
  361. package/packages/core/src/processes/execution-settlement.ts +2 -6
  362. package/packages/core/src/processes/harvest-execution-state.ts +2 -6
  363. package/packages/core/src/processes/harvest-runner.ts +7 -2
  364. package/packages/core/src/processes/hook-command.ts +125 -0
  365. package/packages/core/src/processes/hook-webhook.ts +144 -0
  366. package/packages/core/src/processes/hooks.ts +740 -0
  367. package/packages/core/src/processes/infrastructure-failure-budget.ts +1 -3
  368. package/packages/core/src/processes/judge-launcher.ts +38 -0
  369. package/packages/core/src/processes/measurement-runner.ts +235 -0
  370. package/packages/core/src/processes/optimization-merges.ts +101 -0
  371. package/packages/core/src/processes/optimization-stop.ts +179 -0
  372. package/packages/core/src/processes/panel-runner.ts +756 -0
  373. package/packages/core/src/processes/phase-failure-budget.ts +1 -0
  374. package/packages/core/src/processes/publication-state.ts +1 -4
  375. package/packages/core/src/processes/repo-view.ts +77 -5
  376. package/packages/core/src/processes/sandbox-state.ts +1 -4
  377. package/packages/core/src/processes/tick-state.ts +1 -3
  378. package/packages/core/src/processes/workspace-preservation.ts +67 -9
  379. package/packages/core/src/scenarios/harness.ts +19 -8
  380. package/packages/core/src/store/contract.ts +72 -0
  381. package/packages/core/src/store/digest.ts +89 -7
  382. package/packages/core/src/store/judge-authority.ts +161 -0
  383. package/packages/core/src/store/phase-session.ts +226 -4
  384. package/packages/core/src/store/reduced-reads.ts +10 -0
  385. package/packages/core/src/store/reducer-value-shapes.json +17254 -11861
  386. package/packages/core/src/store/remote/client.ts +12 -2
  387. package/packages/core/src/store/remote/credentials.ts +31 -1
  388. package/packages/core/src/store/remote/index.ts +8 -0
  389. package/packages/core/src/store/remote/protocol.ts +38 -0
  390. package/packages/core/src/store/remote/released-clients.json +22 -0
  391. package/packages/core/src/store/remote/released-reducer-values/1.10.0.json +34439 -0
  392. package/packages/core/src/store/remote/released-reducer-values/1.9.0.json +29475 -0
  393. package/packages/core/src/store/remote/released-reducer-values/index.ts +18 -14
  394. package/packages/core/src/store/remote/token.ts +13 -4
  395. package/packages/core/src/store/repo-state-events.ts +9 -8
  396. package/packages/core/src/store/retention.ts +16 -2
  397. package/packages/core/src/store/session-reducer.ts +1 -4
  398. package/packages/core/src/store/ticket-assets.ts +1 -3
  399. package/packages/core/src/store/types.ts +9 -0
  400. package/packages/core/src/testing/dispatch-read-budget.ts +70 -0
  401. package/packages/core/src/testing/git-config-isolation.ts +25 -0
  402. package/packages/core/src/testing/index.ts +14 -0
  403. package/packages/core/src/testing/reduced-read-budget.ts +3950 -54
  404. package/skills/code-review/SKILL.md +16 -0
  405. package/skills/finalize/SKILL.md +10 -4
  406. package/skills/guide/SKILL.md +464 -83
  407. package/skills/guide/references/integration-tree.md +102 -11
  408. package/skills/guide/references/merge-policy.md +70 -14
  409. package/skills/guide/references/migration-1.0.md +2 -1
  410. package/skills/guide/references/operator-api.md +128 -16
  411. package/skills/guide/references/optimization-nodes.md +1042 -0
  412. package/skills/guide/references/plugin-authoring.md +50 -13
  413. package/skills/guide/references/remote-store-protocol.md +46 -7
  414. package/skills/guide/references/remote-ticket-protocol.md +50 -2
  415. package/skills/guide/references/restacking.md +102 -10
  416. package/skills/guide/references/setup.md +16 -3
  417. package/skills/guide/references/spec-standard.md +2 -1
  418. package/skills/guide/references/ticket-dependencies.md +5 -0
  419. package/skills/guide/references/ticket-migration.md +4 -2
  420. package/skills/implement/SKILL.md +51 -1
  421. package/skills/judge/SKILL.md +43 -0
  422. package/skills/operate/SKILL.md +267 -32
  423. package/skills/plan/SKILL.md +18 -0
  424. package/skills/plan-review/SKILL.md +15 -1
  425. package/skills/propose/SKILL.md +121 -0
  426. package/skills/reconcile/SKILL.md +21 -2
  427. package/skills/spec/SKILL.md +30 -4
  428. package/skills/tickets/SKILL.md +44 -5
  429. package/templates/hosted-service/package.json +2 -2
@@ -0,0 +1,1042 @@
1
+ ---
2
+ title: "Optimization nodes"
3
+ group: "concepts"
4
+ description: "Let a node propose, measure and land its own attempts toward a metric or a judge panel, within a budget you approve once."
5
+ label: "Optimization"
6
+ order: 4.5
7
+ ---
8
+
9
+ # Optimization nodes
10
+
11
+ An optimization node is a node whose spec declares an objective: a metric, a
12
+ direction or a judge panel, a target, a budget and a purpose. Instead of
13
+ collecting children a human filed, it proposes its own attempts, measures each
14
+ one against its current head with a ruler the attempts cannot edit, lands only
15
+ the ones that improve it, and moves the rest to the rejected role. It stops on
16
+ a threshold, a plateau, its budget or your word, and then lands like any other
17
+ node, once you approve it.
18
+
19
+ This page covers when to use one, how a run goes from start to finish, how to
20
+ write the objective, and then the full contract: how the marker is found, what
21
+ refuses an objective, how a node and its attempts are measured, how the
22
+ objective is revised, which facts the log records, what is derived from them,
23
+ how the node proposes its own attempts, and how it stops and completes. The
24
+ objective is the only marker. The ticket's `kind` stays `node`, and no label,
25
+ ticket state or source setting marks it. Because the marker makes a node file
26
+ and dispatch its own work, the rules below leave no room for a false positive
27
+ and no silent fallback in either direction.
28
+
29
+ ## When to use one
30
+
31
+ Use an optimization node when:
32
+
33
+ - the goal is to improve a number, or a judgment two variants can be compared
34
+ on, rather than to ship a known change;
35
+ - you don't know which strategy will work, and many independent tries are
36
+ cheaper than deciding up front;
37
+ - a harness that attempts cannot edit can measure the code being improved.
38
+
39
+ Don't use one when the change is already known (file a work ticket or a plain
40
+ node), when two identical runs disagree by more than the gain you care about
41
+ (see the noise check under [opening](#opening)), when success needs
42
+ product judgment no rubric captures, or when your ticket source has no
43
+ rejected role.
44
+
45
+ ## A run, end to end
46
+
47
+ 1. You groom the node ticket with an objective block; see
48
+ [grooming an optimization node](#grooming-an-optimization-node).
49
+ 2. The dispatcher [opens](#opening) the node and pins the harness at its
50
+ opening commit.
51
+ 3. The node measures its opening head against itself for a starting value and
52
+ runs the [noise check](#opening).
53
+ 4. The [proposer](#proposer-phase) reads the objective and the ledger of
54
+ earlier attempts and proposes strategies; the dispatcher files each as a
55
+ ready attempt ticket that targets the node.
56
+ 5. Each [attempt](#attempts) builds like any work ticket: plan, review,
57
+ implement, review, verify.
58
+ 6. The [landing gate](#landing-and-settlement) measures each attempt against
59
+ the current node head, ratchet-style. An attempt lands only when it
60
+ improves the head; a sibling that lands first makes the others measure
61
+ again.
62
+ 7. Attempts that don't improve the head, or that their implementer declines,
63
+ close unmerged and their tickets move to the rejected role.
64
+ 8. The node [stops](#stopping-and-completion) on its threshold, a plateau,
65
+ its budget, an empty proposal or your `ab objective <node> --stop`.
66
+ 9. Once nothing is in flight, the node completes and verifies.
67
+ 10. You [land it](#landing-the-node) with `ab merge <node>`.
68
+
69
+ ## The marker
70
+
71
+ A node becomes an optimization node only when its spec carries exactly one
72
+ fenced block whose info string is exactly `autobuild-objective`.
73
+
74
+ The scan follows CommonMark fences:
75
+
76
+ - A fence opens on a line indented at most three spaces with three or more
77
+ backticks or tildes, and closes on a line of the same character, at least as
78
+ long, carrying no info string.
79
+ - Only a fence whose trimmed info string equals `autobuild-objective`,
80
+ case-sensitively, counts.
81
+ - A backtick line whose info string contains a backtick is inline code, not a
82
+ fence.
83
+
84
+ None of these count:
85
+
86
+ - a fence nested inside another open fence, so a Markdown example that shows
87
+ the block (as below) never marks the spec that contains it;
88
+ - a fence line that begins with a blockquote or list marker, or is indented
89
+ four or more spaces;
90
+ - a fence inside an HTML block, such as an HTML comment, so a commented-out
91
+ example never counts;
92
+ - a heading named "Objective";
93
+ - a `toml` block, or a fence with any other info string, such as
94
+ `Autobuild-Objective` or `autobuild-objective toml`;
95
+ - prose describing an objective, and inline code.
96
+
97
+ A node spec with no block is a plain node. A work ticket that carries the
98
+ block is refused at dispatch; see [Refusals](#refusals).
99
+
100
+ ## The objective
101
+
102
+ The block's content is TOML. This command objective is valid as written:
103
+
104
+ ````markdown
105
+ ```autobuild-objective
106
+ purpose = """
107
+ p95 latency of the catalog search query, because users wait on it at every
108
+ keystroke. Results, their order and the query's semantics must not change.
109
+ """
110
+
111
+ [metric]
112
+ kind = "command" # or "panel"
113
+ command = "bun bench/search.ts" # prints one JSON object: {"value": <number>}
114
+ direction = "minimize"
115
+ samples = 7 # paired runs per side
116
+ harness = ["bench/search/**", "bench/fixtures/catalog.sql"]
117
+
118
+ [target]
119
+ threshold = 40 # milliseconds; optional
120
+ epsilon = { relative = 0.03 } # or { absolute = 2 }
121
+
122
+ [budget] # at least one limit is required
123
+ maxAttempts = 60
124
+ maxHours = 24
125
+
126
+ [stop]
127
+ plateau = { attempts = 12 } # optional
128
+ mode = "abort" # or "drain"; default "abort"
129
+
130
+ [proposer]
131
+ concurrency = 4 # attempts in flight
132
+ ```
133
+ ````
134
+
135
+ A panel replaces the metric for work without a mechanical measure. Judges
136
+ compare two variants and state a preference, so a panel always maximizes a win
137
+ rate:
138
+
139
+ ```toml
140
+ [metric]
141
+ kind = "panel"
142
+ judges = 5
143
+ rubric = "evals/prose-rubric.md" # a harness path
144
+ harness = ["evals/**"]
145
+ ```
146
+
147
+ ### Schema
148
+
149
+ Every table is strict: an unknown key is refused and named, for example
150
+ `unknown field metric.cmd`. The stored objective is the normalized form, with
151
+ defaults applied.
152
+
153
+ | Field | Required | Constraint | Default |
154
+ |---|---|---|---|
155
+ | `purpose` | yes | Nonblank string. | — |
156
+ | `metric.kind` | yes | `"command"` or `"panel"`. | — |
157
+ | `metric.command` | command | Nonblank string. Refused for a panel. | — |
158
+ | `metric.direction` | command | `"minimize"` or `"maximize"`. Refused for a panel. | — |
159
+ | `metric.samples` | command | Integer from 1 to 100. Refused for a panel. | — |
160
+ | `metric.judges` | panel | Integer from 1 to 20. Refused for a command. | — |
161
+ | `metric.rubric` | panel | A literal repository-relative path, no `*` or `?`, matched by `metric.harness`. Refused for a command. | — |
162
+ | `metric.harness` | yes | Nonempty array of path selectors (below). | — |
163
+ | `target.epsilon` | yes | Exactly one of `{ absolute = n }` with n > 0, or `{ relative = n }` with 0 < n < 1. A panel accepts only an absolute value below 0.5. | — |
164
+ | `target.threshold` | no | A number. A panel threshold is a win rate in (0.5, 1]. | none |
165
+ | `budget.maxAttempts` | at least one | Integer ≥ 1. | none |
166
+ | `budget.maxHours` | at least one | Number > 0. | none |
167
+ | `stop.plateau.attempts` | no | Integer ≥ 1. | none |
168
+ | `stop.mode` | no | `"abort"` or `"drain"`. | `"abort"` |
169
+ | `proposer.concurrency` | no | Integer ≥ 1. | `1` |
170
+
171
+ Harness entries are path selectors, the grammar `[[merge]]` and verify `paths`
172
+ already use: positive, repository-relative, case-sensitive Git-style globs made
173
+ of literal characters, `*`, `?` and whole-segment `**`. Absolute paths,
174
+ backslashes, negation, empty or `.`/`..` segments, character classes, braces
175
+ and extglobs are refused, naming the entry, for example
176
+ `metric.harness[1]: path selectors must be repository-relative`.
177
+
178
+ ## Refusals
179
+
180
+ Each refusal names its reason:
181
+
182
+ | Condition | Reason |
183
+ |---|---|
184
+ | Two or more blocks | `exactly one autobuild-objective block (found N)` |
185
+ | A block never closed | `a valid autobuild-objective block: the fence is never closed` |
186
+ | A TOML syntax error | `a valid autobuild-objective block: TOML syntax error at line L: …` |
187
+ | A schema failure | `a valid autobuild-objective block: <field>: <message>`, for example `metric.rubric: must be inside metric.harness` |
188
+ | No budget limit | `a budget limit in the autobuild-objective block: set budget.maxAttempts or budget.maxHours` |
189
+ | No rejected role in the ticket source | `a rejected role for optimization attempts: set [tickets].rejectedState` |
190
+ | A work ticket carrying the block | `no autobuild-objective block in a work ticket: the block marks an optimization node (file it with --kind node)` |
191
+
192
+ The dispatcher checks the ticket body when it prepares a claimed ticket, before
193
+ any spec authoring. A refusal bounces the ticket back to triage with a comment
194
+ naming every reason and creates no build. A refused node never opens as a plain
195
+ node instead. Fix the block, or file the ticket with `--kind node`, and move it
196
+ to ready again.
197
+
198
+ ## Grooming an optimization node
199
+
200
+ The node ticket is still a spec-standard charter, with what and why,
201
+ acceptance criteria, out of scope and evidence. The block adds what to
202
+ improve and when to stop.
203
+
204
+ ### Writing the purpose
205
+
206
+ Write the purpose for an agent that will try to game the number. Say why
207
+ the metric matters, what it stands in for, and what must not change while it
208
+ moves: behavior, output, semantics, interfaces. "p95 latency of catalog search,
209
+ because users wait on it at every keystroke; results and their order must not
210
+ change" is a purpose. "Make search faster" is not.
211
+
212
+ ### Choosing the harness
213
+
214
+ Choose the harness as everything that decides the number. Include the
215
+ measurement command's script, its fixtures and datasets, and a panel's rubric.
216
+ The harness is the ruler, pinned at the node's opening commit (`harnessPin`),
217
+ not the code under improvement, so leave that code out. Keep selectors narrow:
218
+ a harness that covers the code being optimized pins the very code attempts are
219
+ meant to change.
220
+
221
+ ### Choosing ε and the noise check
222
+
223
+ Choose ε above the noise. ε is the smallest gain worth landing. Run the
224
+ command several times on the same tree first. If the median moves by more than
225
+ your ε between identical runs, raise ε or `samples`. The node checks this when
226
+ it opens: its starting measurement raises `optimization.noise-exceeded` when ε
227
+ is below the measured spread. A panel node judges its opening head against
228
+ itself the same way; raise ε or `judges` if that panel strays from 0.5 by more
229
+ than ε. A relative ε suits
230
+ metrics whose scale may change; an absolute ε suits metrics with a natural
231
+ unit. A panel's ε is a win-rate margin above 0.5, such as 0.1.
232
+
233
+ When the check fires, `ab watch` reports the node's
234
+ `optimization.noise-exceeded` as attention, naming ε and the spread. The node
235
+ still opens and runs. Raise ε in place with `ab objective <node> --epsilon …`
236
+ (see [revisions](#revisions)), or raise `samples` or `judges` with a spec
237
+ revision, before the gate starts accepting noise.
238
+
239
+ ### Writing a panel rubric
240
+
241
+ Write a panel's rubric for comparing two variants. Judges see two
242
+ variants side by side and say which is better, so write criteria a reader can
243
+ apply to a pair: "which explains the setup steps in fewer, clearer sentences"
244
+ compares; "scores 1–10 on clarity" does not. Name what must not be traded away,
245
+ and say that text written for the judges rather than for the reader counts
246
+ against a variant. Keep the rubric and any fixtures the judges read inside the
247
+ harness, so the pin fixes them. Choose `judges` for cost against noise: each
248
+ judge costs one agent session per comparison when its primary target succeeds,
249
+ and more judges narrow the win rate's spread. A judge that falls back to
250
+ provider alternates, or is retried after a failure, runs one more session for
251
+ each alternate or retry. Five suits most prose; use more when a single preference
252
+ should not decide an ε of 0.1. See [judge panels](#judge-panels).
253
+
254
+ ### Choosing a budget
255
+
256
+ Choose a budget you would sign off on unattended. It is the limit a human
257
+ approves once for the whole run. `maxAttempts` bounds cost; `maxHours` bounds wall-clock
258
+ time. Set a plateau when a run of failed strategies should end the search
259
+ early. Set a threshold only when there is a value at which you would stop
260
+ looking. Use `concurrency` above 1 only when attempts are independent enough to
261
+ run side by side.
262
+
263
+ ### Configure the rejected role
264
+
265
+ Configure the rejected role first. The ticket source must name
266
+ `[tickets].rejectedState`, or the node is refused. Every attempt that does not
267
+ land ends there.
268
+
269
+ ## Opening
270
+
271
+ Opening an optimization node records `optimization.objective-accepted` with the
272
+ objective, revision 1, a `harnessPin` equal to the node's opening commit, and
273
+ the spec revision it was parsed from. It is recorded before `node.opened`, so an
274
+ opened optimization node always has an accepted objective.
275
+
276
+ Every optimization node then measures its opening head against itself and
277
+ records `optimization.baseline-measured` with the starting value and the noise
278
+ spread. A command node uses the objective's pairing and sample count (see
279
+ [Measurement](#measurement)). A panel node runs one
280
+ [judge panel](#judge-panels) of its harness pin against itself: its starting
281
+ value is 0.5, and its spread is the distance of that self-comparison win rate
282
+ from 0.5. The dispatcher admits that run as it admits a node verification: the
283
+ node takes a runner slot, gets a workspace for the run, and releases it once
284
+ the starting value is recorded.
285
+
286
+ **Noise check.** When ε, in metric units, is smaller than the measured spread,
287
+ the gate would accept noise. A panel's ε is a win-rate margin, compared with
288
+ the self-comparison's distance from 0.5. The node records
289
+ `optimization.noise-exceeded` naming both numbers, which `ab watch` reports as
290
+ attention. The node still opens: raise `target.epsilon` with `ab objective`,
291
+ or raise `metric.samples` (a command) or `metric.judges` (a panel) with a spec
292
+ revision. A relative ε over a starting value of 0 is 0, so any spread exceeds
293
+ it.
294
+
295
+ ## Revisions
296
+
297
+ Two paths change the objective of an open optimization node.
298
+
299
+ **Quick revision.** `ab objective <node>` shows the effective objective and
300
+ progress. Flags revise the knobs that only change when to stop, how much to
301
+ spend or how large a gain must be:
302
+
303
+ ```sh
304
+ ab objective <node> [--threshold n] [--epsilon n|n%] [--max-attempts n] \
305
+ [--max-hours n] [--plateau n] [--stop-mode abort|drain] [--concurrency n] \
306
+ [--json] [--store <ref>]
307
+ ab objective <node> --stop [--drain | --abort] [--json] [--store <ref>]
308
+ ```
309
+
310
+ `--epsilon 2` is absolute; `--epsilon 3%` is relative 0.03. A revision records
311
+ `optimization.objective-revised` with the changes and the next revision, then
312
+ shows the result. The operator tool `optimization.revise` does the same; see the
313
+ [operator API](operator-api.md#optimization-objective-revision). Both refuse a
314
+ build that is not a node, a node with no accepted objective and a terminal node,
315
+ and the revised objective must still validate. Running attempts are unaffected
316
+ and nothing is replanned: the dispatcher checks the revised threshold, budget
317
+ and plateau on its next tick, so lowering the threshold to the current value or
318
+ the budget to what was already spent stops the node then. A stop is final; a
319
+ revision after it is recorded but never resumes proposing. `--stop` is
320
+ described under [stopping and completion](#stopping-and-completion).
321
+
322
+ **Spec revision.** `ab answer <node> --revise-spec <file>` or
323
+ `--revise-spec-from-ticket` changes anything else: the metric, the harness or
324
+ the purpose. The replacement may change the objective, but it must keep exactly
325
+ one valid block:
326
+
327
+ - removing the block from an optimization node is refused; close the node and
328
+ open a new one instead;
329
+ - adding a block to a plain node or a work build is refused;
330
+ - an invalid replacement block is refused, naming the field.
331
+
332
+ A refused revision records nothing. After an accepted one, the dispatcher
333
+ records `optimization.objective-accepted` again with the next revision. When the
334
+ metric changed, or the purpose of a panel (judges read it), it pins the harness
335
+ again at the current node head and starts a new ruler: earlier measurements stay
336
+ in history but are never compared with new ones, and the node measures the new
337
+ pin against itself for a new starting value and noise check; a panel node runs
338
+ a new self-comparison panel. Otherwise the pin is unchanged.
339
+
340
+ A quick revision is never written back to the ticket. `ab ticket show` prints
341
+ the effective objective of an open optimization node and marks each field that
342
+ differs from the ticket's block `(revised)`, so a stale ticket is visible. The
343
+ open build, not the ticket body, decides this: when an edit removes the block or
344
+ leaves it invalid, every field is marked.
345
+ `ab ticket tree` labels the ticket `[node, optimization]`, and status labels the
346
+ build `optimization node`.
347
+
348
+ ## Measurement
349
+
350
+ A measurement compares two heads in one execution, so both sides run on the
351
+ same hardware. A stored number from another machine is never a baseline.
352
+
353
+ **Pairing.** The measurer makes two detached worktrees, one at the candidate
354
+ and one at the baseline. A round runs the metric command once in each, and
355
+ the rounds alternate which side runs first, so a warming cache or a
356
+ throttling CPU cancels out. There are `samples` rounds. When `[commands].setup`
357
+ is configured, it runs once in each worktree first, because a fresh worktree
358
+ has no installed dependencies.
359
+
360
+ **Harness pinning.** Before any run, every path matched by `metric.harness` is
361
+ overwritten in both worktrees with its contents at `harnessPin`, and a harness
362
+ file the pin lacks is deleted. A candidate that edits the benchmark, or a
363
+ harness change arriving through a node restack, never moves the ruler.
364
+ Attempts can read and run the harness; they cannot change what counts.
365
+
366
+ **Output contract.** Each run must exit 0 and print exactly one JSON object
367
+ whose `value` is a finite number, such as `{"value": 41.7}`. Each run, and each
368
+ setup run, has a 30-minute timeout.
369
+
370
+ **Decision.** The value of a side is the median of its samples. The delta is
371
+ positive for an improvement: `baseline − candidate` when minimizing,
372
+ `candidate − baseline` when maximizing. ε in metric units is the absolute ε,
373
+ or the relative ε times the baseline median's magnitude. A delta of at least ε
374
+ is `improved`; anything less is `no-improvement`. A starting measurement's
375
+ value is the median of all samples, and its spread is the distance between the
376
+ two sides' medians. A panel decides by win rate instead, with ties counted as
377
+ half: a win rate of at least 0.5 + ε is `improved`, so 3 of 5 judges meets an
378
+ ε of 0.1, and anything less is `no-improvement`. Its delta is
379
+ `winRate − 0.5`.
380
+
381
+ **Spread beside every delta.** A command's `attempt.measured` carries the
382
+ node's starting spread as `spread`, and `ab watch` prints it next to the
383
+ delta, such as `delta 6 (noise ±0.4)`. The raw per-sample values, or a
384
+ panel's judgments, are deposited as a `measurement-samples` artifact
385
+ referenced by `report`.
386
+
387
+ **Attempts.** An `attempt.measurement-requested` names the candidate, the
388
+ baseline, the harness pin, the objective revision and the node's metric. A
389
+ panel request also carries the objective's purpose, which its judges read. A
390
+ parked attempt with such a request takes a runner slot as a re-verify does,
391
+ and its runner samples in the attempt's own workspace and records
392
+ `attempt.sampled`. For a panel, the runner runs one [judge
393
+ panel](#judge-panels) of the attempt's head against the node head and records
394
+ the win rate, with the judge count as `samples`. The runner reads only its own
395
+ build, so the dispatcher decides: it reads the node once, checks that the
396
+ request's revision and harness pin are still the node's ruler, and records
397
+ `attempt.measured` using the node's current ε and, for a command, its starting
398
+ spread. A panel decision needs no starting value. A quick ε revision made while
399
+ the samples ran therefore applies. A request whose ruler or pin was replaced
400
+ while it was sampled records no decision; the attempt needs a fresh request.
401
+ A request whose baseline is no longer the node head the attempt last observed
402
+ is skipped before sampling: it takes no slot, and the landing gate requests a
403
+ current pair once the attempt has restacked. The recorded decision and the
404
+ landing gate use the same effective ε, so they always agree.
405
+
406
+ **Failures.** None of these record a value or a decision:
407
+
408
+ - the command exits nonzero, times out, or prints anything other than one
409
+ JSON object with a numeric `value`;
410
+ - a worktree or setup command fails;
411
+ - a judge panel fails: a judge failed twice, or the variants could not be
412
+ prepared;
413
+ - a request names no metric, a panel request names no purpose, or its ruler
414
+ is no longer the node's.
415
+
416
+ Instead, the build escalates with target `measurement` and policy cause
417
+ `measurement-failed`. The question names the cause, the failing sample and
418
+ the output tail. Answering a runner failure measures again; for a panel the
419
+ answer starts a fresh panel, while a crash resumes the same one and keeps its
420
+ judgments. Abort still aborts. A refusal of samples taken under a replaced ruler stays refused after
421
+ the answer, because sampling the same request again cannot succeed.
422
+
423
+ ## Judge panels
424
+
425
+ A panel objective is measured by agent judges instead of a command. A panel
426
+ run compares two heads, a candidate and a baseline, under one harness pin, and
427
+ returns the candidate's win rate. A panel node runs one for its starting
428
+ measurement (its pin against itself; see [Opening](#opening)) and one for its
429
+ progress after each accepted attempt. Attempt acceptance runs a panel against the current node head and records
430
+ its decision in `attempt.measured.winRate` (see [Measurement](#measurement)
431
+ and [Landing and settlement](#landing-and-settlement)).
432
+
433
+ **Progress.** After each accepted attempt the node runs one panel: the head the
434
+ attempt landed as (the candidate) against the starting head (the baseline). It
435
+ records the win rate as `optimization.progress-measured`, which becomes the
436
+ node's current value; a panel threshold is that win rate. Every accepted head
437
+ gets its own panel, in landing order. While a progress panel is owed, the
438
+ node's next child waits to land (landing verdict `wait-progress`), so the node
439
+ head never moves past an unmeasured head. Progress is measured while a node
440
+ drains after a stop, too.
441
+
442
+ **Node panel failures.** A failed starting or progress panel records no value.
443
+ The node escalates with target `measurement` and policy cause
444
+ `measurement-failed`, naming the judge and its last outcome. A restart before
445
+ the answer resumes the same run. Answering it runs a new panel with fresh
446
+ judges.
447
+
448
+ **The run.** `panel.started` records the run's inputs: the candidate, the
449
+ baseline, the harness pin, the purpose, the rubric path, the harness and the
450
+ judge count. Every judge then runs in its own session, all of them at once,
451
+ under the `judge` role. Judges are build sessions, so the build's profile
452
+ applies to them.
453
+
454
+ **Blind, pinned variants.** Each judge gets a fresh root in the system
455
+ temporary directory, outside any repository. The root holds the two variants
456
+ as plain trees labeled `A/` and `B/`, a brief, and the `ab-judge` skill. Each
457
+ judge's order is drawn at random. Both trees carry the exact committed bytes
458
+ at every path, with no line-ending, filter or keyword conversion. Every harness
459
+ path, the rubric included, carries the harness pin's bytes, and a harness file
460
+ the pin lacks is absent. The skill is copied from the harness pin's
461
+ `.agents/skills/ab-judge/SKILL.md`, so a candidate cannot rewrite its own
462
+ judges' instructions. The variants are checked out from private Git material
463
+ outside the roots, and that material is deleted before any judge starts.
464
+
465
+ **Protected locations.** The workspace, its checkout, its Git common directory,
466
+ the main checkout that owns that directory, and a local store are protected
467
+ locations. Before writing anything, the runner refuses a temporary directory
468
+ at or under one of them. It checks each judge root again after preparing it.
469
+ Git discovery from the scratch location runs across filesystem boundaries, and
470
+ only a clean "not a git repository" counts as outside. Any other result, such
471
+ as a dubious-ownership error, fails the run. A failed check names the cause,
472
+ not the path. Point `TMPDIR` outside any repository.
473
+
474
+ **What a judge can learn.** Nothing Autobuild gives a judge reveals which
475
+ variant is the candidate or where it came from. That covers its context, its
476
+ environment, its labels, the location and names of its variant trees, its
477
+ store credential, any Git metadata reachable from its working directory, its
478
+ `ab` command and that command's process arguments. Nothing under the judge's
479
+ root links back to the repository it was prepared from, and no value Autobuild
480
+ supplies names a protected location.
481
+
482
+ - The judge's inherited environment is scrubbed: every value that names a
483
+ protected location is dropped, such as `INIT_CWD` or `npm_package_json`, and
484
+ so is every `PATH` entry under one. A path counts whether it names the real
485
+ location or reaches it through a symlinked checkout, ancestor or file, and
486
+ whether it stands alone, follows a prefix such as `-I`, or sits on one line
487
+ of a multiline value; a path that cannot be resolved is dropped as well. This can also drop a provider variable
488
+ whose value points inside the repository. Keep runtime credentials and tools
489
+ outside it.
490
+ - The judge's `ab` is a self-contained, judge-only launcher written beside the
491
+ roots in the temporary directory. It is not a path into the Autobuild
492
+ installation. It runs `ab judge context` and `ab judge prefer` and refuses
493
+ every other command. Its content names no protected location and no
494
+ installation path, and it runs as `bun <launcher> judge …`.
495
+ - If the `bun` interpreter or the judge runtime's executable resolves only at
496
+ or under a protected location, for example only in the repository's
497
+ `node_modules/.bin`, the run fails before any judge starts. Install both
498
+ outside the repository. A runtime that would load Autobuild files from a
499
+ protected location by path fails the judge's start the same way: the `pi`
500
+ runtime does this with its bridge extension when Autobuild is installed
501
+ inside the repository.
502
+
503
+ The guarantee covers what Autobuild supplies. A judge process that
504
+ deliberately searches the filesystem outside its root, for example through
505
+ `/proc`, the home directory or a scan for repositories, crosses the shared
506
+ trust boundary of unconfined local agent sessions. Autobuild does not claim a
507
+ general sandbox.
508
+
509
+ **The order is recorded where judges cannot read it.** The kernel records each
510
+ judge's order in `panel.judge-started` before the session starts. No judge
511
+ channel reads the log. The judge's environment carries `AB_JUDGE`
512
+ (`<build>:<panel>:<judge>`), `AB_SESSION` and `AB_CONTEXT_DIR`. Only with a
513
+ remote store does it also carry `AB_STORE` and a `build-judge` credential in
514
+ `AB_TOKEN`. It carries no `AB_BUILD`, no `AB_PHASE`, no inherited `AB_*` or
515
+ `GIT_*` value and no `PWD`. A judge never learns a local store's path. The
516
+ remote credential is write-only: it can append exactly one `panel.preferred`
517
+ for its own panel, judge and session while the session is open, and every read
518
+ is refused. Any read command run with `AB_JUDGE` set fails.
519
+
520
+ **The terminal.** A judge runs `ab judge context`, which writes `purpose.md`,
521
+ `rubric.md` and `context.json` from its brief and reads no store. It compares
522
+ `A/` and `B/` and ends with exactly one
523
+ `ab judge prefer <A|B|tie> --reason "<paragraph>"`. The reason must not be
524
+ blank, and a second call is refused. With a remote store, the preference is
525
+ appended over the write-only credential. The server checks the session and
526
+ appends in one conditional step, so two concurrent calls from one session
527
+ record at most one preference, and the other is refused. With a local store,
528
+ `ab judge prefer` saves the preference once to `preference.json` in the
529
+ judge's context directory, and a second or concurrent call is refused. The
530
+ runner commits that file as the judge's `panel.preferred` when the turn ends,
531
+ with the same atomic check. After the turn, the kernel records `panel.judged`
532
+ with the judge's index, its order, the preference and the reason.
533
+
534
+ **Win rate.** A judge who prefers the candidate scores 1, a tie scores 0.5 and
535
+ a preference for the baseline scores 0. The win rate is the mean over the
536
+ recorded judgments, so ties count as half.
537
+
538
+ **Resumption.** A run resumed after a crash or restart keeps every recorded
539
+ judgment. A dangling session is closed as `reclaimed`. A preference a local
540
+ judge saved before the crash is committed first, while its session is still
541
+ open. A dangling session's stream, if it has one, is closed after that
542
+ commit and before the `reclaimed` end. A judge whose preference was recorded is completed from that preference
543
+ and its recorded order without a new session. Only judges with no recorded preference run
544
+ again, each with a freshly drawn order.
545
+
546
+ **Failures.** A judge's turn that ends without a preference (`no-terminal`),
547
+ fails (`failed`) or exceeds the session budget (`expired`) counts as a
548
+ failure. A failure that a provider alternate replaced does not count; only the
549
+ last session of a judge's chain does. An alternate whose executable is
550
+ refused is not started, and the failure it would have replaced counts. After two counted failures for one judge, the run fails and names the
551
+ judge and its last outcome. A shutdown records `interrupted`, which does not
552
+ count. A run that cannot prepare its variants fails with the Git output tail.
553
+ A variant holding a committed symlink that resolves outside its judge root
554
+ fails the run before any judge starts, naming the link. A temporary directory
555
+ in a protected location, an interpreter or runtime executable found only
556
+ inside one, and a launcher that would name one also fail the run before any
557
+ judge starts. A local judge's saved preference that is malformed, or names
558
+ another judge or session, ends that judge as `no-terminal` with the reason.
559
+ Every judge root and the launcher directory are removed when the run ends.
560
+
561
+ **Provider alternates.** A judge launch follows the `judge` role's provider
562
+ alternates under the same eligibility rules as a build phase: an availability
563
+ or exhaustion failure, or a thrown start, moves to the next target; a
564
+ credentials or configuration failure, a failed credential delegation, an
565
+ expired budget and a shutdown do not. Each target is its own judge session in
566
+ the same root and with the same order, with its own `panel.judge-started`
567
+ (whose `substitution` names the failed session), credential, stream and
568
+ transcript. Before an alternate launches, its executable is checked against
569
+ the judge's filtered `PATH` and protected locations, like the primary's; a
570
+ refused alternate is not started, ends the chain, and its reason is appended
571
+ to the failed session's error. An alternate starts only after the failed
572
+ session's saved preference is settled and its `panel.judge-ended` is recorded,
573
+ and never after any preference, saved outbox or unreadable outbox for that
574
+ judge.
575
+
576
+ **Watching a judge.** A judge session streams like any other build session
577
+ when its runtime can stream: the stream's session identity carries the `judge`
578
+ role, the runtime and the phase `judge:<panel>:<judge>`, and never the order,
579
+ a side or the root. Its id is recorded on `panel.judge-started`, and it closes
580
+ before `panel.judge-ended`, `completed` when the session preferred and
581
+ `aborted` otherwise. The dashboard's session rows show each judge session,
582
+ including replaced ones, attributed to the panel and judge, without the
583
+ blinded order.
584
+
585
+ ## Events
586
+
587
+ | Event | Log | Facts |
588
+ |---|---|---|
589
+ | `optimization.objective-accepted` | node | objective, revision, harnessPin, specRev |
590
+ | `optimization.objective-revised` | node | changes, revision (human) |
591
+ | `optimization.baseline-measured` | node | revision, head, harnessPin, samples, median, spread, report |
592
+ | `optimization.noise-exceeded` | node | revision, head, harnessPin, median, spread, epsilon, effective ε (advisory) |
593
+ | `optimization.proposal-requested` | node | id, node head, room, budget used (attempts, hours) (dispatcher) |
594
+ | `optimization.attempts-proposed` | node | request, proposals (id, ticket, title, strategy), reason when empty; recorded after every ticket exists (dispatcher) |
595
+ | `attempt.measurement-requested` | attempt | id, node, candidate, baseline, harnessPin, revision, metric, purpose (panel) |
596
+ | `attempt.sampled` | attempt | request, candidate, baseline, harnessPin, revision, samples (judges for a panel), medians or win rate, report |
597
+ | `attempt.measured` | attempt | request, candidate, baseline, harnessPin, revision, samples, medians or win rate, delta, decision, spread, report |
598
+ | `optimization.proposal-deferred` | node | reason: `paused`, `blocked`, `command`, `restack`, `integration`, `landing` or `compatibility` (dispatcher) |
599
+ | `optimization.proposal-withdrawn` | node | request, reason: `stopped`, `budget` or `concurrency` (dispatcher) |
600
+ | `propose.started` | node | round, request (kernel) |
601
+ | `propose.completed` | node | round, request, proposal ids, `attempts` artifact (proposer) |
602
+ | `optimization.progress-measured` | node | revision, head, starting head, win rate, judges |
603
+ | `implement.declined` | attempt | round, reason, artifact? (agent) |
604
+ | `attempt.settled` | node | attempt (proposal, ticket, build, branch?), outcome, measurement (revision, baseline, candidate, delta), policy?, mergedSha?, note, head (accepted only) |
605
+ | `attempt.merged-unmeasured` | node | proposal, ticket, build, merged head (sha?), reason, measuredCandidate? |
606
+ | `optimization.stopped` | node | cause, mode |
607
+ | `attempt.ticket-rejected` | node | proposal, ticket, rejected state the ticket moved to |
608
+ | `attempt.branch-deleted` | node | proposal, build, branch |
609
+ | `attempt.branch-cleanup-failed` | node | proposal, build?, branch, error |
610
+ | `panel.started` | panel host | panel, candidate, baseline, harnessPin, purpose, rubric, harness, judges |
611
+ | `panel.judge-started` | panel host | panel, judge, session, order, runner, model?, account?, stream?, substitution? |
612
+ | `panel.preferred` | panel host | panel, judge, session, preference, reason (agent) |
613
+ | `panel.judged` | panel host | panel, judge, session, order, preference, reason |
614
+ | `panel.judge-ended` | panel host | panel, judge, session, outcome, error?, transcript? |
615
+
616
+ `decision` is `improved`, `no-improvement`, `non-regressing` or `regressed`.
617
+ `outcome` is `accepted`, `no-improvement`, `declined`, `stopped`, `aborted` or
618
+ `merged-unmeasured`. `accepted` and `no-improvement` carry their measurement.
619
+ `merged-unmeasured` carries a `policy` and never a measurement. Only `declined`
620
+ and `no-improvement` carry a `branch` to clean up. A `reason` is `absent`,
621
+ `stale-head`, `unrelated` or `unresolvable`; only `unresolvable` lacks the
622
+ merged head. `cause` is
623
+ `threshold`, `plateau`, `budget`, `exhausted` or `operator`. `report`,
624
+ `spread`, a request's `metric` and a settlement's `head` are optional: older
625
+ facts lack them. `head` is the node head an `accepted` attempt landed as, which
626
+ a panel node's progress panel measures.
627
+ `attempt.sampled` records samples, never a decision; `attempt.measured` is the
628
+ decision.
629
+ The panel facts live on the log of the build that runs the panel. `order` is
630
+ `candidate-first` or `baseline-first`, `preference` is `A`, `B` or `tie`, and
631
+ a judge's `outcome` is `completed`, `no-terminal`, `failed`, `expired`,
632
+ `interrupted` or `reclaimed`. `panel.preferred` never carries the order.
633
+ The dispatcher records `exhausted` after two consecutive empty proposals.
634
+
635
+ A positive delta is an improvement in the objective's direction:
636
+ `baseline − candidate` when minimizing, `candidate − baseline` when maximizing,
637
+ and `winRate − 0.5` for a panel. `revision` counts every acceptance and quick
638
+ revision, starting at 1; measurement facts carry the revision they ran under.
639
+
640
+ ## Progress
641
+
642
+ Progress is derived from the node's log, never recorded:
643
+
644
+ - **Starting value and noise spread** from the baseline measurement under the
645
+ current ruler. A panel's starting value is 0.5, and its spread comes from
646
+ the self-comparison panel.
647
+ - **Current value**: for a command, the candidate value of the latest accepted
648
+ attempt, else the starting value; for a panel, the latest
649
+ `optimization.progress-measured` win rate against the starting head, else
650
+ 0.5. **Best value** in the objective's direction.
651
+ - **Attempts**: filed, accepted, rejected (no-improvement, declined, stopped or
652
+ aborted), merged unmeasured (released by an operator) and running. Two kinds
653
+ of attempt still occupy a concurrency slot: settled attempts whose ticket has
654
+ not yet moved to the rejected role or whose branch is not yet deleted, and
655
+ running attempts that merged without a landing measurement. A tracker or
656
+ forge that refuses its step therefore stalls new proposals instead of piling
657
+ them up. `ab objective` lists each unmeasured merge (`unmeasured merge: …;
658
+ holds a concurrency slot until settled`) and each pending branch cleanup
659
+ (`branch cleanup pending: <branch> (<build>)[: <error>]`). `ab build status
660
+ <node>` prints the same lines, and the objective row adds `N merged
661
+ unmeasured (slot held)` while any remain.
662
+ - **Plateau counter**: consecutive `no-improvement` or `declined` settlements
663
+ since the last `accepted`; `stopped` and `aborted` leave it unchanged.
664
+ - **Elapsed budget**: hours since the first acceptance, against `maxHours`, and
665
+ attempts filed, against `maxAttempts`.
666
+ - **Stop eligibility** by threshold, plateau and budget, and whether the node
667
+ has stopped. Once stopped, `ab objective` also shows what still blocks
668
+ completion, or `ready for node verification`.
669
+
670
+ The attempt ledger holds one entry per settled attempt: strategy, outcome,
671
+ measured delta and closing note. A **near miss** is a `no-improvement`
672
+ settlement that improved by less than ε (0 < delta < ε, with a relative ε
673
+ scaled by the baseline's magnitude).
674
+
675
+ ## Where progress appears
676
+
677
+ Every surface shows the same objective row, read from the node's digest alone:
678
+
679
+ - The terminal dashboard prints it under the node's progress bar and as the
680
+ `Objective` field of the detail view.
681
+ - `ab status` prints it on a continuation line under the node's row, and
682
+ `ab build status <node>` prints it under `optimization node: objective
683
+ revision N`.
684
+ - `--json` summaries, the `builds.list` and `builds.get` operator tools, and
685
+ `ab watch --json` records (`state.objective`) carry it as `objective`;
686
+ `builds.get` also carries the dashboard's `objectiveRow`. `ab watch` appends
687
+ it to the line of every optimization event.
688
+
689
+ ```text
690
+ objective 50 → 44 (minimize) · threshold 35 · noise ±1.5
691
+ attempts 1 accepted · 3 rejected · 0 running
692
+ budget 4/60 attempts · 3.1/24 hours
693
+ stopped plateau (drain)
694
+ ```
695
+
696
+ A panel shows `win rate 50% → 70%` instead. Only configured budgets appear,
697
+ `no threshold` and `objective not measured` stand in for absent values, and
698
+ the `stopped` segment appears once the node stops. Budget hours stop at the
699
+ stop time; a watch record evaluates them at its own timestamp. `ab objective`
700
+ remains the full view, with the best value, plateau and stop eligibility.
701
+
702
+ ## Proposer phase
703
+
704
+ An optimization node proposes its own attempts. Its grammar is
705
+ `branch opening → starting measurement → (propose → collecting)*`, followed by
706
+ the node's normal completion, verification and merge. Grooming the objective,
707
+ its purpose, budget and stop policy, is the dispatch decision for every attempt
708
+ the node generates: the proposer's attempts go straight to ready, within that
709
+ budget, and each must pass the measurement gate before it lands.
710
+
711
+ **Admission.** The dispatcher records `optimization.proposal-requested` when
712
+ the node is open, has not stopped and no stop cause is eligible, has a starting measurement under the
713
+ current ruler, has no open request, has fewer than two consecutive empty
714
+ proposals, and has room. Room is the smaller of the free concurrency slots
715
+ (`proposer.concurrency` minus attempts queued or running) and the attempts
716
+ the budget still allows, and is 0 once the attempts or hours budget is spent.
717
+ An open request reserves the node's single outstanding proposal round, so no
718
+ second request is made while it is open. It may be waiting for capacity,
719
+ running, or awaiting filing after its session deposited. A proposer session is
720
+ running only once its matching phase and session have started, not merely
721
+ because a request is open. A node that is paused, blocked, has a pending command, an active or
722
+ conflicted node restack, a landing intent or a merged or closed PR, or is
723
+ deferred for runtime compatibility gets `optimization.proposal-deferred` with
724
+ that reason instead, and is reconsidered once a fact that can clear it lands.
725
+ The request takes a slot ahead of normal ticket claims, like node reconcile and
726
+ verification. Before the session starts, the dispatcher re-checks the request:
727
+ when the node stopped, the hours budget expired, or room fell below the
728
+ recorded room, it records `optimization.proposal-withdrawn`, which clears the
729
+ request and never counts as an empty proposal. A session that already started
730
+ keeps the room it was granted.
731
+
732
+ **Context.** The session runs the `ab-propose` skill on the node head, checked
733
+ out detached. `ab context` writes:
734
+
735
+ - `objective.json`: the effective objective, its revision and the fields
736
+ quick-revised since its latest acceptance;
737
+ - `progress.json`: starting, current, best and threshold values, attempt
738
+ counts, attempts in flight, the plateau counter, consecutive empty proposals,
739
+ the opening time and the request (`id`, `head`, `room`);
740
+ - `ledger.json`: `settled`, one entry per settled attempt with `nearMiss: true`
741
+ on a near miss, and `inFlight`, the running attempts with their titles and
742
+ strategies;
743
+
744
+ plus the spec, answered guidance and ticket assets. The manifest's
745
+ `optimization` names the request, head and room.
746
+
747
+ **`ab propose`.** The session ends with `ab propose <file>`,
748
+ `ab propose --none <reason>` or `ab escalate`; `ab done` and `ab verdict` are
749
+ refused. The file is JSON:
750
+
751
+ ```json
752
+ {"proposals": [{"id": "batch-index-lookups", "title": "…", "strategy": "…", "body": "…"}], "reason": "…"}
753
+ ```
754
+
755
+ - `id` matches `^[a-z0-9][a-z0-9-]{0,63}$`, is unique in the file and was never
756
+ used by this node before, whether settled, pending or in flight.
757
+ - `title` is one line of at most 200 characters; `strategy` is one line of at
758
+ most 300 characters naming one strategy.
759
+ - `body` meets the [spec standard](spec-standard.md) (what and why,
760
+ `## Acceptance criteria` with at least one item, `## Out of scope`) and
761
+ carries no `autobuild-objective` block.
762
+ - The count is at most the request's room. An empty list needs a `reason`.
763
+
764
+ A valid file is deposited as an `attempts` artifact together with
765
+ `propose.completed`. The proposer never creates tickets.
766
+
767
+ **Filing.** The dispatcher reads the deposit once and creates one work ticket
768
+ per proposal, targeting the node, in the source's ready role. Each ticket
769
+ carries every `readyLabels` entry and any `[tickets].createLabels` and, when
770
+ `[tickets].readyAssignee` is set,
771
+ is assigned to that user, adopted tickets included, so intake lists it. Each creation
772
+ carries an idempotency key derived from the repository, the node and the
773
+ proposal id, so a crash between the deposit, the creation and the record
774
+ adopts the ticket an earlier try created instead of filing it twice. Until the
775
+ record lands, intake withholds ready tickets whose creation key matches a
776
+ deposited proposal. Once every ticket exists, the dispatcher records
777
+ `optimization.attempts-proposed` and releases the node's workspace. If that
778
+ release never happens, after a crash, a failed release or a runner still
779
+ leased, a later dispatcher pass releases any optimization-node workspace that
780
+ no runner, starting or progress measurement, proposal, restack or integration work owns. A ticket source without integration-tree support, or an unreadable deposit, raises an
781
+ escalation on the node instead of creating anything.
782
+
783
+ **Exhausted.** Two consecutive empty proposals stop the node: the dispatcher
784
+ records `optimization.stopped` with cause `exhausted` and the objective's stop
785
+ mode, and requests no further proposals. The shared stop enforcer applies the
786
+ recorded mode to attempts already in flight, just as for every other stop cause.
787
+
788
+ Starting and progress measurements have precedence over new proposer admission.
789
+ An open but unstarted proposer request waits while a measurement is owed or running.
790
+ A proposer already admitted when a measurement becomes due finishes or resumes
791
+ with its granted allowance, and its deposit is filed normally. Measurement runs
792
+ next, before another proposer. The node workspace remains held while either a
793
+ starting or progress measurement or a
794
+ proposal request or session needs it; neither owner releases the other’s workspace.
795
+
796
+ ## Attempts
797
+
798
+ A build is an attempt of a node exactly when its ticket was created from a
799
+ recorded proposal of that node (`optimization.attempts-proposed`), which the
800
+ dispatcher files from the proposer's deposit. Children
801
+ filed any other way, for example a repair child, are not attempts and count
802
+ toward neither the budget nor the plateau. The proposal's ticket and the
803
+ build's ticket are compared through any recorded ticket-source migration, so a
804
+ proposal recorded before a migration still matches its child. When that
805
+ continuity cannot be resolved, the command refuses with `cannot resolve
806
+ optimization attempt identity for build <slug>: …` rather than treating the
807
+ build as an ordinary child.
808
+
809
+ An attempt keeps the ordinary work grammar: plan, plan review, implement, code
810
+ review, verify and finalize.
811
+
812
+ ### Attempt context
813
+
814
+ In every phase of an attempt, `ab context` writes a derived `objective.md` and
815
+ adds an `attempt` block to the manifest. Reviewers need the purpose as much as
816
+ the implementer does. The document names the node and the objective revision
817
+ and gives:
818
+
819
+ - the purpose, verbatim;
820
+ - the measurement: the command, its direction and samples, or a panel's judges
821
+ and rubric;
822
+ - the harness selectors, with a note that the harness is pinned and `ab done`
823
+ refuses any change to it;
824
+ - ε, the threshold if any, and the node's current value ("not measured yet"
825
+ before a baseline), with the best and starting values when present.
826
+
827
+ The manifest block is
828
+ `{node, proposal, revision, purpose, metric: {kind, command?, direction?,
829
+ samples?, judges?, rubric?}, harness, current?, path}`, where `path` is the
830
+ workspace-relative `objective.md`.
831
+
832
+ ### Harness edits are refused
833
+
834
+ The harness is the ruler. In an attempt's implement phase, `ab done` compares
835
+ the net contribution (`base..head`, renames as delete plus add) with
836
+ `metric.harness`. A change to a matching path is refused before anything is
837
+ deposited or published, as other invalid deposits are, so no event is written
838
+ and code review never sees it:
839
+
840
+ ```text
841
+ publication rejected: an optimization attempt must not change its harness (the measurement's ruler):
842
+ bench/search/run.ts
843
+ Revert these paths to the contribution base, commit, then retry 'ab done'.
844
+ ```
845
+
846
+ Only the net diff counts: a harness edit reverted in a later commit changes
847
+ nothing the ruler measures. Children that are not attempts are not checked.
848
+
849
+ ### Declining
850
+
851
+ When a strategy finds no real gain, the implementer declines:
852
+
853
+ ```sh
854
+ ab done --no-improvement "<what was tried and why it did not help>" [--notes <file>]
855
+ ```
856
+
857
+ It records `implement.declined {round, reason, artifact?}`, with the notes as
858
+ `implement-notes` when `--notes` is given. The reason is trimmed and must be 1
859
+ to 4000 characters. Declining needs no commits and no clean worktree, and it
860
+ publishes nothing. No review, verification, finalize or measurement follows.
861
+ The dispatcher then appends `attempt.settled {outcome: declined, note}` to the
862
+ node with the reason as the note, releases the attempt's workspace, and
863
+ completes the build `closed-unmerged`. A declined settlement enters the ledger
864
+ the proposer reads and advances the plateau counter. If an earlier implement
865
+ round published the attempt's branch, the node's poll deletes it before moving
866
+ the ticket (see [Landing and settlement](#landing-and-settlement)).
867
+
868
+ Declining is a successful outcome: a specific reason tells the proposer what
869
+ not to try again. The flag is refused outside implement (`'--no-improvement'
870
+ is only valid in implement of an optimization attempt`) and in a build that is
871
+ not an attempt (`ab done --no-improvement is only for optimization attempts:
872
+ build <slug> is not an attempt of an optimization node`).
873
+
874
+ ## Landing and settlement
875
+
876
+ Passing verify and finalize is not enough for a child of an optimization node
877
+ to land. Verify asks whether a change is correct; measurement asks whether it
878
+ helped. Once a child is ready to land, the dispatcher records
879
+ `attempt.measurement-requested` on the child's log for one exact pair: the
880
+ child's candidate head and the node head it would land on. The child lands only
881
+ with an `attempt.measured` result for that same pair, under the accepted
882
+ harness pin and the current ruler. The node writer's guarded merge is guarded
883
+ on that measured node head.
884
+
885
+ - **Freshness.** When a sibling lands first, the node head moves and the
886
+ measurement no longer applies. The child restacks and a new measurement is
887
+ requested. A request the child already saw superseded is never sampled, so
888
+ no paired measurement is spent on a pair that cannot land; samples already
889
+ running when the head moves are recorded and then rejected as stale.
890
+ A clean restack keeps verification; it never keeps a measurement.
891
+ The node writer is never held while a measurement runs.
892
+ A landing interrupted after its writer reservation publishes on recovery only
893
+ while that pair still passes the gate; after a revision it does not pass, the
894
+ reservation is abandoned.
895
+ - **Attempts must improve.** An attempt lands when its delta is at least ε;
896
+ on a panel objective, when its win rate against the current node head
897
+ reaches 0.5 + ε. Anything less settles it `no-improvement`: its PR closes
898
+ without merging and no further implement round runs.
899
+ - **Other children must not regress.** A child that is not an attempt lands
900
+ when its delta is at least −ε, or its win rate at least 0.5 − ε. A
901
+ regressing child escalates with both medians or the win rate, the delta and
902
+ ε; answering asks for a fresh measurement. These
903
+ children never settle and count toward neither budget nor plateau.
904
+ - **Harness edits escalate.** An attempt whose head changes a harness path is
905
+ never measured. It escalates naming the paths, and that head stays
906
+ unmeasured even after an answer; revise the attempt or abort it.
907
+ - **Turn.** An attempt overtaken by sibling landings three consecutive times
908
+ gets the next turn. Later candidates neither request measurements nor land
909
+ until it lands, closes, or escalates.
910
+ - **Progress first.** While a panel node owes a progress panel for an accepted
911
+ head, a child that would otherwise land waits (`wait-progress`). Its
912
+ measurement may still run; it lands once the progress is recorded.
913
+
914
+ `ab watch` and `ab build status <child>` print the recorded measurement: a
915
+ command's medians or a panel's win rate, the delta and the decision, such as
916
+ `win rate 0.8: delta 0.3 → improved`.
917
+
918
+ Every attempt settles exactly once, on the node's log. A measured settlement
919
+ records the medians, or for a panel a baseline of 0.5 and the win rate as the
920
+ candidate:
921
+
922
+ | How the attempt ends | Outcome | Ticket role |
923
+ |---|---|---|
924
+ | Merged into the node, with a measurement of the merged head; records the merged head | `accepted` | done |
925
+ | Landing measurement shows no improvement | `no-improvement` | rejected |
926
+ | Its implementer declines it (`ab done --no-improvement`) | `declined` | rejected |
927
+ | Node stops | `stopped` | rejected |
928
+ | Operator abort, or a human closes its PR | `aborted` | rejected |
929
+ | Merged without a measurement of the merged head, then released by an operator | `merged-unmeasured` | done |
930
+
931
+ **Unmeasured merges.** A human forge merge bypasses the landing gate. An
932
+ attempt settles `accepted` only with a result for exactly the merged head that
933
+ answers this node's request. Otherwise the dispatcher records
934
+ `attempt.merged-unmeasured` on the node once, with its reason, and one followup
935
+ observation on the child. The attempt stays in flight and keeps its concurrency
936
+ slot. Its build and ticket still complete. The dispatcher reconciles merges that
937
+ completed without either record on its next node tick. Release the slot
938
+ explicitly:
939
+
940
+ ```sh
941
+ ab objective <node> --settle-unmeasured <proposal|build> --policy release-unmeasured [--note <text>]
942
+ ```
943
+
944
+ A connected agent calls the operator tool `optimization.settle-unmeasured`
945
+ with `{repo, slug, attempt, policy, note?}`. The policy is required.
946
+ `release-unmeasured` records `attempt.settled {outcome: merged-unmeasured,
947
+ policy, mergedSha}` with you as the actor. The slot is released exactly once
948
+ and the attempt is counted as merged unmeasured, never accepted. The current
949
+ and best values, the baseline and the plateau counter do not move, and the
950
+ ledger entry has no measurement. The action works on a stopped node. It refuses
951
+ an attempt that is not in flight, has not merged unmeasured, or whose merged
952
+ head has a valid measurement, and it refuses a terminal node.
953
+
954
+ **Rejected tickets and branch cleanup.** This is the one case in which the
955
+ dispatcher moves a ticket into the rejected role. Once the attempt's build is
956
+ done (or it never had one), the node's poll moves the ticket, comments the
957
+ outcome, and records `attempt.ticket-rejected`. An aborted or closed attempt
958
+ never returns to triage. A completed node keeps being polled until every such
959
+ move has committed.
960
+
961
+ A `declined` or `no-improvement` attempt that published its branch (it
962
+ completed an implement round or opened a PR) leaves a cleanup obligation on
963
+ that pending rejection. Before moving the ticket, the poll deletes exactly that
964
+ build's branch from the forge and records `attempt.branch-deleted`. A branch
965
+ that is already gone counts as deleted. The poll never deletes the node's
966
+ branch, its base or another build's branch. A failed or refused deletion
967
+ records `attempt.branch-cleanup-failed` once per distinct error, keeps the
968
+ slot, and retries on later polls without changing the settlement. An attempt
969
+ that never published needs no deletion. Aborted and stopped attempts keep abort
970
+ cleanup's own branch deletion.
971
+
972
+ ## Stopping and completion
973
+
974
+ An optimization node is done when the number is good enough, when it stops
975
+ getting better, when the budget runs out, or when an operator takes the
976
+ progress so far. Every accepted attempt improved the node head, so stopping at
977
+ any point lands real, verified progress.
978
+
979
+ **Causes.** The node records `optimization.stopped {cause, mode}` once:
980
+
981
+ | Cause | When |
982
+ |---|---|
983
+ | `threshold` | The node head's current value has reached `target.threshold` in the objective's direction; for a panel, the head's recorded win rate against the starting head. |
984
+ | `plateau` | `stop.plateau.attempts` consecutive `no-improvement` or `declined` settlements. |
985
+ | `budget` | Attempts filed reached `maxAttempts`, or hours since the first acceptance reached `maxHours`. |
986
+ | `exhausted` | The proposer has nothing left to try. |
987
+ | `operator` | A human stopped it with `ab objective <node> --stop` or `optimization.stop`. |
988
+
989
+ The dispatcher checks every open, unpaused optimization node on every tick and
990
+ records the first eligible of threshold, plateau and budget, with the
991
+ objective's stop mode. It checks the effective objective, so a quick revision
992
+ takes effect on the next tick.
993
+
994
+ **Stopping by hand.** `ab objective <node> --stop` uses the objective's stop
995
+ mode, `abort` unless the objective says otherwise; `--stop --drain` and
996
+ `--stop --abort` override it for this stop. The operator tool
997
+ `optimization.stop` takes an optional `mode`; see the
998
+ [operator API](operator-api.md#optimization-stop). Both refuse a build that is
999
+ not a node, a plain node, a terminal node and a node that has already stopped.
1000
+ `--stop` cannot be combined with revision flags.
1001
+
1002
+ **Modes.** Every cause, `exhausted` included, applies the same modes:
1003
+
1004
+ - **abort**: queued attempts are cancelled and running attempts are aborted
1005
+ through the ordinary abort saga, with a dispatcher `build.abort-requested`
1006
+ naming the stop. Those aborted by the stop settle `stopped`.
1007
+ - **drain**: queued attempts are cancelled and settle `stopped`; running
1008
+ attempts finish and face the landing gate.
1009
+
1010
+ The first recorded `build.abort-requested` fixes the abort's cause. A node-stop
1011
+ request records `origin {kind: optimization-stop, node}`; an operator request has
1012
+ operator origin (no node-stop origin). Abort cleanup alone settles an aborted
1013
+ build: `stopped` for a node-stop request, `aborted` for an operator request.
1014
+ An existing request is never replaced: identical repeats are idempotent and
1015
+ conflicting operator requests are refused. The stop enforcer waits for a pending
1016
+ abort, so an operator abort before a stop remains `aborted`; an operator abort
1017
+ during drain is also `aborted`. Settlement is conditional on the attempt still
1018
+ being in flight, and the existing node sweep alone moves its ticket to rejected.
1019
+
1020
+ An attempt with no build yet is cancelled and settles `stopped` in both modes. No new proposer
1021
+ session is admitted after a stop. A proposer session that had already started
1022
+ keeps the allowance it was granted and may finish or resume; its deposited
1023
+ proposals are filed and recorded, but the stopped node's attempt handling
1024
+ cancels and settles those attempts, so no fresh attempt work runs. Dispatch
1025
+ refuses an attempt ticket of a stopped node with
1026
+ `target optimization node <id> has stopped; attempt <ticket> is cancelled`.
1027
+ Children filed by hand, such as repair tickets, are still admitted.
1028
+
1029
+ **Completion.** The node is complete when it has stopped, no attempt is running
1030
+ or waiting to land, and every child is otherwise resolved under the ordinary
1031
+ node completion rule. It then verifies, authorizes and merges like any other
1032
+ node. Stopping is not consent: once the node is ready, land it with
1033
+ `ab merge <node>`. `ab merge` refuses an optimization node that has not
1034
+ stopped, or whose attempts are still in flight, and names which.
1035
+
1036
+ ## Landing the node
1037
+
1038
+ `ab merge <node>` approves the node's branch: the verified accumulation of
1039
+ every accepted attempt, each of which improved the head it landed on, plus any
1040
+ children filed by hand. Rejected attempts never reach the node branch, because
1041
+ the landing gate closes them unmerged. The node then lands into its target
1042
+ like any other node; see [integration trees](integration-tree.md).