new-skill creation: deny by default, refuse silently
A host now leans on the committed packs: `new_skill_creation` defaults to `deny` (core schema, generated config.example.json, and the scheduler's unset fallback), so a fresh bootstrap does not author skills at runtime. A host with the resources opts in with `allow` (or `ask`). Under deny, an unmatched request no longer exposes the authoring machinery: `_blocked_create` answers with a plain refusal (`skills.UNABLE_MESSAGE`, "I'm sorry, I'm not able to help with that.") instead of an error naming `new_skill_creation`/`config.json`, and a leftover empty/in-progress leaf in a denied category refuses the same way rather than telling the user to `restart` the body write. The block is still traced (`category_create_blocked` / `skill_create_blocked`) for operators. Routing, decision logging, and the allow/ask paths are unchanged. Tests: authoring-mechanics helpers opt in explicitly; the default-deny and silent-refusal cases are asserted.
This commit is contained in:
1 parent
78b4621ba0
commit
711dba2f03
9 files changed
+153
-60
No files matched your search
@@ -34,6 +34,9 @@ def build_scheduler(tmp_path, engine=None):
|
||||
log=log,
|
||||
config={
|
||||
"skills": {},
|
||||
# Dashboard mechanics tests exercise the authoring path, an opt-in
|
||||
# now that new-skill creation is denied by default.
|
||||
"new_skill_creation": "allow",
|
||||
"skill_packs": str(tmp_path / "seeds"),
|
||||
"skill_bodies": str(tmp_path / "skills"),
|
||||
"category_registry": str(tmp_path / "categories.json"),
|
||||
|
||||
@@ -26,6 +26,7 @@ from semif_agent.skills import (
|
||||
build_housekeeping_skills,
|
||||
parse_meta_command,
|
||||
resolve_skill_ref,
|
||||
UNABLE_MESSAGE,
|
||||
_cancel_build_act,
|
||||
_delete_skill_act,
|
||||
)
|
||||
@@ -264,7 +265,8 @@ def test_housekeeping_and_response_are_hard_locked(tmp_path):
|
||||
def test_category_mode_config_roundtrip(tmp_path):
|
||||
scheduler = _scheduler(tmp_path)
|
||||
scheduler.tree["notes"] = []
|
||||
assert scheduler._category_mode("notes") == "allow"
|
||||
# New-skill creation is denied by default (the global fallback).
|
||||
assert scheduler._category_mode("notes") == "deny"
|
||||
|
||||
status, _ = scheduler.set_category_mode("notes", "ask")
|
||||
assert status == "ok"
|
||||
@@ -294,12 +296,44 @@ def test_category_mode_inherits_global_and_overrides(tmp_path):
|
||||
|
||||
|
||||
def test_dispatch_skill_blocked_when_denied(tmp_path):
|
||||
"""A denied category answers with the plain refusal: the user is never told
|
||||
that new-skill creation (or its config) exists."""
|
||||
scheduler = _scheduler(tmp_path)
|
||||
scheduler.tree["notes"] = []
|
||||
scheduler.set_category_mode("notes", "deny")
|
||||
result = scheduler._dispatch_skill(Request("make a note"), "notes")
|
||||
assert result.kind == "error"
|
||||
assert "denied" in result.summary
|
||||
assert result.kind == "ran"
|
||||
assert result.summary == UNABLE_MESSAGE
|
||||
for leak in ("denied", "new_skill_creation", "config.json", "category", "skill"):
|
||||
assert leak not in result.summary
|
||||
assert any(e["kind"] == "skill_create_blocked" for e in scheduler.trace.read())
|
||||
|
||||
|
||||
def test_dispatch_create_category_denied_is_silent(tmp_path):
|
||||
"""Global `deny` answers a request that would author a category with the
|
||||
plain refusal, and still traces the block for operators."""
|
||||
scheduler = _scheduler(tmp_path)
|
||||
scheduler.new_skill_mode = "deny"
|
||||
scheduler.tree = {}
|
||||
result = scheduler._dispatch(Request("book a trip to japan"))
|
||||
assert result.kind == "ran"
|
||||
assert result.summary == UNABLE_MESSAGE
|
||||
assert result.result == UNABLE_MESSAGE
|
||||
assert any(
|
||||
e["kind"] == "category_create_blocked" for e in scheduler.trace.read()
|
||||
)
|
||||
|
||||
|
||||
def test_run_stub_under_deny_is_silent(tmp_path):
|
||||
"""A leftover empty leaf in a denied category refuses plainly instead of
|
||||
telling the user to `restart` the body write."""
|
||||
scheduler = _scheduler(tmp_path)
|
||||
scheduler.tree["notes"] = []
|
||||
scheduler.set_category_mode("notes", "deny")
|
||||
stub = Skill(name="stub", category="notes", description="d")
|
||||
result = scheduler._run_skill(stub, Request("make a note"))
|
||||
assert result.summary == UNABLE_MESSAGE
|
||||
assert "restart" not in result.summary
|
||||
assert any(e["kind"] == "skill_create_blocked" for e in scheduler.trace.read())
|
||||
|
||||
|
||||
|
||||
+29
-4
@@ -141,6 +141,9 @@ def _scheduler(tmp_path, codegen=None, choices=None, default="success", verbosit
|
||||
SemIf decision now, so a run needs the engine to answer `assess:*`."""
|
||||
config = {
|
||||
"skills": {},
|
||||
# Most mechanics tests exercise the authoring path, which is an opt-in
|
||||
# now that new-skill creation is denied by default.
|
||||
"new_skill_creation": "allow",
|
||||
"category_registry": str(tmp_path / "categories.json"),
|
||||
"skill_bodies": str(tmp_path / "skills"),
|
||||
"skill_packs": str(tmp_path / "seeds"),
|
||||
@@ -1165,6 +1168,7 @@ def test_dispatch_action_tau_controls_catchall_routing(tmp_path):
|
||||
log=DecisionLog(str(tmp_path / "decisions.jsonl")),
|
||||
config={
|
||||
"skills": {},
|
||||
"new_skill_creation": "allow",
|
||||
"navigation": {"action_tau": action_tau},
|
||||
"category_registry": str(tmp_path / "categories.json"),
|
||||
"skill_bodies": str(tmp_path / "skills"),
|
||||
@@ -1209,6 +1213,7 @@ def test_dispatch_intent_tau_controls_reuse_vs_create(tmp_path):
|
||||
log=DecisionLog(str(tmp_path / "decisions.jsonl")),
|
||||
config={
|
||||
"skills": {},
|
||||
"new_skill_creation": "allow",
|
||||
"navigation": {"intent_tau": intent_tau},
|
||||
"category_registry": str(tmp_path / "categories.json"),
|
||||
"skill_bodies": str(tmp_path / "skills"),
|
||||
@@ -1348,6 +1353,7 @@ def test_dispatch_confident_leaf_winner_still_runs_intent_guard(tmp_path):
|
||||
log=DecisionLog(str(tmp_path / "decisions.jsonl")),
|
||||
config={
|
||||
"skills": {},
|
||||
"new_skill_creation": "allow",
|
||||
"category_registry": str(tmp_path / "categories.json"),
|
||||
"skill_bodies": str(tmp_path / "skills"),
|
||||
"skill_packs": str(tmp_path / "seeds"),
|
||||
@@ -1394,6 +1400,7 @@ def test_dispatch_create_category_queues_draft_and_is_not_fatal(tmp_path):
|
||||
log=log,
|
||||
config={
|
||||
"skills": {},
|
||||
"new_skill_creation": "allow",
|
||||
"category_registry": str(tmp_path / "categories.json"),
|
||||
"skill_bodies": str(tmp_path / "skills"),
|
||||
"skill_packs": str(tmp_path / "seeds"),
|
||||
@@ -1433,13 +1440,31 @@ def _answer_approval_when_posted(scheduler, approved, timeout=5.0):
|
||||
return False
|
||||
|
||||
|
||||
def test_creation_mode_allow_proceeds(tmp_path):
|
||||
"""The default (`new_skill_creation` unset -> allow) leaves creation
|
||||
unchanged: the gate returns immediately and posts nothing."""
|
||||
scheduler = _scheduler(tmp_path)
|
||||
def test_creation_mode_defaults_to_deny_and_allow_opts_in(tmp_path):
|
||||
"""New-skill creation is denied by default (the agent leans on the committed
|
||||
packs); a host opts in by setting `new_skill_creation: allow`."""
|
||||
# Unset -> deny: the gate aborts without prompting.
|
||||
unset = Scheduler(
|
||||
engine=ScriptedEngine(),
|
||||
llm=LLMClient(base_url="http://localhost:1/v1", model="test"),
|
||||
log=DecisionLog(str(tmp_path / "decisions.jsonl")),
|
||||
config={
|
||||
"skills": {},
|
||||
"category_registry": str(tmp_path / "categories.json"),
|
||||
"skill_bodies": str(tmp_path / "skills"),
|
||||
"skill_packs": str(tmp_path / "seeds"),
|
||||
},
|
||||
trace=TraceLog(str(tmp_path / "runs.jsonl")),
|
||||
)
|
||||
assert unset.new_skill_mode == "deny"
|
||||
job = DraftAuthor(
|
||||
request=Request("book a trip"), category=None, kind="category"
|
||||
)
|
||||
assert unset._request_approval(job, "category", "travel", "Trips.") is False
|
||||
|
||||
# Explicit allow: the gate returns immediately and posts nothing.
|
||||
scheduler = _scheduler(tmp_path)
|
||||
assert scheduler.new_skill_mode == "allow"
|
||||
assert scheduler._request_approval(job, "category", "travel", "Trips.") is True
|
||||
assert scheduler.pending_approvals() == []
|
||||
|
||||
|
||||
Reference in new issue
Block a user