@tea-agent/loop-agent 0.1.0-fe-test.5 → 0.1.0-fe-test.6

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 (552) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +441 -2525
  3. package/README.md +19 -12
  4. package/dist/adapters/loop-agent.js +34 -0
  5. package/dist/application/dag/args.js +8 -0
  6. package/dist/application/dag/run-dag.js +5 -0
  7. package/dist/application/evaluation/budget.js +40 -1
  8. package/dist/application/evaluation/corpus-hash.js +10 -15
  9. package/dist/application/evaluation/corpus.js +2 -1
  10. package/dist/application/evaluation/frontend-browser-acceptance.js +77 -0
  11. package/dist/application/evaluation/frontend-corpus-browser-acceptance.js +175 -0
  12. package/dist/application/evaluation/frontend-gateway-evidence.js +226 -0
  13. package/dist/application/evaluation/frontend-pair-registration.js +143 -0
  14. package/dist/application/evaluation/frontend-paired-summary.js +150 -0
  15. package/dist/application/evaluation/frontend-run-observation.js +144 -0
  16. package/dist/application/evaluation/frontend-shared-evidence.js +105 -0
  17. package/dist/application/evaluation/types.js +45 -12
  18. package/dist/application/task-lifecycle/advance.js +64 -15
  19. package/dist/application/task-lifecycle/observe.js +69 -30
  20. package/dist/application/task-lifecycle/plan-transitions.js +5 -4
  21. package/dist/build-stamp.json +3 -3
  22. package/dist/cli/command-definitions.js +18 -5
  23. package/dist/cli/program.js +8 -5
  24. package/dist/cli/update/init-surface-notifier.js +2 -0
  25. package/dist/cli/update/policy.js +2 -0
  26. package/dist/commands/client-recovery.js +20 -55
  27. package/dist/commands/cursor-prompt.js +2 -0
  28. package/dist/commands/dag-approve.js +2 -0
  29. package/dist/commands/dag-final-verification.js +2 -0
  30. package/dist/commands/dag-init-hybrid.js +2 -0
  31. package/dist/commands/dag-reconcile-tasks.js +2 -0
  32. package/dist/commands/dag-reject.js +2 -0
  33. package/dist/commands/dag-report.js +2 -0
  34. package/dist/commands/dag-rerun.js +2 -0
  35. package/dist/commands/dag-resume.js +2 -0
  36. package/dist/commands/dag-workflow-compile.js +2 -0
  37. package/dist/commands/dag-workflow-plan.js +2 -0
  38. package/dist/commands/dag-workflow-validate.js +2 -0
  39. package/dist/commands/delegate.js +2 -0
  40. package/dist/commands/examples.js +2 -0
  41. package/dist/commands/import-prd.js +2 -0
  42. package/dist/commands/init-legacy-audit.js +330 -0
  43. package/dist/commands/init-model-catalog.js +2 -0
  44. package/dist/commands/init-upgrade.js +644 -104
  45. package/dist/commands/init.js +700 -338
  46. package/dist/commands/instructions.js +2 -0
  47. package/dist/commands/knowledge.js +2 -0
  48. package/dist/commands/loop-benchmark.js +2 -0
  49. package/dist/commands/operator-guide.js +99 -0
  50. package/dist/commands/operator.js +16 -3
  51. package/dist/commands/pi-prompt.js +2 -0
  52. package/dist/commands/pi-reuse-benchmark.js +2 -0
  53. package/dist/commands/promote-run.js +2 -0
  54. package/dist/commands/stats.js +1 -1
  55. package/dist/commands/study-init.js +2 -0
  56. package/dist/commands/task-advance.js +32 -0
  57. package/dist/commands/task-source-prepare.js +18 -2
  58. package/dist/commands/worktree-create.js +2 -0
  59. package/dist/commands/worktree-remove.js +2 -0
  60. package/dist/executors/dag-pi/guards.js +4 -0
  61. package/dist/executors/dag-pi/model-config.js +30 -0
  62. package/dist/executors/dag-pi/plan/fact-adoption.js +55 -0
  63. package/dist/executors/dag-pi/plan/facts.js +180 -0
  64. package/dist/executors/dag-pi/plan/finalize-tools.js +259 -0
  65. package/dist/executors/dag-pi/plan/ledger-contract.js +55 -0
  66. package/dist/executors/dag-pi/plan/record-tools.js +861 -0
  67. package/dist/executors/dag-pi/plan/schema.js +129 -0
  68. package/dist/executors/dag-pi/plan/tool-helpers.js +16 -0
  69. package/dist/executors/dag-pi/sessions/index.js +6 -0
  70. package/dist/executors/dag-pi/sessions/plan-batches.js +280 -0
  71. package/dist/executors/dag-pi/sessions/plan-prompts.js +367 -0
  72. package/dist/executors/dag-pi/sessions/scout-parallel.js +197 -0
  73. package/dist/executors/dag-pi/sessions/segmented-plan.js +1184 -0
  74. package/dist/executors/dag-pi/sessions/writer-evidence.js +60 -0
  75. package/dist/executors/dag-pi/tools/contract-tools.js +515 -0
  76. package/dist/executors/dag-pi/tools/design-terminal-tools.js +159 -0
  77. package/dist/executors/dag-pi/tools/plan-decision-tools.js +529 -0
  78. package/dist/executors/dag-pi/tools/review-terminal-tools.js +159 -0
  79. package/dist/executors/dag-pi/tools/scout-evidence-tools.js +270 -0
  80. package/dist/executors/dag-pi-executor.js +1516 -3181
  81. package/dist/executors/pi-executor.js +112 -4
  82. package/dist/executors/pi-sdk-executor.js +258 -44
  83. package/dist/executors/pi-writer-tool-policy.js +60 -4
  84. package/dist/executors/playwright-cli-launcher.js +31 -45
  85. package/dist/executors/shell-executor.js +313 -48
  86. package/dist/executors/shell-presets.js +1 -1
  87. package/dist/executors/shell-verification.js +3 -0
  88. package/dist/executors/shell-write-guard.js +77 -102
  89. package/dist/governance/exec-plans.js +16 -4
  90. package/dist/governance/harness.js +2 -7
  91. package/dist/governance/manifest-types.js +28 -9
  92. package/dist/governance/project-capability-scanner.js +263 -0
  93. package/dist/governance/project-config.js +96 -0
  94. package/dist/governance/resource-catalog.js +151 -0
  95. package/dist/infrastructure/console/app-data.js +12 -2
  96. package/dist/infrastructure/console/operation-store.js +48 -14
  97. package/dist/infrastructure/evaluation/corpus-store.js +37 -12
  98. package/dist/shared/artifacts-core.js +2 -0
  99. package/dist/shared/backend-dogfood-preflight.js +47 -0
  100. package/dist/shared/dag-failure-category.js +9 -0
  101. package/dist/shared/file-identity.js +23 -0
  102. package/dist/shared/frontend-execution-policy.js +23 -0
  103. package/dist/shared/git-progress.js +2 -0
  104. package/dist/shared/git-workspace-status.js +482 -0
  105. package/dist/shared/one-shot-prompt-args.js +2 -0
  106. package/dist/shared/operator/capabilities.js +185 -0
  107. package/dist/shared/package-metadata.js +29 -11
  108. package/dist/shared/path-safety.js +2 -2
  109. package/dist/shared/pi-context-pressure/extension.js +49 -16
  110. package/dist/shared/pi-context-pressure/index.js +1 -0
  111. package/dist/shared/pi-context-pressure/sift-bridge.js +1 -1
  112. package/dist/shared/pi-context-pressure/telemetry.js +4 -0
  113. package/dist/shared/pi-context-pressure/tool-result-pruner.js +98 -0
  114. package/dist/shared/pi-provider-recovery.js +182 -0
  115. package/dist/shared/pi-retry-settings.js +40 -0
  116. package/dist/shared/reference-context.js +2 -0
  117. package/dist/shared/update/npm-client.js +49 -1
  118. package/dist/shared/wizard-local-telemetry.js +51 -0
  119. package/dist/task/config-types.js +51 -2
  120. package/dist/task/contract/apply.js +36 -2
  121. package/dist/task/contract/project.js +22 -0
  122. package/dist/task/contract/recover.js +6 -0
  123. package/dist/task/contract/schema.js +12 -0
  124. package/dist/task/frontend-preflight.js +1 -1
  125. package/dist/task/source-prepare/artifact-meta.js +9 -2
  126. package/dist/task/source-prepare/build-draft.js +61 -0
  127. package/dist/task/source-prepare/fragment-inventory.js +4 -1
  128. package/dist/task/source-prepare/ledger-reconciliation.js +2 -2
  129. package/dist/task/source-prepare/ledger-review.js +6 -9
  130. package/dist/task/source-prepare/parse-intent.js +165 -14
  131. package/dist/task/source-prepare/path-policy.js +17 -7
  132. package/dist/task/source-prepare/prepare.js +6 -1
  133. package/dist/task/source-prepare/semantic-intake.js +33 -28
  134. package/dist/task/source-prepare/source-execution.js +65 -0
  135. package/dist/task/source-prepare/source-fidelity-pi.js +49 -17
  136. package/dist/task/source-prepare/source-provider-budget.js +290 -0
  137. package/dist/task/source-references.js +48 -23
  138. package/dist/task/task-demand-routing.js +5 -2
  139. package/dist/worker/cli.js +3 -5
  140. package/dist/worker/console/chat/assistant-content.js +5 -13
  141. package/dist/worker/console/chat/browser-automation.js +937 -0
  142. package/dist/worker/console/chat/browser-content.js +74 -0
  143. package/dist/worker/console/chat/browser-diagnostics.js +250 -0
  144. package/dist/worker/console/chat/browser-evaluation.js +58 -0
  145. package/dist/worker/console/chat/browser-operation-queue.js +19 -0
  146. package/dist/worker/console/chat/browser-pick.js +113 -0
  147. package/dist/worker/console/chat/browser-policy.js +113 -0
  148. package/dist/worker/console/chat/browser-routes.js +329 -0
  149. package/dist/worker/console/chat/browser-screenshot-result.js +47 -0
  150. package/dist/worker/console/chat/browser-storage.js +89 -0
  151. package/dist/worker/console/chat/chat-event-store.js +73 -18
  152. package/dist/worker/console/chat/context-insights.js +788 -0
  153. package/dist/worker/console/chat/conversation-nodes.js +383 -0
  154. package/dist/worker/console/chat/db-connections.js +854 -0
  155. package/dist/worker/console/chat/explore-tools.js +18 -2
  156. package/dist/worker/console/chat/pet/pet-affinity.js +169 -0
  157. package/dist/worker/console/chat/pet/pet-persist.js +109 -0
  158. package/dist/worker/console/chat/pet/pet-registry.js +142 -0
  159. package/dist/worker/console/chat/pet/pet-remarks.js +48 -0
  160. package/dist/worker/console/chat/pet/pet-routes.js +125 -0
  161. package/dist/worker/console/chat/pet/pet-service.js +262 -0
  162. package/dist/worker/console/chat/pet/pet-state.js +99 -0
  163. package/dist/worker/console/chat/pi-mode-loop-isolation.js +170 -0
  164. package/dist/worker/console/chat/pi-runtime/custom-tools/ask-user-question.js +44 -0
  165. package/dist/worker/console/chat/pi-runtime/custom-tools/browser-tools.js +135 -0
  166. package/dist/worker/console/chat/pi-runtime/custom-tools/explore-tools.js +202 -0
  167. package/dist/worker/console/chat/pi-runtime/custom-tools/goal-tools.js +79 -0
  168. package/dist/worker/console/chat/pi-runtime/custom-tools/operator-tools.js +94 -0
  169. package/dist/worker/console/chat/pi-runtime/custom-tools/scheduled-goal-tools.js +22 -0
  170. package/dist/worker/console/chat/pi-runtime/custom-tools/sql-tools.js +670 -0
  171. package/dist/worker/console/chat/pi-runtime/custom-tools/todo-write.js +38 -0
  172. package/dist/worker/console/chat/pi-runtime/inspection-types.js +28 -0
  173. package/dist/worker/console/chat/pi-runtime/inspection.js +439 -0
  174. package/dist/worker/console/chat/pi-runtime/progressive-tools.js +195 -0
  175. package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +153 -0
  176. package/dist/worker/console/chat/pi-runtime/sdk-session.js +5 -0
  177. package/dist/worker/console/chat/pi-runtime.js +793 -1230
  178. package/dist/worker/console/chat/provider-error.js +0 -12
  179. package/dist/worker/console/chat/repo-browser.js +132 -6
  180. package/dist/worker/console/chat/repo-preview-kind.js +155 -0
  181. package/dist/worker/console/chat/resource-loader.js +4 -1
  182. package/dist/worker/console/chat/routes.js +861 -148
  183. package/dist/worker/console/chat/scheduled-goal-booking.js +59 -0
  184. package/dist/worker/console/chat/scheduled-goal-delivery.js +27 -0
  185. package/dist/worker/console/chat/scheduled-goal-request.js +198 -0
  186. package/dist/worker/console/chat/scm-routes.js +217 -0
  187. package/dist/worker/console/chat/scm-service.js +283 -0
  188. package/dist/worker/console/chat/scm-tools.js +111 -0
  189. package/dist/worker/console/chat/sdd-data-alignment.js +85 -41
  190. package/dist/worker/console/chat/session-catalog.js +32 -0
  191. package/dist/worker/console/chat/session-mode-view.js +49 -0
  192. package/dist/worker/console/chat/session-mode.js +224 -0
  193. package/dist/worker/console/chat/session-store.js +232 -32
  194. package/dist/worker/console/chat/shortcuts.js +13 -0
  195. package/dist/worker/console/chat/subagents/agent-tool.js +62 -0
  196. package/dist/worker/console/chat/subagents/explore-agent.js +169 -0
  197. package/dist/worker/console/chat/subagents/index.js +5 -0
  198. package/dist/worker/console/chat/subagents/orchestrator.js +273 -0
  199. package/dist/worker/console/chat/subagents/tool-policy.js +53 -0
  200. package/dist/worker/console/chat/subagents/types.js +13 -0
  201. package/dist/worker/console/chat/terminal-routes.js +216 -0
  202. package/dist/worker/console/chat/terminal-sessions.js +348 -0
  203. package/dist/worker/console/chat/terminal-tools.js +211 -0
  204. package/dist/worker/console/chat/timeline-message-order.js +22 -0
  205. package/dist/worker/console/chat/tool-preview.js +136 -0
  206. package/dist/worker/console/chat/tools.js +69 -1
  207. package/dist/worker/console/chat/turn-order.js +13 -0
  208. package/dist/worker/console/chat/turn-process.js +210 -36
  209. package/dist/worker/console/chat/user-turn-outline.js +19 -0
  210. package/dist/worker/console/console-shutdown.js +34 -0
  211. package/dist/worker/console/console-update-and-init.js +1 -19
  212. package/dist/worker/console/console-update-runtime.js +7 -22
  213. package/dist/worker/console/dag-confirmation.js +3 -0
  214. package/dist/worker/console/dag-execution-receipt.js +3 -0
  215. package/dist/worker/console/interview/tools.js +1 -0
  216. package/dist/worker/console/operator-actions.js +95 -4
  217. package/dist/worker/console/operator-user-error.js +28 -1
  218. package/dist/worker/console/pi-readiness.js +4 -4
  219. package/dist/worker/console/prd-intake-bridge.js +47 -1
  220. package/dist/worker/console/recovery-cta.js +14 -14
  221. package/dist/worker/console/routes.js +13 -0
  222. package/dist/worker/console/scheduled-goal-host.js +98 -0
  223. package/dist/worker/console/scheduled-goal-operation-adapter.js +127 -0
  224. package/dist/worker/console/server.js +33 -31
  225. package/dist/worker/console/static/app-icon.svg +39 -0
  226. package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BZogYNl1.js → abnfDiagram-N423BO3Z-DASc69AM.js} +1 -1
  227. package/dist/worker/console/static/assets/{arc-DcJTLe2v.js → arc-h09p-LAc.js} +1 -1
  228. package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-B39EQQ9n.js → architectureDiagram-T3A2C74G-CZ3dtLkh.js} +1 -1
  229. package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CitCGV56.js → blockDiagram-VBNYF7ZC-DMrRhMXG.js} +1 -1
  230. package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-rvWuOHLG.js → c4Diagram-5PPSVZJV-DQxisHV6.js} +1 -1
  231. package/dist/worker/console/static/assets/channel-D1zgKZfg.js +1 -0
  232. package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-DGXplIJs.js → chunk-2GRJ4B5K-CefVN9zh.js} +1 -1
  233. package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-ur9OqjPn.js → chunk-2Q5K7J3B-DmR1Koq2.js} +1 -1
  234. package/dist/worker/console/static/assets/{chunk-5RXB4S5H-D1KqU_Vi.js → chunk-5RXB4S5H-NlzrSW7L.js} +1 -1
  235. package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BlVZrbtM.js → chunk-5VM5RSS4-DfelJv-0.js} +1 -1
  236. package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-BAzz3nQy.js → chunk-6Q2QTUOP-BK6RFy58.js} +1 -1
  237. package/dist/worker/console/static/assets/{chunk-GF5L2VYU-CP_nYuCV.js → chunk-GF5L2VYU-BAeh9lz4.js} +1 -1
  238. package/dist/worker/console/static/assets/{chunk-JWPE2WC7-CWvKQ80X.js → chunk-JWPE2WC7-ChPS5WzG.js} +1 -1
  239. package/dist/worker/console/static/assets/{chunk-KBJHAD2P-CyUki8wp.js → chunk-KBJHAD2P-BoVe5IM6.js} +1 -1
  240. package/dist/worker/console/static/assets/{chunk-RYQCIY6F-5NYzNKfY.js → chunk-RYQCIY6F-C4q_0Lw9.js} +1 -1
  241. package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DHdUgjS-.js → chunk-XXDRQBXY-Bb9TvjeY.js} +1 -1
  242. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-CXNNsY2M.js +1 -0
  243. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-CXNNsY2M.js +1 -0
  244. package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-ANQ5g_t6.js → cose-bilkent-JH36ORCC-DmNnL8Ff.js} +1 -1
  245. package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CruT_4-0.js → cynefin-VYW2F7L2-Contvx58.js} +1 -1
  246. package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-rbFo77ID.js → cynefinDiagram-MW4NZA55-Cigq7cjk.js} +1 -1
  247. package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-asstxBQs.js → dagre-VZM6K2ZE-dEbC0nxb.js} +1 -1
  248. package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DzTyBZwI.js → diagram-7IWD3JNH-CzIztESV.js} +1 -1
  249. package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-gw8ccH3B.js → diagram-B4RE2ZJO-Bo14zbaY.js} +1 -1
  250. package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B8RpZzOf.js → diagram-LBJQPF4R-C4xUyil6.js} +1 -1
  251. package/dist/worker/console/static/assets/{diagram-Q27KOJAE-B1zJkCS9.js → diagram-Q27KOJAE-CaBY_uYa.js} +1 -1
  252. package/dist/worker/console/static/assets/{diagram-UB23O5K3-B6JLWZmO.js → diagram-UB23O5K3-ClUXUeiu.js} +1 -1
  253. package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-q2iZP-Ps.js → ebnfDiagram-BXEA7PRR-BbGCgjC6.js} +1 -1
  254. package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-B3dbbktQ.js → erDiagram-JOGREHBK-Dr-AcwSl.js} +1 -1
  255. package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-C-zc6-kB.js → flowDiagram-UKHOOZJN-BG8Gcfyc.js} +1 -1
  256. package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-BSolnot9.js → ganttDiagram-PKOTCBZU-CFVaPs5r.js} +1 -1
  257. package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js → gitGraphDiagram-DS77QQ5N-ChJ8pm-O.js} +1 -1
  258. package/dist/worker/console/static/assets/index-B_5GhVIO.js +488 -0
  259. package/dist/worker/console/static/assets/index-C7YMBluX.css +1 -0
  260. package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-DQaZqJOH.js → infoDiagram-6WML65LV-C5J9-uCZ.js} +1 -1
  261. package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DsdX1WnE.js → ishikawaDiagram-WSZJBQD7-BcfjqzDv.js} +1 -1
  262. package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-CP5EYDZL.js → journeyDiagram-NVQOT4AX-BzzCO-rD.js} +1 -1
  263. package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-DAm14Dr8.js → kanban-definition-27J2QSJJ-NCHUZ46h.js} +1 -1
  264. package/dist/worker/console/static/assets/{linear-gZECoLc5.js → linear-BKZlWCUU.js} +1 -1
  265. package/dist/worker/console/static/assets/{mermaid.core-BRJNIM6p.js → mermaid.core-DbTaQjFE.js} +5 -5
  266. package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Cja3kLkR.js → mindmap-definition-FAOFIHXS-CroYl5xQ.js} +1 -1
  267. package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-22ZGFisL.js → pegDiagram-VL7TDLO6-DgMBx-9k.js} +1 -1
  268. package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BXin0Y1o.js → pieDiagram-7S7Q4E2Y-CyWDmbq1.js} +1 -1
  269. package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js → quadrantDiagram-CIZ2JOQS-BgGEOqSP.js} +1 -1
  270. package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-C1-gTieN.js → railroadDiagram-AXF67PYL-BMZ7oeeV.js} +1 -1
  271. package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP--H5N2iI1.js → requirementDiagram-LRYGKXZP-DxqyGhcc.js} +1 -1
  272. package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-CgWAPeRz.js → sankeyDiagram-W5VNT64P-DnSvNCG8.js} +1 -1
  273. package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-CrKqzGvt.js → sequenceDiagram-SI44F4Z6-BiZh6f-R.js} +1 -1
  274. package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-BB3wG06K.js → sizeCapture-X5ZJPWSS-BKXSI8WB.js} +1 -1
  275. package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-DjsGgdgY.js → stateDiagram-OKZ733FA-CfSgoYFm.js} +1 -1
  276. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DgHi3vjb.js +1 -0
  277. package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DYKEbvAR.js → swimlanes-SLNWSIFB-CyGADcHe.js} +2 -2
  278. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-Bgvdt1Y0.js +8 -0
  279. package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-eQOb5k9Y.js → timeline-definition-Z64GVDOM-HmPaSPOK.js} +1 -1
  280. package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B2-l9FIu.js → vennDiagram-T6HMQDX7-VA2VBbez.js} +1 -1
  281. package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-BX2Cda3l.js → wardleyDiagram-T6FBY63Y-BxjiBPZa.js} +1 -1
  282. package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-D9S892ph.js → xychartDiagram-ELKLHX3M--hUY-qFj.js} +1 -1
  283. package/dist/worker/console/static/index.html +5 -2
  284. package/dist/worker/console/static/manifest.webmanifest +19 -0
  285. package/dist/worker/console/static/pets/ember/pet.json +167 -0
  286. package/dist/worker/console/static/pets/ember/spritesheet.png +0 -0
  287. package/dist/worker/console/static-src/app/console-types.js +9 -1
  288. package/dist/worker/console/static-src/chat-view-types.js +1 -1
  289. package/dist/worker/console/static-src/operator-chat/active-turn-tail.js +10 -0
  290. package/dist/worker/console/static-src/operator-chat/animation-frame-batcher.js +38 -0
  291. package/dist/worker/console/static-src/operator-chat/chat-link.js +114 -0
  292. package/dist/worker/console/static-src/operator-chat/chat-scroll-position.js +24 -0
  293. package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +360 -14
  294. package/dist/worker/console/static-src/operator-chat/chat-stream-continuity.js +101 -0
  295. package/dist/worker/console/static-src/operator-chat/compaction-message.js +10 -2
  296. package/dist/worker/console/static-src/operator-chat/composer-session-ledger.js +192 -0
  297. package/dist/worker/console/static-src/operator-chat/context-insights-store.js +64 -0
  298. package/dist/worker/console/static-src/operator-chat/details-rail-surfaces.js +99 -0
  299. package/dist/worker/console/static-src/operator-chat/file-palette-nav.js +81 -0
  300. package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +57 -9
  301. package/dist/worker/console/static-src/operator-chat/pending-user-message.js +66 -0
  302. package/dist/worker/console/static-src/operator-chat/process-label.js +63 -0
  303. package/dist/worker/console/static-src/operator-chat/slash-palette-nav.js +15 -5
  304. package/dist/worker/console/static-src/operator-chat/timeline-merge.js +29 -0
  305. package/dist/worker/console/static-src/operator-chat/tools-catalog.js +36 -8
  306. package/dist/worker/console/static-src/operator-chat/transcript-mode.js +21 -0
  307. package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +16 -0
  308. package/dist/worker/console/static-src/operator-chat/turn-process-disclosure.js +18 -0
  309. package/dist/worker/console/static-src/operator-chat/turn-state-projection.js +166 -0
  310. package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +58 -2
  311. package/dist/worker/console/static-src/operator-chat/use-searchable-hidden.js +51 -0
  312. package/dist/worker/console/static-src/operator-chat/use-stat-dialog.js +95 -0
  313. package/dist/worker/console/static-src/operator-chat/useChatSessions.js +338 -93
  314. package/dist/worker/console/static-src/operator-chat/useChatStream.js +310 -106
  315. package/dist/worker/console/static-src/operator-chat/useChatThread.js +179 -75
  316. package/dist/worker/console/static-src/operator-chat/useComposer.js +281 -79
  317. package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +21 -3
  318. package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +36 -17
  319. package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +18 -0
  320. package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
  321. package/dist/worker/console/static-src/operator-chat/user-turn-anchor-equality.js +21 -0
  322. package/dist/worker/console/static-src/prd-file-import.js +3 -1
  323. package/dist/worker/console/static-src/shell/console-update-reload.js +1 -1
  324. package/dist/worker/console/workspace-context.js +54 -1
  325. package/dist/worker/console/workspace-initialization.js +218 -0
  326. package/dist/worker/delivery/git-transaction.js +2 -0
  327. package/dist/worker/delivery/package.js +4 -1
  328. package/dist/worker/feature/fullstack-validate.js +2 -0
  329. package/dist/worker/loop-agent/loop-agent-client.js +8 -2
  330. package/dist/worker/materialize/harness-task-lineage.js +4 -2
  331. package/dist/worker/materialize/harness-task-materializer.js +4 -1
  332. package/dist/worker/metrics/projector.js +1 -1
  333. package/dist/worker/observability/event-store.js +4 -1
  334. package/dist/worker/observability/read-model.js +27 -3
  335. package/dist/worker/observe/node-context-insights.js +479 -0
  336. package/dist/worker/observe/node-transparency.js +103 -72
  337. package/dist/worker/observe/routes.js +24 -1
  338. package/dist/worker/observe/static/console-theme.css +178 -0
  339. package/dist/worker/observe/static/console-theme.js +74 -0
  340. package/dist/worker/observe/static/dag-inspector-humanize.js +3 -0
  341. package/dist/worker/observe/static/dom.js +20 -1
  342. package/dist/worker/observe/static/format-pool.d.ts +2 -0
  343. package/dist/worker/observe/static/format-pool.js +6 -0
  344. package/dist/worker/observe/static/format.js +7 -0
  345. package/dist/worker/observe/static/inspect-workspace.js +34 -7
  346. package/dist/worker/observe/static/inspector-submission.js +32 -0
  347. package/dist/worker/observe/static/kpi.js +1 -0
  348. package/dist/worker/observe/static/operator-chrome.css +85 -0
  349. package/dist/worker/observe/static/operator-chrome.js +13 -1
  350. package/dist/worker/observe/static/relations.js +2 -0
  351. package/dist/worker/observe/static/router.js +13 -0
  352. package/dist/worker/observe/static/run-processing.js +2 -0
  353. package/dist/worker/observe/static/shell-chrome.js +36 -3
  354. package/dist/worker/observe/static/state.js +35 -2
  355. package/dist/worker/observe/static/styles.css +263 -39
  356. package/dist/worker/observe/static/task-failure-labels.d.ts +4 -0
  357. package/dist/worker/observe/static/task-failure-labels.js +67 -0
  358. package/dist/worker/observe/static/task-history.js +12 -0
  359. package/dist/worker/observe/static/views/batch.js +6 -13
  360. package/dist/worker/observe/static/views/dag-graph.js +50 -3
  361. package/dist/worker/observe/static/views/dag-inspector.js +742 -268
  362. package/dist/worker/observe/static/views/dag-trajectory.js +3 -0
  363. package/dist/worker/observe/static/views/dag.d.ts +6 -0
  364. package/dist/worker/observe/static/views/dag.js +49 -11
  365. package/dist/worker/observe/static/views/dags.js +2 -0
  366. package/dist/worker/observe/static/views/dashboard.js +21 -12
  367. package/dist/worker/observe/static/views/failures.js +21 -11
  368. package/dist/worker/observe/static/views/feature.js +11 -29
  369. package/dist/worker/observe/static/views/pool.js +37 -28
  370. package/dist/worker/observe/static/views/run.js +48 -5
  371. package/dist/worker/observe/static/views/session-timeline.js +189 -240
  372. package/dist/worker/observe/static/views/task.js +81 -62
  373. package/dist/worker/outcomes/declared-artifacts.js +2 -0
  374. package/dist/worker/preflight.js +3 -0
  375. package/dist/worker/scheduler/scheduled-goal-dispatch.js +118 -0
  376. package/dist/worker/scheduler/scheduled-goal-evidence.js +230 -0
  377. package/dist/worker/scheduler/scheduled-goal-recovery.js +62 -0
  378. package/dist/worker/scheduler/scheduled-goal-store.js +709 -0
  379. package/dist/worker/scheduler/scheduled-goal-supervisor.js +132 -0
  380. package/dist/worker/scheduler/scheduled-goal-time.js +102 -0
  381. package/dist/worker/scheduler/scheduled-goal-types.js +95 -0
  382. package/dist/worker/task-spec/validate.js +4 -1
  383. package/dist/workflows/dag/backend-test-case-coverage-analysis.js +3 -1
  384. package/dist/workflows/dag/backend-test-layout.js +27 -7
  385. package/dist/workflows/dag/backend-test-markdown-workflow.js +9 -25
  386. package/dist/workflows/dag/backend-test-plan-protocol.js +82 -5
  387. package/dist/workflows/dag/backend-test-pytest-collection.js +4 -1
  388. package/dist/workflows/dag/budget-enforcement.js +82 -3
  389. package/dist/workflows/dag/checkpoint.js +686 -0
  390. package/dist/workflows/dag/dag-retry-schema.js +14 -0
  391. package/dist/workflows/dag/decision-envelope.js +2 -0
  392. package/dist/workflows/dag/dynamic-runtime/shared.js +2 -2
  393. package/dist/workflows/dag/final-verification.js +45 -10
  394. package/dist/workflows/dag/frontend-capacity.js +9 -0
  395. package/dist/workflows/dag/frontend-closeout.js +5 -1
  396. package/dist/workflows/dag/frontend-committed-facts.js +461 -0
  397. package/dist/workflows/dag/frontend-contract-facts.js +133 -0
  398. package/dist/workflows/dag/frontend-design-policy.js +107 -21
  399. package/dist/workflows/dag/frontend-durable-tools.js +225 -0
  400. package/dist/workflows/dag/frontend-execution-groups.js +24 -0
  401. package/dist/workflows/dag/frontend-implementation-contract.js +554 -26
  402. package/dist/workflows/dag/frontend-input-projection.js +76 -0
  403. package/dist/workflows/dag/frontend-plan-canary.js +103 -0
  404. package/dist/workflows/dag/frontend-plan-decision-contract.js +795 -0
  405. package/dist/workflows/dag/frontend-plan-progress.js +92 -0
  406. package/dist/workflows/dag/frontend-plan-recovery-policy.js +18 -0
  407. package/dist/workflows/dag/frontend-plan-render.js +21 -5
  408. package/dist/workflows/dag/frontend-provider-capability-matrix.js +8 -61
  409. package/dist/workflows/dag/frontend-recovery-controller.js +7 -7
  410. package/dist/workflows/dag/frontend-recovery-lineage.js +13 -0
  411. package/dist/workflows/dag/frontend-recovery-plan.js +10 -5
  412. package/dist/workflows/dag/frontend-recovery-run.js +148 -47
  413. package/dist/workflows/dag/frontend-repair-assertions.js +36 -0
  414. package/dist/workflows/dag/frontend-repair.js +79 -76
  415. package/dist/workflows/dag/frontend-review-context.js +71 -69
  416. package/dist/workflows/dag/frontend-review-scopes.js +237 -0
  417. package/dist/workflows/dag/frontend-risk.js +101 -12
  418. package/dist/workflows/dag/frontend-root-observation.js +261 -0
  419. package/dist/workflows/dag/frontend-session-budget.js +376 -0
  420. package/dist/workflows/dag/frontend-session-context.js +10 -0
  421. package/dist/workflows/dag/frontend-shape-facts.js +12 -2
  422. package/dist/workflows/dag/frontend-shape.js +27 -32
  423. package/dist/workflows/dag/frontend-test-case-checklist.js +12 -3
  424. package/dist/workflows/dag/frontend-test-case-generation-assessment.js +21 -2
  425. package/dist/workflows/dag/frontend-test-case-quality.js +3 -3
  426. package/dist/workflows/dag/frontend-test-environment-probe.js +0 -2
  427. package/dist/workflows/dag/frontend-test-execution-evidence.js +328 -0
  428. package/dist/workflows/dag/frontend-test-framework-adapters.js +309 -0
  429. package/dist/workflows/dag/frontend-test-layout.js +41 -12
  430. package/dist/workflows/dag/frontend-typed-event-store.js +57 -26
  431. package/dist/workflows/dag/frontend-verification-trace.js +65 -48
  432. package/dist/workflows/dag/frontend-writer-admission.js +6 -48
  433. package/dist/workflows/dag/frontend-writer-status.js +0 -23
  434. package/dist/workflows/dag/hybrid/sources.js +1831 -0
  435. package/dist/workflows/dag/hybrid/templates/backend-test.js +1822 -0
  436. package/dist/workflows/dag/hybrid/templates/frontend-test.js +807 -0
  437. package/dist/workflows/dag/hybrid/templates/frontend.js +1529 -0
  438. package/dist/workflows/dag/hybrid/templates/index.js +8 -0
  439. package/dist/workflows/dag/hybrid/templates/kg-bootstrap.js +449 -0
  440. package/dist/workflows/dag/hybrid/templates/knowledge-sync.js +495 -0
  441. package/dist/workflows/dag/hybrid/templates/shared.js +101 -0
  442. package/dist/workflows/dag/hybrid/templates/standard.js +265 -0
  443. package/dist/workflows/dag/hybrid/types.js +32 -0
  444. package/dist/workflows/dag/init-hybrid.js +57 -7167
  445. package/dist/workflows/dag/interrupt-request.js +2 -0
  446. package/dist/workflows/dag/lifecycle.js +11 -2
  447. package/dist/workflows/dag/node-execution.js +257 -247
  448. package/dist/workflows/dag/output-protocol.js +1 -0
  449. package/dist/workflows/dag/prompt.js +4 -0
  450. package/dist/workflows/dag/reconcile-run.js +2 -0
  451. package/dist/workflows/dag/repair-artifact.js +3 -1
  452. package/dist/workflows/dag/report.js +2 -0
  453. package/dist/workflows/dag/rerun-feedback.js +36 -4
  454. package/dist/workflows/dag/rerun-plan.js +106 -4
  455. package/dist/workflows/dag/rerun-run.js +7 -0
  456. package/dist/workflows/dag/rerun-task.js +75 -1
  457. package/dist/workflows/dag/retry-policy.js +34 -10
  458. package/dist/workflows/dag/runner-exit-diagnostics.js +125 -0
  459. package/dist/workflows/dag/runner.js +38 -1074
  460. package/dist/workflows/dag/scheduler.js +2 -4
  461. package/dist/workflows/dag/skill-instructions.js +102 -32
  462. package/dist/workflows/dag/skill-snapshot.js +3 -0
  463. package/dist/workflows/dag/skills.js +7 -7
  464. package/dist/workflows/dag/structured-output-repair.js +4 -1
  465. package/dist/workflows/dag/terminal-status.js +502 -0
  466. package/dist/workflows/dag/test-artifact-namespace.js +73 -0
  467. package/dist/workflows/dag/types.js +58 -7
  468. package/dist/workflows/dag/validate.js +38 -13
  469. package/dist/workflows/dag/workspace-checkpoint.js +79 -1
  470. package/dist/workflows/loop/benchmark.js +11 -8
  471. package/docs/README.md +2 -1
  472. package/docs/architecture/dag-execution.md +4 -4
  473. package/docs/architecture/runtime-boundaries.md +29 -23
  474. package/docs/governance/README.md +1 -0
  475. package/docs/governance/harness-methodology-verification.md +11 -0
  476. package/docs/init-surface.manifest.json +44 -295
  477. package/docs/operations/README.md +4 -0
  478. package/docs/templates/README.md +5 -5
  479. package/docs/templates/agent-dag.base.json +9 -9
  480. package/docs/templates/agent-dag.final-verification.json +6 -6
  481. package/docs/templates/agent-dag.schema.json +2 -2
  482. package/docs/templates/agent-dag.supervised-implementation.json +12 -12
  483. package/docs/templates/backend-test-dag.generate-pytest.prompt.md +3 -3
  484. package/docs/templates/backend-test-dag.json +708 -703
  485. package/docs/templates/backend-test-dag.review-cases.prompt.md +3 -3
  486. package/docs/templates/frontend-design-contract.md +4 -4
  487. package/docs/templates/frontend-implementation-contract.schema.json +99 -22
  488. package/docs/templates/frontend-implementation-dag.json +7 -7
  489. package/docs/templates/frontend-test-case-checklist.md +2 -2
  490. package/docs/templates/frontend-test-case.example.md +2 -0
  491. package/docs/templates/frontend-test-dag.generate-cases.prompt.md +1 -1
  492. package/docs/templates/frontend-test-dag.json +46 -37
  493. package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +2 -2
  494. package/docs/templates/frontend-test-dag.retrospect.prompt.md +1 -1
  495. package/docs/templates/frontend-test-dag.review-cases.prompt.md +1 -1
  496. package/docs/templates/hybrid-dag.json +9 -9
  497. package/docs/templates/knowledge-sync-dag.json +8 -8
  498. package/harness.json +1 -1
  499. package/package.json +27 -8
  500. package/resource-catalog.v1.json +1981 -0
  501. package/resources/agent-bridge/loop-agent/SKILL.md +40 -0
  502. package/resources/init-history/legacy-surface.v1.json +33 -0
  503. package/skills/fe-test-ui-scout/SKILL.md +4 -4
  504. package/skills/fe-test-ui-scout/references/ledger-schema.md +1 -1
  505. package/skills/frontend-bounded-implement/references/code-standards.md +3 -3
  506. package/skills/frontend-contract/SKILL.md +2 -1
  507. package/skills/frontend-contract/references/contract-protocol.md +22 -4
  508. package/skills/frontend-design-review/SKILL.md +16 -18
  509. package/skills/frontend-design-review/references/review-checklist.md +3 -4
  510. package/skills/frontend-plan/SKILL.md +25 -3
  511. package/skills/frontend-plan/references/decision-contract.md +117 -8
  512. package/skills/frontend-plan/references/design-decisions.md +32 -0
  513. package/skills/frontend-review/SKILL.md +29 -36
  514. package/skills/frontend-review/references/review-findings.md +8 -3
  515. package/skills/frontend-scout/references/scout-evidence.md +4 -0
  516. package/skills/init-update/SKILL.md +34 -0
  517. package/skills/init-update/agents/openai.yaml +6 -0
  518. package/skills/loop-agent/references/command-reference.md +8 -0
  519. package/skills/loop-agent/references/hybrid-dag.md +1 -1
  520. package/skills/playwright-cli/SKILL.md +1 -1
  521. package/skills/playwright-cli-case-generator/SKILL.md +7 -5
  522. package/dist/commands/new-task.js +0 -5
  523. package/dist/commands/status.js +0 -57
  524. package/dist/commands/task-contract.js +0 -269
  525. package/dist/shared/prompts.js +0 -26
  526. package/dist/task/config.js +0 -2
  527. package/dist/task/contract/validate-draft.js +0 -106
  528. package/dist/task/goal.js +0 -3
  529. package/dist/task/index.js +0 -12
  530. package/dist/task/lifecycle.js +0 -1
  531. package/dist/task/operator/capabilities.js +0 -6
  532. package/dist/task/operator/envelope.js +0 -2
  533. package/dist/task/operator/index.js +0 -5
  534. package/dist/task/operator/registry.js +0 -2
  535. package/dist/task/paths.js +0 -1
  536. package/dist/task/source-state.js +0 -1
  537. package/dist/task/subagent-guidance.js +0 -1
  538. package/dist/worker/console/chat/sift-bridge.js +0 -1
  539. package/dist/worker/console/index.js +0 -20
  540. package/dist/worker/console/static/assets/channel-CXqdP5pW.js +0 -1
  541. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +0 -1
  542. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +0 -1
  543. package/dist/worker/console/static/assets/index-CAZ2fC_X.css +0 -1
  544. package/dist/worker/console/static/assets/index-DhfjOafu.js +0 -449
  545. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +0 -1
  546. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +0 -8
  547. package/dist/worker/scheduler/index.js +0 -25
  548. package/dist/workflows/dag/facts.js +0 -4
  549. package/dist/workflows/dag/frontend-shadow-dual-write.js +0 -941
  550. package/dist/workflows/dag/index.js +0 -6
  551. package/dist/workflows/dynamic/index.js +0 -7
  552. /package/dist/{task/operator/types.js → executors/dag-pi/plan/session.js} +0 -0
