@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
@@ -5,8 +5,10 @@ import path from "node:path";
5
5
  import { z } from "zod";
6
6
  import YAML from "yaml";
7
7
  import { resolveBackendTestLayout, } from "./backend-test-layout.js";
8
- import { assessScenarioPartitionCoverage, parseScenarioPartitions, } from "./backend-test-scenario-partitions.js";
8
+ import { resolveBackendTestManifestModules, backendManifestStatusFinding } from "./backend-test-markdown-workflow.js";
9
+ import { applyOpenApiPartitionDomainPolicy, assessScenarioPartitionCoverage, parseScenarioPartitions, } from "./backend-test-scenario-partitions.js";
9
10
  import { backendTestCaseManifestSchema, computeCaseManifestCoverageSummary, } from "./backend-test-case-manifest.js";
11
+ import { inferScenarioParamIntent } from "./backend-test-scenario-param.js";
10
12
  const CASE_HEADING = /^##\s+(BE-[A-Z0-9_-]+-\d{3})\b.*$/gm;
11
13
  const CASE_ID_IN_TEXT = /\bBE-[A-Z0-9_-]+-\d{3}\b/g;
12
14
  const NON_CANONICAL_CASE_HEADING = /^##\s+(BE-[A-Z0-9_-]+-(?:\d{2}|\d{2,3}[A-Z]+))\b.*$/gm;
@@ -280,6 +282,87 @@ export const backendTestMarkdownPytestCorrespondenceFactsSchema = z.object({
280
282
  entries: z.array(correspondenceEntrySchema),
281
283
  findings: z.array(z.string()),
282
284
  }).strict();
285
+ function bindingCounts(entry) {
286
+ const counts = new Map();
287
+ for (const point of [...entry.variantTestPoints, ...entry.assertionTestPoints, ...entry.crossCuttingTestPoints]) {
288
+ counts.set(point, (counts.get(point) ?? 0) + 1);
289
+ }
290
+ return counts;
291
+ }
292
+ /**
293
+ * Classify correspondence defects by the only writer that can safely repair
294
+ * them. Markdown-owned contract defects must be fixed before pytest generation;
295
+ * pytest-owned generated-asset defects may enter the single bounded N11 repair.
296
+ */
297
+ export function classifyBackendTestCorrespondenceRepair(facts, layout) {
298
+ const resolved = layout ?? resolveBackendTestLayout(undefined);
299
+ const scriptRoot = resolved.scriptDir.replace(/\/$/, "");
300
+ const safePytestPath = (candidate) => {
301
+ const normalized = candidate.replaceAll("\\", "/").replace(/^\.\//, "");
302
+ return normalized.endsWith(".py") && (normalized === scriptRoot || normalized.startsWith(`${scriptRoot}/`));
303
+ };
304
+ const markdownBlockingEntries = [];
305
+ const pytestRepairEntries = [];
306
+ for (const entry of facts.entries) {
307
+ const markdownReasons = [];
308
+ const pytestReasons = [];
309
+ const counts = bindingCounts(entry);
310
+ if (entry.cardinality !== "0:1" &&
311
+ entry.testPoints.some((point) => (counts.get(point) ?? 0) !== 1)) {
312
+ // Only ### 测试点 inventory must be bound exactly once. Extra
313
+ // automation-mapping TPs (typical: 横切 listed only under 跨切证据)
314
+ // are pytest-owned docstring/repair defects, not Markdown BLOCKED.
315
+ markdownReasons.push("markdown-test-point-binding-invalid");
316
+ }
317
+ if (entry.declaredScript && entry.declaredScript !== entry.expectedScript) {
318
+ markdownReasons.push("markdown-script-declaration-invalid");
319
+ }
320
+ const evidenceOnly = isEvidenceOnlyCorrespondenceEntry(entry);
321
+ if (!evidenceOnly && entry.cardinality === "1:0")
322
+ pytestReasons.push("missing-pytest-symbol");
323
+ if (entry.cardinality === "1:N")
324
+ pytestReasons.push("multiple-pytest-symbols");
325
+ if (entry.cardinality === "0:1")
326
+ pytestReasons.push("extra-pytest-symbol");
327
+ if (entry.actualScripts.some((script) => script !== entry.expectedScript))
328
+ pytestReasons.push("pytest-script-mismatch");
329
+ if (entry.declaredPrimarySymbol && entry.pytestSymbols.some((symbol) => symbol !== entry.declaredPrimarySymbol)) {
330
+ pytestReasons.push("pytest-primary-symbol-mismatch");
331
+ }
332
+ if (!evidenceOnly && entry.variantTestPoints.some((point) => !entry.parameterIds.includes(point))) {
333
+ pytestReasons.push("variant-parameter-missing");
334
+ }
335
+ if (!evidenceOnly && entry.assertionTestPoints.some((point) => !entry.mappedTestPoints.includes(point))) {
336
+ pytestReasons.push("assertion-binding-missing");
337
+ }
338
+ if (!evidenceOnly && entry.crossCuttingTestPoints.some((point) => !entry.mappedTestPoints.includes(point))) {
339
+ pytestReasons.push("cross-cutting-binding-missing");
340
+ }
341
+ if (entry.parameterIds.some((point) => !entry.testPoints.includes(point)))
342
+ pytestReasons.push("pytest-test-point-binding-extra");
343
+ if (entry.payloadAssessment.status === "UNSAFE")
344
+ pytestReasons.push("pytest-payload-shape-mismatch");
345
+ if (entry.status !== "EXACT_1_TO_1" &&
346
+ !["TEST_POINT_BINDING_DUPLICATE", "PAYLOAD_CONTRACT_UNAVAILABLE"].includes(entry.status)) {
347
+ pytestReasons.push(`correspondence-${entry.status.toLowerCase().replaceAll("_", "-")}`);
348
+ }
349
+ if (entry.status === "PAYLOAD_CONTRACT_UNAVAILABLE" && entry.cardinality !== "0:1") {
350
+ markdownReasons.push("markdown-payload-contract-unavailable");
351
+ }
352
+ const paths = orderedUnique([entry.expectedScript, ...entry.actualScripts].filter(safePytestPath));
353
+ if (markdownReasons.length > 0) {
354
+ markdownBlockingEntries.push({ ...(entry.caseId ? { caseId: entry.caseId } : {}), reasonCodes: orderedUnique(markdownReasons), paths });
355
+ }
356
+ if (pytestReasons.length > 0 && paths.length > 0) {
357
+ pytestRepairEntries.push({ ...(entry.caseId ? { caseId: entry.caseId } : {}), reasonCodes: orderedUnique(pytestReasons), paths });
358
+ }
359
+ }
360
+ return {
361
+ markdownBlockingEntries,
362
+ pytestRepairEntries,
363
+ pytestRepairPaths: orderedUnique(pytestRepairEntries.flatMap((entry) => entry.paths)).sort(),
364
+ };
365
+ }
283
366
  function isRecord(value) {
284
367
  return typeof value === "object" && value !== null && !Array.isArray(value);
285
368
  }
@@ -486,6 +569,55 @@ export async function extractBackendTestOpenApiRules(input) {
486
569
  }
487
570
  return rules.sort((left, right) => left.ruleKey.localeCompare(right.ruleKey));
488
571
  }
