gateway: serve a local messaging bridge so skills can send/read SimpleX

The gateway now exposes a localhost stdlib HTTP API (bridge.py) that
buffers authorized inbound DMs and forwards outbound sends, so a skill
body never opens a WebSocket to the simplex-chat daemon. Endpoints:
GET /health, /contacts, /inbox (peek), /inbox/next (pop oldest unread),
POST /send (resolve id/display name onto the adapter's outbound queue).
GatewayService gains an observer hook and inbox.dispatch (pull-only mode).

Expose the capability to codegen (SKILL.md, BODY_DIRECTIVES, elicitation,
TESTGEN.md) and add the simplex.next_message seed (SemIf recipient
resolution) with its hermetic loopback test. Config: messaging_bridge_url
plus gateway.simplex.{inbox,bridge}; bootstrap keeps them in sync.
This commit is contained in:
Denton Social committed 2026-09-26 21:39:39 -05:00
1 parent b348f19486
commit 08d6bb23e2
19 files changed
+1006 -29

No files matched your search

+34 -17
View File
@@ -1,32 +1,47 @@
"""The committed seed skills are real, inspectable, and hermetically tested.
A seed is a starter integration shipped in the repo in the SKILL.md folder
format. These tests keep it honest: the declared integration must match the
code, the contract must cover what the body reads, and the hermetic mechanics
test must pass. They are not proof of the live integration — only a real run
against the user's service is (see AGENTS.md).
format. These tests keep every seed honest: the declared integration must match
the code, the contract must cover what the body reads, and the hermetic
mechanics test must pass. They are not proof of the live integration — only a
real run against the user's service is (see AGENTS.md).
"""
import json
import os
from pathlib import Path
import pytest
from semif_agent.codegen import integration_findings, parse_integration, run_skill_test
SEED = Path(__file__).resolve().parent.parent / "seeds" / "calendar" / "next_event"
SEEDS = Path(__file__).resolve().parent.parent / "seeds"
SEED_DIRS = sorted(path.parent for path in SEEDS.glob("*/*/skill.py"))
def test_seed_declares_a_real_integration():
code = (SEED / "skill.py").read_text()
def seed_id(seed: Path) -> str:
return f"{seed.parent.name}.{seed.name}"
def test_expected_seeds_exist():
ids = {seed_id(seed) for seed in SEED_DIRS}
assert "calendar.next_event" in ids
assert "simplex.next_message" in ids
@pytest.mark.parametrize("seed", SEED_DIRS, ids=[seed_id(s) for s in SEED_DIRS])
def test_seed_declares_a_real_integration(seed):
code = (seed / "skill.py").read_text()
integration = parse_integration(code)
assert integration["service"] == "nextcloud_calendar"
assert integration["transport"] == "caldav"
assert integration["service"]
assert integration["transport"]
assert integration_findings(integration, "declared", code) == []
def test_seed_contract_is_flat_and_covered_by_declaration():
code = (SEED / "skill.py").read_text()
contract = json.loads((SEED / "contract.json").read_text())
@pytest.mark.parametrize("seed", SEED_DIRS, ids=[seed_id(s) for s in SEED_DIRS])
def test_seed_contract_is_flat_and_covered_by_declaration(seed):
code = (seed / "skill.py").read_text()
contract = json.loads((seed / "contract.json").read_text())
assert contract, "the seed must carry a data contract"
for name, description in contract.items():
assert name.islower() and " " not in name, name
@@ -35,14 +50,16 @@ def test_seed_contract_is_flat_and_covered_by_declaration():
assert set(integration["config_vars"]) == set(contract)
def test_seed_has_manifest_description():
manifest = json.loads((SEED / "manifest.json").read_text())
@pytest.mark.parametrize("seed", SEED_DIRS, ids=[seed_id(s) for s in SEED_DIRS])
def test_seed_has_manifest_description(seed):
manifest = json.loads((seed / "manifest.json").read_text())
assert manifest["description"].strip()
def test_seed_hermetic_test_passes(monkeypatch):
root = str(SEED.parents[2])
@pytest.mark.parametrize("seed", SEED_DIRS, ids=[seed_id(s) for s in SEED_DIRS])
def test_seed_hermetic_test_passes(seed, monkeypatch):
root = str(seed.parents[2])
existing = os.environ.get("PYTHONPATH", "")
monkeypatch.setenv("PYTHONPATH", root + os.pathsep + existing)
passed, output = run_skill_test(SEED, timeout=30)
passed, output = run_skill_test(seed, timeout=30)
assert passed, output