File size: 4,366 Bytes
a436531 d3d78ce 157758d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | """Reconcile the declared training schedule, reported evidence and live activities."""
from thirdloss.records import HORIZONS, run_name
from thirdloss.report_records import study_snapshot
def test_inventory_distinguishes_full_training_development_and_frozen_test(tmp_path):
from thirdloss.run_inventory import inventory
study = study_snapshot(tmp_path)
for stage in HORIZONS:
study["context"][stage]["selection"] = {"ratios": {"trace": .01, "third": .01}}
run = run_name("abstracts", "ce", "confirm", 2, 0)
row = {"id": run, "stage": "abstracts", "phase": "confirm", "method": "ce", "seed": 2, "ratio": 0.,
"tokens": HORIZONS["abstracts"], "status": "scoring development", "evaluation_progress": {
"split": "dev", "targets_scored": 37, "targets_to_score": 101}}
study["runs"] = [row]
plan = inventory(study)
item = next(job for job in plan["fits"] if job["id"] == run)
assert item["fit"] == "Scoring development" and item["test"] == "Awaiting freeze"
assert "37/101" in plan["activity"][0]
assert len(plan["fits"]) == 128 and plan["total"] == 304 and plan["done"] == 0
row.update(status="complete", dev_nll=3.0, flatness={}, score_flatness={})
row["evaluation_progress"] = {"split": "test", "targets_scored": 10, "targets_to_score": 27}
study["frozen_stages"] = ["abstracts"]
plan = inventory(study)
item = next(job for job in plan["fits"] if job["id"] == run)
assert item["fit"] == "Complete" and item["test"] == "Scoring test" and item["geometry"] == "Complete"
assert plan["done"] == 2 and "10/27" in plan["activity"][0]
row.pop("evaluation_progress")
row.update(test_nll=3.1)
study["runs"].append({**row, "id": "early-fp32", "phase": "diagnostic", "method": "third"})
plan = inventory(study)
assert plan["done"] == 4 and plan["total"] == 305
assert sum(job["phase"] == "diagnostic" for job in plan["fits"]) == 1
assert not plan["activity"]
def test_queue_keeps_unknown_strength_explicit_and_defers_the_cyclic_replay(tmp_path):
from thirdloss.run_inventory import inventory
study = study_snapshot(tmp_path)
plan = inventory(study)
assert plan["next"] == "TinyStories · Third derivative · pilot seed 0 (3%)"
unselected = next(j for j in plan["fits"] if j["stage"] == "abstracts" and j["phase"] == "confirm"
and j["method"] == "third" and j["seed"] == 1)
assert unselected["id"] is None and unselected["ratio"] is None
hybrid = [j for j in plan["fits"] if j["phase"] == "hybrid"]
assert (hybrid[-1]["seed"], hybrid[-1]["method"]) == (21, "replay")
def test_standalone_status_reads_the_sealed_final_analysis(tmp_path):
"""A fresh progress process recognizes the same final milestone as the published report."""
from thirdloss.records import write_json
from thirdloss.run_inventory import inventory
root = tmp_path / "results"
write_json(root / "analysis" / "seed-sensitivity.json", {"sealed_at": "final", "rows": []})
assert not inventory(study_snapshot(tmp_path))["final"]
write_json(root / "freeze" / "seed-sensitivity.json", {"sealed_at": "final"})
assert inventory(study_snapshot(tmp_path))["final"]
def test_pause_uses_durable_progress_and_leaves_the_queue_idle(tmp_path):
"""Uncommitted log entries remain available in the raw interrupted attempt."""
from thirdloss.live_hub import overlay
from thirdloss.records import write_json
from thirdloss.run_inventory import inventory
run = run_name("stories", "third", "pilot", 0, .03)
folder = tmp_path / "results" / run
write_json(folder / "config.json", {"stage": "stories", "method": "third", "phase": "pilot", "seed": 0, "ratio": .03})
write_json(folder / "state.json", {"status": "paused", "checkpoint_step": 2})
(folder / "events.jsonl").write_text('{"step":2,"tokens":4}\n{"step":3,"tokens":6}\n', encoding="utf-8")
study = study_snapshot(tmp_path)
row = study["runs"][0]
assert (row["status"], row["steps"], row["tokens"]) == ("paused", 2, 4)
plan = inventory(study)
assert plan["paused"] and not plan["activity"] and run == plan["fits"][0]["id"]
assert "Third derivative" in plan["next"] and plan["done"] == 0
update = overlay(study)
assert not update["active"] and update["runs"][0]["status"] == "paused"
|