codeplain 0.4.3.dev61__tar.gz → 0.4.3.dev63__tar.gz

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 (216) hide show
  1. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/PKG-INFO +2 -2
  2. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/codeplain_REST_api.py +51 -47
  3. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain2code.py +2 -0
  4. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/pyproject.toml +1 -1
  5. codeplain-0.4.3.dev63/render_machine/actions/fix_conformance_test.py +423 -0
  6. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/fix_unit_tests.py +1 -0
  7. codeplain-0.4.3.dev63/render_machine/actions/prepare_testing_environment.py +120 -0
  8. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/render_conformance_tests.py +2 -0
  9. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/run_conformance_tests.py +5 -0
  10. codeplain-0.4.3.dev63/render_machine/agent_tools.py +601 -0
  11. codeplain-0.4.3.dev63/render_machine/conformance_fix_conversation.py +409 -0
  12. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/render_context.py +3 -1
  13. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/render_types.py +69 -0
  14. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/render_utils.py +10 -1
  15. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/requirements.txt +1 -1
  16. codeplain-0.4.3.dev63/tests/test_agent_tools.py +346 -0
  17. codeplain-0.4.3.dev63/tests/test_api_client_retries.py +52 -0
  18. codeplain-0.4.3.dev63/tests/test_background_preparation.py +73 -0
  19. codeplain-0.4.3.dev63/tests/test_conformance_fix_conversation.py +677 -0
  20. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_fix_unit_tests_action.py +7 -0
  21. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_fix_unit_tests_conformance_context.py +8 -106
  22. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_render_finished_report.py +14 -0
  23. codeplain-0.4.3.dev63/tests/test_script_timeout_hint.py +24 -0
  24. codeplain-0.4.3.dev61/render_machine/actions/fix_conformance_test.py +0 -221
  25. codeplain-0.4.3.dev61/render_machine/actions/prepare_testing_environment.py +0 -46
  26. codeplain-0.4.3.dev61/render_machine/agent_tools.py +0 -270
  27. codeplain-0.4.3.dev61/tests/test_agent_tools.py +0 -166
  28. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.claude/settings.json +0 -0
  29. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.flake8 +0 -0
  30. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.github/dependabot.yml +0 -0
  31. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.github/scripts/record-linear-release.cjs +0 -0
  32. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.github/workflows/e2e.yml +0 -0
  33. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.github/workflows/lint-and-test.yml +0 -0
  34. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.github/workflows/lint-powershell.yml +0 -0
  35. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.github/workflows/notify-slack-on-main-merge.yml +0 -0
  36. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.github/workflows/publish-dev-to-pypi.yml +0 -0
  37. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.github/workflows/publish-install-script.yml +0 -0
  38. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.github/workflows/publish-to-pypi.yml +0 -0
  39. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.gitignore +0 -0
  40. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.vscode/launch.json +0 -0
  41. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/.vscode/settings.json +0 -0
  42. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/CLAUDE.md +0 -0
  43. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/CONTRIBUTING.md +0 -0
  44. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/LICENSE +0 -0
  45. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/README.md +0 -0
  46. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/change_detection.py +0 -0
  47. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/cli_output/__init__.py +0 -0
  48. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/cli_output/dry_run.py +0 -0
  49. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/cli_output/render_summary.py +0 -0
  50. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/cli_output/status.py +0 -0
  51. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/concept_utils.py +0 -0
  52. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/config/__init__.py +0 -0
  53. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/config/system_config.yaml +0 -0
  54. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/conformance_fix_journal.py +0 -0
  55. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/diff_utils.py +0 -0
  56. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/docs/generate_cli.py +0 -0
  57. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/docs/plain2code_cli.md +0 -0
  58. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/docs/starting_a_plain_project_from_scratch.md +0 -0
  59. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/event_bus.py +0 -0
  60. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_golang/config.yaml +0 -0
  61. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_golang/harness_tests/hello_world_test.go +0 -0
  62. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_golang/hello_world_golang.plain +0 -0
  63. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_golang/run.sh +0 -0
  64. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_golang/tests/hello_world_golang/display-hello-world.plain +0 -0
  65. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_python/config.yaml +0 -0
  66. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_python/harness_tests/hello_world_display/test_hello_world.py +0 -0
  67. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_python/hello_world_python.plain +0 -0
  68. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_python/run.sh +0 -0
  69. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_python/tests/hello_world_python/display-hello-world.plain +0 -0
  70. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_react/config.yaml +0 -0
  71. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_react/harness_tests/hello_world_display/cypress/e2e/hello_world.cy.ts +0 -0
  72. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_react/harness_tests/hello_world_display/cypress/support/e2e.ts +0 -0
  73. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_react/harness_tests/hello_world_display/cypress.config.ts +0 -0
  74. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_react/harness_tests/hello_world_display/package.json +0 -0
  75. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_react/harness_tests/hello_world_display/tsconfig.json +0 -0
  76. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_react/hello_world_react.plain +0 -0
  77. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_react/run.sh +0 -0
  78. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_react/tests/hello_world_react/display-hello-world.plain +0 -0
  79. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/example_hello_world_react/tests/typescript-react-app-boilerplate/entry-point.plain +0 -0
  80. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/examples/run.sh +0 -0
  81. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/file_utils.py +0 -0
  82. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/git_preflight.py +0 -0
  83. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/git_utils.py +0 -0
  84. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/install/bash/examples.sh +0 -0
  85. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/install/bash/install.sh +0 -0
  86. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/install/bash/walkthrough.sh +0 -0
  87. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/install/powershell/examples.ps1 +0 -0
  88. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/install/powershell/install.ps1 +0 -0
  89. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/install/powershell/walkthrough.ps1 +0 -0
  90. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/memory_management.py +0 -0
  91. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/metadata_utils.py +0 -0
  92. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/module_renderer.py +0 -0
  93. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/partial_rendering.py +0 -0
  94. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/path_resolution.py +0 -0
  95. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain2code_arguments.py +0 -0
  96. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain2code_cli.md +0 -0
  97. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain2code_console.py +0 -0
  98. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain2code_events.py +0 -0
  99. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain2code_exceptions.py +0 -0
  100. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain2code_logger.py +0 -0
  101. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain2code_nodes.py +0 -0
  102. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain2code_read_config.py +0 -0
  103. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain2code_state.py +0 -0
  104. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain2code_telemetry.py +0 -0
  105. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain2code_utils.py +0 -0
  106. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain_file.py +0 -0
  107. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain_modules.py +0 -0
  108. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/plain_spec.py +0 -0
  109. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/pytest.ini +0 -0
  110. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/__init__.py +0 -0
  111. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/analyze_specification_ambiguity.py +0 -0
  112. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/base_action.py +0 -0
  113. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/commit_conformance_tests_changes.py +0 -0
  114. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/commit_implementation_code_changes.py +0 -0
  115. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/create_dist.py +0 -0
  116. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/distill_conformance_test_memory.py +0 -0
  117. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/exit_with_error.py +0 -0
  118. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/finish_functional_requirement.py +0 -0
  119. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/prepare_repositories.py +0 -0
  120. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/refactor_code.py +0 -0
  121. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/render_functional_requirement.py +0 -0
  122. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/run_unit_tests.py +0 -0
  123. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/actions/summarize_conformance_tests.py +0 -0
  124. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/code_renderer.py +0 -0
  125. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/conformance_tests.py +0 -0
  126. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/implementation_code_helpers.py +0 -0
  127. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/state_machine_config.py +0 -0
  128. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/states.py +0 -0
  129. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/render_machine/triggers.py +0 -0
  130. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/resources/codeplain_overview.png +0 -0
  131. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/resources/plain_example.png +0 -0
  132. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/standard_template_library/golang-console-app-template.plain +0 -0
  133. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/standard_template_library/python-console-app-template.plain +0 -0
  134. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/standard_template_library/typescript-react-app-boilerplate.plain +0 -0
  135. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/standard_template_library/typescript-react-app-template.plain +0 -0
  136. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/system_config.py +0 -0
  137. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_conformance_tests_cypress.ps1 +0 -0
  138. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_conformance_tests_cypress.sh +0 -0
  139. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_conformance_tests_golang.ps1 +0 -0
  140. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_conformance_tests_golang.sh +0 -0
  141. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_conformance_tests_python.ps1 +0 -0
  142. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_conformance_tests_python.sh +0 -0
  143. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_unittests_flutter.ps1 +0 -0
  144. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_unittests_flutter.sh +0 -0
  145. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_unittests_golang.ps1 +0 -0
  146. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_unittests_golang.sh +0 -0
  147. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_unittests_python.ps1 +0 -0
  148. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_unittests_python.sh +0 -0
  149. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_unittests_react.ps1 +0 -0
  150. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/test_scripts/run_unittests_react.sh +0 -0
  151. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/__init__.py +0 -0
  152. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/conftest.py +0 -0
  153. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/data/acceptance_tests_warning/main_requiring_acceptance_tests.plain +0 -0
  154. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/data/acceptance_tests_warning/required_with_acceptance_tests.plain +0 -0
  155. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/data/acceptance_tests_warning/tests/required_with_acceptance_tests/entry-point.plain +0 -0
  156. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/data/partial_rendering/pr_code_var.plain +0 -0
  157. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/data/partial_rendering/pr_implement.plain +0 -0
  158. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/data/partial_rendering/pr_leaf.plain +0 -0
  159. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/data/partial_rendering/pr_middle.plain +0 -0
  160. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/data/partial_rendering/pr_root.plain +0 -0
  161. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/data/partial_rendering/pr_solo.plain +0 -0
  162. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/e2e/Dockerfile +0 -0
  163. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/e2e/conftest.py +0 -0
  164. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/e2e/test_hello_world_python.py +0 -0
  165. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/e2e/test_hello_world_python_windows.py +0 -0
  166. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_acceptance_scenario_rendered_once.py +0 -0
  167. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_acceptance_scenarios_after_a_code_fix.py +0 -0
  168. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_arg_provenance.py +0 -0
  169. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_change_detection.py +0 -0
  170. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_cli_output.py +0 -0
  171. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_conformance_fix_journal.py +0 -0
  172. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_console_log_styles.py +0 -0
  173. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_dependency_pins.py +0 -0
  174. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_distill_conformance_test_memory.py +0 -0
  175. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_dry_run_link_validation.py +0 -0
  176. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_exit_when_done.py +0 -0
  177. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_file_utils.py +0 -0
  178. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_folder_path_resolution.py +0 -0
  179. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_frid_arguments.py +0 -0
  180. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_functionality_position.py +0 -0
  181. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_functionality_without_scenarios.py +0 -0
  182. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_git_preflight.py +0 -0
  183. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_git_utils.py +0 -0
  184. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_headless_logging.py +0 -0
  185. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_log_file_name_resolution.py +0 -0
  186. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_logging_config_path_resolution.py +0 -0
  187. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_partial_rendering.py +0 -0
  188. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_path_resolution.py +0 -0
  189. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_plain2code.py +0 -0
  190. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_plain2code_state.py +0 -0
  191. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_plain2code_utils.py +0 -0
  192. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_plain_modules.py +0 -0
  193. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_prepare_repositories_layout.py +0 -0
  194. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_render_range.py +0 -0
  195. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_render_stop_reason.py +0 -0
  196. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_resolve_config_file.py +0 -0
  197. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_script_path_resolution.py +0 -0
  198. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_system_config.py +0 -0
  199. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_telemetry.py +0 -0
  200. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_terminal_attachment.py +0 -0
  201. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_tests_folders.py +0 -0
  202. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_traceability_warnings.py +0 -0
  203. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_tui_components.py +0 -0
  204. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_tui_usage.py +0 -0
  205. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_usage_summary.py +0 -0
  206. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tests/test_user_error_message.py +0 -0
  207. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tui/__init__.py +0 -0
  208. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tui/components.py +0 -0
  209. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tui/models.py +0 -0
  210. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tui/plain2code_tui.py +0 -0
  211. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tui/plain_module_render_choice_tui.py +0 -0
  212. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tui/spinner.py +0 -0
  213. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tui/state_handlers.py +0 -0
  214. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tui/styles.css +0 -0
  215. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/tui/widget_helpers.py +0 -0
  216. {codeplain-0.4.3.dev61 → codeplain-0.4.3.dev63}/usage_summary.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: codeplain
