real integrations: implementation elicitation, INTEGRATION, fidelity + repair

Anchor the product premise at the top of AGENTS.md: semif-agent is an
end-user app that does the user's task for real against their actual
service, asking a few questions and learning when it doesn't know how.

Elicitation now asks implementation questions (service/account, how to
connect, credential source, expected result) and is on by default. The
REPL asks inline; the dashboard defers via a question queue the worker
waits on (/api/questions + panel). Answers ride every body attempt and
persist in the registry so restart doesn't re-ask.

SKILL.md requires real actions via stdlib transports with values from
ctx.config and a module-level INTEGRATION declaration
(service/transport/config_vars). TESTGEN.md scopes tests as hermetic
mechanics checks (loopback http.server in-test, never fixture addresses
in bodies) that never certify the live integration.

After the body lands a fidelity review (small LLM + static declaration
findings) regenerates a simulated body once, then accepts it traced and
badged unverified. A failed real run logs a SemIf repair choice
(retry/repair_skill/ask_user/no_repair), surfaced in REPL and dashboard,
bounded by codegen.repair.max_attempts and user-confirmed.

Dev unit suite: 191 passed. Jarvis integration run still pending.
This commit is contained in:
Denton Social committed 2026-09-26 01:42:00 -05:00
1 parent 06ccfb77c6
commit dde034f1b4
16 files changed
+2263 -255

No files matched your search

+41 -7
View File
@@ -71,6 +71,8 @@ class Skill:
writing: bool = False
config: dict = field(default_factory=dict)
contract: dict = field(default_factory=dict)
integration: dict = field(default_factory=dict)
integration_source: str = "unknown"
def is_noop(self) -> bool:
"""A stub leaf: authored (title + description) but no runnable body yet."""
@@ -121,13 +123,15 @@ class SkillDraft:
`requirements` maps elicitation questions (asked of the human during
authoring) to their answers; they are fed to the body-writer so the body
reflects the refined product goal.
reflects the refined product goal. `integration` carries the service and
transport the answers point at, so the body writer implements exactly that.
"""
name: str
description: str
code: str = ""
requirements: dict[str, str] = field(default_factory=dict)
integration: dict = field(default_factory=dict)
class CategoryRegistry:
@@ -153,21 +157,29 @@ class CategoryRegistry:
self.path.write_text(json.dumps(categories, indent=2) + "\n")
def register_skill(
self, category: str, name: str, description: str, request_text: str = ""
self,
category: str,
name: str,
description: str,
request_text: str = "",
requirements: dict[str, str] | None = None,
) -> None:
"""Add a skill leaf to a category, creating the category entry if needed.
`request_text` is the originating request, kept so a later restart of the
stub can re-drive codegen with the same context.
stub can re-drive codegen with the same context. `requirements` are the
elicitation answers, kept so a restart does not have to ask again.
"""
categories = self.read()
entry = categories.setdefault(category, {"description": "", "skills": []})
skills = entry.setdefault("skills", [])
entry_row = next((s for s in skills if s.get("name") == name), None)
if entry_row is None:
skills.append({"name": name, "description": description, "request_text": request_text})
else:
entry_row["request_text"] = request_text
entry_row = {"name": name, "description": description}
skills.append(entry_row)
entry_row["request_text"] = request_text
if requirements:
entry_row["requirements"] = requirements
self.path.parent.mkdir(parents=True, exist_ok=True)
self.path.write_text(json.dumps(categories, indent=2) + "\n")
@@ -272,13 +284,25 @@ def load_skill_module(category: str, name: str, base: str = "data/skills"):
return module
def _extract_integration(code: str) -> tuple[dict, str]:
"""Integration declaration (or inference) for a body, lazily.
Lives in codegen.py; imported here so skills.py stays free of codegen at
module import time (codegen imports skills).
"""
from .codegen import extract_integration
return extract_integration(code)
def materialize_skill(
draft: SkillDraft, category: str, store: SkillStore
) -> Skill:
"""Persist the draft's code body and build a runnable Skill from it.
The skill's config and contract are read back from the store so the runner
can resolve its data needs across restarts.
can resolve its data needs across restarts; its integration declaration is
extracted from the body so the tree can show what it talks to.
"""
if not draft.code:
raise ValueError(f"skill {draft.name} has no code body to materialize")
@@ -291,6 +315,7 @@ def materialize_skill(
getattr(module, "act", None)
):
raise ValueError(f"skill {category}.{draft.name} body must define predict and act")
integration, integration_source = _extract_integration(draft.code)
return Skill(
name=draft.name,
category=category,
@@ -299,6 +324,8 @@ def materialize_skill(
act=module.act,
config=store.read_config(category, draft.name),
contract=store.read_contract(category, draft.name),
integration=integration,
integration_source=integration_source,
)
@@ -322,6 +349,11 @@ def merge_skill_store(
module = load_skill_module(category, name, store.path)
except Exception:
continue
code_path = store.dir(category, name) / "skill.py"
try:
integration, integration_source = _extract_integration(code_path.read_text())
except OSError:
integration, integration_source = {}, "unknown"
skill = Skill(
name=name,
category=category,
@@ -330,6 +362,8 @@ def merge_skill_store(
act=module.act,
config=store.read_config(category, name),
contract=store.read_contract(category, name),
integration=integration,
integration_source=integration_source,
)
skills = tree.setdefault(category, [])
for index, existing in enumerate(skills):