elanous 0.2.23 → 0.2.24

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 (347) hide show
  1. package/apps/pwa/out/404/index.html +1 -1
  2. package/apps/pwa/out/404.html +1 -1
  3. package/apps/pwa/out/_next/static/chunks/{272-b23d2e92161d11fd.js → 272-0eed0fb0aab716b6.js} +1 -1
  4. package/apps/pwa/out/_next/static/chunks/{3961-fbef064c213b2b18.js → 3961-aaae04ed1d32622f.js} +1 -1
  5. package/apps/pwa/out/_next/static/chunks/app/approvals/{page-d5341ac96203a983.js → page-3b9fc39362473ae7.js} +1 -1
  6. package/apps/pwa/out/_next/static/chunks/app/autopilot/page-f2b62c19ca68fef8.js +1 -0
  7. package/apps/pwa/out/_next/static/chunks/app/board/{page-55c631c032dcc47e.js → page-d7602d489edf5f37.js} +1 -1
  8. package/apps/pwa/out/_next/static/chunks/app/botlab/{page-ad3bd8084048bee4.js → page-24282bf9f90031a5.js} +1 -1
  9. package/apps/pwa/out/_next/static/chunks/app/bots/page-8b7c5ab6b5bc8d64.js +1 -0
  10. package/apps/pwa/out/_next/static/chunks/app/ceo/{page-5c5d0e370f495ef6.js → page-4eb84d454f8c3415.js} +1 -1
  11. package/apps/pwa/out/_next/static/chunks/app/chat/{page-c325e21543cd48a8.js → page-b2e494bdad57fcb5.js} +1 -1
  12. package/apps/pwa/out/_next/static/chunks/app/consult/{page-6168a7c43e6ef8f5.js → page-c0ab229673a8b0eb.js} +1 -1
  13. package/apps/pwa/out/_next/static/chunks/app/control/page-3e2b45f3c36dbac4.js +1 -0
  14. package/apps/pwa/out/_next/static/chunks/app/decisions/page-c22aa511b28743ad.js +1 -0
  15. package/apps/pwa/out/_next/static/chunks/app/design-check/page-26345242e4049f55.js +1 -0
  16. package/apps/pwa/out/_next/static/chunks/app/editor/{page-25bb425afdb27541.js → page-bf88c0f558d8ef54.js} +1 -1
  17. package/apps/pwa/out/_next/static/chunks/app/exec/{page-32d72fdef1afe11a.js → page-52fec523e5b5d3ad.js} +1 -1
  18. package/apps/pwa/out/_next/static/chunks/app/field/page-67723dfdcde92b31.js +1 -0
  19. package/apps/pwa/out/_next/static/chunks/app/inside/{page-2bd9ce9c020d02d4.js → page-22725e2570f1126b.js} +1 -1
  20. package/apps/pwa/out/_next/static/chunks/app/intake/{page-a34096245e63b9f2.js → page-1891335950d68b70.js} +1 -1
  21. package/apps/pwa/out/_next/static/chunks/app/layout-3267af1ebdc73cf5.js +1 -0
  22. package/apps/pwa/out/_next/static/chunks/app/live/{page-4cc66d22ca4ec502.js → page-c314b75c11234998.js} +1 -1
  23. package/apps/pwa/out/_next/static/chunks/app/live-run/{page-83b14c729fcea837.js → page-9f9c85415f61782b.js} +1 -1
  24. package/apps/pwa/out/_next/static/chunks/app/loops/page-c1d4276059085587.js +1 -0
  25. package/apps/pwa/out/_next/static/chunks/app/market/page-833aab587f26ad4c.js +1 -0
  26. package/apps/pwa/out/_next/static/chunks/app/missions/[id]/{page-ccdb83ed40c8d724.js → page-8526c17ae38e6a50.js} +1 -1
  27. package/apps/pwa/out/_next/static/chunks/app/morning/{page-7ad3de8fa06fdea9.js → page-f998637a8402115c.js} +1 -1
  28. package/apps/pwa/out/_next/static/chunks/app/not-found-b7bb53828b17b335.js +1 -0
  29. package/apps/pwa/out/_next/static/chunks/app/observatory/page-1b1850de0257e46d.js +1 -0
  30. package/apps/pwa/out/_next/static/chunks/app/ops/checklist/{page-786111f30b6f0969.js → page-6f23159fedb41f67.js} +1 -1
  31. package/apps/pwa/out/_next/static/chunks/app/ops/release/{page-48fb31810693c357.js → page-1d809a87139dd024.js} +1 -1
  32. package/apps/pwa/out/_next/static/chunks/app/ops/seats/{page-4e17cce5e2ed0fee.js → page-da9e570234d481fd.js} +1 -1
  33. package/apps/pwa/out/_next/static/chunks/app/outputs/{page-cb154acadb025414.js → page-b92caddb5c715f30.js} +1 -1
  34. package/apps/pwa/out/_next/static/chunks/app/page-8ce3a38e210b810a.js +1 -0
  35. package/apps/pwa/out/_next/static/chunks/app/reflection/{page-c2dd2b19c93f90ab.js → page-57ffeeb6019440fd.js} +1 -1
  36. package/apps/pwa/out/_next/static/chunks/app/scheduler/page-abbb417bf514630b.js +1 -0
  37. package/apps/pwa/out/_next/static/chunks/app/sessions/{page-d3c007c8a0ddd7ee.js → page-2c2b3f29cec1efa4.js} +1 -1
  38. package/apps/pwa/out/_next/static/chunks/app/settings/devices/{page-7837ce2aacb97b04.js → page-9369279f72fc7b51.js} +1 -1
  39. package/apps/pwa/out/_next/static/chunks/app/settings/page-64861f14039499c3.js +1 -0
  40. package/apps/pwa/out/_next/static/chunks/app/setup/done/page-ddc4c93efd8ab94b.js +1 -0
  41. package/apps/pwa/out/_next/static/chunks/app/setup/page-901a1391b81053bc.js +1 -0
  42. package/apps/pwa/out/_next/static/chunks/app/share/page-68d9bbaac9841a58.js +1 -0
  43. package/apps/pwa/out/_next/static/chunks/app/showroom/{page-119be9a0444d2482.js → page-b5c0c996f329371e.js} +1 -1
  44. package/apps/pwa/out/_next/static/chunks/app/tasks/{page-fa806c018833e332.js → page-89881ccbcf728978.js} +1 -1
  45. package/apps/pwa/out/_next/static/chunks/app/term/page-0e87a803b3d7165e.js +1 -0
  46. package/apps/pwa/out/_next/static/chunks/app/today/{page-d431fbdea6ad93dd.js → page-58d4e5cb30ef4871.js} +1 -1
  47. package/apps/pwa/out/_next/static/chunks/app/trace/page-02ce4c3b5f39e4d2.js +1 -0
  48. package/apps/pwa/out/_next/static/chunks/app/vault/page-e620d1bb8eadcec2.js +1 -0
  49. package/apps/pwa/out/_next/static/chunks/app/workflows/chat-ui/{page-847c3de6ca8a4416.js → page-acf868c64d77f950.js} +1 -1
  50. package/apps/pwa/out/_next/static/chunks/app/workflows/page-54fa605fa6dba457.js +1 -0
  51. package/apps/pwa/out/_next/static/chunks/app/workspace/{page-74e69ba2c8e970d4.js → page-bc79f0833533fa84.js} +1 -1
  52. package/apps/pwa/out/_next/static/chunks/app/worktrees/{page-70038f41ae7cf931.js → page-d5c4398eea03d8f3.js} +1 -1
  53. package/apps/pwa/out/_next/static/css/72becfd42807b50d.css +1 -0
  54. package/apps/pwa/out/approvals/index.html +1 -1
  55. package/apps/pwa/out/approvals/index.txt +14 -14
  56. package/apps/pwa/out/autopilot/index.html +1 -1
  57. package/apps/pwa/out/autopilot/index.txt +14 -14
  58. package/apps/pwa/out/board/index.html +1 -1
  59. package/apps/pwa/out/board/index.txt +14 -14
  60. package/apps/pwa/out/botlab/index.html +1 -1
  61. package/apps/pwa/out/botlab/index.txt +14 -14
  62. package/apps/pwa/out/bots/index.html +1 -1
  63. package/apps/pwa/out/bots/index.txt +14 -14
  64. package/apps/pwa/out/ceo/index.html +1 -1
  65. package/apps/pwa/out/ceo/index.txt +14 -14
  66. package/apps/pwa/out/chat/index.html +1 -1
  67. package/apps/pwa/out/chat/index.txt +14 -14
  68. package/apps/pwa/out/consult/index.html +1 -1
  69. package/apps/pwa/out/consult/index.txt +14 -14
  70. package/apps/pwa/out/control/index.html +1 -1
  71. package/apps/pwa/out/control/index.txt +14 -14
  72. package/apps/pwa/out/decisions/index.html +1 -1
  73. package/apps/pwa/out/decisions/index.txt +14 -14
  74. package/apps/pwa/out/design-check/index.html +1 -1
  75. package/apps/pwa/out/design-check/index.txt +14 -14
  76. package/apps/pwa/out/editor/index.html +1 -1
  77. package/apps/pwa/out/editor/index.txt +14 -14
  78. package/apps/pwa/out/exec/index.html +1 -1
  79. package/apps/pwa/out/exec/index.txt +14 -14
  80. package/apps/pwa/out/field/index.html +1 -1
  81. package/apps/pwa/out/field/index.txt +14 -14
  82. package/apps/pwa/out/healthz +1 -1
  83. package/apps/pwa/out/index.html +1 -1
  84. package/apps/pwa/out/index.txt +14 -14
  85. package/apps/pwa/out/inside/index.html +1 -1
  86. package/apps/pwa/out/inside/index.txt +14 -14
  87. package/apps/pwa/out/intake/index.html +1 -1
  88. package/apps/pwa/out/intake/index.txt +14 -14
  89. package/apps/pwa/out/live/index.html +1 -1
  90. package/apps/pwa/out/live/index.txt +14 -14
  91. package/apps/pwa/out/live-run/index.html +1 -1
  92. package/apps/pwa/out/live-run/index.txt +14 -14
  93. package/apps/pwa/out/loops/index.html +1 -1
  94. package/apps/pwa/out/loops/index.txt +14 -14
  95. package/apps/pwa/out/market/index.html +1 -1
  96. package/apps/pwa/out/market/index.txt +14 -14
  97. package/apps/pwa/out/missions/placeholder/index.html +1 -1
  98. package/apps/pwa/out/missions/placeholder/index.txt +14 -14
  99. package/apps/pwa/out/morning/index.html +1 -1
  100. package/apps/pwa/out/morning/index.txt +14 -14
  101. package/apps/pwa/out/observatory/index.html +1 -1
  102. package/apps/pwa/out/observatory/index.txt +14 -14
  103. package/apps/pwa/out/ops/checklist/index.html +1 -1
  104. package/apps/pwa/out/ops/checklist/index.txt +14 -14
  105. package/apps/pwa/out/ops/release/index.html +1 -1
  106. package/apps/pwa/out/ops/release/index.txt +14 -14
  107. package/apps/pwa/out/ops/seats/index.html +1 -1
  108. package/apps/pwa/out/ops/seats/index.txt +14 -14
  109. package/apps/pwa/out/outputs/index.html +1 -1
  110. package/apps/pwa/out/outputs/index.txt +14 -14
  111. package/apps/pwa/out/reflection/index.html +1 -1
  112. package/apps/pwa/out/reflection/index.txt +15 -15
  113. package/apps/pwa/out/scheduler/index.html +1 -1
  114. package/apps/pwa/out/scheduler/index.txt +14 -14
  115. package/apps/pwa/out/sessions/index.html +1 -1
  116. package/apps/pwa/out/sessions/index.txt +14 -14
  117. package/apps/pwa/out/settings/devices/index.html +1 -1
  118. package/apps/pwa/out/settings/devices/index.txt +14 -14
  119. package/apps/pwa/out/settings/index.html +1 -1
  120. package/apps/pwa/out/settings/index.txt +14 -14
  121. package/apps/pwa/out/setup/done/index.html +1 -1
  122. package/apps/pwa/out/setup/done/index.txt +14 -14
  123. package/apps/pwa/out/setup/index.html +1 -1
  124. package/apps/pwa/out/setup/index.txt +14 -14
  125. package/apps/pwa/out/share/index.html +1 -1
  126. package/apps/pwa/out/share/index.txt +14 -14
  127. package/apps/pwa/out/showroom/index.html +1 -1
  128. package/apps/pwa/out/showroom/index.txt +14 -14
  129. package/apps/pwa/out/tasks/index.html +1 -1
  130. package/apps/pwa/out/tasks/index.txt +14 -14
  131. package/apps/pwa/out/term/index.html +1 -1
  132. package/apps/pwa/out/term/index.txt +14 -14
  133. package/apps/pwa/out/today/index.html +1 -1
  134. package/apps/pwa/out/today/index.txt +14 -14
  135. package/apps/pwa/out/trace/index.html +1 -1
  136. package/apps/pwa/out/trace/index.txt +14 -14
  137. package/apps/pwa/out/vault/index.html +1 -1
  138. package/apps/pwa/out/vault/index.txt +14 -14
  139. package/apps/pwa/out/workflows/chat-ui/index.html +1 -1
  140. package/apps/pwa/out/workflows/chat-ui/index.txt +14 -14
  141. package/apps/pwa/out/workflows/index.html +1 -1
  142. package/apps/pwa/out/workflows/index.txt +14 -14
  143. package/apps/pwa/out/workspace/index.html +1 -1
  144. package/apps/pwa/out/workspace/index.txt +14 -14
  145. package/apps/pwa/out/worktrees/index.html +1 -1
  146. package/apps/pwa/out/worktrees/index.txt +14 -14
  147. package/catalog/models/openrouter/deepseek-v4-pro-0813.yaml +39 -0
  148. package/catalog/models/openrouter/deepseek-v4.1-flash.yaml +38 -0
  149. package/catalog/models/openrouter/glm-5.3-flash.yaml +35 -0
  150. package/catalog/providers/openrouter.yaml +2 -0
  151. package/graphs/implement-loop.yaml +31 -0
  152. package/graphs/ops/harness-gc.yaml +17 -0
  153. package/graphs/ops/recipes.yaml +3 -0
  154. package/graphs/overlays/README.md +1 -1
  155. package/graphs/overlays/stop-heal-ladder.yaml +105 -0
  156. package/package.json +1 -1
  157. package/scripts/add-api-key.sh +1 -1
  158. package/scripts/ci-typecheck-changed.ts +71 -14
  159. package/scripts/fleet/bedrock-pod-secret.ts +122 -0
  160. package/scripts/fleet/node-setup-linux.sh +97 -0
  161. package/scripts/fleet/node-setup.sh +11 -0
  162. package/scripts/fleet/zai-pod-secret.ts +86 -0
  163. package/scripts/land-global-checks.ts +3 -0
  164. package/scripts/measure-log-diet-2.ts +213 -0
  165. package/scripts/measure-tsc-affected-roots.ts +289 -0
  166. package/scripts/release-loop/gate-executor.ts +28 -0
  167. package/scripts/release-loop/gate-node.ts +262 -26
  168. package/scripts/release-loop/resume-release.ts +9 -3
  169. package/scripts/release-loop/resume.ts +41 -0
  170. package/scripts/release-loop/unattended-release.ts +22 -7
  171. package/scripts/tsc-baseline-cache.ts +147 -0
  172. package/scripts/usage-rollup.ts +58 -6
  173. package/src/agent/run-context.ts +10 -0
  174. package/src/agent-mission/driver.ts +18 -3
  175. package/src/agent-mission/resource-ladder.ts +8 -3
  176. package/src/agent-mission/review-loop.ts +8 -2
  177. package/src/agent-substrate/acp-implementer.ts +139 -0
  178. package/src/agent-substrate/pr-reviewer.ts +31 -4
  179. package/src/agent-substrate/self-review-cli.ts +48 -9
  180. package/src/autopilot/mission-critique.ts +18 -5
  181. package/src/autopilot/mission-feasibility-negotiate.ts +11 -10
  182. package/src/autopilot/mission-trace.ts +12 -1
  183. package/src/autopilot/system-lookback-run.ts +16 -10
  184. package/src/bench/bench.ts +183 -0
  185. package/src/budget/fetchers/grok.ts +15 -5
  186. package/src/budget/llm-cost.ts +37 -5
  187. package/src/budget/types.ts +8 -2
  188. package/src/budget/unified-usage.ts +88 -6
  189. package/src/cli/bench-cli.ts +34 -0
  190. package/src/cli/guardian-cli.ts +26 -1
  191. package/src/cli/image-cli.ts +101 -0
  192. package/src/cli/log-event-names.ts +4 -0
  193. package/src/cli/pr-cli.ts +62 -5
  194. package/src/cli/pr-land-overlap-evidence.ts +160 -12
  195. package/src/cli/release-cli.ts +18 -9
  196. package/src/cli/rfc-status.ts +52 -2
  197. package/src/cli/self-update.ts +104 -0
  198. package/src/cli/tasks-cli.ts +109 -4
  199. package/src/cli/usage-cli.ts +91 -8
  200. package/src/core-turn/run-goal-loop.ts +5 -4
  201. package/src/dashboard/ad-run-setup-bindings.ts +279 -0
  202. package/src/dashboard/index.ts +18 -276
  203. package/src/dashboard/stale-install-check.ts +11 -0
  204. package/src/debug/log-diet.ts +38 -7
  205. package/src/debug/log.ts +19 -1
  206. package/src/domains/release-tool.ts +39 -0
  207. package/src/error-report/report.ts +21 -4
  208. package/src/github/pr-labels.ts +1 -0
  209. package/src/graph-runner/graph-cli.ts +42 -1
  210. package/src/graph-runner/runner.ts +167 -6
  211. package/src/grok/usage.ts +23 -2
  212. package/src/grounding/ref-index.ts +253 -0
  213. package/src/harness/dispatch-backpressure.ts +10 -2
  214. package/src/harness/harness-clean.ts +199 -78
  215. package/src/harness/harness-cli-command.ts +122 -7
  216. package/src/harness/harness-gc.ts +331 -0
  217. package/src/harness/harness-stop.ts +4 -2
  218. package/src/harness/harness-substrate-default.ts +142 -7
  219. package/src/harness/launch-registry.ts +6 -0
  220. package/src/harness/worktree-branch-prefix.ts +9 -0
  221. package/src/hq/fence.ts +187 -0
  222. package/src/hq/seats.ts +38 -22
  223. package/src/images/image-ledger.ts +179 -0
  224. package/src/index.ts +93 -11
  225. package/src/instance/child-scope.ts +32 -1
  226. package/src/instance/dev-project.ts +133 -0
  227. package/src/instance/resolve.ts +24 -0
  228. package/src/instance/spawn-elanous.ts +45 -0
  229. package/src/intake-plane/ref-prefetch.ts +110 -0
  230. package/src/intelligence-map/model-catalog.ts +72 -0
  231. package/src/llm/bedrock-eventstream.ts +215 -0
  232. package/src/llm/bedrock-provider.ts +114 -41
  233. package/src/llm/bedrock.ts +174 -28
  234. package/src/llm/openrouter-byok-cost.ts +96 -0
  235. package/src/llm/openrouter-deepseek.ts +151 -0
  236. package/src/llm/openrouter-upstream-pins.config.ts +25 -0
  237. package/src/llm/zai-coding-plan.ts +700 -0
  238. package/src/llm.ts +87 -16
  239. package/src/loops/checker.ts +148 -9
  240. package/src/loops/orchestrator/resync-shadow.ts +34 -7
  241. package/src/maturity/feature-maturity.ts +2 -2
  242. package/src/model-tier/llm-tier-map.ts +9 -5
  243. package/src/models/prompts.ts +2 -1
  244. package/src/mss/logging/log-store.ts +58 -11
  245. package/src/nexus/api/missions.ts +73 -2
  246. package/src/nexus/api/ops-api.ts +18 -0
  247. package/src/nexus/index.ts +7 -75
  248. package/src/nexus/tools-kind.ts +78 -0
  249. package/src/oauth/codex-account-rotation.ts +39 -2
  250. package/src/oauth/codex-account-store.ts +323 -24
  251. package/src/oauth/fallback-chain.ts +53 -15
  252. package/src/onboarding/first-run.ts +37 -18
  253. package/src/onboarding/web-first.ts +20 -2
  254. package/src/ops/machine-heartbeat.ts +185 -0
  255. package/src/ops/overview-cache.ts +175 -0
  256. package/src/ops/overview.ts +8 -0
  257. package/src/prompt-cache/openai.ts +3 -0
  258. package/src/prompt-cache/types.ts +5 -0
  259. package/src/prompt-enhance/enhance.ts +23 -0
  260. package/src/release-loop/placement.ts +16 -1
  261. package/src/requirements/requirement-ledger.ts +536 -0
  262. package/src/retro/daily.ts +5 -5
  263. package/src/seat-loop/seat-loop.ts +32 -10
  264. package/src/self-dev/dev-cli.ts +44 -10
  265. package/src/self-dev/dev-pipeline.ts +7 -2
  266. package/src/self-dev/draft-residue.ts +14 -2
  267. package/src/self-dev/draft-sweep.ts +103 -0
  268. package/src/self-dev/graph-journey-route.ts +6 -0
  269. package/src/self-dev/orchestrate-cli.ts +25 -3
  270. package/src/self-dev/orchestrate.ts +41 -6
  271. package/src/self-dev/run-supervisor.ts +188 -15
  272. package/src/self-dev/run-types.ts +13 -0
  273. package/src/self-dev/supervisor-verdict-edges.ts +1 -0
  274. package/src/self-implement/budget-gate.ts +53 -13
  275. package/src/self-implement/child-context-composition.ts +139 -0
  276. package/src/self-implement/child-llm-preference.ts +13 -5
  277. package/src/self-implement/claude-acp-implement.ts +67 -0
  278. package/src/self-implement/flex-signals.ts +59 -0
  279. package/src/self-implement/frozen-merges.ts +8 -3
  280. package/src/self-implement/goal-author-decompose.ts +10 -2
  281. package/src/self-implement/goal-author.ts +24 -9
  282. package/src/self-implement/graph-overlay-condition.ts +28 -0
  283. package/src/self-implement/graph-overlay-yaml.ts +41 -7
  284. package/src/self-implement/graph-templates.ts +33 -1
  285. package/src/self-implement/graph-yaml.ts +56 -0
  286. package/src/self-implement/heal-intake.ts +5 -1
  287. package/src/self-implement/orchestrator.ts +144 -15
  288. package/src/self-implement/running-runs.ts +75 -5
  289. package/src/self-implement/seams.ts +47 -1
  290. package/src/self-implement/self-implement-cli.ts +9 -4
  291. package/src/self-implement/stop-autoheal.ts +69 -2
  292. package/src/session-runtime/retry-policy.ts +2 -1
  293. package/src/steward/launch.ts +5 -4
  294. package/src/steward/triage-budget.ts +62 -0
  295. package/src/steward/triage.ts +83 -22
  296. package/src/task-agent/actions.ts +62 -5
  297. package/src/task-agent/completion-evidence.ts +5 -0
  298. package/src/task-agent/cover.ts +101 -3
  299. package/src/task-agent/judge.ts +16 -0
  300. package/src/task-agent/land-order-ledger.ts +95 -0
  301. package/src/task-agent/live-move-history.ts +87 -1
  302. package/src/task-agent/live-moves.ts +350 -20
  303. package/src/task-agent/rejudge-on-head.ts +75 -20
  304. package/src/task-agent/review-prior-fix.ts +146 -0
  305. package/src/task-agent/run-adopt.ts +136 -0
  306. package/src/task-agent/shadow.ts +53 -9
  307. package/src/task-agent/task-hand.ts +54 -7
  308. package/src/task-orchestrator/surfaces/pod-account-broker.ts +38 -5
  309. package/src/task-orchestrator/surfaces/pod-bedrock-child.ts +74 -0
  310. package/src/task-orchestrator/surfaces/pod-child-default.ts +50 -0
  311. package/src/task-orchestrator/surfaces/pod-child-providers.ts +14 -1
  312. package/src/task-orchestrator/surfaces/pod-failure-reason.ts +79 -6
  313. package/src/task-orchestrator/surfaces/pod-lease.ts +17 -5
  314. package/src/task-orchestrator/surfaces/pod-ledger-collect.ts +11 -5
  315. package/src/task-orchestrator/surfaces/pod-pool.ts +20 -4
  316. package/src/task-orchestrator/surfaces/pod-zai-child.ts +101 -0
  317. package/src/task-orchestrator/surfaces/self-implement-pod.ts +213 -23
  318. package/src/task-orchestrator/surfaces/self-implement.ts +19 -1
  319. package/src/typecheck-ratchet.ts +1 -0
  320. package/src/user-config.ts +51 -11
  321. package/src/version/packed-revision.json +1 -1
  322. package/src/workflow-runtime/triggers/registry.ts +59 -0
  323. package/src/workflow-runtime/triggers/webhook-source.ts +35 -5
  324. package/apps/pwa/out/_next/static/chunks/app/autopilot/page-0160ab83c8685a12.js +0 -1
  325. package/apps/pwa/out/_next/static/chunks/app/bots/page-e6784759a2531031.js +0 -1
  326. package/apps/pwa/out/_next/static/chunks/app/control/page-31417d3604154a6d.js +0 -1
  327. package/apps/pwa/out/_next/static/chunks/app/decisions/page-e9606dc0bdec9305.js +0 -1
  328. package/apps/pwa/out/_next/static/chunks/app/design-check/page-a648bc464c9dc754.js +0 -1
  329. package/apps/pwa/out/_next/static/chunks/app/field/page-d27b794c8ba76bbb.js +0 -1
  330. package/apps/pwa/out/_next/static/chunks/app/layout-22170f4f00a15496.js +0 -1
  331. package/apps/pwa/out/_next/static/chunks/app/loops/page-6e2781c523dad761.js +0 -1
  332. package/apps/pwa/out/_next/static/chunks/app/market/page-26dd415c8f13f341.js +0 -1
  333. package/apps/pwa/out/_next/static/chunks/app/not-found-015c02c4fec4023e.js +0 -1
  334. package/apps/pwa/out/_next/static/chunks/app/observatory/page-6b0ae5b5c42f6d2f.js +0 -1
  335. package/apps/pwa/out/_next/static/chunks/app/page-16258e956ea93fc2.js +0 -1
  336. package/apps/pwa/out/_next/static/chunks/app/scheduler/page-85f35dd1dd96ae87.js +0 -1
  337. package/apps/pwa/out/_next/static/chunks/app/settings/page-7350ee93f4fe1033.js +0 -1
  338. package/apps/pwa/out/_next/static/chunks/app/setup/done/page-00723458575f2b19.js +0 -1
  339. package/apps/pwa/out/_next/static/chunks/app/setup/page-745d9b6c015076f8.js +0 -1
  340. package/apps/pwa/out/_next/static/chunks/app/share/page-736d33c7414a8a1a.js +0 -1
  341. package/apps/pwa/out/_next/static/chunks/app/term/page-c782041b5f5199ba.js +0 -1
  342. package/apps/pwa/out/_next/static/chunks/app/trace/page-0c056abff82b9891.js +0 -1
  343. package/apps/pwa/out/_next/static/chunks/app/vault/page-242d668e4fbf72c4.js +0 -1
  344. package/apps/pwa/out/_next/static/chunks/app/workflows/page-81dd0d8ae923ed72.js +0 -1
  345. package/apps/pwa/out/_next/static/css/5619d59e87eddf66.css +0 -1
  346. /package/apps/pwa/out/_next/static/{rfkMm4movqkqMebBrCXiR → Q-7iofoxOEv1WX18S35of}/_buildManifest.js +0 -0
  347. /package/apps/pwa/out/_next/static/{rfkMm4movqkqMebBrCXiR → Q-7iofoxOEv1WX18S35of}/_ssgManifest.js +0 -0