3
- Version: 0.4.3.dev61
3
+ Version: 0.4.3.dev63
4
4
  Summary: Transform plain language specifications into working code
5
5
  License-File: LICENSE
6
6
  Classifier: Environment :: Console
@@ -16,7 +16,7 @@ Requires-Dist: python-liquid2==0.4.0
16
16
  Requires-Dist: pyyaml==6.0.3
17
17
  Requires-Dist: requests==2.34.2
18
18
  Requires-Dist: rich==15.0.0
19
- Requires-Dist: sentry-sdk==2.73.0
19
+ Requires-Dist: sentry-sdk==2.74.0
20
20
  Requires-Dist: textual>=7.5.0
21
21
  Requires-Dist: tiktoken==0.14.0
22
22
  Requires-Dist: transitions==0.9.3
@@ -13,6 +13,10 @@ from plain2code_state import RunState
13
13
 
14
14
  MAX_RETRIES = 4
15
15
  RETRY_DELAY = 3
16
+ # Agent calls carry a whole session: losing one ends a long-running fix, so they retry longer (with the delay
17
+ # capped), which rides out a provider or network outage of several minutes.
18
+ AGENT_MAX_RETRIES = 8
19
+ MAX_RETRY_DELAY = 60
16
20
 
17
21
  # A report the render does not consume must not be able to hold the process open
