load committed seeds regardless of cwd; fix skills listing + SimpleX link

- cli.load_config anchors skill_seeds/skill_bodies/category_registry/log/trace
  to the checkout root, so a fresh clone's committed seeds load from any cwd
  (running outside the repo root had an empty tree -> codegen loop).
- `skills` (CLI + REPL) lists scheduler.tree, not a throwaway built-ins tree.
- SimpleX adapter reads the real /_show_address shape
  (contactLink.connLinkContact), so simplex.connect_link returns the link
  instead of reporting no address.
This commit is contained in:
Denton Social committed 2026-09-28 13:52:00 -05:00
1 parent a9b096f2e8
commit d46fbdca19
4 files changed
+118 -7

No files matched your search

+31 -4
View File
@@ -24,12 +24,39 @@ from .engine import EngineConfig, EngineUnavailable, SemIfEngine
from .llm import LLMClient
from .log import DecisionLog
from .scheduler import Scheduler
from .skills import build_skills, build_tree, tree_summary
from .skills import tree_summary
from .trace import TraceLog
REPO_ROOT = Path(__file__).resolve().parent.parent
_PATH_KEYS = ("skill_seeds", "skill_bodies", "category_registry", "log", "trace")
_PATH_DEFAULTS = {
"skill_seeds": "seeds",
"skill_bodies": "data/skills",
"category_registry": "data/categories.json",
"log": "data/decisions.jsonl",
"trace": "data/runs.jsonl",
}
def _anchor_path(value: str) -> str:
path = Path(value)
return str(path if path.is_absolute() else REPO_ROOT / path)
def load_config(path: str = "config.json") -> dict:
return json.loads(Path(path).read_text())
"""Load config.json and anchor its runtime paths to the checkout root.
Path-valued keys (`skill_seeds`, `skill_bodies`, `category_registry`, `log`,
`trace`) resolve against REPO_ROOT, not the process cwd, so a fresh clone
loads its committed seeds and writes runtime artifacts into the checkout no
matter where the CLI is invoked from. Absolute values pass through untouched.
"""
config = json.loads(Path(path).read_text())
for key in _PATH_KEYS:
config[key] = _anchor_path(config.get(key) or _PATH_DEFAULTS[key])
return config
def build_scheduler(config: dict) -> tuple[Scheduler, dict]:
@@ -221,7 +248,7 @@ def repl(scheduler: Scheduler, config: dict) -> None:
print(scheduler.status())
continue
if lower == "skills":
print(tree_summary(build_tree(build_skills(config))))
print(tree_summary(scheduler.tree))
continue
if lower == "dream":
print(run_dream(scheduler.log).render())
@@ -414,7 +441,7 @@ def main(argv: list[str] | None = None) -> int:
elif args.command == "dream":
print(run_dream(scheduler.log).render())
elif args.command == "skills":
print(tree_summary(build_tree(build_skills(config))))
print(tree_summary(scheduler.tree))
elif args.command == "status":
print(scheduler.status())
elif args.command == "relabel":
+23 -2
View File
@@ -23,6 +23,27 @@ from typing import Any
from .base import GatewayAdapter, InboundMessage, OutboundMessage
def contact_link(resp: dict) -> dict:
"""Pull `{connShortLink, connFullLink}` out of a daemon address response.
`/_show_address` nests it as `contactLink.connLinkContact`; `/_address`
returns it directly as `connLinkContact`. Tolerate both (and a flat
`contactLink`) so the adapter reads the real daemon shape rather than
calling `/_address` again on an existing link and reporting nothing.
"""
for candidate in (
(resp.get("contactLink") or {}).get("connLinkContact"),
resp.get("connLinkContact"),
resp.get("contactLink"),
resp,
):
if isinstance(candidate, dict) and (
candidate.get("connShortLink") or candidate.get("connFullLink")
):
return candidate
return {}
class SimplexAdapter(GatewayAdapter):
name = "simplex"
@@ -177,10 +198,10 @@ class SimplexAdapter(GatewayAdapter):
link: dict = {}
created = False
if resp.get("type") == "userContactLink":
link = resp.get("contactLink") or {}
link = contact_link(resp)
if not (link.get("connShortLink") or link.get("connFullLink")):
resp = await self._roundtrip(f"/_address {self.user_id}", timeout)
link = resp.get("connLinkContact") or {}
link = contact_link(resp)
created = True
return {
"short_link": link.get("connShortLink") or "",
+8 -1
View File
@@ -410,7 +410,14 @@ def test_address_returns_existing_link():
[
{
"type": "userContactLink",
"contactLink": {"connShortLink": "simplex:/a", "connFullLink": "https://a"},
"user": {"userId": 3},
"contactLink": {
"userContactLinkId": 1,
"connLinkContact": {
"connShortLink": "simplex:/a",
"connFullLink": "https://a",
},
},
}
],
)
+56
View File
@@ -16,6 +16,7 @@ from pathlib import Path
import pytest
from semif_agent.cli import REPO_ROOT, load_config
from semif_agent.codegen import CodegenClient
from semif_agent.decisions import Request
from semif_agent.engine import EngineConfig, EngineUnavailable, SemIfEngine
@@ -438,6 +439,61 @@ def test_scheduler_loads_committed_seed_skills(tmp_path):
assert calendar[0].integration["transport"] == "caldav"
def test_load_config_anchors_runtime_paths_to_checkout(tmp_path):
"""Path-valued config keys resolve against the checkout, not the cwd, so a
fresh clone finds its committed seeds from anywhere; absolute paths pass
through untouched."""
config_file = tmp_path / "config.json"
config_file.write_text(
json.dumps(
{
"skill_seeds": "seeds",
"skill_bodies": "data/skills",
"log": "/absolute/decisions.jsonl",
}
)
)
config = load_config(str(config_file))
assert config["skill_seeds"] == str(REPO_ROOT / "seeds")
assert config["skill_bodies"] == str(REPO_ROOT / "data/skills")
assert config["category_registry"] == str(REPO_ROOT / "data/categories.json")
assert config["log"] == "/absolute/decisions.jsonl"
assert config["trace"] == str(REPO_ROOT / "data/runs.jsonl")
def test_committed_seeds_load_from_a_foreign_cwd(tmp_path, monkeypatch):
"""A fresh checkout's seeds come from the anchored `seeds/` path even when
the process runs from an unrelated directory (the zero-skills regression:
relative paths resolved against cwd, so the tree was only response.reject
and navigation fell into the codegen loop)."""
config_file = tmp_path / "config.json"
config_file.write_text(
json.dumps(
{
"skill_seeds": "seeds",
"skill_bodies": str(tmp_path / "skills"),
"category_registry": str(tmp_path / "categories.json"),
"log": str(tmp_path / "decisions.jsonl"),
"trace": str(tmp_path / "runs.jsonl"),
}
)
)
monkeypatch.chdir(tmp_path)
config = load_config(str(config_file))
scheduler = Scheduler(
engine=SemIfEngine(EngineConfig()),
llm=LLMClient(base_url="http://localhost:1/v1", model="test"),
log=DecisionLog(config["log"]),
config=config,
trace=TraceLog(config["trace"]),
)
assert [s.name for s in scheduler.tree["simplex"]] == [
"connect_link",
"next_message",
]
assert [s.name for s in scheduler.tree["calendar"]] == ["next_event"]
def test_navigate_empty_tree_short_circuits(tmp_path):
"""An empty tree goes straight to CreateCategory without a SemIf call."""
log = DecisionLog(str(tmp_path / "decisions.jsonl"))