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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .verify-floor.json

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions src/model_profile_trial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Guarded, read-only Sol/Terra/Luna worker-profile plumbing trial.
"""Guarded, read-only Astra/Terra/Luna worker-profile plumbing trial.

The trial is instrumentation, not a benchmark: one frozen packet, one shared
Codex capacity snapshot, randomized launch order, and three exact profiles. It
Expand Down Expand Up @@ -55,7 +55,7 @@ def _manifest_profile_ids(manifest: dict[str, Any]) -> tuple[str, ...]:
for supported in (EXPECTED_PROFILE_IDS, LEGACY_PROFILE_IDS):
if actual == set(supported) and len(requests) == len(supported):
return supported
raise ValueError("trial requires an exact supported three-profile set")
raise ValueError("trial requires an exact supported profile set")


DEFAULT_STATE_PATH = Path(
Expand Down Expand Up @@ -370,6 +370,7 @@ def validate_trial_manifest(manifest: dict[str, Any]) -> None:
):
raise ValueError("trial source manifest is incomplete")
profile_ids = _manifest_profile_ids(manifest)
expected_count = len(profile_ids)
identity = {
"created_at": manifest.get("created_at"),
"packet_hash": manifest.get("packet_hash"),
Expand All @@ -385,9 +386,9 @@ def validate_trial_manifest(manifest: dict[str, Any]) -> None:

requests = manifest.get("requests") or []
if {item.get("profile_id") for item in requests} != set(profile_ids):
raise ValueError("trial requires an exact supported three-profile set")
if len({item.get("run_id") for item in requests}) != 3:
raise ValueError("trial requires three distinct run identities")
raise ValueError("trial requires an exact supported profile set")
if len({item.get("run_id") for item in requests}) != expected_count:
raise ValueError("trial requires one distinct run identity per profile")
if manifest.get("capacity_snapshot", {}).get("snapshot_count") != 1:
raise ValueError("trial requires one shared-pool snapshot")
launch_order = manifest.get("launch_order") or []
Expand All @@ -396,8 +397,10 @@ def validate_trial_manifest(manifest: dict[str, Any]) -> None:
by_ordinal = sorted(requests, key=lambda item: int(item.get("launch_ordinal") or 0))
if [item.get("profile_id") for item in by_ordinal] != launch_order:
raise ValueError("trial request ordinals do not match launch order")
if [int(item.get("launch_ordinal") or 0) for item in by_ordinal] != [1, 2, 3]:
raise ValueError("trial launch ordinals must be exactly 1,2,3")
if [int(item.get("launch_ordinal") or 0) for item in by_ordinal] != list(
range(1, expected_count + 1)
):
raise ValueError("trial launch ordinals must cover the selected profile set")
for request in requests:
profile = execution_profiles.get_profile(request["profile_id"])
expected_run_id = f"{manifest['trial_id']}:{request['profile_id']}"
Expand Down Expand Up @@ -635,8 +638,8 @@ def finalize_trial(
for request in manifest["requests"]
]
)
if debit != {"codex-subscription": 3.0}:
raise AssertionError("trial did not debit one shared pool exactly three times")
if debit != {"codex-subscription": float(len(manifest["requests"]))}:
raise AssertionError("trial did not debit one shared pool once per profile")
state = {
"schema": STATE_SCHEMA,
"version": SCHEMA_VERSION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
"round": "r15",
"source": "rounds/r15/proposers/P3-cursor/orch/exercises/local-model-profile-trial.json"
},
"pass_check": "python3 -c \"import json,sys; m=json.load(open('$CONTRACT_DIR/fixtures/local-model-profile-trial/manifest.json')); ids={r['profile_id'] for r in m['requests']}; ok=(m.get('promotion_allowed') is False and m.get('learning_enabled') is False and ids=={'codex-5.6-sol-high','codex-5.6-terra-high','codex-5.6-luna-high'} and m.get('stop_conditions',{}).get('triggered') is False); sys.exit(0 if ok else 1)\"",
"pass_check": "python3 -c \"import json,sys; m=json.load(open('$CONTRACT_DIR/fixtures/local-model-profile-trial/manifest.json')); ids={r['profile_id'] for r in m['requests']}; ok=(m.get('promotion_allowed') is False and m.get('learning_enabled') is False and ids=={'codex-6-astra-high','codex-5.6-terra-high','codex-5.6-luna-high'} and m.get('stop_conditions',{}).get('triggered') is False); sys.exit(0 if ok else 1)\"",
"run": [
"cd $REPO_ROOT/orch && python3 src/model_profile_trial.py prepare --orchestrator-root $CONTRACT_DIR/fixtures/local-model-profile-trial/orch --workflows-root $CONTRACT_DIR/fixtures/local-model-profile-trial/workflows --output $CONTRACT_DIR/fixtures/local-model-profile-trial/manifest.json --capacity-state ok > $CONTRACT_DIR/fixtures/local-model-profile-trial/prepare-out.json",
"cd $REPO_ROOT/orch && python3 -c \"import json,sys; sys.path.insert(0,'src'); from model_profile_trial import validate_trial_manifest; m=json.load(open('$CONTRACT_DIR/fixtures/local-model-profile-trial/manifest.json')); validate_trial_manifest(m); assert m['schema']=='orchestrator.model-profile-trial'; assert m['lifecycle']=='shadow'; assert len(m['requests'])==3; print('validate_ok')\""
],
"setup": [],
"stated_task": "Prepare and validate a shadow Sol/Terra/Luna trial manifest from minimal fixture source trees without executing workers or recording feedback."
"stated_task": "Prepare and validate a shadow Astra/Terra/Luna trial manifest from minimal fixture source trees without executing workers or recording feedback."
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@
],
"state": "ok"
},
"codex-6-astra-high": {
"capacity_pool_ids": [
"codex-subscription"
],
"state": "ok"
},
"cursor-composer-2.5": {
"capacity_pool_ids": [
"cursor-subscription"
Expand Down Expand Up @@ -142,7 +148,7 @@
"launch_order": [
"codex-5.6-terra-high",
"codex-5.6-luna-high",
"codex-5.6-sol-high"
"codex-6-astra-high"
],
"learning_enabled": false,
"lifecycle": "shadow",
Expand All @@ -163,7 +169,7 @@
"provider": "openai",
"reasoning_effort": "high",
"requested_model": "gpt-5.6-terra",
"run_id": "model-profile-trial:d965f949e25603e6d56293f9:codex-5.6-terra-high",
"run_id": "model-profile-trial:e5267a218ea4136c9682a5ff:codex-5.6-terra-high",
"sandbox": "read-only",
"tools": []
},
Expand All @@ -181,7 +187,7 @@
"provider": "openai",
"reasoning_effort": "high",
"requested_model": "gpt-5.6-luna",
"run_id": "model-profile-trial:d965f949e25603e6d56293f9:codex-5.6-luna-high",
"run_id": "model-profile-trial:e5267a218ea4136c9682a5ff:codex-5.6-luna-high",
"sandbox": "read-only",
"tools": []
},
Expand All @@ -194,12 +200,12 @@
"learning_enabled": false,
"packet_hash": "sha256:343604df7f0b27aa9df5507a34fd48beffdc1627987439c7b89e72af715a7605",
"permission_mode": "read-only",
"profile_id": "codex-5.6-sol-high",
"profile_id": "codex-6-astra-high",
"prompt_version": "orchestrator-prompt-v1",
"provider": "openai",
"reasoning_effort": "high",
"requested_model": "gpt-5.6-sol",
"run_id": "model-profile-trial:d965f949e25603e6d56293f9:codex-5.6-sol-high",
"requested_model": "gpt-6-astra",
"run_id": "model-profile-trial:e5267a218ea4136c9682a5ff:codex-6-astra-high",
"sandbox": "read-only",
"tools": []
}
Expand Down Expand Up @@ -236,6 +242,6 @@
"reasons": [],
"triggered": false
},
"trial_id": "model-profile-trial:d965f949e25603e6d56293f9",
"trial_id": "model-profile-trial:e5267a218ea4136c9682a5ff",
"version": 1
}
13 changes: 13 additions & 0 deletions tests/test_capacity_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@ def test_nested_sandbox_never_widens_read_only_profile(monkeypatch):
assert command[command.index("--sandbox") + 1] == "read-only"


def test_full_tier_selects_astra_and_keeps_historical_sol_lookup():
assert adapters.resolve_model("codex", "full") == "gpt-6-astra"
active = execution_profiles.profiles_for_agent("codex")
full = [p for p in active if p["requested_model"] == adapters.resolve_model("codex", "full")]
assert [p["profile_id"] for p in full] == ["codex-6-astra-high"]
assert "codex-5.6-sol-high" not in {p["profile_id"] for p in active}
selected = execution_profiles.select_profile(
"implement", "o/r#full-tier", [p["profile_id"] for p in full], rng_seed=0
)
assert selected["selected_profile_id"] == "codex-6-astra-high"
assert execution_profiles.get_profile("codex-5.6-sol-high")["requested_model"] == "gpt-5.6-sol"


def test_router_profile_envelope_replays_exact_choice():
cap = capacity.profile_capacity_snapshot(
{
Expand Down
51 changes: 51 additions & 0 deletions tests/test_model_profile_trial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from __future__ import annotations

import json
import os
import shutil
import subprocess
from pathlib import Path

import pytest

Expand Down Expand Up @@ -325,3 +329,50 @@ def test_frozen_sol_trial_remains_valid_after_astra_migration(trial_roots, monke
)
assert "codex-6-astra-high" in fresh["launch_order"]
assert fresh["trial_id"] != frozen["trial_id"]


@pytest.mark.parametrize("profile_count", [2, 4])
def test_manifest_cardinality_follows_selected_profiles(trial_roots, monkeypatch, profile_count):
profiles = (
"codex-6-astra-high",
"codex-5.6-terra-high",
"codex-5.6-luna-high",
"codex-5.6-sol-high",
)[:profile_count]
monkeypatch.setattr(model_profile_trial, "EXPECTED_PROFILE_IDS", profiles)
manifest = model_profile_trial.build_trial_manifest(
*trial_roots, seed=14, now=1000, capacity_state="ok"
)
model_profile_trial.validate_trial_manifest(manifest)
results = trial_attempt_fixture.__wrapped__(manifest)
assert len(model_profile_trial._validate_results(manifest, results)) == profile_count
state = model_profile_trial.finalize_trial(manifest, results, now=1000)
assert state["shared_pool_debit"] == {"codex-subscription": float(profile_count)}
assert state["attempt_count"] == profile_count


def test_committed_rail_contract_accepts_current_astra_trial(tmp_path):
source = Path(__file__).parent / "rail_exercises/local-model-profile-trial/arm-a"
contract = json.loads((source / "contract.json").read_text())
fixture = source / "fixtures/local-model-profile-trial/manifest.json"
frozen = json.loads(fixture.read_text())
assert {r["profile_id"] for r in frozen["requests"]} == {
"codex-6-astra-high",
"codex-5.6-terra-high",
"codex-5.6-luna-high",
}
model_profile_trial.validate_trial_manifest(frozen)
copied = tmp_path / "arm-a"
shutil.copytree(source, copied)
roots = copied / "fixtures/local-model-profile-trial"
fresh = model_profile_trial.build_trial_manifest(
roots / "orch", roots / "workflows", seed=14, now=1000, capacity_state="ok"
)
(roots / "manifest.json").write_text(json.dumps(fresh))
result = subprocess.run(
["bash", "-eu", "-c", contract["pass_check"]],
env={**os.environ, "CONTRACT_DIR": str(copied)},
capture_output=True,
text=True,
)
assert result.returncode == 0, result.stderr
Loading