bridges: derive skill config vars from the bridge block
Bridge listener addresses were hand-maintained duplicates of bridges.<name>.host/port at the top level (simplex_bridge_url, llm_bridge_url, nextcloud_bridge_url, plus their _token). A host provisioned before a bridge was added never gained the key, so a skill for that bridge could not resolve its URL: the contract config search fell back to 'ask' and a front end captured an unrelated reply as the value (a voice task request was recorded as nextcloud_bridge_url). Add bridges.registry.derived_config_vars(config): for every catalog bridge, derive <name>_bridge_url/<name>_bridge_token from its own bridges.<name> host/port/token. build_scheduler injects these into the config the scheduler and ctx.config expose, so the contract config search finds them and skills read them with no top-level duplicate. A block with no port contributes no URL, leaving an unconfigured bridge as an unresolved variable the operator is asked for. Bind-all hosts normalize to 127.0.0.1. Remove the six redundant top-level keys from config.example.json and update README/AGENTS/bootstrap notes. Tests cover derivation, bind-all normalization, and the unconfigured-bridge skip.
This commit is contained in:
1 parent
d9cc7e4fed
commit
228886f7cd
8 files changed
+113
-36
No files matched your search
+38
-1
@@ -15,7 +15,11 @@ import urllib.request
|
||||
import pytest
|
||||
|
||||
from semif_agent.bridges.llm import LLMBridge
|
||||
from semif_agent.bridges.registry import describe_bridges, known_infos
|
||||
from semif_agent.bridges.registry import (
|
||||
derived_config_vars,
|
||||
describe_bridges,
|
||||
known_infos,
|
||||
)
|
||||
from semif_agent.bridges.simplex import SimplexBridge
|
||||
|
||||
|
||||
@@ -674,6 +678,39 @@ def test_every_bridge_documents_its_config_vars_and_auth():
|
||||
assert info.auth_config_var in info.config_vars, info.name
|
||||
|
||||
|
||||
def test_derived_config_vars_come_from_each_bridge_block():
|
||||
config = {
|
||||
"bridges": {
|
||||
"simplex": {"host": "127.0.0.1", "port": 5227, "token": "s"},
|
||||
"llm": {"host": "127.0.0.1", "port": 5229, "token": ""},
|
||||
"nextcloud": {"host": "127.0.0.1", "port": 5230, "token": "n"},
|
||||
}
|
||||
}
|
||||
derived = derived_config_vars(config)
|
||||
assert derived["simplex_bridge_url"] == "http://127.0.0.1:5227"
|
||||
assert derived["simplex_bridge_token"] == "s"
|
||||
assert derived["llm_bridge_url"] == "http://127.0.0.1:5229"
|
||||
assert derived["llm_bridge_token"] == ""
|
||||
assert derived["nextcloud_bridge_url"] == "http://127.0.0.1:5230"
|
||||
assert derived["nextcloud_bridge_token"] == "n"
|
||||
|
||||
|
||||
def test_derived_config_vars_normalize_bind_all_host():
|
||||
config = {"bridges": {"llm": {"host": "0.0.0.0", "port": 5229}}}
|
||||
assert derived_config_vars(config)["llm_bridge_url"] == "http://127.0.0.1:5229"
|
||||
|
||||
|
||||
def test_derived_config_vars_skip_unconfigured_bridges():
|
||||
# No block at all: nothing derived, so the contract variable stays
|
||||
# unresolved and the operator is asked for it.
|
||||
assert derived_config_vars({}) == {}
|
||||
# A block without a port is not a callable address: no URL, but the token
|
||||
# var is still satisfiable (empty = no auth).
|
||||
derived = derived_config_vars({"bridges": {"nextcloud": {"token": ""}}})
|
||||
assert "nextcloud_bridge_url" not in derived
|
||||
assert derived["nextcloud_bridge_token"] == ""
|
||||
|
||||
|
||||
def test_describe_bridges_renders_service_auth_and_endpoints():
|
||||
text = describe_bridges()
|
||||
assert "simplex" in text
|
||||
|
||||
Reference in new issue
Block a user