Files
cleveragents-core/robot/helper_m5_e2e_support.py
T
aditya 4e64544aae
CI / benchmark-publish (pull_request) Has been skipped
CI / quality (pull_request) Successful in 48s
CI / build (pull_request) Successful in 31s
CI / helm (pull_request) Successful in 21s
CI / lint (pull_request) Successful in 3m15s
CI / typecheck (pull_request) Successful in 4m4s
CI / security (pull_request) Successful in 4m13s
CI / unit_tests (pull_request) Successful in 4m28s
CI / docker (pull_request) Successful in 1m52s
CI / integration_tests (pull_request) Successful in 7m14s
CI / coverage (pull_request) Successful in 12m49s
CI / e2e_tests (pull_request) Successful in 22m8s
CI / status-check (pull_request) Successful in 2s
CI / benchmark-regression (pull_request) Successful in 57m27s
feat(acms): projects with 10,000+ files index without timeout
Add explicit indexing timeout bounds and propagate timeout_seconds through the repo indexing service, utility walker, and CLI entrypoint so large repositories fail predictably instead of hanging.

Add 10K-scale Behave/Robot verification and a dedicated benchmark path to validate that large-project indexing completes, persists status correctly, and remains measurable for regressions.

Address review feedback by splitting oversized Behave and Robot support files into focused modules, trimming repo_indexing_service.py back under the 500-line limit, and rebasing the branch onto current master.

ISSUES CLOSED: #851

# Conflicts:
#	CHANGELOG.md
#	robot/helper_m5_e2e_verification.py
2026-03-30 10:18:19 +00:00

95 lines
2.8 KiB
Python

"""Shared helpers for the M5 Robot E2E verification commands."""
from __future__ import annotations
import sys
from pathlib import Path
from typing import Any, NoReturn, cast
from sqlalchemy import create_engine
from sqlalchemy.orm import Session, sessionmaker
from cleveragents.application.services.resource_registry_service import (
ResourceRegistryService,
)
from cleveragents.domain.models.core.project import (
NamespacedProject,
parse_namespaced_name,
)
from cleveragents.infrastructure.database.models import Base
from cleveragents.infrastructure.database.repositories import (
NamespacedProjectRepository,
ProjectResourceLinkRepository,
)
def _fail(msg: str) -> NoReturn:
"""Print failure message to stderr and exit with code 1."""
print(f"FAIL: {msg}", file=sys.stderr)
raise SystemExit(1)
class _NoClose:
"""Session wrapper that suppresses ``close()`` for in-memory SQLite."""
def __init__(self, session: object) -> None:
object.__setattr__(self, "_s", session)
def close(self) -> None:
pass
def __getattr__(self, name: str) -> Any:
return getattr(object.__getattribute__(self, "_s"), name)
def _setup_db() -> tuple[
NamespacedProjectRepository,
ProjectResourceLinkRepository,
ResourceRegistryService,
Any,
]:
"""Create an in-memory SQLite DB with all tables."""
engine = create_engine("sqlite:///:memory:", echo=False)
Base.metadata.create_all(engine)
session = sessionmaker(bind=engine, expire_on_commit=False)()
wrapper = _NoClose(session)
def factory() -> Session:
return cast(Session, wrapper)
proj_repo = NamespacedProjectRepository(session_factory=factory)
link_repo = ProjectResourceLinkRepository(session_factory=factory)
svc = ResourceRegistryService(session_factory=factory)
svc.bootstrap_builtin_types()
return proj_repo, link_repo, svc, factory
def _create_project(
repo: NamespacedProjectRepository,
name: str,
description: str | None = None,
) -> NamespacedProject:
"""Create and return a NamespacedProject via the repository."""
parsed = parse_namespaced_name(name)
proj = NamespacedProject(
name=parsed.name,
namespace=parsed.namespace,
description=description,
)
repo.create(proj)
return repo.get(proj.namespaced_name)
def _create_large_python_repo(root: Path) -> int:
"""Populate *root* with 10,000 small Python files and return the count."""
file_count = 0
for i in range(100):
module_dir = root / f"module_{i:03d}"
module_dir.mkdir(parents=True, exist_ok=True)
for j in range(100):
(module_dir / f"file_{j:03d}.py").write_text(
f"def f_{i}_{j}():\n return {i + j}\n"
)
file_count += 1
return file_count