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:
gabby committed 2026-10-01 10:21:31 +00:00
1 parent 4a62e794a5
commit 567c280ee2
26 files changed
+679 -706

No files matched your search

+12 -22
View File
@@ -15,9 +15,9 @@ import pytest
from semif_agent.cli import build_scheduler, load_config
from semif_agent.codegen import (
CodegenClient,
generate_data_contract,
generate_skill_body,
generate_skill_tests,
parse_contract,
parse_integration,
)
from semif_agent.decisions import Request
@@ -28,7 +28,6 @@ from semif_agent.skills import (
ActionResult,
CategoryDraft,
CreateSkill,
Prediction,
Skill,
SkillDraft,
SkillStore,
@@ -82,10 +81,7 @@ def _install_tracking_fixture(scheduler):
`llm`/`codegen` providers, and the decision log all remain real.
"""
def predict(ctx, request):
return Prediction(text="", decisions=[])
def act(ctx, request, prediction):
def act(ctx, request):
return ActionResult(
action_log="tracking fixture: checked the package status",
new_state="package status checked",
@@ -96,7 +92,6 @@ def _install_tracking_fixture(scheduler):
name="tracking.check",
category="tracking",
description="Check the delivery status of a package.",
predict=predict,
act=act,
)
]
@@ -331,9 +326,7 @@ def test_generate_skill_body_codegen(tmp_path):
assert "127.0.0.1" not in code and "localhost" not in code, (
"the body must take its endpoint from ctx.config, never a fixture"
)
contract = generate_data_contract(
client, request, "tracking", draft, code
)
contract = parse_contract(code)
print(f"data contract: {contract}")
test = generate_skill_tests(
client,
@@ -357,7 +350,7 @@ def test_generate_skill_body_codegen(tmp_path):
draft.code = code
skill = materialize_skill(draft, "tracking", store)
assert callable(skill.predict) and callable(skill.act)
assert callable(skill.act)
assert skill.contract == contract
assert skill.integration["transport"] in ("http", "caldav")
@@ -389,10 +382,11 @@ def test_fidelity_gate_is_a_real_semif_decision(tmp_path):
weight=0.5,
)
undeclared = '''\
def predict(ctx, request):
return Prediction(text="ok", decisions=[])
from semif_agent.skills import ActionResult
def act(ctx, request, prediction):
CONTRACT = {}
def act(ctx, request):
return ActionResult(action_log="delivered", new_state="delivered")
'''
gated = scheduler._fidelity_gate(job, undeclared)
@@ -406,13 +400,13 @@ def act(ctx, request, prediction):
declared = '''
INTEGRATION = {"service": "carrier", "transport": "http", "config_vars": ["tracking_url"]}
CONTRACT = {"tracking_url": "Carrier status endpoint."}
import json
import urllib.request
def predict(ctx, request):
return Prediction(text="ok", decisions=[])
from semif_agent.skills import ActionResult
def act(ctx, request, prediction):
def act(ctx, request):
with urllib.request.urlopen(ctx.config["tracking_url"], timeout=15) as response:
payload = json.loads(response.read().decode("utf-8"))
return ActionResult(
@@ -545,10 +539,7 @@ def test_skill_pauses_for_input_and_resumes(tmp_path):
seen = []
def predict(ctx, request):
return Prediction(text="", decisions=[])
def act(ctx, request, prediction):
def act(ctx, request):
if request.user_input:
seen.append(request.user_input)
return ActionResult(
@@ -565,7 +556,6 @@ def test_skill_pauses_for_input_and_resumes(tmp_path):
name="track.manual",
category="tracking",
description="Resolve a tracking number with the human.",
predict=predict,
act=act,
)