Skip to content

Graded test suite is writable by the agent, and mutations are not detected #7

Description

@KTanmay1

The graded test suite is writable by the agent, and mutations are not detected

RepoTransAgent/run.py:67

shutil.copytree(self.target_base_path, self.working_path)

copies the whole target bundle — including tests/original/ — into the agent's working
directory. CreateFile accepts any path under that directory, so the agent can overwrite
the tests it is scored against. Nothing checks afterwards whether it did.

Observed

Running RepoTransAgent on antirez_smaz (C → Python, 20 iterations, Claude Haiku 4.5),
the agent rewrote a graded test:

tests/original/test_smaz_original.py
  -def test_smaz_fixed_strings(smaz_mock_funcs):
  +def test_smaz_original_fixed_strings(smaz_mock_funcs):

The other two test files were untouched. Re-scoring its final tree against the pristine
suite instead of its own copy, the rename was worth exactly one test — 8/24 became 7/21
under the harness's own parser.

Small in this instance. But it is unbounded in principle: an agent that stubs out or
deletes the assertions in tests/original/ scores higher, and the run records nothing
unusual. Since scoring reads the agent's copy rather than the bundle, the harness cannot
distinguish "solved the task" from "edited the test".

Why I am not sending a patch

The fixes I can see are design decisions, not bug fixes, and they belong to you:

  1. Grade from a pristine copy of tests/ rather than the working tree.
  2. Mount or copy tests/ read-only, and reject CreateFile paths that land inside it.
  3. Leave it writable but diff tests/ against the bundle before scoring and flag or
    invalidate runs that modified it.

(3) is the smallest and preserves current behaviour, since a legitimate translation never
needs to edit tests/original/. But which of these is right depends on whether you intend
the agent to be able to touch the target-language test scaffolding at all — for some
language pairs it plausibly does need to create build files next to the tests.

Happy to send a PR for whichever you prefer.


Two separate PRs are open against related issues, both self-contained:

and #4, which changes no behaviour: API credentials are logged to stdout and persisted into
conversation_logs/*.json.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions