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

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 (484) hide show
  1. package/AGENTS.md +6 -3
  2. package/CHANGELOG.md +605 -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 +4321 -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 +1411 -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 +2 -1
  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 +30 -4
  370. package/dist/workflows/dag/frontend-test-case-manifest.js +11 -4
  371. package/dist/workflows/dag/frontend-test-case-quality.js +11 -16
  372. package/dist/workflows/dag/frontend-test-environment-probe.js +230 -0
  373. package/dist/workflows/dag/frontend-test-html-report.js +3 -1
  374. package/dist/workflows/dag/frontend-test-l5-report.js +3 -1
  375. package/dist/workflows/dag/frontend-test-layout.js +159 -0
  376. package/dist/workflows/dag/frontend-test-markdown.js +61 -0
  377. package/dist/workflows/dag/frontend-test-result-contract.js +188 -42
  378. package/dist/workflows/dag/frontend-test-standard-scenarios.js +70 -0
  379. package/dist/workflows/dag/frontend-typed-event-store.js +452 -0
  380. package/dist/workflows/dag/frontend-typed-event-transaction.js +180 -0
  381. package/dist/workflows/dag/frontend-verification-trace.js +281 -29
  382. package/dist/workflows/dag/frontend-worktree-diff.js +250 -17
  383. package/dist/workflows/dag/frontend-writer-admission.js +319 -0
  384. package/dist/workflows/dag/frontend-writer-rollback.js +32 -0
  385. package/dist/workflows/dag/frontend-writer-status.js +256 -0
  386. package/dist/workflows/dag/init-hybrid.js +1670 -706
  387. package/dist/workflows/dag/interrupt-request.js +10 -3
  388. package/dist/workflows/dag/lifecycle.js +3 -3
  389. package/dist/workflows/dag/node-execution.js +1141 -32
  390. package/dist/workflows/dag/path-safety.js +1 -0
  391. package/dist/workflows/dag/prompt.js +158 -7
  392. package/dist/workflows/dag/recovery-lease.js +170 -0
  393. package/dist/workflows/dag/report.js +37 -1
  394. package/dist/workflows/dag/rerun-feedback.js +526 -0
  395. package/dist/workflows/dag/rerun-plan.js +790 -28
  396. package/dist/workflows/dag/rerun-run.js +700 -21
  397. package/dist/workflows/dag/rerun-task.js +311 -14
  398. package/dist/workflows/dag/retry-policy.js +336 -101
  399. package/dist/workflows/dag/runner.js +596 -121
  400. package/dist/workflows/dag/scheduler.js +133 -20
  401. package/dist/workflows/dag/skill-snapshot.js +17 -0
  402. package/dist/workflows/dag/structured-output-repair.js +712 -0
  403. package/dist/workflows/dag/types.js +579 -31
  404. package/dist/workflows/dag/validate.js +92 -32
  405. package/docs/README.md +2 -0
  406. package/docs/architecture/evolution.md +45 -0
  407. package/docs/architecture/runtime-boundaries.md +8 -7
  408. package/docs/architecture/worker-and-feature.md +1 -1
  409. package/docs/examples/README.md +5 -0
  410. package/docs/init-surface.manifest.json +36 -12
  411. package/docs/operations/README.md +1 -1
  412. package/docs/operations/local-development-environment.md +22 -5
  413. package/docs/skills/vetted-skill-registry.md +16 -0
  414. package/docs/templates/README.md +4 -2
  415. package/docs/templates/agent-dag-report.schema.json +8 -2
  416. package/docs/templates/agent-dag.schema.json +95 -1
  417. package/docs/templates/backend-test-dag.json +278 -244
  418. package/docs/templates/frontend-implementation-contract.schema.json +684 -24
  419. package/docs/templates/frontend-implementation-dag.json +89 -0
  420. package/docs/templates/frontend-test-case-checklist.md +2 -2
  421. package/docs/templates/frontend-test-dag.json +8 -10
  422. package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +1 -1
  423. package/docs/templates/init-managed-agents.md +13 -3
  424. package/docs/templates/product-line/task.yaml +1 -1
  425. package/docs/templates/spec-registry.schema.json +45 -0
  426. package/harness.json +2 -2
  427. package/package.json +19 -5
  428. package/scripts/next-info.mjs +356 -0
  429. package/scripts/next-publish-gate.mjs +238 -0
  430. package/scripts/release-source-binding.mjs +251 -0
  431. package/skills/analyze-product-requirements/SKILL.md +8 -5
  432. package/skills/analyze-product-requirements/references/acceptance-criteria.md +1 -1
  433. package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +10 -6
  434. package/skills/analyze-product-requirements/references/example.md +50 -0
  435. package/skills/analyze-product-requirements/references/forward-test-cases.md +11 -7
  436. package/skills/analyze-product-requirements/references/kb-integration.md +5 -5
  437. package/skills/analyze-product-requirements/references/product-analysis-schema.md +8 -4
  438. package/skills/analyze-product-requirements/references/product-requirement-schema.md +2 -2
  439. package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +1 -1
  440. package/skills/analyze-product-requirements/scripts/test-validators.mjs +11 -1
  441. package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +20 -1
  442. package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +9 -0
  443. package/skills/codebase-scout/SKILL.md +1 -1
  444. package/skills/fe-test-ui-scout/SKILL.md +65 -0
  445. package/skills/fe-test-ui-scout/references/ledger-schema.md +62 -0
  446. package/skills/fe-test-ui-scout/references/recon-protocol.md +54 -0
  447. package/skills/frontend-bounded-implement/SKILL.md +15 -14
  448. package/skills/frontend-bounded-implement/references/code-standards.md +19 -0
  449. package/skills/frontend-contract/SKILL.md +23 -0
  450. package/skills/frontend-contract/references/contract-protocol.md +34 -0
  451. package/skills/frontend-design-review/SKILL.md +22 -41
  452. package/skills/frontend-plan/SKILL.md +26 -0
  453. package/skills/frontend-plan/references/decision-contract.md +37 -0
  454. package/skills/frontend-plan/references/design-decisions.md +17 -0
  455. package/skills/frontend-review/SKILL.md +20 -15
  456. package/skills/frontend-review/references/review-findings.md +6 -7
  457. package/skills/frontend-scout/SKILL.md +25 -0
  458. package/skills/frontend-scout/references/design-evidence.md +16 -0
  459. package/skills/frontend-scout/references/scout-evidence.md +23 -0
  460. package/skills/frontend-verification/SKILL.md +1 -1
  461. package/skills/improve-codebase-architecture/SKILL.md +81 -0
  462. package/skills/improve-codebase-architecture/deepening.md +37 -0
  463. package/skills/improve-codebase-architecture/html-report.md +123 -0
  464. package/skills/improve-codebase-architecture/interface-design.md +44 -0
  465. package/skills/improve-codebase-architecture/language.md +53 -0
  466. package/skills/loop-agent/references/command-reference.md +32 -4
  467. package/skills/loop-agent/references/hybrid-dag.md +9 -2
  468. package/skills/playwright-cli/SKILL.md +23 -1
  469. package/skills/playwright-cli-case-generator/SKILL.md +50 -13
  470. package/dist/worker/console/operation-store.js +0 -169
  471. package/dist/worker/console/static/assets/channel-Tl-FkUqr.js +0 -1
  472. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BaehtRk4.js +0 -1
  473. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BaehtRk4.js +0 -1
  474. package/dist/worker/console/static/assets/index-B7Y-0g3J.css +0 -1
  475. package/dist/worker/console/static/assets/index-DkCrqaYg.js +0 -325
  476. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-eEhq2A8Y.js +0 -1
  477. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-la8AC7fo.js +0 -8
  478. package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +0 -73
  479. package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +0 -59
  480. package/skills/frontend-implementation/SKILL.md +0 -52
  481. package/skills/frontend-implementation/references/code-standards.md +0 -33
  482. package/skills/frontend-implementation/references/design-spec.md +0 -56
  483. package/skills/frontend-implementation/references/node-contracts.md +0 -31
  484. /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();
