devflow-engine 1.0.0__py3-none-any.whl

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 (393) hide show
  1. devflow_engine/__init__.py +3 -0
  2. devflow_engine/agentic_prompts.py +100 -0
  3. devflow_engine/agentic_runtime.py +398 -0
  4. devflow_engine/api_key_flow_harness.py +539 -0
  5. devflow_engine/api_keys.py +357 -0
  6. devflow_engine/bootstrap/__init__.py +2 -0
  7. devflow_engine/bootstrap/provision_from_template.py +84 -0
  8. devflow_engine/cli/__init__.py +0 -0
  9. devflow_engine/cli/app.py +7270 -0
  10. devflow_engine/core/__init__.py +0 -0
  11. devflow_engine/core/config.py +86 -0
  12. devflow_engine/core/logging.py +29 -0
  13. devflow_engine/core/paths.py +45 -0
  14. devflow_engine/core/toml_kv.py +33 -0
  15. devflow_engine/devflow_event_worker.py +1292 -0
  16. devflow_engine/devflow_state.py +201 -0
  17. devflow_engine/devin2/__init__.py +9 -0
  18. devflow_engine/devin2/agent_definition.py +120 -0
  19. devflow_engine/devin2/pi_runner.py +204 -0
  20. devflow_engine/devin_orchestration.py +69 -0
  21. devflow_engine/docs/prompts/anti-patterns.md +42 -0
  22. devflow_engine/docs/prompts/devin-agent-prompt.md +55 -0
  23. devflow_engine/docs/prompts/devin2-agent-prompt.md +81 -0
  24. devflow_engine/docs/prompts/examples/devin-vapi-clone-reference-exchange.json +85 -0
  25. devflow_engine/doctor/__init__.py +2 -0
  26. devflow_engine/doctor/triage.py +140 -0
  27. devflow_engine/error/__init__.py +0 -0
  28. devflow_engine/error/remediation.py +21 -0
  29. devflow_engine/errors/error_solver_dag.py +522 -0
  30. devflow_engine/errors/runtime_observability.py +67 -0
  31. devflow_engine/idea/__init__.py +4 -0
  32. devflow_engine/idea/actors.py +481 -0
  33. devflow_engine/idea/agentic.py +465 -0
  34. devflow_engine/idea/analyze.py +93 -0
  35. devflow_engine/idea/devin_chat_dag.py +1 -0
  36. devflow_engine/idea/diff.py +99 -0
  37. devflow_engine/idea/drafts.py +446 -0
  38. devflow_engine/idea/idea_creation_dag.py +643 -0
  39. devflow_engine/idea/ideation_enrichment.py +355 -0
  40. devflow_engine/idea/ideation_enrichment_worker.py +19 -0
  41. devflow_engine/idea/paths.py +28 -0
  42. devflow_engine/idea/promote.py +53 -0
  43. devflow_engine/idea/redaction.py +27 -0
  44. devflow_engine/idea/repo_tools.py +1277 -0
  45. devflow_engine/idea/response_mode.py +30 -0
  46. devflow_engine/idea/story_pipeline.py +1585 -0
  47. devflow_engine/idea/sufficiency.py +376 -0
  48. devflow_engine/idea/traditional_stories.py +1257 -0
  49. devflow_engine/implementation/__init__.py +0 -0
  50. devflow_engine/implementation/alembic_preflight.py +700 -0
  51. devflow_engine/implementation/dag.py +8450 -0
  52. devflow_engine/implementation/green_gate.py +93 -0
  53. devflow_engine/implementation/prompts.py +108 -0
  54. devflow_engine/implementation/test_runtime.py +623 -0
  55. devflow_engine/integration/__init__.py +19 -0
  56. devflow_engine/integration/agentic.py +66 -0
  57. devflow_engine/integration/dag.py +3539 -0
  58. devflow_engine/integration/prompts.py +114 -0
  59. devflow_engine/integration/supabase_schema.sql +31 -0
  60. devflow_engine/integration/supabase_sync.py +177 -0
  61. devflow_engine/llm/__init__.py +1 -0
  62. devflow_engine/llm/cli_one_shot.py +84 -0
  63. devflow_engine/llm/cli_stream.py +371 -0
  64. devflow_engine/llm/execution_context.py +26 -0
  65. devflow_engine/llm/invoke.py +1322 -0
  66. devflow_engine/llm/provider_api.py +304 -0
  67. devflow_engine/llm/repo_knowledge.py +588 -0
  68. devflow_engine/llm_primitives.py +315 -0
  69. devflow_engine/orchestration.py +62 -0
  70. devflow_engine/planning/__init__.py +0 -0
  71. devflow_engine/planning/analyze_repo.py +92 -0
  72. devflow_engine/planning/render_drafts.py +133 -0
  73. devflow_engine/playground/__init__.py +0 -0
  74. devflow_engine/playground/hooks.py +26 -0
  75. devflow_engine/playwright_workflow/__init__.py +5 -0
  76. devflow_engine/playwright_workflow/dag.py +1317 -0
  77. devflow_engine/process/__init__.py +5 -0
  78. devflow_engine/process/dag.py +59 -0
  79. devflow_engine/project_registration/__init__.py +3 -0
  80. devflow_engine/project_registration/dag.py +1581 -0
  81. devflow_engine/project_registry.py +109 -0
  82. devflow_engine/prompts/devin/generic/prompt.md +6 -0
  83. devflow_engine/prompts/devin/ideation/prompt.md +263 -0
  84. devflow_engine/prompts/devin/ideation/scenarios.md +5 -0
  85. devflow_engine/prompts/devin/ideation_loop/prompt.md +6 -0
  86. devflow_engine/prompts/devin/insight/prompt.md +11 -0
  87. devflow_engine/prompts/devin/insight/scenarios.md +5 -0
  88. devflow_engine/prompts/devin/intake/prompt.md +15 -0
  89. devflow_engine/prompts/devin/iterate/prompt.md +12 -0
  90. devflow_engine/prompts/devin/shared/eval_doctrine.md +9 -0
  91. devflow_engine/prompts/devin/shared/principles.md +246 -0
  92. devflow_engine/prompts/devin_eval/assessment/prompt.md +18 -0
  93. devflow_engine/prompts/idea/api_ideation_agent/prompt.md +8 -0
  94. devflow_engine/prompts/idea/api_insight_agent/prompt.md +8 -0
  95. devflow_engine/prompts/idea/response_doctrine/prompt.md +18 -0
  96. devflow_engine/prompts/implementation/dependency_assessment/prompt.md +12 -0
  97. devflow_engine/prompts/implementation/green/green/prompt.md +11 -0
  98. devflow_engine/prompts/implementation/green/node_config/prompt.md +3 -0
  99. devflow_engine/prompts/implementation/green_review/outcome_review/prompt.md +5 -0
  100. devflow_engine/prompts/implementation/green_review/prior_run_review/prompt.md +5 -0
  101. devflow_engine/prompts/implementation/red/prompt.md +27 -0
  102. devflow_engine/prompts/implementation/redreview/prompt.md +23 -0
  103. devflow_engine/prompts/implementation/redreview_repair/prompt.md +16 -0
  104. devflow_engine/prompts/implementation/setupdoc/prompt.md +10 -0
  105. devflow_engine/prompts/implementation/story_planning/prompt.md +13 -0
  106. devflow_engine/prompts/implementation/test_design/prompt.md +27 -0
  107. devflow_engine/prompts/integration/README.md +185 -0
  108. devflow_engine/prompts/integration/green/example.md +67 -0
  109. devflow_engine/prompts/integration/green/green/prompt.md +10 -0
  110. devflow_engine/prompts/integration/green/node_config/prompt.md +42 -0
  111. devflow_engine/prompts/integration/green/past_prompts/20260417T212300/green/prompt.md +15 -0
  112. devflow_engine/prompts/integration/green/past_prompts/20260417T212300/node_config/prompt.md +42 -0
  113. devflow_engine/prompts/integration/green_enrich/example.md +79 -0
  114. devflow_engine/prompts/integration/green_enrich/green_enrich/prompt.md +9 -0
  115. devflow_engine/prompts/integration/green_enrich/node_config/prompt.md +41 -0
  116. devflow_engine/prompts/integration/green_enrich/past_prompts/20260417T212300/green_enrich/prompt.md +14 -0
  117. devflow_engine/prompts/integration/green_enrich/past_prompts/20260417T212300/node_config/prompt.md +41 -0
  118. devflow_engine/prompts/integration/red/code_repair/prompt.md +12 -0
  119. devflow_engine/prompts/integration/red/example.md +152 -0
  120. devflow_engine/prompts/integration/red/node_config/prompt.md +86 -0
  121. devflow_engine/prompts/integration/red/past_prompts/20260417T212300/code_repair/prompt.md +19 -0
  122. devflow_engine/prompts/integration/red/past_prompts/20260417T212300/node_config/prompt.md +84 -0
  123. devflow_engine/prompts/integration/red/past_prompts/20260417T212300/red/prompt.md +16 -0
  124. devflow_engine/prompts/integration/red/past_prompts/20260417T212300/red_repair/prompt.md +15 -0
  125. devflow_engine/prompts/integration/red/past_prompts/20260417T215032/code_repair/prompt.md +10 -0
  126. devflow_engine/prompts/integration/red/past_prompts/20260417T215032/node_config/prompt.md +84 -0
  127. devflow_engine/prompts/integration/red/past_prompts/20260417T215032/red_repair/prompt.md +11 -0
  128. devflow_engine/prompts/integration/red/red/prompt.md +11 -0
  129. devflow_engine/prompts/integration/red/red_repair/prompt.md +12 -0
  130. devflow_engine/prompts/integration/red_review/example.md +71 -0
  131. devflow_engine/prompts/integration/red_review/node_config/prompt.md +41 -0
  132. devflow_engine/prompts/integration/red_review/past_prompts/20260417T212300/node_config/prompt.md +41 -0
  133. devflow_engine/prompts/integration/red_review/past_prompts/20260417T212300/red_review/prompt.md +15 -0
  134. devflow_engine/prompts/integration/red_review/red_review/prompt.md +9 -0
  135. devflow_engine/prompts/integration/resolve/example.md +111 -0
  136. devflow_engine/prompts/integration/resolve/node_config/prompt.md +64 -0
  137. devflow_engine/prompts/integration/resolve/past_prompts/20260417T212300/node_config/prompt.md +64 -0
  138. devflow_engine/prompts/integration/resolve/past_prompts/20260417T212300/resolve_implicated_users/prompt.md +15 -0
  139. devflow_engine/prompts/integration/resolve/past_prompts/20260417T212300/resolve_side_effects/prompt.md +15 -0
  140. devflow_engine/prompts/integration/resolve/resolve_implicated_users/prompt.md +10 -0
  141. devflow_engine/prompts/integration/resolve/resolve_side_effects/prompt.md +10 -0
  142. devflow_engine/prompts/integration/validate/build_idea_acceptance_coverage/prompt.md +12 -0
  143. devflow_engine/prompts/integration/validate/code_repair/prompt.md +13 -0
  144. devflow_engine/prompts/integration/validate/example.md +143 -0
  145. devflow_engine/prompts/integration/validate/node_config/prompt.md +87 -0
  146. devflow_engine/prompts/integration/validate/past_prompts/20260417T212300/code_repair/prompt.md +19 -0
  147. devflow_engine/prompts/integration/validate/past_prompts/20260417T212300/node_config/prompt.md +67 -0
  148. devflow_engine/prompts/integration/validate/past_prompts/20260417T212300/validate_enrich_gate/prompt.md +17 -0
  149. devflow_engine/prompts/integration/validate/past_prompts/20260417T212300/validate_repair/prompt.md +16 -0
  150. devflow_engine/prompts/integration/validate/past_prompts/20260417T215032/code_repair/prompt.md +10 -0
  151. devflow_engine/prompts/integration/validate/past_prompts/20260417T215032/node_config/prompt.md +67 -0
  152. devflow_engine/prompts/integration/validate/past_prompts/20260417T215032/validate_repair/prompt.md +9 -0
  153. devflow_engine/prompts/integration/validate/validate_enrich_gate/prompt.md +10 -0
  154. devflow_engine/prompts/integration/validate/validate_repair/prompt.md +20 -0
  155. devflow_engine/prompts/integration/write_workflows/example.md +100 -0
  156. devflow_engine/prompts/integration/write_workflows/node_config/prompt.md +44 -0
  157. devflow_engine/prompts/integration/write_workflows/past_prompts/20260417T212300/node_config/prompt.md +44 -0
  158. devflow_engine/prompts/integration/write_workflows/past_prompts/20260417T212300/write_workflows/prompt.md +17 -0
  159. devflow_engine/prompts/integration/write_workflows/write_workflows/prompt.md +11 -0
  160. devflow_engine/prompts/iterate/README.md +7 -0
  161. devflow_engine/prompts/iterate/coder/prompt.md +11 -0
  162. devflow_engine/prompts/iterate/framer/prompt.md +11 -0
  163. devflow_engine/prompts/iterate/iterator/prompt.md +13 -0
  164. devflow_engine/prompts/iterate/observer/prompt.md +11 -0
  165. devflow_engine/prompts/recovery/diagnosis/prompt.md +7 -0
  166. devflow_engine/prompts/recovery/execution/prompt.md +8 -0
  167. devflow_engine/prompts/recovery/execution_verification/prompt.md +7 -0
  168. devflow_engine/prompts/recovery/failure_investigation/prompt.md +10 -0
  169. devflow_engine/prompts/recovery/preflight_health_repo_repair/prompt.md +8 -0
  170. devflow_engine/prompts/recovery/remediation_execution/prompt.md +11 -0
  171. devflow_engine/prompts/recovery/root_cause_investigation/prompt.md +12 -0
  172. devflow_engine/prompts/scope_idea/doctrine/prompt.md +7 -0
  173. devflow_engine/prompts/source_doc_eval/document/prompt.md +6 -0
  174. devflow_engine/prompts/source_doc_eval/targeted_mutation/prompt.md +9 -0
  175. devflow_engine/prompts/source_doc_mutation/domain_entities/prompt.md +6 -0
  176. devflow_engine/prompts/source_doc_mutation/product_brief/prompt.md +6 -0
  177. devflow_engine/prompts/source_doc_mutation/project_doc_coherence/prompt.md +7 -0
  178. devflow_engine/prompts/source_doc_mutation/project_doc_render/prompt.md +9 -0
  179. devflow_engine/prompts/source_doc_mutation/source_doc_coherence/prompt.md +5 -0
  180. devflow_engine/prompts/source_doc_mutation/source_doc_enrichment_coherence/prompt.md +6 -0
  181. devflow_engine/prompts/source_doc_mutation/user_workflows/prompt.md +6 -0
  182. devflow_engine/prompts/source_scope/doctrine/prompt.md +10 -0
  183. devflow_engine/prompts/ui_grounding/doctrine/prompt.md +7 -0
  184. devflow_engine/recovery/__init__.py +3 -0
  185. devflow_engine/recovery/dag.py +2609 -0
  186. devflow_engine/recovery/models.py +220 -0
  187. devflow_engine/refactor.py +93 -0
  188. devflow_engine/registry/__init__.py +1 -0
  189. devflow_engine/registry/cards.py +238 -0
  190. devflow_engine/registry/domain_normalize.py +60 -0
  191. devflow_engine/registry/effects.py +65 -0
  192. devflow_engine/registry/enforce_report.py +150 -0
  193. devflow_engine/registry/module_cards_classify.py +164 -0
  194. devflow_engine/registry/module_cards_draft.py +184 -0
  195. devflow_engine/registry/module_cards_gate.py +59 -0
  196. devflow_engine/registry/packages.py +347 -0
  197. devflow_engine/registry/pathways.py +323 -0
  198. devflow_engine/review/__init__.py +11 -0
  199. devflow_engine/review/dag.py +588 -0
  200. devflow_engine/review/review_story.py +67 -0
  201. devflow_engine/scope_idea/__init__.py +3 -0
  202. devflow_engine/scope_idea/agentic.py +39 -0
  203. devflow_engine/scope_idea/dag.py +1069 -0
  204. devflow_engine/scope_idea/models.py +175 -0
  205. devflow_engine/skills/builtins/devflow/queue_failure_investigation/SKILL.md +112 -0
  206. devflow_engine/skills/builtins/devflow/queue_idea_to_story/SKILL.md +120 -0
  207. devflow_engine/skills/builtins/devflow/queue_integration/SKILL.md +105 -0
  208. devflow_engine/skills/builtins/devflow/queue_recovery/SKILL.md +108 -0
  209. devflow_engine/skills/builtins/devflow/queue_runtime_core/SKILL.md +155 -0
  210. devflow_engine/skills/builtins/devflow/queue_story_implementation/SKILL.md +122 -0
  211. devflow_engine/skills/builtins/devin/idea_to_story_handoff/SKILL.md +120 -0
  212. devflow_engine/skills/builtins/devin/ideation/SKILL.md +168 -0
  213. devflow_engine/skills/builtins/devin/ideation/state-and-phrasing-reference.md +18 -0
  214. devflow_engine/skills/builtins/devin/insight/SKILL.md +22 -0
  215. devflow_engine/skills/registry.example.yaml +42 -0
  216. devflow_engine/source_doc_assumptions.py +291 -0
  217. devflow_engine/source_doc_mutation_dag.py +1606 -0
  218. devflow_engine/source_doc_mutation_eval.py +417 -0
  219. devflow_engine/source_doc_mutation_worker.py +25 -0
  220. devflow_engine/source_docs_schema.py +207 -0
  221. devflow_engine/source_docs_updater.py +309 -0
  222. devflow_engine/source_scope/__init__.py +15 -0
  223. devflow_engine/source_scope/agentic.py +45 -0
  224. devflow_engine/source_scope/dag.py +1626 -0
  225. devflow_engine/source_scope/models.py +177 -0
  226. devflow_engine/stores/__init__.py +0 -0
  227. devflow_engine/stores/execution_store.py +3534 -0
  228. devflow_engine/story/__init__.py +0 -0
  229. devflow_engine/story/contracts.py +160 -0
  230. devflow_engine/story/discovery.py +47 -0
  231. devflow_engine/story/evidence.py +118 -0
  232. devflow_engine/story/hashing.py +27 -0
  233. devflow_engine/story/implemented_queue_purge.py +148 -0
  234. devflow_engine/story/indexer.py +105 -0
  235. devflow_engine/story/io.py +20 -0
  236. devflow_engine/story/markdown_contracts.py +298 -0
  237. devflow_engine/story/reconciliation.py +408 -0
  238. devflow_engine/story/validate_stories.py +149 -0
  239. devflow_engine/story/validate_tests_story.py +512 -0
  240. devflow_engine/story/validation.py +133 -0
  241. devflow_engine/ui_grounding/__init__.py +11 -0
  242. devflow_engine/ui_grounding/agentic.py +31 -0
  243. devflow_engine/ui_grounding/dag.py +874 -0
  244. devflow_engine/ui_grounding/models.py +224 -0
  245. devflow_engine/ui_grounding/pencil_bridge.py +247 -0
  246. devflow_engine/vendor/__init__.py +0 -0
  247. devflow_engine/vendor/datalumina_genai/__init__.py +11 -0
  248. devflow_engine/vendor/datalumina_genai/core/__init__.py +0 -0
  249. devflow_engine/vendor/datalumina_genai/core/exceptions.py +9 -0
  250. devflow_engine/vendor/datalumina_genai/core/nodes/__init__.py +0 -0
  251. devflow_engine/vendor/datalumina_genai/core/nodes/agent.py +48 -0
  252. devflow_engine/vendor/datalumina_genai/core/nodes/agent_streaming_node.py +26 -0
  253. devflow_engine/vendor/datalumina_genai/core/nodes/base.py +89 -0
  254. devflow_engine/vendor/datalumina_genai/core/nodes/concurrent.py +30 -0
  255. devflow_engine/vendor/datalumina_genai/core/nodes/router.py +69 -0
  256. devflow_engine/vendor/datalumina_genai/core/schema.py +72 -0
  257. devflow_engine/vendor/datalumina_genai/core/task.py +52 -0
  258. devflow_engine/vendor/datalumina_genai/core/validate.py +139 -0
  259. devflow_engine/vendor/datalumina_genai/core/workflow.py +200 -0
  260. devflow_engine/worker.py +1086 -0
  261. devflow_engine/worker_guard.py +233 -0
  262. devflow_engine-1.0.0.dist-info/METADATA +235 -0
  263. devflow_engine-1.0.0.dist-info/RECORD +393 -0
  264. devflow_engine-1.0.0.dist-info/WHEEL +4 -0
  265. devflow_engine-1.0.0.dist-info/entry_points.txt +3 -0
  266. devin/__init__.py +6 -0
  267. devin/dag.py +58 -0
  268. devin/dag_two_arm.py +138 -0
  269. devin/devin_chat_scenario_catalog.json +588 -0
  270. devin/devin_eval.py +677 -0
  271. devin/nodes/__init__.py +0 -0
  272. devin/nodes/ideation/__init__.py +0 -0
  273. devin/nodes/ideation/node.py +195 -0
  274. devin/nodes/ideation/playground.py +267 -0
  275. devin/nodes/ideation/prompt.md +65 -0
  276. devin/nodes/ideation/scenarios/continue_refinement.py +13 -0
  277. devin/nodes/ideation/scenarios/continue_refinement_evals.py +18 -0
  278. devin/nodes/ideation/scenarios/idea_fits_existing_patterns.py +17 -0
  279. devin/nodes/ideation/scenarios/idea_fits_existing_patterns_evals.py +16 -0
  280. devin/nodes/ideation/scenarios/large_idea_split.py +4 -0
  281. devin/nodes/ideation/scenarios/large_idea_split_evals.py +17 -0
  282. devin/nodes/ideation/scenarios/source_documentation_added.py +4 -0
  283. devin/nodes/ideation/scenarios/source_documentation_added_evals.py +16 -0
  284. devin/nodes/ideation/scenarios/user_says_create_it.py +30 -0
  285. devin/nodes/ideation/scenarios/user_says_create_it_evals.py +23 -0
  286. devin/nodes/ideation/scenarios/vague_idea.py +16 -0
  287. devin/nodes/ideation/scenarios/vague_idea_evals.py +47 -0
  288. devin/nodes/ideation/tools.json +312 -0
  289. devin/nodes/insight/__init__.py +0 -0
  290. devin/nodes/insight/node.py +49 -0
  291. devin/nodes/insight/playground.py +154 -0
  292. devin/nodes/insight/prompt.md +61 -0
  293. devin/nodes/insight/scenarios/architecture_pattern_query.py +15 -0
  294. devin/nodes/insight/scenarios/architecture_pattern_query_evals.py +25 -0
  295. devin/nodes/insight/scenarios/codebase_exploration.py +15 -0
  296. devin/nodes/insight/scenarios/codebase_exploration_evals.py +23 -0
  297. devin/nodes/insight/scenarios/devin_ideation_routing.py +19 -0
  298. devin/nodes/insight/scenarios/devin_ideation_routing_evals.py +39 -0
  299. devin/nodes/insight/scenarios/devin_insight_routing.py +20 -0
  300. devin/nodes/insight/scenarios/devin_insight_routing_evals.py +40 -0
  301. devin/nodes/insight/scenarios/operational_debugging.py +15 -0
  302. devin/nodes/insight/scenarios/operational_debugging_evals.py +23 -0
  303. devin/nodes/insight/scenarios/operational_question.py +9 -0
  304. devin/nodes/insight/scenarios/operational_question_evals.py +8 -0
  305. devin/nodes/insight/scenarios/queue_status.py +15 -0
  306. devin/nodes/insight/scenarios/queue_status_evals.py +23 -0
  307. devin/nodes/insight/scenarios/source_doc_explanation.py +14 -0
  308. devin/nodes/insight/scenarios/source_doc_explanation_evals.py +21 -0
  309. devin/nodes/insight/scenarios/worker_state_check.py +15 -0
  310. devin/nodes/insight/scenarios/worker_state_check_evals.py +22 -0
  311. devin/nodes/insight/tools.json +126 -0
  312. devin/nodes/intake/__init__.py +0 -0
  313. devin/nodes/intake/node.py +27 -0
  314. devin/nodes/intake/playground.py +47 -0
  315. devin/nodes/intake/prompt.md +12 -0
  316. devin/nodes/intake/scenarios/ideation_routing.py +4 -0
  317. devin/nodes/intake/scenarios/ideation_routing_evals.py +5 -0
  318. devin/nodes/intake/scenarios/insight_routing.py +4 -0
  319. devin/nodes/intake/scenarios/insight_routing_evals.py +5 -0
  320. devin/nodes/iterate/README.md +44 -0
  321. devin/nodes/iterate/__init__.py +1 -0
  322. devin/nodes/iterate/_archived_design_stages/01-objectives-requirements.md +112 -0
  323. devin/nodes/iterate/_archived_design_stages/02-evals.md +131 -0
  324. devin/nodes/iterate/_archived_design_stages/03-tools-and-boundaries.md +110 -0
  325. devin/nodes/iterate/_archived_design_stages/04-harness-and-playground.md +32 -0
  326. devin/nodes/iterate/_archived_design_stages/05-prompt-deferred.md +11 -0
  327. devin/nodes/iterate/_archived_design_stages/coder_agent_design/01-objectives-requirements.md +20 -0
  328. devin/nodes/iterate/_archived_design_stages/coder_agent_design/02-evals.md +8 -0
  329. devin/nodes/iterate/_archived_design_stages/coder_agent_design/03-tools-and-boundaries.md +14 -0
  330. devin/nodes/iterate/_archived_design_stages/coder_agent_design/04-harness-and-playground.md +12 -0
  331. devin/nodes/iterate/_archived_design_stages/framer_agent_design/01-objectives-requirements.md +20 -0
  332. devin/nodes/iterate/_archived_design_stages/framer_agent_design/02-evals.md +8 -0
  333. devin/nodes/iterate/_archived_design_stages/framer_agent_design/03-tools-and-boundaries.md +13 -0
  334. devin/nodes/iterate/_archived_design_stages/framer_agent_design/04-harness-and-playground.md +12 -0
  335. devin/nodes/iterate/_archived_design_stages/iterator_agent_design/01-objectives-requirements.md +25 -0
  336. devin/nodes/iterate/_archived_design_stages/iterator_agent_design/02-evals.md +9 -0
  337. devin/nodes/iterate/_archived_design_stages/iterator_agent_design/03-tools-and-boundaries.md +14 -0
  338. devin/nodes/iterate/_archived_design_stages/iterator_agent_design/04-harness-and-playground.md +12 -0
  339. devin/nodes/iterate/_archived_design_stages/observer_agent_design/01-objectives-requirements.md +20 -0
  340. devin/nodes/iterate/_archived_design_stages/observer_agent_design/02-evals.md +8 -0
  341. devin/nodes/iterate/_archived_design_stages/observer_agent_design/03-tools-and-boundaries.md +14 -0
  342. devin/nodes/iterate/_archived_design_stages/observer_agent_design/04-harness-and-playground.md +13 -0
  343. devin/nodes/iterate/agent-roles.md +89 -0
  344. devin/nodes/iterate/agents/README.md +10 -0
  345. devin/nodes/iterate/artifacts.md +504 -0
  346. devin/nodes/iterate/contract.md +100 -0
  347. devin/nodes/iterate/eval-plan.md +74 -0
  348. devin/nodes/iterate/node.py +100 -0
  349. devin/nodes/iterate/pipeline/README.md +13 -0
  350. devin/nodes/iterate/playground-contract.md +76 -0
  351. devin/nodes/iterate/prompt.md +11 -0
  352. devin/nodes/iterate/scenarios/README.md +38 -0
  353. devin/nodes/iterate/scenarios/artifact-and-loop-scenarios.md +101 -0
  354. devin/nodes/iterate/scenarios/coder_artifact_alignment.py +32 -0
  355. devin/nodes/iterate/scenarios/coder_artifact_alignment_evals.py +45 -0
  356. devin/nodes/iterate/scenarios/coder_bounded_fix.py +27 -0
  357. devin/nodes/iterate/scenarios/coder_bounded_fix_evals.py +45 -0
  358. devin/nodes/iterate/scenarios/devin_iterate_routing.py +21 -0
  359. devin/nodes/iterate/scenarios/devin_iterate_routing_evals.py +36 -0
  360. devin/nodes/iterate/scenarios/framer_scope_boundary.py +25 -0
  361. devin/nodes/iterate/scenarios/framer_scope_boundary_evals.py +57 -0
  362. devin/nodes/iterate/scenarios/framer_task_framing.py +25 -0
  363. devin/nodes/iterate/scenarios/framer_task_framing_evals.py +58 -0
  364. devin/nodes/iterate/scenarios/iterate_error_fix.py +21 -0
  365. devin/nodes/iterate/scenarios/iterate_error_fix_evals.py +39 -0
  366. devin/nodes/iterate/scenarios/iterate_quick_change.py +21 -0
  367. devin/nodes/iterate/scenarios/iterate_quick_change_evals.py +35 -0
  368. devin/nodes/iterate/scenarios/iterate_to_idea_promotion.py +23 -0
  369. devin/nodes/iterate/scenarios/iterate_to_idea_promotion_evals.py +53 -0
  370. devin/nodes/iterate/scenarios/iterate_to_insight_reroute.py +23 -0
  371. devin/nodes/iterate/scenarios/iterate_to_insight_reroute_evals.py +53 -0
  372. devin/nodes/iterate/scenarios/observer_evidence_seam.py +28 -0
  373. devin/nodes/iterate/scenarios/observer_evidence_seam_evals.py +55 -0
  374. devin/nodes/iterate/scenarios/observer_repro_creation.py +28 -0
  375. devin/nodes/iterate/scenarios/observer_repro_creation_evals.py +45 -0
  376. devin/nodes/iterate/scenarios/routing-matrix.md +45 -0
  377. devin/nodes/shared/__init__.py +0 -0
  378. devin/nodes/shared/filemaker_expert.md +80 -0
  379. devin/nodes/shared/filemaker_expert.py +354 -0
  380. devin/nodes/shared/filemaker_expert_eval/runner.py +176 -0
  381. devin/nodes/shared/filemaker_expert_eval/scenarios.json +65 -0
  382. devin/nodes/shared/goldilocks_advisor_eval/runner.py +214 -0
  383. devin/nodes/shared/goldilocks_advisor_eval/scenarios.json +58 -0
  384. devin/nodes/shared/helpers.py +156 -0
  385. devin/nodes/shared/idea_compliance_advisor_eval/runner.py +252 -0
  386. devin/nodes/shared/idea_compliance_advisor_eval/scenarios.json +75 -0
  387. devin/nodes/shared/models.py +44 -0
  388. devin/nodes/shared/post.py +40 -0
  389. devin/nodes/shared/router.py +107 -0
  390. devin/nodes/shared/tools.py +191 -0
  391. devin/shared/devin-chat-rubric.md +237 -0
  392. devin/shared/devin-chat-scenario-suite.md +90 -0
  393. devin/shared/eval_doctrine.md +9 -0
