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

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 (485) hide show
  1. package/AGENTS.md +6 -3
  2. package/CHANGELOG.md +607 -93
  3. package/README.md +11 -5
  4. package/bin/loop-agent.js +7 -3
  5. package/dist/adapters/context-transfer/optional-pi-handoff.js +31 -0
  6. package/dist/adapters/context-transfer/pi-session.js +61 -0
  7. package/dist/application/dag/generate-task-dag.js +90 -21
  8. package/dist/application/dag/run-dag.js +41 -0
  9. package/dist/application/task-lifecycle/advance.js +40 -5
  10. package/dist/application/task-lifecycle/observe.js +171 -17
  11. package/dist/application/task-lifecycle/plan-transitions.js +42 -7
  12. package/dist/application/task-lifecycle/recommendations.js +13 -2
  13. package/dist/build-stamp.json +3 -3
  14. package/dist/cli/command-definitions.js +44 -10
  15. package/dist/cli/program.js +82 -6
  16. package/dist/cli/update/notifier.js +2 -2
  17. package/dist/cli/update/runtime-activity.js +1 -29
  18. package/dist/cli.js +2 -1
  19. package/dist/commands/client-recovery.js +11 -36
  20. package/dist/commands/dag-artifact.js +284 -0
  21. package/dist/commands/dag-context.js +184 -0
  22. package/dist/commands/dag-follow-up.js +138 -0
  23. package/dist/commands/dag-rerun-task.js +2 -0
  24. package/dist/commands/dag-rerun.js +261 -2
  25. package/dist/commands/init-model-catalog.js +486 -0
  26. package/dist/commands/init-upgrade.js +265 -97
  27. package/dist/commands/init.js +455 -28
  28. package/dist/commands/inspect-next.js +8 -0
  29. package/dist/commands/task-advance.js +73 -1
  30. package/dist/commands/task-source-prepare.js +5 -0
  31. package/dist/commands/task-status.js +1 -0
  32. package/dist/executors/dag-pi-executor.js +4323 -231
  33. package/dist/executors/pi-event-serializer.js +42 -1
  34. package/dist/executors/pi-executor.js +70 -6
  35. package/dist/executors/pi-extension-resolver.js +245 -0
  36. package/dist/executors/pi-playwright-cli-tool.js +74 -28
  37. package/dist/executors/pi-read-budget-policy.js +239 -0
  38. package/dist/executors/pi-sdk-executor.js +263 -59
  39. package/dist/executors/pi-writer-tool-policy.js +57 -1
  40. package/dist/executors/shell-executor.js +1456 -240
  41. package/dist/executors/shell-write-guard.js +14 -0
  42. package/dist/executors/workspace-write-snapshot.js +68 -0
  43. package/dist/governance/checks.js +1 -0
  44. package/dist/{worker → infrastructure}/console/app-data.js +4 -0
  45. package/dist/infrastructure/console/artifact-revision-store.js +430 -0
  46. package/dist/infrastructure/console/context-export-store.js +160 -0
  47. package/dist/infrastructure/console/dir-lock.js +132 -0
  48. package/dist/infrastructure/console/operation-store.js +417 -0
  49. package/dist/infrastructure/harness/artifact-store.js +10 -1
  50. package/dist/infrastructure/harness/atomic-write.js +35 -2
  51. package/dist/shared/context-transfer/artifact-revision.js +172 -0
  52. package/dist/shared/context-transfer.js +418 -0
  53. package/dist/shared/dag-failure-category.js +150 -0
  54. package/dist/shared/dag-prompt-override.js +27 -0
  55. package/dist/shared/openspec-spec.js +70 -4
  56. package/dist/shared/operator/capabilities.js +65 -4
  57. package/dist/shared/operator/safe-run-summary.js +1 -0
  58. package/dist/shared/path-safety.js +93 -0
  59. package/dist/shared/pi-context-pressure/checkpoint.js +116 -0
  60. package/dist/shared/pi-context-pressure/compaction-policy.js +151 -0
  61. package/dist/shared/pi-context-pressure/env.js +58 -0
  62. package/dist/shared/pi-context-pressure/extension.js +100 -0
  63. package/dist/shared/pi-context-pressure/index.js +7 -0
  64. package/dist/shared/pi-context-pressure/overflow.js +252 -0
  65. package/dist/shared/pi-context-pressure/sift-bridge.js +386 -0
  66. package/dist/shared/pi-context-pressure/telemetry.js +51 -0
  67. package/dist/shared/playwright-cli-command-policy.js +15 -0
  68. package/dist/shared/preview.js +28 -4
  69. package/dist/shared/update/console-notifier.js +100 -0
  70. package/dist/{cli → shared}/update/npm-client.js +70 -15
  71. package/dist/{cli → shared}/update/state.js +41 -13
  72. package/dist/task/config-types.js +125 -6
  73. package/dist/task/contract/adopt.js +4 -0
  74. package/dist/task/contract/apply.js +11 -1
  75. package/dist/task/contract/constants.js +3 -0
  76. package/dist/task/contract/diff.js +26 -0
  77. package/dist/task/contract/hash.js +3 -0
  78. package/dist/task/contract/import-revision.js +4 -0
  79. package/dist/task/contract/observe.js +25 -4
  80. package/dist/task/contract/paths.js +2 -1
  81. package/dist/task/contract/project.js +23 -1
  82. package/dist/task/contract/schema.js +9 -1
  83. package/dist/task/contract/transaction.js +12 -0
  84. package/dist/task/frontend-project-capability.js +203 -20
  85. package/dist/task/runtime.js +5 -2
  86. package/dist/task/source-prepare/build-draft.js +18 -3
  87. package/dist/task/source-prepare/completeness.js +188 -0
  88. package/dist/task/source-prepare/fragment-inventory.js +513 -0
  89. package/dist/task/source-prepare/index.js +3 -0
  90. package/dist/task/source-prepare/ledger-reconciliation.js +127 -0
  91. package/dist/task/source-prepare/ledger-review.js +214 -0
  92. package/dist/task/source-prepare/ledger.js +545 -0
  93. package/dist/task/source-prepare/parse-intent.js +24 -4
  94. package/dist/task/source-prepare/prepare.js +368 -2
  95. package/dist/task/source-prepare/semantic-intake.js +25 -5
  96. package/dist/task/source-prepare/source-fidelity-pi.js +384 -0
  97. package/dist/task/source-prepare/types.js +22 -0
  98. package/dist/task/source-references.js +22 -1
  99. package/dist/task/task-demand-routing.js +3 -0
  100. package/dist/worker/cli.js +18 -2
  101. package/dist/worker/console/chat/assistant-content.js +7 -0
  102. package/dist/worker/console/chat/chat-event-store.js +159 -18
  103. package/dist/worker/console/chat/chat-ui-policy.js +4 -2
  104. package/dist/worker/console/chat/context-panel.js +7 -0
  105. package/dist/worker/console/chat/deferred-turn.js +103 -0
  106. package/dist/worker/console/chat/goal-round-driver.js +72 -0
  107. package/dist/worker/console/chat/goals.js +300 -0
  108. package/dist/worker/console/chat/model-resolver.js +7 -4
  109. package/dist/worker/console/chat/operation-card.js +8 -1
  110. package/dist/worker/console/chat/pi-console-config.js +81 -10
  111. package/dist/worker/console/chat/pi-runtime.js +868 -30
  112. package/dist/worker/console/chat/provider-error.js +99 -0
  113. package/dist/worker/console/chat/repo-browser.js +101 -12
  114. package/dist/worker/console/chat/resource-preferences-store.js +1 -1
  115. package/dist/worker/console/chat/routes.js +1451 -145
  116. package/dist/worker/console/chat/sdd-data-alignment.js +222 -0
  117. package/dist/worker/console/chat/semantic-activity.js +25 -24
  118. package/dist/worker/console/chat/session-catalog.js +50 -0
  119. package/dist/worker/console/chat/session-stats.js +275 -0
  120. package/dist/worker/console/chat/session-store.js +348 -76
  121. package/dist/worker/console/chat/shortcuts.js +26 -3
  122. package/dist/worker/console/chat/sift-bridge.js +1 -0
  123. package/dist/worker/console/chat/todos.js +115 -0
  124. package/dist/worker/console/chat/tool-preview.js +42 -0
  125. package/dist/worker/console/chat/turn-process.js +185 -112
  126. package/dist/worker/console/chat/user-questions.js +266 -0
  127. package/dist/worker/console/chat/workspace-landing.js +79 -0
  128. package/dist/worker/console/console-handoff.js +82 -0
  129. package/dist/worker/console/console-update-and-init.js +115 -0
  130. package/dist/worker/console/console-update-runtime.js +84 -0
  131. package/dist/worker/console/context-transfer-diagnostics.js +198 -0
  132. package/dist/worker/console/dag-confirmation.js +1 -1
  133. package/dist/worker/console/dag-execution-receipt.js +54 -3
  134. package/dist/worker/console/doctor.js +1 -1
  135. package/dist/worker/console/draft-store.js +50 -1
  136. package/dist/worker/console/frontend-human-decision-adapter.js +19 -0
  137. package/dist/worker/console/frontend-split-operation-adapter.js +20 -0
  138. package/dist/worker/console/human-gate-token.js +1 -1
  139. package/dist/worker/console/index.js +6 -3
  140. package/dist/worker/console/inspect-split.js +18 -0
  141. package/dist/worker/console/interview/assessment.js +1 -1
  142. package/dist/worker/console/interview/session.js +1 -1
  143. package/dist/worker/console/native-directory-picker.js +13 -0
  144. package/dist/worker/console/operation-run-facts.js +19 -3
  145. package/dist/worker/console/operation-runner.js +45 -4
  146. package/dist/worker/console/operation-sse.js +1 -1
  147. package/dist/worker/console/operation-wait.js +1 -1
  148. package/dist/worker/console/operator-actions.js +534 -15
  149. package/dist/worker/console/operator-selection.js +6 -2
  150. package/dist/worker/console/operator-surface-health.js +2 -1
  151. package/dist/worker/console/operator-user-error.js +171 -2
  152. package/dist/worker/console/pi-plugins.catalog.json +73658 -0
  153. package/dist/worker/console/pi-plugins.js +238 -0
  154. package/dist/worker/console/pi-readiness.js +7 -6
  155. package/dist/worker/console/prd-intake-bridge.js +13 -0
  156. package/dist/worker/console/recovery-cta.js +4 -4
  157. package/dist/worker/console/recovery-error-copy.js +4 -4
  158. package/dist/worker/console/routes.js +1231 -10
  159. package/dist/worker/console/security.js +102 -13
  160. package/dist/worker/console/server.js +762 -159
  161. package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BmOEx0gA.js → abnfDiagram-N423BO3Z-BZogYNl1.js} +1 -1
  162. package/dist/worker/console/static/assets/{arc-BGiVVe8b.js → arc-DcJTLe2v.js} +1 -1
  163. package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-nDdu4rgJ.js → architectureDiagram-T3A2C74G-B39EQQ9n.js} +1 -1
  164. package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-Bb5u0BWf.js → blockDiagram-VBNYF7ZC-CitCGV56.js} +1 -1
  165. package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BlhC0j94.js → c4Diagram-5PPSVZJV-rvWuOHLG.js} +1 -1
  166. package/dist/worker/console/static/assets/channel-CXqdP5pW.js +1 -0
  167. package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-Ai8_qQXI.js → chunk-2GRJ4B5K-DGXplIJs.js} +1 -1
  168. package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-B9gyCjqX.js → chunk-2Q5K7J3B-ur9OqjPn.js} +1 -1
  169. package/dist/worker/console/static/assets/{chunk-5RXB4S5H-Bzbj3zGH.js → chunk-5RXB4S5H-D1KqU_Vi.js} +1 -1
  170. package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BT415PvT.js → chunk-5VM5RSS4-BlVZrbtM.js} +1 -1
  171. package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-D_A5_5QL.js → chunk-6Q2QTUOP-BAzz3nQy.js} +1 -1
  172. package/dist/worker/console/static/assets/{chunk-GF5L2VYU-srJkaP3f.js → chunk-GF5L2VYU-CP_nYuCV.js} +1 -1
  173. package/dist/worker/console/static/assets/{chunk-JWPE2WC7-UYGvEP4l.js → chunk-JWPE2WC7-CWvKQ80X.js} +1 -1
  174. package/dist/worker/console/static/assets/{chunk-KBJHAD2P-B8luBrrz.js → chunk-KBJHAD2P-CyUki8wp.js} +1 -1
  175. package/dist/worker/console/static/assets/{chunk-RYQCIY6F-DN7wXZSq.js → chunk-RYQCIY6F-5NYzNKfY.js} +1 -1
  176. package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DXKyMuKS.js → chunk-XXDRQBXY-DHdUgjS-.js} +1 -1
  177. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +1 -0
  178. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +1 -0
  179. package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-dqvoynXj.js → cose-bilkent-JH36ORCC-ANQ5g_t6.js} +1 -1
  180. package/dist/worker/console/static/assets/{cynefin-VYW2F7L2--PcyL34A.js → cynefin-VYW2F7L2-CruT_4-0.js} +1 -1
  181. package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-DvWs_hTY.js → cynefinDiagram-MW4NZA55-rbFo77ID.js} +1 -1
  182. package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-DxeIxbyO.js → dagre-VZM6K2ZE-asstxBQs.js} +1 -1
  183. package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DPCG61Of.js → diagram-7IWD3JNH-DzTyBZwI.js} +1 -1
  184. package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-CmuU50-U.js → diagram-B4RE2ZJO-gw8ccH3B.js} +1 -1
  185. package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B61XLD_v.js → diagram-LBJQPF4R-B8RpZzOf.js} +1 -1
  186. package/dist/worker/console/static/assets/{diagram-Q27KOJAE-BB7HTRRY.js → diagram-Q27KOJAE-B1zJkCS9.js} +1 -1
  187. package/dist/worker/console/static/assets/{diagram-UB23O5K3-DvkboAIp.js → diagram-UB23O5K3-B6JLWZmO.js} +1 -1
  188. package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BdJ_y1fL.js → ebnfDiagram-BXEA7PRR-q2iZP-Ps.js} +1 -1
  189. package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-9bUBZTRi.js → erDiagram-JOGREHBK-B3dbbktQ.js} +1 -1
  190. package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-Dw4L4RBa.js → flowDiagram-UKHOOZJN-C-zc6-kB.js} +1 -1
  191. package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Jr82N_QP.js → ganttDiagram-PKOTCBZU-BSolnot9.js} +1 -1
  192. package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-DAz9wFLr.js → gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js} +1 -1
  193. package/dist/worker/console/static/assets/index-CAZ2fC_X.css +1 -0
  194. package/dist/worker/console/static/assets/index-DhfjOafu.js +449 -0
  195. package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-CBB5Np7y.js → infoDiagram-6WML65LV-DQaZqJOH.js} +1 -1
  196. package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-D8IOp94y.js → ishikawaDiagram-WSZJBQD7-DsdX1WnE.js} +1 -1
  197. package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-Dgd3AHGG.js → journeyDiagram-NVQOT4AX-CP5EYDZL.js} +1 -1
  198. package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-BmYOxLE9.js → kanban-definition-27J2QSJJ-DAm14Dr8.js} +1 -1
  199. package/dist/worker/console/static/assets/{linear-DfYTEF6J.js → linear-gZECoLc5.js} +1 -1
  200. package/dist/worker/console/static/assets/{mermaid.core-BjuFPRqa.js → mermaid.core-BRJNIM6p.js} +5 -5
  201. package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-CLyUViGd.js → mindmap-definition-FAOFIHXS-Cja3kLkR.js} +1 -1
  202. package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-BvX2Di4-.js → pegDiagram-VL7TDLO6-22ZGFisL.js} +1 -1
  203. package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BFj0_OLv.js → pieDiagram-7S7Q4E2Y-BXin0Y1o.js} +1 -1
  204. package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BIUrD_hx.js → quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js} +1 -1
  205. package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-CHBB48fj.js → railroadDiagram-AXF67PYL-C1-gTieN.js} +1 -1
  206. package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-sJrYw2Sf.js → requirementDiagram-LRYGKXZP--H5N2iI1.js} +1 -1
  207. package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-BzHH6fPR.js → sankeyDiagram-W5VNT64P-CgWAPeRz.js} +1 -1
  208. package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-7QCnelCt.js → sequenceDiagram-SI44F4Z6-CrKqzGvt.js} +1 -1
  209. package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-sDYSxn72.js → sizeCapture-X5ZJPWSS-BB3wG06K.js} +1 -1
  210. package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-XpiUdwzm.js → stateDiagram-OKZ733FA-DjsGgdgY.js} +1 -1
  211. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +1 -0
  212. package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DvqgNPzD.js → swimlanes-SLNWSIFB-DYKEbvAR.js} +2 -2
  213. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +8 -0
  214. package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-2TyOYNx0.js → timeline-definition-Z64GVDOM-eQOb5k9Y.js} +1 -1
  215. package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B-nM6wM2.js → vennDiagram-T6HMQDX7-B2-l9FIu.js} +1 -1
  216. package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-B86wPdbr.js → wardleyDiagram-T6FBY63Y-BX2Cda3l.js} +1 -1
  217. package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-Dr1C4AQz.js → xychartDiagram-ELKLHX3M-D9S892ph.js} +1 -1
  218. package/dist/worker/console/static/index.html +7 -2
  219. package/dist/worker/console/static-src/active-run-badge.js +17 -0
  220. package/dist/worker/console/static-src/app/console-types.js +68 -4
  221. package/dist/worker/console/static-src/app/useConsoleShell.js +30 -12
  222. package/dist/worker/console/static-src/app/useOperatorActions.js +43 -7
  223. package/dist/worker/console/static-src/app/useRecoveryActions.js +2 -2
  224. package/dist/worker/console/static-src/app/useRecoveryConsole.js +45 -10
  225. package/dist/worker/console/static-src/app/useRunProgress.js +54 -0
  226. package/dist/worker/console/static-src/app/useTaskWizard.js +74 -2
  227. package/dist/worker/console/static-src/night/useNightBoard.js +8 -5
  228. package/dist/worker/console/static-src/operator-chat/cards/failure-category-advice.js +25 -0
  229. package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +264 -13
  230. package/dist/worker/console/static-src/operator-chat/compaction-message.js +113 -0
  231. package/dist/worker/console/static-src/operator-chat/dag-progress-link.js +22 -0
  232. package/dist/worker/console/static-src/operator-chat/details-dag-actions.js +122 -0
  233. package/dist/worker/console/static-src/operator-chat/input-history.js +78 -0
  234. package/dist/worker/console/static-src/operator-chat/mutation-gate.js +1 -1
  235. package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +338 -0
  236. package/dist/worker/console/static-src/operator-chat/refs.js +3 -0
  237. package/dist/worker/console/static-src/operator-chat/runtime-selection-labels.js +27 -0
  238. package/dist/worker/console/static-src/operator-chat/runtime-snapshot-store.js +10 -0
  239. package/dist/worker/console/static-src/operator-chat/spatial-overlay.js +1 -2
  240. package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +33 -1
  241. package/dist/worker/console/static-src/operator-chat/turn-submission.js +55 -0
  242. package/dist/worker/console/static-src/operator-chat/useChatSessions.js +448 -109
  243. package/dist/worker/console/static-src/operator-chat/useChatStream.js +344 -27
  244. package/dist/worker/console/static-src/operator-chat/useChatThread.js +323 -11
  245. package/dist/worker/console/static-src/operator-chat/useComposer.js +45 -4
  246. package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +97 -13
  247. package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +57 -9
  248. package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +8 -2
  249. package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
  250. package/dist/worker/console/static-src/operator-chat/workspace-layout-mode.js +3 -3
  251. package/dist/worker/console/static-src/operator-chat/workspace-reorder.js +18 -0
  252. package/dist/worker/console/static-src/pages/tasks/run-id-resolution.js +79 -0
  253. package/dist/worker/console/static-src/pages/tasks/run-ownership-verify.js +23 -0
  254. package/dist/worker/console/static-src/pages/tasks/run-panel-progress.js +216 -0
  255. package/dist/worker/console/static-src/shell/console-update-reload.js +52 -0
  256. package/dist/worker/console/static-src/shell/useWorkspaces.js +415 -0
  257. package/dist/worker/console/static-src/shell/workspace-route.js +356 -0
  258. package/dist/worker/console/workspace-context.js +399 -0
  259. package/dist/worker/console/workspace-registry.js +487 -0
  260. package/dist/worker/continuation/worker-continuation.js +278 -0
  261. package/dist/worker/loop-agent/loop-agent-client.js +7 -3
  262. package/dist/worker/materialize/frontend-split-task-materializer.js +72 -0
  263. package/dist/worker/materialize/harness-task-lineage.js +5 -2
  264. package/dist/worker/observability/init-runtime-activity.js +26 -0
  265. package/dist/worker/observability/read-model.js +26 -0
  266. package/dist/worker/observe/health.js +1 -1
  267. package/dist/worker/observe/node-input.js +160 -3
  268. package/dist/worker/observe/node-process.js +377 -0
  269. package/dist/worker/observe/node-transparency.js +572 -0
  270. package/dist/worker/observe/routes.js +278 -3
  271. package/dist/worker/observe/server.js +4 -0
  272. package/dist/worker/observe/shell-handler-keys.js +34 -0
  273. package/dist/worker/observe/static/api.js +154 -4
  274. package/dist/worker/observe/static/app.js +18 -70
  275. package/dist/worker/observe/static/constants.js +26 -19
  276. package/dist/worker/observe/static/dag-context-reason-labels.d.ts +9 -0
  277. package/dist/worker/observe/static/dag-context-reason-labels.js +139 -0
  278. package/dist/worker/observe/static/dag-helpers.js +4 -2
  279. package/dist/worker/observe/static/dag-history-labels.js +5 -0
  280. package/dist/worker/observe/static/dag-inspector-humanize.d.ts +16 -0
  281. package/dist/worker/observe/static/dag-inspector-humanize.js +339 -0
  282. package/dist/worker/observe/static/dag-node-purpose.d.ts +6 -0
  283. package/dist/worker/observe/static/dag-node-purpose.js +208 -0
  284. package/dist/worker/observe/static/format.js +60 -0
  285. package/dist/worker/observe/static/index.html +10 -5
  286. package/dist/worker/observe/static/inspect-bootstrap.d.ts +8 -0
  287. package/dist/worker/observe/static/inspect-bootstrap.js +57 -0
  288. package/dist/worker/observe/static/inspect-workspace.js +374 -0
  289. package/dist/worker/observe/static/kpi.js +2 -2
  290. package/dist/worker/observe/static/markdown-render.js +20 -1
  291. package/dist/worker/observe/static/operator-chrome.css +168 -24
  292. package/dist/worker/observe/static/operator-chrome.d.ts +30 -5
  293. package/dist/worker/observe/static/operator-chrome.js +354 -101
  294. package/dist/worker/observe/static/prompt-restart-candidates.d.ts +18 -0
  295. package/dist/worker/observe/static/prompt-restart-candidates.js +38 -0
  296. package/dist/worker/observe/static/relations.js +7 -7
  297. package/dist/worker/observe/static/router.d.ts +57 -0
  298. package/dist/worker/observe/static/router.js +67 -1
  299. package/dist/worker/observe/static/run-processing.js +4 -2
  300. package/dist/worker/observe/static/shell-chrome.js +2 -2
  301. package/dist/worker/observe/static/state.d.ts +50 -0
  302. package/dist/worker/observe/static/state.js +191 -1
  303. package/dist/worker/observe/static/styles.css +1720 -86
  304. package/dist/worker/observe/static/views/dag-graph.js +5 -3
  305. package/dist/worker/observe/static/views/dag-inspector.js +2601 -188
  306. package/dist/worker/observe/static/views/dag.d.ts +13 -0
  307. package/dist/worker/observe/static/views/dag.js +39 -18
  308. package/dist/worker/observe/static/views/dags.js +10 -6
  309. package/dist/worker/observe/static/views/dashboard.js +18 -8
  310. package/dist/worker/observe/static/views/failures.js +5 -2
  311. package/dist/worker/observe/static/views/night.js +2 -2
  312. package/dist/worker/observe/static/views/pool.js +8 -2
  313. package/dist/worker/observe/static/views/run.js +15 -4
  314. package/dist/worker/observe/static/views/session-timeline.js +386 -25
  315. package/dist/worker/observe/static/views/task.js +63 -3
  316. package/dist/worker/outcomes/adapters.js +19 -0
  317. package/dist/worker/outcomes/types.js +1 -0
  318. package/dist/worker/pool/attempt-lease.js +97 -66
  319. package/dist/worker/pool/begin-attempt-with-lease.js +1 -0
  320. package/dist/worker/pool/reconcile.js +46 -1
  321. package/dist/worker/pool/run-store.js +2 -0
  322. package/dist/worker/pool/state-projection.js +2 -0
  323. package/dist/worker/task-spec/workflow-routing.js +8 -3
  324. package/dist/workflows/dag/artifact-bindings.js +149 -0
  325. package/dist/workflows/dag/artifact-revision-schema-registry.js +31 -0
  326. package/dist/workflows/dag/backend-test-case-coverage-analysis.js +470 -31
  327. package/dist/workflows/dag/backend-test-markdown-workflow.js +189 -2
  328. package/dist/workflows/dag/backend-test-plan-protocol.js +210 -0
  329. package/dist/workflows/dag/backend-test-pytest-collection.js +168 -16
  330. package/dist/workflows/dag/backend-test-result-contract.js +5 -1
  331. package/dist/workflows/dag/backend-test-scenario-param.js +506 -73
  332. package/dist/workflows/dag/backend-test-scenario-partitions.js +135 -2
  333. package/dist/workflows/dag/backend-test-writer-completeness.js +131 -28
  334. package/dist/workflows/dag/budget-enforcement.js +10 -0
  335. package/dist/workflows/dag/context-receipt.js +305 -0
  336. package/dist/workflows/dag/context-transfer/context-bundle.js +423 -0
  337. package/dist/workflows/dag/context-transfer/operator-actions.js +61 -0
  338. package/dist/workflows/dag/context-transfer/renderers.js +93 -0
  339. package/dist/workflows/dag/contract-output-registry.js +15 -0
  340. package/dist/workflows/dag/contract-validator-registrations.js +1 -2
  341. package/dist/workflows/dag/convergence/controller.js +141 -0
  342. package/dist/workflows/dag/dag-retry-schema.js +138 -0
  343. package/dist/workflows/dag/dynamic-runtime/loop-until.js +1 -1
  344. package/dist/workflows/dag/dynamic-runtime/map.js +17 -3
  345. package/dist/workflows/dag/failure-category.js +7 -116
  346. package/dist/workflows/dag/frontend-closeout.js +221 -0
  347. package/dist/workflows/dag/frontend-design-policy.js +400 -0
  348. package/dist/workflows/dag/frontend-human-decision.js +182 -0
  349. package/dist/workflows/dag/frontend-implementation-contract.js +1377 -141
  350. package/dist/workflows/dag/frontend-plan-render.js +26 -1
  351. package/dist/workflows/dag/frontend-prewrite-gate.js +376 -318
  352. package/dist/workflows/dag/frontend-provider-capability-matrix.js +159 -0
  353. package/dist/workflows/dag/frontend-recovery-capsule.js +455 -0
  354. package/dist/workflows/dag/frontend-recovery-controller.js +226 -0
  355. package/dist/workflows/dag/frontend-recovery-lineage.js +178 -0
  356. package/dist/workflows/dag/frontend-recovery-plan.js +21 -10
  357. package/dist/workflows/dag/frontend-recovery-run.js +166 -34
  358. package/dist/workflows/dag/frontend-repair.js +7 -424
  359. package/dist/workflows/dag/frontend-review-context.js +348 -20
  360. package/dist/workflows/dag/frontend-review-findings.js +270 -0
  361. package/dist/workflows/dag/frontend-risk.js +15 -2
  362. package/dist/workflows/dag/frontend-shadow-dual-write.js +941 -0
  363. package/dist/workflows/dag/frontend-shape-capsule-store.js +191 -0
  364. package/dist/workflows/dag/frontend-shape-facts.js +419 -0
  365. package/dist/workflows/dag/frontend-shape.js +435 -0
  366. package/dist/workflows/dag/frontend-source-fidelity-ledger.js +108 -0
  367. package/dist/workflows/dag/frontend-split-application-service.js +203 -0
  368. package/dist/workflows/dag/frontend-split-orchestrator.js +899 -0
  369. package/dist/workflows/dag/frontend-test-case-checklist.js +32 -4
  370. package/dist/workflows/dag/frontend-test-case-generation-assessment.js +69 -0
  371. package/dist/workflows/dag/frontend-test-case-manifest.js +17 -5
  372. package/dist/workflows/dag/frontend-test-case-quality.js +11 -16
  373. package/dist/workflows/dag/frontend-test-environment-probe.js +230 -0
  374. package/dist/workflows/dag/frontend-test-html-report.js +3 -1
  375. package/dist/workflows/dag/frontend-test-l5-report.js +3 -1
  376. package/dist/workflows/dag/frontend-test-layout.js +159 -0
  377. package/dist/workflows/dag/frontend-test-markdown.js +61 -0
  378. package/dist/workflows/dag/frontend-test-result-contract.js +202 -42
  379. package/dist/workflows/dag/frontend-test-standard-scenarios.js +70 -0
  380. package/dist/workflows/dag/frontend-typed-event-store.js +452 -0
  381. package/dist/workflows/dag/frontend-typed-event-transaction.js +180 -0
  382. package/dist/workflows/dag/frontend-verification-trace.js +281 -29
  383. package/dist/workflows/dag/frontend-worktree-diff.js +250 -17
  384. package/dist/workflows/dag/frontend-writer-admission.js +319 -0
  385. package/dist/workflows/dag/frontend-writer-rollback.js +32 -0
  386. package/dist/workflows/dag/frontend-writer-status.js +256 -0
  387. package/dist/workflows/dag/init-hybrid.js +1771 -717
  388. package/dist/workflows/dag/interrupt-request.js +10 -3
  389. package/dist/workflows/dag/lifecycle.js +3 -3
  390. package/dist/workflows/dag/node-execution.js +1141 -32
  391. package/dist/workflows/dag/path-safety.js +1 -0
  392. package/dist/workflows/dag/prompt.js +158 -7
  393. package/dist/workflows/dag/recovery-lease.js +170 -0
  394. package/dist/workflows/dag/report.js +37 -1
  395. package/dist/workflows/dag/rerun-feedback.js +526 -0
  396. package/dist/workflows/dag/rerun-plan.js +790 -28
  397. package/dist/workflows/dag/rerun-run.js +700 -21
  398. package/dist/workflows/dag/rerun-task.js +311 -14
  399. package/dist/workflows/dag/retry-policy.js +336 -101
  400. package/dist/workflows/dag/runner.js +596 -121
  401. package/dist/workflows/dag/scheduler.js +133 -20
  402. package/dist/workflows/dag/skill-snapshot.js +17 -0
  403. package/dist/workflows/dag/structured-output-repair.js +712 -0
  404. package/dist/workflows/dag/types.js +600 -31
  405. package/dist/workflows/dag/validate.js +92 -32
  406. package/docs/README.md +2 -0
  407. package/docs/architecture/evolution.md +45 -0
  408. package/docs/architecture/runtime-boundaries.md +8 -7
  409. package/docs/architecture/worker-and-feature.md +1 -1
  410. package/docs/examples/README.md +5 -0
  411. package/docs/init-surface.manifest.json +36 -12
  412. package/docs/operations/README.md +1 -1
  413. package/docs/operations/local-development-environment.md +22 -5
  414. package/docs/skills/vetted-skill-registry.md +16 -0
  415. package/docs/templates/README.md +4 -2
  416. package/docs/templates/agent-dag-report.schema.json +8 -2
  417. package/docs/templates/agent-dag.schema.json +95 -1
  418. package/docs/templates/backend-test-dag.json +278 -244
  419. package/docs/templates/frontend-implementation-contract.schema.json +684 -24
  420. package/docs/templates/frontend-implementation-dag.json +89 -0
  421. package/docs/templates/frontend-test-case-checklist.md +2 -2
  422. package/docs/templates/frontend-test-dag.json +10 -12
  423. package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +1 -1
  424. package/docs/templates/init-managed-agents.md +13 -3
  425. package/docs/templates/product-line/task.yaml +1 -1
  426. package/docs/templates/spec-registry.schema.json +45 -0
  427. package/harness.json +2 -2
  428. package/package.json +19 -5
  429. package/scripts/next-info.mjs +356 -0
  430. package/scripts/next-publish-gate.mjs +238 -0
  431. package/scripts/release-source-binding.mjs +251 -0
  432. package/skills/analyze-product-requirements/SKILL.md +8 -5
  433. package/skills/analyze-product-requirements/references/acceptance-criteria.md +1 -1
  434. package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +10 -6
  435. package/skills/analyze-product-requirements/references/example.md +50 -0
  436. package/skills/analyze-product-requirements/references/forward-test-cases.md +11 -7
  437. package/skills/analyze-product-requirements/references/kb-integration.md +5 -5
  438. package/skills/analyze-product-requirements/references/product-analysis-schema.md +8 -4
  439. package/skills/analyze-product-requirements/references/product-requirement-schema.md +2 -2
  440. package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +1 -1
  441. package/skills/analyze-product-requirements/scripts/test-validators.mjs +11 -1
  442. package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +20 -1
  443. package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +9 -0
  444. package/skills/codebase-scout/SKILL.md +1 -1
  445. package/skills/fe-test-ui-scout/SKILL.md +65 -0
  446. package/skills/fe-test-ui-scout/references/ledger-schema.md +62 -0
  447. package/skills/fe-test-ui-scout/references/recon-protocol.md +54 -0
  448. package/skills/frontend-bounded-implement/SKILL.md +15 -14
  449. package/skills/frontend-bounded-implement/references/code-standards.md +19 -0
  450. package/skills/frontend-contract/SKILL.md +23 -0
  451. package/skills/frontend-contract/references/contract-protocol.md +34 -0
  452. package/skills/frontend-design-review/SKILL.md +22 -41
  453. package/skills/frontend-plan/SKILL.md +26 -0
  454. package/skills/frontend-plan/references/decision-contract.md +37 -0
  455. package/skills/frontend-plan/references/design-decisions.md +17 -0
  456. package/skills/frontend-review/SKILL.md +20 -15
  457. package/skills/frontend-review/references/review-findings.md +6 -7
  458. package/skills/frontend-scout/SKILL.md +25 -0
  459. package/skills/frontend-scout/references/design-evidence.md +16 -0
  460. package/skills/frontend-scout/references/scout-evidence.md +23 -0
  461. package/skills/frontend-verification/SKILL.md +1 -1
  462. package/skills/improve-codebase-architecture/SKILL.md +81 -0
  463. package/skills/improve-codebase-architecture/deepening.md +37 -0
  464. package/skills/improve-codebase-architecture/html-report.md +123 -0
  465. package/skills/improve-codebase-architecture/interface-design.md +44 -0
  466. package/skills/improve-codebase-architecture/language.md +53 -0
  467. package/skills/loop-agent/references/command-reference.md +32 -4
  468. package/skills/loop-agent/references/hybrid-dag.md +9 -2
  469. package/skills/playwright-cli/SKILL.md +23 -1
  470. package/skills/playwright-cli-case-generator/SKILL.md +50 -13
  471. package/dist/worker/console/operation-store.js +0 -169
  472. package/dist/worker/console/static/assets/channel-Tl-FkUqr.js +0 -1
  473. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BaehtRk4.js +0 -1
  474. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BaehtRk4.js +0 -1
  475. package/dist/worker/console/static/assets/index-B7Y-0g3J.css +0 -1
  476. package/dist/worker/console/static/assets/index-DkCrqaYg.js +0 -325
  477. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-eEhq2A8Y.js +0 -1
  478. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-la8AC7fo.js +0 -8
  479. package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +0 -73
  480. package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +0 -59
  481. package/skills/frontend-implementation/SKILL.md +0 -52
  482. package/skills/frontend-implementation/references/code-standards.md +0 -33
  483. package/skills/frontend-implementation/references/design-spec.md +0 -56
  484. package/skills/frontend-implementation/references/node-contracts.md +0 -31
  485. /package/dist/{worker → infrastructure}/console/repo-fingerprint.js +0 -0
