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.
- devflow_engine/__init__.py +3 -0
- devflow_engine/agentic_prompts.py +100 -0
- devflow_engine/agentic_runtime.py +398 -0
- devflow_engine/api_key_flow_harness.py +539 -0
- devflow_engine/api_keys.py +357 -0
- devflow_engine/bootstrap/__init__.py +2 -0
- devflow_engine/bootstrap/provision_from_template.py +84 -0
- devflow_engine/cli/__init__.py +0 -0
- devflow_engine/cli/app.py +7270 -0
- devflow_engine/core/__init__.py +0 -0
- devflow_engine/core/config.py +86 -0
- devflow_engine/core/logging.py +29 -0
- devflow_engine/core/paths.py +45 -0
- devflow_engine/core/toml_kv.py +33 -0
- devflow_engine/devflow_event_worker.py +1292 -0
- devflow_engine/devflow_state.py +201 -0
- devflow_engine/devin2/__init__.py +9 -0
- devflow_engine/devin2/agent_definition.py +120 -0
- devflow_engine/devin2/pi_runner.py +204 -0
- devflow_engine/devin_orchestration.py +69 -0
- devflow_engine/docs/prompts/anti-patterns.md +42 -0
- devflow_engine/docs/prompts/devin-agent-prompt.md +55 -0
- devflow_engine/docs/prompts/devin2-agent-prompt.md +81 -0
- devflow_engine/docs/prompts/examples/devin-vapi-clone-reference-exchange.json +85 -0
- devflow_engine/doctor/__init__.py +2 -0
- devflow_engine/doctor/triage.py +140 -0
- devflow_engine/error/__init__.py +0 -0
- devflow_engine/error/remediation.py +21 -0
- devflow_engine/errors/error_solver_dag.py +522 -0
- devflow_engine/errors/runtime_observability.py +67 -0
- devflow_engine/idea/__init__.py +4 -0
- devflow_engine/idea/actors.py +481 -0
- devflow_engine/idea/agentic.py +465 -0
- devflow_engine/idea/analyze.py +93 -0
- devflow_engine/idea/devin_chat_dag.py +1 -0
- devflow_engine/idea/diff.py +99 -0
- devflow_engine/idea/drafts.py +446 -0
- devflow_engine/idea/idea_creation_dag.py +643 -0
- devflow_engine/idea/ideation_enrichment.py +355 -0
- devflow_engine/idea/ideation_enrichment_worker.py +19 -0
- devflow_engine/idea/paths.py +28 -0
- devflow_engine/idea/promote.py +53 -0
- devflow_engine/idea/redaction.py +27 -0
- devflow_engine/idea/repo_tools.py +1277 -0
- devflow_engine/idea/response_mode.py +30 -0
- devflow_engine/idea/story_pipeline.py +1585 -0
- devflow_engine/idea/sufficiency.py +376 -0
- devflow_engine/idea/traditional_stories.py +1257 -0
- devflow_engine/implementation/__init__.py +0 -0
- devflow_engine/implementation/alembic_preflight.py +700 -0
- devflow_engine/implementation/dag.py +8450 -0
- devflow_engine/implementation/green_gate.py +93 -0
- devflow_engine/implementation/prompts.py +108 -0
- devflow_engine/implementation/test_runtime.py +623 -0
- devflow_engine/integration/__init__.py +19 -0
- devflow_engine/integration/agentic.py +66 -0
- devflow_engine/integration/dag.py +3539 -0
- devflow_engine/integration/prompts.py +114 -0
- devflow_engine/integration/supabase_schema.sql +31 -0
- devflow_engine/integration/supabase_sync.py +177 -0
- devflow_engine/llm/__init__.py +1 -0
- devflow_engine/llm/cli_one_shot.py +84 -0
- devflow_engine/llm/cli_stream.py +371 -0
- devflow_engine/llm/execution_context.py +26 -0
- devflow_engine/llm/invoke.py +1322 -0
- devflow_engine/llm/provider_api.py +304 -0
- devflow_engine/llm/repo_knowledge.py +588 -0
- devflow_engine/llm_primitives.py +315 -0
- devflow_engine/orchestration.py +62 -0
- devflow_engine/planning/__init__.py +0 -0
- devflow_engine/planning/analyze_repo.py +92 -0
- devflow_engine/planning/render_drafts.py +133 -0
- devflow_engine/playground/__init__.py +0 -0
- devflow_engine/playground/hooks.py +26 -0
- devflow_engine/playwright_workflow/__init__.py +5 -0
- devflow_engine/playwright_workflow/dag.py +1317 -0
- devflow_engine/process/__init__.py +5 -0
- devflow_engine/process/dag.py +59 -0
- devflow_engine/project_registration/__init__.py +3 -0
- devflow_engine/project_registration/dag.py +1581 -0
- devflow_engine/project_registry.py +109 -0
- devflow_engine/prompts/devin/generic/prompt.md +6 -0
- devflow_engine/prompts/devin/ideation/prompt.md +263 -0
- devflow_engine/prompts/devin/ideation/scenarios.md +5 -0
- devflow_engine/prompts/devin/ideation_loop/prompt.md +6 -0
- devflow_engine/prompts/devin/insight/prompt.md +11 -0
- devflow_engine/prompts/devin/insight/scenarios.md +5 -0
- devflow_engine/prompts/devin/intake/prompt.md +15 -0
- devflow_engine/prompts/devin/iterate/prompt.md +12 -0
- devflow_engine/prompts/devin/shared/eval_doctrine.md +9 -0
- devflow_engine/prompts/devin/shared/principles.md +246 -0
- devflow_engine/prompts/devin_eval/assessment/prompt.md +18 -0
- devflow_engine/prompts/idea/api_ideation_agent/prompt.md +8 -0
- devflow_engine/prompts/idea/api_insight_agent/prompt.md +8 -0
- devflow_engine/prompts/idea/response_doctrine/prompt.md +18 -0
- devflow_engine/prompts/implementation/dependency_assessment/prompt.md +12 -0
- devflow_engine/prompts/implementation/green/green/prompt.md +11 -0
- devflow_engine/prompts/implementation/green/node_config/prompt.md +3 -0
- devflow_engine/prompts/implementation/green_review/outcome_review/prompt.md +5 -0
- devflow_engine/prompts/implementation/green_review/prior_run_review/prompt.md +5 -0
- devflow_engine/prompts/implementation/red/prompt.md +27 -0
- devflow_engine/prompts/implementation/redreview/prompt.md +23 -0
- devflow_engine/prompts/implementation/redreview_repair/prompt.md +16 -0
- devflow_engine/prompts/implementation/setupdoc/prompt.md +10 -0
- devflow_engine/prompts/implementation/story_planning/prompt.md +13 -0
- devflow_engine/prompts/implementation/test_design/prompt.md +27 -0
- devflow_engine/prompts/integration/README.md +185 -0
- devflow_engine/prompts/integration/green/example.md +67 -0
- devflow_engine/prompts/integration/green/green/prompt.md +10 -0
- devflow_engine/prompts/integration/green/node_config/prompt.md +42 -0
- devflow_engine/prompts/integration/green/past_prompts/20260417T212300/green/prompt.md +15 -0
- devflow_engine/prompts/integration/green/past_prompts/20260417T212300/node_config/prompt.md +42 -0
- devflow_engine/prompts/integration/green_enrich/example.md +79 -0
- devflow_engine/prompts/integration/green_enrich/green_enrich/prompt.md +9 -0
- devflow_engine/prompts/integration/green_enrich/node_config/prompt.md +41 -0
- devflow_engine/prompts/integration/green_enrich/past_prompts/20260417T212300/green_enrich/prompt.md +14 -0
- devflow_engine/prompts/integration/green_enrich/past_prompts/20260417T212300/node_config/prompt.md +41 -0
- devflow_engine/prompts/integration/red/code_repair/prompt.md +12 -0
- devflow_engine/prompts/integration/red/example.md +152 -0
- devflow_engine/prompts/integration/red/node_config/prompt.md +86 -0
- devflow_engine/prompts/integration/red/past_prompts/20260417T212300/code_repair/prompt.md +19 -0
- devflow_engine/prompts/integration/red/past_prompts/20260417T212300/node_config/prompt.md +84 -0
- devflow_engine/prompts/integration/red/past_prompts/20260417T212300/red/prompt.md +16 -0
- devflow_engine/prompts/integration/red/past_prompts/20260417T212300/red_repair/prompt.md +15 -0
- devflow_engine/prompts/integration/red/past_prompts/20260417T215032/code_repair/prompt.md +10 -0
- devflow_engine/prompts/integration/red/past_prompts/20260417T215032/node_config/prompt.md +84 -0
- devflow_engine/prompts/integration/red/past_prompts/20260417T215032/red_repair/prompt.md +11 -0
- devflow_engine/prompts/integration/red/red/prompt.md +11 -0
- devflow_engine/prompts/integration/red/red_repair/prompt.md +12 -0
- devflow_engine/prompts/integration/red_review/example.md +71 -0
- devflow_engine/prompts/integration/red_review/node_config/prompt.md +41 -0
- devflow_engine/prompts/integration/red_review/past_prompts/20260417T212300/node_config/prompt.md +41 -0
- devflow_engine/prompts/integration/red_review/past_prompts/20260417T212300/red_review/prompt.md +15 -0
- devflow_engine/prompts/integration/red_review/red_review/prompt.md +9 -0
- devflow_engine/prompts/integration/resolve/example.md +111 -0
- devflow_engine/prompts/integration/resolve/node_config/prompt.md +64 -0
- devflow_engine/prompts/integration/resolve/past_prompts/20260417T212300/node_config/prompt.md +64 -0
- devflow_engine/prompts/integration/resolve/past_prompts/20260417T212300/resolve_implicated_users/prompt.md +15 -0
- devflow_engine/prompts/integration/resolve/past_prompts/20260417T212300/resolve_side_effects/prompt.md +15 -0
- devflow_engine/prompts/integration/resolve/resolve_implicated_users/prompt.md +10 -0
- devflow_engine/prompts/integration/resolve/resolve_side_effects/prompt.md +10 -0
- devflow_engine/prompts/integration/validate/build_idea_acceptance_coverage/prompt.md +12 -0
- devflow_engine/prompts/integration/validate/code_repair/prompt.md +13 -0
- devflow_engine/prompts/integration/validate/example.md +143 -0
- devflow_engine/prompts/integration/validate/node_config/prompt.md +87 -0
- devflow_engine/prompts/integration/validate/past_prompts/20260417T212300/code_repair/prompt.md +19 -0
- devflow_engine/prompts/integration/validate/past_prompts/20260417T212300/node_config/prompt.md +67 -0
- devflow_engine/prompts/integration/validate/past_prompts/20260417T212300/validate_enrich_gate/prompt.md +17 -0
- devflow_engine/prompts/integration/validate/past_prompts/20260417T212300/validate_repair/prompt.md +16 -0
- devflow_engine/prompts/integration/validate/past_prompts/20260417T215032/code_repair/prompt.md +10 -0
- devflow_engine/prompts/integration/validate/past_prompts/20260417T215032/node_config/prompt.md +67 -0
- devflow_engine/prompts/integration/validate/past_prompts/20260417T215032/validate_repair/prompt.md +9 -0
- devflow_engine/prompts/integration/validate/validate_enrich_gate/prompt.md +10 -0
- devflow_engine/prompts/integration/validate/validate_repair/prompt.md +20 -0
- devflow_engine/prompts/integration/write_workflows/example.md +100 -0
- devflow_engine/prompts/integration/write_workflows/node_config/prompt.md +44 -0
- devflow_engine/prompts/integration/write_workflows/past_prompts/20260417T212300/node_config/prompt.md +44 -0
- devflow_engine/prompts/integration/write_workflows/past_prompts/20260417T212300/write_workflows/prompt.md +17 -0
- devflow_engine/prompts/integration/write_workflows/write_workflows/prompt.md +11 -0
- devflow_engine/prompts/iterate/README.md +7 -0
- devflow_engine/prompts/iterate/coder/prompt.md +11 -0
- devflow_engine/prompts/iterate/framer/prompt.md +11 -0
- devflow_engine/prompts/iterate/iterator/prompt.md +13 -0
- devflow_engine/prompts/iterate/observer/prompt.md +11 -0
- devflow_engine/prompts/recovery/diagnosis/prompt.md +7 -0
- devflow_engine/prompts/recovery/execution/prompt.md +8 -0
- devflow_engine/prompts/recovery/execution_verification/prompt.md +7 -0
- devflow_engine/prompts/recovery/failure_investigation/prompt.md +10 -0
- devflow_engine/prompts/recovery/preflight_health_repo_repair/prompt.md +8 -0
- devflow_engine/prompts/recovery/remediation_execution/prompt.md +11 -0
- devflow_engine/prompts/recovery/root_cause_investigation/prompt.md +12 -0
- devflow_engine/prompts/scope_idea/doctrine/prompt.md +7 -0
- devflow_engine/prompts/source_doc_eval/document/prompt.md +6 -0
- devflow_engine/prompts/source_doc_eval/targeted_mutation/prompt.md +9 -0
- devflow_engine/prompts/source_doc_mutation/domain_entities/prompt.md +6 -0
- devflow_engine/prompts/source_doc_mutation/product_brief/prompt.md +6 -0
- devflow_engine/prompts/source_doc_mutation/project_doc_coherence/prompt.md +7 -0
- devflow_engine/prompts/source_doc_mutation/project_doc_render/prompt.md +9 -0
- devflow_engine/prompts/source_doc_mutation/source_doc_coherence/prompt.md +5 -0
- devflow_engine/prompts/source_doc_mutation/source_doc_enrichment_coherence/prompt.md +6 -0
- devflow_engine/prompts/source_doc_mutation/user_workflows/prompt.md +6 -0
- devflow_engine/prompts/source_scope/doctrine/prompt.md +10 -0
- devflow_engine/prompts/ui_grounding/doctrine/prompt.md +7 -0
- devflow_engine/recovery/__init__.py +3 -0
- devflow_engine/recovery/dag.py +2609 -0
- devflow_engine/recovery/models.py +220 -0
- devflow_engine/refactor.py +93 -0
- devflow_engine/registry/__init__.py +1 -0
- devflow_engine/registry/cards.py +238 -0
- devflow_engine/registry/domain_normalize.py +60 -0
- devflow_engine/registry/effects.py +65 -0
- devflow_engine/registry/enforce_report.py +150 -0
- devflow_engine/registry/module_cards_classify.py +164 -0
- devflow_engine/registry/module_cards_draft.py +184 -0
- devflow_engine/registry/module_cards_gate.py +59 -0
- devflow_engine/registry/packages.py +347 -0
- devflow_engine/registry/pathways.py +323 -0
- devflow_engine/review/__init__.py +11 -0
- devflow_engine/review/dag.py +588 -0
- devflow_engine/review/review_story.py +67 -0
- devflow_engine/scope_idea/__init__.py +3 -0
- devflow_engine/scope_idea/agentic.py +39 -0
- devflow_engine/scope_idea/dag.py +1069 -0
- devflow_engine/scope_idea/models.py +175 -0
- devflow_engine/skills/builtins/devflow/queue_failure_investigation/SKILL.md +112 -0
- devflow_engine/skills/builtins/devflow/queue_idea_to_story/SKILL.md +120 -0
- devflow_engine/skills/builtins/devflow/queue_integration/SKILL.md +105 -0
- devflow_engine/skills/builtins/devflow/queue_recovery/SKILL.md +108 -0
- devflow_engine/skills/builtins/devflow/queue_runtime_core/SKILL.md +155 -0
- devflow_engine/skills/builtins/devflow/queue_story_implementation/SKILL.md +122 -0
- devflow_engine/skills/builtins/devin/idea_to_story_handoff/SKILL.md +120 -0
- devflow_engine/skills/builtins/devin/ideation/SKILL.md +168 -0
- devflow_engine/skills/builtins/devin/ideation/state-and-phrasing-reference.md +18 -0
- devflow_engine/skills/builtins/devin/insight/SKILL.md +22 -0
- devflow_engine/skills/registry.example.yaml +42 -0
- devflow_engine/source_doc_assumptions.py +291 -0
- devflow_engine/source_doc_mutation_dag.py +1606 -0
- devflow_engine/source_doc_mutation_eval.py +417 -0
- devflow_engine/source_doc_mutation_worker.py +25 -0
- devflow_engine/source_docs_schema.py +207 -0
- devflow_engine/source_docs_updater.py +309 -0
- devflow_engine/source_scope/__init__.py +15 -0
- devflow_engine/source_scope/agentic.py +45 -0
- devflow_engine/source_scope/dag.py +1626 -0
- devflow_engine/source_scope/models.py +177 -0
- devflow_engine/stores/__init__.py +0 -0
- devflow_engine/stores/execution_store.py +3534 -0
- devflow_engine/story/__init__.py +0 -0
- devflow_engine/story/contracts.py +160 -0
- devflow_engine/story/discovery.py +47 -0
- devflow_engine/story/evidence.py +118 -0
- devflow_engine/story/hashing.py +27 -0
- devflow_engine/story/implemented_queue_purge.py +148 -0
- devflow_engine/story/indexer.py +105 -0
- devflow_engine/story/io.py +20 -0
- devflow_engine/story/markdown_contracts.py +298 -0
- devflow_engine/story/reconciliation.py +408 -0
- devflow_engine/story/validate_stories.py +149 -0
- devflow_engine/story/validate_tests_story.py +512 -0
- devflow_engine/story/validation.py +133 -0
- devflow_engine/ui_grounding/__init__.py +11 -0
- devflow_engine/ui_grounding/agentic.py +31 -0
- devflow_engine/ui_grounding/dag.py +874 -0
- devflow_engine/ui_grounding/models.py +224 -0
- devflow_engine/ui_grounding/pencil_bridge.py +247 -0
- devflow_engine/vendor/__init__.py +0 -0
- devflow_engine/vendor/datalumina_genai/__init__.py +11 -0
- devflow_engine/vendor/datalumina_genai/core/__init__.py +0 -0
- devflow_engine/vendor/datalumina_genai/core/exceptions.py +9 -0
- devflow_engine/vendor/datalumina_genai/core/nodes/__init__.py +0 -0
- devflow_engine/vendor/datalumina_genai/core/nodes/agent.py +48 -0
- devflow_engine/vendor/datalumina_genai/core/nodes/agent_streaming_node.py +26 -0
- devflow_engine/vendor/datalumina_genai/core/nodes/base.py +89 -0
- devflow_engine/vendor/datalumina_genai/core/nodes/concurrent.py +30 -0
- devflow_engine/vendor/datalumina_genai/core/nodes/router.py +69 -0
- devflow_engine/vendor/datalumina_genai/core/schema.py +72 -0
- devflow_engine/vendor/datalumina_genai/core/task.py +52 -0
- devflow_engine/vendor/datalumina_genai/core/validate.py +139 -0
- devflow_engine/vendor/datalumina_genai/core/workflow.py +200 -0
- devflow_engine/worker.py +1086 -0
- devflow_engine/worker_guard.py +233 -0
- devflow_engine-1.0.0.dist-info/METADATA +235 -0
- devflow_engine-1.0.0.dist-info/RECORD +393 -0
- devflow_engine-1.0.0.dist-info/WHEEL +4 -0
- devflow_engine-1.0.0.dist-info/entry_points.txt +3 -0
- devin/__init__.py +6 -0
- devin/dag.py +58 -0
- devin/dag_two_arm.py +138 -0
- devin/devin_chat_scenario_catalog.json +588 -0
- devin/devin_eval.py +677 -0
- devin/nodes/__init__.py +0 -0
- devin/nodes/ideation/__init__.py +0 -0
- devin/nodes/ideation/node.py +195 -0
- devin/nodes/ideation/playground.py +267 -0
- devin/nodes/ideation/prompt.md +65 -0
- devin/nodes/ideation/scenarios/continue_refinement.py +13 -0
- devin/nodes/ideation/scenarios/continue_refinement_evals.py +18 -0
- devin/nodes/ideation/scenarios/idea_fits_existing_patterns.py +17 -0
- devin/nodes/ideation/scenarios/idea_fits_existing_patterns_evals.py +16 -0
- devin/nodes/ideation/scenarios/large_idea_split.py +4 -0
- devin/nodes/ideation/scenarios/large_idea_split_evals.py +17 -0
- devin/nodes/ideation/scenarios/source_documentation_added.py +4 -0
- devin/nodes/ideation/scenarios/source_documentation_added_evals.py +16 -0
- devin/nodes/ideation/scenarios/user_says_create_it.py +30 -0
- devin/nodes/ideation/scenarios/user_says_create_it_evals.py +23 -0
- devin/nodes/ideation/scenarios/vague_idea.py +16 -0
- devin/nodes/ideation/scenarios/vague_idea_evals.py +47 -0
- devin/nodes/ideation/tools.json +312 -0
- devin/nodes/insight/__init__.py +0 -0
- devin/nodes/insight/node.py +49 -0
- devin/nodes/insight/playground.py +154 -0
- devin/nodes/insight/prompt.md +61 -0
- devin/nodes/insight/scenarios/architecture_pattern_query.py +15 -0
- devin/nodes/insight/scenarios/architecture_pattern_query_evals.py +25 -0
- devin/nodes/insight/scenarios/codebase_exploration.py +15 -0
- devin/nodes/insight/scenarios/codebase_exploration_evals.py +23 -0
- devin/nodes/insight/scenarios/devin_ideation_routing.py +19 -0
- devin/nodes/insight/scenarios/devin_ideation_routing_evals.py +39 -0
- devin/nodes/insight/scenarios/devin_insight_routing.py +20 -0
- devin/nodes/insight/scenarios/devin_insight_routing_evals.py +40 -0
- devin/nodes/insight/scenarios/operational_debugging.py +15 -0
- devin/nodes/insight/scenarios/operational_debugging_evals.py +23 -0
- devin/nodes/insight/scenarios/operational_question.py +9 -0
- devin/nodes/insight/scenarios/operational_question_evals.py +8 -0
- devin/nodes/insight/scenarios/queue_status.py +15 -0
- devin/nodes/insight/scenarios/queue_status_evals.py +23 -0
- devin/nodes/insight/scenarios/source_doc_explanation.py +14 -0
- devin/nodes/insight/scenarios/source_doc_explanation_evals.py +21 -0
- devin/nodes/insight/scenarios/worker_state_check.py +15 -0
- devin/nodes/insight/scenarios/worker_state_check_evals.py +22 -0
- devin/nodes/insight/tools.json +126 -0
- devin/nodes/intake/__init__.py +0 -0
- devin/nodes/intake/node.py +27 -0
- devin/nodes/intake/playground.py +47 -0
- devin/nodes/intake/prompt.md +12 -0
- devin/nodes/intake/scenarios/ideation_routing.py +4 -0
- devin/nodes/intake/scenarios/ideation_routing_evals.py +5 -0
- devin/nodes/intake/scenarios/insight_routing.py +4 -0
- devin/nodes/intake/scenarios/insight_routing_evals.py +5 -0
- devin/nodes/iterate/README.md +44 -0
- devin/nodes/iterate/__init__.py +1 -0
- devin/nodes/iterate/_archived_design_stages/01-objectives-requirements.md +112 -0
- devin/nodes/iterate/_archived_design_stages/02-evals.md +131 -0
- devin/nodes/iterate/_archived_design_stages/03-tools-and-boundaries.md +110 -0
- devin/nodes/iterate/_archived_design_stages/04-harness-and-playground.md +32 -0
- devin/nodes/iterate/_archived_design_stages/05-prompt-deferred.md +11 -0
- devin/nodes/iterate/_archived_design_stages/coder_agent_design/01-objectives-requirements.md +20 -0
- devin/nodes/iterate/_archived_design_stages/coder_agent_design/02-evals.md +8 -0
- devin/nodes/iterate/_archived_design_stages/coder_agent_design/03-tools-and-boundaries.md +14 -0
- devin/nodes/iterate/_archived_design_stages/coder_agent_design/04-harness-and-playground.md +12 -0
- devin/nodes/iterate/_archived_design_stages/framer_agent_design/01-objectives-requirements.md +20 -0
- devin/nodes/iterate/_archived_design_stages/framer_agent_design/02-evals.md +8 -0
- devin/nodes/iterate/_archived_design_stages/framer_agent_design/03-tools-and-boundaries.md +13 -0
- devin/nodes/iterate/_archived_design_stages/framer_agent_design/04-harness-and-playground.md +12 -0
- devin/nodes/iterate/_archived_design_stages/iterator_agent_design/01-objectives-requirements.md +25 -0
- devin/nodes/iterate/_archived_design_stages/iterator_agent_design/02-evals.md +9 -0
- devin/nodes/iterate/_archived_design_stages/iterator_agent_design/03-tools-and-boundaries.md +14 -0
- devin/nodes/iterate/_archived_design_stages/iterator_agent_design/04-harness-and-playground.md +12 -0
- devin/nodes/iterate/_archived_design_stages/observer_agent_design/01-objectives-requirements.md +20 -0
- devin/nodes/iterate/_archived_design_stages/observer_agent_design/02-evals.md +8 -0
- devin/nodes/iterate/_archived_design_stages/observer_agent_design/03-tools-and-boundaries.md +14 -0
- devin/nodes/iterate/_archived_design_stages/observer_agent_design/04-harness-and-playground.md +13 -0
- devin/nodes/iterate/agent-roles.md +89 -0
- devin/nodes/iterate/agents/README.md +10 -0
- devin/nodes/iterate/artifacts.md +504 -0
- devin/nodes/iterate/contract.md +100 -0
- devin/nodes/iterate/eval-plan.md +74 -0
- devin/nodes/iterate/node.py +100 -0
- devin/nodes/iterate/pipeline/README.md +13 -0
- devin/nodes/iterate/playground-contract.md +76 -0
- devin/nodes/iterate/prompt.md +11 -0
- devin/nodes/iterate/scenarios/README.md +38 -0
- devin/nodes/iterate/scenarios/artifact-and-loop-scenarios.md +101 -0
- devin/nodes/iterate/scenarios/coder_artifact_alignment.py +32 -0
- devin/nodes/iterate/scenarios/coder_artifact_alignment_evals.py +45 -0
- devin/nodes/iterate/scenarios/coder_bounded_fix.py +27 -0
- devin/nodes/iterate/scenarios/coder_bounded_fix_evals.py +45 -0
- devin/nodes/iterate/scenarios/devin_iterate_routing.py +21 -0
- devin/nodes/iterate/scenarios/devin_iterate_routing_evals.py +36 -0
- devin/nodes/iterate/scenarios/framer_scope_boundary.py +25 -0
- devin/nodes/iterate/scenarios/framer_scope_boundary_evals.py +57 -0
- devin/nodes/iterate/scenarios/framer_task_framing.py +25 -0
- devin/nodes/iterate/scenarios/framer_task_framing_evals.py +58 -0
- devin/nodes/iterate/scenarios/iterate_error_fix.py +21 -0
- devin/nodes/iterate/scenarios/iterate_error_fix_evals.py +39 -0
- devin/nodes/iterate/scenarios/iterate_quick_change.py +21 -0
- devin/nodes/iterate/scenarios/iterate_quick_change_evals.py +35 -0
- devin/nodes/iterate/scenarios/iterate_to_idea_promotion.py +23 -0
- devin/nodes/iterate/scenarios/iterate_to_idea_promotion_evals.py +53 -0
- devin/nodes/iterate/scenarios/iterate_to_insight_reroute.py +23 -0
- devin/nodes/iterate/scenarios/iterate_to_insight_reroute_evals.py +53 -0
- devin/nodes/iterate/scenarios/observer_evidence_seam.py +28 -0
- devin/nodes/iterate/scenarios/observer_evidence_seam_evals.py +55 -0
- devin/nodes/iterate/scenarios/observer_repro_creation.py +28 -0
- devin/nodes/iterate/scenarios/observer_repro_creation_evals.py +45 -0
- devin/nodes/iterate/scenarios/routing-matrix.md +45 -0
- devin/nodes/shared/__init__.py +0 -0
- devin/nodes/shared/filemaker_expert.md +80 -0
- devin/nodes/shared/filemaker_expert.py +354 -0
- devin/nodes/shared/filemaker_expert_eval/runner.py +176 -0
- devin/nodes/shared/filemaker_expert_eval/scenarios.json +65 -0
- devin/nodes/shared/goldilocks_advisor_eval/runner.py +214 -0
- devin/nodes/shared/goldilocks_advisor_eval/scenarios.json +58 -0
- devin/nodes/shared/helpers.py +156 -0
- devin/nodes/shared/idea_compliance_advisor_eval/runner.py +252 -0
- devin/nodes/shared/idea_compliance_advisor_eval/scenarios.json +75 -0
- devin/nodes/shared/models.py +44 -0
- devin/nodes/shared/post.py +40 -0
- devin/nodes/shared/router.py +107 -0
- devin/nodes/shared/tools.py +191 -0
- devin/shared/devin-chat-rubric.md +237 -0
- devin/shared/devin-chat-scenario-suite.md +90 -0
- devin/shared/eval_doctrine.md +9 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import shutil
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from datetime import UTC, datetime
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from pydantic import BaseModel
|
|
11
|
+
|
|
12
|
+
from .agentic_prompts import load_agentic_prompt_lines
|
|
13
|
+
from .agentic_runtime import run_agent_step
|
|
14
|
+
from .source_doc_mutation_dag import PROJECT_DOC_TARGETS, build_source_doc_mutation_request, run_source_doc_mutation_dag
|
|
15
|
+
|
|
16
|
+
CANONICAL_SOURCE_DOCS = (
|
|
17
|
+
"product_brief.json",
|
|
18
|
+
"user_workflows.json",
|
|
19
|
+
"domain_entities.json",
|
|
20
|
+
"assumptions_registry.json",
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
EXCLUDED_PROJECT_DOC_MATRIX_DOCS = {"index.md"}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class DocumentAssessment(BaseModel):
|
|
27
|
+
doc_name: str
|
|
28
|
+
doc_family: str
|
|
29
|
+
quality: float
|
|
30
|
+
completeness: float
|
|
31
|
+
notes: list[str] = []
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class MutationDocumentAssessment(DocumentAssessment):
|
|
35
|
+
appropriate_update: float
|
|
36
|
+
thoroughness: float
|
|
37
|
+
accuracy: float
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass(frozen=True)
|
|
41
|
+
class SourceDocMutationEvalResult:
|
|
42
|
+
run_id: str
|
|
43
|
+
started_at: str
|
|
44
|
+
eval_root: Path
|
|
45
|
+
payload: dict[str, Any]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass(frozen=True)
|
|
49
|
+
class TargetedMutationBaseline:
|
|
50
|
+
eval_root: Path
|
|
51
|
+
source_docs_root: Path
|
|
52
|
+
project_docs_root: Path
|
|
53
|
+
manifest: dict[str, Any]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _now_run_id() -> tuple[str, str]:
|
|
57
|
+
started_at = datetime.now(UTC).replace(microsecond=0).isoformat().replace("+00:00", "Z")
|
|
58
|
+
run_id = started_at.replace("-", "").replace(":", "")
|
|
59
|
+
return run_id, started_at
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _write_json(path: Path, payload: dict[str, Any]) -> None:
|
|
63
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
64
|
+
path.write_text(json.dumps(payload, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _load_json(path: Path) -> dict[str, Any]:
|
|
68
|
+
return json.loads(path.read_text(encoding="utf-8"))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _copy_tree(src: Path, dst: Path) -> list[str]:
|
|
72
|
+
copied: list[str] = []
|
|
73
|
+
dst.mkdir(parents=True, exist_ok=True)
|
|
74
|
+
for path in sorted(src.rglob("*")):
|
|
75
|
+
if not path.is_file():
|
|
76
|
+
continue
|
|
77
|
+
rel = path.relative_to(src)
|
|
78
|
+
out = dst / rel
|
|
79
|
+
out.parent.mkdir(parents=True, exist_ok=True)
|
|
80
|
+
shutil.copy2(path, out)
|
|
81
|
+
copied.append(rel.as_posix())
|
|
82
|
+
return copied
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _mean(values: list[float]) -> float:
|
|
86
|
+
if not values:
|
|
87
|
+
return 0.0
|
|
88
|
+
return round(sum(values) / len(values), 6)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _existing_source_refs() -> list[str]:
|
|
92
|
+
return [f"ai_docs/context/source_docs/{name}" for name in CANONICAL_SOURCE_DOCS]
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _doc_paths(eval_root: Path) -> tuple[Path, Path]:
|
|
96
|
+
return eval_root / "ai_docs" / "context" / "source_docs", eval_root / "ai_docs" / "context" / "project_docs"
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _baseline_doc_paths(eval_root: Path) -> tuple[Path, Path]:
|
|
100
|
+
return eval_root / "baseline" / "source_docs", eval_root / "baseline" / "project_docs"
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _assess_doc(*, repo_root: Path, stage_name: str, output_model: type[BaseModel], context_payload: dict[str, Any], guidance: list[str]) -> BaseModel:
|
|
104
|
+
model, _ = run_agent_step(
|
|
105
|
+
repo_root=repo_root,
|
|
106
|
+
stage_name=stage_name,
|
|
107
|
+
output_model=output_model,
|
|
108
|
+
context_payload=context_payload,
|
|
109
|
+
guidance=guidance,
|
|
110
|
+
)
|
|
111
|
+
return model
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _resolve_targeted_mutation_baseline(*, evals_root: Path, baseline_eval_root: Path | None = None) -> TargetedMutationBaseline:
|
|
115
|
+
if baseline_eval_root is not None:
|
|
116
|
+
resolved = baseline_eval_root.resolve()
|
|
117
|
+
manifest_path = resolved / "eval_manifest.json"
|
|
118
|
+
if manifest_path.exists():
|
|
119
|
+
candidates = [resolved]
|
|
120
|
+
elif resolved.exists() and resolved.is_dir():
|
|
121
|
+
candidates = sorted((path.resolve() for path in resolved.iterdir() if path.is_dir()), reverse=True)
|
|
122
|
+
else:
|
|
123
|
+
candidates = [resolved]
|
|
124
|
+
else:
|
|
125
|
+
candidates = sorted((path.resolve() for path in evals_root.iterdir() if path.is_dir()), reverse=True)
|
|
126
|
+
for candidate in candidates:
|
|
127
|
+
manifest_path = candidate / "eval_manifest.json"
|
|
128
|
+
if not manifest_path.exists():
|
|
129
|
+
continue
|
|
130
|
+
manifest = _load_json(manifest_path)
|
|
131
|
+
if manifest.get("eval_type") != "sparse_input":
|
|
132
|
+
continue
|
|
133
|
+
source_docs_root = candidate / "ai_docs" / "context" / "source_docs"
|
|
134
|
+
project_docs_root = candidate / "ai_docs" / "context" / "project_docs"
|
|
135
|
+
if not source_docs_root.exists() or not project_docs_root.exists():
|
|
136
|
+
continue
|
|
137
|
+
return TargetedMutationBaseline(
|
|
138
|
+
eval_root=candidate,
|
|
139
|
+
source_docs_root=source_docs_root,
|
|
140
|
+
project_docs_root=project_docs_root,
|
|
141
|
+
manifest=manifest,
|
|
142
|
+
)
|
|
143
|
+
if baseline_eval_root is not None:
|
|
144
|
+
raise FileNotFoundError(f"Targeted mutation baseline not found or invalid at {baseline_eval_root}")
|
|
145
|
+
raise FileNotFoundError(
|
|
146
|
+
f"No sparse_input eval baseline found under {evals_root}. Run a sparse_input eval first or pass baseline_eval_root explicitly."
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _summarize_assessments(eval_root: Path, run_id: str, started_at: str, assessments: list[DocumentAssessment]) -> dict[str, Any]:
|
|
151
|
+
source_docs = [a for a in assessments if a.doc_family == "source_docs"]
|
|
152
|
+
project_docs = [a for a in assessments if a.doc_family == "project_docs" and a.doc_name not in EXCLUDED_PROJECT_DOC_MATRIX_DOCS]
|
|
153
|
+
excluded_project_docs = [a for a in assessments if a.doc_family == "project_docs" and a.doc_name in EXCLUDED_PROJECT_DOC_MATRIX_DOCS]
|
|
154
|
+
overall_assessments = source_docs + project_docs
|
|
155
|
+
source_index = {
|
|
156
|
+
"run_id": run_id,
|
|
157
|
+
"started_at": started_at,
|
|
158
|
+
"doc_family": "source_docs",
|
|
159
|
+
"docs": [a.model_dump() for a in source_docs],
|
|
160
|
+
"mean_quality": _mean([a.quality for a in source_docs]),
|
|
161
|
+
"mean_completeness": _mean([a.completeness for a in source_docs]),
|
|
162
|
+
}
|
|
163
|
+
project_index = {
|
|
164
|
+
"run_id": run_id,
|
|
165
|
+
"started_at": started_at,
|
|
166
|
+
"doc_family": "project_docs",
|
|
167
|
+
"docs": [a.model_dump() for a in project_docs],
|
|
168
|
+
"excluded_docs": [a.doc_name for a in excluded_project_docs],
|
|
169
|
+
"mean_quality": _mean([a.quality for a in project_docs]),
|
|
170
|
+
"mean_completeness": _mean([a.completeness for a in project_docs]),
|
|
171
|
+
}
|
|
172
|
+
overall = {
|
|
173
|
+
"run_id": run_id,
|
|
174
|
+
"started_at": started_at,
|
|
175
|
+
"source_docs": {
|
|
176
|
+
"quality": source_index["mean_quality"],
|
|
177
|
+
"completeness": source_index["mean_completeness"],
|
|
178
|
+
},
|
|
179
|
+
"project_docs": {
|
|
180
|
+
"quality": project_index["mean_quality"],
|
|
181
|
+
"completeness": project_index["mean_completeness"],
|
|
182
|
+
},
|
|
183
|
+
"overall": {
|
|
184
|
+
"quality": _mean([a.quality for a in overall_assessments]),
|
|
185
|
+
"completeness": _mean([a.completeness for a in overall_assessments]),
|
|
186
|
+
},
|
|
187
|
+
}
|
|
188
|
+
_write_json(eval_root / "indexes" / "source_docs_index.json", source_index)
|
|
189
|
+
_write_json(eval_root / "indexes" / "project_docs_index.json", project_index)
|
|
190
|
+
_write_json(eval_root / "metrics" / "quality.json", {
|
|
191
|
+
"run_id": run_id,
|
|
192
|
+
"started_at": started_at,
|
|
193
|
+
"per_document": [{"doc_name": a.doc_name, "doc_family": a.doc_family, "quality": a.quality} for a in assessments],
|
|
194
|
+
"source_docs": source_index["mean_quality"],
|
|
195
|
+
"project_docs": project_index["mean_quality"],
|
|
196
|
+
"excluded_project_docs": sorted(EXCLUDED_PROJECT_DOC_MATRIX_DOCS),
|
|
197
|
+
"overall": overall["overall"]["quality"],
|
|
198
|
+
})
|
|
199
|
+
_write_json(eval_root / "metrics" / "completeness.json", {
|
|
200
|
+
"run_id": run_id,
|
|
201
|
+
"started_at": started_at,
|
|
202
|
+
"per_document": [{"doc_name": a.doc_name, "doc_family": a.doc_family, "completeness": a.completeness} for a in assessments],
|
|
203
|
+
"source_docs": source_index["mean_completeness"],
|
|
204
|
+
"project_docs": project_index["mean_completeness"],
|
|
205
|
+
"excluded_project_docs": sorted(EXCLUDED_PROJECT_DOC_MATRIX_DOCS),
|
|
206
|
+
"overall": overall["overall"]["completeness"],
|
|
207
|
+
})
|
|
208
|
+
return overall
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def run_sparse_input_eval(*, repo_root: Path, text: str, agent_runtime_mode: str = "real", project_id: str = "eval_sparse_input", idea_id: str = "eval_sparse_input_001", pipeline_key: str = "eval_sparse_input", evals_root: Path | None = None) -> SourceDocMutationEvalResult:
|
|
212
|
+
run_id, started_at = _now_run_id()
|
|
213
|
+
request = build_source_doc_mutation_request(
|
|
214
|
+
project_id=project_id,
|
|
215
|
+
idea_id=idea_id,
|
|
216
|
+
repo_root=repo_root,
|
|
217
|
+
raw_text=text,
|
|
218
|
+
grounded_raw_text=text,
|
|
219
|
+
mode="ideation_mutation",
|
|
220
|
+
existing_source_doc_refs=_existing_source_refs(),
|
|
221
|
+
pipeline_key=pipeline_key,
|
|
222
|
+
agent_runtime_mode=agent_runtime_mode,
|
|
223
|
+
)
|
|
224
|
+
dag_result = run_source_doc_mutation_dag(request=request)
|
|
225
|
+
eval_root = (evals_root or (repo_root / "evals")) / run_id
|
|
226
|
+
source_dst, project_dst = _doc_paths(eval_root)
|
|
227
|
+
source_copied = _copy_tree(repo_root / "ai_docs" / "context" / "source_docs", source_dst)
|
|
228
|
+
project_copied = _copy_tree(repo_root / "ai_docs" / "context" / "v2" / "project_docs" / "source_docs", project_dst)
|
|
229
|
+
|
|
230
|
+
assessments: list[DocumentAssessment] = []
|
|
231
|
+
for family, root in (("source_docs", source_dst), ("project_docs", project_dst)):
|
|
232
|
+
for path in sorted(root.glob("*.json" if family == "source_docs" else "*.md")):
|
|
233
|
+
if family == "project_docs" and path.name in EXCLUDED_PROJECT_DOC_MATRIX_DOCS:
|
|
234
|
+
continue
|
|
235
|
+
model = _assess_doc(
|
|
236
|
+
repo_root=repo_root,
|
|
237
|
+
stage_name=f"source_doc_eval_{family}_{path.stem}",
|
|
238
|
+
output_model=DocumentAssessment,
|
|
239
|
+
context_payload={
|
|
240
|
+
"run_id": run_id,
|
|
241
|
+
"started_at": started_at,
|
|
242
|
+
"eval_type": "sparse_input",
|
|
243
|
+
"doc_family": family,
|
|
244
|
+
"doc_name": path.name,
|
|
245
|
+
"doc_content": path.read_text(encoding="utf-8"),
|
|
246
|
+
"user_input": text,
|
|
247
|
+
},
|
|
248
|
+
guidance=load_agentic_prompt_lines("source_doc_eval_document"),
|
|
249
|
+
)
|
|
250
|
+
assessments.append(model)
|
|
251
|
+
|
|
252
|
+
overall = _summarize_assessments(eval_root, run_id, started_at, assessments)
|
|
253
|
+
manifest = {
|
|
254
|
+
"run_id": run_id,
|
|
255
|
+
"started_at": started_at,
|
|
256
|
+
"eval_type": "sparse_input",
|
|
257
|
+
"repo_root": str(repo_root),
|
|
258
|
+
"eval_root": str(eval_root),
|
|
259
|
+
"agent_runtime_mode": agent_runtime_mode,
|
|
260
|
+
"dag_run_id": dag_result.run_id,
|
|
261
|
+
"dag_pipeline_dir": str(dag_result.pipeline_dir),
|
|
262
|
+
"artifacts": {
|
|
263
|
+
"source_docs_root": str(source_dst),
|
|
264
|
+
"project_docs_root": str(project_dst),
|
|
265
|
+
"source_docs_index": "indexes/source_docs_index.json",
|
|
266
|
+
"project_docs_index": "indexes/project_docs_index.json",
|
|
267
|
+
"quality_metrics": "metrics/quality.json",
|
|
268
|
+
"completeness_metrics": "metrics/completeness.json",
|
|
269
|
+
},
|
|
270
|
+
"copied_source_docs": source_copied,
|
|
271
|
+
"copied_project_docs": project_copied,
|
|
272
|
+
"overall_metrics": overall,
|
|
273
|
+
}
|
|
274
|
+
_write_json(eval_root / "eval_manifest.json", manifest)
|
|
275
|
+
return SourceDocMutationEvalResult(run_id=run_id, started_at=started_at, eval_root=eval_root, payload=manifest)
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def run_targeted_mutation_eval(*, repo_root: Path, base_text: str, mutation_text: str, agent_runtime_mode: str = "real", project_id: str = "eval_targeted_mutation", idea_id: str = "eval_targeted_mutation_001", pipeline_key_prefix: str = "eval_targeted_mutation", evals_root: Path | None = None, baseline_eval_root: Path | None = None) -> SourceDocMutationEvalResult:
|
|
279
|
+
run_id, started_at = _now_run_id()
|
|
280
|
+
resolved_evals_root = (evals_root or (repo_root / "evals")).resolve()
|
|
281
|
+
baseline = _resolve_targeted_mutation_baseline(evals_root=resolved_evals_root, baseline_eval_root=baseline_eval_root)
|
|
282
|
+
|
|
283
|
+
repo_source_root = repo_root / "ai_docs" / "context" / "source_docs"
|
|
284
|
+
repo_project_root = repo_root / "ai_docs" / "context" / "v2" / "project_docs" / "source_docs"
|
|
285
|
+
baseline_source_copied_to_repo = _copy_tree(baseline.source_docs_root, repo_source_root)
|
|
286
|
+
baseline_project_copied_to_repo = _copy_tree(baseline.project_docs_root, repo_project_root)
|
|
287
|
+
|
|
288
|
+
before_source = {name: _load_json(repo_source_root / name) for name in CANONICAL_SOURCE_DOCS}
|
|
289
|
+
before_project: dict[str, str] = {}
|
|
290
|
+
for name in PROJECT_DOC_TARGETS:
|
|
291
|
+
path = repo_project_root / name
|
|
292
|
+
before_project[name] = path.read_text(encoding="utf-8") if path.exists() else ""
|
|
293
|
+
|
|
294
|
+
mutation_request = build_source_doc_mutation_request(
|
|
295
|
+
project_id=project_id,
|
|
296
|
+
idea_id=idea_id,
|
|
297
|
+
repo_root=repo_root,
|
|
298
|
+
raw_text=mutation_text,
|
|
299
|
+
grounded_raw_text=mutation_text,
|
|
300
|
+
mode="ideation_mutation",
|
|
301
|
+
existing_source_doc_refs=_existing_source_refs(),
|
|
302
|
+
pipeline_key=f"{pipeline_key_prefix}_mutation",
|
|
303
|
+
agent_runtime_mode=agent_runtime_mode,
|
|
304
|
+
)
|
|
305
|
+
mutation_result = run_source_doc_mutation_dag(request=mutation_request)
|
|
306
|
+
|
|
307
|
+
eval_root = resolved_evals_root / run_id
|
|
308
|
+
source_dst, project_dst = _doc_paths(eval_root)
|
|
309
|
+
baseline_source_dst, baseline_project_dst = _baseline_doc_paths(eval_root)
|
|
310
|
+
baseline_source_copied = _copy_tree(baseline.source_docs_root, baseline_source_dst)
|
|
311
|
+
baseline_project_copied = _copy_tree(baseline.project_docs_root, baseline_project_dst)
|
|
312
|
+
source_copied = _copy_tree(repo_source_root, source_dst)
|
|
313
|
+
project_copied = _copy_tree(repo_project_root, project_dst)
|
|
314
|
+
|
|
315
|
+
assessments: list[MutationDocumentAssessment] = []
|
|
316
|
+
for family, names in (("source_docs", list(CANONICAL_SOURCE_DOCS)), ("project_docs", list(PROJECT_DOC_TARGETS))):
|
|
317
|
+
for name in names:
|
|
318
|
+
if family == "project_docs" and name in EXCLUDED_PROJECT_DOC_MATRIX_DOCS:
|
|
319
|
+
continue
|
|
320
|
+
before_payload = before_source[name] if family == "source_docs" else before_project[name]
|
|
321
|
+
after_path = (source_dst if family == "source_docs" else project_dst) / name
|
|
322
|
+
after_payload = after_path.read_text(encoding="utf-8")
|
|
323
|
+
model = _assess_doc(
|
|
324
|
+
repo_root=repo_root,
|
|
325
|
+
stage_name=f"source_doc_eval_mutation_{family}_{Path(name).stem}",
|
|
326
|
+
output_model=MutationDocumentAssessment,
|
|
327
|
+
context_payload={
|
|
328
|
+
"run_id": run_id,
|
|
329
|
+
"started_at": started_at,
|
|
330
|
+
"eval_type": "targeted_mutation",
|
|
331
|
+
"doc_family": family,
|
|
332
|
+
"doc_name": name,
|
|
333
|
+
"base_request": base_text,
|
|
334
|
+
"mutation_request": mutation_text,
|
|
335
|
+
"before_doc": before_payload,
|
|
336
|
+
"after_doc": after_payload,
|
|
337
|
+
},
|
|
338
|
+
guidance=load_agentic_prompt_lines("source_doc_eval_targeted_mutation"),
|
|
339
|
+
)
|
|
340
|
+
assessments.append(model)
|
|
341
|
+
|
|
342
|
+
overall = _summarize_assessments(eval_root, run_id, started_at, assessments)
|
|
343
|
+
scored_project_docs = [a for a in assessments if a.doc_family == "project_docs" and a.doc_name not in EXCLUDED_PROJECT_DOC_MATRIX_DOCS]
|
|
344
|
+
scored_overall = [a for a in assessments if not (a.doc_family == "project_docs" and a.doc_name in EXCLUDED_PROJECT_DOC_MATRIX_DOCS)]
|
|
345
|
+
appropriate_matrix = {
|
|
346
|
+
"run_id": run_id,
|
|
347
|
+
"started_at": started_at,
|
|
348
|
+
"metric": "appropriate_update",
|
|
349
|
+
"docs": [{"doc_name": a.doc_name, "doc_family": a.doc_family, "appropriate_update": a.appropriate_update} for a in assessments],
|
|
350
|
+
"excluded_project_docs": sorted(EXCLUDED_PROJECT_DOC_MATRIX_DOCS),
|
|
351
|
+
"source_docs": _mean([a.appropriate_update for a in assessments if a.doc_family == "source_docs"]),
|
|
352
|
+
"project_docs": _mean([a.appropriate_update for a in scored_project_docs]),
|
|
353
|
+
"overall": _mean([a.appropriate_update for a in scored_overall]),
|
|
354
|
+
}
|
|
355
|
+
thoroughness_matrix = {
|
|
356
|
+
"run_id": run_id,
|
|
357
|
+
"started_at": started_at,
|
|
358
|
+
"metric": "thoroughness",
|
|
359
|
+
"docs": [{"doc_name": a.doc_name, "doc_family": a.doc_family, "thoroughness": a.thoroughness} for a in assessments],
|
|
360
|
+
"excluded_project_docs": sorted(EXCLUDED_PROJECT_DOC_MATRIX_DOCS),
|
|
361
|
+
"source_docs": _mean([a.thoroughness for a in assessments if a.doc_family == "source_docs"]),
|
|
362
|
+
"project_docs": _mean([a.thoroughness for a in scored_project_docs]),
|
|
363
|
+
"overall": _mean([a.thoroughness for a in scored_overall]),
|
|
364
|
+
}
|
|
365
|
+
accuracy_matrix = {
|
|
366
|
+
"run_id": run_id,
|
|
367
|
+
"started_at": started_at,
|
|
368
|
+
"metric": "accuracy",
|
|
369
|
+
"formula": "average(appropriate_update, thoroughness)",
|
|
370
|
+
"docs": [{"doc_name": a.doc_name, "doc_family": a.doc_family, "accuracy": a.accuracy} for a in assessments],
|
|
371
|
+
"excluded_project_docs": sorted(EXCLUDED_PROJECT_DOC_MATRIX_DOCS),
|
|
372
|
+
"source_docs": _mean([a.accuracy for a in assessments if a.doc_family == "source_docs"]),
|
|
373
|
+
"project_docs": _mean([a.accuracy for a in scored_project_docs]),
|
|
374
|
+
"overall": _mean([a.accuracy for a in scored_overall]),
|
|
375
|
+
}
|
|
376
|
+
_write_json(eval_root / "matrices" / "appropriate_update.json", appropriate_matrix)
|
|
377
|
+
_write_json(eval_root / "matrices" / "thoroughness.json", thoroughness_matrix)
|
|
378
|
+
_write_json(eval_root / "matrices" / "accuracy.json", accuracy_matrix)
|
|
379
|
+
|
|
380
|
+
manifest = {
|
|
381
|
+
"run_id": run_id,
|
|
382
|
+
"started_at": started_at,
|
|
383
|
+
"eval_type": "targeted_mutation",
|
|
384
|
+
"repo_root": str(repo_root),
|
|
385
|
+
"eval_root": str(eval_root),
|
|
386
|
+
"agent_runtime_mode": agent_runtime_mode,
|
|
387
|
+
"baseline_eval_root": str(baseline.eval_root),
|
|
388
|
+
"baseline_eval_type": baseline.manifest.get("eval_type"),
|
|
389
|
+
"baseline_run_id": baseline.manifest.get("run_id"),
|
|
390
|
+
"baseline_started_at": baseline.manifest.get("started_at"),
|
|
391
|
+
"mutation_dag_run_id": mutation_result.run_id,
|
|
392
|
+
"mutation_dag_pipeline_dir": str(mutation_result.pipeline_dir),
|
|
393
|
+
"artifacts": {
|
|
394
|
+
"baseline_source_docs_root": str(baseline_source_dst),
|
|
395
|
+
"baseline_project_docs_root": str(baseline_project_dst),
|
|
396
|
+
"source_docs_root": str(source_dst),
|
|
397
|
+
"project_docs_root": str(project_dst),
|
|
398
|
+
"source_docs_index": "indexes/source_docs_index.json",
|
|
399
|
+
"project_docs_index": "indexes/project_docs_index.json",
|
|
400
|
+
"quality_metrics": "metrics/quality.json",
|
|
401
|
+
"completeness_metrics": "metrics/completeness.json",
|
|
402
|
+
"appropriate_update_matrix": "matrices/appropriate_update.json",
|
|
403
|
+
"thoroughness_matrix": "matrices/thoroughness.json",
|
|
404
|
+
"accuracy_matrix": "matrices/accuracy.json",
|
|
405
|
+
},
|
|
406
|
+
"baseline_copied_to_repo": {
|
|
407
|
+
"source_docs": baseline_source_copied_to_repo,
|
|
408
|
+
"project_docs": baseline_project_copied_to_repo,
|
|
409
|
+
},
|
|
410
|
+
"copied_baseline_source_docs": baseline_source_copied,
|
|
411
|
+
"copied_baseline_project_docs": baseline_project_copied,
|
|
412
|
+
"copied_source_docs": source_copied,
|
|
413
|
+
"copied_project_docs": project_copied,
|
|
414
|
+
"overall_metrics": overall,
|
|
415
|
+
}
|
|
416
|
+
_write_json(eval_root / "eval_manifest.json", manifest)
|
|
417
|
+
return SourceDocMutationEvalResult(run_id=run_id, started_at=started_at, eval_root=eval_root, payload=manifest)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from .stores.execution_store import ExecutionStore
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def enqueue_source_doc_mutation_task(
|
|
9
|
+
*,
|
|
10
|
+
store: ExecutionStore,
|
|
11
|
+
project_id: str | None,
|
|
12
|
+
source_run_id: str,
|
|
13
|
+
mutation_request: dict[str, Any],
|
|
14
|
+
) -> dict[str, Any]:
|
|
15
|
+
queue_id = store.enqueue_source_doc_mutation_task(
|
|
16
|
+
project_id=project_id,
|
|
17
|
+
enqueue_run_id=source_run_id,
|
|
18
|
+
idea_id=str(mutation_request.get("idea_id") or "").strip() or None,
|
|
19
|
+
title=f"Source doc mutation for {str(mutation_request.get('idea_id') or 'unknown-idea')}",
|
|
20
|
+
mutation_request=mutation_request,
|
|
21
|
+
)
|
|
22
|
+
row = store.get_source_doc_mutation_queue_item(source_doc_mutation_queue_id=queue_id)
|
|
23
|
+
if row is None:
|
|
24
|
+
raise RuntimeError(f"source_doc_mutation_queue row missing after enqueue: {queue_id}")
|
|
25
|
+
return row
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from typing import Any, Literal
|
|
6
|
+
|
|
7
|
+
SectionKind = Literal["string", "scalar_list", "object", "keyed_list"]
|
|
8
|
+
MutationMode = Literal["replace", "merge", "remove"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True)
|
|
12
|
+
class SourceDocSectionSchema:
|
|
13
|
+
kind: SectionKind
|
|
14
|
+
default: Any
|
|
15
|
+
topic_key_field: str | None = None
|
|
16
|
+
nested_scalar_lists: tuple[str, ...] = ()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass(frozen=True)
|
|
20
|
+
class SourceDocSchema:
|
|
21
|
+
filename: str
|
|
22
|
+
sections: dict[str, SourceDocSectionSchema]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _clone(value: Any) -> Any:
|
|
26
|
+
return json.loads(json.dumps(value))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
SOURCE_DOC_SCHEMAS: dict[str, SourceDocSchema] = {
|
|
30
|
+
"product_brief.json": SourceDocSchema(
|
|
31
|
+
filename="product_brief.json",
|
|
32
|
+
sections={
|
|
33
|
+
"product_summary": SourceDocSectionSchema("string", ""),
|
|
34
|
+
"problem_statement": SourceDocSectionSchema("string", ""),
|
|
35
|
+
"target_users": SourceDocSectionSchema("scalar_list", []),
|
|
36
|
+
"goals": SourceDocSectionSchema("scalar_list", []),
|
|
37
|
+
"scope": SourceDocSectionSchema("object", {"in_scope": [], "out_of_scope": []}, nested_scalar_lists=("in_scope", "out_of_scope")),
|
|
38
|
+
"non_goals": SourceDocSectionSchema("scalar_list", []),
|
|
39
|
+
"constraints": SourceDocSectionSchema("scalar_list", []),
|
|
40
|
+
"success_criteria": SourceDocSectionSchema("scalar_list", []),
|
|
41
|
+
"assumptions": SourceDocSectionSchema("scalar_list", []),
|
|
42
|
+
},
|
|
43
|
+
),
|
|
44
|
+
"user_workflows.json": SourceDocSchema(
|
|
45
|
+
filename="user_workflows.json",
|
|
46
|
+
sections={
|
|
47
|
+
"actors": SourceDocSectionSchema("scalar_list", []),
|
|
48
|
+
"primary_workflows": SourceDocSectionSchema("keyed_list", [], topic_key_field="workflow_key"),
|
|
49
|
+
"alternate_flows": SourceDocSectionSchema("keyed_list", [], topic_key_field="workflow_key"),
|
|
50
|
+
"edge_cases": SourceDocSectionSchema("scalar_list", []),
|
|
51
|
+
"workflow_assumptions": SourceDocSectionSchema("scalar_list", []),
|
|
52
|
+
},
|
|
53
|
+
),
|
|
54
|
+
"domain_entities.json": SourceDocSchema(
|
|
55
|
+
filename="domain_entities.json",
|
|
56
|
+
sections={
|
|
57
|
+
"entities": SourceDocSectionSchema("keyed_list", [], topic_key_field="entity_key"),
|
|
58
|
+
"relationships": SourceDocSectionSchema("keyed_list", [], topic_key_field="relationship_key"),
|
|
59
|
+
"ownership_assumptions": SourceDocSectionSchema("scalar_list", []),
|
|
60
|
+
},
|
|
61
|
+
),
|
|
62
|
+
"assumptions_registry.json": SourceDocSchema(
|
|
63
|
+
filename="assumptions_registry.json",
|
|
64
|
+
sections={
|
|
65
|
+
"assumptions": SourceDocSectionSchema("keyed_list", [], topic_key_field="assumption_id"),
|
|
66
|
+
},
|
|
67
|
+
),
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def source_doc_template_payloads() -> dict[str, dict[str, Any]]:
|
|
72
|
+
return {name: {section: _clone(spec.default) for section, spec in schema.sections.items()} for name, schema in SOURCE_DOC_SCHEMAS.items()}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _dedupe_strings(values: list[Any]) -> list[str]:
|
|
76
|
+
out: list[str] = []
|
|
77
|
+
for item in values:
|
|
78
|
+
if not isinstance(item, str):
|
|
79
|
+
continue
|
|
80
|
+
text = item.strip()
|
|
81
|
+
if text and text not in out:
|
|
82
|
+
out.append(text)
|
|
83
|
+
return out
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def normalize_source_doc_payload(doc_name: str, payload: Any) -> dict[str, Any]:
|
|
87
|
+
schema = SOURCE_DOC_SCHEMAS[doc_name]
|
|
88
|
+
raw = payload if isinstance(payload, dict) else {}
|
|
89
|
+
normalized: dict[str, Any] = {}
|
|
90
|
+
for section_key, section_schema in schema.sections.items():
|
|
91
|
+
value = raw.get(section_key, _clone(section_schema.default))
|
|
92
|
+
if section_schema.kind == "string":
|
|
93
|
+
normalized[section_key] = str(value).strip() if isinstance(value, str) else str(value).strip() if value not in (None, "") else ""
|
|
94
|
+
elif section_schema.kind == "scalar_list":
|
|
95
|
+
normalized[section_key] = _dedupe_strings(value if isinstance(value, list) else [])
|
|
96
|
+
elif section_schema.kind == "object":
|
|
97
|
+
source = value if isinstance(value, dict) else {}
|
|
98
|
+
section_value = _clone(section_schema.default)
|
|
99
|
+
for nested_key, nested_default in section_value.items():
|
|
100
|
+
nested_value = source.get(nested_key, nested_default)
|
|
101
|
+
if nested_key in section_schema.nested_scalar_lists:
|
|
102
|
+
section_value[nested_key] = _dedupe_strings(nested_value if isinstance(nested_value, list) else [])
|
|
103
|
+
else:
|
|
104
|
+
section_value[nested_key] = _clone(nested_value)
|
|
105
|
+
normalized[section_key] = section_value
|
|
106
|
+
elif section_schema.kind == "keyed_list":
|
|
107
|
+
key_field = str(section_schema.topic_key_field)
|
|
108
|
+
items: list[dict[str, Any]] = []
|
|
109
|
+
for item in value if isinstance(value, list) else []:
|
|
110
|
+
if not isinstance(item, dict):
|
|
111
|
+
continue
|
|
112
|
+
topic_key = str(item.get(key_field) or "").strip()
|
|
113
|
+
if not topic_key or any(existing.get(key_field) == topic_key for existing in items):
|
|
114
|
+
continue
|
|
115
|
+
clean = _clone(item)
|
|
116
|
+
clean[key_field] = topic_key
|
|
117
|
+
items.append(clean)
|
|
118
|
+
normalized[section_key] = items
|
|
119
|
+
else:
|
|
120
|
+
raise ValueError(f"Unsupported source doc section kind: {section_schema.kind}")
|
|
121
|
+
return normalized
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def apply_source_doc_mutation(
|
|
125
|
+
doc_name: str,
|
|
126
|
+
payload: Any,
|
|
127
|
+
*,
|
|
128
|
+
section_key: str,
|
|
129
|
+
topic_key: str | None = None,
|
|
130
|
+
value: Any = None,
|
|
131
|
+
mode: MutationMode = "merge",
|
|
132
|
+
) -> tuple[dict[str, Any], bool]:
|
|
133
|
+
schema = SOURCE_DOC_SCHEMAS[doc_name]
|
|
134
|
+
if section_key not in schema.sections:
|
|
135
|
+
raise KeyError(f"Unknown section '{section_key}' for {doc_name}")
|
|
136
|
+
section_schema = schema.sections[section_key]
|
|
137
|
+
normalized = normalize_source_doc_payload(doc_name, payload)
|
|
138
|
+
before = json.dumps(normalized, sort_keys=True)
|
|
139
|
+
|
|
140
|
+
if section_schema.kind == "string":
|
|
141
|
+
if topic_key is not None:
|
|
142
|
+
raise ValueError(f"Section '{section_key}' does not support topic_key mutation")
|
|
143
|
+
normalized[section_key] = "" if mode == "remove" else str(value or "").strip()
|
|
144
|
+
elif section_schema.kind == "scalar_list":
|
|
145
|
+
current = list(normalized[section_key])
|
|
146
|
+
if topic_key is not None:
|
|
147
|
+
if mode == "remove":
|
|
148
|
+
normalized[section_key] = [item for item in current if item != topic_key]
|
|
149
|
+
else:
|
|
150
|
+
if value is not None:
|
|
151
|
+
raise ValueError(f"Section '{section_key}' expects topic_key-only mutation or whole-list value")
|
|
152
|
+
normalized[section_key] = _dedupe_strings(current + [topic_key])
|
|
153
|
+
elif mode == "replace":
|
|
154
|
+
normalized[section_key] = _dedupe_strings(value if isinstance(value, list) else [])
|
|
155
|
+
elif mode == "remove":
|
|
156
|
+
removals = _dedupe_strings(value if isinstance(value, list) else [value])
|
|
157
|
+
normalized[section_key] = [item for item in current if item not in removals]
|
|
158
|
+
else:
|
|
159
|
+
additions = _dedupe_strings(value if isinstance(value, list) else [value])
|
|
160
|
+
normalized[section_key] = _dedupe_strings(current + additions)
|
|
161
|
+
elif section_schema.kind == "object":
|
|
162
|
+
current = dict(normalized[section_key])
|
|
163
|
+
if topic_key is None:
|
|
164
|
+
if mode == "replace":
|
|
165
|
+
current = normalize_source_doc_payload(doc_name, {section_key: value}).get(section_key, _clone(section_schema.default))
|
|
166
|
+
elif isinstance(value, dict):
|
|
167
|
+
merged = current | value
|
|
168
|
+
current = normalize_source_doc_payload(doc_name, {section_key: merged}).get(section_key, _clone(section_schema.default))
|
|
169
|
+
else:
|
|
170
|
+
raise ValueError(f"Section '{section_key}' expects dict value when mutating without topic_key")
|
|
171
|
+
elif topic_key in section_schema.nested_scalar_lists:
|
|
172
|
+
existing = list(current.get(topic_key) or [])
|
|
173
|
+
if mode == "replace":
|
|
174
|
+
current[topic_key] = _dedupe_strings(value if isinstance(value, list) else [])
|
|
175
|
+
elif mode == "remove":
|
|
176
|
+
removals = _dedupe_strings(value if isinstance(value, list) else [value])
|
|
177
|
+
current[topic_key] = [item for item in existing if item not in removals]
|
|
178
|
+
else:
|
|
179
|
+
additions = _dedupe_strings(value if isinstance(value, list) else [value])
|
|
180
|
+
current[topic_key] = _dedupe_strings(existing + additions)
|
|
181
|
+
else:
|
|
182
|
+
raise KeyError(f"Unknown topic '{topic_key}' for section '{section_key}'")
|
|
183
|
+
normalized[section_key] = current
|
|
184
|
+
elif section_schema.kind == "keyed_list":
|
|
185
|
+
key_field = str(section_schema.topic_key_field)
|
|
186
|
+
current = list(normalized[section_key])
|
|
187
|
+
if not topic_key:
|
|
188
|
+
raise ValueError(f"Section '{section_key}' requires topic_key mutation")
|
|
189
|
+
survivors = [item for item in current if str(item.get(key_field) or "") != topic_key]
|
|
190
|
+
if mode == "remove":
|
|
191
|
+
normalized[section_key] = survivors
|
|
192
|
+
else:
|
|
193
|
+
incoming = value if isinstance(value, dict) else {}
|
|
194
|
+
previous = next((item for item in current if str(item.get(key_field) or "") == topic_key), {})
|
|
195
|
+
if mode == "replace":
|
|
196
|
+
merged = dict(incoming)
|
|
197
|
+
else:
|
|
198
|
+
merged = dict(previous)
|
|
199
|
+
merged.update(incoming)
|
|
200
|
+
merged[key_field] = topic_key
|
|
201
|
+
normalized[section_key] = survivors + [merged]
|
|
202
|
+
else:
|
|
203
|
+
raise ValueError(f"Unsupported source doc section kind: {section_schema.kind}")
|
|
204
|
+
|
|
205
|
+
normalized = normalize_source_doc_payload(doc_name, normalized)
|
|
206
|
+
after = json.dumps(normalized, sort_keys=True)
|
|
207
|
+
return normalized, before != after
|