007af498b8
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 17s
CI / helm (pull_request) Successful in 33s
CI / lint (pull_request) Successful in 3m42s
CI / security (pull_request) Successful in 4m8s
CI / quality (pull_request) Successful in 4m9s
CI / typecheck (pull_request) Successful in 4m20s
CI / integration_tests (pull_request) Successful in 7m2s
CI / unit_tests (pull_request) Successful in 7m55s
CI / docker (pull_request) Successful in 1m19s
CI / coverage (pull_request) Successful in 8m46s
CI / e2e_tests (pull_request) Successful in 16m1s
CI / status-check (pull_request) Successful in 1s
CI / build (push) Successful in 17s
CI / helm (push) Successful in 22s
CI / quality (push) Successful in 31s
CI / lint (push) Successful in 3m28s
CI / typecheck (push) Successful in 3m54s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 4m5s
CI / integration_tests (push) Successful in 6m13s
CI / unit_tests (push) Successful in 6m28s
CI / docker (push) Successful in 1m34s
CI / coverage (push) Successful in 12m5s
CI / e2e_tests (push) Successful in 18m47s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Successful in 28m0s
CI / benchmark-regression (pull_request) Successful in 59m48s
Renamed all 11 task-type confidence threshold fields in AutomationProfile from phase-transition semantics to spec-defined task-type semantics. Updated all 8 built-in profiles, CLI formatting, YAML schema, services, and all Behave/Robot tests referencing the old field names. Post-review fixes: - Fixed 24 stale old field names in M6 fixture files (automation_profiles.json, autonomy_guardrails.json) - Added model_validator(mode='before') to detect legacy field names and raise actionable ValueError with rename mapping - Added semantic bridge comments in PlanLifecycleService mapping task-type thresholds to phase-transition gates - Added threshold_field to structured log messages for observability - Restored categorised CLI automation-profile show output to match spec (Phase Transitions / Decision Automation / Self-Repair / Execution Controls) instead of flat list - Added missing access_network field to spec show output examples (Rich, Plain, JSON, YAML variants) - Aligned ADR-017 profile fields table to all 11 fields with descriptions matching spec Automatable Tasks table - Aligned automation_profiles.md threshold descriptions with spec - Added spec section references in phase_reversion.md, error_recovery.md, and plan_execute.md for field naming context - Extended repository roundtrip test to assert all 11 threshold fields - Fixed benchmark _make_profile() passing safety fields as top-level kwargs instead of via SafetyProfile sub-model (incompatible with extra="forbid") - Aligned CLI JSON/YAML output structure for automation-profile show with the specification grouped format (phase_transitions, decision_automation, self_repair, execution_controls) - Moved safety boolean fields into the Execution Controls section of Rich output per spec examples - Reverted auto profile description to "Fully automatic except apply" per specification (line 16703, line 28406) - Improved bridge comments in test steps with semantic context for threshold-to-gate mappings ISSUES CLOSED: #902
169 lines
5.7 KiB
Python
169 lines
5.7 KiB
Python
"""ASV benchmarks for Semantic Escalation confidence computation.
|
|
|
|
Measures the performance of:
|
|
- ConfidenceFactors model construction
|
|
- EscalationDecision model construction
|
|
- AutonomyController confidence computation
|
|
- AutonomyController.should_proceed_automatically end-to-end
|
|
- Historical outcome recording and success rate retrieval
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
try:
|
|
from cleveragents.application.services.autonomy_controller import (
|
|
AutonomyController,
|
|
)
|
|
from cleveragents.domain.models.core.automation_profile import (
|
|
BUILTIN_PROFILES,
|
|
)
|
|
from cleveragents.domain.models.core.escalation import (
|
|
ConfidenceFactors,
|
|
HistoricalOutcome,
|
|
OperationContext,
|
|
)
|
|
except ModuleNotFoundError:
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
|
|
from cleveragents.application.services.autonomy_controller import (
|
|
AutonomyController,
|
|
)
|
|
from cleveragents.domain.models.core.automation_profile import (
|
|
BUILTIN_PROFILES,
|
|
)
|
|
from cleveragents.domain.models.core.escalation import (
|
|
ConfidenceFactors,
|
|
HistoricalOutcome,
|
|
OperationContext,
|
|
)
|
|
|
|
|
|
class ConfidenceFactorsConstructionSuite:
|
|
"""Benchmark ConfidenceFactors model construction."""
|
|
|
|
def time_factors_construction_defaults(self) -> None:
|
|
"""Benchmark default ConfidenceFactors creation."""
|
|
ConfidenceFactors()
|
|
|
|
def time_factors_construction_full(self) -> None:
|
|
"""Benchmark fully-populated ConfidenceFactors creation."""
|
|
ConfidenceFactors(
|
|
past_success_rate=0.85,
|
|
codebase_familiarity=0.9,
|
|
risk_assessment=0.2,
|
|
invariant_complexity=0.3,
|
|
)
|
|
|
|
|
|
class ConfidenceComputationSuite:
|
|
"""Benchmark confidence score computation throughput."""
|
|
|
|
def setup(self) -> None:
|
|
"""Set up the controller and factors for benchmarking."""
|
|
self.controller = AutonomyController()
|
|
self.factors_high = ConfidenceFactors(
|
|
past_success_rate=0.95,
|
|
codebase_familiarity=0.9,
|
|
risk_assessment=0.1,
|
|
invariant_complexity=0.1,
|
|
)
|
|
self.factors_low = ConfidenceFactors(
|
|
past_success_rate=0.1,
|
|
codebase_familiarity=0.2,
|
|
risk_assessment=0.9,
|
|
invariant_complexity=0.8,
|
|
)
|
|
self.factors_neutral = ConfidenceFactors(
|
|
past_success_rate=0.5,
|
|
codebase_familiarity=0.5,
|
|
risk_assessment=0.5,
|
|
invariant_complexity=0.5,
|
|
)
|
|
|
|
def time_compute_confidence_high(self) -> None:
|
|
"""Benchmark confidence computation with high factors."""
|
|
self.controller.compute_confidence(self.factors_high)
|
|
|
|
def time_compute_confidence_low(self) -> None:
|
|
"""Benchmark confidence computation with low factors."""
|
|
self.controller.compute_confidence(self.factors_low)
|
|
|
|
def time_compute_confidence_neutral(self) -> None:
|
|
"""Benchmark confidence computation with neutral factors."""
|
|
self.controller.compute_confidence(self.factors_neutral)
|
|
|
|
|
|
class EscalationDecisionSuite:
|
|
"""Benchmark end-to-end escalation decision throughput."""
|
|
|
|
def setup(self) -> None:
|
|
"""Set up controller, factors, and profiles."""
|
|
self.controller = AutonomyController()
|
|
self.factors = ConfidenceFactors(
|
|
past_success_rate=0.8,
|
|
codebase_familiarity=0.75,
|
|
risk_assessment=0.15,
|
|
invariant_complexity=0.2,
|
|
)
|
|
self.operation = OperationContext(operation_type="create_tool")
|
|
self.profile_cautious = BUILTIN_PROFILES["cautious"]
|
|
self.profile_fullauto = BUILTIN_PROFILES["full-auto"]
|
|
self.profile_manual = BUILTIN_PROFILES["manual"]
|
|
|
|
def time_should_proceed_cautious(self) -> None:
|
|
"""Benchmark should_proceed_automatically with cautious profile."""
|
|
self.controller.should_proceed_automatically(
|
|
self.operation,
|
|
self.factors,
|
|
self.profile_cautious,
|
|
)
|
|
|
|
def time_should_proceed_fullauto(self) -> None:
|
|
"""Benchmark should_proceed_automatically with full-auto profile."""
|
|
self.controller.should_proceed_automatically(
|
|
self.operation,
|
|
self.factors,
|
|
self.profile_fullauto,
|
|
)
|
|
|
|
def time_should_proceed_manual(self) -> None:
|
|
"""Benchmark should_proceed_automatically with manual profile."""
|
|
self.controller.should_proceed_automatically(
|
|
self.operation,
|
|
self.factors,
|
|
self.profile_manual,
|
|
)
|
|
|
|
|
|
class HistoricalTrackingSuite:
|
|
"""Benchmark historical outcome recording and retrieval."""
|
|
|
|
def setup(self) -> None:
|
|
"""Set up controller with pre-populated history."""
|
|
self.controller = AutonomyController()
|
|
self.outcome_success = HistoricalOutcome(
|
|
operation_type="create_tool",
|
|
succeeded=True,
|
|
)
|
|
self.outcome_failure = HistoricalOutcome(
|
|
operation_type="create_tool",
|
|
succeeded=False,
|
|
)
|
|
# Pre-populate history
|
|
for _ in range(100):
|
|
self.controller.record_outcome(self.outcome_success)
|
|
|
|
def time_record_outcome(self) -> None:
|
|
"""Benchmark recording a single outcome."""
|
|
self.controller.record_outcome(self.outcome_success)
|
|
|
|
def time_get_success_rate(self) -> None:
|
|
"""Benchmark retrieving historical success rate."""
|
|
self.controller.get_historical_success_rate("create_tool")
|
|
|
|
def time_get_history_count(self) -> None:
|
|
"""Benchmark retrieving history count."""
|
|
self.controller.get_history_count("create_tool")
|