diff --git a/src/soup_cli/commands/shrink.py b/src/soup_cli/commands/shrink.py index d03c8d3..77832ff 100644 --- a/src/soup_cli/commands/shrink.py +++ b/src/soup_cli/commands/shrink.py @@ -378,7 +378,7 @@ def _attach_to_registry(registry_id: str, report_path: str) -> None: ) return try: - attach_artifact(registry_id, "shrink_report", report_path) + attach_artifact(registry_id, path=report_path, kind="shrink_report") console.print( f"[green]Attached[/] shrink_report to registry entry [bold]{escape(registry_id)}[/]" ) diff --git a/src/soup_cli/registry/store.py b/src/soup_cli/registry/store.py index ed336c8..ca7cc92 100644 --- a/src/soup_cli/registry/store.py +++ b/src/soup_cli/registry/store.py @@ -50,6 +50,8 @@ _VALID_KINDS = frozenset( # v0.71.9 #194/#203 — knowledge-edited models + GRACE codebooks. "edited_model", "grace_codebook", + # v0.71.29 — depth-prune + distill-heal shrink reports. + "shrink_report", } ) _VALID_RELATIONS = frozenset( diff --git a/tests/test_v07129.py b/tests/test_v07129.py index dd0d3d8..02fe487 100644 --- a/tests/test_v07129.py +++ b/tests/test_v07129.py @@ -601,3 +601,47 @@ class TestHeal: "--calib", "calib.jsonl", "--heal", str(outside), "--device", "cpu"], ) assert r.exit_code != 0 + + +# --------------------------------------------------------------------------- +# Task 6 — registry attach (real round-trip) +# --------------------------------------------------------------------------- +class TestRegistryAttach: + def test_attach_round_trip(self, tmp_path, monkeypatch): + """_attach_to_registry attaches a shrink_report artifact to a real + registry entry (keyword-correct call; not the diagnose positional bug).""" + monkeypatch.setenv("SOUP_REGISTRY_DB_PATH", str(tmp_path / "reg.db")) + monkeypatch.chdir(tmp_path) + + from soup_cli.commands.shrink import _attach_to_registry + from soup_cli.registry.store import RegistryStore + + with RegistryStore() as store: + entry_id = store.push( + name="tiny-shrunk", + tag="test", + base_model="HuggingFaceTB/SmolLM2-135M", + task="sft", + run_id=None, + config={"task": "sft"}, + ) + + report = tmp_path / "shrink_report.json" + report.write_text('{"decision":"SHIP"}', encoding="utf-8") + + _attach_to_registry(entry_id, str(report)) + + with RegistryStore() as store: + artifacts = store.get_artifacts(entry_id) + assert any(a.get("kind") == "shrink_report" for a in artifacts), artifacts + + def test_attach_unknown_entry_warns_no_raise(self, tmp_path, monkeypatch): + monkeypatch.setenv("SOUP_REGISTRY_DB_PATH", str(tmp_path / "reg2.db")) + monkeypatch.chdir(tmp_path) + + from soup_cli.commands.shrink import _attach_to_registry + + report = tmp_path / "shrink_report.json" + report.write_text('{"decision":"SHIP"}', encoding="utf-8") + # Must not raise even for a nonexistent entry (best-effort warn). + _attach_to_registry("nonexistent-id", str(report))