From dd08332996974d426912dd8ffd2ab1331db982ff Mon Sep 17 00:00:00 2001 From: Dusan Omercevic Date: Fri, 27 Feb 2026 08:59:36 +0100 Subject: [PATCH] Fixed a nasty bug with memory files leaking into context --- file_utils.py | 5 ++++ .../analyze_specification_ambiguity.py | 7 ++++-- render_machine/implementation_code_helpers.py | 25 ++++++++++++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/file_utils.py b/file_utils.py index d392620..05ed630 100644 --- a/file_utils.py +++ b/file_utils.py @@ -47,6 +47,11 @@ SYSTEM_FOLDERS = [".git", CODEPLAIN_METADATA_FOLDER, CODEPLAIN_MEMORY_SUBFOLDER] +def is_system_folder_path(file_path: str) -> bool: + parts = Path(file_path).parts + return bool(parts) and parts[0] in SYSTEM_FOLDERS + + def get_file_type(file_name): # Extract the file extension diff --git a/render_machine/actions/analyze_specification_ambiguity.py b/render_machine/actions/analyze_specification_ambiguity.py index 052a038..25a3d0c 100644 --- a/render_machine/actions/analyze_specification_ambiguity.py +++ b/render_machine/actions/analyze_specification_ambiguity.py @@ -7,6 +7,7 @@ from plain2code_exceptions import InternalClientError from plain2code_utils import AMBIGUITY_CAUSES from render_machine.actions.base_action import BaseAction +from render_machine.implementation_code_helpers import ImplementationCodeHelpers from render_machine.render_context import RenderContext @@ -14,19 +15,21 @@ class AnalyzeSpecificationAmbiguity(BaseAction): SUCCESSFUL_OUTCOME = "conformance_tests_postanalyzed" def execute(self, render_context: RenderContext, _previous_action_payload: Any | None): - fixed_implementation_code_diff = git_utils.get_fixed_implementation_code_diff( + + fixed_implementation_code_diff = ImplementationCodeHelpers.get_fixed_implementation_code_diff( render_context.build_folder, render_context.frid_context.frid ) if fixed_implementation_code_diff is None: raise InternalClientError( "Fixes to the implementation code found during conformance testing are not committed to git." ) + previous_frid = plain_spec.get_previous_frid(render_context.plain_source_tree, render_context.frid_context.frid) git_utils.checkout_commit_with_frid(render_context.build_folder, previous_frid) existing_files = file_utils.list_all_text_files(render_context.build_folder) existing_files_content = file_utils.get_existing_files_content(render_context.build_folder, existing_files) git_utils.checkout_previous_branch(render_context.build_folder) - implementation_code_diff = git_utils.get_implementation_code_diff( + implementation_code_diff = ImplementationCodeHelpers.get_implementation_code_diff( render_context.build_folder, render_context.frid_context.frid, previous_frid ) rendering_analysis = render_context.codeplain_api.analyze_rendering( diff --git a/render_machine/implementation_code_helpers.py b/render_machine/implementation_code_helpers.py index 664c39e..219f29a 100644 --- a/render_machine/implementation_code_helpers.py +++ b/render_machine/implementation_code_helpers.py @@ -17,10 +17,33 @@ def fetch_existing_files(build_folder: str): existing_files_content = file_utils.get_existing_files_content(build_folder, existing_files) return existing_files, existing_files_content + @staticmethod + def remove_system_folder_paths_from_code_diff(code_diff: dict): + for file_name in list(code_diff.keys()): + if file_utils.is_system_folder_path(file_name): + del code_diff[file_name] + + return code_diff + @staticmethod def get_code_diff(build_folder: str, plain_source_tree: dict, frid: str): previous_frid_code_diff = git_utils.diff( build_folder, plain_spec.get_previous_frid(plain_source_tree, frid), ) - return previous_frid_code_diff + + return ImplementationCodeHelpers.remove_system_folder_paths_from_code_diff(previous_frid_code_diff) + + @staticmethod + def get_fixed_implementation_code_diff(build_folder: str, frid: str): + fixed_implementation_code_diff = git_utils.get_fixed_implementation_code_diff(build_folder, frid) + if fixed_implementation_code_diff is None: + return None + + return ImplementationCodeHelpers.remove_system_folder_paths_from_code_diff(fixed_implementation_code_diff) + + @staticmethod + def get_implementation_code_diff(build_folder: str, frid: str, previous_frid: str): + implementation_code_diff = git_utils.get_implementation_code_diff(build_folder, frid, previous_frid) + + return ImplementationCodeHelpers.remove_system_folder_paths_from_code_diff(implementation_code_diff)