diff --git a/.github/scripts/aggregate_unified.py b/.github/scripts/aggregate_unified.py index c3325ba2dfa..0c263b99d68 100644 --- a/.github/scripts/aggregate_unified.py +++ b/.github/scripts/aggregate_unified.py @@ -373,15 +373,21 @@ def main(argv: list[str] | None = None) -> int: write_outputs( combined, args.rollouts, out_dir, os.environ.get("GITHUB_STEP_SUMMARY") ) + if not leaves: + print("::error::No usable eval leaf summaries were found; failing the run.") + return 1 + # Incompleteness is surfaced per model in write_outputs (a ::warning:: plus the + # ⚠️ markers in the table) and never fails the job: a partial scorecard the + # reader can inspect beats a voided run with no output. A single errored shard + # no longer nukes the whole cross-model comparison. models = combined["models"] if expected_models and all( models[model]["incomplete"] for model in expected_models ): print( - "::error::Every expected model is incomplete; " - "no complete unified result is available." + "::warning::All expected models were flagged incomplete; the scorecard " + "below is ranked on partial data — inspect the per-model notes above." ) - return 1 return 0 diff --git a/.github/scripts/enumerate_tasks.py b/.github/scripts/enumerate_tasks.py new file mode 100644 index 00000000000..9e56d895f47 --- /dev/null +++ b/.github/scripts/enumerate_tasks.py @@ -0,0 +1,89 @@ +"""Enumerate a category's task names for the flat shard matrix. + +Reuses the exact task-name resolution the run step uses: + - local (--path) datasets: subdir basenames with a task.toml (sorted, stable), + - synthetic datasets (e.g. "tau3-subset"): a committed task list, since the + name is not a registry package and would fail a registry lookup, + - registry datasets: PackageDatasetClient manifest task_ids -> get_name(). + +Registry lookups need harbor installed and network; the local path is pure +stdlib. Run as a script, main() emits newline-joined names. +""" +from __future__ import annotations + +import os +import sys + +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import shard_matrix # noqa: E402 + + +def local_task_names(local_dir: str) -> list[str]: + names = sorted( + entry.name + for entry in os.scandir(local_dir) + if entry.is_dir() and os.path.isfile(os.path.join(entry.path, "task.toml")) + ) + if not names: + raise SystemExit(f"No local Harbor tasks (dirs with task.toml) under {local_dir}") + return names + + +def registry_task_names(dataset_ref: str) -> list[str]: + import asyncio + + from harbor.registry.client.package import PackageDatasetClient + + md = asyncio.run( + PackageDatasetClient().get_dataset_metadata(f"{dataset_ref}@latest") + ) + names = [x for x in (shard_matrix.task_display_name(t) for t in md.task_ids) if x] + if not names: + raise SystemExit( + f"Resolved 0 usable task names from {dataset_ref}@latest " + f"({len(md.task_ids)} task ids); unexpected task-id shape." + ) + return names + + +def tau3_subset_task_names() -> list[str]: + # "tau3-subset" is a synthetic curated view, not a registry package, so it + # cannot be resolved via the registry client. Pull its committed 30-task + # list from the same module the harbor leaf uses (single source of truth). + from deepagents_evals.tau3_subset import INCLUDE_TASKS + + names = INCLUDE_TASKS.split() + if not names: + raise SystemExit( + "tau3-subset resolved to 0 tasks; " + "deepagents_evals.tau3_subset.INCLUDE_TASKS is empty." + ) + return names + + +# Synthetic datasets resolve to a committed task list instead of a registry +# lookup, because their names are not `org/name` registry packages. +SYNTHETIC_DATASETS = {"tau3-subset": tau3_subset_task_names} + + +def main() -> int: + dataset_path = os.environ.get("ENUM_DATASET_PATH", "").strip() + dataset = os.environ.get("ENUM_DATASET", "").strip() + if dataset_path: + names = local_task_names(dataset_path) + elif dataset in SYNTHETIC_DATASETS: + names = SYNTHETIC_DATASETS[dataset]() + else: + names = registry_task_names(dataset) + out = os.environ.get("ENUM_OUTPUT") + text = "\n".join(names) + "\n" + if out: + with open(out, "w") as f: + f.write(text) + else: + sys.stdout.write(text) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/.github/scripts/lite_tasks.py b/.github/scripts/lite_tasks.py index e6ce3debb0f..3145c707031 100644 --- a/.github/scripts/lite_tasks.py +++ b/.github/scripts/lite_tasks.py @@ -20,11 +20,16 @@ # Excludes the bix* bioinformatics tasks: their ~6 GB `chenzizhao/bixbench` # image exhausts the Docker-sandbox runner disk (and fails the LangSmith # builder). Re-add once lite runs on a sandbox that builds big images. + # `gpqadiamond-cope-rearrangement-products` and `swesmith-fix-oauth1-header-params` + # replaced `replicationbench-find-galactic-vz-peaks` and `usaco-assign-cows-to-barns`: + # both originals could run ~30-65 min (replicationbench's naive big-data script + # hits the 1h per-command timeout), defeating lite's low-cost goal. The swaps are + # <5 min and still frontier (partial-pass), re-picked on gpt-5.6-terra timing+signal. "autonomous": [ - "harbor-index/replicationbench-find-galactic-vz-peaks", + "harbor-index/gpqadiamond-cope-rearrangement-products", "harbor-index/swebenchverified-fix-span-selector-axes-limits", "harbor-index/omnimath-find-perfect-square-functions", - "harbor-index/usaco-assign-cows-to-barns", + "harbor-index/swesmith-fix-oauth1-header-params", "harbor-index/featurebench-add-feature-mlflow-bedrock-autolog", "harbor-index/build-word2vec-pipeline", "harbor-index/tb-dna-insert", diff --git a/.github/scripts/shard_matrix.py b/.github/scripts/shard_matrix.py index 295a093ae2a..f65d4071ee9 100644 --- a/.github/scripts/shard_matrix.py +++ b/.github/scripts/shard_matrix.py @@ -33,9 +33,11 @@ # https://docs.github.com/actions/using-jobs/using-a-matrix-for-your-jobs GITHUB_MATRIX_MAX = 256 -# Upper bound on the shard axis itself, independent of the matrix cap. Keeps a -# fat-fingered dispatch (e.g. n_shards=1000) from producing a nonsensical run. -MAX_SHARDS = 64 +# Upper bound on the shard axis itself, independent of the matrix cap. Set below +# GitHub's hard GITHUB_MATRIX_MAX so an oversized pool trips this clear error +# rather than GitHub's opaque one; pools larger than this pack multiple tasks +# per shard (see pack_tasks) instead of failing. +MAX_SHARDS = 200 class ShardConfigError(Exception): @@ -184,6 +186,21 @@ def select_shard_tasks( return [name for j, name in enumerate(selected) if j % n_shards == shard_index] +def pack_tasks(names: list[str], max_shards: int = MAX_SHARDS) -> list[list[str]]: + """Split an ordered task list into at most ``max_shards`` contiguous groups. + + One task per group when ``len(names) <= max_shards`` (the common 1-task-shard + case). Above the cap, each group holds ``ceil(n / max_shards)`` tasks so the + shard count stays legal; groups are contiguous slices of the input order, so + their union is exactly ``names`` with no reordering, duplication, or drops. + """ + n = len(names) + if n == 0: + return [] + per = -(-n // max_shards) # ceil division + return [names[i : i + per] for i in range(0, n, per)] + + def main() -> None: """Entry point for the prep job: expand the model matrix by shard. diff --git a/.github/scripts/test_aggregate_unified.py b/.github/scripts/test_aggregate_unified.py index b0c1c786503..25acf0f2f2f 100644 --- a/.github/scripts/test_aggregate_unified.py +++ b/.github/scripts/test_aggregate_unified.py @@ -492,7 +492,7 @@ def test_main_rejects_nonpositive_rollouts( assert "--rollouts must be >= 1" in capsys.readouterr().err -def test_main_fails_only_when_every_expected_model_is_incomplete( +def test_main_fails_when_no_usable_leaf_summaries_exist( tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], @@ -505,13 +505,29 @@ def test_main_fails_only_when_every_expected_model_is_incomplete( assert rc == 1 assert (out / "unified_summary.json").exists() - assert "::error::Every expected model is incomplete" in capsys.readouterr().out + assert ( + "::error::No usable eval leaf summaries were found" in capsys.readouterr().out + ) + +def test_main_warns_but_succeeds_when_usable_leaves_are_incomplete( + tmp_path: Path, + monkeypatch: pytest.MonkeyPatch, + capsys: pytest.CaptureFixture[str], +) -> None: + monkeypatch.setenv("EXPECTED_MODELS", '["m"]') + monkeypatch.setenv("EXPECTED_CATEGORIES", '["context", "autonomous"]') _leaf_dir(tmp_path, "m", "context") - assert au.main([str(tmp_path), "--rollouts", "3", "--out-dir", str(out)]) == 0 + rc = au.main([str(tmp_path), "--rollouts", "3"]) -def test_main_fails_when_required_leaf_has_no_tasks( + assert rc == 0 + assert "::warning::All expected models were flagged incomplete" in ( + capsys.readouterr().out + ) + + +def test_main_warns_when_required_leaf_has_no_tasks( tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], @@ -533,13 +549,15 @@ def test_main_fails_when_required_leaf_has_no_tasks( combined = json.loads((out / "unified_summary.json").read_text()) model = combined["models"]["m"] - assert rc == 1 + assert rc == 0 assert model["categories"]["context"]["incomplete"] is True assert model["incomplete"] is True - assert "::error::Every expected model is incomplete" in capsys.readouterr().out + assert "::warning::All expected models were flagged incomplete" in ( + capsys.readouterr().out + ) -def test_main_ignores_unexpected_complete_model_for_expected_grid_failure( +def test_main_ignores_unexpected_complete_model_for_expected_grid( tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], @@ -551,8 +569,10 @@ def test_main_ignores_unexpected_complete_model_for_expected_grid_failure( rc = au.main([str(tmp_path), "--rollouts", "3", "--out-dir", str(out)]) - assert rc == 1 - assert "::error::Every expected model is incomplete" in capsys.readouterr().out + assert rc == 0 + assert "::warning::All expected models were flagged incomplete" in ( + capsys.readouterr().out + ) def test_main_does_not_apply_expected_grid_failure_without_expected_models( @@ -573,7 +593,7 @@ def test_main_does_not_apply_expected_grid_failure_without_expected_models( assert "::error::Every expected model is incomplete" not in output -def test_main_warns_and_skips_leaf_with_mismatched_rollouts( +def test_main_fails_when_all_leaves_have_mismatched_rollouts( tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], @@ -590,6 +610,7 @@ def test_main_warns_and_skips_leaf_with_mismatched_rollouts( combined = json.loads((out / "unified_summary.json").read_text()) assert rc == 1 assert "rollouts_per_task is 2; expected 3" in output + assert "::error::No usable eval leaf summaries were found" in output assert combined["models"]["m"]["missing_categories"] == ["context"] diff --git a/.github/scripts/test_enumerate_tasks.py b/.github/scripts/test_enumerate_tasks.py new file mode 100644 index 00000000000..0ebf6ae5a93 --- /dev/null +++ b/.github/scripts/test_enumerate_tasks.py @@ -0,0 +1,42 @@ +import os, sys +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import enumerate_tasks as et # noqa: E402 + + +def test_local_task_names_lists_dirs_with_task_toml(tmp_path): + (tmp_path / "cb-cloud-1").mkdir() + (tmp_path / "cb-cloud-1" / "task.toml").write_text("") + (tmp_path / "cb-cloud-0").mkdir() + (tmp_path / "cb-cloud-0" / "task.toml").write_text("") + (tmp_path / "not-a-task").mkdir() # no task.toml -> excluded + (tmp_path / "dataset.toml").write_text("") # file, not a task dir + assert et.local_task_names(str(tmp_path)) == ["cb-cloud-0", "cb-cloud-1"] + + +def test_local_task_names_empty_raises(tmp_path): + import pytest + with pytest.raises(SystemExit, match="No local Harbor tasks"): + et.local_task_names(str(tmp_path)) + + +def test_tau3_subset_is_registered_synthetic(): + # "tau3-subset" is not an org/name registry package, so it must resolve via + # a synthetic resolver rather than the registry client. + assert "tau3-subset" in et.SYNTHETIC_DATASETS + + +def test_main_routes_synthetic_dataset_not_registry(tmp_path, monkeypatch): + import pytest + + out = tmp_path / "names.txt" + monkeypatch.setitem(et.SYNTHETIC_DATASETS, "tau3-subset", lambda: ["a", "b", "c"]) + monkeypatch.setenv("ENUM_DATASET", "tau3-subset") + monkeypatch.setenv("ENUM_OUTPUT", str(out)) + monkeypatch.delenv("ENUM_DATASET_PATH", raising=False) + monkeypatch.setattr( + et, + "registry_task_names", + lambda _ref: pytest.fail("registry must not be queried for a synthetic dataset"), + ) + assert et.main() == 0 + assert out.read_text().split() == ["a", "b", "c"] diff --git a/.github/scripts/test_shard_matrix.py b/.github/scripts/test_shard_matrix.py index f34cf4279bd..3c9b90266b0 100644 --- a/.github/scripts/test_shard_matrix.py +++ b/.github/scripts/test_shard_matrix.py @@ -87,9 +87,23 @@ def test_expand_matrix_rejects_real_all_set_overflow(shard: ModuleType) -> None: shard.expand_matrix(_models(56), 5) -@pytest.mark.parametrize("bad", [0, 65, -1]) +def test_expand_matrix_accepts_max_shards_boundary(shard: ModuleType) -> None: + """n_shards == MAX_SHARDS is accepted (boundary).""" + m = {"include": [{"model": "x"}]} + out = shard.expand_matrix(m, shard.MAX_SHARDS) + assert len(out["include"]) == shard.MAX_SHARDS + + +def test_expand_matrix_rejects_over_max_shards(shard: ModuleType) -> None: + """n_shards == MAX_SHARDS + 1 is rejected (out of range).""" + m = {"include": [{"model": "x"}]} + with pytest.raises(shard.ShardConfigError, match=r"1\.\.200"): + shard.expand_matrix(m, shard.MAX_SHARDS + 1) + + +@pytest.mark.parametrize("bad", [0, 201, -1]) def test_expand_matrix_rejects_out_of_range_shards(shard: ModuleType, bad: int) -> None: - """n_shards must be an integer in 1..64.""" + """n_shards must be an integer in 1..200.""" with pytest.raises(shard.ShardConfigError, match="Invalid n_shards"): shard.expand_matrix(_models(2), bad) @@ -427,3 +441,37 @@ def test_main_rejects_matrix_overflow_as_exit( with pytest.raises(SystemExit) as excinfo: shard.main() assert excinfo.value.code == 1 + + +# --------------------------------------------------------------------------- # +# pack_tasks — split ordered task list into contiguous groups (comment #3) +# --------------------------------------------------------------------------- # + + +def test_pack_tasks_one_per_shard_under_cap(shard: ModuleType) -> None: + """When len(names) <= max_shards, one task per group (1-task shards).""" + names = [f"t{i}" for i in range(5)] + assert shard.pack_tasks(names, max_shards=200) == [["t0"], ["t1"], ["t2"], ["t3"], ["t4"]] + + +def test_pack_tasks_packs_above_cap_contiguously(shard: ModuleType) -> None: + """Above the cap, pack ceil(n/max_shards) tasks per group contiguously. + + cap 2 -> ceil(5/2)=3 per group -> [t0,t1,t2],[t3,t4] + """ + names = [f"t{i}" for i in range(5)] + assert shard.pack_tasks(names, max_shards=2) == [["t0", "t1", "t2"], ["t3", "t4"]] + + +def test_pack_tasks_covers_every_task_disjointly(shard: ModuleType) -> None: + """Order-preserving, no dupes, no drops (covers exactly the input set).""" + names = [f"t{i}" for i in range(203)] + groups = shard.pack_tasks(names, max_shards=200) + assert len(groups) <= 200 + flat = [n for g in groups for n in g] + assert flat == names # order-preserving, no dupes, no drops + + +def test_pack_tasks_empty(shard: ModuleType) -> None: + """Empty input yields empty output.""" + assert shard.pack_tasks([], max_shards=200) == [] diff --git a/.github/scripts/test_unified_prep.py b/.github/scripts/test_unified_prep.py index 8c5c1590104..aeeb77c3732 100644 --- a/.github/scripts/test_unified_prep.py +++ b/.github/scripts/test_unified_prep.py @@ -1,6 +1,8 @@ import os import sys +import pytest + sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import shard_matrix # noqa: E402 import unified_prep as up # noqa: E402 @@ -22,359 +24,132 @@ def test_provider_of_uses_prefix_and_falls_back_to_other(): assert up.provider_of("weirdvendor:x", known) == "other" -def test_clamp_shard_parallel_enforces_both_invariants(): - # per-model: conc*sp<=40 ; global: P*sp<=64 - assert ( - up.clamp_shard_parallel(10, num_providers=1, concurrency=4) == 10 - ) # 4*10=40, 1*10=64-ok - assert ( - up.clamp_shard_parallel(10, num_providers=7, concurrency=4) == 9 - ) # floor(64/7)=9 - assert ( - up.clamp_shard_parallel(10, num_providers=2, concurrency=8) == 5 - ) # floor(40/8)=5 - assert ( - up.clamp_shard_parallel(10, num_providers=100, concurrency=4) == 1 - ) # floor(64/100)=0 -> 1 - - -def test_build_provider_matrices_cross_products_models_and_categories(): - models = ["anthropic:opus", "openai:gpt", "anthropic:sonnet"] - cats = ["autonomous", "context"] - mats = up.build_provider_matrices( - models, - cats, - shard_parallel=10, - n_shards_by_cat={"autonomous": 10, "context": 3}, - ) - # bucketed by provider prefix - assert set(mats) == {"anthropic", "openai"} - # 2 anthropic models x 2 categories = 4 entries - assert len(mats["anthropic"]) == 4 - entry = next( - e - for e in mats["anthropic"] - if e["model"] == "anthropic:opus" and e["category"] == "context" - ) - assert entry["dataset_path"] == "datasets/context-retrieval-evals" - assert entry["agent_impl"] == "bare" - # Shared dataset: empty so the leaf derives the canonical per-category name. - assert entry["langsmith_dataset"] == "" - assert entry["n_shards"] == 3 - - -def test_agent_impl_override_applies_only_to_deepagent_categories(): - models = ["anthropic:opus"] - cats = ["autonomous", "conversation", "context"] - n = {"autonomous": 10, "conversation": 3, "context": 3} - - # No override -> each category's CATEGORY_MAP default. autonomous/context are - # the bare deep-agents harness; conversation is pinned to tau3. - default_impls = { - e["category"]: e["agent_impl"] - for e in up.build_provider_matrices(models, cats, 10, n)["anthropic"] - } - assert default_impls == { - "autonomous": "bare", - "conversation": "tau3", - "context": "bare", - } - - # dcode override -> only the deep-agents categories switch; tau3 is untouched. - overridden = { - e["category"]: e["agent_impl"] - for e in up.build_provider_matrices(models, cats, 10, n, agent_impl="dcode")[ - "anthropic" - ] - } - assert overridden == { - "autonomous": "dcode", - "conversation": "tau3", - "context": "dcode", - } - - -def test_agent_impl_override_applies_across_providers(): - # The override is resolved per entry, independent of provider bucket, so it - # must reach every provider's matrix identically. - models = ["anthropic:opus", "openai:gpt"] - mats = up.build_provider_matrices( - models, - ["autonomous", "context"], - shard_parallel=10, - n_shards_by_cat={"autonomous": 10, "context": 3}, - agent_impl="dcode", +def test_derive_pool_uses_full_concurrency_for_packed_shards(): + # Packed shards can use all four slots: 40 // 4 = 10. + assert up.derive_pool(concurrency=4, rollouts=3, n_shards=34, n_models=1) == (10, 1) + # concurrency 1 -> 40 shard jobs; 80 // 40 = 2 models. + assert up.derive_pool(concurrency=1, rollouts=3, n_shards=100, n_models=5) == ( + 40, + 2, ) - assert set(mats) == {"anthropic", "openai"} - for prov in ("anthropic", "openai"): - assert {e["agent_impl"] for e in mats[prov]} == {"dcode"} + # Lower rollouts do not reduce a packed shard's peak concurrency. + assert up.derive_pool(concurrency=4, rollouts=2, n_shards=100, n_models=1)[0] == 10 + # Clamp max_parallel to n_shards when few tasks; model_parallel clamps to n_models. + assert up.derive_pool(concurrency=1, rollouts=3, n_shards=8, n_models=1) == (8, 1) -def test_build_provider_matrices_rejects_unknown_agent_impl(): - # Defense in depth: a truthy-but-unknown harness must not flow silently into - # a matrix entry, even for a caller that bypasses main()'s validation. - import pytest - - with pytest.raises(ValueError, match="agent_impl"): - up.build_provider_matrices( - ["anthropic:opus"], - ["autonomous"], - shard_parallel=10, - n_shards_by_cat={"autonomous": 10}, - agent_impl="garbage", - ) - - -def test_full_profile_has_empty_include_tasks(): - mats = up.build_provider_matrices( - ["openai:gpt"], - ["autonomous"], - shard_parallel=10, - n_shards_by_cat={"autonomous": 10}, +def test_allocate_shard_budgets_trims_overflow_from_largest_category(): + budgets = up._allocate_shard_budgets( + {"big": 10_000, "s1": 1, "s2": 1}, cap=shard_matrix.MAX_SHARDS ) - assert mats["openai"][0]["include_tasks"] == "" + assert sum(budgets.values()) <= shard_matrix.MAX_SHARDS + assert budgets == {"big": 198, "s1": 1, "s2": 1} -def test_lite_profile_sets_include_tasks_and_shards_one_task_each(): - import lite_tasks - defaults = {"autonomous": 10, "conversation": 3, "context": 3} - mats = up.build_provider_matrices( - ["openai:gpt"], - ["autonomous", "conversation", "context"], - shard_parallel=10, - n_shards_by_cat=defaults, - agent_impl="bare", - profile="lite", - ) - by_cat = {e["category"]: e for e in mats["openai"]} - for cat in ("autonomous", "conversation", "context"): - n = len(lite_tasks.LITE_TASKS[cat]) - assert by_cat[cat]["include_tasks"] == " ".join(lite_tasks.LITE_TASKS[cat]) - # One task per shard: max-parallel drains the queue, GH pulls the next - # single-task shard as each finishes (dynamic load-balancing). - assert by_cat[cat]["n_shards"] == n - assert by_cat["autonomous"]["n_shards"] == 15 - - -def test_lite_shards_independent_of_shard_parallel(): - # n_shards is the queue depth (one task each), NOT capped at shard_parallel: - # a small max-parallel just means GH drains the queue in more waves. - mats = up.build_provider_matrices( - ["openai:gpt"], - ["autonomous"], - shard_parallel=2, - n_shards_by_cat={"autonomous": 10}, - profile="lite", +def test_allocate_shard_budgets_breaks_largest_ties_by_category_order(): + budgets = up._allocate_shard_budgets( + {"first": 1_000, "second": 1_000, "small-1": 1, "small-2": 1, "small-3": 1}, + cap=shard_matrix.MAX_SHARDS, ) - assert mats["openai"][0]["n_shards"] == 15 + assert sum(budgets.values()) <= shard_matrix.MAX_SHARDS + assert budgets == { + "first": 98, + "second": 99, + "small-1": 1, + "small-2": 1, + "small-3": 1, + } -def test_langsmith_dataset_is_empty_for_shared_dataset(): - # No per-model dataset name: the leaf derives the canonical shared dataset, - # so every entry's langsmith_dataset is empty regardless of the model spec. - mats = up.build_provider_matrices( - ["openrouter:foo/bar", "openrouter:foo-bar"], - ["context"], - shard_parallel=10, - n_shards_by_cat={"context": 3}, - ) - assert all(e["langsmith_dataset"] == "" for e in mats["openrouter"]) +def test_main_rejects_empty_requested_category(tmp_path, monkeypatch): + import json as _j + import pytest -def test_main_dedupes_repeated_categories(tmp_path, monkeypatch): - monkeypatch.setenv("UNIFIED_MODELS", "anthropic:opus") - monkeypatch.setenv("UNIFIED_CATEGORIES", "context,context,context") + tasks_json = tmp_path / "tasks.json" + tasks_json.write_text(_j.dumps({"autonomous": []})) + monkeypatch.setenv("UNIFIED_MODELS", "openai:gpt") + monkeypatch.setenv("UNIFIED_CATEGORIES", "autonomous") + monkeypatch.setenv("UNIFIED_PROFILE", "full") + monkeypatch.setenv("UNIFIED_TASKS_JSON", str(tasks_json)) monkeypatch.setenv("GITHUB_OUTPUT", str(tmp_path / "o")) - assert up.main([]) == 0 - import json as _j - lines = dict( - line.split("=", 1) for line in (tmp_path / "o").read_text().splitlines() - ) - anth = _j.loads(lines["anthropic_matrix"]) - assert len(anth["include"]) == 1 # one entry, not three + with pytest.raises(SystemExit, match=r"No tasks resolved for requested categor"): + up.main([]) -def test_main_emits_per_provider_outputs(tmp_path, monkeypatch): - out = tmp_path / "gh_out" - monkeypatch.setenv("UNIFIED_MODELS", "anthropic:opus, openai:gpt") - monkeypatch.setenv("UNIFIED_CATEGORIES", "autonomous,context") - monkeypatch.setenv("UNIFIED_CONCURRENCY", "4") - monkeypatch.setenv("UNIFIED_SHARD_PARALLEL", "10") - monkeypatch.setenv("GITHUB_OUTPUT", str(out)) - rc = up.main([]) - assert rc == 0 - text = out.read_text() - lines = dict(line.split("=", 1) for line in text.splitlines()) - assert lines["anthropic_has_models"] == "true" - assert lines["openai_has_models"] == "true" - assert lines["fireworks_has_models"] == "false" - assert lines["effective_shard_parallel"] == "10" +@pytest.mark.parametrize( + "tasks", [{"autonomous": "taskname"}, ["taskname"], {"autonomous": ["task", 1]}] +) +def test_main_rejects_invalid_full_task_json_shape(tmp_path, monkeypatch, tasks): import json as _j - - anth = _j.loads(lines["anthropic_matrix"]) - assert len(anth["include"]) == 2 # 1 model x 2 categories - assert "providers" not in lines - - -def test_main_rejects_invalid_concurrency(tmp_path, monkeypatch): - monkeypatch.setenv("UNIFIED_MODELS", "anthropic:opus") - monkeypatch.setenv("UNIFIED_CATEGORIES", "context") - monkeypatch.setenv("GITHUB_OUTPUT", str(tmp_path / "o")) import pytest - for raw in ("not-an-integer", "", "1.5", "-1", "0", "41"): - monkeypatch.setenv("UNIFIED_CONCURRENCY", raw) - with pytest.raises(SystemExit, match=r"UNIFIED_CONCURRENCY.*1\.\.40"): - up.main([]) - - -def test_main_rejects_invalid_shard_parallel(tmp_path, monkeypatch): - monkeypatch.setenv("UNIFIED_MODELS", "anthropic:opus") - monkeypatch.setenv("UNIFIED_CATEGORIES", "context") + tasks_json = tmp_path / "tasks.json" + tasks_json.write_text(_j.dumps(tasks)) + monkeypatch.setenv("UNIFIED_MODELS", "openai:gpt") + monkeypatch.setenv("UNIFIED_CATEGORIES", "autonomous") + monkeypatch.setenv("UNIFIED_PROFILE", "full") + monkeypatch.setenv("UNIFIED_TASKS_JSON", str(tasks_json)) monkeypatch.setenv("GITHUB_OUTPUT", str(tmp_path / "o")) - import pytest - for raw in ("not-an-integer", "", "1.5", "-1", "0"): - monkeypatch.setenv("UNIFIED_SHARD_PARALLEL", raw) - with pytest.raises(SystemExit, match=r"UNIFIED_SHARD_PARALLEL.*>= 1"): - up.main([]) + with pytest.raises(SystemExit, match=r"UNIFIED_TASKS_JSON must be a JSON object"): + up.main([]) -def test_main_accepts_large_shard_parallel_and_clamps_to_resource_limits( - tmp_path, monkeypatch -): - cases = [ - ("anthropic:a", "8", "5"), - ( - "anthropic:a,baseten:b,fireworks:c,google_genai:d,groq:e," - "nvidia:f,openai:g,xai:h", - "1", - "8", - ), - ] - for index, (models, concurrency, expected) in enumerate(cases): - out = tmp_path / f"o{index}" - monkeypatch.setenv("UNIFIED_MODELS", models) - monkeypatch.setenv("UNIFIED_CATEGORIES", "context") - monkeypatch.setenv("UNIFIED_CONCURRENCY", concurrency) - monkeypatch.setenv("UNIFIED_SHARD_PARALLEL", "1000") - monkeypatch.setenv("GITHUB_OUTPUT", str(out)) - - assert up.main([]) == 0 - lines = dict(line.split("=", 1) for line in out.read_text().splitlines()) - assert lines["effective_shard_parallel"] == expected - - -def test_main_rejects_invalid_category_shard_counts(tmp_path, monkeypatch): - variables = ( - "UNIFIED_N_SHARDS_AUTONOMOUS", - "UNIFIED_N_SHARDS_CONVERSATION", - "UNIFIED_N_SHARDS_CONTEXT", - ) - invalid = ( - "not-an-integer", - "", - "1.5", - "-1", - "0", - str(shard_matrix.MAX_SHARDS + 1), - ) - monkeypatch.setenv("UNIFIED_MODELS", "anthropic:opus") - monkeypatch.setenv("UNIFIED_CATEGORIES", "context") - monkeypatch.setenv("GITHUB_OUTPUT", str(tmp_path / "o")) +def test_main_rejects_invalid_agent_impl(tmp_path, monkeypatch): import pytest - for variable in variables: - for raw in invalid: - for current in variables: - monkeypatch.setenv(current, "1") - monkeypatch.setenv(variable, raw) - with pytest.raises( - SystemExit, - match=rf"{variable}.*1\.\.{shard_matrix.MAX_SHARDS}", - ): - up.main([]) - - -def test_main_accepts_category_shard_count_boundaries(tmp_path, monkeypatch): - variables = { - "autonomous": "UNIFIED_N_SHARDS_AUTONOMOUS", - "conversation": "UNIFIED_N_SHARDS_CONVERSATION", - "context": "UNIFIED_N_SHARDS_CONTEXT", - } - monkeypatch.setenv("UNIFIED_MODELS", "anthropic:opus") - import json as _j - - for category, variable in variables.items(): - for boundary in (1, shard_matrix.MAX_SHARDS): - out = tmp_path / f"{category}-{boundary}" - for current in variables.values(): - monkeypatch.setenv(current, "1") - monkeypatch.setenv(variable, str(boundary)) - monkeypatch.setenv("UNIFIED_CATEGORIES", category) - monkeypatch.setenv("GITHUB_OUTPUT", str(out)) + monkeypatch.setenv("UNIFIED_MODELS", "openai:gpt") + monkeypatch.setenv("UNIFIED_CATEGORIES", "autonomous") + monkeypatch.setenv("GITHUB_OUTPUT", str(tmp_path / "o")) + monkeypatch.setenv("UNIFIED_AGENT_IMPL", "deepagent") + with pytest.raises(SystemExit, match=r"UNIFIED_AGENT_IMPL must be one of"): + up.main() - assert up.main([]) == 0 - lines = dict(line.split("=", 1) for line in out.read_text().splitlines()) - matrix = _j.loads(lines["anthropic_matrix"]) - assert matrix["include"][0]["n_shards"] == boundary +def test_main_rejects_invalid_profile(tmp_path, monkeypatch): + import pytest -def test_main_rejects_invalid_agent_impl(tmp_path, monkeypatch): - monkeypatch.setenv("UNIFIED_MODELS", "anthropic:opus") - monkeypatch.setenv("UNIFIED_CATEGORIES", "context") - monkeypatch.setenv( - "UNIFIED_AGENT_IMPL", "tau3" - ) # valid harness, not selectable here + monkeypatch.setenv("UNIFIED_MODELS", "openai:gpt") + monkeypatch.setenv("UNIFIED_CATEGORIES", "autonomous") monkeypatch.setenv("GITHUB_OUTPUT", str(tmp_path / "o")) - import pytest + monkeypatch.setenv("UNIFIED_PROFILE", "medium") + with pytest.raises(SystemExit, match=r"UNIFIED_PROFILE must be one of"): + up.main() - with pytest.raises(SystemExit, match="UNIFIED_AGENT_IMPL"): - up.main([]) +def test_main_dedupes_repeated_categories(tmp_path, monkeypatch): + import lite_tasks -def test_main_agent_impl_override_reaches_matrix(tmp_path, monkeypatch): - # Guards the main() -> build_provider_matrices wiring: a dropped agent_impl - # argument would fall back to category defaults and go undetected otherwise. - out = tmp_path / "o" monkeypatch.setenv("UNIFIED_MODELS", "anthropic:opus") - monkeypatch.setenv("UNIFIED_CATEGORIES", "autonomous,context") - monkeypatch.setenv("UNIFIED_AGENT_IMPL", "dcode") - monkeypatch.setenv("GITHUB_OUTPUT", str(out)) + monkeypatch.setenv("UNIFIED_CATEGORIES", "context,context,context") + monkeypatch.setenv("UNIFIED_PROFILE", "lite") + monkeypatch.setenv("GITHUB_OUTPUT", str(tmp_path / "o")) assert up.main([]) == 0 import json as _j - lines = dict(line.split("=", 1) for line in out.read_text().splitlines()) - matrix = _j.loads(lines["anthropic_matrix"]) - assert {e["agent_impl"] for e in matrix["include"]} == {"dcode"} + lines = dict( + line.split("=", 1) for line in (tmp_path / "o").read_text().splitlines() + ) + assert _j.loads(lines["categories"]) == ["context"] # one entry, not three + # the flat matrix isn't tripled either: one shard per context task + eval_matrix = _j.loads(lines["eval_matrix"])["include"] + matrix = _j.loads(eval_matrix[0]["flat_matrix"])["include"] + assert len(matrix) == len(lite_tasks.LITE_TASKS["context"]) -def test_main_blank_agent_impl_falls_back_to_default(tmp_path, monkeypatch): - # A whitespace-only env value must fall back to bare, not raise. - out = tmp_path / "o" +def test_main_rejects_invalid_concurrency(tmp_path, monkeypatch): monkeypatch.setenv("UNIFIED_MODELS", "anthropic:opus") - monkeypatch.setenv("UNIFIED_CATEGORIES", "autonomous,context") - monkeypatch.setenv("UNIFIED_AGENT_IMPL", " ") - monkeypatch.setenv("GITHUB_OUTPUT", str(out)) - assert up.main([]) == 0 - import json as _j - - lines = dict(line.split("=", 1) for line in out.read_text().splitlines()) - matrix = _j.loads(lines["anthropic_matrix"]) - assert {e["agent_impl"] for e in matrix["include"]} == {"bare"} - - -def test_main_rejects_invalid_profile(tmp_path, monkeypatch): + monkeypatch.setenv("UNIFIED_CATEGORIES", "context") + monkeypatch.setenv("GITHUB_OUTPUT", str(tmp_path / "o")) import pytest - monkeypatch.setenv("UNIFIED_MODELS", "openai:gpt") - monkeypatch.setenv("UNIFIED_CATEGORIES", "autonomous") - monkeypatch.setenv("GITHUB_OUTPUT", str(tmp_path / "o")) - monkeypatch.setenv("UNIFIED_PROFILE", "medium") - with pytest.raises(SystemExit, match=r"UNIFIED_PROFILE must be one of"): - up.main() + for raw in ("not-an-integer", "", "1.5", "-1", "0", "41"): + monkeypatch.setenv("UNIFIED_CONCURRENCY", raw) + with pytest.raises(SystemExit, match=r"UNIFIED_CONCURRENCY.*1\.\.40"): + up.main([]) def test_main_rejects_bad_spec(tmp_path, monkeypatch): @@ -402,6 +177,7 @@ def test_main_rejects_empty_categories(tmp_path, monkeypatch): def test_main_emits_expected_models_and_categories(tmp_path, monkeypatch): monkeypatch.setenv("UNIFIED_MODELS", "anthropic:opus, openai:gpt") monkeypatch.setenv("UNIFIED_CATEGORIES", "autonomous,context") + monkeypatch.setenv("UNIFIED_PROFILE", "lite") monkeypatch.setenv("GITHUB_OUTPUT", str(tmp_path / "o")) assert up.main([]) == 0 import json as _j @@ -413,20 +189,191 @@ def test_main_emits_expected_models_and_categories(tmp_path, monkeypatch): assert _j.loads(lines["categories"]) == ["autonomous", "context"] -def test_main_routes_unknown_provider_into_other_bucket(tmp_path, monkeypatch): - # A spec whose prefix isn't a KNOWN_PROVIDER still resolves (the resolver - # doesn't allowlist providers), and must land in the "other" matrix rather - # than being silently dropped from every provider bucket. +def test_total_job_guard_allows_within_budget(): + up.total_job_guard(n_models=2, shards_per_model=142) # 284 <= 400, no raise + + +def test_total_job_guard_rejects_over_budget(): + import pytest + + with pytest.raises(SystemExit, match=r"worker pool"): + up.total_job_guard(n_models=3, shards_per_model=142) # 426 > 400 + + +def test_main_full_multi_model_guard_counts_packed_shards(tmp_path, monkeypatch): + # The guard must count the packed flat-matrix entries, not the raw task + # count. 260 tasks pack (via ceil division) to 130 shards/model, so 3 models + # emit 3 x 130 = 390 jobs, within the 400 budget. Guarding on the raw count + # (3 x 260 = 780) -- or on the loose min(tasks, MAX_SHARDS)=200 bound + # (3 x 200 = 600) -- would wrongly reject this valid run. + import json as _j + + n_tasks = 260 + packed = len( + up.build_flat_matrix("x:y", ["autonomous"], {"autonomous": ["t"] * n_tasks}) + ) + assert packed == 130 # pins the packing so the budget arithmetic below is real + assert ( + 3 * packed <= up.TOTAL_JOB_BUDGET < 3 * min(n_tasks, up.shard_matrix.MAX_SHARDS) + ) + + tasks_json = tmp_path / "tasks.json" + tasks_json.write_text( + _j.dumps({"autonomous": [f"harbor-index/t-{i}" for i in range(n_tasks)]}) + ) + monkeypatch.setenv("UNIFIED_MODELS", "anthropic:a,anthropic:b,anthropic:c") + monkeypatch.setenv("UNIFIED_CATEGORIES", "autonomous") + monkeypatch.setenv("UNIFIED_PROFILE", "full") + monkeypatch.setenv("UNIFIED_TASKS_JSON", str(tasks_json)) + monkeypatch.setenv("GITHUB_OUTPUT", str(tmp_path / "o")) + + assert up.main([]) == 0 # SystemExit if the guard over-counts (raw or loose bound) + lines = dict( + line.split("=", 1) for line in (tmp_path / "o").read_text().splitlines() + ) + entries = _j.loads(lines["eval_matrix"])["include"] + assert len(entries) == 3 + for entry in entries: + assert len(_j.loads(entry["flat_matrix"])["include"]) == packed + + +def test_build_flat_matrix_one_entry_per_task_across_categories(): + tasks = { + "autonomous": ["harbor-index/a", "harbor-index/b"], + "context": ["cb-cloud-0"], + } + entries = up.build_flat_matrix( + "openai:gpt", ["autonomous", "context"], tasks, code_impl="bare" + ) + # 2 autonomous + 1 context = 3 single-task shards + assert len(entries) == 3 + auto = [e for e in entries if e["category"] == "autonomous"] + assert {e["include_tasks"] for e in auto} == {"harbor-index/a", "harbor-index/b"} + assert all(e["n_shards"] == 1 and e["shard"] == 0 for e in entries) + assert all(e["agent_impl"] == "bare" for e in auto) # code override applies + ctx = next(e for e in entries if e["category"] == "context") + assert ctx["dataset_path"] == "datasets/context-retrieval-evals" + assert ctx["agent_impl"] == "bare" + assert all(e["langsmith_dataset"] == "" for e in entries) + + +def test_build_flat_matrix_defaults_to_bare(): + # No override: the code categories fall back to DEFAULT_AGENT_IMPL (bare), + # while conversation stays pinned to tau3. + assert up.DEFAULT_AGENT_IMPL == "bare" + tasks = { + "autonomous": ["harbor-index/a"], + "conversation": ["sierra-research/tau3-bench__x"], + } + entries = up.build_flat_matrix("openai:gpt", ["autonomous", "conversation"], tasks) + auto = next(e for e in entries if e["category"] == "autonomous") + conv = next(e for e in entries if e["category"] == "conversation") + assert auto["agent_impl"] == "bare" + assert conv["agent_impl"] == "tau3" + + +def test_build_flat_matrix_conversation_stays_tau3(): + tasks = {"conversation": ["sierra-research/tau3-bench__x"]} + entries = up.build_flat_matrix( + "openai:gpt", ["conversation"], tasks, code_impl="bare" + ) + assert entries[0]["agent_impl"] == "tau3" + + +def test_build_flat_matrix_packs_above_cap(): + tasks = { + "autonomous": [f"harbor-index/t{i}" for i in range(shard_matrix.MAX_SHARDS + 5)] + } + entries = up.build_flat_matrix( + "openai:gpt", ["autonomous"], tasks, code_impl="dcode" + ) + assert len(entries) <= shard_matrix.MAX_SHARDS + # every task still present, split across include_tasks strings + seen = " ".join(e["include_tasks"] for e in entries).split() + assert seen == tasks["autonomous"] + + +def test_build_flat_matrix_bounds_per_model_total_across_categories(): + # 120 + 120 + 40 = 280 > MAX_SHARDS (200): the per-model TOTAL must be + # packed down to the cap via proportional per-category budgets, not just + # each category independently capped (which would allow up to 3x200). + tasks = { + "autonomous": [f"harbor-index/a{i}" for i in range(120)], + "conversation": [f"sierra-research/tau3-bench__c{i}" for i in range(120)], + "context": [f"cb-cloud-{i}" for i in range(40)], + } + entries = up.build_flat_matrix( + "openai:gpt", + ["autonomous", "conversation", "context"], + tasks, + code_impl="dcode", + ) + assert len(entries) <= shard_matrix.MAX_SHARDS + for cat, expected in tasks.items(): + cat_entries = [e for e in entries if e["category"] == cat] + seen = " ".join(e["include_tasks"] for e in cat_entries).split() + assert seen == expected # every task present exactly once, order preserved + + +def test_derive_pool_budgets_packed_shards_at_full_concurrency(): + tasks = {"autonomous": [f"harbor-index/a{i}" for i in range(260)]} + entries = up.build_flat_matrix("openai:gpt", ["autonomous"], tasks) + assert any(len(entry["include_tasks"].split()) > 1 for entry in entries) + + max_parallel, _ = up.derive_pool( + concurrency=4, rollouts=3, n_shards=len(entries), n_models=1 + ) + assert max_parallel == 10 + assert max_parallel * 4 == up.MAX_TASKS_PER_MODEL + + +def test_build_flat_matrix_below_cap_stays_one_task_per_shard(): + # Lite-like: total is well under MAX_SHARDS, so behavior is unchanged — + # one task per matrix entry, no packing. + tasks = { + "autonomous": [f"harbor-index/a{i}" for i in range(15)], + "conversation": [f"sierra-research/tau3-bench__c{i}" for i in range(11)], + "context": [f"cb-cloud-{i}" for i in range(8)], + } + entries = up.build_flat_matrix( + "openai:gpt", + ["autonomous", "conversation", "context"], + tasks, + code_impl="dcode", + ) + assert len(entries) == 15 + 11 + 8 + assert all(len(e["include_tasks"].split()) == 1 for e in entries) + + +def test_main_emits_per_model_flat_matrix_lite(tmp_path, monkeypatch): + import json as _j + out = tmp_path / "o" - monkeypatch.setenv("UNIFIED_MODELS", "weirdvendor:x") - monkeypatch.setenv("UNIFIED_CATEGORIES", "context") + monkeypatch.setenv("UNIFIED_MODELS", "openai:gpt, anthropic:opus") + monkeypatch.setenv("UNIFIED_CATEGORIES", "autonomous,conversation,context") + monkeypatch.setenv("UNIFIED_PROFILE", "lite") + monkeypatch.setenv("UNIFIED_CONCURRENCY", "4") + monkeypatch.setenv("UNIFIED_ROLLOUTS", "3") monkeypatch.setenv("GITHUB_OUTPUT", str(out)) assert up.main([]) == 0 - import json as _j - lines = dict(line.split("=", 1) for line in out.read_text().splitlines()) - assert lines["other_has_models"] == "true" - assert lines["anthropic_has_models"] == "false" - other = _j.loads(lines["other_matrix"]) - assert [e["model"] for e in other["include"]] == ["weirdvendor:x"] - assert other["include"][0]["provider"] == "other" + assert lines["max_parallel"] == "10" # conc4 -> 40//4 + assert lines["model_parallel"] == "2" # 80//10=8 -> min(8, 2 models) + eval_matrix = _j.loads(lines["eval_matrix"])["include"] + assert len(eval_matrix) == 2 # one entry per model + assert {e["model"] for e in eval_matrix} == {"openai:gpt", "anthropic:opus"} + for entry in eval_matrix: + assert set(entry) == {"model", "slug", "flat_matrix"} + flat = _j.loads(entry["flat_matrix"])["include"] + # lite totals 15+11+8 = 34 single-task shards per model + assert len(flat) == 34 + assert {e["category"] for e in flat} == { + "autonomous", + "conversation", + "context", + } + # No other output carries per-model or per-provider data; eval_matrix is + # the single source for both. + assert "model_slugs" not in lines + assert "model_0_matrix" not in lines + assert "openai_matrix" not in lines diff --git a/.github/scripts/test_unified_workflow.py b/.github/scripts/test_unified_workflow.py index 46a131a9d7a..b8350f9208c 100644 --- a/.github/scripts/test_unified_workflow.py +++ b/.github/scripts/test_unified_workflow.py @@ -90,166 +90,117 @@ def test_dispatch_inputs_reach_every_provider_without_changing_categories() -> N categories = _indented_block(dispatch, " categories:") assert 'default: "autonomous,conversation,context"' in categories - conversation_shards = _indented_block(dispatch, " n_shards_conversation:") - assert 'default: "3"' in conversation_shards - - provider_jobs = [ - "eval-anthropic", - "eval-baseten", - "eval-fireworks", - "eval-google_genai", - "eval-groq", - "eval-nvidia", - "eval-ollama", - "eval-openai", - "eval-openrouter", - "eval-xai", - "eval-other", - ] + + # The deep-agents harness for autonomous/context defaults to bare. + agent_impl = _indented_block(dispatch, " agent_impl:") + assert 'default: "bare"' in agent_impl + assert "- bare" in agent_impl + assert "- dcode" in agent_impl + + # Exactly one reusable-workflow call: the flat-pool `eval` job (see + # test_eval_job_uses_single_flat_pool_matrix below for its shape). reusable_call = "uses: ./.github/workflows/_harbor_run.yml" - assert workflow.count(reusable_call) == len(provider_jobs) - for job_name in provider_jobs: - job = _indented_block(workflow, f" {job_name}:") - assert job.count(reusable_call) == 1 - assert job.count("force_build: ${{ inputs.force_build }}") == 1 - assert ( - job.count("harbor_package_override: ${{ inputs.harbor_package_override }}") - == 1 - ) + assert workflow.count(reusable_call) == 1 + eval_job = _indented_block(workflow, " eval:") + assert eval_job.count("force_build: ${{ inputs.force_build }}") == 1 + assert ( + eval_job.count("harbor_package_override: ${{ inputs.harbor_package_override }}") + == 1 + ) prep_job = _indented_block(workflow, " prep:") assert "UNIFIED_CATEGORIES: ${{ inputs.categories }}" in prep_job - assert "UNIFIED_AGENT_IMPL: ${{ inputs.agent_impl }}" in prep_job - assert ( - "UNIFIED_N_SHARDS_CONVERSATION: ${{ inputs.n_shards_conversation }}" in prep_job - ) assert "run: python .github/scripts/unified_prep.py" in prep_job - # A run-configuration summary in prep makes a dispatch's inputs debuggable. - assert "$GITHUB_STEP_SUMMARY" in prep_job - # ...but the harbor_package_override spec (which can carry credentials) must - # never reach the summary step's environment or public output. Derive only - # a boolean in the expression context and report whether an override was set. - summary_step = _indented_block( - prep_job, ' - name: "📝 Summarize dispatch inputs"' - ) - # Runs even when the parse step failed, so a bad dispatch still records what - # was requested. - assert "if: ${{ always() }}" in summary_step - summary_env = _indented_block(summary_step, " env:") - assert ( - "HARBOR_OVERRIDE_SET: ${{ inputs.harbor_package_override != '' }}" - in summary_env - ) - # Enforce the invariant, not one variable name: the only reference to the - # override spec anywhere in the summary step may be the `!= ''` boolean. - # A raw interpolation under *any* name (e.g. `X: ${{ inputs.harbor_package_override }}`) - # would leak a credentialed spec into the public summary and must fail here. - assert re.search(r"inputs\.harbor_package_override(?!\s*!=)", summary_step) is None - assert '[ "${HARBOR_OVERRIDE_SET}" = "true" ]' in summary_step - - # The harness selector is a constrained choice defaulting to bare. - agent_impl_input = _indented_block(workflow, " agent_impl:") - assert "type: choice" in agent_impl_input - assert 'default: "bare"' in agent_impl_input - assert "- bare" in agent_impl_input - assert "- dcode" in agent_impl_input + + # The run-configuration summary runs even when prep fails and writes to the + # job summary, so every dispatch records what it was asked to run. + assert '- name: "📝 Summarize dispatch inputs"' in prep_job + assert "if: ${{ always() }}" in prep_job + assert 'echo "## Unified evals — run configuration"' in prep_job + assert '} >> "$GITHUB_STEP_SUMMARY"' in prep_job prep_source = PREP_SCRIPT.read_text() conversation = _indented_block(prep_source, ' "conversation": {') assert '"dataset": "tau3-subset"' in conversation assert '"dataset_path": ""' in conversation assert '"agent_impl": "tau3"' in conversation - # The deep-agents categories default to the bare harness (dcode is opt-in). - for marker in (' "autonomous": {', ' "context": {'): - assert '"agent_impl": "bare"' in _indented_block(prep_source, marker) - -def test_agent_impl_choice_matches_prep_allowlist() -> None: - """Keep the dispatch `choice` options and the prep allowlist in lockstep. - The YAML `choice` gates dispatches at the UI; `DEEPAGENT_IMPLS` in the prep - script is the backstop that `SystemExit`s an unknown value. If one gains an - impl the other lacks, a dispatch either offers an option prep rejects or - accepts a value the UI never presents — so the two sources must be equal. - """ +def test_eval_job_uses_single_flat_pool_matrix() -> None: + """One eval job matrixes over per-model flat matrices, capped by model_parallel.""" workflow = UNIFIED_WORKFLOW.read_text() - agent_impl_input = _indented_block(workflow, " agent_impl:") - yaml_options = set(re.findall(r"^\s+- (\S+)$", agent_impl_input, re.MULTILINE)) - assert yaml_options == {"bare", "dcode"} - prep_source = PREP_SCRIPT.read_text() - literal = re.search(r"DEEPAGENT_IMPLS = \{([^}]+)\}", prep_source) - assert literal is not None - allowlist = set(re.findall(r'"([^"]+)"', literal.group(1))) - assert yaml_options == allowlist - - -def test_summary_flags_inert_agent_impl_and_renders_resolved_models( - tmp_path: Path, -) -> None: - """The run summary reports effective config, not just the raw inputs. - - `agent_impl` only affects the deep-agents (autonomous/context) categories, - so when neither runs the value is inert and must be flagged rather than - imply a harness was used. The resolved model list is emitted as a plain - comma list, not the raw JSON array prep writes to `GITHUB_OUTPUT`. - """ + prep_job = _indented_block(workflow, " prep:") + prep_outputs = _indented_block(prep_job, " outputs:") + assert "eval_matrix: ${{ steps.p.outputs.eval_matrix }}" in prep_outputs + assert "max_parallel: ${{ steps.p.outputs.max_parallel }}" in prep_outputs + assert "model_parallel: ${{ steps.p.outputs.model_parallel }}" in prep_outputs + assert "models: ${{ steps.p.outputs.models }}" in prep_outputs + assert "categories: ${{ steps.p.outputs.categories }}" in prep_outputs + # No per-provider output or gate exists anywhere in the workflow. + assert "_has_models" not in workflow + + eval_job = _indented_block(workflow, " eval:") + assert "needs: prep" in eval_job + strategy = _indented_block(eval_job, " strategy:") + assert "fail-fast: false" in strategy + assert ( + "max-parallel: ${{ fromJson(needs.prep.outputs.model_parallel) }}" in strategy + ) + assert "matrix: ${{ fromJson(needs.prep.outputs.eval_matrix) }}" in strategy + assert "max-parallel: 1" not in workflow + + eval_with = _indented_block(eval_job, " with:") + assert "model: ${{ matrix.model }}" in eval_with + assert "flat_matrix: ${{ matrix.flat_matrix }}" in eval_with + assert "max_parallel: ${{ needs.prep.outputs.max_parallel }}" in eval_with + # n_shards/shard_parallel/langsmith_dataset/include_tasks are per-shard + # values now carried inside flat_matrix, not passed at the top level. + assert "n_shards:" not in eval_with + assert "shard_parallel:" not in eval_with + assert "langsmith_dataset:" not in eval_with + assert "include_tasks:" not in eval_with + + +def test_enumerate_step_gated_on_full_profile() -> None: + """The task-enumeration step only runs for the full profile; lite skips it.""" workflow = UNIFIED_WORKFLOW.read_text() prep_job = _indented_block(workflow, " prep:") - summary_step = _indented_block( - prep_job, ' - name: "📝 Summarize dispatch inputs"' + enumerate_step = _indented_block( + prep_job, ' - name: "🔢 Enumerate full-profile tasks"' ) - script = _step_script(summary_step) - - def run(tag: str, resolved_categories: str, resolved_models: str) -> str: - summary = tmp_path / f"{tag}.md" - env = os.environ.copy() - env.update( - { - "GITHUB_STEP_SUMMARY": str(summary), - "IN_MODELS": "anthropic:opus", - "RESOLVED_MODELS": resolved_models, - "IN_CATEGORIES": "n/a", - "RESOLVED_CATEGORIES": resolved_categories, - "IN_AGENT_IMPL": "dcode", - "IN_ROLLOUTS": "3", - "IN_CONCURRENCY": "4", - "IN_SHARD_PARALLEL": "10", - "EFFECTIVE_SHARD_PARALLEL": "10", - "IN_N_SHARDS_AUTONOMOUS": "10", - "IN_N_SHARDS_CONVERSATION": "3", - "IN_N_SHARDS_CONTEXT": "3", - "IN_SANDBOX_ENV": "langsmith", - "IN_FORCE_BUILD": "false", - "HARBOR_OVERRIDE_SET": "false", - } - ) - result = subprocess.run( - ["bash", "-e", "-o", "pipefail", "-c", script], - env=env, - capture_output=True, - text=True, - check=False, - ) - assert result.returncode == 0, (result.stdout, result.stderr) - return summary.read_text() - - inert = "not applicable (no autonomous/context category selected)" - - # No deep-agents category selected -> agent_impl is inert and flagged. - out = run("inert", '["conversation"]', '["anthropic:opus"]') - assert inert in out - # ...and the JSON array is rendered as a plain list. - assert "| models (resolved) | `anthropic:opus` |" in out - - # A deep-agents category is selected -> no flag. - out = run("eligible", '["autonomous","conversation"]', '["anthropic:opus"]') - assert inert not in out - - # Prep didn't complete (empty outputs) -> no misleading flag; honest fallback. - out = run("failed", "", "") - assert inert not in out - assert "(prep did not complete)" in out + assert "if: ${{ inputs.profile == 'full' }}" in enumerate_step + assert "ENUM_DATASET" in enumerate_step + assert "ENUM_DATASET_PATH" in enumerate_step + assert "harbor_adapters.contextbench.main" in enumerate_step + assert "--populate" in enumerate_step + assert "UNIFIED_TASKS_JSON" in enumerate_step + + p_step = _indented_block( + prep_job, ' - name: "🧮 Parse models + build the per-model flat matrix"' + ) + p_env = _indented_block(p_step, " env:") + assert "UNIFIED_MODELS: ${{ inputs.models }}" in p_env + assert "UNIFIED_CATEGORIES: ${{ inputs.categories }}" in p_env + assert "UNIFIED_AGENT_IMPL: ${{ inputs.agent_impl }}" in p_env + assert "UNIFIED_PROFILE: ${{ inputs.profile }}" in p_env + assert "UNIFIED_CONCURRENCY: ${{ inputs.concurrency }}" in p_env + assert "UNIFIED_ROLLOUTS: ${{ inputs.rollouts }}" in p_env + assert "UNIFIED_TASKS_JSON: ${{ env.UNIFIED_TASKS_JSON }}" in p_env + assert "UNIFIED_SHARD_PARALLEL" not in workflow + assert "UNIFIED_N_SHARDS_" not in workflow + + +def test_combine_needs_prep_and_eval() -> None: + """Combine waits on the single eval job, not a fixed provider job list.""" + workflow = UNIFIED_WORKFLOW.read_text() + combine_job = _indented_block(workflow, " combine:") + needs = _indented_block(combine_job, " needs:") + assert "- prep" in needs + assert "- eval" in needs + # marker line ("needs:") plus exactly the two job names, no leftover + # provider jobs. + assert len([line for line in needs.splitlines() if line.strip()]) == 3 def test_combine_download_classifies_no_artifacts_and_retries_failures() -> None: @@ -418,18 +369,68 @@ def test_leaf_aggregation_requires_every_expected_shard() -> None: """Count successful empty shards while detecting missing artifacts.""" workflow = HARBOR_WORKFLOW.read_text() harbor = _indented_block(workflow, " harbor:") + prep_job = _indented_block(workflow, " prep:") aggregate = _indented_block(workflow, " aggregate:") + # Category-scoped so independently-sharded categories in a flat multi-category + # run can't collide on the same shard index's marker basename (aggregate_shards.py + # counts markers by basename alone). assert ( - 'touch "harbor-jobs/terminal-bench/empty-shard-$HARBOR_SHARD_INDEX"' in harbor + 'touch "harbor-jobs/terminal-bench/empty-shard-${HARBOR_CATEGORY}-${HARBOR_SHARD_INDEX}"' + in harbor ) assert " needs: [prep, harbor]" in aggregate - assert "EXPECTED_SHARDS: ${{ needs.prep.outputs.n_shards }}" in aggregate + # expected_shards now flows per-category via aggregate_matrix (derived in prep + # from prep's own shard-matrix output on the single-dataset path), not a + # single job-level env var on the aggregate job. + assert ( + "SINGLE_EXPECTED_SHARDS: ${{ steps.shard-matrix.outputs.n_shards }}" + in prep_job + ) + assert "EXPECTED_SHARDS: ${{ matrix.expected_shards }}" in aggregate compute = _indented_block(aggregate, ' - name: "📊 Compute pass@k / avg@k"') assert 'expected_shards_args=(--expected-shards "$EXPECTED_SHARDS")' in compute assert '"${expected_shards_args[@]}"' in compute +def test_aggregate_runs_per_category() -> None: + """Aggregate matrixes over categories instead of hardcoding a single one.""" + text = HARBOR_WORKFLOW.read_text() + # aggregate loops over the categories present in the flat matrix + assert "for cat in" in text or "matrix.category" in text + assert "aggregate_shards.py" in text + assert "--category" in text + + workflow = HARBOR_WORKFLOW.read_text() + prep_job = _indented_block(workflow, " prep:") + aggregate_job = _indented_block(workflow, " aggregate:") + + assert "aggregate_matrix: ${{ steps.agg-matrix.outputs.aggregate_matrix }}" in prep_job + derive_step = _indented_block(prep_job, ' - name: "🗂️ Derive aggregate matrix"') + assert "FLAT_MATRIX: ${{ inputs.flat_matrix }}" in derive_step + assert "expected_shards" in derive_step + + aggregate_strategy = _indented_block(aggregate_job, " strategy:") + assert ( + "matrix: ${{ fromJson(needs.prep.outputs.aggregate_matrix) }}" + in aggregate_strategy + ) + + compute = _indented_block( + aggregate_job, ' - name: "📊 Compute pass@k / avg@k"' + ) + assert "DATASET: ${{ matrix.dataset }}" in compute + assert "CATEGORY: ${{ matrix.category }}" in compute + assert "--category" in compute + + upload = _indented_block(aggregate_job, ' - name: "📤 Upload combined results"') + assert "format('harbor-combined-{0}', steps.slug.outputs.slug)" in upload + assert ( + "format('harbor-combined-{0}-{1}', matrix.category, steps.slug.outputs.slug)" + in upload + ) + + def test_chart_publishers_are_serialized_and_replace_rerun_assets() -> None: """Protect the shared branch from concurrent pushes and stale rerun files.""" publishers = [ @@ -556,6 +557,74 @@ def test_override_inputs_warn_against_mutable_or_credentialed_sources() -> None: assert descriptions[0] == descriptions[1] +def test_harbor_run_accepts_flat_matrix_and_derives_parallel_pool() -> None: + """Wire a flat per-model matrix through prep without losing the single-dataset path.""" + workflow = HARBOR_WORKFLOW.read_text() + call_inputs = _indented_block(workflow, " inputs:") + assert 'flat_matrix:' in call_inputs + assert 'max_parallel:' in call_inputs + flat_matrix_input = _indented_block(call_inputs, " flat_matrix:") + assert 'default: ""' in flat_matrix_input + max_parallel_input = _indented_block(call_inputs, " max_parallel:") + assert 'default: "0"' in max_parallel_input + + prep_job = _indented_block(workflow, " prep:") + assert ( + "matrix: ${{ steps.resolve-matrix.outputs.matrix }}" in prep_job + ) + assert ( + "effective_max_parallel: ${{ steps.resolve-matrix.outputs.effective_max_parallel }}" + in prep_job + ) + expand_step = _indented_block(prep_job, ' - name: "🔀 Expand matrix by shard"') + assert "if: ${{ inputs.flat_matrix == '' }}" in expand_step + + resolve_step = _indented_block(prep_job, ' - name: "🧮 Resolve matrix + parallel pool"') + assert 'FLAT_MATRIX: ${{ inputs.flat_matrix }}' in resolve_step + assert 'MAX_PARALLEL: ${{ inputs.max_parallel }}' in resolve_step + assert 'SHARD_PARALLEL: ${{ inputs.shard_parallel }}' in resolve_step + assert 'if [ -n "$FLAT_MATRIX" ]; then' in resolve_step + assert 'matrix="$FLAT_MATRIX"' in resolve_step + assert 'echo "matrix=$matrix"' in resolve_step + assert ( + 'if [[ "$MAX_PARALLEL" =~ ^[0-9]+$ ]] && [ "$MAX_PARALLEL" -gt 0 ]; then' + in resolve_step + ) + assert 'effective_max_parallel="$MAX_PARALLEL"' in resolve_step + assert 'effective_max_parallel="$SHARD_PARALLEL"' in resolve_step + assert 'echo "effective_max_parallel=$effective_max_parallel"' in resolve_step + + harbor_job = _indented_block(workflow, " harbor:") + strategy = _indented_block(harbor_job, " strategy:") + assert ( + "max-parallel: ${{ fromJson(needs.prep.outputs.effective_max_parallel) }}" + in strategy + ) + + job_env = _indented_block(harbor_job, " env:") + assert ( + "HARBOR_DATASET: ${{ matrix.dataset || inputs.dataset || 'terminal-bench/terminal-bench-2' }}" + in job_env + ) + assert ( + "HARBOR_DATASET_PATH: ${{ matrix.dataset_path || inputs.dataset_path }}" + in job_env + ) + assert ( + "HARBOR_AGENT_IMPL: ${{ matrix.agent_impl || inputs.agent_impl }}" in job_env + ) + assert ( + "HARBOR_INCLUDE_TASKS: ${{ matrix.include_tasks || inputs.include_tasks }}" + in job_env + ) + assert ( + "HARBOR_N_SHARDS: ${{ matrix.n_shards || needs.prep.outputs.n_shards || '1' }}" + in job_env + ) + assert "HARBOR_CATEGORY: ${{ matrix.category || inputs.category }}" in job_env + assert "HARBOR_SHARD_INDEX: ${{ matrix.shard }}" in job_env + + def test_evals_ci_filter_includes_unified_workflows() -> None: """Run evals CI when either unified workflow changes in isolation.""" workflow = CI_WORKFLOW.read_text() diff --git a/.github/scripts/test_validate_harbor_limits.py b/.github/scripts/test_validate_harbor_limits.py index cfbcc4a057b..c5beaf369c9 100644 --- a/.github/scripts/test_validate_harbor_limits.py +++ b/.github/scripts/test_validate_harbor_limits.py @@ -15,12 +15,13 @@ REPO_ROOT = Path(__file__).resolve().parents[2] SCRIPT = REPO_ROOT / ".github" / "scripts" / "validate_harbor_limits.py" +UNIFIED_PREP_SCRIPT = REPO_ROOT / ".github" / "scripts" / "unified_prep.py" -def _load() -> ModuleType: - spec = importlib.util.spec_from_file_location("gha_validate_harbor_limits", SCRIPT) +def _load(path: Path, name: str) -> ModuleType: + spec = importlib.util.spec_from_file_location(name, path) if spec is None or spec.loader is None: - msg = f"Could not load module spec for {SCRIPT}" + msg = f"Could not load module spec for {path}" raise AssertionError(msg) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) @@ -29,7 +30,12 @@ def _load() -> ModuleType: @pytest.fixture(scope="module") def mod() -> ModuleType: - return _load() + return _load(SCRIPT, "gha_validate_harbor_limits") + + +@pytest.fixture(scope="module") +def unified_prep() -> ModuleType: + return _load(UNIFIED_PREP_SCRIPT, "gha_unified_prep") def _one_model(name: str = "openai:gpt-5.4") -> list[dict]: @@ -37,34 +43,39 @@ def _one_model(name: str = "openai:gpt-5.4") -> list[dict]: def test_single_model_at_caps_is_valid(mod: ModuleType) -> None: - """One model, n_shards == 10, concurrency == 4 (the documented maximum) passes.""" - assert mod.validate_limits(_one_model(), mod.MAX_SHARDS, mod.MAX_CONCURRENCY) == [] + """One model, n_shards at the shard cap, concurrency at its own cap, passes.""" + assert ( + mod.validate_limits( + _one_model(), mod.shard_matrix.MAX_SHARDS, mod.MAX_CONCURRENCY, 1 + ) + == [] + ) def test_zero_models_rejected(mod: ModuleType) -> None: - errors = mod.validate_limits([], 1, 1) + errors = mod.validate_limits([], 1, 1, 1) assert any("single model" in e for e in errors) def test_two_models_rejected_and_names_reported(mod: ModuleType) -> None: models = [{"model": "openai:gpt-5.4"}, {"model": "anthropic:claude-sonnet-4-6"}] - errors = mod.validate_limits(models, 1, 1) + errors = mod.validate_limits(models, 1, 1, 1) assert any("single model" in e for e in errors) # The offending model names are surfaced so the failure is self-diagnosing. assert any("anthropic:claude-sonnet-4-6" in e for e in errors) def test_n_shards_over_cap_rejected(mod: ModuleType) -> None: - errors = mod.validate_limits(_one_model(), mod.MAX_SHARDS + 1, 1) + errors = mod.validate_limits(_one_model(), mod.shard_matrix.MAX_SHARDS + 1, 1, 1) assert any("n_shards" in e for e in errors) - # Boundary: exactly the cap is allowed. - assert mod.validate_limits(_one_model(), mod.MAX_SHARDS, 1) == [] + # Boundary: exactly the cap (200, from shard_matrix.MAX_SHARDS) is allowed. + assert mod.validate_limits(_one_model(), mod.shard_matrix.MAX_SHARDS, 1, 1) == [] def test_concurrency_over_cap_rejected(mod: ModuleType) -> None: - errors = mod.validate_limits(_one_model(), 1, mod.MAX_CONCURRENCY + 1) + errors = mod.validate_limits(_one_model(), 1, mod.MAX_CONCURRENCY + 1, 1) assert any("concurrency" in e for e in errors) - assert mod.validate_limits(_one_model(), 1, mod.MAX_CONCURRENCY) == [] + assert mod.validate_limits(_one_model(), 1, mod.MAX_CONCURRENCY, 1) == [] @pytest.mark.parametrize("bad", ["0", "-1", "abc", "", " ", "1.5"]) @@ -77,6 +88,62 @@ def test_parse_positive_accepts_valid(mod: ModuleType) -> None: assert mod.parse_positive("n_shards", " 7 ") == 7 +def test_derive_shard_parallel_saturates_pool_and_clamps_to_n_shards( + mod: ModuleType, +) -> None: + # Packed shards can use all 4 slots; 40 // 4 = 10, under n_shards=100. + assert mod.derive_shard_parallel(concurrency=4, rollouts=3, n_shards=100) == 10 + # Same concurrency/rollouts, but n_shards=5 clamps the pool down to 5. + assert mod.derive_shard_parallel(concurrency=4, rollouts=3, n_shards=5) == 5 + # concurrency 1 allows 40 shard jobs, using the full budget. + assert mod.derive_shard_parallel(concurrency=1, rollouts=3, n_shards=100) == 40 + + +def test_derive_shard_parallel_uses_concurrency_when_rollouts_are_lower( + mod: ModuleType, +) -> None: + """Multiple tasks let a shard fill concurrency beyond one task's rollouts.""" + pool = mod.derive_shard_parallel(concurrency=4, rollouts=2, n_shards=100) + assert pool == 10 + assert pool * 4 == mod.MAX_TASKS_PER_MODEL + + +def test_derive_shard_parallel_unchanged_at_todays_n_shards_10(mod: ModuleType) -> None: + """No-change property: at n_shards=10 with today's typical inputs, the + derived shard_parallel equals n_shards itself — identical to the current + (undifferentiated) behavior of passing n_shards straight through. + """ + assert mod.derive_shard_parallel(concurrency=4, rollouts=3, n_shards=10) == 10 + assert mod.derive_shard_parallel(concurrency=4, rollouts=4, n_shards=10) == 10 + + +@pytest.mark.parametrize( + ("concurrency", "rollouts", "n_shards"), + [ + (4, 3, 100), + (4, 3, 10), + (4, 4, 10), + (1, 3, 100), + (4, 2, 100), + (1, 3, 8), + (4, 3, 5), + (2, 5, 34), + ], +) +def test_derive_shard_parallel_matches_unified_prep_derive_pool( + mod: ModuleType, + unified_prep: ModuleType, + concurrency: int, + rollouts: int, + n_shards: int, +) -> None: + """Drift guard: pins this module's derivation to unified_prep.derive_pool's + single-model max_parallel so the two formulas can't silently diverge. + """ + expected = unified_prep.derive_pool(concurrency, rollouts, n_shards, 1)[0] + assert mod.derive_shard_parallel(concurrency, rollouts, n_shards) == expected + + def test_main_exits_nonzero_on_multiple_models( mod: ModuleType, monkeypatch: pytest.MonkeyPatch ) -> None: @@ -84,6 +151,7 @@ def test_main_exits_nonzero_on_multiple_models( monkeypatch.setenv("MODEL_MATRIX", json.dumps(matrix)) monkeypatch.setenv("N_SHARDS", "10") monkeypatch.setenv("CONCURRENCY", "4") + monkeypatch.setenv("ROLLOUTS", "3") with pytest.raises(SystemExit) as exc: mod.main() assert exc.value.code not in (0, None) @@ -95,16 +163,34 @@ def test_main_exits_nonzero_on_bad_shards( monkeypatch.setenv("MODEL_MATRIX", json.dumps({"include": [{"model": "a:1"}]})) monkeypatch.setenv("N_SHARDS", "0") monkeypatch.setenv("CONCURRENCY", "4") + monkeypatch.setenv("ROLLOUTS", "3") with pytest.raises(SystemExit) as exc: mod.main() assert exc.value.code not in (0, None) -def test_main_succeeds_for_valid_single_model( +def test_main_exits_nonzero_on_bad_rollouts( mod: ModuleType, monkeypatch: pytest.MonkeyPatch ) -> None: monkeypatch.setenv("MODEL_MATRIX", json.dumps({"include": [{"model": "a:1"}]})) monkeypatch.setenv("N_SHARDS", "10") monkeypatch.setenv("CONCURRENCY", "4") + monkeypatch.setenv("ROLLOUTS", "0") + with pytest.raises(SystemExit) as exc: + mod.main() + assert exc.value.code not in (0, None) + + +def test_main_succeeds_for_valid_single_model( + mod: ModuleType, monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + monkeypatch.setenv("MODEL_MATRIX", json.dumps({"include": [{"model": "a:1"}]})) + monkeypatch.setenv("N_SHARDS", "10") + monkeypatch.setenv("CONCURRENCY", "4") + monkeypatch.setenv("ROLLOUTS", "3") + github_output = tmp_path / "github_output.txt" + monkeypatch.setenv("GITHUB_OUTPUT", str(github_output)) # No SystemExit == success. mod.main() + # The derived shard_parallel is emitted for harbor.yml to consume. + assert "shard_parallel=10" in github_output.read_text() diff --git a/.github/scripts/unified_prep.py b/.github/scripts/unified_prep.py index bbe98110529..cd6c545f265 100644 --- a/.github/scripts/unified_prep.py +++ b/.github/scripts/unified_prep.py @@ -1,13 +1,21 @@ """Prep step for the unified multi-model Harbor evals orchestrator. Parses a free-form comma-separated model CSV, validates it via models.py, -buckets specs by provider, clamps shard_parallel to satisfy the two -concurrency invariants, maps each category to its Harbor dataset, and emits -per-provider matrices to GITHUB_OUTPUT. - -Concurrency invariants: - per model: concurrency * shard_parallel <= 40 - global: num_providers * shard_parallel <= 64 +maps each category to its Harbor dataset, and emits a per-model flat matrix +(one entry per shard, spanning every category) to GITHUB_OUTPUT. + +Pool sizing is derived by `derive_pool`, not clamped after the fact: given +`concurrency` (trials in flight per shard job), `max_parallel = +MAX_TASKS_PER_MODEL // concurrency` saturates the per-model 40-trial budget. +Using full concurrency is necessary because packed shards can contain multiple +tasks. `model_parallel = MAX_RUNNERS // max_parallel` bounds how many models +run at once so total runners stay within MAX_RUNNERS. Both invariants hold by +construction: + per model: concurrency * max_parallel <= MAX_TASKS_PER_MODEL (40) + global: model_parallel * max_parallel <= MAX_RUNNERS (80) +`total_job_guard` separately caps the total job count (n_models * shards +per model, post-pack) against a fixed budget so an oversized selection fails +fast instead of launching a firehose. """ from __future__ import annotations @@ -15,6 +23,7 @@ import json import os import sys +from typing import cast sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import lite_tasks # noqa: E402 (lite_tasks.py in same dir) @@ -22,7 +31,7 @@ import shard_matrix # noqa: E402 (shard_matrix.py in same dir) MAX_TASKS_PER_MODEL = 40 -MAX_RUNNERS = 64 +MAX_RUNNERS = 80 KNOWN_PROVIDERS = { "anthropic", @@ -55,32 +64,50 @@ }, } -DEFAULT_N_SHARDS = {"autonomous": 10, "conversation": 3, "context": 3} - -DEEPAGENT_IMPLS = {"bare", "dcode"} -"""Deep-agent harnesses eligible for the `agent_impl` override.""" +# Harnesses selectable for the code categories (autonomous, context) via the +# `agent_impl` input. Conversation is always tau3 and is never overridden. +CODE_AGENT_IMPLS = {"dcode", "bare"} +# Harness used when the `agent_impl` input (UNIFIED_AGENT_IMPL) is unset or blank. DEFAULT_AGENT_IMPL = "bare" -"""Deep-agent harness used when `UNIFIED_AGENT_IMPL` is unset or blank.""" -KNOWN_AGENT_IMPLS = DEEPAGENT_IMPLS | {"tau3"} -"""Every harness a category may pin (deep-agent harnesses plus `tau3`).""" +# Every harness a category may pin in CATEGORY_MAP (code harnesses plus tau3). +KNOWN_AGENT_IMPLS = CODE_AGENT_IMPLS | {"tau3"} + +# A typo in a CATEGORY_MAP `agent_impl` (e.g. "bear") would silently make that +# category ineligible for the override and route it to a nonexistent harness, so +# validate at import. raise (not assert): asserts are stripped under `python -O`. +if not all(cm["agent_impl"] in KNOWN_AGENT_IMPLS for cm in CATEGORY_MAP.values()): + raise RuntimeError( + f"every CATEGORY_MAP agent_impl must be one of {sorted(KNOWN_AGENT_IMPLS)}" + ) +if DEFAULT_AGENT_IMPL not in CODE_AGENT_IMPLS: + raise RuntimeError(f"DEFAULT_AGENT_IMPL must be one of {sorted(CODE_AGENT_IMPLS)}") # Run profiles: "full" = every task in each category; "lite" = the frozen # high-signal subset from lite_tasks.py (fewer tasks, full rollouts). PROFILES = {"full", "lite"} -# A typo in a CATEGORY_MAP `agent_impl` (e.g. "bear") would silently make that -# category ineligible for the override *and* run it on a nonexistent harness. -# Fail loudly at import instead. -assert all(cm["agent_impl"] in KNOWN_AGENT_IMPLS for cm in CATEGORY_MAP.values()), ( - f"every CATEGORY_MAP agent_impl must be one of {sorted(KNOWN_AGENT_IMPLS)}" -) -# The default must itself be a selectable deep-agent harness, otherwise every -# default run (UNIFIED_AGENT_IMPL unset) would fail validation in main(). -assert DEFAULT_AGENT_IMPL in DEEPAGENT_IMPLS, ( - f"DEFAULT_AGENT_IMPL must be one of {sorted(DEEPAGENT_IMPLS)}" -) +TOTAL_JOB_BUDGET = 400 + + +def total_job_guard(n_models: int, shards_per_model: int) -> None: + """Fail when the flat matrix would generate too many total jobs. + + Each model emits `shards_per_model` shard jobs (already packed to at most + `shard_matrix.MAX_SHARDS`), so the run launches n_models * shards_per_model + jobs. GitHub-hosted Actions become unreliable well before that count needs + to be large, so cap it and point at the worker-pool escalation instead of + silently launching a firehose. + """ + total = n_models * shards_per_model + if total > TOTAL_JOB_BUDGET: + raise SystemExit( + f"Flat matrix would generate ~{total} jobs " + f"({n_models} models x ~{shards_per_model} shards), over " + f"TOTAL_JOB_BUDGET={TOTAL_JOB_BUDGET}. Reduce the model set or task " + "count, or move to a worker pool orchestrator (see the flat-pool spec)." + ) def parse_int_input( @@ -121,107 +148,118 @@ def provider_of(spec: str, known: set[str] = KNOWN_PROVIDERS) -> str: return prefix if prefix in known else "other" -def clamp_shard_parallel(requested: int, num_providers: int, concurrency: int) -> int: - sp = min( - requested, - MAX_RUNNERS // max(num_providers, 1), - MAX_TASKS_PER_MODEL // max(concurrency, 1), - ) - return max(sp, 1) +def derive_pool( + concurrency: int, rollouts: int, n_shards: int, n_models: int +) -> tuple[int, int]: + """Derive (max_parallel, model_parallel) from the requested run limits. + A packed shard can run multiple tasks and therefore use its full + `concurrency` even when `rollouts` is lower. `max_parallel` saturates the + per-model 40-trial budget; `model_parallel` bounds how many models run at + once so total runners stay within `MAX_RUNNERS`. `rollouts` remains in the + signature for compatibility with callers that supply all run limits. + """ + del rollouts + max_parallel = max(1, min(MAX_TASKS_PER_MODEL // max(1, concurrency), n_shards)) + model_parallel = max(1, min(MAX_RUNNERS // max_parallel, n_models)) + return max_parallel, model_parallel -def build_provider_matrices( - models_list: list[str], - categories: list[str], - shard_parallel: int, - n_shards_by_cat: dict[str, int], - *, - agent_impl: str | None = None, - profile: str = "full", -) -> dict[str, list[dict]]: - """Cross-product models and categories into per-provider matrix entries. - Args: - models_list: Resolved `provider:model` specs. - categories: Capability categories to run (keys of `CATEGORY_MAP`). - shard_parallel: Parallel shards per `(model, category)` leaf. - n_shards_by_cat: Shard count per category, falling back to - `DEFAULT_N_SHARDS`. - agent_impl: Deep-agent harness override. `None` keeps each category's - `CATEGORY_MAP` default; a value in `DEEPAGENT_IMPLS` replaces the - default only for categories already pinned to a deep-agent harness - (a category pinned to a non-deep-agent harness such as `tau3` is - never overridden). - profile: `"full"` runs every task in each category; `"lite"` runs the - frozen high-signal subset from `lite_tasks.py` (fewer tasks, full - rollouts) and shards it one task per shard. +def _load_tasks_json(path: str) -> dict[str, list[str]]: + """Load the full-profile task mapping from an enumerated JSON file.""" + msg = "UNIFIED_TASKS_JSON must be a JSON object mapping category names to lists of task strings" + try: + with open(path) as f: + raw: object = json.load(f) + except json.JSONDecodeError as exc: + raise SystemExit(msg) from exc + if not isinstance(raw, dict) or not all( + isinstance(category, str) + and isinstance(tasks, list) + and all(isinstance(task, str) for task in tasks) + for category, tasks in raw.items() + ): + raise SystemExit(msg) + return cast(dict[str, list[str]], raw) - Returns: - A mapping of provider to its list of matrix entries. - Raises: - ValueError: If `agent_impl` is neither `None` nor in `DEEPAGENT_IMPLS`. +def _allocate_shard_budgets(counts: dict[str, int], cap: int) -> dict[str, int]: + """Split `cap` shards across categories proportional to `counts`. + + Each category gets `max(1, cap * count // total)` shards. That floor + allocation can round up to more than `cap` in total when several small + categories each get bumped to the 1-shard floor, so any resulting excess is + trimmed one shard at a time from the currently-largest budget (ties broken + by category order) until the sum is exactly `<= cap`. """ - # Defense in depth for direct callers: main() validates UNIFIED_AGENT_IMPL, - # but this public helper must not silently route a run to an unknown harness. - if agent_impl and agent_impl not in DEEPAGENT_IMPLS: - msg = ( - f"agent_impl must be one of {sorted(DEEPAGENT_IMPLS)} or None, " - f"got {agent_impl!r}" + total = sum(counts.values()) + budgets = {cat: max(1, (cap * n) // total) for cat, n in counts.items()} + excess = sum(budgets.values()) - cap + while excess > 0: + shrinkable = [cat for cat, b in budgets.items() if b > 1] + if not shrinkable: + break + largest = max(shrinkable, key=lambda cat: budgets[cat]) + budgets[largest] -= 1 + excess -= 1 + return budgets + + +def build_flat_matrix( + model: str, + categories: list[str], + tasks_by_cat: dict[str, list[str]], + code_impl: str = DEFAULT_AGENT_IMPL, +) -> list[dict]: + """One flat matrix of single-`harbor run` shards spanning all categories. + + Each category's task list is packed into a per-category shard budget; each + group is one matrix entry carrying its own dataset and agent so the leaf's + max-parallel pool drains the mixed queue across category boundaries. + `provider` is retained only as an aggregation tag. + + The per-model total entry count is bounded by `shard_matrix.MAX_SHARDS`: + when the categories' combined task count fits under the cap, each category + packs 1 task/shard as usual. Above the cap, `MAX_SHARDS` is allocated across + the active categories proportional to their task counts (via + `_allocate_shard_budgets`) and each category is packed into its own budget, + so the sum across categories never exceeds `MAX_SHARDS`. + """ + prov = provider_of(model) + active_counts = { + cat: len(tasks_by_cat[cat]) for cat in categories if tasks_by_cat.get(cat) + } + total = sum(active_counts.values()) + if total > shard_matrix.MAX_SHARDS: + budgets = _allocate_shard_budgets(active_counts, shard_matrix.MAX_SHARDS) + else: + budgets = dict.fromkeys(active_counts, shard_matrix.MAX_SHARDS) + + entries: list[dict] = [] + for cat in categories: + cm = CATEGORY_MAP[cat] + # The override selects the code harness (bare/dcode); a category pinned + # to a non-code harness (tau3) is never overridden. + agent_impl = ( + code_impl if cm["agent_impl"] in CODE_AGENT_IMPLS else cm["agent_impl"] ) - raise ValueError(msg) - matrices: dict[str, list[dict]] = {} - for spec in models_list: - prov = provider_of(spec) - for cat in categories: - cm = CATEGORY_MAP[cat] - # The override selects the deep-agents harness; it never applies to a - # category pinned to a non-deep-agents harness (e.g. tau3). - resolved_impl = ( - agent_impl - if agent_impl and cm["agent_impl"] in DEEPAGENT_IMPLS - else cm["agent_impl"] + cat_budget = budgets.get(cat, shard_matrix.MAX_SHARDS) + for group in shard_matrix.pack_tasks(tasks_by_cat.get(cat, []), cat_budget): + entries.append( + { + "model": model, + "provider": prov, + "category": cat, + "dataset": cm["dataset"], + "dataset_path": cm["dataset_path"], + "agent_impl": agent_impl, + "include_tasks": " ".join(group), + "langsmith_dataset": "", + "n_shards": 1, + "shard": 0, + } ) - # `lite` runs a frozen high-signal subset (full rollouts, fewer tasks). - # One task per shard: `shard_parallel` (the leaf's matrix max-parallel) - # is the number of concurrent runner slots, and GitHub pulls the next - # single-task shard in the instant one finishes. That gives dynamic - # load-balancing across runners -- the long pole is the slowest single - # task, not a static bucket -- and scatters each task's image onto its - # own runner so heavy images never concentrate and blow the disk. - # Bounded by shard_matrix.MAX_SHARDS (and its 256-job matrix guard). - include = lite_tasks.include_tasks(cat) if profile == "lite" else "" - n_shards = n_shards_by_cat.get(cat, DEFAULT_N_SHARDS[cat]) - if include: - n_tasks = len(include.split()) - n_shards = min(n_tasks, shard_matrix.MAX_SHARDS) - entry = { - "model": spec, - "provider": prov, - "category": cat, - "dataset": cm["dataset"], - "dataset_path": cm["dataset_path"], - "agent_impl": resolved_impl, - "include_tasks": include, - # Empty: the leaf derives the canonical shared dataset name per - # category (harbor-index/harbor-index-1.0, tau3-subset, local/...) - # and a stable per-run experiment name, so a model's shards attach - # to the one shared dataset. NOTE: consolidating those shards into a - # SINGLE experiment per model needs harbor > 0.1.1. Released - # harbor-langsmith==0.1.1 suffixes every shard's experiment with - # "-{job.id[:8]}" (one experiment per shard); harbor main honors the - # explicit experiment_name _harbor_run.yml sets and reuses the - # session across shards. Until a fixed release ships, set the - # `harbor_package_override` input to a harbor build with that fix, - # e.g. commit af2e8629e95c2e9f487f7a2ba87c1e25b531a55b (see that - # input's description for the full pip specs). The GH-aggregated - # unified_summary is the cross-model surface regardless. - "langsmith_dataset": "", - "n_shards": n_shards, - "shard_parallel": shard_parallel, - } - matrices.setdefault(prov, []).append(entry) - return matrices + return entries def _emit(github_output: str | None, outputs: dict[str, object]) -> None: @@ -255,25 +293,17 @@ def main(argv: list[str] | None = None) -> int: minimum=1, maximum=MAX_TASKS_PER_MODEL, ) - requested_sp = parse_int_input( - "UNIFIED_SHARD_PARALLEL", - os.environ.get("UNIFIED_SHARD_PARALLEL", "10"), - minimum=1, + rollouts = parse_int_input( + "UNIFIED_ROLLOUTS", os.environ.get("UNIFIED_ROLLOUTS", "3"), minimum=1 ) - n_shards_by_cat = { - category: parse_int_input( - f"UNIFIED_N_SHARDS_{category.upper()}", - os.environ.get(f"UNIFIED_N_SHARDS_{category.upper()}", str(default)), - minimum=1, - maximum=shard_matrix.MAX_SHARDS, - ) - for category, default in DEFAULT_N_SHARDS.items() - } - agent_impl = ( - os.environ.get("UNIFIED_AGENT_IMPL", DEFAULT_AGENT_IMPL).strip() - or DEFAULT_AGENT_IMPL - ) + # Empty defaults to the bare create_deep_agent harness for the code categories. + code_impl = os.environ.get("UNIFIED_AGENT_IMPL", "").strip() or DEFAULT_AGENT_IMPL + if code_impl not in CODE_AGENT_IMPLS: + raise SystemExit( + f"UNIFIED_AGENT_IMPL must be one of {sorted(CODE_AGENT_IMPLS)}, " + f"got {code_impl!r}" + ) profile = os.environ.get("UNIFIED_PROFILE", "").strip() or "full" if profile not in PROFILES: @@ -288,57 +318,98 @@ def main(argv: list[str] | None = None) -> int: raise SystemExit( f"Unknown categor(y/ies): {unknown}. Valid: {sorted(CATEGORY_MAP)}" ) - if agent_impl not in DEEPAGENT_IMPLS: - raise SystemExit( - f"UNIFIED_AGENT_IMPL must be one of {sorted(DEEPAGENT_IMPLS)}, " - f"got {agent_impl!r}" - ) # Validate + dedupe the free-form CSV via the shared resolver. try: model_specs = models._resolve_models("harbor", selection) except ValueError as exc: raise SystemExit(str(exc)) - providers_present: list[str] = [] - seen = set() - for spec in model_specs: - p = provider_of(spec) - if p not in seen: - seen.add(p) - providers_present.append(p) + # Resolve the per-category task lists. + if profile == "lite": + tasks_by_cat = {c: list(lite_tasks.LITE_TASKS.get(c, [])) for c in categories} + else: + tasks_json = os.environ.get("UNIFIED_TASKS_JSON", "").strip() + if not tasks_json: + raise SystemExit( + "full profile requires UNIFIED_TASKS_JSON (enumerated tasks)." + ) + tasks_by_cat = _load_tasks_json(tasks_json) - shard_parallel = clamp_shard_parallel( - requested_sp, len(providers_present), concurrency + empty_categories = [ + category for category in categories if not tasks_by_cat.get(category) + ] + if empty_categories: + raise SystemExit( + f"No tasks resolved for requested categor(y/ies): {empty_categories}" + ) + + n_models = len(model_specs) + est_tasks = sum(len(tasks_by_cat[category]) for category in categories) + # Jobs launched per model = the packed flat-matrix entry count, not the raw + # task count: build_flat_matrix groups tasks into at most MAX_SHARDS shards, + # and ceil-division packing usually yields fewer (e.g. 120+120+40 tasks pack + # to 140 entries, not 200). The count is model-independent, so measure it + # once on the first model and guard on the real emitted job total. Guarding + # on the raw task count would reject valid multi-model full runs whose packed + # total is within budget (e.g. 3 models x 260 tasks -> 3 x 130 = 390 <= 400). + first_matrix = build_flat_matrix( + model_specs[0], categories, tasks_by_cat, code_impl ) - # clamp guarantees both invariants; assert as a safety net. - assert concurrency * shard_parallel <= MAX_TASKS_PER_MODEL - assert len(providers_present) * shard_parallel <= MAX_RUNNERS - - matrices = build_provider_matrices( - model_specs, - categories, - shard_parallel, - n_shards_by_cat, - agent_impl=agent_impl, - profile=profile, + missing_matrix_categories = [ + category + for category in categories + if not any(entry["category"] == category for entry in first_matrix) + ] + if missing_matrix_categories: + raise SystemExit( + "No matrix entries resolved for requested categor(y/ies): " + f"{missing_matrix_categories}" + ) + if not first_matrix: + raise SystemExit("Unified eval matrix is empty.") + packed_per_model = len(first_matrix) + total_job_guard(n_models, packed_per_model) + + # n_shards for the pool = number of single-task shards (pre-pack); derive pool. + n_shards = est_tasks + max_parallel, model_parallel = derive_pool( + concurrency, rollouts, n_shards, n_models ) outputs: dict[str, object] = { - "effective_shard_parallel": str(shard_parallel), # The expected grid, so the combiner can flag missing/incomplete leaves # instead of silently ranking a model on fewer categories. "models": model_specs, "categories": categories, + "max_parallel": str(max_parallel), + "model_parallel": str(model_parallel), } - for prov in sorted(KNOWN_PROVIDERS | {"other"}): - include = matrices.get(prov, []) - outputs[f"{prov}_has_models"] = "true" if include else "false" - if include: - outputs[f"{prov}_matrix"] = {"include": include} - + # One eval_matrix entry per model, each carrying its own pre-serialized + # flat matrix. GitHub job outputs are statically declared, so a single + # matrixable output (rather than one `model__matrix` output per + # model) is what lets the `eval` job's `strategy.matrix` scale to an + # arbitrary model count. + eval_include = [ + { + "model": m, + "slug": _slug(m), + "flat_matrix": json.dumps( + {"include": build_flat_matrix(m, categories, tasks_by_cat, code_impl)}, + separators=(",", ":"), + ), + } + for m in model_specs + ] + outputs["eval_matrix"] = {"include": eval_include} _emit(os.environ.get("GITHUB_OUTPUT"), outputs) return 0 +def _slug(model: str) -> str: + import re + + return re.sub(r"[^A-Za-z0-9._-]", "-", model.replace("/", "-").replace(":", "-")) + + if __name__ == "__main__": raise SystemExit(main()) diff --git a/.github/scripts/validate_harbor_limits.py b/.github/scripts/validate_harbor_limits.py index 8515f6ed569..656de615629 100644 --- a/.github/scripts/validate_harbor_limits.py +++ b/.github/scripts/validate_harbor_limits.py @@ -6,9 +6,19 @@ * the resolved model set is not a single model (a model group like `all`/`set0` or a comma-separated `models_override` resolves to more than one), or -* the per-run limits are exceeded: `n_shards <= 10`, `concurrency <= 4`. With a - single model their product bounds concurrent sandboxes to `10 * 4 = 40`; the - caps are checked independently (there is no separate product check). +* the per-run limits are exceeded: `n_shards <= shard_matrix.MAX_SHARDS` (200), + `concurrency <= 4`. `n_shards` does not bound concurrency directly — it may + be set as high as the task count (one task per shard) for dynamic dispatch. + Instead, the derived `shard_parallel` (the pool the shards drain through) is + what's bounded, alongside the per-shard concurrent-trial count: `shard_parallel + * concurrency <= 40`. + +This module owns the derivation of `shard_parallel` for the single-model case: +`shard_parallel = min(MAX_TASKS_PER_MODEL // concurrency, n_shards)`, mirroring +`unified_prep.derive_pool` (pinned together by +`test_validate_harbor_limits.py`'s drift-guard test). `main()` emits it as +`shard_parallel=` to `$GITHUB_OUTPUT` for `harbor.yml` to pass straight +through to the leaf workflow's `shard_parallel` input. Mirrors `.github/scripts/shard_matrix.py` (import-by-path, stdlib only) so it is exercised by `test_validate_harbor_limits.py` under CI's @@ -22,8 +32,13 @@ import os import sys -MAX_SHARDS = 10 +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import shard_matrix # noqa: E402 (shard_matrix.py in same dir) + MAX_CONCURRENCY = 4 +# Per-model concurrent-sandbox budget the derived shard_parallel must respect +# alongside concurrency (mirrors unified_prep.MAX_TASKS_PER_MODEL). +MAX_TASKS_PER_MODEL = 40 class LimitError(Exception): @@ -42,7 +57,21 @@ def parse_positive(name: str, raw: str | None) -> int: return int(text) -def validate_limits(models: list, n_shards: int, concurrency: int) -> list[str]: +def derive_shard_parallel(concurrency: int, rollouts: int, n_shards: int) -> int: + """Derive the shard pool size the run job's shards drain through. + + Mirrors `unified_prep.derive_pool`'s `max_parallel` for a single model: + each shard job can use its full `concurrency` when it contains multiple + tasks, even when `rollouts` is lower. The pool saturates the per-model + `MAX_TASKS_PER_MODEL` (40) budget without exceeding `n_shards` itself. + """ + del rollouts + return max(1, min(MAX_TASKS_PER_MODEL // max(1, concurrency), n_shards)) + + +def validate_limits( + models: list, n_shards: int, concurrency: int, rollouts: int +) -> list[str]: """Return a list of human-readable violations (empty when the run is valid).""" errors: list[str] = [] if len(models) != 1: @@ -52,10 +81,26 @@ def validate_limits(models: list, n_shards: int, concurrency: int) -> list[str]: f"to {len(models)}: {names}. Pick exactly one model — model groups " "(all/set0/frontier/...) and comma-separated overrides are not accepted." ) - if n_shards > MAX_SHARDS: - errors.append(f"n_shards={n_shards} exceeds the cap of {MAX_SHARDS}") + if n_shards > shard_matrix.MAX_SHARDS: + errors.append( + f"n_shards={n_shards} exceeds the cap of {shard_matrix.MAX_SHARDS}" + ) if concurrency > MAX_CONCURRENCY: errors.append(f"concurrency={concurrency} exceeds the cap of {MAX_CONCURRENCY}") + + # Defensive, not user-facing: derive_shard_parallel's floor division makes + # this true by construction (never trips). A shard may contain multiple + # tasks, so its peak is the full concurrency even when each individual task + # has fewer rollouts. An explicit raise (never a bare `assert`, which + # `python -O` strips) makes a formula regression fail loudly instead of + # silently over-provisioning sandboxes. + shard_parallel = derive_shard_parallel(concurrency, rollouts, n_shards) + if shard_parallel * concurrency > MAX_TASKS_PER_MODEL: + msg = ( + f"internal error: derived shard_parallel={shard_parallel} * " + f"concurrency={concurrency} exceeds {MAX_TASKS_PER_MODEL}" + ) + raise AssertionError(msg) return errors @@ -65,19 +110,29 @@ def main() -> None: models = json.loads(os.environ["MODEL_MATRIX"]).get("include", []) n_shards = parse_positive("n_shards", os.environ.get("N_SHARDS")) concurrency = parse_positive("concurrency", os.environ.get("CONCURRENCY")) + rollouts = parse_positive("rollouts", os.environ.get("ROLLOUTS")) except LimitError as exc: print(f"::error::{exc}") # noqa: T201 sys.exit(1) - errors = validate_limits(models, n_shards, concurrency) + errors = validate_limits(models, n_shards, concurrency, rollouts) for err in errors: print(f"::error::{err}") # noqa: T201 if errors: sys.exit(1) + + shard_parallel = derive_shard_parallel(concurrency, rollouts, n_shards) print( # noqa: T201 f"OK: single model ({models[0].get('model')}), n_shards={n_shards} " - f"(<= {MAX_SHARDS}), concurrency={concurrency} (<= {MAX_CONCURRENCY})" + f"(<= {shard_matrix.MAX_SHARDS}), concurrency={concurrency} " + f"(<= {MAX_CONCURRENCY}), derived shard_parallel={shard_parallel}" ) + github_output = os.environ.get("GITHUB_OUTPUT") + if github_output: + with open(github_output, "a") as f: # noqa: PTH123 + f.write(f"shard_parallel={shard_parallel}\n") + else: + print(f"shard_parallel={shard_parallel}") # noqa: T201 if __name__ == "__main__": diff --git a/.github/workflows/_harbor_run.yml b/.github/workflows/_harbor_run.yml index 2030938156e..892606ec0ac 100644 --- a/.github/workflows/_harbor_run.yml +++ b/.github/workflows/_harbor_run.yml @@ -31,6 +31,19 @@ on: shard_parallel: type: string default: "10" + flat_matrix: + # A pre-expanded `{"include":[...]}` job matrix (one entry per + # model/category/shard leaf), e.g. from a unified multi-model dispatch. + # When non-empty, `prep` passes it through verbatim instead of running + # `shard_matrix.py`'s single-dataset expansion. + type: string + default: "" + max_parallel: + # Explicit size of the harbor job's parallel runner pool, for a caller + # driving `flat_matrix` across several models/categories at once. 0 + # falls back to `shard_parallel`, the single-dataset pool size. + type: string + default: "0" concurrency: type: string default: "4" @@ -89,16 +102,28 @@ jobs: runs-on: ubuntu-latest environment: evals outputs: - matrix: ${{ steps.shard-matrix.outputs.matrix }} + matrix: ${{ steps.resolve-matrix.outputs.matrix }} # Effective shard count after capping to the selectable work (<= n_shards). # The harbor job reads this so its partition matches the emitted matrix. - n_shards: ${{ steps.shard-matrix.outputs.n_shards }} + n_shards: ${{ steps.resolve-matrix.outputs.n_shards }} + # Size of the harbor job's parallel runner pool: an explicit max_parallel + # override when the caller supplied one, else the per-leaf shard_parallel. + effective_max_parallel: ${{ steps.resolve-matrix.outputs.effective_max_parallel }} + # One entry per category to aggregate: a single entry for the plain + # single-dataset call, or (on a flat multi-category run) one entry per + # distinct category present in flat_matrix. The `aggregate` job matrixes + # over this. + aggregate_matrix: ${{ steps.agg-matrix.outputs.aggregate_matrix }} steps: - name: "📋 Checkout Code" uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - name: "🔀 Expand matrix by shard" id: shard-matrix + # Only the single-dataset path needs this expansion; a caller supplying + # flat_matrix has already pre-expanded its own model/category/shard + # entries (see the passthrough step below). + if: ${{ inputs.flat_matrix == '' }} # This leaf evaluates exactly ONE model (inputs.model), so the model # matrix is a single-entry include (no models.py/validate_harbor_limits # step needed here). Cross-products it with the shard axis, caps the @@ -111,6 +136,103 @@ jobs: N_TASKS: ${{ inputs.n_tasks }} run: python .github/scripts/shard_matrix.py + - name: "🧮 Resolve matrix + parallel pool" + id: resolve-matrix + # Picks the flat_matrix passthrough or the shard-matrix expansion + # (whichever ran) and derives the parallel pool, all in bash so the + # fallback logic isn't an inline `fromJson`/ternary expression. + env: + FLAT_MATRIX: ${{ inputs.flat_matrix }} + SHARD_MATRIX: ${{ steps.shard-matrix.outputs.matrix }} + SHARD_N_SHARDS: ${{ steps.shard-matrix.outputs.n_shards }} + MAX_PARALLEL: ${{ inputs.max_parallel }} + SHARD_PARALLEL: ${{ inputs.shard_parallel }} + run: | + if [ -n "$FLAT_MATRIX" ]; then + matrix="$FLAT_MATRIX" + else + matrix="$SHARD_MATRIX" + fi + { + echo "matrix=$matrix" + echo "n_shards=$SHARD_N_SHARDS" + } >> "$GITHUB_OUTPUT" + + if [[ "$MAX_PARALLEL" =~ ^[0-9]+$ ]] && [ "$MAX_PARALLEL" -gt 0 ]; then + effective_max_parallel="$MAX_PARALLEL" + else + effective_max_parallel="$SHARD_PARALLEL" + fi + echo "effective_max_parallel=$effective_max_parallel" >> "$GITHUB_OUTPUT" + + - name: "🗂️ Derive aggregate matrix" + id: agg-matrix + # One aggregate_shards.py invocation per category: the single-dataset + # path (flat_matrix empty) emits exactly one entry; a flat + # multi-category run emits one entry per distinct category present in + # flat_matrix, with expected_shards = the number of flat_matrix entries + # carrying that category (each entry is one shard job). + env: + FLAT_MATRIX: ${{ inputs.flat_matrix }} + SINGLE_CATEGORY: ${{ inputs.category }} + SINGLE_DATASET: ${{ inputs.dataset }} + SINGLE_EXPECTED_SHARDS: ${{ steps.shard-matrix.outputs.n_shards }} + run: | + python - <<'PY' + import json + import os + import re + import sys + + flat_matrix = os.environ.get("FLAT_MATRIX", "").strip() + category_re = re.compile(r"^[A-Za-z0-9_.-]+$") + + if flat_matrix: + try: + data = json.loads(flat_matrix) + except json.JSONDecodeError as exc: + sys.exit(f"::error::Invalid flat_matrix JSON: {exc}") + by_category: dict[str, dict] = {} + for entry in data.get("include", []): + category = entry.get("category") + if not category or not category_re.match(str(category)): + sys.exit( + f"::error::Invalid or missing category in flat_matrix entry: {category!r}" + ) + info = by_category.setdefault(category, {"count": 0, "dataset": None}) + info["count"] += 1 + if info["dataset"] is None: + info["dataset"] = entry.get("dataset") or entry.get("dataset_path") or "" + if not by_category: + sys.exit("::error::flat_matrix produced no categories to aggregate") + include = [ + { + "category": category, + "dataset": info["dataset"] or "", + "expected_shards": info["count"], + } + for category, info in sorted(by_category.items()) + ] + else: + raw_expected = os.environ.get("SINGLE_EXPECTED_SHARDS", "").strip() + include = [ + { + "category": os.environ.get("SINGLE_CATEGORY", ""), + "dataset": os.environ.get("SINGLE_DATASET", ""), + "expected_shards": int(raw_expected) if raw_expected.isdigit() else "", + } + ] + + matrix = {"include": include} + line = "aggregate_matrix=" + json.dumps(matrix, separators=(",", ":")) + github_output = os.environ.get("GITHUB_OUTPUT") + if github_output: + with open(github_output, "a") as fh: + fh.write(line + "\n") + else: + print(line) + PY + harbor: name: "📊 Evals - Harbor (${{ matrix.model }} / ${{ inputs.sandbox_env }} / ${{ inputs.agent_impl }})" needs: prep @@ -122,7 +244,7 @@ jobs: actions: read strategy: fail-fast: false - max-parallel: ${{ fromJson(inputs.shard_parallel) }} + max-parallel: ${{ fromJson(needs.prep.outputs.effective_max_parallel) }} matrix: ${{ fromJson(needs.prep.outputs.matrix) }} defaults: @@ -130,11 +252,11 @@ jobs: working-directory: libs/evals env: UV_NO_SYNC: "true" - HARBOR_DATASET: ${{ inputs.dataset || 'terminal-bench/terminal-bench-2' }} - HARBOR_DATASET_PATH: ${{ inputs.dataset_path }} + HARBOR_DATASET: ${{ matrix.dataset || inputs.dataset || 'terminal-bench/terminal-bench-2' }} + HARBOR_DATASET_PATH: ${{ matrix.dataset_path || inputs.dataset_path }} HARBOR_CONCURRENCY: ${{ inputs.concurrency }} HARBOR_N_TASKS: ${{ inputs.n_tasks }} - HARBOR_INCLUDE_TASKS: ${{ inputs.include_tasks }} + HARBOR_INCLUDE_TASKS: ${{ matrix.include_tasks || inputs.include_tasks }} HARBOR_ROLLOUTS_PER_TASK: ${{ inputs.rollouts }} HARBOR_N_RETRIES: ${{ inputs.n_retries || '0' }} HARBOR_AGENT_TIMEOUT_MULTIPLIER: ${{ inputs.agent_timeout_multiplier || '1.0' }} @@ -143,12 +265,17 @@ jobs: HARBOR_DISABLE_VERIFICATION: ${{ inputs.disable_verification || 'false' }} HARBOR_FORCE_BUILD: ${{ inputs.force_build || 'false' }} HARBOR_SHARD_INDEX: ${{ matrix.shard }} - # Effective shard count from prep (capped to selectable work), not the raw - # input — the partition must match the matrix or tasks would be dropped. - HARBOR_N_SHARDS: ${{ needs.prep.outputs.n_shards || '1' }} + # A flat_matrix entry carries its own (already-effective) n_shards; + # otherwise fall back to prep's effective shard count (capped to + # selectable work), not the raw input — the partition must match the + # matrix or tasks would be dropped. + HARBOR_N_SHARDS: ${{ matrix.n_shards || needs.prep.outputs.n_shards || '1' }} HARBOR_SANDBOX_ENV: ${{ inputs.sandbox_env }} - HARBOR_AGENT_IMPL: ${{ inputs.agent_impl }} + HARBOR_AGENT_IMPL: ${{ matrix.agent_impl || inputs.agent_impl }} HARBOR_MODEL: ${{ matrix.model }} + # Per-leaf category, so a multi-category flat_matrix run can be + # aggregated per category downstream. + HARBOR_CATEGORY: ${{ matrix.category || inputs.category }} HARBOR_LS_DATASET_OVERRIDE: ${{ inputs.langsmith_dataset }} HARBOR_JUDGE_MODELS: ${{ inputs.judge_models || 'gpt-5.6-luna' }} LANGSMITH_TRACING: "true" @@ -164,10 +291,11 @@ jobs: GOOGLE_API_KEY: ${{ startsWith(matrix.model, 'google_genai:') && secrets.GOOGLE_API_KEY || '' }} GROQ_API_KEY: ${{ startsWith(matrix.model, 'groq:') && secrets.GROQ_API_KEY || '' }} LANGSMITH_API_KEY: ${{ secrets.LANGSMITH_API_KEY }} - LANGSMITH_SANDBOX_API_KEY: ${{ inputs.sandbox_env == 'langsmith' && secrets.LANGSMITH_SANDBOX_API_KEY || '' }} NVIDIA_API_KEY: ${{ startsWith(matrix.model, 'nvidia:') && secrets.NVIDIA_API_KEY || '' }} OLLAMA_API_KEY: ${{ startsWith(matrix.model, 'ollama:') && secrets.OLLAMA_API_KEY || '' }} - OPENAI_API_KEY: ${{ (startsWith(matrix.model, 'openai:') || contains(inputs.dataset, 'tau3') || contains(inputs.dataset, 'harbor-index')) && secrets.OPENAI_API_KEY || '' }} + # The verifier's judge is always an OpenAI model (JUDGE_PROVIDER=openai), + # so this key is required regardless of the model under test. + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} OPENROUTER_API_KEY: ${{ startsWith(matrix.model, 'openrouter:') && secrets.OPENROUTER_API_KEY || '' }} XAI_API_KEY: ${{ startsWith(matrix.model, 'xai:') && secrets.XAI_API_KEY || '' }} run: | @@ -181,11 +309,7 @@ jobs: docker) ;; # No additional credentials needed langsmith) - # The sandbox authenticates with its own dedicated key (passed via - # --environment-kwarg below); tracing/datasets/results use - # LANGSMITH_API_KEY (required above). - [ -z "$LANGSMITH_SANDBOX_API_KEY" ] && missing+=("LANGSMITH_SANDBOX_API_KEY") - ;; + ;; # Uses LANGSMITH_API_KEY (already required above) *) echo "::error::Unknown sandbox environment: $HARBOR_SANDBOX_ENV" exit 1 @@ -310,10 +434,10 @@ jobs: "$GITHUB_WORKSPACE/libs/evals/deepagents_harbor/langgraph_project/langgraph.json" - name: "🗂️ Populate local dataset corpus" - if: ${{ inputs.dataset_path != '' }} + if: ${{ (matrix.dataset_path || inputs.dataset_path) != '' }} working-directory: libs/evals env: - HARBOR_DATASET_PATH: ${{ inputs.dataset_path }} + HARBOR_DATASET_PATH: ${{ matrix.dataset_path || inputs.dataset_path }} # The per-task corpus is single-sourced (git-ignored) and regenerated from # the vendored copy so each task's build context has its files/ before # Harbor builds the task images. @@ -323,6 +447,27 @@ jobs: fi uv run python -m harbor_adapters.contextbench.main --populate "$HARBOR_DATASET_PATH" + - name: "🐳 Wait for the Docker daemon" + # GH-hosted runners intermittently have the Docker daemon not-yet-ready at + # job start; harbor's docker sandbox then hard-fails with "Docker daemon is + # not running", losing an otherwise-good shard. Wait it out (docker-sandbox + # only). No sudo/start: the codebase disallows privilege escalation in + # workflows, and this targets the startup race, not a dead daemon (which + # still fails the shard, but the aggregator no longer voids the scorecard + # for a single missing shard). + if: ${{ inputs.sandbox_env == 'docker' }} + run: | + for i in $(seq 1 60); do + if docker info >/dev/null 2>&1; then + echo "Docker daemon ready (after ${i} check(s))." + exit 0 + fi + sleep 2 + done + echo "::error::Docker daemon not ready after ~120s." + docker info || true + exit 1 + - name: "⚓ Run Harbor" env: ANTHROPIC_API_KEY: ${{ startsWith(matrix.model, 'anthropic:') && secrets.ANTHROPIC_API_KEY || '' }} @@ -331,10 +476,11 @@ jobs: GOOGLE_API_KEY: ${{ startsWith(matrix.model, 'google_genai:') && secrets.GOOGLE_API_KEY || '' }} GROQ_API_KEY: ${{ startsWith(matrix.model, 'groq:') && secrets.GROQ_API_KEY || '' }} LANGSMITH_API_KEY: ${{ secrets.LANGSMITH_API_KEY }} - LANGSMITH_SANDBOX_API_KEY: ${{ inputs.sandbox_env == 'langsmith' && secrets.LANGSMITH_SANDBOX_API_KEY || '' }} NVIDIA_API_KEY: ${{ startsWith(matrix.model, 'nvidia:') && secrets.NVIDIA_API_KEY || '' }} OLLAMA_API_KEY: ${{ startsWith(matrix.model, 'ollama:') && secrets.OLLAMA_API_KEY || '' }} - OPENAI_API_KEY: ${{ (startsWith(matrix.model, 'openai:') || contains(inputs.dataset, 'tau3') || contains(inputs.dataset, 'harbor-index')) && secrets.OPENAI_API_KEY || '' }} + # The verifier's judge is always an OpenAI model (JUDGE_PROVIDER=openai), + # so this key is required regardless of the model under test. + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} OPENROUTER_API_KEY: ${{ startsWith(matrix.model, 'openrouter:') && secrets.OPENROUTER_API_KEY || '' }} XAI_API_KEY: ${{ startsWith(matrix.model, 'xai:') && secrets.XAI_API_KEY || '' }} run: | @@ -381,6 +527,10 @@ jobs: echo "::error::Invalid n_retries (non-negative integer): $HARBOR_N_RETRIES" exit 1 fi + if ! [[ "$HARBOR_CATEGORY" =~ ^[A-Za-z0-9_.-]+$ ]]; then + echo "::error::Invalid Harbor category: $HARBOR_CATEGORY" + exit 1 + fi # Positive decimal only; reject all-zero (0, 0.0, ...) which would mean a 0s timeout. if ! [[ "$HARBOR_AGENT_TIMEOUT_MULTIPLIER" =~ ^[0-9]+(\.[0-9]+)?$ ]] || [[ "$HARBOR_AGENT_TIMEOUT_MULTIPLIER" =~ ^0+(\.0+)?$ ]]; then echo "::error::Invalid agent_timeout_multiplier (must be a positive decimal): $HARBOR_AGENT_TIMEOUT_MULTIPLIER" @@ -529,7 +679,9 @@ jobs: # shard's slice is legitimately empty. Upload a marker so aggregation # can distinguish this successful no-op from a missing shard artifact. mkdir -p harbor-jobs/terminal-bench - touch "harbor-jobs/terminal-bench/empty-shard-$HARBOR_SHARD_INDEX" + # Category-scoped so a flat multi-category run's independently-sharded + # categories can't collide on the same shard index's marker name. + touch "harbor-jobs/terminal-bench/empty-shard-${HARBOR_CATEGORY}-${HARBOR_SHARD_INDEX}" echo "Shard $HARBOR_SHARD_INDEX/$HARBOR_N_SHARDS has no tasks (selection smaller than shard count); skipping." echo "SHARD_EMPTY=true" >> "$GITHUB_ENV" exit 0 @@ -557,18 +709,6 @@ jobs: fi env_flag="--env $HARBOR_SANDBOX_ENV" - # Give the LangSmith sandbox a dedicated credential, isolated from the - # LANGSMITH_API_KEY used for tracing/datasets/results. Passed as a ${VAR} - # template (single-quoted so bash keeps the literal); harbor resolves it - # from the host env at construction, so the value stays off argv and out - # of the serialized job/trial config. Requires a harbor build with - # --environment-kwarg ${VAR} support (harbor#2344); the pinned harbor - # passes the literal template through and the sandbox fails auth, so a - # langsmith-sandbox run must set harbor_package_override until #2344 ships. - env_kwarg_args=() - if [ "$HARBOR_SANDBOX_ENV" = "langsmith" ]; then - env_kwarg_args+=(--environment-kwarg 'langsmith_api_key=${LANGSMITH_SANDBOX_API_KEY}') - fi case "$HARBOR_AGENT_IMPL" in dcode) HARBOR_AGENT_GRAPH=deepagent @@ -594,17 +734,20 @@ jobs: esac experiment_model=$(printf '%s' "$HARBOR_MODEL" | tr '/:' '--' | tr -c '[:alnum:]._-' '-') experiment_agent=$(printf '%s' "$HARBOR_AGENT_IMPL" | tr -c '[:alnum:]._-' '-') + experiment_category=$(printf '%s' "$HARBOR_CATEGORY" | tr -c '[:alnum:]._-' '-') # Precedence: explicit override > tau3-subset name hook > the value # resolved above (local-path-aware `local/...` or the registry ref). # The override uses a dedicated var the tau3 step never writes, so it # can't be clobbered. HARBOR_LANGSMITH_DATASET="${HARBOR_LS_DATASET_OVERRIDE:-${HARBOR_LANGSMITH_DATASET_NAME:-$HARBOR_LANGSMITH_DATASET}}" - # Include the run id + attempt so all shards of this dispatch share one - # experiment name (Harbor's LangSmith plugin uses an explicit name - # verbatim and create-or-reuses it, converging the shards) while a - # later dispatch or re-run gets its own experiment. HARBOR_LANGSMITH_DATASET + # Scope the experiment name by category so each category's dataset gets + # its own experiment: one model spans three datasets, and a single + # experiment name shared across them double-counts runs in LangSmith. + # Shards within a category still share this name, so Harbor's LangSmith + # plugin reuses one session per category and converges them; the run id + + # attempt keep a later dispatch or re-run separate. HARBOR_LANGSMITH_DATASET # is already set (local-path-aware) in the dataset-resolution block above. - HARBOR_LANGSMITH_EXPERIMENT="deepagents-harbor-${experiment_agent}-${experiment_model}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" + HARBOR_LANGSMITH_EXPERIMENT="deepagents-harbor-${experiment_agent}-${experiment_model}${experiment_category:+-$experiment_category}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" echo "HARBOR_AGENT_GRAPH=$HARBOR_AGENT_GRAPH" >> "$GITHUB_ENV" echo "HARBOR_AGENT_LABEL=$HARBOR_AGENT_LABEL" >> "$GITHUB_ENV" echo "HARBOR_LANGSMITH_DATASET=$HARBOR_LANGSMITH_DATASET" >> "$GITHUB_ENV" @@ -675,7 +818,6 @@ jobs: "${verifier_env_args[@]}" \ --jobs-dir harbor-jobs/terminal-bench \ $env_flag \ - "${env_kwarg_args[@]}" \ --model "$HARBOR_MODEL" \ --plugin langsmith \ --plugin-kwarg dataset_name="$HARBOR_LANGSMITH_DATASET" \ @@ -741,7 +883,9 @@ jobs: - name: "🔖 Compute leaf slug" if: always() # Sanitized model+category, used to scope this run's artifact names so - # concurrent runs don't collide. + # concurrent runs don't collide. HARBOR_CATEGORY_SAFE additionally scopes + # the artifact name by category, so a flat multi-category run's shards + # group distinctly per category for the aggregate job. env: MODEL: ${{ inputs.model }} CATEGORY: ${{ inputs.category }} @@ -752,12 +896,24 @@ jobs: slug="${slug}-$(printf '%s' "$raw" | sha256sum | cut -c1-8)" echo "LEAF_SLUG=$slug" >> "$GITHUB_ENV" + category_safe=$(printf '%s' "$HARBOR_CATEGORY" | tr '[:upper:]' '[:lower:]' | tr -c 'a-z0-9' '-' | sed 's/--*/-/g; s/^-//; s/-$//') + if [ -z "$category_safe" ]; then + category_safe="uncategorized" + fi + # Short hash keeps the category slug injective, mirroring LEAF_SLUG + # above: two raw categories differing only in separators (e.g. + # "auto.test" vs "auto_test") would otherwise sanitize alike and + # collide in aggregate_matrix's per-category shard glob. + category_safe="${category_safe}-$(printf '%s' "$HARBOR_CATEGORY" | sha256sum | cut -c1-8)" + echo "HARBOR_CATEGORY_SAFE=$category_safe" >> "$GITHUB_ENV" + - name: "📤 Upload Harbor artifacts" if: always() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: - # Slug-scoped so the aggregate job globs only this run's shards. - name: shard-${{ env.LEAF_SLUG }}-${{ strategy.job-index }} + # Category- and slug-scoped so the aggregate job globs only this run's + # own shards, grouped per category. + name: shard-${{ env.HARBOR_CATEGORY_SAFE }}-${{ env.LEAF_SLUG }}-${{ strategy.job-index }} path: | libs/evals/harbor-jobs/terminal-bench if-no-files-found: warn @@ -773,6 +929,13 @@ jobs: permissions: contents: read actions: write # download shard artifacts, then delete them after merging + # One leg per category to aggregate: a single leg for the plain + # single-dataset call, or (on a flat multi-category run) one leg per + # distinct category present in flat_matrix, each carrying its own dataset + + # expected_shards. + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.prep.outputs.aggregate_matrix) }} env: GH_TOKEN: ${{ github.token }} REPO: ${{ github.repository }} @@ -781,9 +944,6 @@ jobs: # failed. Empty shards (task-filtered slices) no-op successfully, so a # filtered run is not falsely reported as incomplete. HARBOR_RESULT: ${{ needs.harbor.result }} - # Authoritative effective count after prep caps shards to selectable work. - # Successful empty slices upload markers, so every emitted shard is countable. - EXPECTED_SHARDS: ${{ needs.prep.outputs.n_shards }} steps: - name: "📋 Checkout Code" uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 @@ -802,13 +962,34 @@ jobs: slug="${slug}-$(printf '%s' "$raw" | sha256sum | cut -c1-8)" echo "slug=$slug" >> "$GITHUB_OUTPUT" + - name: "🔖 Compute category slug" + id: cat-slug + # Sanitized aggregate_matrix category. Must match the harbor job's + # HARBOR_CATEGORY_SAFE byte-for-byte so the download/delete globs below + # hit exactly this category's shard artifacts. + env: + CATEGORY: ${{ matrix.category }} + run: | + if ! [[ "$CATEGORY" =~ ^[A-Za-z0-9_.-]+$ ]]; then + echo "::error::Invalid aggregate category: $CATEGORY" + exit 1 + fi + category_safe=$(printf '%s' "$CATEGORY" | tr '[:upper:]' '[:lower:]' | tr -c 'a-z0-9' '-' | sed 's/--*/-/g; s/^-//; s/-$//') + if [ -z "$category_safe" ]; then + category_safe="uncategorized" + fi + # Short hash keeps the category slug injective (mirrors the harbor + # job's HARBOR_CATEGORY_SAFE); must match it byte-for-byte. + category_safe="${category_safe}-$(printf '%s' "$CATEGORY" | sha256sum | cut -c1-8)" + echo "slug=$category_safe" >> "$GITHUB_OUTPUT" + - name: "⬇️ Download shard results" # Distinguish "no artifacts" (a legitimate task-filtered run) from a real # download failure (auth / network / rate-limit). Only the former aggregates # an empty set; anything else fails the step, so a transient failure is never # mistaken for a complete, zero-result run. Transient errors are retried. env: - SHARD_PATTERN: shard-${{ steps.slug.outputs.slug }}-* + SHARD_PATTERN: shard-${{ steps.cat-slug.outputs.slug }}-${{ steps.slug.outputs.slug }}-* run: | attempt=1 while :; do @@ -836,12 +1017,17 @@ jobs: - name: "📊 Compute pass@k / avg@k" # Inputs are passed via quoted env (not ${{ }} shell interpolation) to - # avoid workflow-input injection; argparse int-parses --rollouts. + # avoid workflow-input injection; argparse int-parses --rollouts. Dataset, + # category, and expected_shards come from this leg's aggregate_matrix + # entry: on the single-dataset path that entry mirrors inputs.dataset / + # inputs.category / needs.prep.outputs.n_shards exactly. env: - DATASET: ${{ inputs.dataset }} + DATASET: ${{ matrix.dataset }} ROLLOUTS: ${{ inputs.rollouts }} MODEL: ${{ inputs.model }} - CATEGORY: ${{ inputs.category }} + CATEGORY: ${{ matrix.category }} + EXPECTED_SHARDS: ${{ matrix.expected_shards }} + FLAT_MATRIX: ${{ inputs.flat_matrix }} run: | if ! [[ "$ROLLOUTS" =~ ^[1-9][0-9]*$ ]]; then echo "::error::Invalid rollouts_per_task: $ROLLOUTS" @@ -851,6 +1037,18 @@ jobs: if [ -n "$EXPECTED_SHARDS" ]; then expected_shards_args=(--expected-shards "$EXPECTED_SHARDS") fi + # needs.harbor.result is the single result of the whole harbor matrix. + # On a flat multi-category run that matrix spans every category, so one + # failed shard would mark *every* category's summary incomplete. There + # the per-category --expected-shards count is the category-local + # completeness authority (a category whose shards all uploaded is + # complete regardless of a sibling category's failure), so the global + # result is not passed. The single-dataset path (one category leg) + # keeps it: that result maps to its lone category. + harbor_result_args=() + if [ -z "$FLAT_MATRIX" ]; then + harbor_result_args=(--harbor-result "$HARBOR_RESULT") + fi # --model/--category are recorded authoritatively in summary.json # (model is otherwise null when every trial errored). python3 .github/scripts/aggregate_shards.py _shards \ @@ -859,15 +1057,19 @@ jobs: --dataset "$DATASET" \ --model "$MODEL" \ --category "$CATEGORY" \ - --harbor-result "$HARBOR_RESULT" \ + "${harbor_result_args[@]}" \ --out-dir _shards - name: "📤 Upload combined results" # One zip per category: the merged shard harbor data plus summary.json - # and per_task.jsonl. + # and per_task.jsonl. The single-dataset path (flat_matrix unset) keeps + # the plain unqualified name; a flat multi-category run qualifies it by + # raw matrix.category, which is safe only because the cat-slug step's + # `exit 1` validation (rejects anything outside [A-Za-z0-9_.-]) already + # ran earlier in this job; don't reorder past it. uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: - name: harbor-combined-${{ steps.slug.outputs.slug }} + name: ${{ inputs.flat_matrix == '' && format('harbor-combined-{0}', steps.slug.outputs.slug) || format('harbor-combined-{0}-{1}', matrix.category, steps.slug.outputs.slug) }} path: _shards if-no-files-found: warn @@ -880,7 +1082,7 @@ jobs: # so the sanitized (a-z0-9- only) prefix is interpolated directly into # the jq string literal below — safe since the slug charset excludes # quotes/backslashes and can't break out of the jq string. - SHARD_PREFIX: shard-${{ steps.slug.outputs.slug }}- + SHARD_PREFIX: shard-${{ steps.cat-slug.outputs.slug }}-${{ steps.slug.outputs.slug }}- run: | ids=$(gh api "repos/$REPO/actions/runs/$RUN_ID/artifacts" --paginate \ --jq ".artifacts[] | select(.name | startswith(\"${SHARD_PREFIX}\")) | .id") diff --git a/.github/workflows/harbor.yml b/.github/workflows/harbor.yml index 6fc53b4dc68..ff2b71c074b 100644 --- a/.github/workflows/harbor.yml +++ b/.github/workflows/harbor.yml @@ -184,7 +184,7 @@ on: default: false type: boolean n_shards: - description: "Split the dataset's tasks across N parallel shard jobs per model (each on its own runner at the per-job concurrency). Composes with include_tasks/n_tasks: those select the task set first, then it's partitioned across shards (total tasks run is unchanged). Capped at 10 (with concurrency capped at 4 and a single model, at most 40 concurrent sandboxes)." + description: "Split the dataset's tasks across N shard jobs per model (each on its own runner at the per-job concurrency). Composes with include_tasks/n_tasks: those select the task set first, then it's partitioned across shards (total tasks run is unchanged). May be set as high as the task count (one task per shard) for dynamic dispatch — shards drain through a derived pool (shard_parallel), not all at once. Capped at 200 (shard_matrix.MAX_SHARDS); the pool is bounded so shard_parallel * concurrency <= 40 concurrent sandboxes." required: false default: "10" type: string @@ -220,6 +220,9 @@ jobs: # Eval category derived from the dataset inputs, consumed by the leaf # workflow's unified reporting (autonomous | conversation | context). category: ${{ steps.category.outputs.category }} + # Derived shard pool (dynamic dispatch) from the "🔒 Validate single + # model + resource limits" step, for the run job's shard_parallel input. + shard_parallel: ${{ steps.limits.outputs.shard_parallel }} env: LANGSMITH_API_KEY: ${{ secrets.LANGSMITH_API_KEY }} steps: @@ -274,13 +277,18 @@ jobs: - name: "🔒 Validate single model + resource limits" # This workflow evaluates exactly ONE model. Fail fast (before the matrix # fans out) if the resolved model set is not a single model, or if the - # per-run limits are exceeded (n_shards <= 10, concurrency <= 4; with one - # model their product bounds concurrent sandboxes to 40). Inputs are read + # per-run limits are exceeded (n_shards <= shard_matrix.MAX_SHARDS=200, + # concurrency <= 4). n_shards may be set high for dynamic dispatch (one + # task per shard); shards drain through a derived shard_parallel pool + # instead of all running at once, bounded so shard_parallel * + # concurrency <= 40 concurrent sandboxes. Inputs are read # via env (no shell interpolation) and int-parsed in the script. # See validate_harbor_limits.py (unit-tested in test_validate_harbor_limits.py). + id: limits env: N_SHARDS: ${{ inputs.n_shards || '10' }} CONCURRENCY: ${{ inputs.concurrency || '4' }} + ROLLOUTS: ${{ inputs.rollouts_per_task }} MODEL_MATRIX: ${{ steps.set-matrix.outputs.matrix }} run: python .github/scripts/validate_harbor_limits.py @@ -329,8 +337,9 @@ jobs: langsmith_dataset: "" rollouts: ${{ inputs.rollouts_per_task }} n_shards: ${{ inputs.n_shards }} - # Run every shard in parallel (cap = n_shards). - shard_parallel: ${{ inputs.n_shards }} + # Derived pool the shards drain through (dynamic dispatch), not n_shards + # itself — see the prep job's "🔒 Validate single model + resource limits" step. + shard_parallel: ${{ needs.prep.outputs.shard_parallel }} concurrency: ${{ inputs.concurrency }} sandbox_env: ${{ inputs.sandbox_env }} n_retries: ${{ inputs.n_retries }} diff --git a/.github/workflows/unified_evals.yml b/.github/workflows/unified_evals.yml index 4309fac16ef..bf0af01ccb1 100644 --- a/.github/workflows/unified_evals.yml +++ b/.github/workflows/unified_evals.yml @@ -31,18 +31,6 @@ on: concurrency: type: string default: "4" - shard_parallel: - type: string - default: "10" - n_shards_autonomous: - type: string - default: "10" - n_shards_conversation: - type: string - default: "3" - n_shards_context: - type: string - default: "3" sandbox_env: type: string default: "langsmith" @@ -58,7 +46,7 @@ on: permissions: contents: read # Lets the called reusable workflow manage run artifacts; a caller caps the - # callee's token, so it must be granted here (provider jobs inherit this). + # callee's token, so it must be granted here (the eval job inherits this). actions: write concurrency: @@ -67,40 +55,115 @@ concurrency: jobs: prep: - name: "🔧 Parse models + build provider matrices" + name: "🔧 Parse models + build the per-model flat matrix" runs-on: ubuntu-latest environment: evals outputs: - anthropic_matrix: ${{ steps.p.outputs.anthropic_matrix }} - anthropic_has_models: ${{ steps.p.outputs.anthropic_has_models }} - baseten_matrix: ${{ steps.p.outputs.baseten_matrix }} - baseten_has_models: ${{ steps.p.outputs.baseten_has_models }} - fireworks_matrix: ${{ steps.p.outputs.fireworks_matrix }} - fireworks_has_models: ${{ steps.p.outputs.fireworks_has_models }} - google_genai_matrix: ${{ steps.p.outputs.google_genai_matrix }} - google_genai_has_models: ${{ steps.p.outputs.google_genai_has_models }} - groq_matrix: ${{ steps.p.outputs.groq_matrix }} - groq_has_models: ${{ steps.p.outputs.groq_has_models }} - nvidia_matrix: ${{ steps.p.outputs.nvidia_matrix }} - nvidia_has_models: ${{ steps.p.outputs.nvidia_has_models }} - ollama_matrix: ${{ steps.p.outputs.ollama_matrix }} - ollama_has_models: ${{ steps.p.outputs.ollama_has_models }} - openai_matrix: ${{ steps.p.outputs.openai_matrix }} - openai_has_models: ${{ steps.p.outputs.openai_has_models }} - openrouter_matrix: ${{ steps.p.outputs.openrouter_matrix }} - openrouter_has_models: ${{ steps.p.outputs.openrouter_has_models }} - xai_matrix: ${{ steps.p.outputs.xai_matrix }} - xai_has_models: ${{ steps.p.outputs.xai_has_models }} - other_matrix: ${{ steps.p.outputs.other_matrix }} - other_has_models: ${{ steps.p.outputs.other_has_models }} - effective_shard_parallel: ${{ steps.p.outputs.effective_shard_parallel }} + eval_matrix: ${{ steps.p.outputs.eval_matrix }} + max_parallel: ${{ steps.p.outputs.max_parallel }} + model_parallel: ${{ steps.p.outputs.model_parallel }} models: ${{ steps.p.outputs.models }} categories: ${{ steps.p.outputs.categories }} steps: - name: "📋 Checkout Code" uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - name: "🧮 Parse models + build provider matrices" + - name: "🐍 Set up Python + UV" + if: ${{ inputs.profile == 'full' }} + uses: "./.github/actions/uv_setup" + with: + python-version: "3.12" + cache-suffix: unified-enumerate + working-directory: libs/evals + + - name: "📦 Install Dependencies" + if: ${{ inputs.profile == 'full' }} + working-directory: libs/evals + run: uv sync --group test --locked + + - name: "🔢 Enumerate full-profile tasks" + # Only the full profile needs the live task list per category; lite + # uses the frozen subset baked into lite_tasks.py and skips this + # entirely. Resolves each selected category's task names the same way + # the harbor leaf's own sharding does (enumerate_tasks.py), so + # unified_prep.py's flat matrix always matches the real dataset. + if: ${{ inputs.profile == 'full' }} + id: enumerate + working-directory: libs/evals + env: + UNIFIED_CATEGORIES: ${{ inputs.categories }} + run: | + python3 - <<'PY' + import json + import os + import subprocess + import sys + + # Resolve dataset refs straight from unified_prep.py's CATEGORY_MAP + # (the same module the flat-matrix step below imports) so there is + # a single source of truth for category -> dataset and a version + # bump there can't silently drift out of sync with enumeration. + sys.path.insert( + 0, os.path.join(os.environ["GITHUB_WORKSPACE"], ".github", "scripts") + ) + from unified_prep import CATEGORY_MAP + + KNOWN_CATEGORIES = set(CATEGORY_MAP) + + raw = os.environ.get("UNIFIED_CATEGORIES", "") + categories = list(dict.fromkeys(c.strip() for c in raw.split(",") if c.strip())) + unknown = [c for c in categories if c not in KNOWN_CATEGORIES] + if unknown: + sys.exit(f"::error::Unknown categor(y/ies) for enumeration: {unknown}") + if not categories: + sys.exit("::error::No categories selected to enumerate for the full profile") + + enumerate_script = os.path.join( + os.environ["GITHUB_WORKSPACE"], ".github", "scripts", "enumerate_tasks.py" + ) + tasks_by_cat: dict[str, list[str]] = {} + for category in categories: + dataset = CATEGORY_MAP[category]["dataset"] + dataset_path = CATEGORY_MAP[category]["dataset_path"] + env = os.environ.copy() + if dataset_path: + # Local dataset: the per-task corpus is git-ignored and must be + # regenerated from the vendored copy before enumeration can see + # any task.toml files, mirroring the leaf's own populate step. + subprocess.run( + [ + "uv", "run", "python", "-m", + "harbor_adapters.contextbench.main", + "--populate", dataset_path, + ], + check=True, + ) + env["ENUM_DATASET_PATH"] = dataset_path + env.pop("ENUM_DATASET", None) + else: + env["ENUM_DATASET"] = dataset + env.pop("ENUM_DATASET_PATH", None) + result = subprocess.run( + ["uv", "run", "python", enumerate_script], + env=env, + capture_output=True, + text=True, + check=True, + ) + names = [line for line in result.stdout.splitlines() if line.strip()] + if not names: + sys.exit(f"::error::Enumerated 0 tasks for category {category!r}") + tasks_by_cat[category] = names + + out_path = os.path.join(os.environ["RUNNER_TEMP"], "tasks.json") + with open(out_path, "w") as f: + json.dump(tasks_by_cat, f) + + with open(os.environ["GITHUB_ENV"], "a") as f: + f.write(f"UNIFIED_TASKS_JSON={out_path}\n") + PY + + - name: "🧮 Parse models + build the per-model flat matrix" id: p env: UNIFIED_MODELS: ${{ inputs.models }} @@ -108,15 +171,15 @@ jobs: UNIFIED_AGENT_IMPL: ${{ inputs.agent_impl }} UNIFIED_PROFILE: ${{ inputs.profile }} UNIFIED_CONCURRENCY: ${{ inputs.concurrency }} - UNIFIED_SHARD_PARALLEL: ${{ inputs.shard_parallel }} - UNIFIED_N_SHARDS_AUTONOMOUS: ${{ inputs.n_shards_autonomous }} - UNIFIED_N_SHARDS_CONVERSATION: ${{ inputs.n_shards_conversation }} - UNIFIED_N_SHARDS_CONTEXT: ${{ inputs.n_shards_context }} + UNIFIED_ROLLOUTS: ${{ inputs.rollouts }} + # Set by the enumerate step above for the full profile only; empty + # (unset) for lite, which unified_prep.py never reads in that case. + UNIFIED_TASKS_JSON: ${{ env.UNIFIED_TASKS_JSON }} run: python .github/scripts/unified_prep.py # A single place to see exactly what a dispatch ran with — the raw inputs - # plus the values prep derived from them (resolved model list, effective - # shard_parallel after clamping). Runs even if the parse step failed, so a + # plus the values prep derived from them (resolved model list, and the + # derived shard-pool parallelism). Runs even if the parse step failed, so a # bad dispatch still shows what was requested. Values are passed via env # (never interpolated into the script) so free-form inputs can't inject. - name: "📝 Summarize dispatch inputs" @@ -127,13 +190,11 @@ jobs: IN_CATEGORIES: ${{ inputs.categories }} RESOLVED_CATEGORIES: ${{ steps.p.outputs.categories }} IN_AGENT_IMPL: ${{ inputs.agent_impl }} + IN_PROFILE: ${{ inputs.profile }} IN_ROLLOUTS: ${{ inputs.rollouts }} IN_CONCURRENCY: ${{ inputs.concurrency }} - IN_SHARD_PARALLEL: ${{ inputs.shard_parallel }} - EFFECTIVE_SHARD_PARALLEL: ${{ steps.p.outputs.effective_shard_parallel }} - IN_N_SHARDS_AUTONOMOUS: ${{ inputs.n_shards_autonomous }} - IN_N_SHARDS_CONVERSATION: ${{ inputs.n_shards_conversation }} - IN_N_SHARDS_CONTEXT: ${{ inputs.n_shards_context }} + MAX_PARALLEL: ${{ steps.p.outputs.max_parallel }} + MODEL_PARALLEL: ${{ steps.p.outputs.model_parallel }} IN_SANDBOX_ENV: ${{ inputs.sandbox_env }} IN_FORCE_BUILD: ${{ inputs.force_build }} HARBOR_OVERRIDE_SET: ${{ inputs.harbor_package_override != '' }} @@ -168,305 +229,51 @@ jobs: echo "| models (resolved) | \`${resolved_models}\` |" echo "| categories | \`${IN_CATEGORIES}\` |" echo "| agent_impl (autonomous/context) | \`${IN_AGENT_IMPL}\`${agent_impl_note} |" + echo "| profile | \`${IN_PROFILE}\` |" echo "| rollouts | \`${IN_ROLLOUTS}\` |" echo "| concurrency | \`${IN_CONCURRENCY}\` |" - echo "| shard_parallel (requested → effective) | \`${IN_SHARD_PARALLEL}\` → \`${EFFECTIVE_SHARD_PARALLEL:-?}\` |" - echo "| n_shards (autonomous/conversation/context) | \`${IN_N_SHARDS_AUTONOMOUS}\` / \`${IN_N_SHARDS_CONVERSATION}\` / \`${IN_N_SHARDS_CONTEXT}\` |" + echo "| shard pool (max_parallel / model_parallel) | \`${MAX_PARALLEL:-?}\` / \`${MODEL_PARALLEL:-?}\` |" echo "| sandbox_env | \`${IN_SANDBOX_ENV}\` |" echo "| force_build | \`${IN_FORCE_BUILD}\` |" echo "| harbor_package_override | \`${override_status}\` |" } >> "$GITHUB_STEP_SUMMARY" - eval-anthropic: - needs: prep - if: needs.prep.outputs.anthropic_has_models == 'true' - strategy: - fail-fast: false - max-parallel: 1 - matrix: ${{ fromJson(needs.prep.outputs.anthropic_matrix) }} - uses: ./.github/workflows/_harbor_run.yml - secrets: inherit - with: - model: ${{ matrix.model }} - category: ${{ matrix.category }} - dataset: ${{ matrix.dataset }} - dataset_path: ${{ matrix.dataset_path }} - agent_impl: ${{ matrix.agent_impl }} - langsmith_dataset: ${{ matrix.langsmith_dataset }} - n_shards: ${{ matrix.n_shards }} - shard_parallel: ${{ matrix.shard_parallel }} - rollouts: ${{ inputs.rollouts }} - concurrency: ${{ inputs.concurrency }} - sandbox_env: ${{ inputs.sandbox_env }} - force_build: ${{ inputs.force_build }} - harbor_package_override: ${{ inputs.harbor_package_override }} - include_tasks: ${{ matrix.include_tasks }} - - eval-baseten: - needs: prep - if: needs.prep.outputs.baseten_has_models == 'true' - strategy: - fail-fast: false - max-parallel: 1 - matrix: ${{ fromJson(needs.prep.outputs.baseten_matrix) }} - uses: ./.github/workflows/_harbor_run.yml - secrets: inherit - with: - model: ${{ matrix.model }} - category: ${{ matrix.category }} - dataset: ${{ matrix.dataset }} - dataset_path: ${{ matrix.dataset_path }} - agent_impl: ${{ matrix.agent_impl }} - langsmith_dataset: ${{ matrix.langsmith_dataset }} - n_shards: ${{ matrix.n_shards }} - shard_parallel: ${{ matrix.shard_parallel }} - rollouts: ${{ inputs.rollouts }} - concurrency: ${{ inputs.concurrency }} - sandbox_env: ${{ inputs.sandbox_env }} - force_build: ${{ inputs.force_build }} - harbor_package_override: ${{ inputs.harbor_package_override }} - include_tasks: ${{ matrix.include_tasks }} - - eval-fireworks: - needs: prep - if: needs.prep.outputs.fireworks_has_models == 'true' - strategy: - fail-fast: false - max-parallel: 1 - matrix: ${{ fromJson(needs.prep.outputs.fireworks_matrix) }} - uses: ./.github/workflows/_harbor_run.yml - secrets: inherit - with: - model: ${{ matrix.model }} - category: ${{ matrix.category }} - dataset: ${{ matrix.dataset }} - dataset_path: ${{ matrix.dataset_path }} - agent_impl: ${{ matrix.agent_impl }} - langsmith_dataset: ${{ matrix.langsmith_dataset }} - n_shards: ${{ matrix.n_shards }} - shard_parallel: ${{ matrix.shard_parallel }} - rollouts: ${{ inputs.rollouts }} - concurrency: ${{ inputs.concurrency }} - sandbox_env: ${{ inputs.sandbox_env }} - force_build: ${{ inputs.force_build }} - harbor_package_override: ${{ inputs.harbor_package_override }} - include_tasks: ${{ matrix.include_tasks }} - - eval-google_genai: - needs: prep - if: needs.prep.outputs.google_genai_has_models == 'true' - strategy: - fail-fast: false - max-parallel: 1 - matrix: ${{ fromJson(needs.prep.outputs.google_genai_matrix) }} - uses: ./.github/workflows/_harbor_run.yml - secrets: inherit - with: - model: ${{ matrix.model }} - category: ${{ matrix.category }} - dataset: ${{ matrix.dataset }} - dataset_path: ${{ matrix.dataset_path }} - agent_impl: ${{ matrix.agent_impl }} - langsmith_dataset: ${{ matrix.langsmith_dataset }} - n_shards: ${{ matrix.n_shards }} - shard_parallel: ${{ matrix.shard_parallel }} - rollouts: ${{ inputs.rollouts }} - concurrency: ${{ inputs.concurrency }} - sandbox_env: ${{ inputs.sandbox_env }} - force_build: ${{ inputs.force_build }} - harbor_package_override: ${{ inputs.harbor_package_override }} - include_tasks: ${{ matrix.include_tasks }} - - eval-groq: - needs: prep - if: needs.prep.outputs.groq_has_models == 'true' - strategy: - fail-fast: false - max-parallel: 1 - matrix: ${{ fromJson(needs.prep.outputs.groq_matrix) }} - uses: ./.github/workflows/_harbor_run.yml - secrets: inherit - with: - model: ${{ matrix.model }} - category: ${{ matrix.category }} - dataset: ${{ matrix.dataset }} - dataset_path: ${{ matrix.dataset_path }} - agent_impl: ${{ matrix.agent_impl }} - langsmith_dataset: ${{ matrix.langsmith_dataset }} - n_shards: ${{ matrix.n_shards }} - shard_parallel: ${{ matrix.shard_parallel }} - rollouts: ${{ inputs.rollouts }} - concurrency: ${{ inputs.concurrency }} - sandbox_env: ${{ inputs.sandbox_env }} - force_build: ${{ inputs.force_build }} - harbor_package_override: ${{ inputs.harbor_package_override }} - include_tasks: ${{ matrix.include_tasks }} - - eval-nvidia: - needs: prep - if: needs.prep.outputs.nvidia_has_models == 'true' - strategy: - fail-fast: false - max-parallel: 1 - matrix: ${{ fromJson(needs.prep.outputs.nvidia_matrix) }} - uses: ./.github/workflows/_harbor_run.yml - secrets: inherit - with: - model: ${{ matrix.model }} - category: ${{ matrix.category }} - dataset: ${{ matrix.dataset }} - dataset_path: ${{ matrix.dataset_path }} - agent_impl: ${{ matrix.agent_impl }} - langsmith_dataset: ${{ matrix.langsmith_dataset }} - n_shards: ${{ matrix.n_shards }} - shard_parallel: ${{ matrix.shard_parallel }} - rollouts: ${{ inputs.rollouts }} - concurrency: ${{ inputs.concurrency }} - sandbox_env: ${{ inputs.sandbox_env }} - force_build: ${{ inputs.force_build }} - harbor_package_override: ${{ inputs.harbor_package_override }} - include_tasks: ${{ matrix.include_tasks }} - - eval-ollama: - needs: prep - if: needs.prep.outputs.ollama_has_models == 'true' - strategy: - fail-fast: false - max-parallel: 1 - matrix: ${{ fromJson(needs.prep.outputs.ollama_matrix) }} - uses: ./.github/workflows/_harbor_run.yml - secrets: inherit - with: - model: ${{ matrix.model }} - category: ${{ matrix.category }} - dataset: ${{ matrix.dataset }} - dataset_path: ${{ matrix.dataset_path }} - agent_impl: ${{ matrix.agent_impl }} - langsmith_dataset: ${{ matrix.langsmith_dataset }} - n_shards: ${{ matrix.n_shards }} - shard_parallel: ${{ matrix.shard_parallel }} - rollouts: ${{ inputs.rollouts }} - concurrency: ${{ inputs.concurrency }} - sandbox_env: ${{ inputs.sandbox_env }} - force_build: ${{ inputs.force_build }} - harbor_package_override: ${{ inputs.harbor_package_override }} - include_tasks: ${{ matrix.include_tasks }} - - eval-openai: - needs: prep - if: needs.prep.outputs.openai_has_models == 'true' - strategy: - fail-fast: false - max-parallel: 1 - matrix: ${{ fromJson(needs.prep.outputs.openai_matrix) }} - uses: ./.github/workflows/_harbor_run.yml - secrets: inherit - with: - model: ${{ matrix.model }} - category: ${{ matrix.category }} - dataset: ${{ matrix.dataset }} - dataset_path: ${{ matrix.dataset_path }} - agent_impl: ${{ matrix.agent_impl }} - langsmith_dataset: ${{ matrix.langsmith_dataset }} - n_shards: ${{ matrix.n_shards }} - shard_parallel: ${{ matrix.shard_parallel }} - rollouts: ${{ inputs.rollouts }} - concurrency: ${{ inputs.concurrency }} - sandbox_env: ${{ inputs.sandbox_env }} - force_build: ${{ inputs.force_build }} - harbor_package_override: ${{ inputs.harbor_package_override }} - include_tasks: ${{ matrix.include_tasks }} - - eval-openrouter: - needs: prep - if: needs.prep.outputs.openrouter_has_models == 'true' - strategy: - fail-fast: false - max-parallel: 1 - matrix: ${{ fromJson(needs.prep.outputs.openrouter_matrix) }} - uses: ./.github/workflows/_harbor_run.yml - secrets: inherit - with: - model: ${{ matrix.model }} - category: ${{ matrix.category }} - dataset: ${{ matrix.dataset }} - dataset_path: ${{ matrix.dataset_path }} - agent_impl: ${{ matrix.agent_impl }} - langsmith_dataset: ${{ matrix.langsmith_dataset }} - n_shards: ${{ matrix.n_shards }} - shard_parallel: ${{ matrix.shard_parallel }} - rollouts: ${{ inputs.rollouts }} - concurrency: ${{ inputs.concurrency }} - sandbox_env: ${{ inputs.sandbox_env }} - force_build: ${{ inputs.force_build }} - harbor_package_override: ${{ inputs.harbor_package_override }} - include_tasks: ${{ matrix.include_tasks }} - - eval-xai: - needs: prep - if: needs.prep.outputs.xai_has_models == 'true' - strategy: - fail-fast: false - max-parallel: 1 - matrix: ${{ fromJson(needs.prep.outputs.xai_matrix) }} - uses: ./.github/workflows/_harbor_run.yml - secrets: inherit - with: - model: ${{ matrix.model }} - category: ${{ matrix.category }} - dataset: ${{ matrix.dataset }} - dataset_path: ${{ matrix.dataset_path }} - agent_impl: ${{ matrix.agent_impl }} - langsmith_dataset: ${{ matrix.langsmith_dataset }} - n_shards: ${{ matrix.n_shards }} - shard_parallel: ${{ matrix.shard_parallel }} - rollouts: ${{ inputs.rollouts }} - concurrency: ${{ inputs.concurrency }} - sandbox_env: ${{ inputs.sandbox_env }} - force_build: ${{ inputs.force_build }} - harbor_package_override: ${{ inputs.harbor_package_override }} - include_tasks: ${{ matrix.include_tasks }} - - eval-other: + eval: + name: "🚀 Evaluate (${{ matrix.model }})" needs: prep - if: needs.prep.outputs.other_has_models == 'true' strategy: fail-fast: false - max-parallel: 1 - matrix: ${{ fromJson(needs.prep.outputs.other_matrix) }} + # Caps how many models run concurrently so total runners across every + # model's own shard pool stay within the global runner budget (see + # unified_prep.py's derive_pool). + max-parallel: ${{ fromJson(needs.prep.outputs.model_parallel) }} + matrix: ${{ fromJson(needs.prep.outputs.eval_matrix) }} uses: ./.github/workflows/_harbor_run.yml secrets: inherit with: model: ${{ matrix.model }} - category: ${{ matrix.category }} - dataset: ${{ matrix.dataset }} - dataset_path: ${{ matrix.dataset_path }} - agent_impl: ${{ matrix.agent_impl }} - langsmith_dataset: ${{ matrix.langsmith_dataset }} - n_shards: ${{ matrix.n_shards }} - shard_parallel: ${{ matrix.shard_parallel }} + # The model's full multi-category, multi-shard matrix, pre-serialized by + # unified_prep.py. _harbor_run.yml's own harbor job matrixes over these + # entries directly instead of expanding a single-dataset shard axis. + flat_matrix: ${{ matrix.flat_matrix }} + max_parallel: ${{ needs.prep.outputs.max_parallel }} + # Fallbacks only: every flat_matrix entry carries its own category, + # dataset, dataset_path, agent_impl, and include_tasks. + category: "" + dataset: "" + dataset_path: "" + agent_impl: ${{ inputs.agent_impl }} rollouts: ${{ inputs.rollouts }} concurrency: ${{ inputs.concurrency }} sandbox_env: ${{ inputs.sandbox_env }} force_build: ${{ inputs.force_build }} harbor_package_override: ${{ inputs.harbor_package_override }} - include_tasks: ${{ matrix.include_tasks }} combine: name: "📊 Combine cross-model results" needs: - prep - - eval-anthropic - - eval-baseten - - eval-fireworks - - eval-google_genai - - eval-groq - - eval-nvidia - - eval-ollama - - eval-openai - - eval-openrouter - - eval-xai - - eval-other + - eval if: ${{ always() }} runs-on: ubuntu-latest # Every ref publishes to the same branch. Serialize the publishing jobs so diff --git a/libs/evals/UNIFIED_SCORECARD.md b/libs/evals/UNIFIED_SCORECARD.md index aa269f599af..5301b300ea3 100644 --- a/libs/evals/UNIFIED_SCORECARD.md +++ b/libs/evals/UNIFIED_SCORECARD.md @@ -2,6 +2,38 @@ GH aggregate pass@k / avg@k from `.github/workflows/unified_evals.yml`. pass@k = fraction of tasks solved in ≥1 of k rollouts; avg@k = mean reward across rollouts; rewards are binary (0/1). +## openai:gpt-5.6-terra + +### Full (default) + +| Category | pass@k | avg@k | tasks | +| --- | --- | --- | --- | +| autonomous (harbor-index) | 0.268 | 0.183 | 82 | +| conversation (tau3-subset) | 0.467 | 0.389 | 30 | +| context (context-retrieval) | 0.667 | 0.567 | 30 | +| **macro** | **0.467** | **0.379** | | +| **micro** | **0.394** | **0.308** | | + +Run [29430259116](https://github.com/langchain-ai/deepagents/actions/runs/29430259116) · 2026-07-15 · `agent_impl=bare` · `profile=full` · rollouts=3 · `sandbox=docker` · `judge=gpt-5.6-luna` · harbor@`27a6eac` · wall ~4h + +autonomous includes 14 of 246 trials that errored (agent/verifier timeouts and one OOM) and are scored as failures. Aggregated from the run's artifacts (one shard recovered from the retry attempt); no tasks were re-run. + +### Lite + +Frozen high-signal subset (`lite_tasks.py`, difficulty-frontier tasks). + +| Category | pass@k | avg@k | tasks | +| --- | --- | --- | --- | +| autonomous (harbor-index) | 0.400 | 0.267 | 15 | +| conversation (tau3-subset) | 0.727 | 0.455 | 11 | +| context (context-retrieval) | 0.625 | 0.375 | 8 | +| **macro** | **0.584** | **0.365** | | +| **micro** | **0.559** | **0.353** | | + +Run [29509108062](https://github.com/langchain-ai/deepagents/actions/runs/29509108062) · 2026-07-16 · `agent_impl=bare` · `profile=lite` · rollouts=3 · `sandbox=docker` · `judge=gpt-5.6-luna` · harbor@`27a6eac` · wall ~25m + +One conversation shard hit a transient Docker-daemon failure; recovered from the run's artifacts (merged the retried shard), no tasks re-run. + ## openai:gpt-5.6-luna ### Full (default) @@ -22,10 +54,10 @@ Frozen high-signal subset (`lite_tasks.py`, difficulty-frontier tasks). | Category | pass@k | avg@k | tasks | | --- | --- | --- | --- | -| autonomous (harbor-index) | 0.400 | 0.156 | 15 | -| conversation (tau3-subset) | 0.273 | 0.212 | 11 | -| context (context-retrieval) | 0.375 | 0.125 | 8 | -| **macro** | **0.349** | **0.164** | | -| **micro** | **0.353** | **0.167** | | +| autonomous (harbor-index) | 0.333 | 0.178 | 15 | +| conversation (tau3-subset) | 0.273 | 0.182 | 11 | +| context (context-retrieval) | 0.500 | 0.333 | 8 | +| **macro** | **0.369** | **0.231** | | +| **micro** | **0.353** | **0.216** | | -Run [29304843581](https://github.com/langchain-ai/deepagents/actions/runs/29304843581) · 2026-07-14 · `agent_impl=bare` · `profile=lite` · rollouts=3 · `sandbox=docker` · `judge=gpt-5.6-luna` · harbor@`af2e862` \ No newline at end of file +Run [29509109809](https://github.com/langchain-ai/deepagents/actions/runs/29509109809) · 2026-07-16 · `agent_impl=bare` · `profile=lite` · rollouts=3 · `sandbox=docker` · `judge=gpt-5.6-luna` · harbor@`27a6eac` · wall ~50m \ No newline at end of file diff --git a/libs/evals/tests/unit_tests/test_harbor_langsmith_integration.py b/libs/evals/tests/unit_tests/test_harbor_langsmith_integration.py index 038a4a301ae..0a409ff86d2 100644 --- a/libs/evals/tests/unit_tests/test_harbor_langsmith_integration.py +++ b/libs/evals/tests/unit_tests/test_harbor_langsmith_integration.py @@ -244,9 +244,10 @@ def test_harbor_workflow_wires_tau3_subset() -> None: # The resolve step must fail loudly on a wrong-sized filter (empty => full # dataset), so the count tripwire must stay wired. assert 'if [ "$task_count" -ne 30 ]; then' in leaf - # tau3's verifier/user simulator needs OpenAI even when the agent model is - # hosted by another provider, so missing credentials should fail preflight. - assert "contains(inputs.dataset, 'tau3')" in leaf + # tau3's verifier/judge is always an OpenAI model, so the leaf provides the + # OpenAI key unconditionally, and the preflight fails loudly if it is missing + # for a tau3 run whose agent model is hosted by another provider. + assert "OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}" in leaf assert '[[ "$HARBOR_DATASET" == *tau3* ]]' in leaf assert '[ "$model_provider" != "openai" ]' in leaf