| type | Reference | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| title | The CapabilityPack interface | ||||||||||||||||||||
| description | The declarative contract a task-specific pack plugs into — and the tested property that a pack can never lower a kernel guardrail. | ||||||||||||||||||||
| tags |
|
||||||||||||||||||||
| lang | en | ||||||||||||||||||||
| status | stable | ||||||||||||||||||||
| generated |
|
||||||||||||||||||||
| sources |
|
🇷🇺 Русская версия: capability-pack-interface.ru.md
A task rides on the kernel as a CapabilityPack — a single frozen dataclass of data
plus callables. No base class, no registry, no discovery (research R1): exactly one pack
exists today and is wired explicitly by the composition root. The whole security value is
in what the interface withholds: a pack contributes capability but has no field, and
no handle, that could weaken a guarantee.
CapabilityPack(
name, # str
actions, # Mapping[str, ActionSpec] — the pack's DOMAIN action ids
tools, # Sequence[ToolDefinition]
privileged_statuses, # frozenset[str] — pack-declared statuses only human_input may set
reasoning_prompt, # str
dispatch, # (Action, PackContext) -> str (read-only / approved path)
execute_confirmed, # (Action, PackContext) -> (str, event?) (post-OOB path)
persist_finding, # (payload, PackContext) -> artifact? (kernel then writes it)
domain_escalation, # extra escalation triggers
signal_from, # domain signal from a model action
)- Open taxonomy.
Action.action_typeis a free string. The pack owns the domain action ids (pack.actions) and its privileged-status set; the kernel retains only the generic, non-domain ids it provides to every pack — the control/memory machinery (write_memory,request_human_confirmation) and the scope-bounded reads (read_file,search_code, decision D6).validate_actionresolves an id againstKERNEL_GENERIC_ACTIONS ∪ pack.actionsand fails closed on a miss.write_memoryis one of these generic ids, but it is not dispatched to the pack at all:KernelActionExecutorintercepts it beforepack.dispatchand builds the record itself, from a fixed shape (payload={"note": …},payload_kind="model_note",source_type=llm_inference, kernel-set). A pack declares nothing for it and must not implement a stub — there is nodispatchbranch for a pack to own (feature 002). ActionSpec=(action_class, is_reversible, validate_params).action_classis the pack's only confirmation lever — the kernel derives "write_execute ⇒ confirm" itself. A missing or permissivevalidate_paramsfails closed: the kernel whitelist, path-containment, and sandbox still apply.PackContextis the narrow, least-privilege surface handed to every pack callable:scope_root,sandbox,wrap_data. It is never the loop and never a memory-write handle, and it carries no PoC state (poc_dir/poc_generatorare pack-side, decision D2). A pack returns domain artifacts (persist_findingreturns the finding;execute_confirmedreturns a status event); the kernel performs every memory write and sets the source tier. (A transitional__getattr__shim still answersctx.audit_root→scope_rootwith aDeprecationWarninguntil the audit pack migrates; removed in PR-3.)
This is the constitution's Principle-III property, and it is tested, not asserted
(tests/security/test_hostile_pack.py). A hostile pack is just a bad value built inline —
no subclassing needed:
- H1 — cannot skip confirmation. A pack that declares an action
write_executecannot also declare it skip-confirmation:validate_actionsetshuman_confirmation = False(pending) from the class, and a structural test asserts no field namedrequires_confirmation/skip_confirmation/human_confirmationexists onActionSpecorCapabilityPack. - H2 — cannot forge a
human_inputtier.PackContexthas nomemoryfield (the test pins its field set exactly), so a pack cannot write memory at all; the kernel persists model-reported findings asexternal_llm_output, never promoted tohuman_input. The same holds forwrite_memory: it never reaches the pack, and the kernel always writes the note asllm_inference— model params cannot setsource_typeor any other identity field (rejected, not stripped). - H3 — cannot opt out of containment. Even with a permissive
validate_params, the kernel-ownedread_filerefuses paths outsidescope_root, andDockerSandbox.rundefaults to--network none— a pack only gets the sandbox handle, not its policy. - H3b — cannot choose where its own commit is filed, without bounds. The
targetparam a pack action carries becomes a memory filename, so the kernel bounds it (validate_commit_target, 200 bytes, no control characters, string only) beforepack.dispatchruns. An out-of-bounds target is a cleanDispatchStatus.errorand the pack is never entered — the refusal cannot come after the effect, because an effect the kernel could not commit re-dispatches on retry.targetis a partition label, not a path: separators are rendered inert and containment comes from the principal'sproject_id, so a traversal-shaped target is accepted and contained rather than rejected. - H4 — under-declaration cannot bypass a status gate. A pack declaring an empty or
reduced
privileged_statusesgates exactly its declared set (empty ⇒ "nothing privileged", not "gate disabled") — it cannot bypass a kernel-enforced status, because post-taxonomy the kernel enforces none of its own.
A pack can mislabel a write as read_only (action_class is genuinely its lever).
That residual is deliberately pinned by test_H1_class_mislabel_is_bounded_not_open: even
mislabeled, read_file/search_code enforce scope_root and tool execution runs in the
network-isolated sandbox. The door is bounded by unconditional containment, not closed —
and the test exists so any future change that widens it is noticed.
tests/architecture/test_kernel_pack_boundary.py enforces the direction of dependency and
the post-split (feature 048) seam:
| check | guarantee |
|---|---|
| B1 | no kernel module imports sr_agent.packs (AST-based, so a string in a comment never counts) |
| B2 | no kernel module reads an audit-owned config field (alchemy_api_key, tenderly_api_key, workspaces_root, git_token, smartgraphical_root) |
| B3 | no kernel routing module carries a stage/PoC slot identifier or the sr-stage2 default — routing is shape-agnostic |
| B4 | the kernel router resolves an arbitrary Mapping[str, str]; a missing role raises KeyError, never a silent default |
| B5 | no kernel test imports audit-only tooling (scripts.* / frontend.*) |
| B6 | the open taxonomy lowered no guardrail: action_type is not a closed domain enum; no domain action id or privileged status is operative in sr_agent/ (AST-checked); KERNEL_GENERIC_ACTIONS and LOOP_TERMINALS are exactly their task-agnostic sets and disjoint; and PackContext carries no poc_* / audit_root real field |
B6 (feature 001) is the anti-regression latch for the open taxonomy — reintroduce a domain
id or a poc_* field into the kernel and it goes red. It supersedes the old B3 naming-residue
tolerance: poc_dir/poc_generator and audit_root/AuditResult have now left the kernel
outright (only a transitional audit_root shim remains, removed in PR-3), so there is no
longer a tolerated naming residue at the action/context layer — see kernel.md.
tests/fixtures/pack/FIXTURE_PACK is a minimal, kernel-only pack (it imports zero
audit modules — the boundary guards scan it). It reproduces the same MI attack-surface
classes as the real audit pack — a read-only tool whose output is DATA-wrapped, a
write_execute action reachable only after OOB confirmation, and a memory-write path where
the kernel sets the tier — so the MI guarantees are demonstrated in this repo with no task
present. See mi-eval.md.
There is intentionally no dynamic plugin registry (YAGNI). The one pack is wired explicitly; the narrow, withholding boundary is the deliverable.