Skip to content

Commit 2a68d08

Browse files
vilenariosclaude
andcommitted
verify_signature: propagate verify_commitment's precise reason field
Knock-on of the malformed-input label cleanup: ``verify_signature`` was hardcoding ``reason="unsupported_spec_version"`` whenever ``spec_status`` came back as ``"unsupported"``, which now overwrites the more specific ``"envelope_not_a_json_object"`` diagnostic that ``verify_commitment`` emits for non-dict input. The fix is a one-line change — fall back to the generic reason only when ``verify_commitment`` didn't supply one. Regression test pins ``verify_signature(None, engine)["reason"]``. Suite: 230 passed, 21 skipped. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent e3f1727 commit 2a68d08

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

ario_mlflow/verify.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,11 @@ def verify_signature(envelope: dict, proof_engine: ProofEngine) -> dict:
479479
"legacy_envelope": legacy,
480480
}
481481
if spec_status == "unsupported":
482-
out["reason"] = "unsupported_spec_version"
482+
# Propagate the more precise diagnostic from verify_commitment when
483+
# available (e.g. ``envelope_not_a_json_object`` for malformed input);
484+
# fall back to the generic ``unsupported_spec_version`` when the
485+
# envelope had a real-but-unknown spec major.
486+
out["reason"] = result.get("reason", "unsupported_spec_version")
483487
return out
484488

485489

tests/test_plugin_smoke.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,23 @@ def test_verify_signature_wrapper_surfaces_spec_version_state(tmp_path):
442442
assert out["reason"] == "unsupported_spec_version"
443443

444444

445+
def test_verify_signature_surfaces_specific_reason_for_non_dict_input(tmp_path):
446+
"""``verify_signature`` should pass the precise diagnostic from
447+
``verify_commitment`` through (``envelope_not_a_json_object`` for
448+
malformed input) rather than always overwriting with the generic
449+
``unsupported_spec_version``. ``ok=False`` is the safety guarantee;
450+
the precise ``reason`` is for diagnostics."""
451+
from ario_mlflow.verify import verify_signature
452+
453+
engine = ProofEngine(str(tmp_path / "priv"), str(tmp_path / "pub"))
454+
out = verify_signature(None, engine)
455+
assert out["ok"] is False
456+
assert out["signature_valid"] is False
457+
assert out["spec_version_status"] == "unsupported"
458+
assert out["legacy_envelope"] is False
459+
assert out["reason"] == "envelope_not_a_json_object"
460+
461+
445462
def test_verify_commitment_rejects_underscore_injection_on_agent_envelope(tmp_path):
446463
"""Profile-conditional ``_*`` strip: only mlflow envelopes are lenient.
447464

0 commit comments

Comments
 (0)