18
22
  # at exit, and requests waits indefinitely by default.
@@ -86,6 +90,18 @@ ERROR_CODE_EXCEPTIONS = {
86
90
  }
87
91
 
88
92
 
93
+ # Client errors that a retry can fix: a timeout on the server's side and rate limiting.
94
+ RETRYABLE_CLIENT_ERROR_STATUSES = {408, 429}
95
+
96
+
97
+ def _is_permanent_client_error(error: Exception) -> bool:
98
+ """An HTTP 4xx answer other than RETRYABLE_CLIENT_ERROR_STATUSES: asking again gets the same answer."""
99
+ if not isinstance(error, requests.exceptions.HTTPError) or error.response is None:
100
+ return False
101
+ status = error.response.status_code
102
+ return 400 <= status < 500 and status not in RETRYABLE_CLIENT_ERROR_STATUSES
103
+
104
+
89
105
  class CodeplainAPI:
90
106
 
91
107
  def __init__(self, api_key, console):
@@ -135,7 +151,7 @@ class CodeplainAPI:
135
151
  )
136
152
  time.sleep(retry_delay)
137
153
  # Exponential backoff
138
- return retry_delay * 2
154
+ return min(retry_delay * 2, MAX_RETRY_DELAY)
139
155
  else:
140
156
  if not silent:
141
157
  self.console.error(f"Max retries ({num_retries}) exceeded. Last error: {error}")
@@ -214,6 +230,10 @@ class CodeplainAPI:
214
230
  if response_json is not None and "error_code" in response_json:
215
231
  if response_json["error_code"] not in RETRY_ERROR_CODES:
216
232
  raise e
233
+ if _is_permanent_client_error(e):
234
+ # Asking again gets the same answer (e.g. an expired agent session is 404): the caller gets the
235
+ # HTTPError itself, right away, to handle it.
236
+ raise e
217
237
 
218
238
  retry_delay = self._handle_retry_logic(attempt, retry_delay, num_retries, e, silent)
219
239
 
@@ -405,50 +425,6 @@ class CodeplainAPI:
405
425
 
406
426
  return self.post_request(endpoint_url, headers, payload, run_state)
407
427
 