@@ -1,3 +1,7 @@
1
+ import { reserveTaskSourceProviderRequest } from "../../task/source-prepare/source-provider-budget.js";
2
+ import { frontendPlanSemanticDigest } from "./frontend-plan-progress.js";
3
+ import { collectFrontendExecutionGroups } from "./frontend-execution-groups.js";
4
+ import { reserveDagProviderRequest } from "./budget-enforcement.js";
1
5
  import { createHash } from "node:crypto";
2
6
  import { existsSync } from "node:fs";
3
7
  import { readFile } from "node:fs/promises";
@@ -13,7 +17,7 @@ import { buildDagNodePromptEnvelope, formatConvergenceFeedbackBlock, } from "./p
13
17
  import { persistLongNodeOutputArtifacts } from "./upstream-artifacts.js";
14
18
  import { materializeDeclaredArtifactFacts } from "./artifact-bindings.js";
15
19
  import { buildOutputLimitRecoverySection, loadBackendTestWriterProgressForRetry, } from "./backend-test-writer-completeness.js";
16
- import { computeBackoffDelayMs, isCanonicalFinalVerifyShellRetryCandidate, isRetryablePiFailureCategory, isSafeReadOnlyPiRetryCandidate, isTargetTemplateTransientRetryNode, isWriterEmptyDiffRetryCandidate, isWriterTransportRetryCandidate, projectFrontendNodeProtocolFailureReason, resolveFrontendPlanBackupRoute, resolveFrontendPlanRetryStep, VERIFY_SHELL_RETRY_POLICY, } from "./retry-policy.js";
20
+ import { computeBackoffDelayMs, isCanonicalFinalVerifyShellRetryCandidate, isProviderAvailabilityFailureCategory, isRetryablePiFailureCategory, isSafeReadOnlyPiRetryCandidate, isTargetTemplateTransientRetryNode, isWriterEmptyDiffRetryCandidate, isWriterTransportRetryCandidate, OUTPUT_LIMIT_RETRY_CATEGORY, projectFrontendNodeProtocolFailureReason, resolveFrontendPlanBackupRoute, resolveFrontendPlanRetryStep, VERIFY_SHELL_RETRY_POLICY, } from "./retry-policy.js";
17
21
  import { applyNodeActivity, evaluateNodeLiveness, resolveLivenessPolicy, } from "./liveness-policy.js";
