Decouple bridges: ship each with its pack
The core no longer owns concrete bridge implementations. A bridge now ships inside the pack that declares it (packs/<name>/bridge/<name>.py, plus its package marker, optional client module, and hermetic test), and the core registry imports it by convention from the pack's `bridges`. Core keeps only: - bridges/base.py: BridgeInfo + BridgeService (shared HTTP/JSON/auth layer), plus a new BridgeService.from_config build hook (a bridge that needs the scheduler's `llm` client or top-level fallback values declares that itself, replacing build_bridge's per-name special-casing) and checkout_root() so a pack-relative bridge can still anchor .runtime/ paths; - bridges/inbox.py: the generic MessagingInbox; - bridges/llm.py: the one shared, pack-less LLMBridge (CORE_BRIDGES); - bridges/registry.py: discovery (discover_bridge_classes/known_infos/ describe_bridges/derived_config_vars/build_bridge/run_bridges) scanning each pack's bridge/ dir, plus load_pack_bridge_module/package for tests. Moved to their packs: simplex, nextcloud (+client), outlook (+client), browser (+client) — each with its hermetic test. tests/test_bridges.py now covers the core (shared LLM bridge + registry); tests/test_packs.py runs every pack's bridge test. Docs (AGENTS.md, PACKGEN.md, README.md) updated. Packs pushed separately to pack.<name>.
This commit is contained in:
1 parent
16e8583921
commit
41c18e6c47
21 files changed
+485
-7476
No files matched your search
@@ -10,6 +10,8 @@ user's service is (see AGENTS.md).
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
@@ -29,6 +31,7 @@ from semif_agent.packs import (
|
||||
|
||||
PACKS = Path(__file__).resolve().parent.parent / "packs"
|
||||
SKILL_DIRS = sorted(path.parent for path in PACKS.glob("*/skills/*/*/skill.py"))
|
||||
BRIDGE_TESTS = sorted(PACKS.glob("*/bridge/test_*.py"))
|
||||
|
||||
|
||||
def seed_id(seed: Path) -> str:
|
||||
@@ -152,3 +155,31 @@ def test_seed_hermetic_test_passes(seed, monkeypatch):
|
||||
monkeypatch.setenv("PYTHONPATH", root + os.pathsep + existing)
|
||||
passed, output = run_skill_test(seed, timeout=30)
|
||||
assert passed, output
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"test_file", BRIDGE_TESTS, ids=[f"{p.parent.parent.name}/{p.name}" for p in BRIDGE_TESTS]
|
||||
)
|
||||
def test_pack_bridge_test_passes(test_file):
|
||||
"""A bridge ships with its pack; its hermetic test runs from the pack.
|
||||
|
||||
The bridge tests are pytest modules (they use fixtures and `pytest.raises`),
|
||||
so they run in a subprocess with the checkout on `PYTHONPATH` — the same
|
||||
import path a real run uses. A pack that declares a bridge but ships no test
|
||||
is a hole; this parametrization picks up exactly the tests that exist, and
|
||||
`test_pack_manifests_are_valid` keeps the packs present.
|
||||
"""
|
||||
root = str(PACKS.parent)
|
||||
env = {
|
||||
**os.environ,
|
||||
"PYTHONPATH": root + os.pathsep + os.environ.get("PYTHONPATH", ""),
|
||||
}
|
||||
proc = subprocess.run(
|
||||
[sys.executable, "-m", "pytest", str(test_file), "-q", "-p", "no:cacheprovider"],
|
||||
cwd=root,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=300,
|
||||
env=env,
|
||||
)
|
||||
assert proc.returncode == 0, (proc.stdout or "") + (proc.stderr or "")
|
||||
Reference in new issue
Block a user