Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,20 @@ reader chooses, does or concludes.
- A prerequisite Review already checks is not repeated.
- `docs/standard.md` headings are never renamed: the import skills cite them.

### Test design

- Test observable behavior, contracts and meaningful failure modes—not incidental
wording, internal structure or current catalogue contents.
- Before adding a test, inspect nearby coverage. Extend an existing case or use
subtests when the fixture and behavior are shared.
- Add a separate test when it protects a distinct regression or needs a different
setup. A past bug alone does not require a separate test.
- Assert exact text only when that text is a contract.
- Before removing a test as redundant, identify the surviving assertions that
protect its behavior. Shared line coverage alone is insufficient.
- Consolidation must preserve edge cases and fixture isolation. Fewer test methods
is not itself the goal.

### Attribution

**No machine attribution in commit messages or pull request descriptions** — no
Expand Down
26 changes: 3 additions & 23 deletions app/tests/harnesses/test_atif.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ def test_the_supported_versions_are_pinned(self):

class Detection(unittest.TestCase):


def test_it_does_not_claim_an_unrelated_directory(self):
self.assertFalse(atif.detect(tempfile.mkdtemp()))
self.assertFalse(atif.detect("/nonexistent/tree"))


def test_well_formed_json_that_is_not_atif_is_passed_over(self):
src = tempfile.mkdtemp()
write_doc(src, "trace.json", {"harbor-trace-v1": True, "roots": []})
Expand Down Expand Up @@ -97,7 +91,6 @@ def convert(self, root, **kw):
self.assertEqual(len(job_dirs), 1)
return job_dirs[0], parse.parse_job(job_dirs[0])


def test_trial_names_follow_the_tree_and_a_bare_trajectory_takes_its_directory(self):
src = tempfile.mkdtemp()
write_doc(src, "a.json", minimal())
Expand Down Expand Up @@ -177,7 +170,7 @@ def test_truncated_json_is_refused_by_name_and_redacted(self):
# nothing was rewritten while refusing
self.assertTrue(os.path.isfile(good) and os.path.isfile(bad))

def test_a_document_without_steps_is_refused_as_partial(self):
def test_a_document_without_a_list_of_steps_is_refused(self):
doc = minimal()
doc.pop("steps")
doc["extra"] = {"token": FAKE_KEY}
Expand All @@ -186,8 +179,7 @@ def test_a_document_without_steps_is_refused_as_partial(self):
self.assertIn("partial.json", message)
self.assertIn("no steps", message)
self.assertNotIn(FAKE_KEY, message)

def test_steps_of_the_wrong_shape_are_refused(self):
os.remove(os.path.join(self.src, "partial.json"))
write_doc(self.src, "odd.json", minimal(steps={"not": "a list"}))
self.assertIn("steps is not a list", self.refused())

Expand All @@ -209,11 +201,9 @@ def test_a_directory_with_nothing_of_ours_is_refused(self):
self.assertIn("no ATIF trajectories", message)
self.assertIn("ATIF-v1.0", message)

def test_the_file_is_named_relative_to_the_tree_given(self):
def test_the_file_is_named_relative_to_the_tree_or_by_its_own_name(self):
write_doc(self.src, "deep/er/bad.json", '{"schema_version": "ATIF-v1.7"')
self.assertTrue(self.refused().startswith("deep/er/bad.json: "))

def test_a_single_bad_file_is_refused_by_its_own_name(self):
path = write_doc(self.src, "lone.json", '{"schema_version": "ATIF-v1.7", "steps": ')
self.assertTrue(self.refused(path).startswith("lone.json: not JSON"))

Expand All @@ -223,15 +213,5 @@ def test_a_good_tree_passes_check_without_writing(self):
self.assertEqual(os.listdir(self.out), [])


class Trees(unittest.TestCase):
"""What one job is under a root the picker opened: the root, as the CLI
reads it — a nested directory of trajectories is one job of several
trials, not a job per child."""


