89 lines
2.5 KiB
Python
89 lines
2.5 KiB
Python
"""Helper script for Robot Framework automation profile smoke tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
# Ensure src is importable when run from workspace root
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
|
|
|
|
from cleveragents.domain.models.core.automation_profile import (
|
|
BUILTIN_PROFILES,
|
|
AutomationProfile,
|
|
get_builtin_profile,
|
|
)
|
|
|
|
_PROFILE_NAMES = [
|
|
"manual",
|
|
"review",
|
|
"supervised",
|
|
"cautious",
|
|
"trusted",
|
|
"auto",
|
|
"ci",
|
|
"full-auto",
|
|
]
|
|
|
|
|
|
def _test_profile(name: str) -> None:
|
|
"""Load a built-in profile and verify it."""
|
|
profile = get_builtin_profile(name)
|
|
assert isinstance(profile, AutomationProfile)
|
|
assert profile.name == name
|
|
assert 0.0 <= profile.auto_strategize <= 1.0
|
|
assert 0.0 <= profile.auto_execute <= 1.0
|
|
assert 0.0 <= profile.auto_apply <= 1.0
|
|
print(
|
|
f"profile-{name}-ok "
|
|
f"(sandbox={profile.require_sandbox}, "
|
|
f"checkpoints={profile.require_checkpoints}, "
|
|
f"unsafe={profile.allow_unsafe_tools})"
|
|
)
|
|
|
|
|
|
def _test_summary() -> None:
|
|
"""Print summary of all built-in profiles."""
|
|
assert len(BUILTIN_PROFILES) == 8
|
|
for name in _PROFILE_NAMES:
|
|
profile = get_builtin_profile(name)
|
|
thresholds = [
|
|
profile.auto_strategize,
|
|
profile.auto_execute,
|
|
profile.auto_apply,
|
|
profile.auto_decisions_strategize,
|
|
profile.auto_decisions_execute,
|
|
profile.auto_validation_fix,
|
|
profile.auto_strategy_revision,
|
|
profile.auto_reversion_from_apply,
|
|
profile.auto_child_plans,
|
|
profile.auto_retry_transient,
|
|
profile.auto_checkpoint_restore,
|
|
]
|
|
avg = sum(thresholds) / len(thresholds)
|
|
print(
|
|
f" {name:>12}: avg_threshold={avg:.2f} "
|
|
f"sandbox={profile.require_sandbox} "
|
|
f"checkpoints={profile.require_checkpoints} "
|
|
f"unsafe={profile.allow_unsafe_tools}"
|
|
)
|
|
print("summary-ok")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
cmd = sys.argv[1] if len(sys.argv) > 1 else "summary"
|
|
dispatch: dict[str, Any] = {
|
|
"summary": _test_summary,
|
|
}
|
|
# Add individual profile tests
|
|
for pname in _PROFILE_NAMES:
|
|
dispatch[pname] = lambda n=pname: _test_profile(n)
|
|
|
|
fn = dispatch.get(cmd)
|
|
if fn:
|
|
fn()
|
|
else:
|
|
print(f"Unknown command: {cmd}", file=sys.stderr)
|
|
sys.exit(1)
|