Remove the predict phase; contract-driven resolution
Skills now have a single `act(ctx, request)` body phase. The free-string `Prediction.text` handoff, the `Prediction` type, and the predict phase are gone. - Resolution is pipeline-owned: the tiered config merge (global -> category -> skill) fills contract vars; the authoring-time SemIf search now searches the whole cascade; unresolved vars pause pre-act (`pre_act`, renamed from `pre_predict`) and are asked of the human one at a time. - The data contract is a module-level `CONTRACT` constant in the body, parsed by `parse_contract`; `contract.json` is a derived mirror. The separate `generate_data_contract` codegen call is removed. - Candidate selection stays in the body: a set of candidates (bridge endpoint, direct API, hard-coded list) gets a SemIf query, and the decisions ride back on `ActionResult.decisions` to be logged with the run outcome (phase `act`). - `assess:outcome`/`assess:requeue` state carries the resolved inputs (secrets redacted by name) so the decision sees the full query -> resolution -> action path. - Authoring validation enforces: compiles + `act`; `INTEGRATION` flat and valid; `CONTRACT` flat str->str; every CONTRACT key actually read from `ctx.config`. - Test-regen ladder narrowed to code/test (the contract rides in the code). SKILL.md/TESTGEN.md rewritten; seeds (calendar.next_event, simplex.next_message, simplex.connect_link) rewritten to act-only + CONTRACT; docs updated. BREAKING: persisted bodies in data/skills/ must be regenerated.
This commit is contained in:
1 parent
4a62e794a5
commit
567c280ee2
26 files changed
+679
-706
No files matched your search
@@ -1,11 +1,11 @@
|
||||
"""Hermetic mechanics test for simplex.next_message.
|
||||
|
||||
Run from this folder: `python skill.test.py`. No external network: a loopback
|
||||
http.server plays the standalone SimpleX forwarding bridge. This proves the body peeks the
|
||||
inbox, resolves the conversation through a SemIf sub-decision (or a configured
|
||||
default), pops the real `next` message, and fails honestly when the bridge is
|
||||
unreachable. It does NOT prove the live integration — only a real run against
|
||||
the bridge and a real contact does.
|
||||
http.server plays the standalone SimpleX forwarding bridge. This proves the body
|
||||
peeks the inbox, resolves the conversation through a SemIf sub-decision (or a
|
||||
configured default), pops the real `next` message, and fails honestly when the
|
||||
bridge is unreachable. It does NOT prove the live integration — only a real run
|
||||
against the bridge and a real contact does.
|
||||
"""
|
||||
|
||||
import json
|
||||
@@ -113,12 +113,9 @@ def test_multiple_senders_uses_semif_decision():
|
||||
engine = FakeEngine(pick="7")
|
||||
ctx = ActionContext(engine=engine, config=config(url))
|
||||
request = Request("read my next simplex message")
|
||||
prediction = skill.predict(ctx, request)
|
||||
assert prediction.text == "contact: 7", prediction.text
|
||||
assert len(prediction.decisions) == 1, "predict must log the conversation choice"
|
||||
action = skill.act(ctx, request)
|
||||
assert len(action.decisions) == 1, "act must log the conversation choice"
|
||||
assert len(engine.decisions) == 1
|
||||
|
||||
action = skill.act(ctx, request, prediction)
|
||||
assert "Bob" in action.action_log, action.action_log
|
||||
assert "shipment arrived" in action.action_log, action.action_log
|
||||
assert action.new_state, "act must set a new state"
|
||||
@@ -143,11 +140,8 @@ def test_default_contact_skips_decision():
|
||||
engine = FakeEngine()
|
||||
ctx = ActionContext(engine=engine, config=config(url, default="Alice"))
|
||||
request = Request("read my next simplex message")
|
||||
prediction = skill.predict(ctx, request)
|
||||
assert prediction.text == "contact: 4", prediction.text
|
||||
action = skill.act(ctx, request)
|
||||
assert engine.decisions == [], "a configured default needs no SemIf decision"
|
||||
|
||||
action = skill.act(ctx, request, prediction)
|
||||
assert "Alice" in action.action_log, action.action_log
|
||||
assert handler.requests[1] == "/inbox/next?contact=4", handler.requests
|
||||
print(action.action_log)
|
||||
@@ -162,10 +156,8 @@ def test_single_sender_needs_no_decision():
|
||||
engine = FakeEngine()
|
||||
ctx = ActionContext(engine=engine, config=config(url))
|
||||
request = Request("read my next simplex message")
|
||||
prediction = skill.predict(ctx, request)
|
||||
assert prediction.text == "contact: 4", prediction.text
|
||||
action = skill.act(ctx, request)
|
||||
assert engine.decisions == []
|
||||
action = skill.act(ctx, request, prediction)
|
||||
assert "hi" in action.action_log, action.action_log
|
||||
print(action.action_log)
|
||||
finally:
|
||||
@@ -179,9 +171,7 @@ def test_empty_inbox_is_reported_honestly():
|
||||
engine = FakeEngine()
|
||||
ctx = ActionContext(engine=engine, config=config(url))
|
||||
request = Request("read my next simplex message")
|
||||
prediction = skill.predict(ctx, request)
|
||||
assert prediction.text == "settled: no unread messages", prediction.text
|
||||
action = skill.act(ctx, request, prediction)
|
||||
action = skill.act(ctx, request)
|
||||
assert "no unread" in action.action_log, action.action_log
|
||||
assert handler.requests == ["/inbox"], "an empty inbox needs no pop"
|
||||
print(action.action_log)
|
||||
@@ -194,10 +184,8 @@ def test_unreachable_bridge_fails_honestly():
|
||||
engine = FakeEngine()
|
||||
ctx = ActionContext(engine=engine, config=config("http://127.0.0.1:1"))
|
||||
request = Request("read my next simplex message")
|
||||
prediction = skill.predict(ctx, request)
|
||||
assert prediction.text.startswith("bridge error:"), prediction.text
|
||||
action = skill.act(ctx, request, prediction)
|
||||
assert action.action_log.startswith("bridge error:"), action.action_log
|
||||
action = skill.act(ctx, request)
|
||||
assert action.action_log.startswith("simplex.next_message:"), action.action_log
|
||||
assert action.new_state == request.text, "a failed read must not fake a result"
|
||||
print(action.action_log)
|
||||
|
||||
@@ -208,8 +196,7 @@ def test_auth_token_is_sent_when_configured():
|
||||
engine = FakeEngine()
|
||||
ctx = ActionContext(engine=engine, config=config(url, token="sekret"))
|
||||
request = Request("read my next simplex message")
|
||||
prediction = skill.predict(ctx, request)
|
||||
action = skill.act(ctx, request, prediction)
|
||||
action = skill.act(ctx, request)
|
||||
assert "hi" in action.action_log, action.action_log
|
||||
assert set(handler.tokens) == {"sekret"}, handler.tokens
|
||||
print(action.action_log)
|
||||
|
||||
Reference in new issue
Block a user