18
22
  import { buildProtocolRetryInstruction, normalizeReviewVerdictAfterRetries, parseJsonReviewVerdict, validateOutputProtocol, } from "./output-protocol.js";
19
23
  import { getStructuredContractValidator } from "./contract-output-registry.js";
@@ -21,6 +25,7 @@ import "./contract-validator-registrations.js";
21
25
  import { computeNormalizedFailureFingerprint } from "./frontend-recovery-lineage.js";
22
26
  import { parseLedgerJson } from "../../task/source-prepare/ledger.js";
23
27
  import { readTypedEventStoreFromJsonl } from "./frontend-typed-event-store.js";
28
+ import { collectCanonicalStateFlowNames, extractRequiredDeliverablePaths, resolveFrontendContractRequirements, } from "./frontend-contract-facts.js";
24
29
  import { allowedRepairReadPaths, auditRepairAttemptToolUse, buildStructuredOutputRepairPrompt, freezeStructuredOutputRepairContext, hasNonEmptyStructuredCandidate, isFrontendStructuredRepairSchemaId, isStructuredRepairableFailureCategory, persistStructuredAttemptRaw, sessionEventsByteLength, GOVERNANCE_BLOCKED_CATEGORY, STRUCTURED_REPAIR_EXHAUSTED_CATEGORY, } from "./structured-output-repair.js";
