Write all changes to a JSON file in players/{name}/changes_r{round}.json
(self, *, round: int)
| 96 | ) |
| 97 | else: |
| 98 | self.logger.info(f"Branch {self._branch_name} doesn't exist on remote, creating it") |
| 99 | assert_zero_exit_code( |
| 100 | self.environment.execute(f"git checkout -B {self._branch_name}"), |
| 101 | logger=self.logger, |
| 102 | ) |
| 103 | |
| 104 | # SECURITY: the container's clone carries every opponent's branch + round tags |
| 105 | # (origin/human/*, <uuid>-round-N) — an agent can `git show` them to copy solutions. |
| 106 | # After the starting codebase is checked out, strip git so there is no path to opponent |
| 107 | # code during the agent's turn. Local commits still work; push re-adds origin transiently. |
| 108 | if self.push: |
| 109 | self._isolate_git() |
| 110 | |
| 111 | # --- Main methods --- |
| 112 | |
| 113 | def pre_run_hook(self, *, new_round: int) -> None: |
| 114 | """Should be called before we call the run method.""" |
| 115 | if new_round == 1: |
| 116 | self._tag_round(0) |
| 117 | self.game_context.round = new_round |
| 118 | |
| 119 | def _write_changes_to_file(self, *, round: int) -> None: |
| 120 | """Write all changes to a JSON file in players/{name}/changes_r{round}.json""" |
| 121 | if round == 0: |
| 122 | return # No changes for round 0 |
| 123 | |
| 124 | # Generate all diffs and extract modified files |
| 125 | raw_diff = self._get_round_diff(round) |
no test coverage detected