def test_a_directory_with_nothing_of_ours_is_no_tree(self):
self.assertEqual(atif.trees(tempfile.mkdtemp()), [])


if __name__ == "__main__":
unittest.main()
19 changes: 0 additions & 19 deletions app/tests/harnesses/test_otel_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@

class Detect(unittest.TestCase):


def test_unrelated_directories_are_not_claimed(self):
self.assertFalse(importer.detect(tempfile.mkdtemp()))
self.assertFalse(importer.detect("/nonexistent/otel/export"))
# a Harbor job: result.json / trajectory / trace.json — no resourceSpans
self.assertFalse(importer.detect(str(APP / "tests" / "fixtures" / "harbor-jobs")))

def test_a_directory_of_only_refused_files_is_not_claimed(self):
root = tempfile.mkdtemp()
with open(os.path.join(root, "broken.json"), "w") as fh:
Expand All @@ -40,7 +33,6 @@ def setUp(self):
self.out = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.out, True)


def test_nothing_readable_is_an_error_naming_the_refusals(self):
src = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, src, True)
Expand Down Expand Up @@ -71,16 +63,5 @@ def test_a_refused_file_deeper_down_is_named_by_its_path_under_the_root_once(sel
self.assertEqual(reason.count("jaeger-trace.json"), 1)


class Trees(unittest.TestCase):
"""What one job is under a root the picker opened: an export
directory is one job; a parent of several export directories is one job
per directory, each one producer's export, not one pooled job."""


def test_a_directory_with_no_export_is_no_tree(self):
self.assertEqual(importer.trees(tempfile.mkdtemp()), [])
self.assertEqual(importer.trees("/nonexistent/export"), [])


if __name__ == "__main__":
unittest.main()
67 changes: 9 additions & 58 deletions app/tests/harnesses/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,24 @@ def test_every_importer_satisfies_the_contract(self):
self.assertTrue((module.__doc__ or "").strip(),
"an importer documents what it reads")

def test_an_unknown_name_is_none_not_an_error(self):
# The CLI turns this into a usage message listing what exists; raising
# here would make a typo look like a crash.
self.assertIsNone(harnesses.get("no-such-harness"))
self.assertIsNone(harnesses.get(""))

def test_nothing_claims_an_unrelated_directory(self):
# detect() runs against whatever a caller points at, including a plain
# directory. A harness that answers yes to everything would capture
# every future import.
empty = tempfile.mkdtemp()
self.assertIsNone(harnesses.detect(empty))

def test_detect_survives_a_path_that_does_not_exist(self):
self.assertIsNone(harnesses.detect("/nonexistent/run/tree"))

def test_the_registry_names_no_harness_itself(self):
# The removal property: deleting a module must be the whole deletion,
# so this package cannot mention one by name.
source = (APP / "nullius" / "importers" / "__init__.py").read_text()
for name in harnesses.available():
with self.subTest(harness=name):
self.assertNotIn(name, source.split('"""')[-1],
f"{name} is named in the registry's code")

def test_the_cli_names_no_harness_either(self):
source = (APP / "nullius" / "importers" / "cli.py").read_text()
body = source.split('"""')[-1]
for name in harnesses.available():
with self.subTest(harness=name):
self.assertNotIn(name, body,
f"{name} is named in the CLI's code")
# so neither this package nor its CLI can mention one by name.
for file, what in (("__init__.py", "the registry's code"),
("cli.py", "the CLI's code")):
source = (APP / "nullius" / "importers" / file).read_text()
body = source.split('"""')[-1]
for name in harnesses.available():
with self.subTest(file=file, harness=name):
self.assertNotIn(name, body, f"{name} is named in {what}")


class FirstMatchIsStable(unittest.TestCase):
Expand All @@ -80,7 +66,6 @@ class FirstMatchIsStable(unittest.TestCase):
"""
EXAMPLES = APP / "tests" / "fixtures"


def test_no_importer_claims_a_harbor_job(self):
for job in ("liveboard-oracle-x4",):
path = str(self.EXAMPLES / "harbor-jobs" / job)
Expand Down Expand Up @@ -160,15 +145,6 @@ def convert(src, out, job_name="", command=""):
self.assertEqual(len(outs), 1)
self.assertFalse(os.path.exists(outs[0]), "the scratch directory is removed")

def test_a_good_tree_is_no_problem(self):
self.registry(stub("x", check=lambda path: None))
self.assertIsNone(harnesses.problem("/t"))

def test_labels_name_the_importers_for_a_person(self):
a, b = stub("a"), stub("b")
b.LABEL = "Bee"
self.registry(a, b)
self.assertEqual(harnesses.labels(), "a, Bee")

class Disjoint(unittest.TestCase):
"""No two importers claim one directory.
Expand Down Expand Up @@ -210,14 +186,6 @@ def test_at_most_one_importer_claims_each_shape(self):
self.assertLessEqual(len(claimants), 1, f"{shape} is claimed by {claimants}")


def test_the_otel_importer_claims_none_of_the_other_shapes(self):
module = harnesses.get("otel")
self.assertIsNotNone(module)
for shape, path in self.candidates().items():
with self.subTest(shape=shape):
self.assertFalse(module.detect(path))


class CLI(unittest.TestCase):
"""`--list` and refusal, against the registry there is and an empty one."""

Expand All @@ -241,16 +209,6 @@ def test_list_names_every_registered_importer(self):
self.assertIn(name, out)
self.assertNotIn("no importers registered", out)

def test_list_with_nothing_registered_says_so_and_exits_zero(self):
# With no importer registered, printing nothing would read exactly
# like a CLI that imported and did no work.
self.empty()
code, out, _ = self.run_cli("--list")
self.assertEqual(code, 0)
self.assertEqual(out.strip(), "no importers registered")
code, out, _ = self.run_cli("--list", "--json")
self.assertEqual((code, json.loads(out)), (0, {}))

def test_an_unrecognised_tree_is_refused_with_nothing_registered(self):
self.empty()
with tempfile.TemporaryDirectory() as run:
Expand All @@ -275,22 +233,15 @@ class Trees(unittest.TestCase):
The default: the root, as one job.
"""

def test_a_claimed_root_is_one_tree_by_default(self):
def test_a_claimed_root_is_one_tree_by_default_and_an_unclaimed_one_none(self):
self.assertEqual(harnesses.trees(stub("x"), "/exp"), ["/exp"])

def test_an_unclaimed_root_is_no_tree_by_default(self):
self.assertEqual(harnesses.trees(stub("x", detect=False), "/exp"), [])

def test_an_importer_with_its_own_answer_is_asked_and_the_default_is_not(self):
module = stub("x", detect=False) # detect says no; trees decides
module.trees = lambda root: [os.path.join(root, "a"), os.path.join(root, "b")]
self.assertEqual(harnesses.trees(module, "/exp"), ["/exp/a", "/exp/b"])

def test_trees_is_not_part_of_the_contract(self):
# A module without it still registers: the hook is optional, and
# the default is the CLI's reading rather than a missing name.
self.assertNotIn("trees", harnesses._CONTRACT)

def test_every_registered_importer_answers_and_an_empty_directory_is_nothing(self):
# Each importer there is says what one job is under a root — the
# answers differ, which is why
Expand Down
8 changes: 0 additions & 8 deletions app/tests/test_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ def test_same_work_under_other_names_reads_the_same(self):
self.assertEqual(short.exploration_per_edit, 3.0)
self.assertEqual((short.n_search, short.n_read, short.n_edit), (1, 2, 1))

def test_a_retry_is_the_same_name_and_target_within_one_agent(self):
# The one place a name is a key: repeating a call that already failed.
# That compares an agent with itself, so its own vocabulary is right.
failed = "success=False data={} error='boom'"
tr = _traj([_tool_step(1, "Run the tests", {"command": "pytest"}, observation=failed),
_tool_step(2, "Run the tests", {"command": "pytest"}, observation=failed)])
self.assertEqual(behavior.analyze(tr).n_repeated_failed_calls, 1)


if __name__ == "__main__":
unittest.main()
6 changes: 0 additions & 6 deletions app/tests/test_benchmark_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def test_one_entry_list_whose_fits_are_the_builders(self):
self.assertEqual(page["osworld1:openai-cua"]["protocol"], "Its own script")



RECIPE = {"harness": "standard", "name": "os", "benchmark": "osworld1", "datasets": ["test_small"], "provider": "openrouter",
"model": "computer-use-preview", "model_choice": "paper", "where": "local", "backend": "local"}

Expand Down Expand Up @@ -180,16 +179,11 @@ def test_like_the_paper_names_the_agent_a_model_is_not_published_with(self):
self.assertEqual(said, [{"step": recipe.STEP["model"],
"message": "OpenAI CUA is published with computer-use-preview: choose one of them, or Any of your choice for another."}])

def test_two_of_its_agents_without_a_model_say_so_once(self):
said = [e["message"] for e in self.compiled(others=["osworld1:m3", "osworld1:claude"], model="")["errors"]]
self.assertEqual(said.count("Choose a model."), 1)

def test_another_benchmarks_agent_is_refused_with_its_reason(self):
said = [e["message"] for e in self.compiled(others=["osworld2:m3"])["errors"]]
self.assertEqual(said, ["MiniMax M3 cannot run OSWorld1: MiniMax M3 belongs to OSWorld2."])



class Records(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.mkdtemp(prefix="nullius-own-job-")
Expand Down
19 changes: 0 additions & 19 deletions app/tests/test_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ def test_usable_is_unknown_when_nothing_was_produced(self):
patch_successfully_applied=False))
self.assertIs(v.produced, False)
self.assertIsNone(v.usable, "no patch means the question has no answer")

def test_patch_is_none_counts_as_not_produced(self):
self.assertIs(swe(report(patch_is_None=True)).produced, False)

def test_tolerates_a_missing_or_malformed_report(self):
Expand Down Expand Up @@ -140,17 +138,6 @@ def test_counts_fall_back_to_the_test_list_when_summary_is_absent(self):
v = tb(ctrf(passed=("a",), failed=("b",), summary=False), 0.0)
self.assertEqual((v.gained_pass, v.gained_fail), (1, 1))

def test_the_reward_marker_scores_without_detail(self):
# Non-pytest tasks (qemu-alpine-ssh, mailman) leave only reward.txt;
# the loader hands read() a bare {} for them.
v = tb({}, 1.0)
self.assertIs(v.succeeded, True)

def test_there_is_no_patch_vocabulary(self):
v = tb(ctrf(failed=("a",)), 0.0)
self.assertIsNone(v.produced)
self.assertIsNone(v.usable)


class Loading(unittest.TestCase):
"""Which file the report is: dataset-owned, so it dispatches like read()."""
Expand Down Expand Up @@ -232,12 +219,6 @@ class VocabularyDispatch(unittest.TestCase):
vocabulary names it, so a Terminal-Bench trial never says "Fail → Pass"
and never answers "Patch applied: No" about patches it cannot have."""

def test_swe_bench_speaks_its_own_names(self):
v = verifier.vocabulary_for("swebench-verified")
self.assertEqual((v.gained, v.held), ("Fail → Pass", "Pass → Pass"))
self.assertEqual((v.gained_abbr, v.held_abbr), ("F→P", "P→P"))
self.assertTrue(v.has_patch)

def test_terminal_bench_has_tests_and_nothing_else(self):
v = verifier.vocabulary_for("terminal-bench")
self.assertEqual(v.gained, "Tests")
Expand Down
Loading