Validate that agent's Kojiro codebase compiles successfully.
(self, agent: Player)
| 42 | self.logger.debug(f"Initialized ChessArena with time control: {time_control}") |
| 43 | |
| 44 | def validate_code(self, agent: Player) -> tuple[bool, str | None]: |
| 45 | """ |
| 46 | Validate that agent's Kojiro codebase compiles successfully. |
| 47 | """ |
| 48 | # Check that src/ directory exists |
| 49 | ls_result = agent.environment.execute("ls") |
| 50 | if "src" not in ls_result["output"]: |
| 51 | return False, "There should be a `src/` directory in the workspace" |
| 52 | |
| 53 | # Compile the engine |
| 54 | self.logger.debug(f"Compiling Kojiro for agent {agent.name}") |
| 55 | compile_result = agent.environment.execute( |
| 56 | "cd src && make native", |
| 57 | timeout=120, # 2 minute timeout for compilation |
| 58 | ) |
| 59 | |
| 60 | if compile_result["returncode"] != 0: |
| 61 | error_output = compile_result.get("output", "Unknown compilation error") |
| 62 | # Truncate very long error messages |
| 63 | if len(error_output) > 1000: |
| 64 | error_output = error_output[:1000] + "\n... (truncated)" |
| 65 | return False, f"Compilation failed:\n{error_output}" |
| 66 | |
| 67 | # Verify executable was created |
| 68 | kojiro_check = agent.environment.execute("ls src/kojiro") |
| 69 | if kojiro_check["returncode"] != 0 or "kojiro" not in kojiro_check["output"]: |
| 70 | return False, "Compilation succeeded but executable 'kojiro' not found in src/" |
| 71 | |
| 72 | self.logger.info(f"Agent {agent.name} passed validation: Kojiro compiles successfully") |
| 73 | return True, None |
| 74 | |
| 75 | def _compile_engines_in_game_container(self, agents: list[Player]) -> dict[str, str]: |
| 76 | """ |