From d87d909f7bff1103d6cd636562245652fef8778f Mon Sep 17 00:00:00 2001 From: Ed_ Date: Wed, 17 Jun 2026 00:27:47 -0400 Subject: [PATCH] refactor(ai_client): rename send_result to send in 5 src/ call sites Renames 10 references across app_controller, conductor_tech_lead, mcp_client (docstring example), multi_agent_conductor, orchestrator_pm. 5 call sites in ai_client.send_result(...) -> ai_client.send(...) 3 print strings mentioning send_result 1 docstring comment (conductor_tech_lead) 1 docstring example (mcp_client) 'src.ai_client.send_result' -> 'src.ai_client.send' Test suite state: still red, but all src/-level call sites are now renamed. Remaining failures are in test files (mocks and patches that still reference send_result). Refs: conductor/tracks/send_result_to_send_20260616/ --- scripts/tier2/apply_t2_1_edits.py | 69 +++++++++++++++++++++++++++++++ src/app_controller.py | 4 +- src/conductor_tech_lead.py | 6 +-- src/mcp_client.py | 2 +- src/multi_agent_conductor.py | 4 +- src/orchestrator_pm.py | 4 +- 6 files changed, 79 insertions(+), 10 deletions(-) create mode 100644 scripts/tier2/apply_t2_1_edits.py diff --git a/scripts/tier2/apply_t2_1_edits.py b/scripts/tier2/apply_t2_1_edits.py new file mode 100644 index 00000000..726e9068 --- /dev/null +++ b/scripts/tier2/apply_t2_1_edits.py @@ -0,0 +1,69 @@ +"""Apply the 10 send_result -> send edits in the 5 other src/ files (Phase 2).""" +from __future__ import annotations + +import sys +from pathlib import Path + +FILES = [ + "src/app_controller.py", + "src/conductor_tech_lead.py", + "src/mcp_client.py", + "src/multi_agent_conductor.py", + "src/orchestrator_pm.py", +] + +EDITS: dict[str, list[tuple[str, str]]] = { + "src/app_controller.py": [ + ("result = ai_client.send_result(context_to_send,", "result = ai_client.send(context_to_send,"), + ("result = ai_client.send_result(\n", "result = ai_client.send(\n"), + ], + "src/conductor_tech_lead.py": [ + (" - Uses ai_client.send_result() for LLM communication", " - Uses ai_client.send() for LLM communication"), + ("result = ai_client.send_result(\n", "result = ai_client.send(\n"), + ("print(f\"[conductor_tech_lead] send_result failed: {_msg}\")", "print(f\"[conductor_tech_lead] send failed: {_msg}\")"), + ], + "src/mcp_client.py": [ + ("'src.ai_client.send_result'", "'src.ai_client.send'"), + ], + "src/multi_agent_conductor.py": [ + ("result = ai_client.send_result(\n", "result = ai_client.send(\n"), + ("print(f\"[MMA] Worker send_result failed for {ticket.id}: {err_msg}\")", "print(f\"[MMA] Worker send failed for {ticket.id}: {err_msg}\")"), + ], + "src/orchestrator_pm.py": [ + ("result = ai_client.send_result(\n", "result = ai_client.send(\n"), + ("print(f\"[orchestrator_pm] send_result failed: {_msg}\")", "print(f\"[orchestrator_pm] send failed: {_msg}\")"), + ], +} + + +def main() -> int: + total = 0 + for rel in FILES: + p = Path(rel) + with p.open("r", encoding="utf-8", newline="") as f: + content = f.read() + has_crlf = "\r\n" in content + nl = "\r\n" if has_crlf else "\n" + edits = [(o.replace("\n", nl), n.replace("\n", nl)) for o, n in EDITS[rel]] + new_content = content + applied = 0 + for old, new in edits: + if old in new_content: + new_content = new_content.replace(old, new, 1) + applied += 1 + else: + print(f"NOT FOUND in {rel}: {old[:80]!r}", file=sys.stderr) + if applied != len(edits): + print(f"Only applied {applied}/{len(edits)} edits in {rel}. ABORTING.", file=sys.stderr) + return 1 + with p.open("w", encoding="utf-8", newline="") as f: + f.write(new_content) + remaining = new_content.count("send_result") + print(f"{rel}: applied {applied}/{len(edits)}, remaining={remaining}") + total += applied + print(f"Total: {total} edits applied") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/src/app_controller.py b/src/app_controller.py index 8d9071cf..7b7c5c13 100644 --- a/src/app_controller.py +++ b/src/app_controller.py @@ -279,7 +279,7 @@ def _api_generate(controller: 'AppController', req: GenerateRequest) -> dict[str has_ai_response = any(e.get("role") == "AI" for e in controller.disc_entries) context_to_send = stable_md if not has_ai_response else "" - result = ai_client.send_result(context_to_send, user_msg, base_dir, controller.last_file_items, disc_text, rag_engine=None) + result = ai_client.send(context_to_send, user_msg, base_dir, controller.last_file_items, disc_text, rag_engine=None) if not result.ok: err = result.errors[0] raise HTTPException(status_code=502, detail=err.ui_message()) @@ -3671,7 +3671,7 @@ class AppController: self._update_gcli_adapter(self.ui_gemini_cli_path) # FR2 / Bug #1: per conductor/code_styleguides/error_handling.md section 3.1 (AND over OR), # we check result.ok instead of catching a ProviderError exception. - result = ai_client.send_result( + result = ai_client.send( event.stable_md, user_msg, event.base_dir, diff --git a/src/conductor_tech_lead.py b/src/conductor_tech_lead.py index f2dc2872..ef600691 100644 --- a/src/conductor_tech_lead.py +++ b/src/conductor_tech_lead.py @@ -5,7 +5,7 @@ This module implements the Tier 2 (Tech Lead) function for generating implementa It uses the LLM to analyze the track requirements and produce structured ticket definitions. Architecture: - - Uses ai_client.send_result() for LLM communication + - Uses ai_client.send() for LLM communication - Uses mma_prompts.PROMPTS["tier2_sprint_planning"] for system prompt - Returns JSON array of ticket definitions @@ -65,14 +65,14 @@ def generate_tickets(track_brief: str, module_skeletons: str) -> list[dict[str, for _ in range(3): try: # 3. Call Tier 2 Model - result = ai_client.send_result( + result = ai_client.send( md_content = "", user_message = user_message ) if not result.ok: _err = result.errors[0] if result.errors else None _msg = _err.ui_message() if _err else "unknown error" - print(f"[conductor_tech_lead] send_result failed: {_msg}") + print(f"[conductor_tech_lead] send failed: {_msg}") return None response = result.data # 4. Parse JSON Output diff --git a/src/mcp_client.py b/src/mcp_client.py index 0e82571a..fd4374b7 100644 --- a/src/mcp_client.py +++ b/src/mcp_client.py @@ -2370,7 +2370,7 @@ MCP_TOOL_SPECS: list[dict[str, Any]] = [ "properties": { "target": { "type": "string", - "description": "Fully qualified name of the target (e.g., 'src.ai_client.send_result') or class.method.", + "description": "Fully qualified name of the target (e.g., 'src.ai_client.send') or class.method.", }, "max_depth": { "type": "integer", diff --git a/src/multi_agent_conductor.py b/src/multi_agent_conductor.py index c4e73598..5c8b0ee1 100644 --- a/src/multi_agent_conductor.py +++ b/src/multi_agent_conductor.py @@ -588,7 +588,7 @@ def run_worker_lifecycle(ticket: Ticket, context: WorkerContext, context_files: ai_client.set_current_tier(f"Tier 3 (Worker): {ticket.id}") try: comms_baseline = len(ai_client.get_comms_log()) - result = ai_client.send_result( + result = ai_client.send( md_content=md_content, user_message=user_message, base_dir=".", @@ -600,7 +600,7 @@ def run_worker_lifecycle(ticket: Ticket, context: WorkerContext, context_files: if not result.ok: err = result.errors[0] if result.errors else None err_msg = err.ui_message() if err else "unknown error" - print(f"[MMA] Worker send_result failed for {ticket.id}: {err_msg}") + print(f"[MMA] Worker send failed for {ticket.id}: {err_msg}") if event_queue: _queue_put(event_queue, "response", {"text": f"\n\n[ERROR] {err_msg}", "stream_id": f"Tier 3 (Worker): {ticket.id}", "status": "error", "role": "Vendor API"}) _queue_put(event_queue, "ticket_completed", {"ticket_id": ticket.id, "timestamp": time.time()}) diff --git a/src/orchestrator_pm.py b/src/orchestrator_pm.py index 6bec3e1b..2c788896 100644 --- a/src/orchestrator_pm.py +++ b/src/orchestrator_pm.py @@ -83,7 +83,7 @@ def generate_tracks(user_request: str, project_config: dict[str, Any], file_item try: # 3. Call Tier 1 Model (Strategic - Pro) # Note: We use gemini-1.5-pro or similar high-reasoning model for Tier 1 - result = ai_client.send_result( + result = ai_client.send( md_content="", # We pass everything in user_message for clarity user_message=user_message, enable_tools=False, @@ -91,7 +91,7 @@ def generate_tracks(user_request: str, project_config: dict[str, Any], file_item if not result.ok: _err = result.errors[0] if result.errors else None _msg = _err.ui_message() if _err else "unknown error" - print(f"[orchestrator_pm] send_result failed: {_msg}") + print(f"[orchestrator_pm] send failed: {_msg}") return [] response = result.data # 4. Parse JSON Output