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:
gabby committed 2026-10-17 07:34:39 +00:00
1 parent ed894bd329
commit ec3e6b1b97
8 files changed
+126 -13

No files matched your search

+28 -1
View File
@@ -47,8 +47,35 @@ class ActionContext:
timers: TimerService | None = None
# The scheduler, exposed to built-in meta skills (housekeeping) so they can
# act on the agent's own tree/registry/store. None for ordinary bodies, which
# must never reach into the agent.
# must never reach into the agent (the read-only `catalog` is their view).
admin: object | None = None
# A read-only view of the agent's own skill catalog (categories -> skills),
# for an introspection skill that reports what the agent can do. Unlike
# `admin` it exposes no mutation, so an ordinary body may read it.
catalog: "SkillCatalog | None" = None
@dataclass
class SkillCatalog:
"""Read-only introspection of the agent's own skill tree.
An ordinary skill body must never reach into the agent (`ctx.admin` is for
the built-in housekeeping meta skills), but a skill that reports the agent's
own capabilities legitimately needs to see the tree. This is that surface:
reads only — the category list and the skills inside one category — with no
way to mutate. `provider` returns the live tree (the scheduler supplies a
locked snapshot), so a skill authored after startup is still listed.
"""
provider: Callable[[], dict[str, list[Skill]]]
def categories(self) -> dict[str, str]:
"""Category id -> scope description, for every category in the tree."""
return category_descriptions(self.provider())
def skills(self, category: str) -> list[str]:
"""The leaf names inside one category (empty when it is unknown)."""
return sorted(skill.name for skill in self.provider().get(category, []))
def _noop_act(ctx: ActionContext, request: Request) -> ActionResult: