Harden M8 trust and guidance workflows
This commit is contained in:
@@ -126,6 +126,71 @@ class TestAnalyzeTool:
|
||||
_check_similar_tools(SimpleNamespace(name="summarize"), report, Client())
|
||||
assert report.similar_tools[0]["name"] == "official/summary"
|
||||
|
||||
def test_server_audit_does_not_claim_skipped_local_checks(self):
|
||||
from cmdforge.tool import Tool, ToolStep
|
||||
|
||||
report = analyze_tool(
|
||||
Tool(name="server", steps=[ToolStep(tool="child", output_var="out")]),
|
||||
check_local_dependencies=False,
|
||||
)
|
||||
checks = report.audit_evidence["checks_run"]
|
||||
assert "dependencies" not in checks
|
||||
assert "toolstep_compatibility" not in checks
|
||||
assert "reuse_opportunities" not in checks
|
||||
assert report.compatibility == []
|
||||
|
||||
def test_unrelated_code_steps_are_not_reuse_evidence(self):
|
||||
from cmdforge.tool import CodeStep, Tool
|
||||
|
||||
current = Tool(
|
||||
name="current", input_schema={}, output_schema={},
|
||||
steps=[
|
||||
CodeStep(code="x = 1", output_var="x"),
|
||||
CodeStep(code="y = 2", output_var="y"),
|
||||
],
|
||||
)
|
||||
other = Tool(
|
||||
name="other", input_schema={}, output_schema={},
|
||||
steps=[
|
||||
CodeStep(code="a = 99", output_var="a"),
|
||||
CodeStep(code="b = 100", output_var="b"),
|
||||
],
|
||||
)
|
||||
with patch("cmdforge.tool.list_tools", return_value=["other"]), patch(
|
||||
"cmdforge.tool.load_tool", return_value=other
|
||||
):
|
||||
report = analyze_tool(current)
|
||||
assert report.reuse_opportunities == []
|
||||
|
||||
def test_exact_contracted_duplicate_has_evidence(self):
|
||||
from cmdforge.tool import PromptStep, Tool
|
||||
|
||||
def make(name):
|
||||
return Tool(
|
||||
name=name, input_schema={}, output_schema={"type": "string"},
|
||||
steps=[
|
||||
PromptStep(
|
||||
prompt="first", provider="mock", output_var="one",
|
||||
output_schema={"type": "string"},
|
||||
),
|
||||
PromptStep(
|
||||
prompt="second", provider="mock", output_var="two",
|
||||
output_schema={"type": "string"},
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
with patch("cmdforge.tool.list_tools", return_value=["other"]), patch(
|
||||
"cmdforge.tool.load_tool", return_value=make("other")
|
||||
):
|
||||
report = analyze_tool(make("current"))
|
||||
duplicate = [
|
||||
item for item in report.reuse_opportunities
|
||||
if item["type"] == "duplicate_sequence"
|
||||
]
|
||||
assert duplicate
|
||||
assert "explicit tool contracts" in duplicate[0]["evidence"]
|
||||
|
||||
def test_registry_error_becomes_warning(self):
|
||||
class Client:
|
||||
def search_tools(self, query, per_page):
|
||||
|
||||
Reference in New Issue
Block a user