M8.0/M8.V1: Add contract inference engine and deterministic conformance testing
This commit is contained in:
@@ -365,6 +365,28 @@ def _print_preflight_sections(report: dict, prefix: str = "") -> None:
|
||||
for value in values:
|
||||
print(f" {marker}: {value}")
|
||||
|
||||
proposal = report.get("contract_proposal") or {}
|
||||
proposed = {
|
||||
key: proposal.get(key)
|
||||
for key in ("input_schema", "output_schema")
|
||||
if proposal.get(key) is not None
|
||||
}
|
||||
if proposed:
|
||||
print(
|
||||
f"{prefix}Contract proposal "
|
||||
f"({proposal.get('confidence', 'low')} confidence; not saved):"
|
||||
)
|
||||
print(yaml.safe_dump(proposed, sort_keys=False).rstrip())
|
||||
|
||||
generated = report.get("generated_tests") or []
|
||||
if generated:
|
||||
print(f"{prefix}Contract conformance ({len(generated)} case(s)):")
|
||||
for result in generated:
|
||||
print(
|
||||
f" {str(result.get('state', 'not_run')).upper()}: "
|
||||
f"{result.get('step', 'unknown')} — {result.get('detail', '')}"
|
||||
)
|
||||
|
||||
|
||||
def _print_registry_suggestions(suggestions: dict) -> None:
|
||||
"""Render registry-specific category, similarity, and scrutiny evidence."""
|
||||
@@ -472,7 +494,9 @@ def _cmd_registry_publish(args):
|
||||
from ..preflight import analyze_tool
|
||||
from ..tool import Tool
|
||||
try:
|
||||
local_report = analyze_tool(Tool.from_dict(data))
|
||||
local_report = analyze_tool(
|
||||
Tool.from_dict(data), include_contract_tests=True
|
||||
)
|
||||
except (KeyError, TypeError, ValueError) as exc:
|
||||
print(f"Local preflight error: {exc}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user