25
30
  import { readFrontendCanonicalCandidate } from "./frontend-implementation-contract.js";
26
31
  import { writeDagNodeJsonArtifact } from "../../infrastructure/harness/artifact-store.js";
@@ -256,6 +261,9 @@ function frontendPlanValidationRetryGuidance(reason) {
256
261
  if (/verificationTargets.*uiStates|uiStates.*verificationTargets/i.test(reason)) {
257
262
  guidance.push("For this retry, provide verificationTargets[].uiStates as an array; use [] when the target has no named UI state.");
258
263
  }
264
+ if (/duplicate|already recorded/i.test(reason)) {
265
+ guidance.push("For this retry, re-commit the corrected entry with the same id and replace=true; the ledger compiles the latest submission as the full replacement. A duplicate receipt is a correction invitation, not a prohibition, and backfilling a cited fact's reverse reference in-node does not re-derive committed facts.");
266
+ }
259
267
  return guidance;
260
268
  }
261
269
  function compactRetryText(text, maxChars) {
@@ -293,6 +301,12 @@ export function buildContextOverflowRetryPrompt(task, basePrompt) {
293
301
  compactRetrySection(basePrompt, "task", COMPACT_RETRY_TASK_MAX_CHARS),
294
302
  "</task>",
295
303
  ].join("\n"),
304
+ // Plan still needs the complete frozen obligations for ledger ownership
305
+ // and scoped projection. Its executor packs this block before dispatch;
306
+ // dropping or character-truncating it prevents safe progress recovery.
307
+ ...(isFrontendPlanLadderTask(task)
308
+ ? [basePrompt.match(/<frontend_plan_input>[\s\S]*?<\/frontend_plan_input>/)?.[0] ?? ""]
309
+ : []),
296
310
  ].join("\n\n");