408
- def fix_conformance_tests_issue(
409
- self,
410
- frid,
411
- functional_requirement_id,
412
- plain_source_tree,
413
- linked_resources,
414
- existing_files_content,
415
- memory_files_content,
416
- module_name: str,
417
- conformance_tests_module_name: str,
418
- required_modules,
419
- code_diff,
420
- conformance_tests_files,
421
- conformance_tests_issue,
422
- implementation_fix_count,
423
- conformance_tests_folder_name,
424
- conflicting_requirements_count: int,
425
- fix_attempts_journal: list,
426
- run_state: RunState,
427
- ):
428
- endpoint_url = f"{self.api_url}/fix_conformance_tests_issue"
429
- headers = {"X-API-Key": self.api_key, "Content-Type": "application/json"}
430
-
431
- payload = {
432
- "frid": frid,
433
- "functional_requirement_id": functional_requirement_id,
434
- "plain_source_tree": plain_source_tree,
435
- "linked_resources": linked_resources,
436
- "existing_files_content": existing_files_content,
437
- "memory_files_content": memory_files_content,
438
- "module_name": module_name,
439
- "conformance_tests_module_name": conformance_tests_module_name,
440
- "required_modules": required_modules,
441
- "code_diff": code_diff,
442
- "conformance_tests_files": conformance_tests_files,
443
- "conformance_tests_issue": conformance_tests_issue,
444
- "implementation_fix_count": implementation_fix_count,
445
- "conformance_tests_folder_name": conformance_tests_folder_name,
446
- "conflicting_requirements_count": conflicting_requirements_count,
447
- "fix_attempts_journal": fix_attempts_journal,
448
- }
449
-
450
- return self.post_request(endpoint_url, headers, payload, run_state)
451
-
452
428
  def render_acceptance_tests(
453
429
  self,
454
430
  frid,
@@ -577,6 +553,34 @@ class CodeplainAPI:
577
553
 
578
554
  return self.post_request(endpoint_url, headers, payload, run_state)
579
555
 
556
+ def report_conflicting_requirements(
557
+ self,
558
+ frid: str,
559
+ functional_requirement_id: str,
560
+ plain_source_tree: dict,
561
+ module_name: str,
562
+ conformance_tests_module_name: str,
563
+ required_modules,
564
+ failing_reason: str,
565
+ conflict_reason: str,
566
+ run_state: RunState,
567
+ ):
568
+ """Report a conflict the conformance tests fixer and its reviewer agreed on after it had been declared
569
+ once. The server always answers with the ConflictingRequirements error, raised here, ending the render."""
570
+ endpoint_url = f"{self.api_url}/report_conflicting_requirements"
571
+ headers = {"X-API-Key": self.api_key, "Content-Type": "application/json"}
572
+ payload = {
573
+ "frid": frid,
574
+ "functional_requirement_id": functional_requirement_id,
575
+ "plain_source_tree": plain_source_tree,
576
+ "module_name": module_name,
577
+ "conformance_tests_module_name": conformance_tests_module_name,
578
+ "required_modules": required_modules,
579
+ "failing_reason": failing_reason,
580
+ "conflict_reason": conflict_reason,
581
+ }
582
+ return self.post_request(endpoint_url, headers, payload, run_state)
583
+
580
584
  def agent_start(self, task_type: str, task_params: dict, frid: str, module_name: str, run_state: RunState):
581
585
  """Start a server-side agent session; returns the first turn (tool calls or completion)."""
582
586
  endpoint_url = f"{self.api_url}/agent/start"
@@ -587,7 +591,7 @@ class CodeplainAPI:
587
591
  "frid": frid,
588
592
  "module_name": module_name,
589
593
  }
590
- return self.post_request(endpoint_url, headers, payload, run_state)
594
+ return self.post_request(endpoint_url, headers, payload, run_state, num_retries=AGENT_MAX_RETRIES)
591
595
 
592
596
  def agent_continue(
593
597
  self, session_id: str, tool_results: list[dict], frid: str, module_name: str, run_state: RunState
@@ -601,4 +605,4 @@ class CodeplainAPI:
601
605
  "frid": frid,
602
606
  "module_name": module_name,
603
607
  }
604
- return self.post_request(endpoint_url, headers, payload, run_state)
608
+ return self.post_request(endpoint_url, headers, payload, run_state, num_retries=AGENT_MAX_RETRIES)
@@ -581,6 +581,8 @@ def main(): # noqa: C901
581
581
  interrupted = True
582
582
  else:
583
583
  error_message = user_error_message(e)
584
+ # A module that finished before the error set render_succeeded; the render as a whole did not.
585
+ run_state.set_render_succeeded(False)
584
586
 
585
587
  if not isinstance(e, EXPECTED_EXCEPTIONS):
586
588
  exc_info = sys.exc_info()
@@ -29,7 +29,7 @@ dependencies = [
29
29
  "transitions==0.9.3",
30
30
  "textual>=7.5.0",
31
31
  "rich==15.0.0",
32
- "sentry-sdk==2.73.0",
32
+ "sentry-sdk==2.74.0",
33
33
  ]
34
34
 
35
35
  [project.optional-dependencies]