572
+ export async function extractBackendTestOpenApiPartitionAxes(input) {
573
+ const axes = [];
574
+ const seen = new Set();
575
+ for (const referencePath of input.sourceBinding.referencePaths) {
576
+ const physicalPath = resolveBoundSourcePath(input.workspaceRoot, input.sourceBinding.taskId, referencePath);
577
+ let document;
578
+ try {
579
+ const parsed = YAML.parse(await readFile(physicalPath, "utf8"));
580
+ if (!isRecord(parsed) || !isRecord(parsed.paths))
581
+ continue;
582
+ document = parsed;
583
+ }
584
+ catch {
585
+ continue;
586
+ }
587
+ for (const [apiPath, pathItem] of Object.entries(document.paths)) {
588
+ if (!isRecord(pathItem))
589
+ continue;
590
+ const operation = pathItem.get;
591
+ if (!isRecord(operation))
592
+ continue;
593
+ const parameterValues = [
594
+ ...(Array.isArray(pathItem.parameters) ? pathItem.parameters : []),
595
+ ...(Array.isArray(operation.parameters) ? operation.parameters : []),
596
+ ];
597
+ for (const rawParameter of parameterValues) {
598
+ const parameter = resolveOpenApiSchema(document, rawParameter);
599
+ if (!parameter || typeof parameter.name !== "string")
600
+ continue;
601
+ const location = parameter.in === "path" ? "path" : parameter.in === "query" ? "query" : undefined;
602
+ if (!location)
603
+ continue;
604
+ const property = resolveOpenApiSchema(document, parameter.schema);
605
+ const enumValues = property && Array.isArray(property.enum) ? property.enum.map(String) : null;
606
+ const identity = `GET ${apiPath}|${location}|${parameter.name}`;
607
+ if (seen.has(identity))
608
+ continue;
609
+ seen.add(identity);
610
+ axes.push({
611
+ operation: `GET ${apiPath}`,
612
+ name: parameter.name,
613
+ in: location,
614
+ enumValues,
615
+ });
616
+ }
617
+ }
618
+ }
619
+ return axes;
620
+ }
489
621
  function orderedUnique(values) {
490
622
  const result = [];
491
623
  const seen = new Set();
@@ -543,6 +675,105 @@ function automationLabelBody(body, labels) {
543
675
  const match = new RegExp(`^\\s*[-*+]\\s*(?:${escaped})\\s*[::]\\s*(.*)$`, "mi").exec(automation);
544
676
  return match?.[1]?.replaceAll("`", "").trim() ?? "";
545
677
  }
678
+ const BINDING_NEGATION_OR_AMBIGUITY = /(?:不是|并非|非变体|非断言|非横切|可能|待定|或者|\b(?:TBD|unknown)\b)/i;
679
+ function explicitBindingModeFromLine(line) {
680
+ if (BINDING_NEGATION_OR_AMBIGUITY.test(line))
681
+ return undefined;
682
+ const modes = TEST_POINT_BINDING_MODES.filter((mode) => AUTOMATION_BINDING_LABELS[mode].some((label) => line.includes(label)));
683
+ return modes.length === 1 ? modes[0] : undefined;
684
+ }
685
+ /**
686
+ * Canonicalize only explicit, unambiguous Test Point classification marks.
687
+ * The model occasionally writes `TP-X(变体测试点)`, `[场景断言测试点] TP-X`
688
+ * or a pipe-delimited equivalent. Those forms carry deterministic semantics,
689
+ * but are not the machine contract consumed by automationLabelBody(). Keep the
690
+ * original prose and materialize the same binding under `### 自动化映射` as the
691
+ * canonical single-line labels. Never infer a mode from ordinary prose.
692
+ */
693
+ export function canonicalizeBackendTestMarkdownTestPointBindings(markdown) {
694
+ const headings = [...markdown.matchAll(CASE_HEADING)];
695
+ let output = "";
696
+ let cursor = 0;
697
+ const unsafeTestPoints = [];
698
+ const canonicalizedTestPoints = [];
699
+ for (let index = 0; index < headings.length; index += 1) {
700
+ const heading = headings[index];
701
+ const start = heading.index;
702
+ const end = headings[index + 1]?.index ?? markdown.length;
703
+ const body = markdown.slice(start, end);
704
+ output += markdown.slice(cursor, start);
705
+ cursor = end;
706
+ const declared = listTokens(body, CASE_SECTION_ALIASES.testPoints, TEST_POINT);
707
+ const current = testPointBindingFacts(body, declared);
708
+ const currentByMode = new Map(TEST_POINT_BINDING_MODES.map((mode) => [
709
+ mode,
710
+ current.testPointBindings.filter((item) => item.mode === mode).map((item) => item.testPoint),
711
+ ]));
712
+ const unresolved = new Set(current.unclassifiedTestPoints);
713
+ for (const line of body.split(/\r?\n/)) {
714
+ const mode = explicitBindingModeFromLine(line);
715
+ if (!mode)
716
+ continue;
717
+ const tokens = orderedUnique(line.match(/\bTP-[A-Z0-9]+(?:-[A-Z0-9]+)*\b/g) ?? []);
718
+ for (const token of tokens) {
719
+ if (!unresolved.has(token))
720
+ continue;
721
+ const existingModes = TEST_POINT_BINDING_MODES.filter((candidate) => (currentByMode.get(candidate) ?? []).includes(token));
722
+ if (existingModes.length > 0)
723
+ continue;
724
+ currentByMode.set(mode, orderedUnique([...(currentByMode.get(mode) ?? []), token]));
725
+ unresolved.delete(token);
726
+ canonicalizedTestPoints.push(token);
727
+ }
728
+ }
729
+ unsafeTestPoints.push(...unresolved);
730
+ if (unresolved.size === current.unclassifiedTestPoints.length) {
731
+ output += body;
732
+ continue;
733
+ }
734
+ const automationMarker = /^###\s+(?:自动化映射|Automation Mapping)\s*$/mi.exec(body);
735
+ if (!automationMarker) {
736
+ output += body;
737
+ continue;
738
+ }
739
+ const automationStart = automationMarker.index + automationMarker[0].length;
740
+ const rest = body.slice(automationStart);
741
+ const nextSection = /^###\s+/m.exec(rest);
742
+ const automationEnd = automationStart + (nextSection?.index ?? rest.length);
743
+ let automation = body.slice(automationStart, automationEnd);
744
+ for (const mode of TEST_POINT_BINDING_MODES) {
745
+ const labels = AUTOMATION_BINDING_LABELS[mode];
746
+ const escaped = labels.map((label) => label.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
747
+ const canonicalLine = `- ${AUTOMATION_BINDING_LABELS[mode][0]}:${(currentByMode.get(mode) ?? []).join("; ") || "无"}`;
748
+ const linePattern = new RegExp(`^\\s*[-*+]\\s*(?:${escaped})\\s*[::].*$`, "mi");
749
+ if (linePattern.test(automation))
750
+ automation = automation.replace(linePattern, canonicalLine);
751
+ else
752
+ automation = `${automation.replace(/\s*$/, "")}\n${canonicalLine}\n`;
753
+ }
754
+ output += body.slice(0, automationStart) + automation + body.slice(automationEnd);
755
+ }
756
+ output += markdown.slice(cursor);
757
+ return {
758
+ markdown: output,
759
+ changed: output !== markdown,
760
+ unsafeTestPoints: orderedUnique(unsafeTestPoints),
761
+ canonicalizedTestPoints: orderedUnique(canonicalizedTestPoints),
762
+ };
763
+ }
764
+ export function inspectBackendTestMarkdownTestPointBindings(markdown) {
765
+ const headings = [...markdown.matchAll(CASE_HEADING)];
766
+ return headings.map((heading, index) => {
767
+ const body = markdown.slice(heading.index, headings[index + 1]?.index ?? markdown.length);
768
+ const testPoints = listTokens(body, CASE_SECTION_ALIASES.testPoints, TEST_POINT);
769
+ const bindings = testPointBindingFacts(body, testPoints);
770
+ return {
771
+ caseId: canonicalCaseId(heading[1]),
772
+ unclassifiedTestPoints: bindings.unclassifiedTestPoints,
773
+ duplicateBindingTestPoints: bindings.duplicateBindingTestPoints,
774
+ };
775
+ });
776
+ }
546
777
  function testPointBindingFacts(body, testPoints) {
547
778
  const bindings = TEST_POINT_BINDING_MODES.flatMap((mode) => {
548
779
  const value = automationLabelBody(body, AUTOMATION_BINDING_LABELS[mode]);
@@ -572,12 +803,26 @@ function isEvidenceOnlyMarkdownCase(testCase) {
572
803
  !hasVariant &&
573
804
  hasNonVariant);
574
805
  }
806
+ function isEvidenceOnlyCorrespondenceEntry(entry) {
807
+ return (entry.status === "EXACT_1_TO_1" &&
808
+ entry.cardinality === "1:0" &&
809
+ !entry.declaredScript &&
810
+ !entry.declaredPrimarySymbol &&
811
+ entry.variantTestPoints.length === 0 &&
812
+ (entry.assertionTestPoints.length > 0 || entry.crossCuttingTestPoints.length > 0) &&
813
+ entry.pytestSymbols.length === 0 &&
814
+ entry.actualScripts.length === 0);
815
+ }
575
816
  function payloadContract(body) {
576
817
  const contractValue = automationLabelBody(body, ["Payload Contract", "载荷合同"]);
577
818
  const requiredValue = automationLabelBody(body, ["Payload Required Paths", "载荷必需路径"]);
578
819
  const allowedValue = automationLabelBody(body, ["Payload Allowed Paths", "载荷允许路径"]);
579
820
  const enumValue = automationLabelBody(body, ["Payload Enum", "载荷枚举"]);
580
- const tokens = (value) => orderedUnique(value.split(/[,;,;]/).map((item) => item.trim()).filter((item) => /^[A-Za-z_][A-Za-z0-9_.]*$/.test(item)));
821
+ const tokens = (value) => orderedUnique(value
822
+ .split(/[,;,;]/)
823
+ .map((item) => item.trim())
824
+ .filter((item) => !/^(?:none|无|not-applicable|n\/a|true|false)$/i.test(item))
825
+ .filter((item) => /^[A-Za-z_][A-Za-z0-9_.]*$/.test(item)));
581
826
  const enumValues = {};
582
827
  for (const assignment of enumValue.split(/[,;,;]/).map((item) => item.trim()).filter(Boolean)) {
583
828
  const match = /^([A-Za-z_][A-Za-z0-9_.]*)\s*(?:=|:)\s*(.+)$/.exec(assignment);
@@ -610,10 +855,18 @@ async function markdownModuleFiles(workspaceRoot, layout) {
610
855
  const resolved = layout ?? resolveBackendTestLayout(undefined);
611
856
  const dir = path.join(workspaceRoot, ...resolved.markdownDir.split("/"));
612
857
  const entries = await readdir(dir, { withFileTypes: true });
613
- return entries
858
+ const all = entries
614
859
  .filter((entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".md") && entry.name.toLowerCase() !== "readme.md")
615
860
  .map((entry) => path.join(dir, entry.name))
616
861
  .sort();
862
+ // Current-round Markdown scope is the README Module Index manifest: unmanifested
863
+ // legacy .md files must not enter Case/coverage/partition statistics. Workspaces
864
+ // without a Module Index fall back to the whole directory (prior behaviour).
865
+ const manifest = await resolveBackendTestManifestModules(workspaceRoot, resolved);
866
+ if (manifest.manifestStatus !== "valid")
867
+ return [];
868
+ const declaredAbs = new Set(manifest.declaredMdFiles.map((rel) => path.join(workspaceRoot, ...rel.split("/")).toLowerCase()));
869
+ return all.filter((file) => declaredAbs.has(file.toLowerCase())).sort();
617
870
  }
618
871
  async function parseMarkdownCases(workspaceRoot, layout) {
619
872
  const result = [];
@@ -825,6 +1078,16 @@ export async function analyzeBackendTestCaseCoverage(input) {
825
1078
  findings.push(...coverageScope.findings);
826
1079
  const matrix = parseCoverageMatrix(readme);
827
1080
  findings.push(...matrix.findings);
1081
+ const manifest = await resolveBackendTestManifestModules(input.workspaceRoot, layout);
1082
+ // Fail closed on README Module Index entries declared but never materialized.
1083
+ if (manifest.declaredMissing.length > 0) {
1084
+ findings.push(`declared Markdown module is missing (Module Index): ${manifest.declaredMissing.join(", ")}`);
1085
+ }
1086
+ // Fail closed on every non-valid Module Index state: without a valid unique
1087
+ // Module Index the current round must not re-scan historical `.md` files.
1088
+ if (manifest.manifestStatus !== "valid") {
1089
+ findings.push(backendManifestStatusFinding(manifest.manifestStatus, manifest.moduleIndexHeadingCount));
1090
+ }
828
1091
  const cases = await parseMarkdownCases(input.workspaceRoot, layout);
829
1092
  for (const file of await markdownModuleFiles(input.workspaceRoot, layout)) {
830
1093
  const markdown = await readFile(file, "utf8");
@@ -985,8 +1248,11 @@ export async function analyzeBackendTestCaseCoverage(input) {
985
1248
  // Plan C: deterministic query/filter axis partitions (fail-closed on missing slots).
986
1249
  const parsedPartitions = parseScenarioPartitions(readme);
987
1250
  findings.push(...parsedPartitions.issues);
1251
+ const openApiPartitionAxes = await extractBackendTestOpenApiPartitionAxes(input);
1252
+ const partitionedBySource = applyOpenApiPartitionDomainPolicy(parsedPartitions.partitions, openApiPartitionAxes);
1253
+ findings.push(...partitionedBySource.issues);
988
1254
  const declaredPointUniverse = new Set(cases.flatMap((item) => item.testPoints));
989
- const partitionAssessment = assessScenarioPartitionCoverage(parsedPartitions.partitions, declaredPointUniverse);
1255
+ const partitionAssessment = assessScenarioPartitionCoverage(partitionedBySource.partitions, declaredPointUniverse);
990
1256
  findings.push(...partitionAssessment.findings);
991
1257
  const [enumValueCount, coveredEnumValueCount] = dimensionCounts(rules, /enum/);
992
1258
  const [boundaryPointCount, coveredBoundaryPointCount] = dimensionCounts(rules, /boundary|length|numeric/);
@@ -1003,7 +1269,7 @@ export async function analyzeBackendTestCaseCoverage(input) {
1003
1269
  sourceBinding: input.sourceBinding,
1004
1270
  inputFiles: await inputFileFacts(input.workspaceRoot, [
1005
1271
  ...((await exists(readmePath)) ? [readmePath] : []),
1006
- ...(await markdownModuleFiles(input.workspaceRoot)),
1272
+ ...(await markdownModuleFiles(input.workspaceRoot, layout)),
1007
1273
  ...(await Promise.all(input.sourceBinding.referencePaths.map(async (referencePath) => {
1008
1274
  const physicalPath = resolveBoundSourcePath(input.workspaceRoot, input.sourceBinding.taskId, referencePath);
1009
1275
  return (await exists(physicalPath)) ? physicalPath : "";
@@ -1057,6 +1323,15 @@ export async function analyzeBackendTestCaseCoverage(input) {
1057
1323
  "",
1058
1324
  facts.status,
1059
1325
  "",
1326
+ `- Manifest scope: ${manifest.manifestStatus === "valid" ? "declared-modules" : `fails-closed:${manifest.manifestStatus}`} (declared-missing=${manifest.declaredMissing.length}, unmanifested-advisory=${manifest.unmanifested.length}, module-index-heading-count=${manifest.moduleIndexHeadingCount})`,
1327
+ "",
1328
+ "## Unmanifested Markdown Modules",
1329
+ "",
1330
+ "- Advisory: existing .md files not declared by the README Module Index are excluded from Case/coverage/partition statistics for this round.",
1331
+ ...(manifest.unmanifested.length > 0
1332
+ ? manifest.unmanifested.map((item) => `- ${item}`)
1333
+ : ["- None"]),
1334
+ "",
1060
1335
  "## Coverage Scope",
1061
1336
  "",
1062
1337
  `- Change Classification: ${facts.coverageScope.changeClassification}`,
@@ -1140,8 +1415,16 @@ export async function analyzeBackendTestCaseCoverage(input) {
1140
1415
  function normalizeModuleStem(markdownPath) {
1141
1416
  return path.posix.basename(markdownPath).replace(/\.md$/i, "").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").replace(/_+/g, "_");
1142
1417
  }
1143
- function expectedScript(markdownPath, layout) {
1418
+ function expectedScript(markdownPath, layout, declaredScripts = []) {
1144
1419
  const resolved = layout ?? resolveBackendTestLayout(undefined);
1420
+ if (declaredScripts.length === 1) {
1421
+ const candidate = declaredScripts[0].replaceAll("\\", "/").replace(/^\.\//, "");
1422
+ const prefix = resolved.scriptDir === "." ? "" : `${resolved.scriptDir}/`;
1423
+ const relative = prefix && candidate.startsWith(prefix) ? candidate.slice(prefix.length) : candidate;
1424
+ if ((!prefix || candidate.startsWith(prefix)) && !relative.includes("..") && /^test_[A-Za-z0-9_.-]+\.py$/.test(path.posix.basename(candidate))) {
1425
+ return candidate;
1426
+ }
1427
+ }
1145
1428
  return `${resolved.scriptDir}/test_${normalizeModuleStem(markdownPath)}.py`;
1146
1429
  }
1147
1430
  function symbolCaseId(symbol) {
@@ -1197,8 +1480,15 @@ for top in ast.walk(tree):
1197
1480
  returned_names.add(node.value.id)
1198
1481
  if isinstance(node,ast.Call):
1199
1482
  for keyword in node.keywords:
1200
- if keyword.arg in {'payload','body','request_body','request_json','dto','json','data','json_body'} and isinstance(keyword.value,ast.Name) and keyword.value.id in positional:
1483
+ if keyword.arg in {'payload','body','request_body','request_json','dto','json','data','json_body','params','query','query_params'} and isinstance(keyword.value,ast.Name) and keyword.value.id in positional:
1201
1484
  transport.append((keyword.value.id,positional.index(keyword.value.id)-call_offset))
1485
+ if keyword.arg is None and isinstance(keyword.value,ast.Name):
1486
+ alias=keyword.value.id
1487
+ assigned_value=assigned.get(alias)
1488
+ if isinstance(assigned_value,ast.Name) and assigned_value.id in positional:
1489
+ transport.append((assigned_value.id,positional.index(assigned_value.id)-call_offset))
1490
+ elif isinstance(assigned_value,ast.Call) and isinstance(assigned_value.func,ast.Name) and assigned_value.func.id == 'dict' and assigned_value.args and isinstance(assigned_value.args[0],ast.Name) and assigned_value.args[0].id in positional:
1491
+ transport.append((assigned_value.args[0].id,positional.index(assigned_value.args[0].id)-call_offset))
1202
1492
  if isinstance(node.func,ast.Attribute) and node.func.attr.lower() in {'post','put','patch'} and len(node.args) >= 2:
1203
1493
  candidate=node.args[1]
1204
1494
  if isinstance(candidate,ast.Name) and candidate.id in positional:
@@ -1210,6 +1500,17 @@ for top in ast.walk(tree):
1210
1500
  matched=node.args[nested_position] if nested_position >= 0 and nested_position < len(node.args) else None
1211
1501
  if isinstance(matched,ast.Name) and matched.id in positional:
1212
1502
  transport.append((matched.id,positional.index(matched.id)-call_offset))
1503
+ # Assignment order in ast.walk is not source order. Re-scan **kwargs
1504
+ # aliases once the complete local assignment table is available.
1505
+ for node in ast.walk(top):
1506
+ if not isinstance(node,ast.Call): continue
1507
+ for keyword in node.keywords:
1508
+ if keyword.arg is not None or not isinstance(keyword.value,ast.Name): continue
1509
+ assigned_value=assigned.get(keyword.value.id)
1510
+ if isinstance(assigned_value,ast.Name) and assigned_value.id in positional:
1511
+ transport.append((assigned_value.id,positional.index(assigned_value.id)-call_offset))
1512
+ elif isinstance(assigned_value,ast.Call) and isinstance(assigned_value.func,ast.Name) and assigned_value.func.id == 'dict' and assigned_value.args and isinstance(assigned_value.args[0],ast.Name) and assigned_value.args[0].id in positional:
1513
+ transport.append((assigned_value.args[0].id,positional.index(assigned_value.args[0].id)-call_offset))
1213
1514
  for returned_name in returned_names:
1214
1515
  entries=mutated.get(returned_name,[])
1215
1516
  if entries:
@@ -1218,7 +1519,7 @@ for top in ast.walk(tree):
1218
1519
  for node in ast.walk(top):
1219
1520
  if not isinstance(node,ast.Call): continue
1220
1521
  for keyword in node.keywords:
1221
- if keyword.arg in {'payload','body','request_body','request_json','dto','json','data','json_body'} and isinstance(keyword.value,ast.Name) and keyword.value.id in assigned:
1522
+ if keyword.arg in {'payload','body','request_body','request_json','dto','json','data','json_body','params','query','query_params'} and isinstance(keyword.value,ast.Name) and keyword.value.id in assigned:
1222
1523
  transport_shapes.append(assigned[keyword.value.id])
1223
1524
  if candidates: FUNCTION_PAYLOADS[top.name]=candidates
1224
1525
  if transport_shapes: FUNCTION_TRANSPORT_SHAPES[top.name]=transport_shapes
@@ -1274,8 +1575,9 @@ def literal(node):
1274
1575
  return repr(node.value)
1275
1576
  return None
1276
1577
 
1277
- def collect_dict(node, prefix, paths, values):
1578
+ def collect_dict(node, prefix, paths, values, parameters=None):
1278
1579
  if not isinstance(node, ast.Dict): return
1580
+ parameters = parameters or {}
1279
1581
  for key,value in zip(node.keys,node.values):
1280
1582
  if not isinstance(key, ast.Constant) or not isinstance(key.value,str): continue
1281
1583
  # Ignore writer helper/meta keys that are not DTO request fields.
@@ -1285,12 +1587,16 @@ def collect_dict(node, prefix, paths, values):
1285
1587
  paths.add(current)
1286
1588
  lv=literal(value)
1287
1589
  if lv is not None: values.setdefault(current,set()).add(lv)
1288
- if isinstance(value, ast.Dict): collect_dict(value,current,paths,values)
1590
+ elif isinstance(value, ast.Name) and value.id in parameters:
1591
+ for bound in parameters[value.id]:
1592
+ bound_lv=literal(bound)
1593
+ if bound_lv is not None: values.setdefault(current,set()).add(bound_lv)
1594
+ if isinstance(value, ast.Dict): collect_dict(value,current,paths,values,parameters)
1289
1595
  elif isinstance(value,(ast.List,ast.Tuple)):
1290
1596
  for item in value.elts:
1291
- if isinstance(item,ast.Dict): collect_dict(item,current,paths,values)
1597
+ if isinstance(item,ast.Dict): collect_dict(item,current,paths,values,parameters)
1292
1598
 
1293
- PAYLOAD_NAMES={'payload','body','request_body','request_json','dto','json','data','json_body'}
1599
+ PAYLOAD_NAMES={'payload','body','request_body','request_json','dto','json','data','json_body','params','query','query_params'}
1294
1600
 
1295
1601
  def shape_only(node):
1296
1602
  if isinstance(node,ast.Dict):
@@ -1324,6 +1630,11 @@ def payload_expr_nodes(expr, assigned, parameters, seen=None):
1324
1630
  if isinstance(key,ast.Constant) and key.value == expr.slice.value:
1325
1631
  result.extend(shape_only(item) for item in payload_expr_nodes(value,assigned,parameters,set(seen)))
1326
1632
  return result
1633
+ if isinstance(expr,ast.IfExp):
1634
+ result=[]
1635
+ result.extend(payload_expr_nodes(expr.body,assigned,parameters,set(seen)))
1636
+ result.extend(payload_expr_nodes(expr.orelse,assigned,parameters,set(seen)))
1637
+ return result
1327
1638
  if isinstance(expr,ast.Call):
1328
1639
  result=[]
1329
1640
  if isinstance(expr.func,ast.Name) and expr.func.id in FUNCTION_PAYLOADS:
@@ -1364,6 +1675,33 @@ def decorator_payload_nodes(parameters,assigned):
1364
1675
  for value in values: result.extend(payload_expr_nodes(value,assigned,parameters))
1365
1676
  return result
1366
1677
 
1678
+ def decorator_payload_nodes_by_tp(fn,assigned):
1679
+ result={}
1680
+ function_payload_nodes=payload_nodes(fn)
1681
+ for dec in fn.decorator_list:
1682
+ if not isinstance(dec,ast.Call) or not isinstance(dec.func,ast.Attribute) or dec.func.attr != 'parametrize' or len(dec.args) < 2: continue
1683
+ if not isinstance(dec.args[0],ast.Constant) or not isinstance(dec.args[0].value,str): continue
1684
+ names=[item.strip() for item in dec.args[0].value.split(',')]
1685
+ rows=dec.args[1]
1686
+ if isinstance(rows,ast.Name) and rows.id in GLOBAL_VALUES: rows=GLOBAL_VALUES[rows.id]
1687
+ for node in ast.walk(rows):
1688
+ if not isinstance(node,ast.Call) or not isinstance(node.func,ast.Attribute) or node.func.attr != 'param': continue
1689
+ tp=None
1690
+ for keyword in node.keywords:
1691
+ if keyword.arg == 'id' and isinstance(keyword.value,ast.Constant) and isinstance(keyword.value.value,str) and keyword.value.value.startswith('TP-'):
1692
+ tp=keyword.value.value
1693
+ if not tp: continue
1694
+ parameters={}
1695
+ for index,name in enumerate(names):
1696
+ if index < len(node.args): parameters.setdefault(name,[]).append(node.args[index])
1697
+ payload_nodes_for_tp=decorator_payload_nodes(parameters,assigned)
1698
+ if not payload_nodes_for_tp:
1699
+ payload_nodes_for_tp=function_payload_nodes
1700
+ paths=set(); values={}
1701
+ for payload_node in payload_nodes_for_tp: collect_dict(payload_node,'',paths,values,parameters)
1702
+ result[tp]={key:sorted(items) for key,items in sorted(values.items())}
1703
+ return result
1704
+
1367
1705
  def fallback_payload_nodes(fn):
1368
1706
  result=[]
1369
1707
  assigned={}
@@ -1393,7 +1731,7 @@ def fallback_payload_nodes(fn):
1393
1731
 
1394
1732
  def is_direct_transport_call(node):
1395
1733
  if not isinstance(node,ast.Call) or not isinstance(node.func,ast.Attribute): return False
1396
- if node.func.attr.lower() not in {'get','post','put','patch','delete','request'}: return False
1734
+ if node.func.attr.lower() not in {'get','post','put','patch','delete','request','call'}: return False
1397
1735
  receiver_tokens=[]
1398
1736
  current=node.func.value
1399
1737
  while isinstance(current,ast.Attribute):
@@ -1402,6 +1740,20 @@ def is_direct_transport_call(node):
1402
1740
  if isinstance(current,ast.Name): receiver_tokens.append(current.id.lower())
1403
1741
  return any(token in {'requests','httpx','client','session','api_client','http_client'} or token.endswith('_client') for token in receiver_tokens)
1404
1742
 
1743
+ HTTP_METHODS={'GET','POST','PUT','PATCH','DELETE','HEAD','OPTIONS'}
1744
+ HTTP_FIXTURE_NAMES={'http','http_client','client','api_client','session'}
1745
+
1746
+ def is_fixture_http_call(node):
1747
+ # R12: http("POST", path, json_body={"title": title}) is a Name-call fixture, not client.post.
1748
+ # R15: http_client(operation, path, json_body={...}) still transports when operation is a parametrized method.
1749
+ if not isinstance(node,ast.Call) or not isinstance(node.func,ast.Name) or not node.args: return False
1750
+ first=node.args[0]
1751
+ if isinstance(first,ast.Constant) and isinstance(first.value,str) and first.value.upper() in HTTP_METHODS:
1752
+ return True
1753
+ func=node.func.id.lower()
1754
+ httpish=func in HTTP_FIXTURE_NAMES or func.endswith('_client')
1755
+ return httpish and isinstance(first,ast.Name)
1756
+
1405
1757
  def payload_nodes(fn):
1406
1758
  result=[]
1407
1759
  assigned={}
@@ -1424,7 +1776,7 @@ def payload_nodes(fn):
1424
1776
  # Observe local payload/body variables only when they flow into a direct
1425
1777
  # HTTP transport call. Arbitrary setup variables are not target requests.
1426
1778
  for node in ast.walk(fn):
1427
- if not is_direct_transport_call(node): continue
1779
+ if not (is_direct_transport_call(node) or is_fixture_http_call(node)): continue
1428
1780
  for keyword in node.keywords:
1429
1781
  if keyword.arg in PAYLOAD_NAMES: result.extend(payload_expr_nodes(keyword.value,assigned,parameters))
1430
1782
  return result
@@ -1434,13 +1786,14 @@ for fn in ast.walk(tree):
1434
1786
  if isinstance(fn,(ast.FunctionDef,ast.AsyncFunctionDef)) and fn.name.startswith('test_'):
1435
1787
  paths=set(); values={}
1436
1788
  fallback_paths=set(); fallback_values={}
1437
- for node in payload_nodes(fn): collect_dict(node,'',paths,values)
1438
- for node in fallback_payload_nodes(fn): collect_dict(node,'',fallback_paths,fallback_values)
1789
+ for node in payload_nodes(fn): collect_dict(node,'',paths,values,{})
1790
+ for node in fallback_payload_nodes(fn): collect_dict(node,'',fallback_paths,fallback_values,{})
1439
1791
  out[fn.name]={
1440
1792
  'paths':sorted(paths),
1441
1793
  'values':{key:sorted(items) for key,items in sorted(values.items())},
1442
1794
  'fallbackPaths':sorted(fallback_paths),
1443
1795
  'fallbackValues':{key:sorted(items) for key,items in sorted(fallback_values.items())},
1796
+ 'valuesByTestPoint':decorator_payload_nodes_by_tp(fn,{}),
1444
1797
  }
1445
1798
  print(json.dumps(out,ensure_ascii=True))
1446
1799
  `;
@@ -1448,8 +1801,26 @@ print(json.dumps(out,ensure_ascii=True))
1448
1801
  // Windows Python may expose stdin as GBK; decoding generated Chinese/emoji
1449
1802
  // source through that locale can create surrogateescape code points and make
1450
1803
  // ast.parse fail with "surrogates not allowed".
1451
- const result = spawnSync("python", ["-c", program], { input: Buffer.from(source, "utf8"), encoding: "utf8", maxBuffer: 4 * 1024 * 1024, windowsHide: true });
1452
- if (result.status !== 0 || !result.stdout.trim())
1804
+ // POSIX images usually expose only `python3` (modern macOS has no `python`);
1805
+ // Windows often has a real `python` plus a Microsoft Store `python3` stub.
1806
+ // A missing interpreter must not silently degrade to empty payload shapes.
1807
+ const interpreterCandidates = process.platform === "win32" ? ["python", "python3"] : ["python3", "python"];
1808
+ let result;
1809
+ for (const interpreter of interpreterCandidates) {
1810
+ const attempt = spawnSync(interpreter, ["-c", program], {
1811
+ input: Buffer.from(source, "utf8"),
1812
+ encoding: "utf8",
1813
+ maxBuffer: 4 * 1024 * 1024,
1814
+ windowsHide: true,
1815
+ });
1816
+ // Interpreter missing/unspawnable → try the next candidate. A spawned
1817
+ // interpreter that exits nonzero analyzed real input; do not retry then.
1818
+ if (attempt.error)
1819
+ continue;
1820
+ result = attempt;
1821
+ break;
1822
+ }
1823
+ if (!result || result.status !== 0 || !result.stdout.trim())
1453
1824
  return new Map();
1454
1825
  try {
1455
1826
  const parsed = JSON.parse(result.stdout);
@@ -1468,14 +1839,39 @@ function metadataTestPoints(region, label) {
1468
1839
  const match = new RegExp(`^\\s*${escaped}\\s*:\\s*(.*)$`, "mi").exec(region);
1469
1840
  return orderedUnique(match?.[1]?.match(/\bTP-[A-Z0-9]+(?:-[A-Z0-9]+)*\b/g) ?? []);
1470
1841
  }
1842
+ function isPytestDecoratorOrContinuationLine(line) {
1843
+ const trimmed = line.trim();
1844
+ if (!trimmed)
1845
+ return false;
1846
+ if (trimmed.startsWith("#"))
1847
+ return true;
1848
+ if (trimmed.startsWith("@"))
1849
+ return true;
1850
+ // Multi-line decorator argument lists: @pytest.mark.parametrize(\n "x", [\n pytest.param(..., id="TP-...")\n ]\n)
1851
+ return /^[\]\),]/.test(trimmed) || /[\(\[{,]$/.test(trimmed) || /\bpytest\.param\s*\(/.test(trimmed);
1852
+ }
1471
1853
  function pytestFunctionRegionStart(source, functionIndex) {
1472
1854
  let regionStart = source.lastIndexOf("\n", functionIndex - 1) + 1;
1473
1855
  let cursor = regionStart;
1856
+ let blankRun = 0;
1474
1857
  while (cursor > 0) {
1475
1858
  const previousEnd = cursor - 1;
1476
1859
  const previousStart = source.lastIndexOf("\n", previousEnd - 1) + 1;
1477
1860
  const previous = source.slice(previousStart, previousEnd).replace(/\r$/, "");
1478
- if (!previous.trim())
1861
+ const trimmed = previous.trim();
1862
+ if (!trimmed) {
1863
+ blankRun += 1;
1864
+ // Keep walking across a small blank gap so a decorator is still bound to
1865
+ // the following test when writers insert one empty line before `def`.
1866
+ if (blankRun > 2)
1867
+ break;
1868
+ cursor = previousStart;
1869
+ continue;
1870
+ }
1871
+ blankRun = 0;
1872
+ if (/^(?:async\s+)?def\s+/.test(trimmed) || /^(?:async\s+)?class\s+/.test(trimmed))
1873
+ break;
1874
+ if (!isPytestDecoratorOrContinuationLine(previous))
1479
1875
  break;
1480
1876
  regionStart = previousStart;
1481
1877
  cursor = previousStart;
@@ -1505,12 +1901,14 @@ function pytestFunctionBodyEnd(source, signatureEnd, functionIndent) {
1505
1901
  }
1506
1902
  function pytestParameterCollections(source) {
1507
1903
  const collections = new Map();
1508
- for (const match of source.matchAll(/^(_?[A-Z][A-Z0-9_]*)\s*=\s*\[(?![^\r\n]*\])([\s\S]*?)^\]/gm)) {
1904
+ for (const match of source.matchAll(/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*\[(?![^\r\n]*\])([\s\S]*?)^\]/gm)) {
1509
1905
  const explicitIds = [...match[2].matchAll(/\bid\s*=\s*["'](TP-[A-Z0-9-]+)["']/g)].map((item) => item[1]);
1510
1906
  const factoryIds = explicitIds.length === 0
1511
1907
  ? [...match[2].matchAll(/["'](TP-[A-Z0-9-]+)["']/g)].map((item) => item[1])
1512
1908
  : [];
1513
- collections.set(match[1], orderedUnique([...explicitIds, ...factoryIds]));
1909
+ const ids = orderedUnique([...explicitIds, ...factoryIds]);
1910
+ if (ids.length > 0)
1911
+ collections.set(match[1], ids);
1514
1912
  }
1515
1913
  return collections;
1516
1914
  }
@@ -1553,6 +1951,7 @@ function pytestSymbols(script, source) {
1553
1951
  payloadValues: payloadShape.values,
1554
1952
  fallbackPayloadPaths: payloadShape.fallbackPaths ?? [],
1555
1953
  fallbackPayloadValues: payloadShape.fallbackValues ?? {},
1954
+ payloadValuesByTestPoint: payloadShape.valuesByTestPoint ?? {},
1556
1955
  };
1557
1956
  });
1558
1957
  }
@@ -1566,6 +1965,39 @@ function executionSignature(testCase) {
1566
1965
  .join("\n");
1567
1966
  return createHash("sha256").update(normalized).digest("hex");
1568
1967
  }
1968
+ function normalizePythonLiteralValue(value) {
1969
+ const trimmed = value.trim();
1970
+ if ((trimmed.startsWith("'") && trimmed.endsWith("'")) || (trimmed.startsWith('"') && trimmed.endsWith('"'))) {
1971
+ return trimmed.slice(1, -1);
1972
+ }
1973
+ if (trimmed === "True")
1974
+ return "true";
1975
+ if (trimmed === "False")
1976
+ return "false";
1977
+ if (trimmed === "None")
1978
+ return "null";
1979
+ return trimmed;
1980
+ }
1981
+ function intentionalInvalidEnumVariant(input) {
1982
+ if (!input.testCase.testPointBindings.some((binding) => binding.mode === "variant" && binding.testPoint === input.testPoint))
1983
+ return false;
1984
+ const inferred = inferScenarioParamIntent({ tpId: input.testPoint, caseBody: input.testCase.body });
1985
+ if (inferred.intentSource !== "machine-line" || inferred.field?.toLowerCase() !== input.field.toLowerCase())
1986
+ return false;
1987
+ const observed = normalizePythonLiteralValue(input.observedValue);
1988
+ if (input.allowed.includes(observed))
1989
+ return false;
1990
+ if (inferred.intent === "enum-invalid" || inferred.intent === "wrong-type")
1991
+ return true;
1992
+ if (inferred.intent === "null")
1993
+ return observed === "None" || observed === "null";
1994
+ if (inferred.intent === "empty")
1995
+ return observed === "";
1996
+ if (!inferred.intent.startsWith("custom-literal:"))
1997
+ return false;
1998
+ const expected = normalizePythonLiteralValue(inferred.example ?? inferred.intent.slice("custom-literal:".length));
1999
+ return observed === expected;
2000
+ }
1569
2001
  function assessPayloadContract(testCase, refs) {
1570
2002
  const requiredPaths = testCase.payloadContract.requiredPaths;
1571
2003
  const directObservedPaths = orderedUnique(refs.flatMap((item) => item.payloadPaths));
@@ -1587,13 +2019,19 @@ function assessPayloadContract(testCase, refs) {
1587
2019
  ? observedPaths.filter((item) => !allowedPaths.includes(item) && !allowedPaths.some((allowed) => item.startsWith(`${allowed}.`)))
1588
2020
  : [];
1589
2021
  const enumMismatches = [];
1590
- const delegatesInvalidEnumToScenarioGate = testCase.testPointBindings
1591
- .filter((binding) => binding.mode === "variant")
1592
- .some((binding) => /(?:ENUM|CATEGORY).*(?:INVALID|UNKNOWN|CASE|WHITESPACE|EMPTY|WRONG-TYPE)|(?:INVALID|UNKNOWN|CASE|WHITESPACE|EMPTY|WRONG-TYPE).*(?:ENUM|CATEGORY)/.test(binding.testPoint));
1593
2022
  for (const [field, allowed] of Object.entries(testCase.payloadContract.enumValues)) {
1594
- const observed = orderedUnique(refs.flatMap((item) => (useFallback ? item.fallbackPayloadValues[field] : item.payloadValues[field]) ?? []).map((value) => value.replace(/^['"]|['"]$/g, "")));
1595
- for (const value of observed) {
1596
- if (!allowed.includes(value) && !delegatesInvalidEnumToScenarioGate)
2023
+ const aggregated = orderedUnique(refs.flatMap((item) => (useFallback ? item.fallbackPayloadValues[field] : item.payloadValues[field]) ?? []));
2024
+ const byTestPoint = orderedUnique(refs.flatMap((item) => Object.values(item.payloadValuesByTestPoint).flatMap((values) => values[field] ?? [])));
2025
+ const observed = orderedUnique([...aggregated, ...byTestPoint]);
2026
+ for (const rawValue of observed) {
2027
+ const value = normalizePythonLiteralValue(rawValue);
2028
+ if (allowed.includes(value))
2029
+ continue;
2030
+ const associatedTestPoints = orderedUnique(refs.flatMap((item) => Object.entries(item.payloadValuesByTestPoint)
2031
+ .filter(([, values]) => (values[field] ?? []).some((itemValue) => itemValue === rawValue || normalizePythonLiteralValue(itemValue) === value))
2032
+ .map(([testPoint]) => testPoint)));
2033
+ const intentionallyInvalid = associatedTestPoints.length > 0 && associatedTestPoints.every((testPoint) => intentionalInvalidEnumVariant({ testCase, testPoint, field, observedValue: rawValue, allowed }));
2034
+ if (!intentionallyInvalid)
1597
2035
  enumMismatches.push(`${field}=${value}; allowed=${allowed.join("|")}`);
1598
2036
  }
1599
2037
  }
@@ -1611,7 +2049,7 @@ export async function analyzeBackendTestMarkdownPytestCorrespondence(input) {
1611
2049
  const layout = input.layout ?? resolveBackendTestLayout(undefined);
1612
2050
  const cases = await parseMarkdownCases(input.workspaceRoot, layout);
1613
2051
  const modulePaths = orderedUnique(cases.map((item) => item.markdownPath));
1614
- const scripts = orderedUnique(cases.flatMap((item) => [...item.declaredScripts, expectedScript(item.markdownPath, layout)]));
2052
+ const scripts = orderedUnique(cases.flatMap((item) => [expectedScript(item.markdownPath, layout, item.declaredScripts)]));
1615
2053
  const allSymbols = [];
1616
2054
  const scriptFiles = [];
1617
2055
  for (const script of scripts) {
@@ -1624,7 +2062,7 @@ export async function analyzeBackendTestMarkdownPytestCorrespondence(input) {
1624
2062
  const findings = [];
1625
2063
  const entries = [];
1626
2064
  for (const testCase of cases) {
1627
- const expected = expectedScript(testCase.markdownPath, layout);
2065
+ const expected = expectedScript(testCase.markdownPath, layout, testCase.declaredScripts);
1628
2066
  const declared = testCase.declaredScripts[0];
1629
2067
  const refs = allSymbols.filter((item) => item.caseIds.includes(testCase.caseId));
1630
2068
  const actualScripts = orderedUnique(refs.map((item) => item.script));
@@ -1782,8 +2220,9 @@ export async function analyzeBackendTestMarkdownPytestCorrespondence(input) {
1782
2220
  for (const [signature, owners] of duplicateSignatureGroups)
1783
2221
  findings.push(`duplicate execution signature ${signature}: ${orderedUnique(owners).join(", ")}`);
1784
2222
  const exactModuleCount = modulePaths.filter((modulePath) => {
1785
- const expected = expectedScript(modulePath, layout);
1786
2223
  const moduleCases = cases.filter((item) => item.markdownPath === modulePath);
2224
+ const moduleDeclaredScripts = orderedUnique(moduleCases.flatMap((item) => item.declaredScripts));
2225
+ const expected = expectedScript(modulePath, layout, moduleDeclaredScripts);
1787
2226
  return moduleCases.every((item) => item.declaredScripts.length === 1 && item.declaredScripts[0] === expected) && scriptFiles.some((file) => path.relative(input.workspaceRoot, file).replaceAll(path.sep, "/") === expected);
1788
2227
  }).length;
1789
2228
  const caseEntries = entries.filter((entry) => entry.cardinality !== "0:1");
@@ -1794,7 +2233,7 @@ export async function analyzeBackendTestMarkdownPytestCorrespondence(input) {
1794
2233
  status: findings.length === 0 ? "PASS" : "FAIL",
1795
2234
  inputFiles: await inputFileFacts(input.workspaceRoot, [
1796
2235
  path.join(input.workspaceRoot, ...layout.readmePath.split("/")),
1797
- ...(await markdownModuleFiles(input.workspaceRoot)),
2236
+ ...(await markdownModuleFiles(input.workspaceRoot, layout)),
1798
2237
  ...scriptFiles,
1799
2238
  ].filter((file) => file && path.isAbsolute(file))),
1800
2239
  summary: {