297
311
  }
298
312
  function isFrontendPlanLadderTask(task) {
@@ -325,6 +339,8 @@ const FRONTEND_CONTRACT_RECORD_TOOL_NAMES_LOCAL = new Set([
325
339
  "record_handoff_intent",
326
340
  "record_open_question",
327
341
  "record_split_proposal",
342
+ "record_ui_state",
343
+ "record_required_deliverables",
328
344
  ]);
329
345
  async function countContractRecordSubmissions(runDir, nodeId) {
330
346
  const eventsPath = path.join(runDir, nodeId, "session-events.jsonl");
@@ -360,41 +376,24 @@ async function countContractRecordSubmissions(runDir, nodeId) {
360
376
  * `hasTerminalFact` reflects a committed `finalize_plan` terminal fact.
361
377
  */
362
378
  async function readFrontendPlanCommittedSnapshot(runDir, nodeId) {
363
- const records = await readTypedEventStoreFromJsonl(path.join(runDir, nodeId, "plan-typed-facts.jsonl"));
364
- const committed = records.filter((record) => record.phase === "committed");
365
- const digest = createHash("sha256")
366
- .update(committed
367
- .map((record) => record.payloadSha256)
368
- .sort()
369
- .join("\n"))
370
- .digest("hex");
371
- const hasTerminalFact = committed.some((record) => record.fact.kind === "finalize_plan");
379
+ const decisions = await readTypedEventStoreFromJsonl(path.join(runDir, nodeId, "plan-decision-facts.jsonl"));
380
+ const records = decisions.some(r => r.phase === "committed") ? decisions : await readTypedEventStoreFromJsonl(path.join(runDir, nodeId, "plan-typed-facts.jsonl"));
381
+ const committed = records.filter(record => record.phase === "committed");
382
+ const digest = frontendPlanSemanticDigest(committed);
383
+ const hasTerminalFact = committed.some((record) => ["finalize_plan", "finalize_decision"].includes(String(record.fact.kind)));
372
384
  return { digest, hasTerminalFact };
373
385
  }
374
386
  function planInputRecord(value) {
375
387
  return typeof value === "object" && value !== null && !Array.isArray(value);
376
388
  }
377
- function planInputText(value, maxChars = 240) {
378
- if (typeof value !== "string" || value.trim().length === 0)
379
- return undefined;
380
- const normalized = value.trim();
381
- return normalized.length <= maxChars
382
- ? normalized
383
- : `${normalized.slice(0, maxChars - 1)}…`;
389
+ function planInputText(value, _maxChars) {
390
+ return typeof value === "string" && value.trim().length ? value.trim() : undefined;
384
391
  }
385
392
  function planInputStrings(value) {
386
393
  return Array.isArray(value)
387
394
  ? value.filter((item) => typeof item === "string")
388
395
  : [];
389
396
  }
390
- /** Input bound for the planner evidence block; protects the model input budget. */
391
- const FRONTEND_PLAN_INPUT_MAX_CHARS = 12_000;
392
- const FRONTEND_PLAN_INPUT_CAP_LADDER = [
393
- { text: 240, array: 40 },
394
- { text: 120, array: 20 },
395
- { text: 60, array: 10 },
396
- { text: 24, array: 4 },
397
- ];
398
397
  /**
399
398
  * Frozen requirement→PRD citation map for the plan review checklist: lets the
400
399
  * model declare sourceRequirementIds whose section/line match the component
@@ -440,78 +439,19 @@ async function resolveComponentSourceCitations(spec, cwd) {
440
439
  return new Map();
441
440
  }
442
441
  }
443
- /** Input bound for the contract node's compiled ledger block. */
444
- const FRONTEND_CONTRACT_INPUT_MAX_CHARS = 12_000;
445
442
  /**
446
- * Render the contract node's complete-but-bounded ledger handoff. The
443
+ * Render the contract node's complete semantic ledger handoff. The
447
444
  * source-fidelity ledger already extracted canonical requirements with source
448
445
  * spans; the contract node confirms and commits them incrementally through
449
446
  * record_requirement instead of re-reading the raw source (extreme-environment:
450
447
  * a small output window cannot absorb a full source re-read).
451
448
  *
452
- * Same shape guarantees as the plan input block: always valid JSON under the
453
- * char bound, ids never drop, texts degrade through the cap ladder.
449
+ * Whole obligations are retained here; the executor selects complete scopes
450
+ * before dispatch. References and conditions are never clipped.
454
451
  */
455
452
  export function renderFrontendContractInputContext(input) {
456
- // Fragment bindings are ids, not prose: they are the one thing the contract
457
- // must never lose. r6 regression — the last-resort degradation dropped
458
- // sourceFragmentIds entirely, the model (correctly refusing to invent ids)
459
- // committed empty bindings, and the plan compile failed the ledger-binding
460
- // gate for every requirement. Bindings therefore bypass the cap ladder and
461
- // every degradation level; only requirement TEXTS and fragment CONTEXT
462
- // (path/headingPath) may degrade. Fragment context is rendered only for
463
- // fragments actually referenced by a requirement and shrinks first.
464
- const referencedFragmentIds = new Set(input.canonicalRequirements.flatMap((requirement) => planInputStrings(requirement.sourceFragmentIds)));
465
- const referencedFragments = input.fragments.filter((fragment) => referencedFragmentIds.has(fragment.id));
466
- const serializeAtCap = (cap) => JSON.stringify({
467
- requirements: input.canonicalRequirements.map((requirement) => ({
468
- id: requirement.id,
469
- text: planInputText(requirement.text, cap.text),
470
- sourceFragmentIds: planInputStrings(requirement.sourceFragmentIds),
471
- })),
472
- fragments: referencedFragments.map((fragment) => ({
473
- id: fragment.id,
474
- path: planInputText(fragment.path, 200),
475
- headingPath: planInputText(fragment.headingPath, 120),
476
- lineRange: fragment.lineRange,
477
- })),
478
- });
479
- let serialized = serializeAtCap(FRONTEND_PLAN_INPUT_CAP_LADDER[0]);
480
- for (const cap of FRONTEND_PLAN_INPUT_CAP_LADDER.slice(1)) {
481
- if (serialized.length <= FRONTEND_CONTRACT_INPUT_MAX_CHARS)
482
- break;
483
- serialized = serializeAtCap(cap);
484
- }
485
- if (serialized.length > FRONTEND_CONTRACT_INPUT_MAX_CHARS) {
486
- // Last resort: keep every requirement id AND its fragment bindings,
487
- // degrade texts, and shrink referenced fragment context first (halve,
488
- // then drop context fields, then drop the fragment list entirely).
489
- // Requirement ids and sourceFragmentIds are never dropped.
490
- let fragments = referencedFragments.map((fragment) => ({
491
- id: fragment.id,
492
- path: planInputText(fragment.path, 120),
493
- }));
494
- let requirements = input.canonicalRequirements.map((requirement) => {
495
- const sourceFragmentIds = planInputStrings(requirement.sourceFragmentIds);
496
- return {
497
- id: requirement.id,
498
- text: "(truncated)",
499
- // Empty bindings carry no information; omit them so the payload
500
- // stays inside the char bound when no requirement is bound.
501
- ...(sourceFragmentIds.length > 0 ? { sourceFragmentIds } : {}),
502
- };
503
- });
504
- let bounded = JSON.stringify({ degraded: "requirement-texts-truncated", requirements, fragments });
505
- while (bounded.length > FRONTEND_CONTRACT_INPUT_MAX_CHARS && fragments.length > 0) {
506
- fragments = fragments.slice(0, Math.floor(fragments.length / 2));
507
- bounded = JSON.stringify({
508
- degraded: "requirement-texts-truncated",
509
- requirements,
510
- fragments,
511
- });
512
- }
513
- serialized = bounded;
514
- }
453
+ const referenced = new Set(input.canonicalRequirements.flatMap(r => r.sourceFragmentIds));
454
+ const serialized = JSON.stringify({ requirements: input.canonicalRequirements, fragments: input.fragments.filter(f => referenced.has(f.id)) });
515
455
  return [
516
456
  "<frontend_contract_input>",
517
457
  "Canonical requirements extracted by the source-fidelity ledger, compiled by the runner. Treat them as the authoritative requirement inventory: confirm and commit each requirement through record_requirement (one per tool call); the ledger already binds source fragments, so do NOT re-read the raw source files.",
@@ -536,16 +476,13 @@ export async function buildFrontendContractInputContext(input) {
536
476
  });
537
477
  }
538
478
  /**
539
- * Render the planner's complete-but-bounded evidence handoff from committed
479
+ * Render the planner's complete semantic evidence handoff from committed
540
480
  * typed facts. It deliberately excludes upstream response prose and artifact
541
481
  * paths: Contract and Scout have already established these facts, so Plan
542
482
  * should decide and commit rather than spend another model turn reading them.
543
483
  *
544
- * The block is always valid JSON under the char bound: field texts shrink
545
- * through a cap ladder before any fact is dropped, and the last-resort
546
- * fallback keeps every requirement id (with `text: "(truncated)"`) while
547
- * declaring the degradation, so the planner records targeted evidence gaps
548
- * instead of receiving a silently corrupted tail.
484
+ * Whole obligations are retained. Session packing and scoped projection happen
485
+ * in the executor before dispatch, without dropping text or source identities.
549
486
  */
550
487
  export function renderFrontendPlanInputContext(input) {
551
488
  const committedFacts = (records) => records.flatMap((record) => record.phase === "committed" && planInputRecord(record.fact)
@@ -553,8 +490,9 @@ export function renderFrontendPlanInputContext(input) {
553
490
  : []);
554
491
  const contractFacts = committedFacts(input.contractRecords);
555
492
  const scoutFacts = committedFacts(input.scoutRecords);
556
- const requirements = contractFacts
557
- .filter((fact) => fact.kind === "requirement" && fact.origin === "contract")
493
+ const requirementFacts = resolveFrontendContractRequirements(contractFacts);
494
+ const requiredDeliverables = extractRequiredDeliverablePaths(contractFacts);
495
+ const requirements = requirementFacts
558
496
  .map((fact) => ({
559
497
  id: planInputText(fact.id, 80),
560
498
  text: planInputText(fact.text),
@@ -580,97 +518,55 @@ export function renderFrontendPlanInputContext(input) {
580
518
  paths: fact.paths,
581
519
  conflicts: fact.conflicts,
582
520
  }));
521
+ // Authoritative UI states (contract-declared): the source's UI-state table
522
+ // extracted by the contract node. The planner binds these ids instead of
523
+ // inventing list-visibility variants.
524
+ const declaredUiStates = contractFacts
525
+ .filter((fact) => fact.kind === "ui-state-declaration" && fact.origin === "contract")
526
+ .map((fact) => ({
527
+ id: planInputText(fact.id, 80),
528
+ trigger: planInputText(fact.trigger),
529
+ observableOutcome: planInputText(fact.observableOutcome),
530
+ }))
531
+ .filter((state) => state.id !== undefined);
532
+ // Replay registry edits and state-flow removals/additions in commit order.
533
+ const committedUxNames = collectCanonicalStateFlowNames(input.planRecords ?? [], true);
534
+ const committedUiStateNames = [...committedUxNames.uiStateNames];
535
+ const committedInteractionNames = [...committedUxNames.interactionNames];
583
536
  // Reviewer-rubric scaffold: the design reviewer re-runs the design-policy
584
537
  // checks on the committed facts, so publish the checklist to the producer.
585
538
  // Requirements whose contract evidence expects behavioural verification are
586
539
  // enumerated explicitly — those are the slots the reviewer finds missing
587
540
  // when the plan models interactions ad hoc (r8/r9 findings).
588
- const behaviorRequiredIds = requirements
589
- .filter((requirement) => {
590
- const fact = contractFacts.find((candidate) => candidate.kind === "requirement" &&
591
- candidate.origin === "contract" &&
592
- candidate.id === requirement.id);
593
- const evidence = fact?.evidence;
594
- return evidence?.behavior === "required";
595
- })
541
+ const behaviorRequiredIds = requirementFacts
542
+ .filter((requirement) => requirement.evidence.behavior === "required")
596
543
  .map((requirement) => requirement.id);
597
- const serializeAtCap = (cap) => JSON.stringify({
598
- requirements: requirements.map((requirement) => ({
599
- id: requirement.id,
600
- text: planInputText(requirement.text, cap.text),
601
- sourceFragmentIds: planInputStrings(requirement.sourceFragmentIds).slice(0, cap.array),
602
- })),
603
- targetSurface: targetSurface.map((surface) => ({
604
- completeness: planInputText(surface.completeness, 32),
605
- entrypoint: planInputText(surface.entrypoint, cap.text),
606
- routeOrMount: planInputText(surface.routeOrMount, cap.text),
607
- implementationPaths: planInputStrings(surface.implementationPaths).slice(0, cap.array),
608
- testPaths: planInputStrings(surface.testPaths).slice(0, cap.array),
609
- dataSource: planInputText(surface.dataSource, cap.text),
610
- allowedPathConflicts: planInputStrings(surface.allowedPathConflicts).slice(0, cap.array),
611
- unresolvedPaths: planInputStrings(surface.unresolvedPaths).slice(0, cap.array),
612
- })),
613
- designEvidence: designEvidence.map((evidence) => ({
614
- source: planInputText(evidence.source, cap.text),
615
- paths: planInputStrings(evidence.paths).slice(0, cap.array),
616
- conflicts: planInputStrings(evidence.conflicts).slice(0, cap.array),
617
- })),
544
+ const serialized = JSON.stringify({
545
+ requirements, requiredDeliverables, targetSurface, designEvidence, declaredUiStates,
546
+ executionGroups: collectFrontendExecutionGroups(contractFacts.filter(f => f.kind === "requirement").map(f => ({ id: String(f.id), execution: f.execution }))),
547
+ constraints: contractFacts.filter(f => ["constraint", "open-question", "split-proposal", "handoff-intent"].includes(String(f.kind))),
548
+ committedUx: committedUiStateNames.length || committedInteractionNames.length ? { uiStateNames: committedUiStateNames, interactionNames: committedInteractionNames } : undefined,
618
549
  });
619
- let serialized = serializeAtCap(FRONTEND_PLAN_INPUT_CAP_LADDER[0]);
620
- for (const cap of FRONTEND_PLAN_INPUT_CAP_LADDER.slice(1)) {
621
- if (serialized.length <= FRONTEND_PLAN_INPUT_MAX_CHARS)
622
- break;
623
- serialized = serializeAtCap(cap);
624
- }
625
- if (serialized.length > FRONTEND_PLAN_INPUT_MAX_CHARS) {
626
- // Last resort: keep every requirement id (ids are short and the plan
627
- // prompt separately lists them) but drop their texts, shrink scout facts
628
- // to the minimum, and declare the degradation instead of corrupting JSON.
629
- let fallback = {
630
- degraded: "requirement-texts-truncated",
631
- requirements: requirements.map((requirement) => ({
632
- id: requirement.id,
633
- text: "(truncated)",
634
- })),
635
- targetSurface: targetSurface.map((surface) => ({
636
- completeness: planInputText(surface.completeness, 32),
637
- implementationPaths: planInputStrings(surface.implementationPaths).slice(0, FRONTEND_PLAN_INPUT_CAP_LADDER[3].array),
638
- })),
639
- designEvidence: [],
640
- };
641
- let bounded = JSON.stringify(fallback);
642
- let keep = fallback.requirements.length;
643
- while (bounded.length > FRONTEND_PLAN_INPUT_MAX_CHARS &&
644
- keep > 0) {
645
- keep = Math.max(0, Math.floor(keep / 2));
646
- fallback = { ...fallback, requirements: fallback.requirements.slice(0, keep) };
647
- bounded = JSON.stringify({
648
- ...fallback,
649
- requirementIdsTruncated: keep < requirements.length,
650
- });
651
- }
652
- serialized = bounded;
653
- }
654
550
  const checklistLines = [
655
- "1. Every interaction you record needs a uiComponentChoices entry whose purpose equals the interaction name, or one decision=reuse-existing choice covering behavioural interactions.",
656
- "2. Every applicable UI state needs a purpose-matching component choice or a stylingStrategy.",
657
- "3. Every requirement marked (behavior) below needs modelled interactions plus at least one verification target that references it.",
658
- "4. targets.files must name the concrete deliverable files; never leave the scope broader than the frozen requirements state.",
551
+ "1. Record the GLOBAL UX vocabulary with record_state_registry BEFORE any record_state_flow: one stable behavior-domain name per state/interaction (e.g. planner-task-edit), never one name per AC number, and never a rename of an already-recorded concept. Coverage slices by AC; UX does not.",
552
+ "2. Every recorded interaction/uiState name must be in that registry, and uiState names must use the contract's declared authoritative ids (declaredUiStates below) when present.",
553
+ "3. Every interaction and every applicable UI state must be covered by a uiComponentChoices entry: its purpose equals the name, or the choice lists the name in covers (one choice may cover many ids). A reuse-existing decision without evidencePath is rejected; stylingStrategy alone covers nothing.",
554
+ "4. Every requirement marked (behavior) below needs modelled interactions plus at least one verification target that references it.",
659
555
  "5. Verification targets may only reference UI states and requirements you actually recorded (the record_* tools reject unknown references).",
660
556
  `Requirements requiring behavioural coverage: ${behaviorRequiredIds.length > 0 ? behaviorRequiredIds.join(", ") : "(none)"}`,
661
- "6. A decision=new component must declare sourceRequirementIds and pass sourceFragmentId for the frozen PRD fragment whose section matches the component's purpose — the runtime validates that binding and derives specReference (path/section/line); the reviewer checks purpose↔citation consistency.",
557
+ "6. A decision=new component must declare sourceRequirementIds and pass sourceFragmentId for the frozen PRD fragment whose section matches the component's purpose — the runtime validates that binding and derives specReference (path/section/line); the reviewer checks purpose↔citation consistency. A decision=reuse-existing component must pass evidencePath pointing at the existing repo file that proves the reuse.",
662
558
  ...[...input.componentSourceCitations ?? []]
663
559
  .filter(([id]) => behaviorRequiredIds.includes(id))
664
560
  .flatMap(([id, citations]) => citations.map((citation) => ` ${id} + ${citation.fragmentId} → ${citation.section}${citation.line ? ` (line ${citation.line})` : ""}`)),
665
561
  ];
666
562
  return [
667
563
  "<frontend_plan_input>",
668
- "Committed Contract/Scout facts, compiled by the runner. Treat them as the complete planning evidence.",
564
+ "Committed Contract/Scout facts, compiled by the runner. Treat them as the complete planning evidence. declaredUiStates are the authoritative UI states from the task source; committedUx (retry attempts) is the UX vocabulary already recorded — reuse those names, never re-invent them.",
669
565
  serialized,
670
566
  "Do not read upstream artifacts, task sources, or repository files. If this input cannot support a decision, record a genuine evidence gap.",
671
567
  "</frontend_plan_input>",
672
568
  "<plan_review_checklist>",
673
- "The design reviewer re-runs these exact checks on the committed facts; satisfy every line before finalize_plan:",
569
+ "Satisfy these checks in the committed facts before the runtime compiles and finalizes the Plan:",
674
570
  ...checklistLines,
675
571
  "</plan_review_checklist>",
676
572
  ].join("\n");
@@ -692,6 +588,16 @@ export async function buildFrontendPlanInputContext(runDir, componentSourceCitat
692
588
  // forbids reading anything.
693
589
  throw new Error(`frontend-plan-input-unavailable: cannot read committed typed facts (${error instanceof Error ? error.message : String(error)})`);
694
590
  }
591
+ // Retry-attempt continuity (UX slice visibility): the plan node's own
592
+ // committed facts are absent on the first attempt and present on retries;
593
+ // a missing file is normal there, not a broken pipeline.
594
+ let planRecords = [];
595
+ try {
596
+ planRecords = await readTypedEventStoreFromJsonl(path.join(runDir, "frontend-plan-pi", "plan-typed-facts.jsonl"));
597
+ }
598
+ catch {
599
+ planRecords = [];
600
+ }
695
601
  const committedCount = [...contractRecords, ...scoutRecords].filter((record) => record.phase === "committed").length;
696
602
  if (committedCount === 0) {
697
603
  throw new Error(`frontend-plan-input-unavailable: no committed Contract/Scout facts in ${contractFactsPath} / ${scoutFactsPath}`);
@@ -699,12 +605,17 @@ export async function buildFrontendPlanInputContext(runDir, componentSourceCitat
699
605
  return renderFrontendPlanInputContext({
700
606
  contractRecords,
701
607
  scoutRecords,
608
+ planRecords,
702
609
  componentSourceCitations,
703
610
  });
704
611
  }
705
612
  export function buildAttemptPrompt(task, basePrompt, attemptNumber, previousFailureCategory, previousProtocolReason, recoveryTargetPaths, recoveryDiagnostics, frontendPlanRetryStep) {
706
613
  if (attemptNumber <= 1)
707
614
  return basePrompt;
615
+ // Match the executor segmented Plan identity; custom nodes retain their terminal.
616
+ const planCompletion = task.id === FRONTEND_PLAN_NODE_ID
617
+ ? "Stop after committing the required facts. The runtime compiles and finalizes the committed ledger automatically; only repair facts reported by its validation."
618
+ : "Then call finalize_plan exactly once.";
708
619
  // Context overflow is a transport/session failure, not a plan-protocol
709
620
  // failure. It must take precedence over the plan retry ladder so every
710
621
  // retry, including a repeated plan overflow, starts from the compact
@@ -736,13 +647,97 @@ export function buildAttemptPrompt(task, basePrompt, attemptNumber, previousFail
736
647
  "</retry_instruction>",
737
648
  ].join("\n");
738
649
  }
650
+ // Repair-category guidance must outrank the retry ladder position: the
651
+ // ladder advances monotonically on transport failures (e.g. length →
652
+ // compact-terminal-first), and its "keep the committed ledger intact"
653
+ // instruction directly contradicts the repair action for invalid-output /
654
+ // truncated ledger facts (re-commit corrected record_* facts). When both
655
+ // apply, the model receives the repair instruction, not the rung script.
656
+ if (previousFailureCategory === "invalid-output" &&
657
+ task.structuredContractOutput &&
658
+ previousProtocolReason) {
659
+ // The frontend plan node's compile authority is the committed typed
660
+ // ledger, not a fenced JSON text artifact: its retry guidance must
661
+ // direct the model to re-commit corrected record_* facts and respect
662
+ // terminal ownership. The full-contract JSON guidance below applies
663
+ // only to nodes whose authority is still a text contract artifact.
664
+ if (task.structuredContractOutput.schemaId ===
665
+ "frontend-implementation-contract-plan-patch-v1") {
666
+ const splitGuidance = /write-set-too-large|split the task/.test(previousProtocolReason ?? "")
667
+ ? [
668
+ "",
669
+ "The writeSet is too large for one implement node. Preserve the complete requirement and file coverage. This needs a Contract-level task split, not a Plan formatting repair. Report the write-set-too-large finding and the affected paths for the controller to resume Contract/split orchestration. Plan cannot change protected targets.files or call Contract-only tools; do not invent a split tool or discard required files.",
670
+ ]
671
+ : [];
672
+ return [
673
+ basePrompt,
674
+ "",
675
+ "<retry_instruction>",
676
+ "Previous plan ledger facts failed canonical contract validation:",
677
+ previousProtocolReason,
678
+ "Fix the reported violations by re-committing corrected record_* facts. The committed typed ledger is the only compile authority.",
679
+ planCompletion,
680
+ "Do not emit a fenced JSON contract, protected skeleton fields, or an openspec-citations block; narrative JSON is not validated and wastes the output budget.",
681
+ ...frontendPlanValidationRetryGuidance(previousProtocolReason),
682
+ ...splitGuidance,
683
+ "</retry_instruction>",
684
+ ].join("\n");
685
+ }
686
+ return [
687
+ basePrompt,
688
+ "",
689
+ "<retry_instruction>",
690
+ "Previous attempt produced an invalid frontend implementation contract:",
691
+ previousProtocolReason,
692
+ ...frontendStructuredArtifactRetryGuidance(task.structuredContractOutput.schemaId),
693
+ "Fix every reported field violation: do not emit null for optional fields, do not misspell field names, and match the required types exactly.",
694
+ "</retry_instruction>",
695
+ ].join("\n");
696
+ }
697
+ if (previousFailureCategory === "invalid-output" &&
698
+ task.id === "frontend-scout-pi") {
699
+ return [
700
+ basePrompt,
701
+ "",
702
+ "<retry_instruction>",
703
+ "The previous Scout attempt did not commit a complete, runtime-evidenced target surface.",
704
+ "Search the repository only as needed to establish the real entrypoint, implementation ownership, and applicable test path. Commit record_target_surface with completeness=complete and unresolvedPaths=[] only after at least one named target has fresh runtime evidence, unless the task source explicitly declares a greenfield target: in that case every future path must be source-declared by the runtime-enriched fact. If ownership truly cannot be established, record completeness=blocked with each unresolved path; do not make Plan discover it.",
705
+ "</retry_instruction>",
706
+ ].join("\n");
707
+ }
708
+ if (previousFailureCategory === "structured-output-truncated" &&
709
+ task.structuredContractOutput) {
710
+ if (task.structuredContractOutput.schemaId ===
711
+ "frontend-implementation-contract-plan-patch-v1") {
712
+ return [
713
+ basePrompt,
714
+ "",
715
+ "<retry_instruction>",
716
+ "Previous attempt was truncated by the provider (stopReason=length) before the plan facts were fully committed.",
717
+ "Re-commit the missing record_* facts; the committed typed ledger is the only compile authority. Do NOT re-read contract/scout outputs or source files — use the facts already in context. Commit record_* facts one tool call per message.",
718
+ planCompletion,
719
+ "Do not emit a fenced JSON contract, protected skeleton fields, or an openspec-citations block; narrative JSON is not validated and wastes the output budget.",
720
+ "</retry_instruction>",
721
+ ].join("\n");
722
+ }
723
+ return [
724
+ basePrompt,
725
+ "",
726
+ "<retry_instruction>",
727
+ "Previous attempt was truncated by the provider (stopReason=length) before the JSON contract was completed.",
728
+ ...frontendStructuredArtifactRetryGuidance(task.structuredContractOutput.schemaId),
729
+ "The JSON artifact must be complete; omit evidence excerpts and duplicated upstream context.",
730
+ "</retry_instruction>",
731
+ ].join("\n");
732
+ }
739
733
  if (frontendPlanRetryStep === "compact-terminal-first") {
740
734
  return [
741
735
  basePrompt,
742
736
  "",
743
737
  "<retry_instruction>",
744
738
  "Frontend plan retry ladder step: compact-terminal-first.",
745
- "Do NOT rewrite the narrative. Only adopt already staged/quarantined fresh facts, fill the missing required facts, then call finalize_plan exactly once.",
739
+ "Do NOT rewrite the narrative. Only adopt already staged/quarantined fresh facts and fill the missing required facts.",
740
+ planCompletion,
746
741
  "Keep the existing committed ledger intact; do not re-derive already committed facts.",
747
742
  "</retry_instruction>",
748
743
  ].join("\n");
@@ -753,7 +748,8 @@ export function buildAttemptPrompt(task, basePrompt, attemptNumber, previousFail
753
748
  "",
754
749
  "<retry_instruction>",
755
750
  "Frontend plan retry ladder step: bounded-tool-only.",
756
- "Reduce reasoning and wall-clock time. Use only read / fact / terminal tools and only for the necessary missing facts, then call finalize_plan exactly once.",
751
+ "Reduce reasoning and wall-clock time. Use only the tools exposed for this session and only for the necessary missing facts.",
752
+ planCompletion,
757
753
  "Do not expand scope or re-derive already committed facts.",
758
754
  "</retry_instruction>",
759
755
  ].join("\n");
@@ -764,7 +760,8 @@ export function buildAttemptPrompt(task, basePrompt, attemptNumber, previousFail
764
760
  "",
765
761
  "<retry_instruction>",
766
762
  "Frontend plan retry ladder step: backup-model.",
767
- "A backup provider/model route was selected after repeated non-converging failures. Re-derive only the missing committed facts, then call finalize_plan exactly once; do not repeat the failed strategy.",
763
+ "A backup provider/model route was selected after repeated non-converging failures. Re-derive only the missing committed facts; do not repeat the failed strategy.",
764
+ planCompletion,
768
765
  "</retry_instruction>",
769
766
  ].join("\n");
770
767
  }
@@ -803,87 +800,30 @@ export function buildAttemptPrompt(task, basePrompt, attemptNumber, previousFail
803
800
  "",
804
801
  "<retry_instruction>",
805
802
  "Previous plan attempt issued too many read-only tool calls (read/grep/ls/find) and blew up the context window. Trust the upstream frontend-contract-pi typed requirement facts and frontend-scout-pi target surface already provided — do NOT re-read contract/scout stdout, PRD/source files, or component sources you already inspected.",
806
- "Minimize discovery reads: only read what you genuinely need, once. Commit record_plan_requirement / record_plan_verification_target / record_* facts directly from the facts already in context (one tool call per message), then call finalize_plan exactly once.",
803
+ "Minimize discovery reads: only read what you genuinely need, once. Commit the required record_* facts directly from the facts already in context (one tool call per message).",
804
+ planCompletion,
807
805
  "</retry_instruction>",
808
806
  ].join("\n");
809
807
  }
810
- if (previousFailureCategory === "invalid-output" &&
811
- task.structuredContractOutput &&
812
- previousProtocolReason) {
813
- // The frontend plan node's compile authority is the committed typed
814
- // ledger, not a fenced JSON text artifact: its retry guidance must
815
- // direct the model to re-commit corrected record_* facts and
816
- // finalize_plan. The legacy full-contract JSON guidance below applies
817
- // only to nodes whose authority is still a text contract artifact.
818
- if (task.structuredContractOutput.schemaId ===
819
- "frontend-implementation-contract-plan-patch-v1") {
820
- const splitGuidance = /write-set-too-large|split the task/.test(previousProtocolReason ?? "")
821
- ? [
822
- "",
823
- "The writeSet is too large for one implement node. Do NOT delete implementation files to squeeze under the limit — that drops required work. Split the task via record_split_proposal (or narrow targets.files to a genuine subset) so each implement node stays bounded; the full file set must remain covered across the split.",
824
- ]
825
- : [];
826
- return [
827
- basePrompt,
828
- "",
829
- "<retry_instruction>",
830
- "Previous plan ledger facts failed canonical contract validation:",
831
- previousProtocolReason,
832
- "Fix the reported violations by re-committing corrected record_* facts and calling finalize_plan exactly once. The committed typed ledger is the only compile authority.",
833
- "Do not emit a fenced JSON contract, protected skeleton fields, or an openspec-citations block; narrative JSON is not validated and wastes the output budget.",
834
- ...frontendPlanValidationRetryGuidance(previousProtocolReason),
835
- ...splitGuidance,
836
- "</retry_instruction>",
837
- ].join("\n");
838
- }
808
+ // Generic output-limit fallback. Every branch above this one carries a
809
+ // more precise instruction for the same capacity signal (contract repair
810
+ // reasons, ladder rungs — compact-terminal-first is the reason-mandated
811
+ // rung for length-before-terminal —, protocol/review/read-burst repair),
812
+ // so output-limit must not shadow them.
813
+ if (previousFailureCategory === OUTPUT_LIMIT_RETRY_CATEGORY) {
839
814
  return [
840
815
  basePrompt,
841
816
  "",
842
817
  "<retry_instruction>",
843
- "Previous attempt produced an invalid frontend implementation contract:",
844
- previousProtocolReason,
845
- ...frontendStructuredArtifactRetryGuidance(task.structuredContractOutput.schemaId),
846
- "Fix every reported field violation: do not emit null for optional fields, do not misspell field names, and match the required types exactly.",
847
- "</retry_instruction>",
848
- ].join("\n");
849
- }
850
- if (previousFailureCategory === "invalid-output" &&
851
- task.id === "frontend-scout-pi") {
852
- return [
853
- basePrompt,
854
- "",
855
- "<retry_instruction>",
856
- "The previous Scout attempt did not commit a complete, runtime-evidenced target surface.",
857
- "Search the repository only as needed to establish the real entrypoint, implementation ownership, and applicable test path. Commit record_target_surface with completeness=complete and unresolvedPaths=[] only after at least one named target has fresh runtime evidence, unless the task source explicitly declares a greenfield target: in that case every future path must be source-declared by the runtime-enriched fact. If ownership truly cannot be established, record completeness=blocked with each unresolved path; do not make Plan discover it.",
858
- "</retry_instruction>",
859
- ].join("\n");
860
- }
861
- if (previousFailureCategory === "structured-output-truncated" &&
862
- task.structuredContractOutput) {
863
- if (task.structuredContractOutput.schemaId ===
864
- "frontend-implementation-contract-plan-patch-v1") {
865
- return [
866
- basePrompt,
867
- "",
868
- "<retry_instruction>",
869
- "Previous attempt was truncated by the provider (stopReason=length) before the plan facts were fully committed.",
870
- "Re-commit the missing record_* facts and call finalize_plan exactly once; the committed typed ledger is the only compile authority. Do NOT re-read contract/scout outputs or source files — use the facts already in context. Commit record_* facts one tool call per message, then finalize_plan immediately.",
871
- "Do not emit a fenced JSON contract, protected skeleton fields, or an openspec-citations block; narrative JSON is not validated and wastes the output budget.",
872
- "</retry_instruction>",
873
- ].join("\n");
874
- }
875
- return [
876
- basePrompt,
877
- "",
878
- "<retry_instruction>",
879
- "Previous attempt was truncated by the provider (stopReason=length) before the JSON contract was completed.",
880
- ...frontendStructuredArtifactRetryGuidance(task.structuredContractOutput.schemaId),
881
- "The JSON artifact must be complete; omit evidence excerpts and duplicated upstream context.",
818
+ "The previous turn ended with stopReason=length before the required output was complete. This is output-capacity truncation, not empty output.",
819
+ "Continue incrementally from already committed typed facts and current in-scope workspace files. Do not repeat completed discovery, decisions, facts, or writes.",
820
+ "Generate the smallest unfinished unit next, validate its required format immediately, repair any format error in this node, and only then continue to the next unfinished unit or terminal tool.",
821
+ "Keep prose minimal and finish the required terminal/output protocol as soon as the remaining work is valid.",
882
822
  "</retry_instruction>",
883
823
  ].join("\n");
884
824
  }
885
825
  if (previousFailureCategory === "writer-empty-diff") {
886
- const maxAttempts = task.retryPolicy?.maxAttempts ?? 3;
826
+ const maxAttempts = task.retryPolicy?.maxAttempts ?? 5;
887
827
  // When a completeness progress exists for this writer, fold the concrete
888
828
  // target paths into the empty-diff retry so the model does not guess and
889
829
  // does not need to read a forbidden `.harness/**` evidence file.
@@ -911,7 +851,7 @@ export function buildAttemptPrompt(task, basePrompt, attemptNumber, previousFail
911
851
  ].join("\n");
912
852
  }
913
853
  if (previousFailureCategory === "incomplete-write-set") {
914
- const maxAttempts = task.retryPolicy?.maxAttempts ?? 3;
854
+ const maxAttempts = task.retryPolicy?.maxAttempts ?? 5;
915
855
  const bindingOnly = task.id?.startsWith("generate-backend-md-case-") === true &&
916
856
  (recoveryTargetPaths?.length ?? 0) === 1 &&
917
857
  Object.values(recoveryDiagnostics ?? {}).flat().some((detail) => /(?:unclassified Test Points|duplicate Test Point bindings)/i.test(detail));
@@ -985,7 +925,8 @@ export function buildAttemptPrompt(task, basePrompt, attemptNumber, previousFail
985
925
  "",
986
926
  "<retry_instruction>",
987
927
  "Previous attempt exceeded the structured output size limit.",
988
- "Re-commit corrected record_* facts and call finalize_plan exactly once; the committed typed ledger is the only compile authority.",
928
+ "Re-commit corrected record_* facts; the committed typed ledger is the only compile authority.",
929
+ planCompletion,
989
930
  "Do not emit a fenced JSON contract, protected skeleton fields, or an openspec-citations block; narrative JSON is not validated and wastes the output budget.",
990
931
  "</retry_instruction>",
991
932
  ].join("\n");
@@ -1143,6 +1084,8 @@ function validateRepairArtifactGateBeforeShell(input) {
1143
1084
  if (!gate)
1144
1085
  return;
1145
1086
  const upstream = input.state.nodes[gate.fromNodeId];
1087
+ if (!upstream)
1088
+ return;
1146
1089
  const parsed = parseSupervisorRepairArtifact(upstream);
1147
1090
  if (!parsed.ok) {
1148
1091
  throw new Error(`repair artifact gate failed: ${parsed.reason}`);
@@ -1519,6 +1462,20 @@ export async function executeDagNode(input) {
1519
1462
  return;
1520
1463
  }
1521
1464
  }
1465
+ if (task.id === "frontend-scout-pi") {
1466
+ try {
1467
+ const { readTypedEventStoreFromJsonl } = await import("./frontend-typed-event-store.js");
1468
+ const facts = (await readTypedEventStoreFromJsonl(path.join(runDir, "frontend-contract-pi", "contract-typed-facts.jsonl"))).filter(r => r.phase === "committed").map(r => r.fact);
1469
+ const requirements = [...new Map(facts.filter(f => f.kind === "requirement").map(f => [String(f.id), f])).values()];
1470
+ if (!requirements.length)
1471
+ throw Error("FRONTEND_INPUT_MISSING: Scout needs committed Contract obligations");
1472
+ prompt += `\n<frontend_scout_input>\n${JSON.stringify({ requirements, sharedFacts: facts.filter(f => !["requirement", "contract-scope-completed", "contract-finalized"].includes(String(f.kind))) })}\n</frontend_scout_input>`;
1473
+ }
1474
+ catch (error) {
1475
+ await failBeforePrompt(error, "frontend-scout-input-unavailable");
1476
+ return;
1477
+ }
1478
+ }
1522
1479
  if (FRONTEND_WRITER_NODE_IDS.includes(nodeId)) {
1523
1480
  // Design-review findings are not reliable in the provider's prose output
1524
1481
  // (typed terminal nodes commonly return an empty assistant message). Inject
@@ -1605,6 +1562,7 @@ export async function executeDagNode(input) {
1605
1562
  // evidence so a late best-effort write cannot recreate an archived run dir.
1606
1563
  void input.persistState().catch(() => { });
1607
1564
  };
1565
+ const scoutCompletedShards = task.id === "frontend-scout-pi" && isSafeReadOnlyPiRetryCandidate(task) ? new Map() : undefined;
1608
1566
  let terminalResult;
1609
1567
  let previousFailureCategory;
1610
1568
  let previousProtocolReason;
@@ -1706,6 +1664,8 @@ export async function executeDagNode(input) {
1706
1664
  attemptPrompt,
1707
1665
  });
1708
1666
  result = await executeNode({
1667
+ ...(scoutCompletedShards ? { scoutCompletedShards } : {}),
1668
+ ...(state.budgetLedger?.mode === "hard" && state.budgetLedger.limits.maxProviderRequests !== undefined ? { reserveProviderRequest: () => reserveDagProviderRequest({ state, nodeId, attempt: attemptNumber, persist: input.persistState, ...(spec.sourceProviderBudget ? { reserveTaskRequest: () => reserveTaskSourceProviderRequest({ repoRoot: cwd, taskId: spec.sourceProviderBudget.ledger.taskId, maxProviderRequests: spec.sourceProviderBudget.ledger.maxProviderRequests, expectedBudgetId: spec.sourceProviderBudget.ledger.budgetId, minimumReservedRequests: spec.sourceProviderBudget.ledger.reservedRequests }) } : {}) }) } : {}),
1709
1669
  task,
1710
1670
  cwd,
1711
1671
  model,
@@ -1727,6 +1687,32 @@ export async function executeDagNode(input) {
1727
1687
  durationMs: 0,
1728
1688
  };
1729
1689
  }
1690
+ // stopReason=length on top of a bare empty-output verdict is a provider
1691
+ // capacity signal, not a true empty response: reroute it through the
1692
+ // dedicated output-limit retry path while keeping the raw category for
1693
+ // diagnostics. Bare empty-output and transport aliases (network,
1694
+ // nonzero-exit, unknown) are rerouted — categories that already carry a
1695
+ // precise repair instruction (output-too-large, invalid-output,
1696
+ // protocol-invalid, structured-output-truncated via the validators below,
1697
+ // writer categories) keep their classification so their exact retry
1698
+ // guidance still reaches the model.
1699
+ if (task.executor === "pi" &&
1700
+ !result.ok &&
1701
+ result.stopReason === "length" &&
1702
+ (result.failureCategory === undefined ||
1703
+ ["empty-output", "network", "nonzero-exit", "unknown"].includes(result.failureCategory))) {
1704
+ result = {
1705
+ ...result,
1706
+ rawFailureCategory: result.rawFailureCategory ?? result.failureCategory,
1707
+ failureCategory: OUTPUT_LIMIT_RETRY_CATEGORY,
1708
+ stderr: [
1709
+ result.stderr,
1710
+ "output-limit: stopReason=length; preserve completed work and retry only the unfinished output",
1711
+ ]
1712
+ .filter(Boolean)
1713
+ .join("\n"),
1714
+ };
1715
+ }
1730
1716
  if (task.id === "generate-backend-md-plan-pi" &&
1731
1717
  !result.ok &&
1732
1718
  (result.failureCategory === "output-too-large" ||
@@ -1738,6 +1724,20 @@ export async function executeDagNode(input) {
1738
1724
  ? result.stderr.slice(markerIndex, markerIndex + 4_000).trim()
1739
1725
  : `backend-test Markdown plan attempt failed with ${result.failureCategory}`;
1740
1726
  }
1727
+ // Decision-path Plan bridge failures surface from the executor as
1728
+ // invalid-output (the derived relationship patch failed pre-validation),
1729
+ // NOT through the R1 structured self-check (which only runs when
1730
+ // result.ok). Capture the bridge diagnostics into previousProtocolReason
1731
+ // so the next attempt prompt tells the model exactly which decision facts
1732
+ // to repair instead of replaying the identical under-declared session.
1733
+ if (task.id === FRONTEND_PLAN_NODE_ID &&
1734
+ !result.ok &&
1735
+ result.failureCategory === "invalid-output" &&
1736
+ /frontend decision → relationship patch failed|frontend decision finalize failed/.test(result.stderr ?? "")) {
1737
+ previousProtocolReason = (result.stderr ?? "")
1738
+ .slice(-4_000)
1739
+ .trim();
1740
+ }
1741
1741
  if (isFrontendStructuredRepairSchemaId(task.structuredContractOutput?.schemaId)) {
1742
1742
  const rawText = canonicalNodeOutput(result);
1743
1743
  if (rawText.trim().length > 0) {
@@ -1860,7 +1860,7 @@ export async function executeDagNode(input) {
1860
1860
  !result.ok &&
1861
1861
  retryPolicy !== undefined) {
1862
1862
  const submissions = await countContractRecordSubmissions(runDir, nodeId);
1863
- if (submissions === 0) {
1863
+ if (submissions === 0 && result.stopReason !== "length") {
1864
1864
  result = {
1865
1865
  ...result,
1866
1866
  failureCategory: "empty-output",
@@ -1906,7 +1906,7 @@ export async function executeDagNode(input) {
1906
1906
  // reason, detect new committed facts, and escalate instead of re-running.
1907
1907
  if (frontendPlanLadderEnabled && !result.ok) {
1908
1908
  const afterSnapshot = await readFrontendPlanCommittedSnapshot(runDir, nodeId);
1909
- const hasNewCommittedFact = beforeCommittedDigest !== undefined &&
1909
+ const hasNewCommittedFact = !result.stderr?.includes("FRONTEND_PLAN_NO_PROGRESS") && beforeCommittedDigest !== undefined &&
1910
1910
  afterSnapshot.digest !== beforeCommittedDigest;
1911
1911
  const protocolReason = projectFrontendNodeProtocolFailureReason({
1912
1912
  failureCategory: result.failureCategory,
@@ -1930,13 +1930,23 @@ export async function executeDagNode(input) {
1930
1930
  frontendPriorFingerprints.push(fingerprint);
1931
1931
  frontendPlanRetryStep = nextStep;
1932
1932
  if (nextStep === "unsupported-provider-capability") {
1933
+ // Reachability first: when the failed attempts never reached model
1934
+ // reasoning (gateway 5xx / rate limit / quota / network), the
1935
+ // ladder's fail-closed category would read as a capability mismatch
1936
+ // and send the diagnosis the wrong way. Keep the outage visible in
1937
+ // the node's category and explain why.
1938
+ const providerOutage = isProviderAvailabilityFailureCategory(result.failureCategory);
1933
1939
  result = {
1934
1940
  ...result,
1935
1941
  ok: false,
1936
- failureCategory: "unsupported-provider-capability",
1942
+ failureCategory: providerOutage
1943
+ ? "upstream-unavailable"
1944
+ : "unsupported-provider-capability",
1937
1945
  stderr: [
1938
1946
  result.stderr,
1939
- "frontend plan retry ladder: no compatible provider capability route for the protocol failure reason",
1947
+ providerOutage
1948
+ ? "frontend plan retry ladder: attempts failed on provider reachability (5xx / rate limit / quota / network), so this is an upstream outage, not a provider capability mismatch"
1949
+ : "frontend plan retry ladder: no compatible provider capability route for the protocol failure reason",
1940
1950
  ]
1941
1951
  .filter(Boolean)
1942
1952
  .join("\n"),