@@ -0,0 +1,623 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import os
5
+ import re
6
+ import sys
7
+ from pathlib import Path
8
+ from typing import Any
9
+
10
+ import tomllib
11
+
12
+ from ..llm.execution_context import get_execution_context
13
+
14
+
15
+ REPO_TEST_RUNTIME_DEFAULTS = Path(".devflow") / "test_runtime.json"
16
+ REPO_RED_CONFIG = Path(".redconfig.jsonc")
17
+ _STORY_TEST_SUFFIXES = {".py", ".js", ".ts", ".jsx", ".tsx", ".mjs", ".cjs"}
18
+
19
+
20
+ def _pytest_marker_examples() -> list[str]:
21
+ return [
22
+ "pytestmark = [",
23
+ ' pytest.mark.story_id("<story_id>"),',
24
+ ' pytest.mark.story_uuid("<story_uuid>"),',
25
+ ' pytest.mark.plane("<plane>"),',
26
+ "]",
27
+ ]
28
+
29
+
30
+ def _pytest_runtime_notes() -> list[str]:
31
+ return [
32
+ "For Python pytest files, use a valid module-level `pytestmark = [...]` assignment or function/class decorators for story markers.",
33
+ "Do not place bare `@pytest.mark.*` decorators at Python module top level before the module docstring or imports; that shape is invalid syntax.",
34
+ ]
35
+
36
+
37
+ def _is_legacy_pytest_marker_examples(marker_examples: list[str]) -> bool:
38
+ return any(example.strip().startswith("@pytest.mark.") for example in marker_examples)
39
+
40
+
41
+ def repo_test_runtime_defaults_path(repo_root: Path) -> Path:
42
+ return repo_root / REPO_TEST_RUNTIME_DEFAULTS
43
+
44
+
45
+ def repo_red_config_path(repo_root: Path) -> Path:
46
+ return repo_root / REPO_RED_CONFIG
47
+
48
+
49
+ def _parse_jsonc(text: str) -> Any:
50
+ """Strip ``//`` line comments and ``/* */`` block comments then JSON-parse.
51
+
52
+ Comments inside JSON string literals are preserved.
53
+ """
54
+ result: list[str] = []
55
+ i = 0
56
+ length = len(text)
57
+ while i < length:
58
+ # String literal – copy verbatim (including any // or /* inside)
59
+ if text[i] == '"':
60
+ j = i + 1
61
+ while j < length:
62
+ if text[j] == '\\':
63
+ j += 2
64
+ continue
65
+ if text[j] == '"':
66
+ j += 1
67
+ break
68
+ j += 1
69
+ result.append(text[i:j])
70
+ i = j
71
+ # Line comment
72
+ elif text[i:i + 2] == '//':
73
+ j = text.find('\n', i)
74
+ if j == -1:
75
+ break
76
+ i = j # keep the newline itself
77
+ # Block comment
78
+ elif text[i:i + 2] == '/*':
79
+ j = text.find('*/', i + 2)
80
+ if j == -1:
81
+ break
82
+ i = j + 2
83
+ else:
84
+ result.append(text[i])
85
+ i += 1
86
+ return json.loads("".join(result))
87
+
88
+
89
+ def story_test_runtime_contract_path(*, repo_root: Path, story_id: str) -> Path:
90
+ safe_story_id = re.sub(r"[^A-Za-z0-9_.-]+", "_", story_id) or "unknown_story"
91
+ return _story_state_root(repo_root=repo_root) / safe_story_id / "test_runtime.json"
92
+
93
+
94
+ def _story_state_root(*, repo_root: Path) -> Path:
95
+ ctx = get_execution_context() or {}
96
+ override = str(ctx.get("devflow_story_state_root") or "").strip()
97
+ if override:
98
+ return Path(override)
99
+ return repo_root / ".devflow" / "stories"
100
+
101
+
102
+ def _load_json_if_exists(path: Path) -> dict[str, Any] | None:
103
+ if not path.exists() or not path.is_file():
104
+ return None
105
+ try:
106
+ payload = json.loads(path.read_text(encoding="utf-8"))
107
+ except Exception:
108
+ return None
109
+ return payload if isinstance(payload, dict) else None
110
+
111
+
112
+ def _load_jsonc_if_exists(path: Path) -> dict[str, Any] | None:
113
+ if not path.exists() or not path.is_file():
114
+ return None
115
+ try:
116
+ payload = _parse_jsonc(path.read_text(encoding="utf-8"))
117
+ except Exception:
118
+ return None
119
+ return payload if isinstance(payload, dict) else None
120
+
121
+
122
+ def _string_map(raw: Any) -> dict[str, str]:
123
+ if not isinstance(raw, dict):
124
+ return {}
125
+ normalized: dict[str, str] = {}
126
+ for key, value in raw.items():
127
+ key_text = str(key or "").strip()
128
+ if not key_text:
129
+ continue
130
+ normalized[key_text] = str(value)
131
+ return normalized
132
+
133
+
134
+ def _string_list(raw: Any) -> list[str]:
135
+ if isinstance(raw, (list, tuple)):
136
+ return [str(item) for item in raw if str(item).strip()]
137
+ return []
138
+
139
+
140
+ def _bool_value(raw: Any) -> bool | None:
141
+ if isinstance(raw, bool):
142
+ return raw
143
+ return None
144
+
145
+
146
+ def infer_test_runtime_contract(repo_root: Path) -> dict[str, Any]:
147
+ package_json = repo_root / "package.json"
148
+ pyproject_toml = repo_root / "pyproject.toml"
149
+ pytest_examples: list[Path] = []
150
+ for pattern in ("tests/**/*.py", "fastapi_backend/tests/**/*.py", "backend/tests/**/*.py"):
151
+ pytest_examples.extend(
152
+ [
153
+ p for p in sorted(repo_root.glob(pattern))
154
+ if p.is_file() and "__pycache__" not in p.parts
155
+ ]
156
+ )
157
+ vitest_examples: list[Path] = []
158
+ for pattern in (
159
+ "tests/**/*.test.ts",
160
+ "tests/**/*.spec.ts",
161
+ "tests/**/*.test.js",
162
+ "tests/**/*.spec.js",
163
+ "tests/**/*.test.mjs",
164
+ "tests/**/*.spec.mjs",
165
+ ):
166
+ vitest_examples.extend([p for p in sorted(repo_root.glob(pattern)) if p.is_file()])
167
+ if package_json.exists():
168
+ try:
169
+ pkg = json.loads(package_json.read_text(encoding="utf-8"))
170
+ except Exception:
171
+ pkg = {}
172
+ deps = {
173
+ **dict(pkg.get("dependencies") or {}),
174
+ **dict(pkg.get("devDependencies") or {}),
175
+ }
176
+ scripts = dict(pkg.get("scripts") or {})
177
+ if "vitest" in deps or any("vitest" in str(value) for value in scripts.values()):
178
+ example_paths = [str(p.relative_to(repo_root)) for p in vitest_examples[:3]]
179
+ return {
180
+ "framework": "vitest",
181
+ "cwd": ".",
182
+ "env": {},
183
+ "test_paths": [],
184
+ "run_cmd": ["npx", "vitest", "run"],
185
+ "file_globs": [
186
+ "tests/**/*.test.ts",
187
+ "tests/**/*.spec.ts",
188
+ "tests/**/*.test.js",
189
+ "tests/**/*.spec.js",
190
+ ],
191
+ "marker_format": "comment",
192
+ "marker_examples": [
193
+ "// @story_id: <story_id>",
194
+ "// @story_uuid: <story_uuid>",
195
+ "// @plane: <plane>",
196
+ ],
197
+ "example_paths": example_paths,
198
+ "source": "inferred",
199
+ }
200
+ if pyproject_toml.exists():
201
+ try:
202
+ cfg = tomllib.loads(pyproject_toml.read_text(encoding="utf-8"))
203
+ except Exception:
204
+ cfg = {}
205
+ project = dict(cfg.get("project") or {})
206
+ deps = [str(item) for item in project.get("dependencies") or []]
207
+ tool = cfg.get("tool", {}) if isinstance(cfg.get("tool"), dict) else {}
208
+ if "pytest" in " ".join(deps).lower() or "pytest" in json.dumps(tool).lower() or pytest_examples:
209
+ example_paths = [str(p.relative_to(repo_root)) for p in pytest_examples[:3]]
210
+ return {
211
+ "framework": "pytest",
212
+ "cwd": ".",
213
+ "env": {},
214
+ "test_paths": [],
215
+ "run_cmd": [sys.executable or "python3", "-m", "pytest"],
216
+ "file_globs": ["tests/**/*.py"],
217
+ "marker_format": "pytest_decorator",
218
+ "marker_examples": _pytest_marker_examples(),
219
+ "notes": _pytest_runtime_notes(),
220
+ "example_paths": example_paths,
221
+ "source": "inferred",
222
+ }
223
+ example_paths = [str(p.relative_to(repo_root)) for p in pytest_examples[:3]]
224
+ return {
225
+ "framework": "pytest",
226
+ "cwd": ".",
227
+ "env": {},
228
+ "test_paths": [],
229
+ "run_cmd": [sys.executable or "python3", "-m", "pytest"],
230
+ "file_globs": ["tests/**/*.py"],
231
+ "marker_format": "pytest_decorator",
232
+ "marker_examples": _pytest_marker_examples(),
233
+ "notes": _pytest_runtime_notes(),
234
+ "example_paths": example_paths,
235
+ "source": "inferred",
236
+ }
237
+
238
+
239
+ def _normalize_loaded_runtime_contract(
240
+ *,
241
+ repo_root: Path,
242
+ contract: dict[str, Any],
243
+ story_id: str,
244
+ story_uuid: str | None = None,
245
+ source: str,
246
+ fallback: dict[str, Any] | None = None,
247
+ ) -> dict[str, Any]:
248
+ return normalize_story_runtime_contract(
249
+ repo_root=repo_root,
250
+ contract=contract,
251
+ story_id=story_id,
252
+ story_uuid=story_uuid,
253
+ source=source,
254
+ fallback=fallback,
255
+ )
256
+
257
+
258
+ def load_repo_test_runtime_defaults(repo_root: Path) -> dict[str, Any] | None:
259
+ payload = _load_json_if_exists(repo_test_runtime_defaults_path(repo_root)) or {}
260
+ redconfig_payload = _load_jsonc_if_exists(repo_red_config_path(repo_root)) or {}
261
+ if not payload and not redconfig_payload:
262
+ return None
263
+ payload = _merge_contract(payload, redconfig_payload)
264
+ normalized: dict[str, Any] = {}
265
+ framework = str(payload.get("framework") or "").strip()
266
+ if framework:
267
+ normalized["framework"] = framework
268
+ run_cmd = _string_list(payload.get("run_cmd") or payload.get("runner"))
269
+ if run_cmd:
270
+ normalized["run_cmd"] = run_cmd
271
+ cwd = str(payload.get("cwd") or "").strip()
272
+ if cwd:
273
+ normalized["cwd"] = cwd
274
+ env = _string_map(payload.get("env"))
275
+ if env:
276
+ normalized["env"] = env
277
+ setup_cmd = _string_list(payload.get("setup_cmd"))
278
+ if setup_cmd:
279
+ normalized["setup_cmd"] = setup_cmd
280
+ test_path_strip_prefix = str(payload.get("test_path_strip_prefix") or "").strip()
281
+ if test_path_strip_prefix:
282
+ normalized["test_path_strip_prefix"] = test_path_strip_prefix
283
+ file_globs = _string_list(payload.get("file_globs"))
284
+ if file_globs:
285
+ normalized["file_globs"] = file_globs
286
+ marker_format = str(payload.get("marker_format") or "").strip()
287
+ if marker_format:
288
+ normalized["marker_format"] = marker_format
289
+ marker_examples = _string_list(payload.get("marker_examples"))
290
+ if marker_examples:
291
+ normalized["marker_examples"] = marker_examples
292
+ example_paths = _string_list(payload.get("example_paths"))
293
+ if example_paths:
294
+ normalized["example_paths"] = example_paths
295
+ test_paths = _string_list(payload.get("test_paths"))
296
+ if test_paths:
297
+ normalized["test_paths"] = test_paths
298
+ notes = _string_list(payload.get("notes"))
299
+ if notes:
300
+ normalized["notes"] = notes
301
+ command_verified = _bool_value(payload.get("command_verified"))
302
+ if command_verified is not None:
303
+ normalized["command_verified"] = command_verified
304
+ command_verification_mode = str(payload.get("command_verification_mode") or "").strip()
305
+ if command_verification_mode:
306
+ normalized["command_verification_mode"] = command_verification_mode
307
+ verified_run_cmd = _string_list(payload.get("verified_run_cmd"))
308
+ if verified_run_cmd:
309
+ normalized["verified_run_cmd"] = verified_run_cmd
310
+ canonical_test_cmd = _string_list(payload.get("canonical_test_cmd"))
311
+ if canonical_test_cmd:
312
+ normalized["canonical_test_cmd"] = canonical_test_cmd
313
+ canonical_test_cwd = str(payload.get("canonical_test_cwd") or "").strip()
314
+ if canonical_test_cwd:
315
+ normalized["canonical_test_cwd"] = canonical_test_cwd
316
+ normalized["source"] = "repo_defaults"
317
+ normalized = _normalize_loaded_runtime_contract(
318
+ repo_root=repo_root,
319
+ contract=normalized,
320
+ story_id=str(normalized.get("story_id") or "repo_defaults"),
321
+ story_uuid=str(normalized.get("story_uuid") or "").strip() or None,
322
+ source="repo_defaults",
323
+ )
324
+ normalized.pop("story_id", None)
325
+ normalized.pop("story_uuid", None)
326
+ if not normalized.get("test_paths"):
327
+ normalized.pop("test_paths", None)
328
+ if not normalized.get("example_paths"):
329
+ normalized.pop("example_paths", None)
330
+ return normalized
331
+
332
+
333
+ def load_story_test_runtime_contract(*, repo_root: Path, story_id: str) -> dict[str, Any] | None:
334
+ path = story_test_runtime_contract_path(repo_root=repo_root, story_id=story_id)
335
+ payload = _load_json_if_exists(path)
336
+ if payload is None:
337
+ return None
338
+ normalized = _normalize_loaded_runtime_contract(
339
+ repo_root=repo_root,
340
+ contract=payload,
341
+ story_id=story_id,
342
+ story_uuid=str(payload.get("story_uuid") or "").strip() or None,
343
+ source=str(payload.get("source") or "story_runtime_contract"),
344
+ fallback=load_repo_test_runtime_defaults(repo_root),
345
+ )
346
+ if normalized != payload:
347
+ persist_story_runtime_contract(repo_root=repo_root, contract=normalized)
348
+ return normalized
349
+
350
+
351
+ def discover_story_scoped_test_paths(*, repo_root: Path, story_id: str | None = None, story_uuid: str | None = None) -> list[str]:
352
+ needles = [str(story_id or "").strip(), str(story_uuid or "").strip()]
353
+ needles = [needle for needle in needles if needle]
354
+ if not needles:
355
+ return []
356
+ roots = [
357
+ repo_root / "tests",
358
+ repo_root / "fastapi_backend" / "tests",
359
+ repo_root / "frontend" / "tests",
360
+ repo_root / "backend" / "tests",
361
+ ]
362
+ discovered: list[str] = []
363
+ seen: set[str] = set()
364
+ for tests_dir in roots:
365
+ if not tests_dir.exists():
366
+ continue
367
+ for path in sorted(tests_dir.rglob("*")):
368
+ if not path.is_file() or path.name.startswith(".") or path.suffix not in _STORY_TEST_SUFFIXES:
369
+ continue
370
+ try:
371
+ content = path.read_text(encoding="utf-8")
372
+ except Exception:
373
+ continue
374
+ if not any(needle in content for needle in needles):
375
+ continue
376
+ rel = str(path.relative_to(repo_root))
377
+ if rel in seen:
378
+ continue
379
+ seen.add(rel)
380
+ discovered.append(rel)
381
+ return discovered
382
+
383
+
384
+ def _merge_contract(base: dict[str, Any], overlay: dict[str, Any] | None) -> dict[str, Any]:
385
+ if not overlay:
386
+ return dict(base)
387
+ merged = dict(base)
388
+ for key, value in overlay.items():
389
+ if key == "env":
390
+ merged["env"] = {**_string_map(base.get("env")), **_string_map(value)}
391
+ continue
392
+ if key == "test_path_strip_prefix":
393
+ prefix = str(value or "").strip()
394
+ if prefix:
395
+ merged[key] = prefix
396
+ else:
397
+ merged.pop(key, None)
398
+ continue
399
+ if key in {"notes", "test_paths", "example_paths", "marker_examples", "file_globs", "verified_run_cmd", "canonical_test_cmd"}:
400
+ merged[key] = _string_list(value)
401
+ continue
402
+ if key in {"run_cmd", "setup_cmd", "runner"}:
403
+ argv = _string_list(value)
404
+ if argv:
405
+ merged["run_cmd" if key in {"run_cmd", "runner"} else key] = argv
406
+ continue
407
+ if key == "command_verified":
408
+ verified = _bool_value(value)
409
+ if verified is not None:
410
+ merged[key] = verified
411
+ continue
412
+ if key == "command_verification_mode":
413
+ mode = str(value or "").strip()
414
+ if mode:
415
+ merged[key] = mode
416
+ else:
417
+ merged.pop(key, None)
418
+ continue
419
+ if key == "canonical_test_cwd":
420
+ cwd = str(value or "").strip()
421
+ if cwd:
422
+ merged[key] = cwd
423
+ else:
424
+ merged.pop(key, None)
425
+ continue
426
+ merged[key] = value
427
+ return merged
428
+
429
+
430
+ def normalize_story_runtime_contract(
431
+ *,
432
+ repo_root: Path,
433
+ contract: dict[str, Any],
434
+ story_id: str,
435
+ story_uuid: str | None = None,
436
+ source: str,
437
+ fallback: dict[str, Any] | None = None,
438
+ ) -> dict[str, Any]:
439
+ base = infer_test_runtime_contract(repo_root)
440
+ if fallback:
441
+ base = _merge_contract(base, fallback)
442
+ merged = _merge_contract(base, contract)
443
+ normalized = dict(merged)
444
+ normalized["framework"] = str(normalized.get("framework") or base.get("framework") or "pytest").strip() or "pytest"
445
+ normalized["cwd"] = str(normalized.get("cwd") or ".").strip() or "."
446
+ normalized["run_cmd"] = _string_list(normalized.get("run_cmd")) or _string_list(base.get("run_cmd")) or [sys.executable or "python3", "-m", "pytest"]
447
+ normalized["env"] = _string_map(normalized.get("env"))
448
+ normalized["test_paths"] = _string_list(normalized.get("test_paths"))
449
+ test_path_strip_prefix = str(normalized.get("test_path_strip_prefix") or "").strip()
450
+ if test_path_strip_prefix:
451
+ normalized["test_path_strip_prefix"] = test_path_strip_prefix
452
+ else:
453
+ normalized.pop("test_path_strip_prefix", None)
454
+ normalized["story_id"] = story_id
455
+ if story_uuid:
456
+ normalized["story_uuid"] = story_uuid
457
+ if normalized.get("setup_cmd"):
458
+ normalized["setup_cmd"] = _string_list(normalized.get("setup_cmd"))
459
+ else:
460
+ normalized.pop("setup_cmd", None)
461
+ command_verified = _bool_value(normalized.get("command_verified"))
462
+ if command_verified is not None:
463
+ normalized["command_verified"] = command_verified
464
+ else:
465
+ normalized.pop("command_verified", None)
466
+ command_verification_mode = str(normalized.get("command_verification_mode") or "").strip()
467
+ if command_verification_mode:
468
+ normalized["command_verification_mode"] = command_verification_mode
469
+ else:
470
+ normalized.pop("command_verification_mode", None)
471
+ verified_run_cmd = _string_list(normalized.get("verified_run_cmd"))
472
+ if verified_run_cmd:
473
+ normalized["verified_run_cmd"] = verified_run_cmd
474
+ else:
475
+ normalized.pop("verified_run_cmd", None)
476
+ canonical_test_cmd = _string_list(normalized.get("canonical_test_cmd"))
477
+ if canonical_test_cmd:
478
+ normalized["canonical_test_cmd"] = canonical_test_cmd
479
+ else:
480
+ normalized.pop("canonical_test_cmd", None)
481
+ canonical_test_cwd = str(normalized.get("canonical_test_cwd") or "").strip()
482
+ if canonical_test_cwd:
483
+ normalized["canonical_test_cwd"] = canonical_test_cwd
484
+ else:
485
+ normalized.pop("canonical_test_cwd", None)
486
+ notes = _string_list(normalized.get("notes"))
487
+ if str(normalized.get("framework") or "").strip().lower() == "pytest":
488
+ marker_examples = _string_list(normalized.get("marker_examples"))
489
+ if not marker_examples or _is_legacy_pytest_marker_examples(marker_examples):
490
+ normalized["marker_examples"] = _pytest_marker_examples()
491
+ notes = list(dict.fromkeys([*notes, *_pytest_runtime_notes()]))
492
+ if notes:
493
+ normalized["notes"] = notes
494
+ else:
495
+ normalized.pop("notes", None)
496
+ normalized["source"] = source
497
+ return normalized
498
+
499
+
500
+ def resolve_story_runtime_contract(
501
+ *,
502
+ repo_root: Path,
503
+ story_id: str,
504
+ story_uuid: str | None = None,
505
+ test_paths: list[str] | None = None,
506
+ prefer_story_contract: bool = True,
507
+ ) -> dict[str, Any]:
508
+ repo_defaults = load_repo_test_runtime_defaults(repo_root)
509
+ story_contract = load_story_test_runtime_contract(repo_root=repo_root, story_id=story_id) if prefer_story_contract else None
510
+ fallback = repo_defaults or {}
511
+ if story_contract is not None:
512
+ resolved = normalize_story_runtime_contract(
513
+ repo_root=repo_root,
514
+ contract=story_contract,
515
+ story_id=story_id,
516
+ story_uuid=story_uuid,
517
+ source=str(story_contract.get("source") or "story_runtime_contract"),
518
+ fallback=fallback,
519
+ )
520
+ elif repo_defaults is not None:
521
+ resolved = normalize_story_runtime_contract(
522
+ repo_root=repo_root,
523
+ contract=repo_defaults,
524
+ story_id=story_id,
525
+ story_uuid=story_uuid,
526
+ source="repo_defaults",
527
+ )
528
+ else:
529
+ resolved = normalize_story_runtime_contract(
530
+ repo_root=repo_root,
531
+ contract={},
532
+ story_id=story_id,
533
+ story_uuid=story_uuid,
534
+ source="inferred",
535
+ )
536
+ if test_paths is not None:
537
+ resolved["test_paths"] = _string_list(test_paths)
538
+ return resolved
539
+
540
+
541
+ def normalize_recovery_story_runtime_contract(*, repo_root: Path, contract: dict[str, Any]) -> dict[str, Any]:
542
+ normalized = dict(contract)
543
+ run_cmd = _string_list(normalized.get("run_cmd"))
544
+ backend_cwd = _infer_backend_runtime_cwd(repo_root=repo_root, contract=normalized)
545
+ canonical_run_cmd = _unwrap_host_backend_pytest_wrapper(run_cmd)
546
+ if str(normalized.get("framework") or "").strip().lower() != "pytest":
547
+ return normalized
548
+ if backend_cwd is None or canonical_run_cmd is None:
549
+ return normalized
550
+ normalized["cwd"] = backend_cwd
551
+ normalized["run_cmd"] = canonical_run_cmd
552
+ return normalized
553
+
554
+
555
+ def persist_story_runtime_contract(*, repo_root: Path, contract: dict[str, Any]) -> Path:
556
+ story_id = str(contract.get("story_id") or "").strip()
557
+ if not story_id:
558
+ raise ValueError("story runtime contract requires story_id")
559
+ path = story_test_runtime_contract_path(repo_root=repo_root, story_id=story_id)
560
+ path.parent.mkdir(parents=True, exist_ok=True)
561
+ path.write_text(json.dumps(contract, indent=2, sort_keys=True) + "\n", encoding="utf-8")
562
+ return path
563
+
564
+
565
+ def runtime_contract_cwd(*, repo_root: Path, runtime_contract: dict[str, Any]) -> Path:
566
+ cwd = str(runtime_contract.get("cwd") or ".").strip() or "."
567
+ target = Path(cwd)
568
+ if not target.is_absolute():
569
+ target = repo_root / target
570
+ return target
571
+
572
+
573
+ def runtime_contract_env(runtime_contract: dict[str, Any]) -> dict[str, str]:
574
+ return {**os.environ, **_string_map(runtime_contract.get("env"))}
575
+
576
+
577
+ def runtime_contract_test_args(*, runtime_contract: dict[str, Any], test_paths: list[str]) -> list[str]:
578
+ cwd = str(runtime_contract.get("cwd") or ".").strip() or "."
579
+ prefix = f"{cwd.rstrip('/')}/"
580
+ adjusted: list[str] = []
581
+ for path in test_paths:
582
+ value = str(path).strip()
583
+ if cwd not in {"", "."} and value.startswith(prefix):
584
+ value = value[len(prefix):]
585
+ adjusted.append(value)
586
+ return adjusted
587
+
588
+
589
+ def _infer_backend_runtime_cwd(*, repo_root: Path, contract: dict[str, Any]) -> str | None:
590
+ candidates: list[Any] = [
591
+ contract.get("test_paths"),
592
+ contract.get("file_globs"),
593
+ contract.get("example_paths"),
594
+ ]
595
+ for values in candidates:
596
+ for raw in _string_list(values):
597
+ if raw.startswith("fastapi_backend/"):
598
+ return "fastapi_backend"
599
+ if raw.startswith("backend/"):
600
+ return "backend"
601
+ for name in ("fastapi_backend", "backend"):
602
+ if (repo_root / name).exists():
603
+ return name
604
+ return None
605
+
606
+
607
+ def _unwrap_host_backend_pytest_wrapper(run_cmd: list[str]) -> list[str] | None:
608
+ if len(run_cmd) < 4:
609
+ return None
610
+ if run_cmd[:3] == ["docker", "compose", "run"]:
611
+ search_start = 3
612
+ elif run_cmd[:2] == ["docker-compose", "run"]:
613
+ search_start = 2
614
+ else:
615
+ return None
616
+ try:
617
+ service_index = next(index for index in range(search_start, len(run_cmd)) if run_cmd[index] == "backend")
618
+ except StopIteration:
619
+ return None
620
+ nested = run_cmd[service_index + 1 :]
621
+ if nested[:3] == ["uv", "run", "pytest"]:
622
+ return nested
623
+ return None
@@ -0,0 +1,19 @@
1
+ from .dag import (
2
+ CANONICAL_ACTOR_ALLOWED_COMBINATIONS,
3
+ IntegrationDagResult,
4
+ _sync_integration_to_supabase,
5
+ default_integration_stages,
6
+ prepare_integration_payload,
7
+ render_stage_plan,
8
+ run_integration_dag,
9
+ )
10
+
11
+ __all__ = [
12
+ "CANONICAL_ACTOR_ALLOWED_COMBINATIONS",
13
+ "IntegrationDagResult",
14
+ "_sync_integration_to_supabase",
15
+ "default_integration_stages",
16
+ "prepare_integration_payload",
17
+ "render_stage_plan",
18
+ "run_integration_dag",
19
+ ]