diff --git a/benchmarks/project_repository_bench.py b/benchmarks/project_repository_bench.py index 65d4d79f1..23552dbb2 100644 --- a/benchmarks/project_repository_bench.py +++ b/benchmarks/project_repository_bench.py @@ -15,6 +15,7 @@ from sqlalchemy.orm import sessionmaker from cleveragents.domain.models.core.project import NamespacedProject from cleveragents.infrastructure.database.models import ( Base, + NamespacedProjectModel, ResourceModel, ResourceTypeModel, ) @@ -96,8 +97,13 @@ class LinkRepositoryCRUD: session.commit() # Project - project_repo = NamespacedProjectRepository(session_factory=self.sf) - project_repo.create(NamespacedProject(name="link-bench", namespace="bench")) + proj = NamespacedProjectModel() + proj.namespaced_name = "bench/link-bench" # type: ignore[assignment] + proj.namespace = "bench" # type: ignore[assignment] + proj.tags_json = "[]" # type: ignore[assignment] + proj.created_at = _now_iso() # type: ignore[assignment] + proj.updated_at = _now_iso() # type: ignore[assignment] + session.add(proj) session.commit() # Resources diff --git a/benchmarks/resource_dag_bench.py b/benchmarks/resource_dag_bench.py index ec47baed9..81ed1b4f1 100644 --- a/benchmarks/resource_dag_bench.py +++ b/benchmarks/resource_dag_bench.py @@ -32,7 +32,7 @@ def _bench_ulid() -> str: _BENCH_CTR += 1 n = _BENCH_CTR suffix = "" - for _ in range(8): + for _ in range(7): suffix = _CB32[n % 32] + suffix n //= 32 return f"01HDAGBNCH0AQDYTR4B{suffix:>7s}"[:26] @@ -40,6 +40,7 @@ def _bench_ulid() -> str: def _seed_types( rt_repo: Any, + session_factory: Any, parent_name: str = "bench/dag-parent", child_name: str = "bench/dag-child", ) -> None: @@ -94,12 +95,16 @@ def _seed_types( built_in=False, ) rt_repo.create(parent_spec) - rt_repo.create(child_spec) + if child_name != parent_name: + rt_repo.create(child_spec) + # Commit so types survive across session boundaries (StaticPool). + session_factory().commit() def _make_resource( res_repo: Any, type_name: str, + session_factory: Any, ) -> str: """Create a resource and return its ID.""" from cleveragents.domain.models.core.resource import ( @@ -124,6 +129,8 @@ def _make_resource( updated_at=datetime.now(tz=UTC), ) res_repo.create(res) + # Commit so the resource survives across session boundaries. + session_factory().commit() return rid @@ -139,12 +146,12 @@ class TimeLinkChild: self.factory = _setup_db() self.rt_repo = ResourceTypeRepository(self.factory) self.res_repo = ResourceRepository(self.factory) - _seed_types(self.rt_repo) - self.parent_id = _make_resource(self.res_repo, "bench/dag-parent") + _seed_types(self.rt_repo, self.factory) + self.parent_id = _make_resource(self.res_repo, "bench/dag-parent", self.factory) self._child_ctr = 0 def time_link_child(self) -> None: - child_id = _make_resource(self.res_repo, "bench/dag-child") + child_id = _make_resource(self.res_repo, "bench/dag-child", self.factory) self.res_repo.link_child(self.parent_id, child_id) @@ -160,10 +167,11 @@ class TimeUnlinkChild: self.factory = _setup_db() self.rt_repo = ResourceTypeRepository(self.factory) self.res_repo = ResourceRepository(self.factory) - _seed_types(self.rt_repo) - self.parent_id = _make_resource(self.res_repo, "bench/dag-parent") - self.child_id = _make_resource(self.res_repo, "bench/dag-child") + _seed_types(self.rt_repo, self.factory) + self.parent_id = _make_resource(self.res_repo, "bench/dag-parent", self.factory) + self.child_id = _make_resource(self.res_repo, "bench/dag-child", self.factory) self.res_repo.link_child(self.parent_id, self.child_id) + self.factory().commit() def time_unlink_child(self) -> None: self.res_repo.unlink_child(self.parent_id, self.child_id) @@ -183,8 +191,8 @@ class TimeAutoDiscoverChildren: self.factory = _setup_db() self.rt_repo = ResourceTypeRepository(self.factory) self.res_repo = ResourceRepository(self.factory) - _seed_types(self.rt_repo) - self.parent_id = _make_resource(self.res_repo, "bench/dag-parent") + _seed_types(self.rt_repo, self.factory) + self.parent_id = _make_resource(self.res_repo, "bench/dag-parent", self.factory) def time_auto_discover_children(self) -> None: self.res_repo.auto_discover_children(self.parent_id) @@ -207,6 +215,7 @@ class TimeCycleDetection: self.res_repo = ResourceRepository(self.factory) _seed_types( self.rt_repo, + self.factory, "bench/chain-type", "bench/chain-type", ) @@ -214,7 +223,7 @@ class TimeCycleDetection: # Build a chain: r0 -> r1 -> ... -> rN self.chain_ids: list[str] = [] for _ in range(chain_depth + 1): - rid = _make_resource(self.res_repo, "bench/chain-type") + rid = _make_resource(self.res_repo, "bench/chain-type", self.factory) self.chain_ids.append(rid) for i in range(chain_depth): @@ -222,6 +231,7 @@ class TimeCycleDetection: self.chain_ids[i], self.chain_ids[i + 1], ) + self.factory().commit() def time_cycle_detection(self, chain_depth: int) -> None: """Attempt to close the cycle (should raise).""" diff --git a/robot/actor_configuration.robot b/robot/actor_configuration.robot index bb1235dd6..8fa6b50bf 100644 --- a/robot/actor_configuration.robot +++ b/robot/actor_configuration.robot @@ -31,7 +31,7 @@ V2 Actor Config Produces Provider And Graph Descriptor ... ${SPACE*4}publications: ... ${SPACE*6}- __output__ Create File ${config} ${content} - ${result}= Run Process ${PYTHON} robot/helper_actor_config.py ${config} stdout=PIPE stderr=PIPE + ${result}= Run Process ${PYTHON} robot/helper_actor_config.py ${config} Should Be Equal As Integers ${result.rc} 0 ${payload}= Evaluate __import__('json').loads('''${result.stdout.strip()}''') Should Be Equal ${payload['provider']} openai diff --git a/robot/changeset_capture.robot b/robot/changeset_capture.robot index ddb1c9496..ccb808124 100644 --- a/robot/changeset_capture.robot +++ b/robot/changeset_capture.robot @@ -13,7 +13,6 @@ File Write Produces ChangeSet Entry ... verify the resulting ChangeSet contains the entry. ${result}= Run Process ${PYTHON} -c ... ${CHANGESET_SCRIPT} - ... stdout=PIPE stderr=PIPE Log ${result.stdout} Log ${result.stderr} Should Be Equal As Integers ${result.rc} 0 @@ -24,7 +23,6 @@ ChangeSet Summary Counts Match [Documentation] Verify summary counts after multiple operations. ${result}= Run Process ${PYTHON} -c ... ${SUMMARY_SCRIPT} - ... stdout=PIPE stderr=PIPE Log ${result.stdout} Log ${result.stderr} Should Be Equal As Integers ${result.rc} 0 @@ -36,7 +34,6 @@ InMemoryChangeSetStore Round Trip [Documentation] Verify start/record/get via InMemoryChangeSetStore. ${result}= Run Process ${PYTHON} -c ... ${STORE_SCRIPT} - ... stdout=PIPE stderr=PIPE Log ${result.stdout} Log ${result.stderr} Should Be Equal As Integers ${result.rc} 0 diff --git a/robot/ci_nox_validation.robot b/robot/ci_nox_validation.robot index d4918d5b2..4017f4ff2 100644 --- a/robot/ci_nox_validation.robot +++ b/robot/ci_nox_validation.robot @@ -7,7 +7,7 @@ Library OperatingSystem Nox Lists All Required Sessions [Documentation] Verify that nox can list sessions and the required CI sessions are present [Tags] ci quality slow - ${result}= Run Process nox --list stdout=PIPE stderr=PIPE + ${result}= Run Process nox --list Should Be Equal As Integers ${result.rc} 0 msg=nox --list failed with: ${result.stderr} # Verify required sessions exist in nox output Should Contain ${result.stdout} lint @@ -28,5 +28,5 @@ CI Workflow File Exists Nox Lint Session Runs Successfully [Documentation] Verify that nox lint session can be invoked [Tags] ci quality slow - ${result}= Run Process nox -s lint stdout=PIPE stderr=PIPE timeout=120s + ${result}= Run Process nox -s lint timeout=120s Should Be Equal As Integers ${result.rc} 0 msg=nox -s lint failed: ${result.stderr} diff --git a/robot/plan_lifecycle_persistence.robot b/robot/plan_lifecycle_persistence.robot index ff52376d7..3ac4f8703 100644 --- a/robot/plan_lifecycle_persistence.robot +++ b/robot/plan_lifecycle_persistence.robot @@ -11,7 +11,7 @@ ${PYTHON} python Plan Lifecycle Persistence Via Helper Script [Documentation] Create action + plan, verify persistence through transitions ${result}= Run Process ${PYTHON} ${CURDIR}/helper_plan_lifecycle_persistence.py - ... stdout=STDOUT stderr=STDOUT timeout=30s + ... stderr=STDOUT timeout=30s Log ${result.stdout} Should Contain ${result.stdout} PASS: plan_lifecycle_persistence smoke test Should Be Equal As Integers ${result.rc} 0 diff --git a/robot/plan_repository.robot b/robot/plan_repository.robot index 1ed0fc846..f6ea572a3 100644 --- a/robot/plan_repository.robot +++ b/robot/plan_repository.robot @@ -11,7 +11,7 @@ ${PYTHON} python Plan Repository CRUD Via Helper Script [Documentation] Create, retrieve, list, count, and delete a plan via LifecyclePlanRepository ${result}= Run Process ${PYTHON} ${CURDIR}/helper_plan_repository.py - ... stdout=STDOUT stderr=STDOUT timeout=30s + ... stderr=STDOUT timeout=30s Log ${result.stdout} Should Contain ${result.stdout} PASS: plan_repository smoke test Should Be Equal As Integers ${result.rc} 0 diff --git a/robot/uow_lifecycle.robot b/robot/uow_lifecycle.robot index 08e02ec59..57acd1690 100644 --- a/robot/uow_lifecycle.robot +++ b/robot/uow_lifecycle.robot @@ -11,7 +11,7 @@ ${PYTHON} python UoW Lifecycle Action And Plan Via Helper Script [Documentation] Create action + plan via UoW, verify retrieval in new session ${result}= Run Process ${PYTHON} ${CURDIR}/helper_uow_lifecycle.py - ... stdout=STDOUT stderr=STDOUT timeout=30s + ... stderr=STDOUT timeout=30s Log ${result.stdout} Should Contain ${result.stdout} PASS: uow_lifecycle smoke test Should Be Equal As Integers ${result.rc} 0