diff --git a/src/lai_automation/agent.py b/src/lai_automation/agent.py index 84bde6e..833b553 100644 --- a/src/lai_automation/agent.py +++ b/src/lai_automation/agent.py @@ -91,4 +91,12 @@ class AiderAgent: for filename in files: if (task_file.parent.parent / filename).is_file(): command.extend(["--file", filename]) + if files: + command.extend([ + "--architect", + "--editor-model", + self.settings.agent_model, + "--editor-edit-format", + "udiff", + ]) return command diff --git a/src/lai_automation/prompt.py b/src/lai_automation/prompt.py index fef7f8b..6019d02 100644 --- a/src/lai_automation/prompt.py +++ b/src/lai_automation/prompt.py @@ -118,6 +118,10 @@ When expected behavior names tables from multiple databases or connections, firs routing and existing staged-query workflows. Do not put an impossible cross-connection join only in ERP semantics. Implement deterministic orchestration that resolves identifiers in one source and passes only the required identifier into the next source, preserving tenant isolation. +For this cross-database report, editing only config/*_semantics.php or tests is an invalid repair. +You MUST implement production behavior in ChatController or TenantDatabaseService and cover that +exact application method in ChatControllerSourceResolutionTest. Before editing, describe the data +flow, connection used at each stage, and where the final result is assembled. """ placeholder_guidance = '' if '__LAI_' in response: diff --git a/tests/test_agent.py b/tests/test_agent.py index c613cc7..d5ec2bf 100644 --- a/tests/test_agent.py +++ b/tests/test_agent.py @@ -27,8 +27,19 @@ def test_aider_command_adds_existing_routed_files(tmp_path) -> None: ("app/Http/Controllers/ChatController.php", "missing.php"), ) - assert command[-2:] == ["--file", "app/Http/Controllers/ChatController.php"] + assert ["--file", "app/Http/Controllers/ChatController.php"] == command[ + command.index("--file"):command.index("--file") + 2 + ] assert "missing.php" not in command + assert "--architect" in command + assert command[command.index("--editor-model") + 1] == "mistral/test" + assert command[command.index("--editor-edit-format") + 1] == "udiff" + + +def test_unrouted_aider_command_stays_in_direct_edit_mode() -> None: + command = AiderAgent(settings()).command(Path("/repo/.git/task.txt")) + + assert "--architect" not in command def test_aider_environment_does_not_include_database_credentials(tmp_path, monkeypatch) -> None: diff --git a/tests/test_prompt.py b/tests/test_prompt.py index 41bdfda..4839e27 100644 --- a/tests/test_prompt.py +++ b/tests/test_prompt.py @@ -200,6 +200,9 @@ def test_cross_database_report_guides_staged_source_routing() -> None: assert "staged-query workflows" in task assert "Do not put an impossible cross-connection join" in task assert "preserving tenant isolation" in task + assert "editing only config/*_semantics.php or tests is an invalid repair" in task + assert "describe the data" in task + assert "flow, connection used at each stage" in task assert repair_files(report) == ( "app/Http/Controllers/ChatController.php", "app/Services/TenantDatabaseService.php",