skills: read-only catalog for introspection bodies
An ordinary skill body may not reach into the agent (`ctx.admin` is the housekeeping-only mutation surface), but a body that reports the agent's own capabilities legitimately needs to see the tree. Add that sanctioned surface: - `SkillCatalog` (skills.py): a read-only view — `categories()` (id -> scope description) and `skills(category)` (leaf names) — over a live provider. - `ActionContext.catalog`: supplied by the scheduler as a locked tree snapshot, passed to every body. - The runner now passes `admin` only to the `housekeeping` category (it was previously handed to every body despite the documented rule); ordinary bodies get `catalog` instead. Consumed by the essentials pack's new `skills.list_categories` / `skills.list_skills` seeds. Docs (CODEGEN.md, AGENTS.md, README.md) updated; tests cover the catalog, the catalog/admin split on the run context, and the new pack seeds.
This commit is contained in:
1 parent
ed894bd329
commit
ec3e6b1b97
8 files changed
+126
-13
No files matched your search
@@ -40,6 +40,7 @@ from semif_agent.skills import (
|
||||
CreateCategory,
|
||||
CreateSkill,
|
||||
Skill,
|
||||
SkillCatalog,
|
||||
SkillDraft,
|
||||
SkillStore,
|
||||
build_category_prompt,
|
||||
@@ -180,6 +181,50 @@ def test_scheduler_sizes_artifact_budgets_from_engine_context(tmp_path):
|
||||
assert scheduler.max_test_chars == scheduler.max_body_chars
|
||||
|
||||
|
||||
def test_skill_catalog_lists_categories_and_skills():
|
||||
"""The read-only catalog reports the tree's categories and one category's
|
||||
leaves, and follows the live provider."""
|
||||
tree = {
|
||||
"time": [
|
||||
Skill(name="now", category="time", description="time"),
|
||||
Skill(name="date", category="time", description="date"),
|
||||
],
|
||||
"calculator": [Skill(name="calculate", category="calculator", description="math")],
|
||||
}
|
||||
catalog = SkillCatalog(lambda: tree)
|
||||
assert set(catalog.categories()) == {"time", "calculator"}
|
||||
assert catalog.skills("time") == ["date", "now"]
|
||||
assert catalog.skills("missing") == []
|
||||
# A skill added after construction is still listed (the provider is live).
|
||||
tree["new"] = [Skill(name="thing", category="new", description="d")]
|
||||
assert "new" in catalog.categories()
|
||||
|
||||
|
||||
def test_scheduler_exposes_a_read_only_catalog(tmp_path):
|
||||
"""The scheduler supplies the catalog on the run context, but reserves
|
||||
`admin` for the built-in housekeeping meta skills."""
|
||||
scheduler = _scheduler(tmp_path)
|
||||
assert scheduler.catalog is not None
|
||||
categories = scheduler.catalog.categories()
|
||||
assert "housekeeping" in categories and "response" in categories
|
||||
assert "delete_skill" in scheduler.catalog.skills("housekeeping")
|
||||
# An ordinary body sees the catalog but not the mutating admin surface.
|
||||
housekeeping = next(
|
||||
s for s in scheduler.tree["housekeeping"] if s.name == "delete_skill"
|
||||
)
|
||||
ordinary = Skill(
|
||||
name="probe",
|
||||
category="tracking",
|
||||
description="Probe.",
|
||||
act=lambda ctx, request: ActionResult(action_log="ok", new_state="x"),
|
||||
)
|
||||
house_ctx = scheduler.runner._skill_context(housekeeping, Request("x"))
|
||||
plain_ctx = scheduler.runner._skill_context(ordinary, Request("x"))
|
||||
assert house_ctx.admin is scheduler
|
||||
assert plain_ctx.admin is None
|
||||
assert plain_ctx.catalog is scheduler.catalog
|
||||
|
||||
|
||||
def test_fidelity_gate_state_is_whole_body_without_the_request(tmp_path):
|
||||
"""The gate ingests the whole body plus the inventory and goal, and never
|
||||
the raw user request (the truncation bug and the PII path, both fixed)."""
|
||||
|
||||
Reference in new issue
Block a user