@@ -523,12 +725,17 @@ export const dagShellConfigSchema = z.object({
523
725
  .optional(),
524
726
  requirementCoverageGate: dagRequirementCoverageGateSchema.optional(),
525
727
  jsonArtifactGate: dagJsonArtifactGateSchema.optional(),
728
+ frontendDesignPolicy: dagFrontendDesignPolicySchema.optional(),
729
+ frontendWriterAdmission: dagFrontendWriterAdmissionShellSchema.optional(),
526
730
  frontendPrewriteGate: dagFrontendPrewriteGateSchema.optional(),
527
- frontendLintBaseline: dagFrontendLintBaselineSchema.optional(),
528
731
  frontendVerificationBundle: dagFrontendVerificationBundleSchema.optional(),
529
732
  frontendReviewContext: dagFrontendReviewContextSchema.optional(),
733
+ frontendContractImport: dagFrontendContractImportSchema.optional(),
734
+ frontendCloseout: dagFrontendCloseoutSchema.optional(),
530
735
  frontendTestCaseChecklist: dagFrontendTestCaseChecklistSchema.optional(),
531
736
  frontendBrowserToolPreflight: dagFrontendBrowserToolPreflightSchema.optional(),
737
+ frontendTestStandardScenarios: dagFrontendTestStandardScenariosSchema.optional(),
738
+ frontendTestEnvironmentProbe: dagFrontendTestEnvironmentProbeSchema.optional(),
532
739
  frontendTestEvidenceValidation: dagFrontendTestEvidenceValidationSchema.optional(),
533
740
  finalWriteSetApprovalGate: dagFinalWriteSetApprovalGateSchema.optional(),
534
741
  frontendTestL5Report: z.object({}).strict().optional(),
@@ -587,6 +794,8 @@ export const dagDynamicExpansionChildTaskSchema = z.object({
587
794
  allowedPaths: z.array(z.string()).optional().default([]),
588
795
  forbiddenPaths: z.array(z.string()).optional().default([]),
589
796
  writeSet: z.array(z.string()).optional(),
797
+ /** Template-rendered strict repository-relative read allowlist. */
798
+ readSet: z.array(z.string()).optional(),
590
799
  /**
591
800
  * Materialized-child pass-through fields for bounded Pi writer children
592
801
  * (backend-test md/pytest case sharding). All optional so legacy
@@ -735,7 +944,58 @@ export const structuredContractOutputSchemaIds = [
735
944
  "frontend-implementation-contract-plan-patch-v1",
736
945
  "frontend-implementation-contract-revision-patch-v1",
737
946
  ];
738
- export const dagTaskSchema = z.object({ id: z.string().regex(/^[a-z][a-z0-9-]*$/, "task id must be kebab-case"),
947
+ export const dagArtifactIdentitySchema = z
948
+ .string()
949
+ .regex(/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/, "artifact id must be stable lower-case dot/kebab syntax");
950
+ const dagArtifactRelativePathSchema = z
951
+ .string()
952
+ .min(1)
953
+ .refine((value) => !value.includes("\0"), "artifact path must not contain NUL")
954
+ .refine((value) => !value.includes("\\"), "artifact path must use POSIX separators")
955
+ .refine((value) => !value.startsWith("/") && !/^[A-Za-z]:/.test(value), "artifact path must be run-relative")
956
+ .refine((value) => value.split("/").every((segment) => segment !== "" && segment !== ".."), "artifact path must not escape the run");
957
+ export const dagProducedArtifactSchema = z
958
+ .object({
959
+ artifactId: dagArtifactIdentitySchema,
960
+ kind: z.enum(["structured", "assistant", "stdout"]),
961
+ path: dagArtifactRelativePathSchema,
962
+ mediaType: z.string().min(1),
963
+ schemaId: z.string().min(1).optional(),
964
+ revisionPolicy: z.enum(["immutable", "replace-file"]),
965
+ })
966
+ .strict()
967
+ .superRefine((value, ctx) => {
968
+ if (value.kind === "structured" && !value.schemaId) {
969
+ ctx.addIssue({
970
+ code: z.ZodIssueCode.custom,
971
+ path: ["schemaId"],
972
+ message: "structured artifact requires schemaId",
973
+ });
974
+ }
975
+ if (value.kind !== "structured" && value.schemaId) {
976
+ ctx.addIssue({
977
+ code: z.ZodIssueCode.custom,
978
+ path: ["schemaId"],
979
+ message: "only structured artifacts may declare schemaId",
980
+ });
981
+ }
982
+ if (value.revisionPolicy === "replace-file" &&
983
+ value.kind !== "structured") {
984
+ ctx.addIssue({
985
+ code: z.ZodIssueCode.custom,
986
+ path: ["revisionPolicy"],
987
+ message: "MVP revisions are limited to structured artifacts",
988
+ });
989
+ }
990
+ });
991
+ export const dagConsumedArtifactSchema = z
992
+ .object({
993
+ artifactId: dagArtifactIdentitySchema,
994
+ required: z.boolean().default(true),
995
+ })
996
+ .strict();
997
+ export const dagTaskSchema = z.object({
998
+ id: z.string().regex(/^[a-z][a-z0-9-]*$/, "task id must be kebab-case"),
739
999
  depends_on: z.array(z.string()).default([]),
740
1000
  /**
741
1001
  * How SKIPPED upstreams affect readiness.
@@ -768,14 +1028,58 @@ export const dagTaskSchema = z.object({ id: z.string().regex(/^[a-z][a-z0-9-]*$/
768
1028
  role: dagRoleSchema.optional(),
769
1029
  skills: z.array(z.string()).optional(),
770
1030
  toolProfile: dagToolProfileSchema.optional(),
1031
+ /** Bounded read-only discovery budget for nodes that inspect a repository. */
1032
+ readBudget: z
1033
+ .object({
1034
+ maxFiles: z.number().int().positive(),
1035
+ maxBytes: z.number().int().positive(),
1036
+ maxMs: z.number().int().positive().optional(),
1037
+ /** Maximum read/grep/find/ls calls. */
1038
+ maxOperations: z.number().int().positive().optional(),
1039
+ /** On any read budget exhaustion, return concise completion guidance instead of failing the node. */
1040
+ onExhaustion: z.enum(["return-guidance"]).optional(),
1041
+ })
1042
+ .strict()
1043
+ .optional(),
1044
+ /**
1045
+ * Explicit Pi extension allowlist (backend implementation DAGs only):
1046
+ * frozen short ids resolved at run time against the Pi settings package
1047
+ * inventory. Omitted = extension discovery stays fully closed (R8.1).
1048
+ * Only `executor: "pi"` nodes may declare it (validated fail-closed).
1049
+ */
1050
+ piExtensions: dagPiExtensionsSchema.optional(),
771
1051
  /** Default deny: file write (toolProfile=write) does not grant command execution. */
772
1052
  commandPolicy: dagCommandPolicySchema.optional(),
773
1053
  writePolicy: dagWritePolicySchema.optional(),
774
1054
  writeSet: z.array(z.string()).optional(),
1055
+ /** Strict repository-relative read allowlist for bounded Pi nodes. */
1056
+ readSet: z.array(z.string()).optional(),
1057
+ /**
1058
+ * Online per-attempt Pi context guard. Unlike run/map cost budgets, this
1059
+ * aborts the active SDK session before an oversized conversation reaches
1060
+ * the provider's context rejection boundary.
1061
+ */
1062
+ contextBudget: z
1063
+ .object({
1064
+ maxTurns: z.number().int().positive().optional(),
1065
+ maxTokens: z.number().int().positive().optional(),
1066
+ })
1067
+ .strict()
1068
+ .refine((value) => value.maxTurns !== undefined || value.maxTokens !== undefined, "contextBudget requires maxTurns or maxTokens")
1069
+ .optional(),
775
1070
  piStep: z.string().optional(),
776
1071
  shell: dagShellConfigSchema.optional(),
777
1072
  static: dagStaticConfigSchema.optional(),
778
1073
  outputContract: z.string().optional(),
1074
+ /**
1075
+ * Frozen producer declarations for run-owned artifacts. These declarations,
1076
+ * together with consumesArtifacts, are the only authority for artifact
1077
+ * lineage and impact analysis. Prompt/outputContract/path heuristics are
1078
+ * intentionally forbidden.
1079
+ */
1080
+ producesArtifacts: z.array(dagProducedArtifactSchema).optional(),
1081
+ /** Frozen logical artifact inputs consumed by this node. */
1082
+ consumesArtifacts: z.array(dagConsumedArtifactSchema).optional(),
779
1083
  outputMode: dagOutputModeSchema.optional(),
780
1084
  firstProtocolLine: z.string().min(1).optional(),
781
1085
  /**
@@ -804,8 +1108,7 @@ export const dagTaskSchema = z.object({ id: z.string().regex(/^[a-z][a-z0-9-]*$/
804
1108
  })
805
1109
  .strict()
806
1110
  .superRefine((value, ctx) => {
807
- if (value.schemaId ===
808
- "frontend-implementation-contract-plan-patch-v1" &&
1111
+ if (value.schemaId === "frontend-implementation-contract-plan-patch-v1" &&
809
1112
  !value.skeleton) {
810
1113
  ctx.addIssue({
811
1114
  code: "custom",
@@ -845,6 +1148,14 @@ export const dagTaskSchema = z.object({ id: z.string().regex(/^[a-z][a-z0-9-]*$/
845
1148
  forbiddenPaths: z.array(z.string()).optional().default([]),
846
1149
  decisionGate: dagDecisionGateSchema.optional(),
847
1150
  retryPolicy: dagRetryPolicySchema.optional(),
1151
+ /**
1152
+ * Generation-path stamp for implicit same-run transient retry. Only the
1153
+ * three target templates stamp canonical final verify shells and
1154
+ * exclusive `implement-pi`. Zod-declared so parseDagSpec does not strip it.
1155
+ */
1156
+ transientRetryProfile: z
1157
+ .literal(TARGET_TEMPLATE_TRANSIENT_RETRY_PROFILE)
1158
+ .optional(),
848
1159
  /** Optional per-node adaptive liveness override (merged over defaults). */
849
1160
  livenessPolicy: dagLivenessPolicySchema,
850
1161
  dynamicExpansion: dagDynamicExpansionSchema.optional(),
@@ -852,6 +1163,121 @@ export const dagTaskSchema = z.object({ id: z.string().regex(/^[a-z][a-z0-9-]*$/
852
1163
  dynamicCondition: dagDynamicConditionSchema.optional(),
853
1164
  dynamicLoopUntil: dagDynamicLoopUntilSchema.optional(),
854
1165
  });
1166
+ function hasTransitiveDependency(tasksById, consumerNodeId, producerNodeId) {
1167
+ const queue = [...(tasksById.get(consumerNodeId)?.depends_on ?? [])];
1168
+ const seen = new Set();
1169
+ while (queue.length > 0) {
1170
+ const nodeId = queue.shift();
1171
+ if (nodeId === producerNodeId)
1172
+ return true;
1173
+ if (seen.has(nodeId))
1174
+ continue;
1175
+ seen.add(nodeId);
1176
+ queue.push(...(tasksById.get(nodeId)?.depends_on ?? []));
1177
+ }
1178
+ return false;
1179
+ }
1180
+ function validateFrozenArtifactBindings(tasks, ctx) {
1181
+ const tasksById = new Map(tasks.map((task) => [task.id, task]));
1182
+ const producers = new Map();
1183
+ const paths = new Map();
1184
+ for (const [taskIndex, task] of tasks.entries()) {
1185
+ const localIds = new Set();
1186
+ for (const [artifactIndex, artifact] of (task.producesArtifacts ?? []).entries()) {
1187
+ if (localIds.has(artifact.artifactId) ||
1188
+ producers.has(artifact.artifactId)) {
1189
+ ctx.addIssue({
1190
+ code: z.ZodIssueCode.custom,
1191
+ path: [
1192
+ "tasks",
1193
+ taskIndex,
1194
+ "producesArtifacts",
1195
+ artifactIndex,
1196
+ "artifactId",
1197
+ ],
1198
+ message: `artifact ${artifact.artifactId} must have exactly one producer`,
1199
+ });
1200
+ }
1201
+ else {
1202
+ producers.set(artifact.artifactId, {
1203
+ nodeId: task.id,
1204
+ taskIndex,
1205
+ artifactIndex,
1206
+ path: artifact.path,
1207
+ });
1208
+ }
1209
+ localIds.add(artifact.artifactId);
1210
+ const foldedPath = artifact.path
1211
+ .normalize("NFC")
1212
+ .toLocaleLowerCase("en-US");
1213
+ const existingArtifactId = paths.get(foldedPath);
1214
+ if (existingArtifactId && existingArtifactId !== artifact.artifactId) {
1215
+ ctx.addIssue({
1216
+ code: z.ZodIssueCode.custom,
1217
+ path: [
1218
+ "tasks",
1219
+ taskIndex,
1220
+ "producesArtifacts",
1221
+ artifactIndex,
1222
+ "path",
1223
+ ],
1224
+ message: `artifact path collides with ${existingArtifactId} under case folding`,
1225
+ });
1226
+ }
1227
+ else {
1228
+ paths.set(foldedPath, artifact.artifactId);
1229
+ }
1230
+ }
1231
+ }
1232
+ for (const [taskIndex, task] of tasks.entries()) {
1233
+ const consumed = new Set();
1234
+ for (const [artifactIndex, binding] of (task.consumesArtifacts ?? []).entries()) {
1235
+ if (consumed.has(binding.artifactId)) {
1236
+ ctx.addIssue({
1237
+ code: z.ZodIssueCode.custom,
1238
+ path: [
1239
+ "tasks",
1240
+ taskIndex,
1241
+ "consumesArtifacts",
1242
+ artifactIndex,
1243
+ "artifactId",
1244
+ ],
1245
+ message: `artifact ${binding.artifactId} is consumed more than once by ${task.id}`,
1246
+ });
1247
+ }
1248
+ consumed.add(binding.artifactId);
1249
+ const producer = producers.get(binding.artifactId);
1250
+ if (!producer) {
1251
+ ctx.addIssue({
1252
+ code: z.ZodIssueCode.custom,
1253
+ path: [
1254
+ "tasks",
1255
+ taskIndex,
1256
+ "consumesArtifacts",
1257
+ artifactIndex,
1258
+ "artifactId",
1259
+ ],
1260
+ message: `artifact ${binding.artifactId} has no declared producer`,
1261
+ });
1262
+ continue;
1263
+ }
1264
+ if (producer.nodeId === task.id ||
1265
+ !hasTransitiveDependency(tasksById, task.id, producer.nodeId)) {
1266
+ ctx.addIssue({
1267
+ code: z.ZodIssueCode.custom,
1268
+ path: [
1269
+ "tasks",
1270
+ taskIndex,
1271
+ "consumesArtifacts",
1272
+ artifactIndex,
1273
+ "artifactId",
1274
+ ],
1275
+ message: `consumer ${task.id} must be downstream of producer ${producer.nodeId}`,
1276
+ });
1277
+ }
1278
+ }
1279
+ }
1280
+ }
855
1281
  export const dagModelsSchema = z
856
1282
  .object({
857
1283
  HIGH: z.string().optional(),
@@ -878,20 +1304,98 @@ export const dagEvaluationBindingSchema = z
878
1304
  .strict();
879
1305
  /** Eval Lab Campaign Budget (W3.4); enforced by runner ledger when mode=hard. */
880
1306
  export const dagBudgetSchema = campaignBudgetSchema;
881
- export const dagSourceBindingSchema = z.object({
1307
+ export const dagSourceBindingSourceSchema = z.object({
1308
+ kind: z.enum(["requirement", "constraint", "reference"]),
1309
+ path: z.string().min(1),
1310
+ sha256: z.string().regex(/^[a-f0-9]{64}$/, "sha256 must be lowercase hex"),
1311
+ });
1312
+ /**
1313
+ * DagSourceBinding v1:无 ledger 字段(schemaVersion=1,.strict() 拒绝 ledger
1314
+ * 字段混入,不得以 v1+optional 冒充 v2)。非 frontend task / 无可解析引用时使用。
1315
+ */
1316
+ export const dagSourceBindingV1Schema = z
1317
+ .object({
882
1318
  schemaVersion: z.literal(1),
883
1319
  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),
1320
+ sources: z.array(dagSourceBindingSourceSchema).min(1),
893
1321
  requirementIds: z.array(z.string().regex(/^(?:REQ|BR|AC)-[A-Z0-9]+(?:-[A-Z0-9]+)*$/)),
894
- });
1322
+ })
1323
+ .strict();
1324
+ /**
1325
+ * DagSourceBinding v2(20260824-frontend-source-fidelity-ledger-v1):仅
1326
+ * frontend-implementation 且存在可解析 requirement/acceptance 引用时产出;
1327
+ * ledgerPath/ledgerSha256/inputDigest/requirementToFragments 全部必填且完整,
1328
+ * 伪造或缺失任一字段被 schema/prewrite 拒绝(AC-002 / AC-FIDELITY-REPAIR-002)。
1329
+ */
1330
+ export const dagSourceBindingV2Schema = z
1331
+ .object({
1332
+ schemaVersion: z.literal(2),
1333
+ taskId: z.string().min(1),
1334
+ sources: z.array(dagSourceBindingSourceSchema).min(1),
1335
+ requirementIds: z.array(z.string().regex(/^(?:REQ|BR|AC)-[A-Z0-9]+(?:-[A-Z0-9]+)*$/)),
1336
+ /** 受管 requirement-ledger.json 的 DAG 可解析路径(.harness/tasks/…/source/…)。 */
1337
+ ledgerPath: z.string().min(1),
1338
+ ledgerSha256: z.string().regex(/^[a-f0-9]{64}$/),
1339
+ inputDigest: z.string().regex(/^[a-f0-9]{64}$/),
1340
+ requirementToFragments: z.record(z.string(), z.array(z.string())),
1341
+ })
1342
+ .strict();
1343
+ export const dagSourceBindingSchema = z.discriminatedUnion("schemaVersion", [
1344
+ dagSourceBindingV1Schema,
1345
+ dagSourceBindingV2Schema,
1346
+ ]);
1347
+ export function isDagSourceBindingV2(binding) {
1348
+ return binding.schemaVersion === 2;
1349
+ }
1350
+ const dagRerunFeedbackEvidencePathSchema = z
1351
+ .string()
1352
+ .min(1)
1353
+ .refine((value) => !/^(?:[A-Za-z]:[\\/]|[\\/]{2}|\/)/.test(value), "rerun feedback evidence paths must be repository-relative");
1354
+ /**
1355
+ * Bounded unresolved verify/review feedback carried by a full task rerun.
1356
+ * This is recovery context, not a mutation of the original task contract.
1357
+ */
1358
+ export const dagRerunFeedbackSchema = z
1359
+ .object({
1360
+ schemaVersion: z.literal(1),
1361
+ kind: z.literal("unresolved-terminal-feedback"),
1362
+ parentRunId: z.string().min(1),
1363
+ taskId: z.string().min(1),
1364
+ sourceNodeId: z.string().min(1),
1365
+ verdict: z.enum(["request-revision", "fail"]).optional(),
1366
+ failureCategory: z.string().min(1).optional(),
1367
+ feedbackText: z.string().min(1).max(12_000),
1368
+ evidenceRefs: z
1369
+ .array(z
1370
+ .object({
1371
+ nodeId: z.string().min(1),
1372
+ preservedNodeRecordPath: dagRerunFeedbackEvidencePathSchema,
1373
+ })
1374
+ .strict())
1375
+ .max(8),
1376
+ attemptSummary: z
1377
+ .object({
1378
+ completedPasses: z.number().int().positive(),
1379
+ maxPasses: z.number().int().positive(),
1380
+ terminalReason: z.string().min(1).optional(),
1381
+ })
1382
+ .strict(),
1383
+ binding: z
1384
+ .object({
1385
+ sourceCanonicalHash: z
1386
+ .string()
1387
+ .regex(/^[a-f0-9]{64}$/)
1388
+ .optional(),
1389
+ taskContractCanonicalHash: z
1390
+ .string()
1391
+ .regex(/^[a-f0-9]{64}$/)
1392
+ .optional(),
1393
+ status: z.enum(["exact", "changed", "unknown"]),
1394
+ })
1395
+ .strict(),
1396
+ digest: z.string().regex(/^[a-f0-9]{64}$/),
1397
+ })
1398
+ .strict();
895
1399
  export const dagSpecSchema = z
896
1400
  .object({
897
1401
  version: dagVersionSchema,
@@ -903,6 +1407,26 @@ export const dagSpecSchema = z
903
1407
  sourceBinding: dagSourceBindingSchema.optional(),
904
1408
  /** v4 managed Task Contract binding; only valid on version 4. */
905
1409
  taskContractBinding: dagTaskContractBindingSchema.optional(),
1410
+ /** Optional unresolved parent-run feedback for a full task rerun. */
1411
+ rerunFeedback: dagRerunFeedbackSchema.optional(),
1412
+ /** Frontend recovery continuation quota (frozen at generation time from
1413
+ * task.json frontendRecovery.maxContinuations). Bounds how many times a
1414
+ * failed frontend run may auto-recover via M6 recovery operations before
1415
+ * the run stays failed and needs human intervention. */
1416
+ frontendRecovery: z
1417
+ .object({
1418
+ maxContinuations: z
1419
+ .number()
1420
+ .int()
1421
+ .min(1)
1422
+ .max(5)
1423
+ .optional()
1424
+ .default(1),
1425
+ })
1426
+ .strict()
1427
+ .optional(),
1428
+ /** Backend-test-only workspace mutation control; absent means Git. */
1429
+ backendTestWorkspaceControl: z.enum(["git", "filesystem-only"]).optional(),
906
1430
  /** Frozen backend-test artifact layout (plan A); absent = historical default testcase/ layout. */
907
1431
  backendTestLayout: z
908
1432
  .object({
@@ -915,6 +1439,18 @@ export const dagSpecSchema = z
915
1439
  isDefault: z.boolean(),
916
1440
  })
917
1441
  .optional(),
1442
+ /** Frozen frontend-test artifact layout; absent = historical testcase/frontend/ layout. */
1443
+ frontendTestLayout: z
1444
+ .object({
1445
+ testRoot: z.string(),
1446
+ ragDir: z.string(),
1447
+ casesDir: z.string(),
1448
+ evidenceDir: z.string(),
1449
+ reportsDir: z.string(),
1450
+ fixturesDir: z.string(),
1451
+ isDefault: z.boolean(),
1452
+ })
1453
+ .optional(),
918
1454
  /** Bound user shared-setup document (plan B); absent = no shared setup references expected. */
919
1455
  backendTestSharedSetup: z
920
1456
  .object({
@@ -938,6 +1474,7 @@ export const dagSpecSchema = z
938
1474
  })
939
1475
  .superRefine((spec, ctx) => {
940
1476
  const supportsV3Fields = spec.version === 3 || spec.version === 4;
1477
+ validateFrozenArtifactBindings(spec.tasks, ctx);
941
1478
  if (spec.evaluation && !supportsV3Fields) {
942
1479
  ctx.addIssue({
943
1480
  code: z.ZodIssueCode.custom,
@@ -1014,6 +1551,9 @@ export const FRONTEND_RECOVERY_RESULT_SCHEMA_VERSION = 1;
1014
1551
  * Phase 3a parents converge first, so `rollback-pending` is not produced and
1015
1552
  * was removed by AC-1; the phase starts at `child-staging` and ends at
1016
1553
  * `settled`.
1554
+ *
1555
+ * @deprecated Read-only compatibility only; the M6 operation controller no
1556
+ * longer uses this phase as the authoritative recovery entry point.
1017
1557
  */
1018
1558
  export const frontendRecoveryPhaseSchema = z.enum([
1019
1559
  "child-staging",
@@ -1027,12 +1567,16 @@ export const frontendRecoveryPhaseSchema = z.enum([
1027
1567
  * the child carries a frozen lineage snapshot so the activation gate can prove
1028
1568
  * it is the reserved child of a child-running parent.
1029
1569
  *
1030
- * Invariants: `attemptIndex ∈ {0,1}`; `continuationCount ∈ {0,1}`; a child's
1570
+ * Invariants: `attemptIndex` and `continuationCount` are bounded by the frozen
1571
+ * frontend recovery quota (currently 1-5); a child's
1031
1572
  * `recoveryRootRunId` always equals the root runId; `revision` is the CAS
1032
1573
  * pre-comparison counter. `revision` monotonicity is enforced at runtime by the
1033
1574
  * runner's `(existing?.revision ?? 0) + 1` CAS write (the schema only bounds it
1034
1575
  * non-negative). `childRunId` may be absent through `child-activating` and must
1035
1576
  * be non-empty from `child-running` onward.
1577
+ *
1578
+ * @deprecated Read-only compatibility only; the runner no longer writes this
1579
+ * intent (the M6 operation controller supervises recovery instead).
1036
1580
  */
1037
1581
  export const frontendRecoveryStateSchema = z
1038
1582
  .object({
@@ -1043,8 +1587,8 @@ export const frontendRecoveryStateSchema = z
1043
1587
  parentRunId: z.string().min(1),
1044
1588
  childRunId: z.string().min(1).optional(),
1045
1589
  attemptId: z.string().min(1),
1046
- attemptIndex: z.number().int().min(0).max(1),
1047
- continuationCount: z.number().int().min(0).max(1),
1590
+ attemptIndex: z.number().int().min(0).max(5),
1591
+ continuationCount: z.number().int().min(0).max(5),
1048
1592
  /** Node id of the reset-closure root: frontend-plan-pi /
1049
1593
  * frontend-plan-revision-pi / frontend-prewrite-gate-shell /
1050
1594
  * frontend-implement-pi (writer partial write). */
@@ -1104,6 +1648,10 @@ export const frontendRecoveryEvidenceRefSchema = z
1104
1648
  * stays permissive (failureClass optional, evidenceRefs may be empty) so it
1105
1649
  * accepts the runner's actual phase-3a products, which do not always carry a
1106
1650
  * failure class or evidence reference.
1651
+ *
1652
+ * @deprecated Read-only compatibility only; the M6 operation controller writes
1653
+ * `recovered`/`auto-recovery-blocked` results directly and never uses this
1654
+ * schema as the authoritative recovery settlement.
1107
1655
  */
1108
1656
  export const frontendRecoveryResultSchema = z
1109
1657
  .object({