- harness/es.py: append-only event store + проекции (образец — кооп-портал) - harness/levels.py: уровни 1с/1м/1ч/1д, контекст ∝ масштабу - harness/scheduler.py: уровневые потоки, идемпотентные тики, absorbed-стабы - harness/isolated_runner.py + _llm_worker.py: LLM-тик в сабпроцессе (глобальный asyncio-рантайм Strands не переживает 2+ create_harness) - cli.py: init/task/tasks/status/events + requeue (написан самим минутным агентом) - 9router: отдельный ключ sk-simbiot, модель auto (glm-5.3 первым)
79 lines
2.1 KiB
Python
79 lines
2.1 KiB
Python
from __future__ import annotations
|
|
|
|
import sys
|
|
import types
|
|
from abc import ABCMeta, abstractmethod
|
|
from collections.abc import AsyncGenerator, Callable, Coroutine, Iterable
|
|
from typing import Any, TypeVar
|
|
|
|
if sys.version_info >= (3, 11):
|
|
from typing import Self
|
|
else:
|
|
from typing_extensions import Self
|
|
|
|
_T = TypeVar("_T")
|
|
|
|
|
|
class TestRunner(metaclass=ABCMeta):
|
|
"""
|
|
Encapsulates a running event loop. Every call made through this object will use the
|
|
same event loop.
|
|
"""
|
|
|
|
def __enter__(self) -> Self:
|
|
return self
|
|
|
|
@abstractmethod
|
|
def __exit__(
|
|
self,
|
|
exc_type: type[BaseException] | None,
|
|
exc_val: BaseException | None,
|
|
exc_tb: types.TracebackType | None,
|
|
) -> bool | None: ...
|
|
|
|
@abstractmethod
|
|
def run_asyncgen_fixture(
|
|
self,
|
|
fixture_func: Callable[..., AsyncGenerator[_T, Any]],
|
|
kwargs: dict[str, Any],
|
|
) -> Iterable[_T]:
|
|
"""
|
|
Run an async generator fixture.
|
|
|
|
:param fixture_func: the fixture function
|
|
:param kwargs: keyword arguments to call the fixture function with
|
|
:return: an iterator yielding the value yielded from the async generator
|
|
"""
|
|
|
|
@abstractmethod
|
|
def run_fixture(
|
|
self,
|
|
fixture_func: Callable[..., Coroutine[Any, Any, _T]],
|
|
kwargs: dict[str, Any],
|
|
) -> _T:
|
|
"""
|
|
Run an async fixture.
|
|
|
|
:param fixture_func: the fixture function
|
|
:param kwargs: keyword arguments to call the fixture function with
|
|
:return: the return value of the fixture function
|
|
"""
|
|
|
|
@abstractmethod
|
|
def run_test(
|
|
self, test_func: Callable[..., Coroutine[Any, Any, Any]], kwargs: dict[str, Any]
|
|
) -> None:
|
|
"""
|
|
Run an async test function.
|
|
|
|
:param test_func: the test function
|
|
:param kwargs: keyword arguments to call the test function with
|
|
"""
|
|
|
|
@abstractmethod
|
|
def is_running(self) -> bool:
|
|
"""
|
|
Check if the test runner is running.
|
|
|
|
:return: ``True`` if the coroutine is currently being run, ``False`` otherwise.
|
|
"""
|