@@ -0,0 +1,423 @@
1
+ import os
2
+ from typing import Any, Optional
3
+
4
+ import file_utils
5
+ import plain_spec
6
+ from memory_management import MemoryManager
7
+ from plain2code_console import RETRY_COLOR, console
8
+ from plain2code_exceptions import InternalClientError
9
+ from plain2code_utils import qualified_frid
10
+ from render_machine import agent_tools
11
+ from render_machine.actions.base_action import BaseAction
12
+ from render_machine.actions.fix_unit_tests import FixUnitTests
13
+ from render_machine.conformance_fix_conversation import (
14
+ CONFLICTING_REQUIREMENTS,
15
+ ConformanceFixConversation,
16
+ )
17
+ from render_machine.implementation_code_helpers import ImplementationCodeHelpers
18
+ from render_machine.render_context import RenderContext
19
+ from render_machine.render_types import ConformanceFixAgents, RenderError, TestExecutionPhase
20
+
21
+ MAX_CONFORMANCE_TEST_FIX_ATTEMPTS = 20
22
+ MAX_CONFORMANCE_TEST_RERENDER_ATTEMPTS = 1
23
+ # What is recorded for the changes of a fix the reviewer did not approve (see FixConformanceTest.execute).
24
+ UNAPPROVED_FIX_ARGS = {
25
+ "root_cause": None,
26
+ "changes_made": "Changes the conformance tests fixer made without getting them approved by the reviewer.",
27
+ }
28
+ # Bound on the conformance tests files a new session is seeded with.
29
+ MAX_CONFORMANCE_TESTS_FILES_CHARS = 60_000
30
+
31
+
32
+ class FixConformanceTest(BaseAction):
33
+ """Fix failing conformance tests through a conversation between a fixer agent and a reviewer agent (see
34
+ ConformanceFixConversation). The action returns once the reviewer approved a fix; the state machine then
35
+ runs the tests again (after the unit tests, when the implementation code changed). The two agents live as
36
+ long as the conformance tests of the same functionality keep failing, so each next execution continues
37
+ them with the new failure output."""
38
+
39
+ IMPLEMENTATION_CODE_NOT_UPDATED = "implementation_code_not_updated"
40
+ IMPLEMENTATION_CODE_UPDATED = "implementation_code_updated"
41
+ LIMIT_EXCEEDED_OUTCOME = "conformance_test_fix_limit_exceeded"
42
+ REGENERATE_CONFORMANCE_TESTS_OUTCOME = "regenerate_conformance_tests"
43
+
44
+ def execute(self, render_context: RenderContext, previous_action_payload: Any | None):
45
+ ctx = render_context.conformance_tests_running_context
46
+ ctx.fix_attempts += 1
47
+
48
+ if ctx.fix_attempts >= MAX_CONFORMANCE_TEST_FIX_ATTEMPTS:
49
+ ctx.conformance_fix_agents = None
50
+ if ctx.conformance_tests_render_attempts >= MAX_CONFORMANCE_TEST_RERENDER_ATTEMPTS:
51
+ error_msg = f"The renderer was unable to produce an implementation that passes conformance tests for functionality '{render_context.frid_context.frid}' after many attempts. Please review and rewrite the specification. (Render ID: {render_context.run_state.render_id})"
52
+ render_context.last_error_message = error_msg
53
+ return (
54
+ self.LIMIT_EXCEEDED_OUTCOME,
55
+ RenderError.encode(message=error_msg).to_payload(),
56
+ )
57
+ else:
58
+ ctx.regenerating_conformance_tests = True
59
+ return self.REGENERATE_CONFORMANCE_TESTS_OUTCOME, None
60
+
61
+ console.info(f"Running conformance tests attempt {ctx.fix_attempts + 1}.")
62
+ console.info(f"Fixing conformance test for functionality {render_context.testing_functionality_label()}.")
63
+
64
+ if not previous_action_payload or not previous_action_payload.get("previous_conformance_tests_issue"):
65
+ raise InternalClientError(
66
+ "Internal client error: Previous action payload does not contain previous conformance tests issue."
67
+ )
68
+ issue = previous_action_payload["previous_conformance_tests_issue"]
69
+
70
+ journal = render_context.memory_manager.journal
71
+ journal.record_result(ctx.current_testing_module_name, ctx.current_testing_frid, passed=False)
72
+ journal.open_attempt(ctx.current_testing_module_name, ctx.current_testing_frid, ctx.fix_attempts, issue)
73
+
74
+ # Reset the conflicting requirement count if the current testing functionality is not the same as the
75
+ # previously conflicting functionality.
76
+ if (ctx.conflicting_module_name, ctx.conflicting_frid) != (
77
+ ctx.current_testing_module_name,
78
+ ctx.current_testing_frid,
79
+ ):
80
+ ctx.conflicting_requirement_count = 0
81
+
82
+ agents = self._agents_for_current_tests(render_context)
83
+ common_params = self._common_params(render_context, agents)
84
+ conversation = ConformanceFixConversation(
85
+ render_context, agents, self._fixer_params(render_context, common_params), common_params
86
+ )
87
+ log_path = render_context.script_execution_history.latest_conformance_test_output_path
88
+ fix = conversation.fix(issue, log_path)
89
+ if fix is not None:
90
+ return self._apply_outcome(render_context, conversation, fix.args, fix.changed_files)
91
+
92
+ # No fix was approved. Its changes stay (see ConformanceFixConversation.fix) and the tests decide; changed
93
+ # implementation code is then tested like an approved change, after the unit tests and a fresh preparation,
94
+ # so it cannot be committed with broken unit tests or tested on an environment prepared for older code.
95
+ changed_files = conversation.unapproved_changes()
96
+ if any(path.startswith(conversation.build_folder + os.sep) for path in changed_files):
97
+ console.warning(
98
+ "No fix was approved; the implementation code the fixer changed is kept and tested: the unit tests "
99
+ "first, then the conformance tests."
100
+ )
101
+ return self._apply_outcome(render_context, conversation, UNAPPROVED_FIX_ARGS, changed_files)
102
+ journal.record_fix(
103
+ ctx.current_testing_module_name, ctx.current_testing_frid, None, [], "IMPLEMENTATION_CODE", None, None
104
+ )
105
+ return self.IMPLEMENTATION_CODE_NOT_UPDATED, None
106
+
107
+ # ---------------------------------------------------------------------------------------------------------
108
+
109
+ def _apply_outcome(
110
+ self,
111
+ render_context: RenderContext,
112
+ conversation: ConformanceFixConversation,
113
+ args: dict,
114
+ changed_files: dict[str, Optional[str]],
115
+ ):
116
+ """Record the fix (the fixer's submit_fix `args` and the files it changed) and pick the next step: the unit
117
+ tests when the implementation code changed, otherwise the conformance tests right away. A conflict confirmed
118
+ a second time ends the render."""
119
+ ctx = render_context.conformance_tests_running_context
120
+ build_folder = conversation.build_folder
121
+ implementation_files = {path for path in changed_files if path.startswith(build_folder + os.sep)}
122
+ code_diff = conversation.diff(changed_files)
123
+ implementation_code_diff = {
124
+ name: diff for name, diff in code_diff.items() if os.path.join(build_folder, name) in implementation_files
125
+ }
126
+ summary = {"hypothesis": args.get("root_cause"), "approach": args.get("changes_made")}
127
+
128
+ if args.get("failing_reason") == CONFLICTING_REQUIREMENTS:
129
+ self._handle_conflict(render_context, args)
130
+
131
+ console.print_files(
132
+ "Files changed while fixing conformance tests:",
133
+ build_folder,
134
+ {conversation.display_name(path): "" for path in sorted(changed_files)},
135
+ style=console.OUTPUT_STYLE,
136
+ )
137
+ target = "IMPLEMENTATION_CODE" if implementation_files else "CONFORMANCE_TESTS"
138
+ render_context.memory_manager.journal.record_fix(
139
+ ctx.current_testing_module_name,
140
+ ctx.current_testing_frid,
141
+ summary,
142
+ sorted(conversation.display_name(path) for path in changed_files),
143
+ target,
144
+ code_diff,
145
+ None,
146
+ )
147
+
148
+ if not implementation_files:
149
+ return self.IMPLEMENTATION_CODE_NOT_UPDATED, None
150
+
151
+ ctx.should_prepare_testing_environment = True
152
+ ctx.test_that_triggered_code_change = (ctx.current_testing_module_name, ctx.current_testing_frid)
153
+ ctx.execution_phase = TestExecutionPhase.RETRYING_AFTER_CODE_CHANGE
154
+ # Remember the change so that the unit tests fixer (which runs next) preserves it instead of reverting
155
+ # it - see FixUnitTests.
156
+ ctx.implementation_code_fixes.append(
157
+ {
158
+ **summary,
159
+ "code_diff": implementation_code_diff,
160
+ "tested": (ctx.current_testing_module_name, str(ctx.current_testing_frid)),
161
+ }
162
+ )
163
+ return self.IMPLEMENTATION_CODE_UPDATED, None
164
+
165
+ def _handle_conflict(self, render_context: RenderContext, args: dict) -> None:
166
+ ctx = render_context.conformance_tests_running_context
167
+ failing_reason = (
168
+ "CONFLICTING_REQUIREMENTS" if self._is_regression(render_context) else "CONFLICTING_ACCEPTANCE_TESTS"
169
+ )
170
+ conflicting_module, conflicting_frid = ctx.current_testing_module_name, str(ctx.current_testing_frid)
171
+ other_tested = self._other_functionality_of_conflict(render_context)
172
+ if other_tested is not None:
173
+ # The functionality has no acceptance tests to conflict with: its tests conflict with the functionality
174
+ # whose tests an earlier fix of this phase made pass (see _other_functionalities_fixes).
175
+ failing_reason = "CONFLICTING_REQUIREMENTS"
176
+ conflicting_module, conflicting_frid = other_tested
177
+ if ctx.conflicting_requirement_count >= 1:
178
+ # Declared before, a fix did not resolve it, and the reviewer agreed again: the server reports it as
179
+ # the ConflictingRequirements error, which ends the render.
180
+ render_context.codeplain_api.report_conflicting_requirements(
181
+ render_context.frid_context.frid,
182
+ conflicting_frid,
183
+ render_context.plain_source_tree,
184
+ render_context.module_name,
185
+ conflicting_module,
186
+ render_context.get_required_modules_functionalities(),
187
+ failing_reason,
188
+ args.get("conflict_reason", ""),
189
+ run_state=render_context.run_state,
190
+ )
191
+ raise InternalClientError("The server did not report the confirmed conflict.")
192
+ ctx.conflicting_requirement_count += 1
193
+ ctx.conflicting_module_name = ctx.current_testing_module_name
194
+ ctx.conflicting_frid = ctx.current_testing_frid
195
+ console.info(
196
+ f"↻ Potential conflicting functionalities detected while fixing conformance tests "
197
+ f"for functionality {render_context.testing_functionality_label()}.",
198
+ color=RETRY_COLOR,
199
+ )
200
+
201
+ @staticmethod
202
+ def _other_functionality_of_conflict(render_context: RenderContext) -> Optional[tuple[str, str]]:
203
+ """The functionality a conflict declared for the current functionality's own tests is with, when that
204
+ functionality has no acceptance tests: the one whose tests the most recent fix of this phase for other tests
205
+ made pass. None for regression tests, with acceptance tests, or without such a fix."""
206
+ if FixConformanceTest._is_regression(render_context):
207
+ return None
208
+ specifications, _ = plain_spec.get_specifications_for_frid(
209
+ render_context.plain_source_tree, render_context.frid_context.frid
210
+ )
211
+ if specifications.get(plain_spec.ACCEPTANCE_TESTS):
212
+ return None
213
+ ctx = render_context.conformance_tests_running_context
214
+ tested = (ctx.current_testing_module_name, str(ctx.current_testing_frid))
215
+ for fix in reversed(ctx.implementation_code_fixes):
216
+ if fix.get("tested") and tuple(fix["tested"]) != tested:
217
+ module_name, frid = fix["tested"]
218
+ return module_name, frid
219
+ return None
220
+
221
+ # ---------------------------------------------------------------------------------------------------------
222
+
223
+ @staticmethod
224
+ def _agents_for_current_tests(render_context: RenderContext) -> ConformanceFixAgents:
225
+ """The fixer and reviewer of the failing tests; new ones when a different functionality's tests fail."""
226
+ ctx = render_context.conformance_tests_running_context
227
+ tested = (ctx.current_testing_module_name, str(ctx.current_testing_frid))
228
+ if ctx.conformance_fix_agents is None or ctx.conformance_fix_agents.tested != tested:
229
+ ctx.conformance_fix_agents = ConformanceFixAgents(
230
+ tested=tested,
231
+ conformance_tests_folder=FixConformanceTest._writable_conformance_tests_folder(render_context),
232
+ readable_tests_folders=FixConformanceTest._readable_conformance_tests_folders(render_context),
233
+ plain_modules_folder=agent_tools.rendered_modules_folder(render_context),
234
+ writable_module_tests_folder=(
235
+ os.path.normpath(
236
+ os.path.abspath(
237
+ render_context.conformance_tests.get_module_conformance_tests_folder(
238
+ render_context.module_name
239
+ )
240
+ )
241
+ )
242
+ if FixConformanceTest._is_regression(render_context)
243
+ else ""
244
+ ),
245
+ )
246
+ if FixConformanceTest._is_regression(render_context):
247
+ ctx.conformance_fix_agents.other_tests_folders = FixConformanceTest._other_tests_folders(
248
+ render_context, ctx.conformance_fix_agents.conformance_tests_folder
249
+ )
250
+ return ctx.conformance_fix_agents
251
+
252
+ @staticmethod
253
+ def _readable_conformance_tests_folders(render_context: RenderContext) -> list[str]:
254
+ """The existing conformance tests folders of the current module and of every module it requires that lie
255
+ outside the rendered modules folder (those inside it are readable with it)."""
256
+ root = agent_tools.rendered_modules_folder(render_context)
257
+ module_names = [render_context.module_name] + [
258
+ module.module_name for module in render_context.plain_module.all_required_modules
259
+ ]
260
+ folders: list[str] = []
261
+ for module_name in module_names:
262
+ folder = os.path.normpath(
263
+ os.path.abspath(render_context.conformance_tests.get_module_conformance_tests_folder(module_name))
264
+ )
265
+ if os.path.isdir(folder) and folder not in folders and not folder.startswith(root + os.sep):
266
+ folders.append(folder)
267
+ return folders
268
+
269
+ @staticmethod
270
+ def _writable_conformance_tests_folder(render_context: RenderContext) -> str:
271
+ """The folder of the failing conformance tests. A required module's tests are fixed in their copy inside
272
+ the current module (made here if missing), which is the copy the conformance tests then run from. The copies
273
+ of that module's other functionalities' tests are made too, so a fix of a cause they share can reach them
274
+ (they run from their copies later)."""
275
+ ctx = render_context.conformance_tests_running_context
276
+ folder = ctx.get_current_conformance_test_folder_name()
277
+ if render_context.module_name == ctx.current_testing_module_name:
278
+ return os.path.normpath(os.path.abspath(folder))
279
+ testing_module = ctx.current_testing_module_name
280
+ other_folders = [
281
+ entry.get("folder_name")
282
+ for entry in render_context.conformance_tests.get_conformance_tests_json(testing_module).values()
283
+ if entry.get("folder_name")
284
+ ]
285
+ writable = folder
286
+ for tests_folder in [folder, *other_folders]:
287
+ source, copy = render_context.conformance_tests.get_source_conformance_test_folder_name(
288
+ render_context.module_name, render_context.required_modules, testing_module, tests_folder
289
+ )
290
+ if not os.path.exists(copy) and os.path.isdir(source):
291
+ file_utils.copy_folder_content(source, copy)
292
+ if tests_folder == folder:
293
+ writable = copy
294
+ return os.path.normpath(os.path.abspath(writable))
295
+
296
+ @staticmethod
297
+ def _other_tests_folders(render_context: RenderContext, tests_folder: str) -> list[str]:
298
+ """The existing folders of the other functionalities' conformance tests the failing tests' module has, where
299
+ a regression fix runs them from: the current module's own folders, or a required module's copies in it."""
300
+ ctx = render_context.conformance_tests_running_context
301
+ testing_module = ctx.current_testing_module_name
302
+ if testing_module == render_context.module_name:
303
+ folders = [entry.get("folder_name") for entry in ctx.get_conformance_tests_json(testing_module).values()]
304
+ else:
305
+ folders = [
306
+ render_context.conformance_tests.get_source_conformance_test_folder_name(
307
+ render_context.module_name, render_context.required_modules, testing_module, entry["folder_name"]
308
+ )[1]
309
+ for entry in render_context.conformance_tests.get_conformance_tests_json(testing_module).values()
310
+ if entry.get("folder_name")
311
+ ]
312
+ normalized = [os.path.normpath(os.path.abspath(f)) for f in folders if f]
313
+ return sorted({f for f in normalized if os.path.isdir(f) and f != tests_folder})
314
+
315
+ @staticmethod
316
+ def _is_regression(render_context: RenderContext) -> bool:
317
+ """Whether the failing tests belong to a functionality implemented before the current one."""
318
+ ctx = render_context.conformance_tests_running_context
319
+ return (
320
+ ctx.current_testing_module_name != render_context.module_name
321
+ or ctx.current_testing_frid != render_context.frid_context.frid
322
+ )
323
+
324
+ @staticmethod
325
+ def _common_params(render_context: RenderContext, agents: ConformanceFixAgents) -> dict:
326
+ """The task params both agents start a session with (besides the issue)."""
327
+ ctx = render_context.conformance_tests_running_context
328
+ frid = render_context.frid_context.frid
329
+ specifications, _ = plain_spec.get_specifications_for_frid(render_context.plain_source_tree, frid)
330
+ tested_text, tested_scenarios = FixConformanceTest._tested_functionality(
331
+ ctx.current_testing_frid_specifications
332
+ )
333
+ is_regression = FixConformanceTest._is_regression(render_context)
334
+ _, memory_files = MemoryManager.fetch_memory_files(render_context.memory_manager.memory_folder)
335
+ params = {
336
+ "definitions": "\n".join(specifications.get(plain_spec.DEFINITIONS, [])),
337
+ "non_functional_requirements": "\n".join(specifications.get(plain_spec.NON_FUNCTIONAL_REQUIREMENTS, [])),
338
+ "test_requirements": "\n".join(specifications.get(plain_spec.TEST_REQUIREMENTS, [])),
339
+ "functional_requirements": FixUnitTests._functional_requirements_section(render_context, specifications),
340
+ "linked_resources": render_context.frid_context.linked_resources,
341
+ "module_name": render_context.module_name,
342
+ "build_folder": os.path.normpath(os.path.abspath(render_context.build_folder)),
343
+ "conformance_tests_folder": agents.conformance_tests_folder,
344
+ **agent_tools.modules_layout_params(render_context),
345
+ "writable_module_tests_folder": agents.writable_module_tests_folder,
346
+ "other_conformance_tests_folders": agents.other_tests_folders,
347
+ "readable_conformance_tests_folders": agents.readable_tests_folders,
348
+ "conformance_tests_script_content": FixUnitTests._read_script(render_context.conformance_tests_script),
349
+ "prepare_environment_script_content": FixUnitTests._read_script(render_context.prepare_environment_script),
350
+ "tested_functionality_id": qualified_frid(ctx.current_testing_module_name, ctx.current_testing_frid),
351
+ "tested_functionality": tested_text,
352
+ "is_regression": is_regression,
353
+ "conformance_scenarios": _stringify_scenarios(tested_scenarios),
354
+ "acceptance_tests": _stringify_scenarios(specifications.get(plain_spec.ACCEPTANCE_TESTS, [])),
355
+ "memory_files": memory_files,
356
+ "conformance_tests_files": _folder_files(agents.conformance_tests_folder),
357
+ }
358
+ if is_regression:
359
+ params["code_diff"] = ImplementationCodeHelpers.get_code_diff(
360
+ render_context.build_folder, render_context.plain_source_tree, frid
361
+ )
362
+ return params
363
+
364
+ @staticmethod
365
+ def _fixer_params(render_context: RenderContext, common_params: dict) -> dict:
366
+ ctx = render_context.conformance_tests_running_context
367
+ params = dict(common_params)
368
+ params["file_tree"] = FixUnitTests._file_tree(render_context.build_folder)
369
+ params["relevant_files"] = FixUnitTests._relevant_files(
370
+ render_context.build_folder, set(render_context.frid_context.changed_files)
371
+ )
372
+ if ctx.conflicting_requirement_count >= 1:
373
+ params["conflict_already_reported"] = True
374
+ other_fixes = FixConformanceTest._other_functionalities_fixes(render_context)
375
+ if other_fixes:
376
+ params["other_functionalities_fixes"] = other_fixes
377
+ return params
378
+
379
+ @staticmethod
380
+ def _other_functionalities_fixes(render_context: RenderContext) -> list[dict]:
381
+ """The implementation changes made earlier in this conformance phase to make another functionality's tests
382
+ pass, oldest first. A fixer that undoes one makes those tests fail again, and the two fixes then alternate,
383
+ so the fixer is shown them and told to declare the conflict instead."""
384
+ ctx = render_context.conformance_tests_running_context
385
+ tested = (ctx.current_testing_module_name, str(ctx.current_testing_frid))
386
+ return [
387
+ {
388
+ "functionality": qualified_frid(*fix["tested"]),
389
+ "hypothesis": fix.get("hypothesis"),
390
+ "approach": fix.get("approach"),
391
+ "code_diff": fix.get("code_diff") or {},
392
+ }
393
+ for fix in ctx.implementation_code_fixes
394
+ if fix.get("tested") and tuple(fix["tested"]) != tested
395
+ ]
396
+
397
+ @staticmethod
398
+ def _tested_functionality(specifications: Optional[dict | str]) -> tuple[str, list]:
399
+ """The text and the conformance scenarios of the functionality whose tests fail. A required module's
400
+ functionality is known only by its text."""
401
+ if isinstance(specifications, str):
402
+ return specifications, []
403
+ specifications = specifications or {}
404
+ functional_requirements = specifications.get(plain_spec.FUNCTIONAL_REQUIREMENTS) or [""]
405
+ return functional_requirements[-1], specifications.get(plain_spec.CONFORMANCE_TESTS) or []
406
+
407
+
408
+ def _stringify_scenarios(scenarios: list) -> str:
409
+ return "\n\n".join(f"#### Scenario `{scenario['id']}`\n\n{scenario['text']}" for scenario in scenarios or [])
410
+
411
+
412
+ def _folder_files(folder: str) -> dict[str, str]:
413
+ """The text files of `folder` by full path, smallest first, within MAX_CONFORMANCE_TESTS_FILES_CHARS."""
414
+ if not os.path.isdir(folder):
415
+ return {}
416
+ contents = file_utils.get_existing_files_content(folder, file_utils.list_all_text_files(folder))
417
+ selected, total = {}, 0
418
+ for name in sorted(contents, key=lambda n: (len(contents[n]), n)):
419
+ if total + len(contents[name]) > MAX_CONFORMANCE_TESTS_FILES_CHARS:
420
+ break
421
+ selected[os.path.join(folder, name)] = contents[name]
422
+ total += len(contents[name])
423
+ return dict(sorted(selected.items()))
@@ -185,6 +185,7 @@ class FixUnitTests(BaseAction):
185
185
  "linked_resources": render_context.frid_context.linked_resources,
186
186
  "build_folder": render_context.build_folder,
187
187
  "module_name": render_context.module_name,
188
+ **agent_tools.modules_layout_params(render_context),
188
189
  "unittests_script_content": FixUnitTests._read_script(render_context.unittests_script),
189
190
  "unittests_issue": unittests_issue,
190
191
  "unittests_log_path": render_context.script_execution_history.latest_unit_test_output_path,