Files
cleveragents-core/benchmarks/unified_context_models_bench.py
T
CoreRasurae 80f1664a0d
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 23s
CI / lint (pull_request) Successful in 3m20s
CI / typecheck (pull_request) Successful in 3m54s
CI / security (pull_request) Successful in 4m13s
CI / quality (pull_request) Successful in 4m17s
CI / integration_tests (pull_request) Successful in 9m21s
CI / unit_tests (pull_request) Successful in 9m42s
CI / docker (pull_request) Successful in 14s
CI / e2e_tests (pull_request) Successful in 12m1s
CI / coverage (pull_request) Successful in 11m41s
CI / status-check (pull_request) Successful in 1s
CI / build (push) Successful in 26s
CI / lint (push) Successful in 3m19s
CI / quality (push) Successful in 3m41s
CI / typecheck (push) Successful in 3m56s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 4m2s
CI / integration_tests (push) Successful in 9m3s
CI / unit_tests (push) Successful in 9m24s
CI / docker (push) Successful in 1m9s
CI / e2e_tests (push) Successful in 13m51s
CI / coverage (push) Successful in 11m25s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Failing after 24m52s
CI / benchmark-regression (pull_request) Failing after 37m6s
test(integration): workflow example 7 — CI/CD integration, automated PR review and fix (ci profile)
Implemented Robot Framework integration test suite validating the CI/CD
workflow (Specification Example 7). Tests cover ci-profile configuration
(automation-profile, format, log level), idempotent resource and project
registration with duplicate-detection assertions, three validation tools
(ci-lint, ci-typecheck, ci-tests) registration and resource attachment
via ToolRegistryService, action creation with typed arguments and
invariants per spec Step 2, plan lifecycle with phase-by-phase completion
through all phases (strategize, execute, apply) until terminal applied
state, and JSON output structure verification including plan_id, phase,
state, action, projects, and arguments fields.

Post-review fixes applied (round 1):
- H1: Fix truncated invariant #2 text to match spec line 39051
- H2: Fix definition_of_done to match spec's 5-bullet-point format
- M1: Register all 3 spec validations (ci-lint, ci-typecheck, ci-tests)
- M3: Add branch property to resource registration per spec Step 3
- M4: Replace phantom resource_id with real registered resource
- M5: Add projects and arguments field assertions to JSON output test
- M7: Replace 'polling-based' with 'phase-by-phase' in docs/comments
- L1: Use timezone-aware datetime (timezone.utc)
- L2: Use tempfile for resource path instead of hardcoded /tmp
- L3: Clarify json_output() docstring to reflect as_cli_dict() scope
- L4: Tighten attachment count assertion from >= 1 to == 1 (now == 3)

Post-review fixes applied (round 2):
- M2: Use Setup Test Environment With Database Isolation for pabot safety
- L1: Replace remaining hardcoded /tmp paths with tempfile (validation_attach,
  resource_idempotent duplicate registration)
- L2: Fix stale 'Polling-based' comment missed in round 1
- L5: Align action description with spec line 39027
- M1/L3/L6: Document automation_profile propagation gap in use_action()
  with TODO for when production code wires the field onto Plan
- L4: Add comment explaining local actor name deviation from spec

Includes CHANGELOG update describing the integration test scope.

ISSUES CLOSED: #771
2026-03-26 21:42:37 +00:00

129 lines
4.2 KiB
Python

"""ASV benchmarks for unified CRP/core context model hierarchy.
Measures the construction throughput for core types that extend CRP base
types via Pydantic v2 inheritance, and the isinstance-check overhead.
"""
from __future__ import annotations
import importlib
import sys
from pathlib import Path
# Ensure the local *source* tree is importable even when ASV has an
# older build of the package installed.
_SRC = str(Path(__file__).resolve().parents[1] / "src")
if _SRC not in sys.path:
sys.path.insert(0, _SRC)
# Force-reload the top-level package so Python picks up the source tree
# version instead of the potentially stale installed copy.
import cleveragents # noqa: E402
importlib.reload(cleveragents)
from cleveragents.domain.models.acms.crp import ( # noqa: E402
AssembledContext as CRPAssembledContext,
)
from cleveragents.domain.models.acms.crp import ( # noqa: E402
ContextBudget as CRPContextBudget,
)
from cleveragents.domain.models.acms.crp import ( # noqa: E402
ContextFragment as CRPContextFragment,
)
from cleveragents.domain.models.acms.crp import ( # noqa: E402
FragmentProvenance as CRPFragmentProvenance,
)
from cleveragents.domain.models.core.context_fragment import ( # noqa: E402
ContextBudget,
ContextFragment,
ContextPayload,
FragmentProvenance,
)
class TimeUnifiedModelCreation:
"""Benchmark unified model construction throughput."""
timeout = 60
def setup(self) -> None:
"""Prepare reusable inputs."""
self.provenance = FragmentProvenance(
resource_uri="uko-py:module/bench",
strategy="benchmark-strategy",
resource_type="git-checkout",
)
def time_fragment_provenance(self) -> None:
"""Create core FragmentProvenance (inherits CRP)."""
for _ in range(1000):
FragmentProvenance(
resource_uri="uko-py:module/bench",
strategy="arce",
resource_type="git-checkout",
)
def time_context_fragment(self) -> None:
"""Create core ContextFragment (inherits CRP)."""
for _ in range(1000):
ContextFragment(
uko_node="project://bench",
content="benchmark fragment",
token_count=100,
tier="hot",
provenance=self.provenance,
)
def time_context_budget(self) -> None:
"""Create core ContextBudget (inherits CRP)."""
for _ in range(1000):
b = ContextBudget(max_tokens=8192, reserved_tokens=1024)
_ = b.available_tokens
def time_context_payload(self) -> None:
"""Create core ContextPayload (inherits CRP AssembledContext)."""
for _ in range(1000):
ContextPayload(plan_id="01JQBENCHPN0000000000000AA")
class TimeIsinstanceChecks:
"""Benchmark isinstance compatibility checks."""
timeout = 60
def setup(self) -> None:
"""Prepare instances."""
prov = FragmentProvenance(resource_uri="uko-py:module/bench")
self.provenance = prov
self.fragment = ContextFragment(
uko_node="project://bench",
content="benchmark fragment",
token_count=100,
provenance=prov,
)
self.budget = ContextBudget(max_tokens=4096, reserved_tokens=512)
self.payload = ContextPayload(
plan_id="01JQBENCHPN0000000000000AA",
)
def time_isinstance_provenance(self) -> None:
"""isinstance check: FragmentProvenance against CRP base."""
for _ in range(10000):
isinstance(self.provenance, CRPFragmentProvenance)
def time_isinstance_fragment(self) -> None:
"""isinstance check: ContextFragment against CRP base."""
for _ in range(10000):
isinstance(self.fragment, CRPContextFragment)
def time_isinstance_budget(self) -> None:
"""isinstance check: ContextBudget against CRP base."""
for _ in range(10000):
isinstance(self.budget, CRPContextBudget)
def time_isinstance_payload(self) -> None:
"""isinstance check: ContextPayload against CRP AssembledContext."""
for _ in range(10000):
isinstance(self.payload, CRPAssembledContext)