@@ -1,8 +1,9 @@
1
1
  // ── 런 슈퍼바이저 — 「끝까지 돌린다」를 «판정»으로 만든다 ───────────────────────
2
2
 
3
- import { hasDelivered, triageRun, type FailureClassification } from './orchestrate.js';
3
+ import { hasDelivered, resumeKey, triageRun, type FailureClassification } from './orchestrate.js';
4
4
  import type { DeployVerifyFinding } from '../harness/browser-verify.js';
5
- import type { SelfDevJobResult, SupervisorStopReason, SupervisorNext } from './run-types.js';
5
+ import type { SelfDevJobResult, SupervisorStopReason, SupervisorNext, ReviewRework } from './run-types.js';
6
+ import { authorRepairGoal } from '../harness/helper-repair.js';
6
7
  export type { SupervisorStopReason } from './run-types.js';
7
8
  import { recordSelfDevRunSupervisorStop, selfDevRunsDir } from './run-store.js';
8
9
  import { debug } from '../debug/log.js';
@@ -23,6 +24,21 @@ export interface SupervisorRound {
23
24
  base?: string;
24
25
  actionable: number;
25
26
  reviewMustFixTrend?: SupervisorDecision['reviewMustFixTrend'];
27
+ signatures?: Record<string, string>;
28
+ oscillationRepairTaskIds?: string[];
29
+ /** Feature of each `oscillationRepairTaskIds` entry (same index) — reruns that mint a new taskId per round keep the goal. */
30
+ oscillationRepairFeatures?: string[];
31
+ /** Authored repair goal texts of that round, by taskId. */
32
+ oscillationRepairGoals?: Record<string, string>;
33
+ /** Tasks whose one main-sync relaunch this round used. */
34
+ mainSyncRelaunchTaskIds?: string[];
35
+ /** Original feature and relaunch goal text of those tasks — a rerun may mint a new taskId, so the piece is also found by goal. */
36
+ mainSyncRelaunchFeatures?: string[];
37
+ /**
38
+ * Tasks of this round that ended `status=failed` without a PR. Omitted when there are none — and on older
39
+ * history, which never measured it, so the no-PR streak guard reads it as «not measured» and stays off.
40
+ */
41
+ noPrTaskIds?: string[];
26
42
  }
