This repository has been archived on 2026-08-04. You can view files and clone it, but cannot push or open issues or pull requests.
orchestrator/agent-team/tests/sim/conftest.py
Adam Moussa 15a416d31a Add Plane-2 leaf scaffold (pipeline graph, nodes, HITL, transports, CI)
Consolidates the 18 leaf modules from the r720-plane2-scaffold workflow onto
the foundation commit. Full suite: 535 passed, 1 skipped; ruff + format clean.

Built (pre-deployment scaffold only — nothing provisioned/enabled):
- LangGraph pipeline graph.py (INTAKE->CLARIFY->PLAN, interrupt()/resume, checkpointer-injectable)
- nodes: clarifier (98% gate), planner, review_loop (GPT-4.1), builders->candidate diff, verifier
- §3.3.1 HITL: ledger ops, resume_worker, deadline_timer, recovery sweep, responder
- transports: slack / github / claude_code adapters
- ci_gate (pure-code pass/fail), operator_cli, run-team.py entry, P1 sim harness
- ci/agent-team-apply-verify.yml (split untrusted/privileged jobs) — authored, disabled

KNOWN OPEN FINDINGS (verifier/cross-review, not yet fixed — see follow-up):
- builders denylist: 4 execution-proven bypasses (delete, mode-change, copy-to, out-of-scope delete)
- §3.3.1 CAS: BEGIN IMMEDIATE outside try/except; shared-connection txn nesting unsafe under concurrency
- operator_cli: missing re-deliver/force-resume; audit-after-mutate ordering gap
- ci yaml: GPT-4.1 cross-review PASS w/ 4 FIX items (symlink path escape, etc.)
- P1 sim harness models the ledger layer, not real LangGraph interrupt/resume; P1 exit criteria not yet truly proven

Deploy-gated (NOT done): IAM/step-ca/Roles Anywhere/confluence-bot provisioning,
/sh-security-review sign-off, live Slack/CI, rsync, live dry-runs, Adam approval.
2026-06-17 15:16:12 -04:00

65 lines
2.2 KiB
Python

"""Pytest fixtures for the P1 exit-criteria simulation (design §7.1 P1).
The parent ``tests/conftest.py`` already puts the ``agent-team/`` project root
on ``sys.path`` so ``agent_team`` (the committed foundation) imports cleanly.
This sim-level conftest adds the local ``tests/sim`` directory to ``sys.path``
so the sibling :mod:`harness` module imports the same way under any pytest
``rootdir``/import mode, and exposes the shared fixtures the four exit-criteria
tests build on.
These fixtures construct the harness against the *real* committed foundation
(the SQLite ``pending_questions`` ledger and the atomic, integrity-checked
state store) rooted under a pytest ``tmp_path``, so every test gets an
isolated, durable, on-disk pipeline and nothing touches live infrastructure.
"""
from __future__ import annotations
import sys
from pathlib import Path
from typing import Iterator
import pytest
# Make the sibling ``harness`` module importable regardless of pytest's import
# mode / rootdir (the parent conftest handles the ``agent_team`` package root).
_SIM_DIR = Path(__file__).resolve().parent
if str(_SIM_DIR) not in sys.path:
sys.path.insert(0, str(_SIM_DIR))
from harness import ( # noqa: E402 (path injected above)
PostFailingTransport,
RecordingTransport,
SimClock,
SimPipeline,
)
@pytest.fixture
def clock() -> SimClock:
"""A fresh advanceable simulation clock starting at tick 0."""
return SimClock(start=0)
@pytest.fixture
def transport() -> RecordingTransport:
"""An in-memory recording transport (faithful Transport subclass, no Slack)."""
return RecordingTransport(name="sim")
@pytest.fixture
def post_failing_transport() -> PostFailingTransport:
"""A transport whose first ``post_question`` raises (lost-post simulation)."""
return PostFailingTransport(name="sim", fail_times=1)
@pytest.fixture
def pipeline(
tmp_path: Path, clock: SimClock, transport: RecordingTransport
) -> Iterator[SimPipeline]:
"""A durable :class:`SimPipeline` rooted under an isolated ``tmp_path``.
Backed by the real ``pending_questions`` SQLite ledger and the real atomic
state store; teardown is the ``tmp_path`` cleanup pytest already does.
"""
yield SimPipeline(tmp_path / "state", clock=clock, transport=transport)