@@ -1,8 +1,13 @@
1
1
  import { z } from "zod";
2
- import { isOpenspecSpecFilePath } from "../../shared/openspec-spec.js";
2
+ import { DEFAULT_FRONTEND_SPEC_ROOTS, isFrontendSpecFilePath, isValidFrontendSpecRoot, OPENSPEC_SPEC_EXT_RE, } from "../../shared/openspec-spec.js";
3
3
  import { campaignBudgetSchema, } from "../../application/evaluation/budget.js";
4
4
  import { assertDagPromptSourceRule } from "./prompt-source.js";
5
- import { dagRetryPolicySchema } from "./retry-policy.js";
5
+ // Leaf-module import: dagRetryPolicySchema must be defined by a module that
6
+ // never transitively reaches types.ts during init (retry-policy does, via
7
+ // frontend-recovery-capsule → frontend-recovery-lineage →
8
+ // frontend-implementation-contract), or a run whose entry module initializes
9
+ // retry-policy first reads an undefined schema here.
10
+ import { dagRetryPolicySchema, TARGET_TEMPLATE_TRANSIENT_RETRY_PROFILE, } from "./dag-retry-schema.js";
6
11
  import { dagLivenessPolicySchema, } from "./liveness-policy.js";
7
12
  import { dagOutputProtocolSchema } from "./output-protocol.js";
