change drone tacking test to simplex create message test

This commit is contained in:
gabby committed 2026-10-01 04:44:37 +00:00
1 parent 65c5899393
commit 375d37d1f1
1 file changed
+41 -18
+41 -18
View File
@@ -453,14 +453,15 @@ def test_create_skill_empty_category_does_not_wedge(tmp_path):
assert scheduler.current is None assert scheduler.current is None
def test_create_category_chain_runs_new_skill(tmp_path): def test_create_simplex_send_skill(tmp_path):
"""A request that needs a brand-new category must end with a skill run. """A send request with no matching leaf must author a new simplex skill.
Deterministic chain: create_category -> create_skill in the new category -> The `simplex` category already ships the read (`next_message`) and
async codegen body write -> re-dispatch of the original request -> run that `connect_link` seeds; "send a message" is a genuinely unmatched action, so
skill (the leaf answers the request, not the category stub). Slow: uses real navigation routes it to create_skill. Deterministic chain: create_skill ->
codegen (~25-45 min) and the worker runs in the background, so the test async codegen body write -> re-dispatch of the original request -> run the
polls the trace for the completion + assessed events. Run in the background. new leaf. Slow: uses real codegen (~25-45 min) and the worker runs in the
background, so the test polls the trace. Run in the background.
""" """
config = load_config() config = load_config()
require_real(config) require_real(config)
@@ -470,29 +471,51 @@ def test_create_category_chain_runs_new_skill(tmp_path):
config["skill_bodies"] = str(tmp_path / "skills") config["skill_bodies"] = str(tmp_path / "skills")
config["codegen"] = {**config.get("codegen", {}), "stream": True} config["codegen"] = {**config.get("codegen", {}), "stream": True}
scheduler, config = build_scheduler(config) scheduler, config = build_scheduler(config)
scheduler.tree = {}
status, detail = scheduler.submit("track my drone delivery in real time") seeded = {s.name for s in scheduler.tree.get("simplex", [])}
assert {"next_message", "connect_link"} <= seeded, (
f"the simplex seeds must be loaded, got {seeded}"
)
status, detail = scheduler.submit("send a simplex message to pepper saying hi")
print(f"[{status}] {detail}") print(f"[{status}] {detail}")
assert status in ("running", "preempted", "queued", "rejected") assert status in ("running", "preempted", "queued", "rejected")
assert "new skill for simplex" in detail, (
"a send request must route to create_skill for simplex"
)
assert scheduler.current is None, "gate must be free again right after the draft is queued" assert scheduler.current is None, "gate must be free again right after the draft is queued"
draft_deadline = time.monotonic() + 10 * 60 draft_deadline = time.monotonic() + 10 * 60
while time.monotonic() < draft_deadline: while time.monotonic() < draft_deadline:
kinds = [e["kind"] for e in scheduler.trace.read()] rows = scheduler.trace.read()
if "category_created" in kinds and "skill_writing" in kinds: if any(e["kind"] == "skill_writing" for e in rows):
break break
time.sleep(5) time.sleep(5)
kinds = [e["kind"] for e in scheduler.trace.read()] rows = scheduler.trace.read()
assert "category_created" in kinds, "category stub must be authored first" assert not any(e["kind"] == "draft_failed" for e in rows), (
assert "skill_writing" in kinds, "the async body write must be launched" "the skill draft must be authored"
)
writing = [e for e in rows if e["kind"] == "skill_writing"]
assert writing and writing[-1]["category"] == "simplex", (
"the async body write must be launched for simplex"
)
deadline = time.monotonic() + 55 * 60 deadline = time.monotonic() + 55 * 60
created = assessed = None created = assessed = None
while time.monotonic() < deadline: while time.monotonic() < deadline:
rows = scheduler.trace.read() rows = scheduler.trace.read()
created = next((e for e in rows if e["kind"] == "skill_created"), None) created = next(
if created and created.get("written"): (
e
for e in rows
if e["kind"] == "skill_created"
and e.get("category") == "simplex"
and e.get("written")
and e.get("skill") not in seeded
),
None,
)
if created:
assessed = next( assessed = next(
(e for e in rows if e["kind"] == "assessed" and e.get("skill") == created["skill"]), (e for e in rows if e["kind"] == "assessed" and e.get("skill") == created["skill"]),
None, None,
@@ -500,8 +523,8 @@ def test_create_category_chain_runs_new_skill(tmp_path):
if assessed: if assessed:
break break
time.sleep(10) time.sleep(10)
assert created is not None and created.get("written"), ( assert created is not None, (
"codegen must produce a runnable body" "codegen must produce a runnable simplex send body"
) )
assert assessed is not None, "the created skill must run after the body lands" assert assessed is not None, "the created skill must run after the body lands"
assert assessed["skill"] == created["skill"], "the created skill must run" assert assessed["skill"] == created["skill"], "the created skill must run"