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,588 @@
1
+ """Review DAG implementation.
2
+
3
+ DEPRECATED: This module is non-canonical. The `devflow review` CLI surface
4
+ and run_review_dag() are retained for backward compatibility and debugging
5
+ only. Canonical automated execution runs through the queue-driven worker
6
+ pipeline (devflow.worker / `devflow worker start`).
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import hashlib
11
+ import json
12
+ import re
13
+ import time
14
+ import uuid
15
+ from dataclasses import dataclass
16
+ from pathlib import Path
17
+ from typing import Any
18
+
19
+ from pydantic import BaseModel
20
+
21
+ from ..implementation.green_gate import run_green_gate
22
+ from ..review.review_story import review_story_contract
23
+ from ..stores.execution_store import ExecutionStore
24
+ from ..vendor.datalumina_genai.core.nodes.base import Node
25
+ from ..vendor.datalumina_genai.core.schema import NodeConfig, WorkflowSchema
26
+ from ..vendor.datalumina_genai.core.task import TaskContext
27
+ from ..vendor.datalumina_genai.core.workflow import Workflow
28
+
29
+ SEVERITY_ORDER = {"info": 0, "low": 1, "medium": 2, "high": 3, "critical": 4}
30
+ SECRET_PATTERNS = [
31
+ ("private_key", re.compile(r"-----BEGIN [A-Z ]*PRIVATE KEY-----")),
32
+ ("token_like", re.compile(r"(?i)(api[_-]?key|secret|token|password)\s*[:=]\s*([A-Za-z0-9._-]{6,})")),
33
+ ]
34
+
35
+
36
+ @dataclass(frozen=True)
37
+ class ReviewFinding:
38
+ finding_id: str
39
+ category: str
40
+ severity: str
41
+ title: str
42
+ description: str
43
+ recommendation: str
44
+ contract_refs: list[str]
45
+ evidence_refs: list[str]
46
+ fingerprint: str
47
+
48
+
49
+ class ReviewEvent(BaseModel):
50
+ repo_root: str
51
+ story: dict[str, Any]
52
+
53
+
54
+ _CURRENT_STORE: ExecutionStore | None = None
55
+ _CURRENT_RUN_ID: str | None = None
56
+ _CURRENT_REVIEW_RUN_ID: str | None = None
57
+
58
+
59
+ def _runtime() -> tuple[ExecutionStore, str, str]:
60
+ if _CURRENT_STORE is None or _CURRENT_RUN_ID is None or _CURRENT_REVIEW_RUN_ID is None:
61
+ raise RuntimeError("review workflow missing runtime bindings")
62
+ return _CURRENT_STORE, _CURRENT_RUN_ID, _CURRENT_REVIEW_RUN_ID
63
+
64
+
65
+ def _stable_hash(payload: dict[str, Any]) -> str:
66
+ return hashlib.sha256(json.dumps(payload, sort_keys=True).encode("utf-8")).hexdigest()
67
+
68
+
69
+ def _make_finding(
70
+ *,
71
+ category: str,
72
+ severity: str,
73
+ title: str,
74
+ description: str,
75
+ recommendation: str,
76
+ contract_refs: list[str] | None = None,
77
+ evidence_refs: list[str] | None = None,
78
+ ) -> ReviewFinding:
79
+ contract_refs = sorted(contract_refs or [])
80
+ evidence_refs = sorted(evidence_refs or [])
81
+ key = {
82
+ "category": category,
83
+ "severity": severity,
84
+ "title": title,
85
+ "description": description,
86
+ "recommendation": recommendation,
87
+ "contract_refs": contract_refs,
88
+ "evidence_refs": evidence_refs,
89
+ }
90
+ digest = _stable_hash(key)
91
+ return ReviewFinding(
92
+ finding_id=digest[:16],
93
+ category=category,
94
+ severity=severity,
95
+ title=title,
96
+ description=description,
97
+ recommendation=recommendation,
98
+ contract_refs=contract_refs,
99
+ evidence_refs=evidence_refs,
100
+ fingerprint=digest,
101
+ )
102
+
103
+
104
+ def _redact_text(text: str) -> tuple[str, list[dict[str, str]]]:
105
+ redactions: list[dict[str, str]] = []
106
+ redacted = text
107
+ for kind, pattern in SECRET_PATTERNS:
108
+ for match in list(pattern.finditer(redacted)):
109
+ secret_text = match.group(0)
110
+ redactions.append({"kind": kind, "match": secret_text[:32]})
111
+ redacted = redacted.replace(secret_text, f"[REDACTED:{kind}]")
112
+ return redacted, redactions
113
+
114
+
115
+ def _load_story_text(story: dict[str, Any], repo_root: Path) -> str:
116
+ contract = story.get("contract") or {}
117
+ raw_text = str(contract.get("raw_text") or "").strip()
118
+ if raw_text:
119
+ return raw_text + ("\n" if not raw_text.endswith("\n") else "")
120
+
121
+ path_value = story.get("path") or contract.get("source_path")
122
+ if path_value:
123
+ path = Path(str(path_value))
124
+ if not path.is_absolute():
125
+ path = repo_root / path
126
+ if path.exists():
127
+ return path.read_text(encoding="utf-8")
128
+ return ""
129
+
130
+
131
+ def _extract_requirement_refs(story_id: str, story_text: str) -> list[str]:
132
+ refs: list[str] = []
133
+ lines = [line.strip() for line in story_text.splitlines()]
134
+ current_section = "contract"
135
+ index = 0
136
+ for line in lines:
137
+ if not line:
138
+ continue
139
+ if line.startswith("## "):
140
+ current_section = line[3:].strip().lower().replace(" ", "_")
141
+ index = 0
142
+ continue
143
+ if line.startswith("### "):
144
+ current_section = line[4:].strip().lower().replace(" ", "_")
145
+ index = 0
146
+ continue
147
+ if line[:1].isdigit() and ". " in line or line.startswith("- "):
148
+ index += 1
149
+ refs.append(f"{story_id}#{current_section}.{index}")
150
+ return refs
151
+
152
+
153
+ def _persist_node(
154
+ *,
155
+ node_id: str,
156
+ node_name: str,
157
+ output: dict[str, Any] | None = None,
158
+ status: str = "succeeded",
159
+ error: dict[str, Any] | None = None,
160
+ ) -> str:
161
+ store, run_id, _review_run_id = _runtime()
162
+ node_exec_id = store.create_node_attempt(run_id=run_id, node_id=node_id, node_name=node_name, attempt=1)
163
+ store.mark_node_finished(node_exec_id=node_exec_id, status=status, output=output, error=error)
164
+ return node_exec_id
165
+
166
+
167
+ class IngestNode(Node):
168
+ async def process(self, task_context: TaskContext) -> TaskContext:
169
+ store, run_id, review_run_id = _runtime()
170
+ repo_root = Path(task_context.event.repo_root)
171
+ story = dict(task_context.event.story)
172
+ contract = dict(story.get("contract") or {})
173
+ story_id = str(contract.get("story_id") or story.get("story_id") or "").strip() or None
174
+ story_text = _load_story_text(story, repo_root)
175
+ packet = {
176
+ "story_id": story_id,
177
+ "story_uuid": contract.get("story_uuid"),
178
+ "title": contract.get("title") or story.get("title"),
179
+ "required_planes": contract.get("required_planes") or [],
180
+ "plane_oracles": contract.get("plane_oracles") or [],
181
+ "story_path": story.get("path") or contract.get("source_path"),
182
+ "repo_root": str(repo_root),
183
+ }
184
+ packet_hash = _stable_hash(packet)
185
+ packet_id = store.add_review_packet(
186
+ run_id=run_id,
187
+ story_id=story_id,
188
+ summary="review packet",
189
+ findings={"packet_hash": packet_hash, "review_run_id": review_run_id},
190
+ )
191
+ node_exec_id = _persist_node(
192
+ node_id="ingest",
193
+ node_name="Ingest",
194
+ output={"packet_id": packet_id, "packet_hash": packet_hash},
195
+ )
196
+ task_context.metadata["story_id"] = story_id
197
+ task_context.metadata["story_text"] = story_text
198
+ secret_scan_text = story_text + "\n" + json.dumps(contract, sort_keys=True)
199
+ redacted_text, redactions = _redact_text(secret_scan_text)
200
+ task_context.metadata["story_text_redacted"] = redacted_text
201
+ task_context.metadata["redactions"] = redactions
202
+ task_context.metadata["packet"] = packet
203
+ task_context.metadata["packet_hash"] = packet_hash
204
+ task_context.metadata["packet_id"] = packet_id
205
+ task_context.metadata["findings"] = []
206
+ if redactions:
207
+ task_context.metadata["findings"].append(
208
+ _make_finding(
209
+ category="security",
210
+ severity="high",
211
+ title="Secrets detected in review inputs",
212
+ description="Review inputs contained token-like or private-key material and were redacted.",
213
+ recommendation="Remove secrets from story contracts and evidence before review.",
214
+ contract_refs=[f"{story_id or 'story'}#functional_requirements.1"],
215
+ evidence_refs=[f"redaction:{item['kind']}" for item in redactions],
216
+ )
217
+ )
218
+ task_context.metadata["node_exec_ids"] = {"ingest": node_exec_id}
219
+ return task_context
220
+
221
+
222
+ class ValidationGateNode(Node):
223
+ async def process(self, task_context: TaskContext) -> TaskContext:
224
+ results = run_green_gate(Path(task_context.event.repo_root))
225
+ failing = [name for name, result in results.items() if not result.ok]
226
+ output = {
227
+ "checks": {
228
+ name: {
229
+ "ok": result.ok,
230
+ "returncode": result.returncode,
231
+ "stderr": result.stderr,
232
+ "stdout": result.stdout,
233
+ }
234
+ for name, result in results.items()
235
+ }
236
+ }
237
+ status = "succeeded"
238
+ error = None
239
+ if failing:
240
+ status = "failed"
241
+ story_id = str(task_context.metadata.get("story_id") or "story")
242
+ finding = _make_finding(
243
+ category="compliance",
244
+ severity="high",
245
+ title="Validation gate failed",
246
+ description=f"Validation checks failed: {', '.join(sorted(failing))}.",
247
+ recommendation="Fix build/type/test/lint failures before accepting the review.",
248
+ contract_refs=[f"{story_id}#functional_requirements.1"],
249
+ evidence_refs=[f"gate:{name}" for name in sorted(failing)],
250
+ )
251
+ task_context.metadata["findings"].append(finding)
252
+ task_context.metadata["halted"] = True
253
+ error = {"message": "validation gate failed", "checks": failing}
254
+ node_exec_id = _persist_node(
255
+ node_id="validation_gate",
256
+ node_name="ValidationGate",
257
+ output=output,
258
+ status=status,
259
+ error=error,
260
+ )
261
+ task_context.metadata["validation_results"] = output["checks"]
262
+ task_context.metadata["node_exec_ids"]["validation_gate"] = node_exec_id
263
+ return task_context
264
+
265
+
266
+ class SecurityReviewNode(Node):
267
+ async def process(self, task_context: TaskContext) -> TaskContext:
268
+ if task_context.metadata.get("halted"):
269
+ node_exec_id = _persist_node(
270
+ node_id="security_review",
271
+ node_name="SecurityReview",
272
+ output={"reason": "validation gate failed"},
273
+ status="skipped",
274
+ )
275
+ task_context.metadata["node_exec_ids"]["security_review"] = node_exec_id
276
+ return task_context
277
+
278
+ node_exec_id = _persist_node(
279
+ node_id="security_review",
280
+ node_name="SecurityReview",
281
+ output={"redaction_count": len(task_context.metadata.get("redactions") or [])},
282
+ )
283
+ task_context.metadata["node_exec_ids"]["security_review"] = node_exec_id
284
+ return task_context
285
+
286
+
287
+ class ContractReviewNode(Node):
288
+ async def process(self, task_context: TaskContext) -> TaskContext:
289
+ if task_context.metadata.get("halted"):
290
+ node_exec_id = _persist_node(
291
+ node_id="contract_review",
292
+ node_name="ContractReview",
293
+ output={"reason": "validation gate failed"},
294
+ status="skipped",
295
+ )
296
+ task_context.metadata["node_exec_ids"]["contract_review"] = node_exec_id
297
+ return task_context
298
+
299
+ repo_root = Path(task_context.event.repo_root)
300
+ story = dict(task_context.event.story)
301
+ contract = dict(story.get("contract") or {})
302
+ story_id = str(task_context.metadata.get("story_id") or "story")
303
+ requirement_refs = _extract_requirement_refs(story_id, str(task_context.metadata.get("story_text") or ""))
304
+
305
+ for finding in review_story_contract(repo_root, contract):
306
+ task_context.metadata["findings"].append(
307
+ _make_finding(
308
+ category="compliance" if finding.kind == "missing_anchor" else "soundness",
309
+ severity=finding.severity,
310
+ title=finding.kind.replace("_", " ").title(),
311
+ description=finding.message,
312
+ recommendation="Add or repair the missing contract evidence/anchor.",
313
+ contract_refs=requirement_refs[:1] or [f"{story_id}#contract.1"],
314
+ evidence_refs=[str(v) for v in finding.evidence.values() if v],
315
+ )
316
+ )
317
+
318
+ if not requirement_refs:
319
+ task_context.metadata["findings"].append(
320
+ _make_finding(
321
+ category="soundness",
322
+ severity="medium",
323
+ title="Requirement extraction incomplete",
324
+ description="No contract requirement anchors could be extracted from the story markdown.",
325
+ recommendation=(
326
+ "Use canonical story sections so coverage and compliance checks "
327
+ "can map to stable anchors."
328
+ ),
329
+ contract_refs=[f"{story_id}#contract.1"],
330
+ evidence_refs=[],
331
+ )
332
+ )
333
+
334
+ node_exec_id = _persist_node(
335
+ node_id="contract_review",
336
+ node_name="ContractReview",
337
+ output={"requirement_refs": requirement_refs},
338
+ )
339
+ task_context.metadata["requirement_refs"] = requirement_refs
340
+ task_context.metadata["node_exec_ids"]["contract_review"] = node_exec_id
341
+ return task_context
342
+
343
+
344
+ class RegressionReviewNode(Node):
345
+ async def process(self, task_context: TaskContext) -> TaskContext:
346
+ if task_context.metadata.get("halted"):
347
+ node_exec_id = _persist_node(
348
+ node_id="regression_review",
349
+ node_name="RegressionReview",
350
+ output={"reason": "validation gate failed"},
351
+ status="skipped",
352
+ )
353
+ task_context.metadata["node_exec_ids"]["regression_review"] = node_exec_id
354
+ return task_context
355
+
356
+ validation_results = dict(task_context.metadata.get("validation_results") or {})
357
+ failing = sorted(name for name, result in validation_results.items() if not result.get("ok"))
358
+ if failing:
359
+ story_id = str(task_context.metadata.get("story_id") or "story")
360
+ task_context.metadata["findings"].append(
361
+ _make_finding(
362
+ category="soundness",
363
+ severity="high",
364
+ title="Regression suite failed",
365
+ description=f"Full-suite validation reported regressions in: {', '.join(failing)}.",
366
+ recommendation="Stabilize the failing regression suite before approval.",
367
+ contract_refs=[f"{story_id}#test_plan.1"],
368
+ evidence_refs=[f"gate:{name}" for name in failing],
369
+ )
370
+ )
371
+
372
+ node_exec_id = _persist_node(
373
+ node_id="regression_review",
374
+ node_name="RegressionReview",
375
+ output={"failing_checks": failing},
376
+ )
377
+ task_context.metadata["node_exec_ids"]["regression_review"] = node_exec_id
378
+ return task_context
379
+
380
+
381
+ class AggregateOutputNode(Node):
382
+ async def process(self, task_context: TaskContext) -> TaskContext:
383
+ story_id = str(task_context.metadata.get("story_id") or "story")
384
+ packet = dict(task_context.metadata.get("packet") or {})
385
+ redacted_story_text = str(
386
+ task_context.metadata.get("story_text_redacted")
387
+ or task_context.metadata.get("story_text")
388
+ or ""
389
+ )
390
+ findings = sorted(
391
+ task_context.metadata.get("findings") or [],
392
+ key=lambda item: (-SEVERITY_ORDER.get(item.severity, 0), item.category, item.title, item.finding_id),
393
+ )
394
+ report = {
395
+ "review_id": _CURRENT_REVIEW_RUN_ID,
396
+ "story_id": story_id,
397
+ "packet_hash": task_context.metadata.get("packet_hash"),
398
+ "story_hash": _stable_hash({"story_id": story_id, "story_text": redacted_story_text}),
399
+ "review_status": "fail"
400
+ if any(SEVERITY_ORDER.get(item.severity, 0) >= SEVERITY_ORDER["high"] for item in findings)
401
+ else "pass",
402
+ "counts_by_severity": {
403
+ severity: sum(1 for item in findings if item.severity == severity)
404
+ for severity in sorted(SEVERITY_ORDER, key=SEVERITY_ORDER.get)
405
+ },
406
+ "counts_by_category": {
407
+ category: sum(1 for item in findings if item.category == category)
408
+ for category in sorted({item.category for item in findings})
409
+ },
410
+ "findings": [
411
+ {
412
+ "finding_id": item.finding_id,
413
+ "category": item.category,
414
+ "severity": item.severity,
415
+ "title": item.title,
416
+ "description": item.description,
417
+ "recommendation": item.recommendation,
418
+ "contract_refs": item.contract_refs,
419
+ "evidence_refs": item.evidence_refs,
420
+ "fingerprint": item.fingerprint,
421
+ }
422
+ for item in findings
423
+ ],
424
+ "review_packet": packet,
425
+ }
426
+ node_exec_id = _persist_node(
427
+ node_id="aggregate_output",
428
+ node_name="AggregateOutput",
429
+ output={"review_status": report["review_status"], "finding_count": len(findings)},
430
+ )
431
+ task_context.metadata["report"] = report
432
+ task_context.metadata["node_exec_ids"]["aggregate_output"] = node_exec_id
433
+ return task_context
434
+
435
+
436
+ class EmitArtifactsNode(Node):
437
+ async def process(self, task_context: TaskContext) -> TaskContext:
438
+ store, run_id, review_run_id = _runtime()
439
+ repo_root = Path(task_context.event.repo_root)
440
+ report = dict(task_context.metadata.get("report") or {})
441
+ packet = dict(task_context.metadata.get("packet") or {})
442
+ output_dir = repo_root / ".devflow" / "reviews" / review_run_id
443
+ output_dir.mkdir(parents=True, exist_ok=True)
444
+
445
+ report_path = output_dir / "review_report.json"
446
+ summary_path = output_dir / "review_summary.md"
447
+ packet_path = output_dir / "review_packet.canonical.json"
448
+
449
+ report_text = json.dumps(report, sort_keys=True, indent=2) + "\n"
450
+ packet_text = json.dumps(packet, sort_keys=True, indent=2) + "\n"
451
+ summary_text = "\n".join(
452
+ [
453
+ "# Review Summary",
454
+ "",
455
+ f"Review status: {report.get('review_status', 'pass')}",
456
+ f"Story: {task_context.metadata.get('story_id') or ''}",
457
+ f"Findings: {len(report.get('findings') or [])}",
458
+ ]
459
+ ) + "\n"
460
+
461
+ report_path.write_text(report_text, encoding="utf-8")
462
+ summary_path.write_text(summary_text, encoding="utf-8")
463
+ packet_path.write_text(packet_text, encoding="utf-8")
464
+
465
+ node_exec_id = _persist_node(
466
+ node_id="emit_artifacts",
467
+ node_name="EmitArtifacts",
468
+ output={"output_dir": str(output_dir)},
469
+ )
470
+ for kind, path, content in [
471
+ ("review_report", report_path, report_text),
472
+ ("review_summary", summary_path, summary_text),
473
+ ("review_packet", packet_path, packet_text),
474
+ ]:
475
+ store.add_artifact(
476
+ run_id=run_id,
477
+ node_exec_id=node_exec_id,
478
+ kind=kind,
479
+ uri=str(path),
480
+ content_type="application/json" if path.suffix == ".json" else "text/markdown",
481
+ byte_size=len(content.encode("utf-8")),
482
+ sha256=hashlib.sha256(content.encode("utf-8")).hexdigest(),
483
+ metadata={"review_run_id": review_run_id},
484
+ )
485
+
486
+ task_context.metadata["output_dir"] = str(output_dir)
487
+ task_context.metadata["node_exec_ids"]["emit_artifacts"] = node_exec_id
488
+ return task_context
489
+
490
+
491
+ class ReviewWorkflow(Workflow):
492
+ workflow_schema = WorkflowSchema(
493
+ description="DevFlow review DAG (GenAI workflow framework)",
494
+ event_schema=ReviewEvent,
495
+ start=IngestNode,
496
+ nodes=[
497
+ NodeConfig(node=IngestNode, connections=[ValidationGateNode]),
498
+ NodeConfig(node=ValidationGateNode, connections=[SecurityReviewNode]),
499
+ NodeConfig(node=SecurityReviewNode, connections=[ContractReviewNode]),
500
+ NodeConfig(node=ContractReviewNode, connections=[RegressionReviewNode]),
501
+ NodeConfig(node=RegressionReviewNode, connections=[AggregateOutputNode]),
502
+ NodeConfig(node=AggregateOutputNode, connections=[EmitArtifactsNode]),
503
+ NodeConfig(node=EmitArtifactsNode, connections=[]),
504
+ ],
505
+ )
506
+
507
+
508
+ def run_review_dag(*, repo_root: Path, store: ExecutionStore, story: dict[str, Any]) -> tuple[int, str]:
509
+ contract = dict(story.get("contract") or {})
510
+ story_id = str(contract.get("story_id") or story.get("story_id") or "").strip() or None
511
+ story_text = _load_story_text(story, repo_root)
512
+ packet = {
513
+ "story_id": story_id,
514
+ "story_uuid": contract.get("story_uuid"),
515
+ "repo_root": str(repo_root),
516
+ "required_planes": contract.get("required_planes") or [],
517
+ }
518
+ packet_hash = _stable_hash(packet)
519
+ story_hash = _stable_hash({"story_id": story_id, "story_text": story_text})
520
+ config_hash = _stable_hash(
521
+ {
522
+ "checks": [
523
+ "validation_gate",
524
+ "security_review",
525
+ "contract_review",
526
+ "regression_review",
527
+ ]
528
+ }
529
+ )
530
+
531
+ run_id = store.create_run(
532
+ dag_id="review_dag",
533
+ dag_version="v1",
534
+ root_correlation_id=f"corr_{uuid.uuid4()}",
535
+ config={"story_id": story_id, "story_hash": story_hash},
536
+ )
537
+ store.mark_run_started(run_id=run_id)
538
+ review_run_id = store.create_review_run(
539
+ run_id=run_id,
540
+ story_id=story_id,
541
+ packet_hash=packet_hash,
542
+ story_hash=story_hash,
543
+ config_hash=config_hash,
544
+ output_dir=str(repo_root / ".devflow" / "reviews" / "pending"),
545
+ )
546
+
547
+ wf = ReviewWorkflow()
548
+ global _CURRENT_STORE, _CURRENT_RUN_ID, _CURRENT_REVIEW_RUN_ID
549
+ _CURRENT_STORE = store
550
+ _CURRENT_RUN_ID = run_id
551
+ _CURRENT_REVIEW_RUN_ID = review_run_id
552
+ try:
553
+ ctx = wf.run({"repo_root": str(repo_root), "story": story})
554
+ finally:
555
+ _CURRENT_STORE = None
556
+ _CURRENT_RUN_ID = None
557
+ _CURRENT_REVIEW_RUN_ID = None
558
+
559
+ report = dict(ctx.metadata.get("report") or {})
560
+ findings = list(report.get("findings") or [])
561
+ for item in findings:
562
+ store.add_review_finding(
563
+ review_run_id=review_run_id,
564
+ finding_id=str(item.get("finding_id") or ""),
565
+ category=str(item.get("category") or "compliance"),
566
+ severity=str(item.get("severity") or "medium"),
567
+ title=str(item.get("title") or ""),
568
+ description=str(item.get("description") or ""),
569
+ recommendation=str(item.get("recommendation") or ""),
570
+ contract_refs=[str(v) for v in item.get("contract_refs") or []],
571
+ evidence_refs=[str(v) for v in item.get("evidence_refs") or []],
572
+ fingerprint=str(item.get("fingerprint") or "") or None,
573
+ )
574
+
575
+ output_dir = str(ctx.metadata.get("output_dir") or (repo_root / ".devflow" / "reviews" / review_run_id))
576
+ with store._connect() as conn:
577
+ conn.execute(
578
+ "UPDATE review_runs SET output_dir=?, updated_at=? WHERE review_run_id=?",
579
+ (output_dir, int(time.time()), review_run_id),
580
+ )
581
+
582
+ review_status = str(report.get("review_status") or "pass")
583
+ store.mark_review_run_finished(review_run_id=review_run_id, status="succeeded", review_status=review_status)
584
+ store.mark_run_finished(run_id=run_id, status="succeeded")
585
+
586
+ exit_code = 2 if review_status == "fail" else 0
587
+ msg = f"review {'failed' if exit_code else 'passed'}: review_run_id={review_run_id} output_dir={output_dir}\n"
588
+ return exit_code, msg
@@ -0,0 +1,67 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from pathlib import Path
5
+ from typing import Any
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class Finding:
10
+ kind: str
11
+ severity: str
12
+ message: str
13
+ evidence: dict[str, Any]
14
+
15
+
16
+ def _anchor_exists(repo_root: Path, anchor: str) -> bool:
17
+ # For now: treat anchor that looks like a path as filesystem check.
18
+ p = (repo_root / anchor).resolve()
19
+ try:
20
+ p.relative_to(repo_root.resolve())
21
+ except Exception:
22
+ return False
23
+ return p.exists()
24
+
25
+
26
+ def review_story_contract(repo_root: Path, contract: dict[str, Any]) -> list[Finding]:
27
+ findings: list[Finding] = []
28
+
29
+ for oracle in contract.get("plane_oracles", []) or []:
30
+ anchor = oracle.get("anchor")
31
+ plane = oracle.get("plane")
32
+ if not isinstance(anchor, str) or not anchor:
33
+ continue
34
+ if _anchor_exists(repo_root, anchor):
35
+ continue
36
+ findings.append(
37
+ Finding(
38
+ kind="missing_anchor",
39
+ severity="medium",
40
+ message=f"Plane oracle anchor not found: {anchor}",
41
+ evidence={"plane": plane, "anchor": anchor},
42
+ )
43
+ )
44
+
45
+ # Lightweight security/compliance heuristics.
46
+ sec = (contract.get("planes") or {}).get("security", "")
47
+ comp = (contract.get("planes") or {}).get("compliance", "")
48
+ if isinstance(sec, str) and "TODO" in sec:
49
+ findings.append(
50
+ Finding(
51
+ kind="security_todo",
52
+ severity="low",
53
+ message="Security plane still contains TODO",
54
+ evidence={},
55
+ )
56
+ )
57
+ if isinstance(comp, str) and "TODO" in comp:
58
+ findings.append(
59
+ Finding(
60
+ kind="compliance_todo",
61
+ severity="low",
62
+ message="Compliance plane still contains TODO",
63
+ evidence={},
64
+ )
65
+ )
66
+
67
+ return findings
@@ -0,0 +1,3 @@
1
+ from .dag import DAG_ID, ScopeToIdeaDagResult, run_scope_to_idea_dag
2
+
3
+ __all__ = ["DAG_ID", "ScopeToIdeaDagResult", "run_scope_to_idea_dag"]