8
13
  export const dagComplexitySchema = z.enum(["HIGH", "MED", "LOW"]);
@@ -10,6 +15,18 @@ export const dagNodeExecutorSchema = z.enum(["pi", "shell", "static"]);
10
15
  export const CURSOR_DAG_EXECUTOR_REMOVED_ERROR = 'executor "cursor" is no longer supported; regenerate the DAG with Pi-only writers (implement-pi / repair-pi)';
11
16
  export const CURSOR_EXECUTOR_MODELS_REMOVED_ERROR = "executorModels.cursor is no longer supported; use executorModels.pi only";
12
17
  export const dagToolProfileSchema = z.enum(["read-only", "write"]);
18
+ /**
19
+ * Frozen Pi extension short ids for backend implementation DAGs (plan
20
+ * 2026-08-21 D2): the DAG carries only these ids; the executor resolves them
21
+ * against the Pi settings package inventory at run time. Adding a package
22
+ * requires changing this enum and the plan.
23
+ */
24
+ export const dagPiExtensionIdSchema = z.enum(["pi-codegraph", "pi-lens"]);
25
+ /** Node-level explicit Pi extension allowlist (omitted = all off, R8.1). */
26
+ export const dagPiExtensionsSchema = z
27
+ .array(dagPiExtensionIdSchema)
28
+ .min(1)
29
+ .transform((ids) => Array.from(new Set(ids)));
13
30
  /** Static command capabilities only; tasks cannot inject executables or shell prefixes. */