27
43
 
28
44
  export const SUPERVISOR_STOP_REASONS = [
@@ -39,6 +55,7 @@ export const SUPERVISOR_STOP_REASONS = [
39
55
  'step-timeout',
40
56
  'decomposable-no-progress',
41
57
  'review-unobserved',
58
+ 'review-oscillating',
42
59
  'deliverable-unobserved',
43
60
  'deliverable-merged',
44
61
  ] as const satisfies readonly SupervisorStopReason[];
@@ -69,12 +86,18 @@ export interface SupervisorDecision {
69
86
  reworkable: string[];
70
87
  decomposable: string[];
71
88
  repairable: string[];
89
+ /** Pieces whose main sync is blocked for the first time — relaunched on the latest main instead of waiting for a human. */
90
+ relaunchOnMain: string[];
91
+ /** Relaunch goal by taskId for the `relaunchOnMain` pieces that kept a branch; the rerun receives these as `repairGoals`. */
92
+ relaunchGoals?: Record<string, string>;
72
93
  needsHuman: string[];
73
94
  classifications: FailureClassification[];
74
95
  deliverableObservation: 'not-attempted' | 'failed' | 'observed';
75
96
  deliverableUnmeasured: boolean;
76
97
  deliverableMergeCompleteness: 'unmeasured' | 'complete' | 'incomplete';
77
- reviewMustFixTrend: 'unmeasured' | 'improving' | 'stable' | 'worsening';
98
+ reviewMustFixTrend: ReviewRework['trend'];
99
+ oscillation?: { taskIds: string[]; helper: 'review-oscillation'; signature: string; repairGoals?: Record<string, string>; heldTaskIds?: string[] };
100
+ pendingDecision?: 'attempt-care-escalation';
78
101
  }
79
102
 
80
103
  export interface SupervisorLimits {
@@ -127,7 +150,19 @@ function awaitingHumanStopWhy(classifications: readonly FailureClassification[])
127
150
  }
128
151
 
129
152
  function countActionable(t: ReturnType<typeof triageRun>): number {
130
- return t.rerunnable.length + t.reworkable.length + t.decomposable.length + t.repairable.length;
153
+ return t.rerunnable.length + t.reworkable.length + t.decomposable.length + t.repairable.length + t.relaunchOnMain.length;
154
+ }
155
+
156
+ /** The goal a main-sync relaunch runs: the same goal text under one head line naming the preserved branch. */
157
+ export function mainSyncRelaunchGoal(feature: string, branch: string): string {
158
+ return `참고 가지: ${branch} — 앞 런 구현. 최신 main 위에서 같은 의도를 다시 구현하되 이 가지의 diff 를 참고\n${feature}`;
159
+ }
160
+
161
+ /** A piece gets one main-sync relaunch: spent when an earlier round recorded its task or its goal (original or relaunch text). */
162
+ function mainSyncRelaunchSpent(history: readonly SupervisorRound[]): (result: SelfDevJobResult) => boolean {
163
+ const taskIds = new Set(history.flatMap((entry) => entry.mainSyncRelaunchTaskIds ?? []));
164
+ const features = new Set(history.flatMap((entry) => entry.mainSyncRelaunchFeatures ?? []).map(resumeKey));
165
+ return (result) => taskIds.has(result.taskId) || features.has(resumeKey(result.feature));
131
166
  }
132
167
 
133
168
  type GoalPlanRevisionObservation = SelfDevJobResult['goalPlanRevision'];
@@ -172,6 +207,13 @@ export type SupervisorJobResult = SelfDevJobResult & {
172
207
  next?: SupervisorNext;
173
208
  };
174
209
 
210
+ export function aggregateReviewTrend(results: readonly SelfDevJobResult[]): ReviewRework['trend'] | undefined {
211
+ const trends = results.flatMap((result) => result.rework ? [result.rework.trend] : []);
212
+ if (!trends.length) return undefined;
213
+ const severity: readonly ReviewRework['trend'][] = ['unmeasured', 'improving', 'stable', 'worsening', 'oscillating'];
214
+ return severity[Math.max(...trends.map((trend) => severity.indexOf(trend)))];
215
+ }
216
+
175
217
  export function decideNextRun(input: {
176
218
  results: readonly SupervisorJobResult[];
177
219
  history?: readonly SupervisorRound[];
@@ -181,7 +223,9 @@ export function decideNextRun(input: {
181
223
  reviewed?: boolean;
182
224
  reviewReason?: string;
183
225
  deliverableMerge?: { readonly expected: number; readonly merged: number };
184
- reviewMustFixTrend?: 'improving' | 'stable' | 'worsening';
226
+ reviewMustFixTrend?: ReviewRework['trend'];
227
+ /** True: the rerun consumes the authored goal. False: it cannot, so oscillation stops for a human. Undefined: pure decision. */
228
+ repairGoalExecution?: boolean;
185
229
  }): SupervisorDecision {
186
230
  const results = [...input.results];
187
231
  const history = [...(input.history ?? [])];
@@ -198,7 +242,16 @@ export function decideNextRun(input: {
198
242
  const handedOffIds = new Set(handedOff.map((result) => result.taskId));
199
243
  const deployFindings = input.deployFindings === undefined ? undefined
200
244
  : new Map([...input.deployFindings].filter(([taskId]) => !handedOffIds.has(taskId)));
201
- const t = triageRun(activeResults, deployFindings, observation === 'failed');
245
+ const t = triageRun(activeResults, deployFindings, observation === 'failed', undefined, mainSyncRelaunchSpent(history));
246
+ const relaunchGoals: Record<string, string> = Object.fromEntries(activeResults.flatMap((result) =>
247
+ t.relaunchOnMain.includes(result.taskId) && result.branch
248
+ ? [[result.taskId, mainSyncRelaunchGoal(result.feature, result.branch)]] : []));
249
+ const noteMainSyncRelaunch = (): void => {
250
+ for (const taskId of t.relaunchOnMain) {
251
+ const branch = activeResults.find((result) => result.taskId === taskId)?.branch ?? null;
252
+ try { debug.log('self-dev.supervisor', 'merge-conflict-relaunch', { taskId, branch, attempt: 1 }); } catch { /* fail-open */ }
253
+ }
254
+ };
202
255
  const round = history.length;
203
256
  const landed = countLanded(results);
204
257
  const baseCompleted = countBaseCompleted(results);
@@ -230,6 +283,8 @@ export function decideNextRun(input: {
230
283
  reworkable: t.reworkable,
231
284
  decomposable: t.decomposable,
232
285
  repairable: t.repairable,
286
+ relaunchOnMain: t.relaunchOnMain,
287
+ ...(Object.keys(relaunchGoals).length > 0 ? { relaunchGoals } : {}),
233
288
  needsHuman: t.needsHuman,
234
289
  classifications: t.classifications,
235
290
  };
@@ -244,8 +299,10 @@ export function decideNextRun(input: {
244
299
  };
245
300
  }
246
301
 
247
- const harvestable = results.filter((result) => result.harvestable === true && !!result.branch);
248
- if (harvestable.length > 0) {
302
+ // A first main-sync block is relaunched before it is judged harvestable; the spent ones stop for a human as before.
303
+ const harvestable = results.filter((result) => result.harvestable === true && !!result.branch
304
+ && !t.relaunchOnMain.includes(result.taskId));
305
+ if (harvestable.length > 0 && t.relaunchOnMain.length === 0) {
249
306
  return {
250
307
  ...base,
251
308
  action: 'stop',
@@ -308,6 +365,7 @@ export function decideNextRun(input: {
308
365
  && t.reworkable.length === 0
309
366
  && t.decomposable.length === 0
310
367
  && t.repairable.length === 0
368
+ && t.relaunchOnMain.length === 0
311
369
  ) {
312
370
  return {
313
371
  ...base,
@@ -335,7 +393,7 @@ export function decideNextRun(input: {
335
393
  }
336
394
 
337
395
  // Only stop when every candidate for the next round is blocked by observed quota exhaustion.
338
- const retryIds = [...new Set([...t.rerunnable, ...t.reworkable, ...t.decomposable, ...t.repairable])];
396
+ const retryIds = [...new Set([...t.rerunnable, ...t.reworkable, ...t.decomposable, ...t.repairable, ...t.relaunchOnMain])];
339
397
  if (retryIds.length > 0 && retryIds.every((taskId) => results.some((result) =>
340
398
  result.taskId === taskId && result.providerErrors?.category === 'quota'))) {
341
399
  const failures = results.filter((result) => retryIds.includes(result.taskId));
@@ -375,7 +433,7 @@ export function decideNextRun(input: {
375
433
  }
376
434
  // 🩸 2026-09-24 🅕: 결말을 가른 것은 공급자 오류 수가 아니라 «리뷰가 시간 안에 판정을 냈나»였다(n=3 · step-timeout 0·1·2
377
435
  // 가 결말과 같은 순서). 제자리의 원인이 단계 시간 초과면 «골을 의심하라» 대신 그 이름을 댄다.
378
- const stalledRetryIds = [...new Set([...t.rerunnable, ...t.reworkable, ...t.decomposable, ...t.repairable])];
436
+ const stalledRetryIds = [...new Set([...t.rerunnable, ...t.reworkable, ...t.decomposable, ...t.repairable, ...t.relaunchOnMain])];
379
437
  const timedOut = results.filter((result) => stalledRetryIds.includes(result.taskId) && result.stage === 'timed-out');
380
438
  if (stalledRetryIds.length > 0 && timedOut.length === stalledRetryIds.length) {
381
439
  const providerNote = timedOut.some((result) => result.providerErrors)
@@ -397,6 +455,85 @@ export function decideNextRun(input: {
397
455
  }
398
456
  }
399
457
 
458
+ // AUT-NO-PROGRESS-RETRY-LOOP — 같은 후보가 PR 없이 두 라운드 연속 실패하면 세 번째 Pod 를 띄우지 않는다
459
+ // (부검 run-1166bcd1 · run-1bde4815 · run-427bd632 · run-46a02f42). 직전 라운드가 noPrTaskIds 를 안 쟀으면 서지 않는다.
460
+ // 호출자가 stallRounds 를 기본보다 늘렸으면(제자리 인내를 늘림) 서지 않는다 — 0.2.24 컷 회귀(orchestrate-cli.test 라운드 상한 둘).
461
+ const previousNoPr = history.at(-1)?.noPrTaskIds;
462
+ if (previousNoPr !== undefined && retryIds.length > 0 && stallRounds <= DEFAULT_STALL_ROUNDS) {
463
+ const failedNoPr = (taskId: string) => activeResults.find((result) => result.taskId === taskId
464
+ && result.status === 'failed' && result.prNumber === undefined);
465
+ const streak = retryIds.every((taskId) => previousNoPr.includes(taskId) && failedNoPr(taskId) !== undefined);
466
+ if (streak && !madeProgress(history.at(-1), thisRound)) {
467
+ const errors = retryIds.flatMap((taskId) => {
468
+ const message = failedNoPr(taskId)?.error?.message;
469
+ return message ? [message.slice(0, 200)] : [];
470
+ });
471
+ try { debug.log('self-dev.supervisor', 'no-pr-streak-stop', { taskIds: retryIds, round, errors }); } catch { /* fail-open */ }
472
+ return {
473
+ ...base,
474
+ action: 'stop',
475
+ stopReason: 'no-progress',
476
+ why: ['PR 없이 2라운드 연속 실패 — 같은 골 재시도 대신 골·불변식 개정 또는 hold', ...errors].join(' · '),
477
+ };
478
+ }
479
+ }
480
+
481
+ const preceding = history.at(-1);
482
+ const oscillating = activeResults.filter((result) => retryIds.includes(result.taskId) && result.rework
483
+ && (result.rework.trend === 'oscillating'
484
+ || !!result.rework.signature && preceding?.signatures?.[result.taskId] === result.rework.signature));
485
+ if (oscillating.length > 0) {
486
+ // Repaired = same taskId, explicit lineage (`oscillationRepairOf`), or a feature that IS an authored repair goal
487
+ // text (orchestrate runs it as the piece's feature) — never a mere shared original feature.
488
+ const isRepaired = (result: SupervisorJobResult): boolean => history.some((entry) =>
489
+ (entry.oscillationRepairTaskIds ?? []).some((id, index) => id === result.taskId || id === result.oscillationRepairOf
490
+ || (entry.oscillationRepairFeatures?.[index] !== undefined && entry.oscillationRepairFeatures[index] === result.feature
491
+ && Object.values(entry.oscillationRepairGoals ?? {}).includes(result.feature))));
492
+ // Per task: a task that already got its one oscillation repair is held for a human; a fresh one may get it.
493
+ const fresh = oscillating.filter((result) => !isRepaired(result));
494
+ const held = [...new Set(oscillating.filter(isRepaired).map((result) => result.taskId))];
495
+ const repairGoals: Record<string, string> = Object.fromEntries(fresh.flatMap((result) => {
496
+ const goal = result.prNumber && result.reviewMustFix?.length
497
+ ? authorRepairGoal({ pr: result.prNumber, category: 'review-oscillation', originalRequest: result.feature,
498
+ mustFix: result.reviewMustFix }) : null;
499
+ return goal ? [[result.taskId, goal]] : [];
500
+ }));
501
+ // A caller that declares it cannot run the authored goal (false), or one that can but has no goal for every fresh
502
+ // oscillating task, would turn add-repair-task into a same-strategy relaunch — stop for a human instead.
503
+ // Undefined is the pure decision (caller unknown): it names the first repair as the goal contract asks.
504
+ const cannotRepair = fresh.length > 0 && (input.repairGoalExecution === false
505
+ || (input.repairGoalExecution === true && fresh.some((result) => !repairGoals[result.taskId])));
506
+ const action = fresh.length === 0 || cannotRepair ? 'stop' : 'add-repair-task';
507
+ const taskIds = action === 'stop'
508
+ ? [...new Set(oscillating.map((result) => result.taskId))]
509
+ : [...new Set(fresh.map((result) => result.taskId))];
510
+ const signatureOf = (results: readonly SupervisorJobResult[]): string => results.map((result) => result.rework!.signature).join(' · ') || '(서명 없음)';
511
+ const signature = oscillating.filter((result) => taskIds.includes(result.taskId)).map((result) => result.rework!.signature).join(' · ');
512
+ const withoutHeld = (ids: readonly string[]): string[] => ids.filter((id) => !held.includes(id));
513
+ try { debug.log('self-dev.supervisor', 'oscillation-seen', { taskIds, signature, trend: reviewMustFixTrend, action, ...(held.length ? { held } : {}) }); } catch { /* fail-open */ }
514
+ if (action === 'add-repair-task') noteMainSyncRelaunch();
515
+ return {
516
+ ...base,
517
+ ...(action === 'add-repair-task' && held.length > 0 ? {
518
+ rerunnable: withoutHeld(base.rerunnable), reworkable: withoutHeld(base.reworkable),
519
+ decomposable: withoutHeld(base.decomposable), repairable: withoutHeld(base.repairable),
520
+ needsHuman: [...new Set([...base.needsHuman, ...held])],
521
+ } : {}),
522
+ action,
523
+ ...(action === 'stop' ? { stopReason: 'review-oscillating' as const } : {}),
524
+ oscillation: { taskIds, helper: 'review-oscillation', signature, ...(Object.keys(repairGoals).length ? { repairGoals } : {}),
525
+ ...(action === 'add-repair-task' && held.length ? { heldTaskIds: held } : {}) },
526
+ pendingDecision: 'attempt-care-escalation',
527
+ why: fresh.length === 0
528
+ ? `리뷰 진동 반복 — ${signatureOf(oscillating)} · 사람 결정 필요(같은 전략 재발사 금지)`
529
+ : cannotRepair
530
+ ? `리뷰 진동 — ${signatureOf(oscillating)} · ${input.repairGoalExecution === false ? '이 감독 경로가 수리 골 실행을 선언하지 않았다(미선언 또는 불가)' : '수리 원문/PR 관측 불가'} · 사람 결정 필요(같은 전략 재발사 금지)`
531
+ : `리뷰 진동 — ${signatureOf(fresh)} · review-oscillation 수리 조각을 한 번 붙인다${input.repairGoalExecution === true ? '' : '(실행 배선 미선언 — 결정 칸만)'}${held.length ? ` · 이미 수리한 조각 ${held.join(', ')} 은 사람 결정 대기` : ''}`,
532
+ };
533
+ }
534
+
535
+ noteMainSyncRelaunch();
536
+
400
537
  if (t.repairable.length > 0) {
401
538
  return {
402
539
  ...base,
@@ -408,7 +545,7 @@ export function decideNextRun(input: {
408
545
  return {
409
546
  ...base,
410
547
  action: 'relaunch',
411
- why: `다시 건다 — 그대로 재실행 ${t.rerunnable.length} · 재작업 ${t.reworkable.length} · 분해 ${t.decomposable.length} · 수리 ${t.repairable.length} · 라운드 ${round + 1}/${maxRounds}`,
548
+ why: `다시 건다 — 그대로 재실행 ${t.rerunnable.length} · 재작업 ${t.reworkable.length} · 분해 ${t.decomposable.length} · 수리 ${t.repairable.length}${t.relaunchOnMain.length > 0 ? ` · main 위 재발사 ${t.relaunchOnMain.length}` : ''} · 라운드 ${round + 1}/${maxRounds}`,
412
549
  };
413
550
  }
414
551
 
@@ -416,22 +553,46 @@ export function appendRound(
416
553
  history: readonly SupervisorRound[],
417
554
  results: readonly SupervisorJobResult[],
418
555
  reviewMustFixTrend?: SupervisorDecision['reviewMustFixTrend'],
556
+ decision?: SupervisorDecision,
419
557
  ): SupervisorRound[] {
420
- const t = triageRun(results.filter((result) => result.salvage !== 'launched'));
558
+ const t = triageRun(results.filter((result) => result.salvage !== 'launched'), undefined, false, undefined, mainSyncRelaunchSpent(history));
421
559
  const baseCompleted = countBaseCompleted(results);
422
560
  const base = roundBase(results);
561
+ const noPrTaskIds = results.filter((result) => result.status === 'failed' && result.prNumber === undefined)
562
+ .map((result) => result.taskId);
423
563
  return [...history, {
424
564
  round: history.length,
425
565
  landed: countLanded(results),
426
566
  ...(baseCompleted > 0 || base !== undefined ? { baseCompleted, ...(base === undefined ? {} : { base }) } : {}),
427
567
  actionable: countActionable(t),
428
568
  ...(reviewMustFixTrend === undefined ? {} : { reviewMustFixTrend }),
569
+ ...(results.some((result) => result.rework?.signature)
570
+ ? { signatures: Object.fromEntries(results.filter((result) => result.rework?.signature).map((result) => [result.taskId, result.rework!.signature])) } : {}),
571
+ ...(decision && decision.action !== 'stop' && decision.relaunchOnMain.length > 0 ? {
572
+ mainSyncRelaunchTaskIds: decision.relaunchOnMain,
573
+ mainSyncRelaunchFeatures: decision.relaunchOnMain.flatMap((id) => [
574
+ results.find((result) => result.taskId === id)?.feature,
575
+ decision.relaunchGoals?.[id],
576
+ ].filter((feature): feature is string => feature !== undefined)),
577
+ } : {}),
578
+ ...(decision?.action === 'add-repair-task' && decision.oscillation ? (() => {
579
+ // Each repaired task is recorded under its original goal feature and, when a rerun runs the authored goal as
580
+ // the piece's new feature (orchestrate), under that repair text too — so the repair's own oscillation stops.
581
+ const pairs = decision.oscillation.taskIds.flatMap((id) => {
582
+ const feature = results.find((result) => result.taskId === id)?.feature ?? '';
583
+ const repairGoal = decision.oscillation!.repairGoals?.[id];
584
+ return repairGoal === undefined ? [[id, feature]] : [[id, feature], [id, repairGoal]];
585
+ });
586
+ return { oscillationRepairTaskIds: pairs.map(([id]) => id!), oscillationRepairFeatures: pairs.map(([, feature]) => feature!),
587
+ ...(decision.oscillation.repairGoals ? { oscillationRepairGoals: decision.oscillation.repairGoals } : {}) };
588
+ })() : {}),
589
+ ...(noPrTaskIds.length > 0 ? { noPrTaskIds } : {}),
429
590
  }];
430
591
  }
431
592
 
432
593
  export interface SuperviseRunOptions {
433
594
  initial: readonly SupervisorJobResult[];
434
- rerun: (previous: readonly SupervisorJobResult[], invocation: { relaunch: true }) => Promise<readonly SupervisorJobResult[]>;
595
+ rerun: (previous: readonly SupervisorJobResult[], invocation: { relaunch: true; repairGoals?: Record<string, string> }) => Promise<readonly SupervisorJobResult[]>;
435
596
  limits?: SupervisorLimits;
436
597
  enrich?: (results: readonly SupervisorJobResult[]) => readonly SupervisorJobResult[];
437
598
  onDecision?: (decision: SupervisorDecision) => void;
@@ -443,6 +604,8 @@ export interface SuperviseRunOptions {
443
604
  runStore?: { runId?: string; operatorDir?: string; dir?: string; isolatedDir?: string };
444
605
  observe?: (event: string, data: Record<string, unknown>) => void;
445
606
  sweepPendingMerges?: typeof sweepFrozenMerges;
607
+ /** True only when rerun consumes `invocation.repairGoals`; omitted or false → a review oscillation stops for a human. */
608
+ repairGoalExecution?: boolean;
446
609
  /**
447
610
  * TASK-AGENT-SHADOW — 멈춤이 확정되면 판단부를 그림자로 부른다(기본 `recordTaskAgentShadowMove`).
448
611
  * `false` 면 끈다. 던져도 런의 결말은 바뀌지 않는다(fail-soft).
@@ -512,6 +675,9 @@ export async function superviseRun(opts: SuperviseRunOptions): Promise<Superviso
512
675
  const decision = decideNextRun({
513
676
  results,
514
677
  history,
678
+ // Undeclared = cannot run the repair goal: an add-repair-task would otherwise be a same-strategy relaunch.
679
+ repairGoalExecution: opts.repairGoalExecution === true,
680
+ ...(aggregateReviewTrend(results) ? { reviewMustFixTrend: aggregateReviewTrend(results) } : {}),
515
681
  ...(opts.limits ? { limits: opts.limits } : {}),
516
682
  ...(observed.deployFindings ? { deployFindings: observed.deployFindings } : {}),
517
683
  deliverableObservation: observed.state,
@@ -616,8 +782,15 @@ export async function superviseRun(opts: SuperviseRunOptions): Promise<Superviso
616
782
  return results;
617
783
  }
618
784
 
619
- history = appendRound(history, results, decision.reviewMustFixTrend);
620
- results = [...await opts.rerun(results, { relaunch: true })];
785
+ history = appendRound(history, results, decision.reviewMustFixTrend, decision);
786
+ // Tasks that already had their one oscillation repair are held for a human — they are not handed to the rerun,
787
+ // but their results stay in the round so the human hand-off (and the final review-oscillating stop) keeps them.
788
+ const held = decision.oscillation?.heldTaskIds ?? [];
789
+ const heldResults = results.filter((result) => held.includes(result.taskId));
790
+ const repairGoals = { ...decision.relaunchGoals, ...decision.oscillation?.repairGoals };
791
+ const rerunResults = await opts.rerun(held.length ? results.filter((result) => !held.includes(result.taskId)) : results,
792
+ { relaunch: true, ...(Object.keys(repairGoals).length > 0 ? { repairGoals } : {}) });
793
+ results = [...rerunResults, ...heldResults.filter((heldResult) => !rerunResults.some((result) => result.taskId === heldResult.taskId))];
621
794
 
622
795
  try {
623
796
  opts.onRound?.(results);
@@ -63,6 +63,12 @@ export interface SelfDevGoal {
63
63
  hotPaths?: string[];
64
64
  }
65
65
 
66
+ export type ReviewRework = {
67
+ trend: 'unmeasured' | 'improving' | 'stable' | 'worsening' | 'oscillating';
68
+ signature: string;
69
+ rounds: number;
70
+ };
71
+
66
72
  export interface SelfDevJobResult {
67
73
  taskId: string;
68
74
  feature: string;
@@ -115,6 +121,12 @@ export interface SelfDevJobResult {
115
121
  /** Self review verdict bound to the PR head observed by the child; absent if either observation is missing. */
116
122
  /** TA-LAND-MUSTFIX-ZERO — `mustFixCount` is the review's must-fix list length; absent = unknown (the land gate fails closed). */
117
123
  selfReview?: { verdict: 'pass' | 'fail'; head: string; mustFixCount?: number };
124
+ /** Measured child review history; absence means not observed, not a negative oscillation result. */
125
+ rework?: ReviewRework;
126
+ /** taskId whose review-oscillation repair produced this result (explicit lineage across a new taskId). */
127
+ oscillationRepairOf?: string;
128
+ /** Verbatim final reviewer must-fix items for a bounded helper repair. */
129
+ reviewMustFix?: string[];
118
130
  /** Whether the child review actually ran; omitted preserves legacy producers. */
119
131
  reviewed?: boolean;
120
132
  /** Why the child did not run review; omitted preserves legacy review-unobserved handling. */
@@ -172,6 +184,7 @@ export type SupervisorStopReason =
172
184
  | 'step-timeout'
173
185
  | 'decomposable-no-progress'
174
186
  | 'review-unobserved'
187
+ | 'review-oscillating'
175
188
  | 'deliverable-unobserved'
176
189
  | 'deliverable-merged';
177
190
 
@@ -18,6 +18,7 @@ export const SUPERVISOR_VERDICT_EDGES = {
18
18
  'step-timeout': { meaning: 'step budget exhausted', next: 'human-gate' },
19
19
  'decomposable-no-progress': { meaning: 'stalled with a decomposition proposal', next: 'scope-decompose' },
20
20
  'review-unobserved': { meaning: 'review was not observed', next: 'self-review' },
21
+ 'review-oscillating': { meaning: 'review oscillation needs a human decision (its one repair is spent or cannot run here)', next: 'human-gate' },
21
22
  'deliverable-unobserved': { meaning: 'deliverable was not observed', next: 'self-review' },
22
23
  'deliverable-merged': { meaning: 'deliverable is merged', next: 'harvest' },
23
24
  } as const satisfies Record<SupervisorStopReason, SupervisorVerdictEdge>;
@@ -2,8 +2,8 @@
2
2
  // 회전·사용량 저장소·선호 해석은 기존 함수를 부른다. 여기선 다시 만들지 않는다.
3
3
 
4
4
  import type { RotationCandidate } from '../oauth/codex-account-rotation.js';
5
- import { inspectCodexRotation } from '../oauth/codex-account-store.js';
6
- import { codexPolicyAllowsCredits } from '../oauth/codex-quota-policy.js';
5
+ import { DEFAULT_CODEX_CREDIT_RESERVE, inspectCodexRotation } from '../oauth/codex-account-store.js';
6
+ import { codexPolicyAllowsCredits, codexPolicyAllowsFallback } from '../oauth/codex-quota-policy.js';
7
7
  import { getUsageStore } from '../budget/usage-store.js';
8
8
  import type { UsageSnapshot } from '../budget/types.js';
9
9
  import { debug } from '../debug/log.js';
@@ -35,7 +35,7 @@ export interface BudgetCodexCandidate {
35
35
 
36
36
  export interface DecideBudgetInput {
37
37
  readonly preference: {
38
- readonly chain: readonly { readonly provider: string; readonly model?: string }[];
38
+ readonly chain: readonly { readonly provider: string; readonly model?: string; readonly codexCredits?: true }[];
39
39
  readonly budgetGate: { readonly onShortfall: BudgetGateOnShortfall };
40
40
  };
41
41
  readonly codexCandidates: readonly BudgetCodexCandidate[];
@@ -44,6 +44,8 @@ export interface DecideBudgetInput {
44
44
  readonly maxUsedPercent: BudgetGateMaxUsedPercent;
45
45
  /** codex 한도 정책이 credits 인가(`codexPolicyAllowsCredits` · 회전·Pod 배분과 같은 해석). 없으면 false. */
46
46
  readonly codexCreditsAllowed?: boolean;
47
+ /** SUBSCRIPTION-EXHAUST-REROUTE — `llm.codexCreditReserve`. 잔액이 이 값 «초과»인 계정만 크레딧 후보다. 없으면 종전(> 0). */
48
+ readonly codexCreditReserve?: number;
47
49
  }
48
50
 
49
51
  export interface BudgetDecision {
@@ -59,6 +61,13 @@ export interface BudgetInputs {
59
61
  readonly grokUsedPercent: number | undefined;
60
62
  readonly maxUsedPercent: BudgetGateMaxUsedPercent;
61
63
  readonly codexCreditsAllowed?: boolean;
64
+ readonly codexCreditReserve?: number;
65
+ }
66
+
67
+ /** `llm.codexCreditReserve` from the same config the preference was read from — invalid or absent = default. */
68
+ function budgetCreditReserve(config: ChildLlmPreferenceInput): number {
69
+ const raw = (config as { llm?: { codexCreditReserve?: unknown } }).llm?.codexCreditReserve;
70
+ return typeof raw === 'number' && Number.isFinite(raw) && raw >= 0 ? raw : DEFAULT_CODEX_CREDIT_RESERVE;
62
71
  }
63
72
 
64
73
  const WEEKLY_WINDOW_MINUTES = 7 * 24 * 60;
@@ -109,11 +118,15 @@ function codexCandidateUsable(candidate: BudgetCodexCandidate, cap: number | und
109
118
 
110
119
  /** BUDGET-GATE(10-05) — 정책이 credits 면 구독 % 가 차도 크레딧 잔액이 «확인된» 계정으로 계속 간다(Pod 배분과 같은 결론).
111
120
  * 잔액을 모르면 쓰지 않는다 — 크레딧은 돈이라 fail-closed. 잔액이 가장 큰 계정 하나를 돌려준다. */
112
- function codexCreditCandidate(input: DecideBudgetInput): BudgetCodexCandidate | undefined {
113
- if (input.codexCreditsAllowed !== true) return undefined;
121
+ function codexCreditCandidate(input: DecideBudgetInput, creditsStep = false): BudgetCodexCandidate | undefined {
122
+ // `codex-credits` 칸은 «체인이 거기까지 왔을 때»만 크레딧을 연다 — 정책(첫 칸)의 크레딧 금지와 별개다.
123
+ if (input.codexCreditsAllowed !== true && !creditsStep) return undefined;
124
+ // The credits step (new spend path) defaults to the reserve when none was passed — money, fail-closed; the policy path keeps > 0.
125
+ const floor = typeof input.codexCreditReserve === 'number' && Number.isFinite(input.codexCreditReserve) && input.codexCreditReserve >= 0
126
+ ? input.codexCreditReserve : creditsStep && input.codexCreditsAllowed !== true ? DEFAULT_CODEX_CREDIT_RESERVE : 0;
114
127
  return input.codexCandidates
115
128
  .filter((candidate) => candidate.hasCredits !== false
116
- && typeof candidate.creditBalance === 'number' && Number.isFinite(candidate.creditBalance) && candidate.creditBalance > 0)
129
+ && typeof candidate.creditBalance === 'number' && Number.isFinite(candidate.creditBalance) && candidate.creditBalance > floor)
117
130
  .sort((a, b) => (b.creditBalance! - a.creditBalance!) || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))[0];
118
131
  }
119
132
 
@@ -121,7 +134,19 @@ function slotUsable(
121
134
  provider: string,
122
135
  input: DecideBudgetInput,
123
136
  allowUnmeasured = false,
137
+ codexCreditsSlot = false,
124
138
  ): { usable: boolean; reason: string; unmeasured?: boolean } {
139
+ if (provider === CODEX_PROVIDER && codexCreditsSlot) {
140
+ // CODEX-CREDITS-STEP — 잔액이 «확인된» 계정만(모르면 못 쓴다 · 돈이라 fail-closed). 미측정 통과도 «없다».
141
+ const credit = codexCreditCandidate(input, true);
142
+ if (!credit) {
143
+ // 칸에 «닿았지만» 잔액 확인된 계정이 없다 — 실패한 도달도 남긴다.
144
+ try { debug.log('budget.gate', 'codex-credits-step', { outcome: 'skipped', why: 'codex-credits-unavailable' }); } catch { /* observation is fail-soft */ }
145
+ }
146
+ return credit
147
+ ? { usable: true, reason: `codex-credits: ${credit.name} 크레딧 잔액 ${credit.creditBalance} (체인 마지막 칸 · 과금)` }
148
+ : { usable: false, reason: 'codex-credits: 잔액이 확인된 계정 없음' };
149
+ }
125
150
  if (provider === CODEX_PROVIDER) {
126
151
  const cap = capFor(input.maxUsedPercent, CODEX_PROVIDER);
127
152
  const measuredUsable = input.codexCandidates.some((candidate) => codexCandidateUsable(candidate, cap));
@@ -139,16 +164,19 @@ function slotUsable(
139
164
  }
140
165
  if (provider === GROK_PROVIDER) {
141
166
  const configured = capFor(input.maxUsedPercent, GROK_PROVIDER);
142
- // 발사 관문은 `elanous usage` 와 같은 주간 사용률에 80% 상한을 실제로 적용한다.
143
- // «못 쟀다»(undefined)는 통과가 아니다. decideBudget 은 설정 상한을 그대로 쓴다.
167
+ // 발사 관문은 잰 주간 사용률에만 80% 상한을 적용한다.
168
+ // «못 쟀다»(undefined)는 allowUnmeasured 일 때 통과하고 unmeasured 를 남긴다(codex 와 같은 꼴).
169
+ // decideBudget 은 설정 상한을 그대로 쓰고 모름을 통과로 보지 않는다.
144
170
  const cap = allowUnmeasured ? LAUNCH_GROK_USED_PERCENT_CAP : configured;
145
171
  const known = typeof input.grokUsedPercent === 'number' && Number.isFinite(input.grokUsedPercent);
146
- const usable = cap === undefined
172
+ const measuredUsable = cap === undefined
147
173
  ? known
148
174
  : known && (input.grokUsedPercent as number) < cap;
175
+ const unmeasured = allowUnmeasured && !known;
149
176
  return {
150
- usable,
177
+ usable: measuredUsable || unmeasured,
151
178
  reason: formatGrokReason(input.grokUsedPercent, cap),
179
+ ...(unmeasured ? { unmeasured: true } : {}),
152
180
  };
153
181
  }
154
182
  return { usable: false, reason: `${provider}: 예산 판정 없음` };
@@ -176,13 +204,19 @@ function decideBudgetWithPolicy(input: DecideBudgetInput, allowUnmeasured: boole
176
204
  let firstUnusable = false;
177
205
  for (let index = 0; index < input.preference.chain.length; index++) {
178
206
  const slot = input.preference.chain[index]!;
179
- const judged = slotUsable(slot.provider, input, allowUnmeasured);
207
+ const judged = slotUsable(slot.provider, input, allowUnmeasured, slot.codexCredits === true);
180
208
  reasons.push(judged.reason);
181
209
  if (!judged.usable) {
182
210
  if (index === 0) firstUnusable = true;
183
211
  continue;
184
212
  }
185
213
  const action: BudgetAction = index === 0 || !firstUnusable ? 'proceed' : 'next-provider';
214
+ if (slot.codexCredits === true) {
215
+ try {
216
+ // 체인이 «마지막 칸»(유료)에 닿을 때마다 한 줄 — 앞 칸을 왜 못 썼나는 reasons 가 말한다(비밀 없음).
217
+ debug.log('budget.gate', 'codex-credits-step', { outcome: 'credits', action, reasons, launch: allowUnmeasured }, { level: 'warn' });
218
+ } catch { /* observation is fail-soft */ }
219
+ }
186
220
  return {
187
221
  decision: {
188
222
  action,
@@ -230,8 +264,12 @@ export interface ReadBudgetInputsDeps {
230
264
  /** 설정·codex 회전·grok 스냅숏을 읽어 판정 입력을 만든다. 판정 자체는 하지 않는다. */
231
265
  export function readBudgetInputs(deps: ReadBudgetInputsDeps = {}): BudgetInputs {
232
266
  const config = deps.config ?? deps.loadConfig?.() ?? loadLiveConfig();
233
- const preference = resolveChildLlmPreference(config);
267
+ const resolved = resolveChildLlmPreference(config);
234
268
  const rotation = (deps.inspectCodex ?? inspectCodexRotation)();
269
+ // 정책 within-quota(한도 안에서만)는 크레딧을 «절대» 안 쓴다 — `codex-credits` 칸도 뺀다(회전·폴백 판정과 같은 해석).
270
+ const preference = rotation.policy && !codexPolicyAllowsFallback(rotation.policy.policy)
271
+ ? { ...resolved, chain: resolved.chain.filter((slot) => slot.codexCredits !== true) }
272
+ : resolved;
235
273
  const snapshot = deps.grokSnapshot
236
274
  ? deps.grokSnapshot()
237
275
  : getUsageStore().getSnapshot('grok');
@@ -242,7 +280,9 @@ export function readBudgetInputs(deps: ReadBudgetInputsDeps = {}): BudgetInputs
242
280
  grokUsedPercent: grokWeeklyUsedPercent(snapshot),
243
281
  maxUsedPercent,
244
282
  // 회전·Pod 배분과 같은 해석(`resolveCodexQuotaPolicy` → `codexPolicyAllowsCredits`)을 읽는다 — 다시 짓지 않는다.
245
- ...(rotation.policy && codexPolicyAllowsCredits(rotation.policy.policy) ? { codexCreditsAllowed: true } : {}),
283
+ ...(rotation.policy && codexPolicyAllowsCredits(rotation.policy.policy) ? { codexCreditsAllowed: true, codexCreditReserve: budgetCreditReserve(config) }
284
+ // CODEX-CREDITS-STEP — the `codex-credits` slot keeps the same reserve (a credit spend below it is the case the reserve exists for).
285
+ : preference.chain.some((slot) => slot.codexCredits === true) ? { codexCreditReserve: budgetCreditReserve(config) } : {}),
246
286
  };
247
287
  }
248
288