14
31
  export const dagCommandCapabilitySchema = z.enum(["playwright-cli"]);
15
32
  export const dagCommandPolicySchema = z.discriminatedUnion("mode", [
@@ -68,7 +85,10 @@ export const dagShellVerifyEvidenceSchema = z.object({
68
85
  selectionReasons: z.array(z.string()).default([]),
69
86
  /** Non-executing generation-time cwd/local-script validation evidence. */
70
87
  preflight: z
71
- .array(z.object({ label: z.string(), status: z.enum(["ok", "future-delivery-script"]) }))
88
+ .array(z.object({
89
+ label: z.string(),
90
+ status: z.enum(["ok", "future-delivery-script", "future-test-target"]),
91
+ }))
72
92
  .default([]),
73
93
  /** Effective timeout applied independently to each shell command. */
74
94
  commandTimeoutMs: z.number().int().positive().optional(),
@@ -173,7 +193,16 @@ const dagFrontendNodeIdSchema = z
173
193
  .regex(/^[a-z][a-z0-9-]*$/, "frontend node id must be kebab-case");
174
194
  const openspecCandidatePathSchema = z
175
195
  .string()
176
- .refine((candidate) => !candidate.includes("\\") && isOpenspecSpecFilePath(candidate), "openspec candidate must be a repo-relative supported file under openspec/schemas/, openspec/project-specs/, or ai_workspace/");
196
+ .refine((candidate) => !candidate.includes("\\") &&
197
+ !candidate.startsWith("/") &&
198
+ !candidate.split("/").includes("..") &&
199
+ OPENSPEC_SPEC_EXT_RE.test(candidate), "openspec candidate must be a repo-relative supported specification file");
200
+ const openspecCandidateSnapshotSchema = z
201
+ .object({
202
+ path: openspecCandidatePathSchema,
203
+ sha256: z.string().regex(/^[a-f0-9]{64}$/),
204
+ })
205
+ .strict();
177
206
  export const dagFrontendPrewriteGateSchema = z.object({
178
207
  schemaVersion: z.literal(1),
179
208
  planFromNodeId: dagFrontendNodeIdSchema,
@@ -192,7 +221,24 @@ export const dagFrontendPrewriteGateSchema = z.object({
192
221
  outputDir: z.string().regex(/^[a-z0-9][a-z0-9._-]*$/),
193
222
  requireSourceFreshness: z.literal(true),
194
223
  implementationWriteSet: z.array(z.string().min(1)).min(1).optional(),
224
+ /**
225
+ * Generation-frozen roots that bound custom normative directories. Omitted
226
+ * legacy DAGs retain the canonical OpenSpec + ai_workspace roots.
227
+ */
228
+ openspecSpecRoots: z
229
+ .array(z.string().refine((root) => isValidFrontendSpecRoot(root), "openspec spec root must be a normalized repo-relative directory"))
230
+ .optional(),
195
231
  openspecCandidatePaths: z.array(openspecCandidatePathSchema).default([]),
232
+ /** Read-only selector output; omitted for scan-strict and legacy DAGs. */
233
+ openspecSelectionNodeId: dagFrontendNodeIdSchema.optional(),
234
+ /** Contract-declared and source-explicit paths that cannot be downgraded. */
235
+ openspecMandatoryPaths: z.array(openspecCandidatePathSchema).optional(),
236
+ /**
237
+ * Content fingerprints frozen with the generation-time OpenSpec scope. New
238
+ * DAGs use these to reject a plan whose cited specification changed after it
239
+ * was read; legacy DAGs without the field retain existence-only drift checks.
240
+ */
241
+ openspecCandidateSnapshots: z.array(openspecCandidateSnapshotSchema).optional(),
196
242
  /**
197
243
  * Generation-frozen component/theme specification bucket. Derived from
198
244
  * `designEvidence.classified.component ∪ theme ∪ rule.components` at DAG
@@ -237,14 +283,28 @@ export const dagFrontendPrewriteGateSchema = z.object({
237
283
  scanStrict: z.array(openspecCandidatePathSchema).default([]),
238
284
  })
239
285
  .optional(),
286
+ }).superRefine((gate, context) => {
287
+ const roots = gate.openspecSpecRoots ?? DEFAULT_FRONTEND_SPEC_ROOTS;
288
+ const candidateGroups = [
289
+ ["openspecCandidatePaths", gate.openspecCandidatePaths],
290
+ ["openspecMandatoryPaths", gate.openspecMandatoryPaths],
291
+ ["componentSpecCandidatePaths", gate.componentSpecCandidatePaths],
292
+ ["openspecCandidateSources.declared", gate.openspecCandidateSources?.declared],
293
+ ["openspecCandidateSources.taskSourceCited", gate.openspecCandidateSources?.taskSourceCited],
294
+ ["openspecCandidateSources.scanStrict", gate.openspecCandidateSources?.scanStrict],
295
+ ];
296
+ for (const [field, paths] of candidateGroups) {
297
+ for (const [index, candidate] of (paths ?? []).entries()) {
298
+ if (!isFrontendSpecFilePath(candidate, roots)) {
299
+ context.addIssue({
300
+ code: z.ZodIssueCode.custom,
301
+ path: [...field.split("."), index],
302
+ message: "openspec candidate must be a supported file under the generation-frozen openspec spec roots",
303
+ });
304
+ }
305
+ }
306
+ }
240
307
  });
241
- export const dagFrontendLintBaselineSchema = z
242
- .object({
243
- schemaVersion: z.literal(1),
244
- lintCommands: z.array(z.string().min(1)).min(1),
245
- lintEvidence: dagShellVerifyEvidenceSchema,
246
- })
247
- .strict();
248
308
  export const dagFrontendVerificationBundleSchema = z
249
309
  .object({
250
310
  schemaVersion: z.literal(1),
@@ -258,6 +318,10 @@ export const dagFrontendVerificationBundleSchema = z
258
318
  behaviorEvidence: dagShellVerifyEvidenceSchema,
259
319
  lintBaselineNodeId: dagFrontendNodeIdSchema.optional(),
260
320
  writerNodeIds: z.array(dagFrontendNodeIdSchema).optional(),
321
+ /** "initial" = first-pass assess bundle; "repair" = the convergence
322
+ * loop's post-repair reverify, which re-runs the same frozen commands
323
+ * and fails on any failure (still no same-run repair branch inside the
324
+ * node itself). */
261
325
  mode: z.enum(["initial", "repair"]),
262
326
  })
263
327
  .superRefine((bundle, context) => {
@@ -333,6 +397,135 @@ export const dagFrontendReviewContextSchema = z.object({
333
397
  schemaVersion: z.literal(1),
334
398
  requireBaseline: z.literal(true),
335
399
  });
400
+ /**
401
+ * Deterministic frontend contract-import shell (micro topology). Re-validates
402
+ * the generation-frozen managed Contract's source/binding/schema freshness and
403
+ * emits a digest. It never invokes a model and never rewrites requirements —
404
+ * micro requires a pre-validated managed Contract, not natural-language intake.
405
+ */
406
+ export const dagFrontendContractImportSchema = z.object({
407
+ schemaVersion: z.literal(1),
408
+ artifactName: z.string().regex(/^[a-z0-9][a-z0-9._-]*\.json$/),
409
+ outputDir: z.string().regex(/^[a-z0-9][a-z0-9._-]*$/),
410
+ requireSourceFreshness: z.literal(true),
411
+ });
412
+ /**
413
+ * Deterministic frontend design-policy shell (M8). Materializes the canonical
414
+ * implementation contract from the plan node and evaluates the design policy
415
+ * (Mock strategy, source freshness, component spec candidates, writeSet
416
+ * patterns, allowed dependencies). Runs BEFORE frontend-design-review-pi, so it
417
+ * never consumes a design verdict; the verdict is enforced by the writer
418
+ * admission shell instead. Replaces the prewrite-gate authorization path.
419
+ */
420
+ export const dagFrontendDesignPolicySchema = z
421
+ .object({
422
+ schemaVersion: z.literal(1),
423
+ planFromNodeId: dagFrontendNodeIdSchema,
424
+ requiredRequirementIds: z
425
+ .array(z.string().regex(/^(?:REQ|BR|AC)-[A-Z0-9]+(?:-[A-Z0-9]+)*$/))
426
+ .default([]),
427
+ allowedMockStrategies: z
428
+ .array(z.enum(["native", "browser-intercept", "request-adapter", "not-needed"]))
429
+ .min(1),
430
+ /** Frozen Mock verification command labels the DAG will actually execute. */
431
+ mockCommandLabels: z.array(z.string()).default([]),
432
+ artifactName: z.string().regex(/^[a-z0-9][a-z0-9._-]*\.json$/),
433
+ outputDir: z.string().regex(/^[a-z0-9][a-z0-9._-]*$/),
434
+ requireSourceFreshness: z.literal(true),
435
+ implementationWriteSet: z.array(z.string().min(1)).min(1).optional(),
436
+ /** Generation-frozen roots that bound custom normative directories. */
437
+ openspecSpecRoots: z
438
+ .array(z.string().refine((root) => isValidFrontendSpecRoot(root), "openspec spec root must be a normalized repo-relative directory"))
439
+ .optional(),
440
+ openspecCandidatePaths: z.array(openspecCandidatePathSchema).default([]),
441
+ /** Read-only selector output; omitted for scan-strict and legacy DAGs. */
442
+ openspecSelectionNodeId: dagFrontendNodeIdSchema.optional(),
443
+ /** Contract-declared and source-explicit paths that cannot be downgraded. */
444
+ openspecMandatoryPaths: z.array(openspecCandidatePathSchema).optional(),
445
+ openspecCandidateSnapshots: z
446
+ .array(openspecCandidateSnapshotSchema)
447
+ .optional(),
448
+ /**
449
+ * Generation-frozen component/theme specification bucket. Derived from
450
+ * `designEvidence.classified.component ∪ theme ∪ rule.components` at DAG
451
+ * generation. When non-empty and the canonical contract has UI-visible
452
+ * work, the design policy requires a non-empty `uiComponentChoices` and
453
+ * cross-checks each `specReference.path` against this set + the effective
454
+ * plan openspec-citations block.
455
+ */
456
+ componentSpecCandidatePaths: z.array(openspecCandidatePathSchema).optional(),
457
+ /** OpenSpec gate policy (cited | scan-strict); generation always writes it. */
458
+ openspecPolicy: z.enum(["cited", "scan-strict"]).optional(),
459
+ /** Generation-frozen candidate source metadata (diagnostic). */
460
+ openspecCandidateSources: z
461
+ .object({
462
+ declared: z.array(openspecCandidatePathSchema).default([]),
463
+ taskSourceCited: z.array(openspecCandidatePathSchema).default([]),
464
+ scanStrict: z.array(openspecCandidatePathSchema).default([]),
465
+ })
466
+ .optional(),
467
+ /** Dependency identifiers authorized at generation time (empty = none). */
468
+ allowedDependencies: z.array(z.string()).default([]),
469
+ })
470
+ .superRefine((gate, context) => {
471
+ const roots = gate.openspecSpecRoots ?? DEFAULT_FRONTEND_SPEC_ROOTS;
472
+ const candidateGroups = [
473
+ ["openspecCandidatePaths", gate.openspecCandidatePaths],
474
+ ["openspecMandatoryPaths", gate.openspecMandatoryPaths],
475
+ ["componentSpecCandidatePaths", gate.componentSpecCandidatePaths],
476
+ ["openspecCandidateSources.declared", gate.openspecCandidateSources?.declared],
477
+ ["openspecCandidateSources.taskSourceCited", gate.openspecCandidateSources?.taskSourceCited],
478
+ ["openspecCandidateSources.scanStrict", gate.openspecCandidateSources?.scanStrict],
479
+ ];
480
+ for (const [field, paths] of candidateGroups) {
481
+ for (const [index, candidate] of (paths ?? []).entries()) {
482
+ if (!isFrontendSpecFilePath(candidate, roots)) {
483
+ context.addIssue({
484
+ code: z.ZodIssueCode.custom,
485
+ path: [...field.split("."), index],
486
+ message: "openspec candidate must be a supported file under the generation-frozen openspec spec roots",
487
+ });
488
+ }
489
+ }
490
+ }
491
+ });
492
+ /**
493
+ * Deterministic frontend writer-admission shell (M8). Runs after
494
+ * frontend-design-review-pi: freezes the writer baseline, derives the concrete
495
+ * writeSet, folds the design-policy result + design verdict into admission,
496
+ * and writes contracts/frontend-writer-admission-result.json
497
+ * (schemaId frontend-writer-admission-shell-v1).
498
+ */
499
+ export const dagFrontendWriterAdmissionShellSchema = z
500
+ .object({
501
+ schemaVersion: z.literal(1),
502
+ /** Design verdict source (frontend-design-review-pi); pass is enforced.
503
+ * Omitted in small topology, which has no design review node. */
504
+ designReviewFromNodeId: dagFrontendNodeIdSchema.optional(),
505
+ /** Frozen command labels the verification bundle will execute. */
506
+ frozenCommandLabels: z.array(z.string()).default([]),
507
+ allowedMockStrategies: z
508
+ .array(z.enum(["native", "browser-intercept", "request-adapter", "not-needed"]))
509
+ .min(1),
510
+ /** Writer-preceding lint commands; baseline is materialized here (R5). */
511
+ lintCommands: z.array(z.string().min(1)).optional(),
512
+ lintEvidence: dagShellVerifyEvidenceSchema.optional(),
513
+ })
514
+ .superRefine((admission, context) => {
515
+ if ((admission.lintCommands?.length ?? 0) > 0 && !admission.lintEvidence) {
516
+ context.addIssue({
517
+ code: z.ZodIssueCode.custom,
518
+ path: ["lintEvidence"],
519
+ message: "lintEvidence is required when lintCommands are present",
520
+ });
521
+ }
522
+ });
523
+ /** Deterministic frontend closeout shell (M8). Renders the closeout from
524
+ * committed facts only (review context + typed review terminal + trace). */
525
+ export const dagFrontendCloseoutSchema = z.object({
526
+ schemaVersion: z.literal(1),
527
+ reviewFromNodeId: dagFrontendNodeIdSchema,
528
+ });
336
529
  export const ENV_VAR_NAME_PATTERN = /^[A-Z_][A-Z0-9_]*$/;
337
530
  export const dagVersionSchema = z
338
531
  .union([z.literal(1), z.literal(2), z.literal(3), z.literal(4)])
@@ -370,7 +563,7 @@ export const dagWritePolicySchema = z.enum([
370
563
  "none",
371
564
  ]);
372
565
  /** Git/post-diff write guard intensity for exclusive Pi writers. */
373
- export const dagWriteGuardPolicySchema = z.enum(["full", "tools-only"]);
566
+ export const dagWriteGuardPolicySchema = z.enum(["full", "tools-only", "filesystem-only"]);
374
567
  /**
375
568
  * Fail-closed outcome/diff consistency contract for bounded Pi writers.
376
569
  * The writer must begin with IMPLEMENTATION_OUTCOME: changed,
@@ -380,7 +573,14 @@ export const dagWriteGuardPolicySchema = z.enum(["full", "tools-only"]);
380
573
  */
381
574
  export const dagWriterOutcomePolicySchema = z
382
575
  .object({
383
- type: z.literal("implementation-outcome-v1"),
576
+ /**
577
+ * Protocol face: `implementation-outcome-v1` keeps the legacy
578
+ * IMPLEMENTATION_OUTCOME first-line protocol (backend/README/module
579
+ * writers + frontend-repair-pi); `frontend-facts-v1` derives the status
580
+ * from mechanical facts (write-tool events / run delta / write guard /
581
+ * requirement coverage / focused-check) and never reads the first line.
582
+ */
583
+ type: z.enum(["implementation-outcome-v1", "frontend-facts-v1"]),
384
584
  /** Generation writers may forbid already-satisfied/no-diff completion. */
385
585
  requireChangedFiles: z.boolean().optional(),
386
586
  })
@@ -427,6 +627,8 @@ export const dagBackendTestPipelineSchema = z.enum([
427
627
  "ingest-backend-test-gap",
428
628
  ]);
429
629
  export const dagFrontendBrowserToolPreflightSchema = z.object({}).strict();
630
+ export const dagFrontendTestStandardScenariosSchema = z.object({}).strict();
631
+ export const dagFrontendTestEnvironmentProbeSchema = z.object({}).strict();
430
632
  export const dagFrontendTestEvidenceValidationSchema = z.object({}).strict();
431
633
  export const dagFrontendTestCaseChecklistSchema = z.object({}).strict();
432
634
  export const dagFrontendTestHtmlReportSchema = z.object({}).strict();
@@ -448,6 +650,12 @@ export const dagFrontendTestCasePackageFinalizeSchema = z
448
650
  declaredAcIds: z.array(z.string()).optional(),
449
651
  })
450
652
  .strict();
653
+ export const dagFrontendTestCaseGenerationAssessmentSchema = z
654
+ .object({
655
+ plannerNodeId: z.string().regex(/^[a-z][a-z0-9-]*$/),
656
+ declaredAcIds: z.array(z.string()).optional(),
657
+ })
658
+ .strict();
451
659
  export const dagFrontendTestCaseManifestSchema = z
452
660
  .object({
453
661
  maxCases: z.number().int().min(1).optional(),
@@ -523,18 +731,24 @@ export const dagShellConfigSchema = z.object({
523
731
  .optional(),
524
732
  requirementCoverageGate: dagRequirementCoverageGateSchema.optional(),
525
733
  jsonArtifactGate: dagJsonArtifactGateSchema.optional(),
734
+ frontendDesignPolicy: dagFrontendDesignPolicySchema.optional(),
735
+ frontendWriterAdmission: dagFrontendWriterAdmissionShellSchema.optional(),
526
736
  frontendPrewriteGate: dagFrontendPrewriteGateSchema.optional(),
527
- frontendLintBaseline: dagFrontendLintBaselineSchema.optional(),
528
737
  frontendVerificationBundle: dagFrontendVerificationBundleSchema.optional(),
529
738
  frontendReviewContext: dagFrontendReviewContextSchema.optional(),
739
+ frontendContractImport: dagFrontendContractImportSchema.optional(),
740
+ frontendCloseout: dagFrontendCloseoutSchema.optional(),
530
741
  frontendTestCaseChecklist: dagFrontendTestCaseChecklistSchema.optional(),
531
742
  frontendBrowserToolPreflight: dagFrontendBrowserToolPreflightSchema.optional(),
743
+ frontendTestStandardScenarios: dagFrontendTestStandardScenariosSchema.optional(),
744
+ frontendTestEnvironmentProbe: dagFrontendTestEnvironmentProbeSchema.optional(),
532
745
  frontendTestEvidenceValidation: dagFrontendTestEvidenceValidationSchema.optional(),
533
746
  finalWriteSetApprovalGate: dagFinalWriteSetApprovalGateSchema.optional(),
534
747
  frontendTestL5Report: z.object({}).strict().optional(),
535
748
  frontendTestHtmlReport: dagFrontendTestHtmlReportSchema.optional(),
536
749
  frontendTestCaseManifest: dagFrontendTestCaseManifestSchema.optional(),
537
750
  frontendTestCasePackageFinalize: dagFrontendTestCasePackageFinalizeSchema.optional(),
751
+ frontendTestCaseGenerationAssessment: dagFrontendTestCaseGenerationAssessmentSchema.optional(),
538
752
  frontendTestRerunCandidates: dagFrontendTestRerunCandidatesSchema.optional(),
539
753
  frontendTestResultFinalize: dagFrontendTestResultFinalizeSchema.optional(),
540
754
  frontendTestReports: dagFrontendTestReportsSchema.optional(),
@@ -587,6 +801,15 @@ export const dagDynamicExpansionChildTaskSchema = z.object({
587
801
  allowedPaths: z.array(z.string()).optional().default([]),
588
802
  forbiddenPaths: z.array(z.string()).optional().default([]),
589
803
  writeSet: z.array(z.string()).optional(),
804
+ /** Template-rendered strict repository-relative read allowlist. */
805
+ readSet: z.array(z.string()).optional(),
806
+ readBudget: z.object({
807
+ maxFiles: z.number().int().positive(),
808
+ maxBytes: z.number().int().positive(),
809
+ maxMs: z.number().int().positive().optional(),
810
+ maxOperations: z.number().int().positive().optional(),
811
+ onExhaustion: z.enum(["return-guidance"]).optional(),
812
+ }).strict().optional(),
590
813
  /**
591
814
  * Materialized-child pass-through fields for bounded Pi writer children
592
815
  * (backend-test md/pytest case sharding). All optional so legacy
@@ -596,6 +819,11 @@ export const dagDynamicExpansionChildTaskSchema = z.object({
596
819
  writeGuardPolicy: dagWriteGuardPolicySchema.optional(),
597
820
  retryPolicy: dagRetryPolicySchema.optional(),
598
821
  });
822
+ export const dagChildFailurePolicySchema = z.object({
823
+ claimRemaining: z.boolean().default(false),
824
+ barrier: z.enum(["fail", "record"]).default("fail"),
825
+ materialize: z.enum(["none", "case-evidence"]).default("none"),
826
+ }).strict();
599
827
  export const dagDynamicExpansionSchema = z.object({
600
828
  type: z.enum(["map_agent", "verify_agent"]),
601
829
  workflowNodeId: z
@@ -635,6 +863,8 @@ export const dagDynamicExpansionSchema = z.object({
635
863
  * (sharded migration and other map_agent workflows).
636
864
  */
637
865
  tolerateChildFailures: z.boolean().optional(),
866
+ /** Explicitly separates claim, barrier, and evidence behavior for child failures. */
867
+ childFailurePolicy: dagChildFailurePolicySchema.optional(),
638
868
  });
639
869
  export const dagDynamicReductionSchema = z.object({
640
870
  type: z.literal("verified_findings_report"),
@@ -735,7 +965,58 @@ export const structuredContractOutputSchemaIds = [
735
965
  "frontend-implementation-contract-plan-patch-v1",
736
966
  "frontend-implementation-contract-revision-patch-v1",
737
967
  ];
738
- export const dagTaskSchema = z.object({ id: z.string().regex(/^[a-z][a-z0-9-]*$/, "task id must be kebab-case"),
968
+ export const dagArtifactIdentitySchema = z
969
+ .string()
970
+ .regex(/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/, "artifact id must be stable lower-case dot/kebab syntax");
971
+ const dagArtifactRelativePathSchema = z
972
+ .string()
973
+ .min(1)
974
+ .refine((value) => !value.includes("\0"), "artifact path must not contain NUL")
975
+ .refine((value) => !value.includes("\\"), "artifact path must use POSIX separators")
976
+ .refine((value) => !value.startsWith("/") && !/^[A-Za-z]:/.test(value), "artifact path must be run-relative")
977
+ .refine((value) => value.split("/").every((segment) => segment !== "" && segment !== ".."), "artifact path must not escape the run");
978
+ export const dagProducedArtifactSchema = z
979
+ .object({
980
+ artifactId: dagArtifactIdentitySchema,
981
+ kind: z.enum(["structured", "assistant", "stdout"]),
982
+ path: dagArtifactRelativePathSchema,
983
+ mediaType: z.string().min(1),
984
+ schemaId: z.string().min(1).optional(),
985
+ revisionPolicy: z.enum(["immutable", "replace-file"]),
986
+ })
987
+ .strict()
988
+ .superRefine((value, ctx) => {
989
+ if (value.kind === "structured" && !value.schemaId) {
990
+ ctx.addIssue({
991
+ code: z.ZodIssueCode.custom,
992
+ path: ["schemaId"],
993
+ message: "structured artifact requires schemaId",
994
+ });
995
+ }
996
+ if (value.kind !== "structured" && value.schemaId) {
997
+ ctx.addIssue({
998
+ code: z.ZodIssueCode.custom,
999
+ path: ["schemaId"],
1000
+ message: "only structured artifacts may declare schemaId",
1001
+ });
1002
+ }
1003
+ if (value.revisionPolicy === "replace-file" &&
1004
+ value.kind !== "structured") {
1005
+ ctx.addIssue({
1006
+ code: z.ZodIssueCode.custom,
1007
+ path: ["revisionPolicy"],
1008
+ message: "MVP revisions are limited to structured artifacts",
1009
+ });
1010
+ }
1011
+ });
1012
+ export const dagConsumedArtifactSchema = z
1013
+ .object({
1014
+ artifactId: dagArtifactIdentitySchema,
1015
+ required: z.boolean().default(true),
1016
+ })
1017
+ .strict();
1018
+ export const dagTaskSchema = z.object({
1019
+ id: z.string().regex(/^[a-z][a-z0-9-]*$/, "task id must be kebab-case"),
739
1020
  depends_on: z.array(z.string()).default([]),
740
1021
  /**
741
1022
  * How SKIPPED upstreams affect readiness.
@@ -768,14 +1049,58 @@ export const dagTaskSchema = z.object({ id: z.string().regex(/^[a-z][a-z0-9-]*$/
768
1049
  role: dagRoleSchema.optional(),
769
1050
  skills: z.array(z.string()).optional(),
770
1051
  toolProfile: dagToolProfileSchema.optional(),
1052
+ /** Bounded read-only discovery budget for nodes that inspect a repository. */
1053
+ readBudget: z
1054
+ .object({
1055
+ maxFiles: z.number().int().positive(),
1056
+ maxBytes: z.number().int().positive(),
1057
+ maxMs: z.number().int().positive().optional(),
1058
+ /** Maximum read/grep/find/ls calls. */
1059
+ maxOperations: z.number().int().positive().optional(),
1060
+ /** On any read budget exhaustion, return concise completion guidance instead of failing the node. */
1061
+ onExhaustion: z.enum(["return-guidance"]).optional(),
1062
+ })
1063
+ .strict()
1064
+ .optional(),
1065
+ /**
1066
+ * Explicit Pi extension allowlist (backend implementation DAGs only):
1067
+ * frozen short ids resolved at run time against the Pi settings package
1068
+ * inventory. Omitted = extension discovery stays fully closed (R8.1).
1069
+ * Only `executor: "pi"` nodes may declare it (validated fail-closed).
1070
+ */
1071
+ piExtensions: dagPiExtensionsSchema.optional(),
771
1072
  /** Default deny: file write (toolProfile=write) does not grant command execution. */
772
1073
  commandPolicy: dagCommandPolicySchema.optional(),
773
1074
  writePolicy: dagWritePolicySchema.optional(),
774
1075
  writeSet: z.array(z.string()).optional(),
1076
+ /** Strict repository-relative read allowlist for bounded Pi nodes. */
1077
+ readSet: z.array(z.string()).optional(),
1078
+ /**
1079
+ * Online per-attempt Pi context guard. Unlike run/map cost budgets, this
1080
+ * aborts the active SDK session before an oversized conversation reaches
1081
+ * the provider's context rejection boundary.
1082
+ */
1083
+ contextBudget: z
1084
+ .object({
1085
+ maxTurns: z.number().int().positive().optional(),
1086
+ maxTokens: z.number().int().positive().optional(),
1087
+ })
1088
+ .strict()
1089
+ .refine((value) => value.maxTurns !== undefined || value.maxTokens !== undefined, "contextBudget requires maxTurns or maxTokens")
1090
+ .optional(),
775
1091
  piStep: z.string().optional(),
776
1092
  shell: dagShellConfigSchema.optional(),
777
1093
  static: dagStaticConfigSchema.optional(),
778
1094
  outputContract: z.string().optional(),
1095
+ /**
1096
+ * Frozen producer declarations for run-owned artifacts. These declarations,
1097
+ * together with consumesArtifacts, are the only authority for artifact
1098
+ * lineage and impact analysis. Prompt/outputContract/path heuristics are
1099
+ * intentionally forbidden.
1100
+ */
1101
+ producesArtifacts: z.array(dagProducedArtifactSchema).optional(),
1102
+ /** Frozen logical artifact inputs consumed by this node. */
1103
+ consumesArtifacts: z.array(dagConsumedArtifactSchema).optional(),
779
1104
  outputMode: dagOutputModeSchema.optional(),
780
1105
  firstProtocolLine: z.string().min(1).optional(),
781
1106
  /**
@@ -804,8 +1129,7 @@ export const dagTaskSchema = z.object({ id: z.string().regex(/^[a-z][a-z0-9-]*$/
804
1129
  })
805
1130
  .strict()
806
1131
  .superRefine((value, ctx) => {
807
- if (value.schemaId ===
808
- "frontend-implementation-contract-plan-patch-v1" &&
1132
+ if (value.schemaId === "frontend-implementation-contract-plan-patch-v1" &&
809
1133
  !value.skeleton) {
810
1134
  ctx.addIssue({
811
1135
  code: "custom",
@@ -845,6 +1169,14 @@ export const dagTaskSchema = z.object({ id: z.string().regex(/^[a-z][a-z0-9-]*$/
845
1169
  forbiddenPaths: z.array(z.string()).optional().default([]),
846
1170
  decisionGate: dagDecisionGateSchema.optional(),
847
1171
  retryPolicy: dagRetryPolicySchema.optional(),
1172
+ /**
1173
+ * Generation-path stamp for implicit same-run transient retry. Only the
1174
+ * three target templates stamp canonical final verify shells and
1175
+ * exclusive `implement-pi`. Zod-declared so parseDagSpec does not strip it.
1176
+ */
1177
+ transientRetryProfile: z
1178
+ .literal(TARGET_TEMPLATE_TRANSIENT_RETRY_PROFILE)
1179
+ .optional(),
848
1180
  /** Optional per-node adaptive liveness override (merged over defaults). */
849
1181
  livenessPolicy: dagLivenessPolicySchema,
850
1182
  dynamicExpansion: dagDynamicExpansionSchema.optional(),
@@ -852,6 +1184,121 @@ export const dagTaskSchema = z.object({ id: z.string().regex(/^[a-z][a-z0-9-]*$/
852
1184
  dynamicCondition: dagDynamicConditionSchema.optional(),
853
1185
  dynamicLoopUntil: dagDynamicLoopUntilSchema.optional(),
854
1186
  });
1187
+ function hasTransitiveDependency(tasksById, consumerNodeId, producerNodeId) {
1188
+ const queue = [...(tasksById.get(consumerNodeId)?.depends_on ?? [])];
1189
+ const seen = new Set();
1190
+ while (queue.length > 0) {
1191
+ const nodeId = queue.shift();
1192
+ if (nodeId === producerNodeId)
1193
+ return true;
1194
+ if (seen.has(nodeId))
1195
+ continue;
1196
+ seen.add(nodeId);
1197
+ queue.push(...(tasksById.get(nodeId)?.depends_on ?? []));
1198
+ }
1199
+ return false;
1200
+ }
1201
+ function validateFrozenArtifactBindings(tasks, ctx) {
1202
+ const tasksById = new Map(tasks.map((task) => [task.id, task]));
1203
+ const producers = new Map();
1204
+ const paths = new Map();
1205
+ for (const [taskIndex, task] of tasks.entries()) {
1206
+ const localIds = new Set();
1207
+ for (const [artifactIndex, artifact] of (task.producesArtifacts ?? []).entries()) {
1208
+ if (localIds.has(artifact.artifactId) ||
1209
+ producers.has(artifact.artifactId)) {
1210
+ ctx.addIssue({
1211
+ code: z.ZodIssueCode.custom,
1212
+ path: [
1213
+ "tasks",
1214
+ taskIndex,
1215
+ "producesArtifacts",
1216
+ artifactIndex,
1217
+ "artifactId",
1218
+ ],
1219
+ message: `artifact ${artifact.artifactId} must have exactly one producer`,
1220
+ });
1221
+ }
1222
+ else {
1223
+ producers.set(artifact.artifactId, {
1224
+ nodeId: task.id,
1225
+ taskIndex,
1226
+ artifactIndex,
1227
+ path: artifact.path,
1228
+ });
1229
+ }
1230
+ localIds.add(artifact.artifactId);
1231
+ const foldedPath = artifact.path
1232
+ .normalize("NFC")
1233
+ .toLocaleLowerCase("en-US");
1234
+ const existingArtifactId = paths.get(foldedPath);
1235
+ if (existingArtifactId && existingArtifactId !== artifact.artifactId) {
1236
+ ctx.addIssue({
1237
+ code: z.ZodIssueCode.custom,
1238
+ path: [
1239
+ "tasks",
1240
+ taskIndex,
1241
+ "producesArtifacts",
1242
+ artifactIndex,
1243
+ "path",
1244
+ ],
1245
+ message: `artifact path collides with ${existingArtifactId} under case folding`,
1246
+ });
1247
+ }
1248
+ else {
1249
+ paths.set(foldedPath, artifact.artifactId);
1250
+ }
1251
+ }
1252
+ }
1253
+ for (const [taskIndex, task] of tasks.entries()) {
1254
+ const consumed = new Set();
1255
+ for (const [artifactIndex, binding] of (task.consumesArtifacts ?? []).entries()) {
1256
+ if (consumed.has(binding.artifactId)) {
1257
+ ctx.addIssue({
1258
+ code: z.ZodIssueCode.custom,
1259
+ path: [
1260
+ "tasks",
1261
+ taskIndex,
1262
+ "consumesArtifacts",
1263
+ artifactIndex,
1264
+ "artifactId",
1265
+ ],
1266
+ message: `artifact ${binding.artifactId} is consumed more than once by ${task.id}`,
1267
+ });
1268
+ }
1269
+ consumed.add(binding.artifactId);
1270
+ const producer = producers.get(binding.artifactId);
1271
+ if (!producer) {
1272
+ ctx.addIssue({
1273
+ code: z.ZodIssueCode.custom,
1274
+ path: [
1275
+ "tasks",
1276
+ taskIndex,
1277
+ "consumesArtifacts",
1278
+ artifactIndex,
1279
+ "artifactId",
1280
+ ],
1281
+ message: `artifact ${binding.artifactId} has no declared producer`,
1282
+ });
1283
+ continue;
1284
+ }
1285
+ if (producer.nodeId === task.id ||
1286
+ !hasTransitiveDependency(tasksById, task.id, producer.nodeId)) {
1287
+ ctx.addIssue({
1288
+ code: z.ZodIssueCode.custom,
1289
+ path: [
1290
+ "tasks",
1291
+ taskIndex,
1292
+ "consumesArtifacts",
1293
+ artifactIndex,
1294
+ "artifactId",
1295
+ ],
1296
+ message: `consumer ${task.id} must be downstream of producer ${producer.nodeId}`,
1297
+ });
1298
+ }
1299
+ }
1300
+ }
1301
+ }
855
1302
  export const dagModelsSchema = z
856
1303
  .object({
857
1304
  HIGH: z.string().optional(),
@@ -878,20 +1325,98 @@ export const dagEvaluationBindingSchema = z
878
1325
  .strict();
879
1326
  /** Eval Lab Campaign Budget (W3.4); enforced by runner ledger when mode=hard. */
880
1327
  export const dagBudgetSchema = campaignBudgetSchema;
881
- export const dagSourceBindingSchema = z.object({
1328
+ export const dagSourceBindingSourceSchema = z.object({
1329
+ kind: z.enum(["requirement", "constraint", "reference"]),
1330
+ path: z.string().min(1),
1331
+ sha256: z.string().regex(/^[a-f0-9]{64}$/, "sha256 must be lowercase hex"),
1332
+ });
1333
+ /**
1334
+ * DagSourceBinding v1:无 ledger 字段(schemaVersion=1,.strict() 拒绝 ledger
1335
+ * 字段混入,不得以 v1+optional 冒充 v2)。非 frontend task / 无可解析引用时使用。
1336
+ */
1337
+ export const dagSourceBindingV1Schema = z
1338
+ .object({
882
1339
  schemaVersion: z.literal(1),
883
1340
  taskId: z.string().min(1),
884
- sources: z
885
- .array(z.object({
886
- kind: z.enum(["requirement", "constraint", "reference"]),
887
- path: z.string().min(1),
888
- sha256: z
889
- .string()
890
- .regex(/^[a-f0-9]{64}$/, "sha256 must be lowercase hex"),
891
- }))
892
- .min(1),
1341
+ sources: z.array(dagSourceBindingSourceSchema).min(1),
893
1342
  requirementIds: z.array(z.string().regex(/^(?:REQ|BR|AC)-[A-Z0-9]+(?:-[A-Z0-9]+)*$/)),
894
- });
1343
+ })
1344
+ .strict();
1345
+ /**
1346
+ * DagSourceBinding v2(20260824-frontend-source-fidelity-ledger-v1):仅
1347
+ * frontend-implementation 且存在可解析 requirement/acceptance 引用时产出;
1348
+ * ledgerPath/ledgerSha256/inputDigest/requirementToFragments 全部必填且完整,
1349
+ * 伪造或缺失任一字段被 schema/prewrite 拒绝(AC-002 / AC-FIDELITY-REPAIR-002)。
1350
+ */
1351
+ export const dagSourceBindingV2Schema = z
1352
+ .object({
1353
+ schemaVersion: z.literal(2),
1354
+ taskId: z.string().min(1),
1355
+ sources: z.array(dagSourceBindingSourceSchema).min(1),
1356
+ requirementIds: z.array(z.string().regex(/^(?:REQ|BR|AC)-[A-Z0-9]+(?:-[A-Z0-9]+)*$/)),
1357
+ /** 受管 requirement-ledger.json 的 DAG 可解析路径(.harness/tasks/…/source/…)。 */
1358
+ ledgerPath: z.string().min(1),
1359
+ ledgerSha256: z.string().regex(/^[a-f0-9]{64}$/),
1360
+ inputDigest: z.string().regex(/^[a-f0-9]{64}$/),
1361
+ requirementToFragments: z.record(z.string(), z.array(z.string())),
1362
+ })
1363
+ .strict();
1364
+ export const dagSourceBindingSchema = z.discriminatedUnion("schemaVersion", [
1365
+ dagSourceBindingV1Schema,
1366
+ dagSourceBindingV2Schema,
1367
+ ]);
1368
+ export function isDagSourceBindingV2(binding) {
1369
+ return binding.schemaVersion === 2;
1370
+ }
1371
+ const dagRerunFeedbackEvidencePathSchema = z
1372
+ .string()
1373
+ .min(1)
1374
+ .refine((value) => !/^(?:[A-Za-z]:[\\/]|[\\/]{2}|\/)/.test(value), "rerun feedback evidence paths must be repository-relative");
1375
+ /**
1376
+ * Bounded unresolved verify/review feedback carried by a full task rerun.
1377
+ * This is recovery context, not a mutation of the original task contract.
1378
+ */
1379
+ export const dagRerunFeedbackSchema = z
1380
+ .object({
1381
+ schemaVersion: z.literal(1),
1382
+ kind: z.literal("unresolved-terminal-feedback"),
1383
+ parentRunId: z.string().min(1),
1384
+ taskId: z.string().min(1),
1385
+ sourceNodeId: z.string().min(1),
1386
+ verdict: z.enum(["request-revision", "fail"]).optional(),
1387
+ failureCategory: z.string().min(1).optional(),
1388
+ feedbackText: z.string().min(1).max(12_000),
1389
+ evidenceRefs: z
1390
+ .array(z
1391
+ .object({
1392
+ nodeId: z.string().min(1),
1393
+ preservedNodeRecordPath: dagRerunFeedbackEvidencePathSchema,
1394
+ })
1395
+ .strict())
1396
+ .max(8),
1397
+ attemptSummary: z
1398
+ .object({
1399
+ completedPasses: z.number().int().positive(),
1400
+ maxPasses: z.number().int().positive(),
1401
+ terminalReason: z.string().min(1).optional(),
1402
+ })
1403
+ .strict(),
1404
+ binding: z
1405
+ .object({
1406
+ sourceCanonicalHash: z
1407
+ .string()
1408
+ .regex(/^[a-f0-9]{64}$/)
1409
+ .optional(),
1410
+ taskContractCanonicalHash: z
1411
+ .string()
1412
+ .regex(/^[a-f0-9]{64}$/)
1413
+ .optional(),
1414
+ status: z.enum(["exact", "changed", "unknown"]),
1415
+ })
1416
+ .strict(),
1417
+ digest: z.string().regex(/^[a-f0-9]{64}$/),
1418
+ })
1419
+ .strict();
895
1420
  export const dagSpecSchema = z
896
1421
  .object({
897
1422
  version: dagVersionSchema,
@@ -903,6 +1428,26 @@ export const dagSpecSchema = z
903
1428
  sourceBinding: dagSourceBindingSchema.optional(),
904
1429
  /** v4 managed Task Contract binding; only valid on version 4. */
905
1430
  taskContractBinding: dagTaskContractBindingSchema.optional(),
1431
+ /** Optional unresolved parent-run feedback for a full task rerun. */
1432
+ rerunFeedback: dagRerunFeedbackSchema.optional(),
1433
+ /** Frontend recovery continuation quota (frozen at generation time from
1434
+ * task.json frontendRecovery.maxContinuations). Bounds how many times a
1435
+ * failed frontend run may auto-recover via M6 recovery operations before
1436
+ * the run stays failed and needs human intervention. */
1437
+ frontendRecovery: z
1438
+ .object({
1439
+ maxContinuations: z
1440
+ .number()
1441
+ .int()
1442
+ .min(1)
1443
+ .max(5)
1444
+ .optional()
1445
+ .default(1),
1446
+ })
1447
+ .strict()
1448
+ .optional(),
1449
+ /** Backend-test-only workspace mutation control; absent means Git. */
1450
+ backendTestWorkspaceControl: z.enum(["git", "filesystem-only"]).optional(),
906
1451
  /** Frozen backend-test artifact layout (plan A); absent = historical default testcase/ layout. */
907
1452
  backendTestLayout: z
908
1453
  .object({
@@ -915,6 +1460,18 @@ export const dagSpecSchema = z
915
1460
  isDefault: z.boolean(),
916
1461
  })
917
1462
  .optional(),
1463
+ /** Frozen frontend-test artifact layout; absent = historical testcase/frontend/ layout. */
1464
+ frontendTestLayout: z
1465
+ .object({
1466
+ testRoot: z.string(),
1467
+ ragDir: z.string(),
1468
+ casesDir: z.string(),
1469
+ evidenceDir: z.string(),
1470
+ reportsDir: z.string(),
1471
+ fixturesDir: z.string(),
1472
+ isDefault: z.boolean(),
1473
+ })
1474
+ .optional(),
918
1475
  /** Bound user shared-setup document (plan B); absent = no shared setup references expected. */
919
1476
  backendTestSharedSetup: z
920
1477
  .object({
@@ -938,6 +1495,7 @@ export const dagSpecSchema = z
938
1495
  })
939
1496
  .superRefine((spec, ctx) => {
940
1497
  const supportsV3Fields = spec.version === 3 || spec.version === 4;
1498
+ validateFrozenArtifactBindings(spec.tasks, ctx);
941
1499
  if (spec.evaluation && !supportsV3Fields) {
942
1500
  ctx.addIssue({
943
1501
  code: z.ZodIssueCode.custom,
@@ -1014,6 +1572,9 @@ export const FRONTEND_RECOVERY_RESULT_SCHEMA_VERSION = 1;
1014
1572
  * Phase 3a parents converge first, so `rollback-pending` is not produced and
1015
1573
  * was removed by AC-1; the phase starts at `child-staging` and ends at
1016
1574
  * `settled`.
1575
+ *
1576
+ * @deprecated Read-only compatibility only; the M6 operation controller no
1577
+ * longer uses this phase as the authoritative recovery entry point.
1017
1578
  */
1018
1579
  export const frontendRecoveryPhaseSchema = z.enum([
1019
1580
  "child-staging",
@@ -1027,12 +1588,16 @@ export const frontendRecoveryPhaseSchema = z.enum([
1027
1588
  * the child carries a frozen lineage snapshot so the activation gate can prove
1028
1589
  * it is the reserved child of a child-running parent.
1029
1590
  *
1030
- * Invariants: `attemptIndex ∈ {0,1}`; `continuationCount ∈ {0,1}`; a child's
1591
+ * Invariants: `attemptIndex` and `continuationCount` are bounded by the frozen
1592
+ * frontend recovery quota (currently 1-5); a child's
1031
1593
  * `recoveryRootRunId` always equals the root runId; `revision` is the CAS
1032
1594
  * pre-comparison counter. `revision` monotonicity is enforced at runtime by the
1033
1595
  * runner's `(existing?.revision ?? 0) + 1` CAS write (the schema only bounds it
1034
1596
  * non-negative). `childRunId` may be absent through `child-activating` and must
1035
1597
  * be non-empty from `child-running` onward.
1598
+ *
1599
+ * @deprecated Read-only compatibility only; the runner no longer writes this
1600
+ * intent (the M6 operation controller supervises recovery instead).
1036
1601
  */
1037
1602
  export const frontendRecoveryStateSchema = z
1038
1603
  .object({
@@ -1043,8 +1608,8 @@ export const frontendRecoveryStateSchema = z
1043
1608
  parentRunId: z.string().min(1),
1044
1609
  childRunId: z.string().min(1).optional(),
1045
1610
  attemptId: z.string().min(1),
1046
- attemptIndex: z.number().int().min(0).max(1),
1047
- continuationCount: z.number().int().min(0).max(1),
1611
+ attemptIndex: z.number().int().min(0).max(5),
1612
+ continuationCount: z.number().int().min(0).max(5),
1048
1613
  /** Node id of the reset-closure root: frontend-plan-pi /
1049
1614
  * frontend-plan-revision-pi / frontend-prewrite-gate-shell /
1050
1615
  * frontend-implement-pi (writer partial write). */
@@ -1104,6 +1669,10 @@ export const frontendRecoveryEvidenceRefSchema = z
1104
1669
  * stays permissive (failureClass optional, evidenceRefs may be empty) so it
1105
1670
  * accepts the runner's actual phase-3a products, which do not always carry a
1106
1671
  * failure class or evidence reference.
1672
+ *
1673
+ * @deprecated Read-only compatibility only; the M6 operation controller writes
1674
+ * `recovered`/`auto-recovery-blocked` results directly and never uses this
1675
+ * schema as the authoritative recovery settlement.
1107
1676
  */
1108
1677
  export const frontendRecoveryResultSchema = z
1109
1678
  .object({