Semgrep, refinement types, and Z3 turn a "formally verified skill" into a proof you can re-check yourself — minus one named gap
Notes on Methods for Formal Verification of Agent Skills: Three Layers Toward a Mechanically Checkable Capability-Containment Proof (arXiv:2605.23951) — A. Metere · May 2026
Note published · written by SkillFed’s research pipeline from the paper above · how these notes are made
AI-assisted notes · reviewed by SkillFed Skill securityAgent skills split into two halves: a deterministic script side that runs known code, and a non-deterministic LLM side that decides what to call next. This paper treats capability-containment — proving a skill's tool calls never exceed what its manifest declares — as a property of that whole system, not just the script, and closes it with three methods built to compose rather than compete. First, abstract interpretation walks a capability-effect lattice to over-approximate what the script's code can actually do, reusing existing dataflow engines (Semgrep, CodeQL, Pyright) instead of building new analyzers from scratch. Second, the tool-call dispatch function gets wrapped in a refinement type that mechanically rejects any call whose inferred capability falls outside the manifest's declared set, no matter what the LLM asks for. Third, SMT-bounded model checking with Z3 tests the parent paper's biconditional correctness criterion against a session-length horizon, so any violation surfaces as a concrete counter-example trace rather than an abstract failure.
Together the three layers cover the threat model soundly, but the authors name one residual themselves: an LLM can always refuse to act, and neither the static analysis nor the bounded proof forecloses that. It's caught only at the session boundary, by the runtime's own biconditional check — not by the formal layers. A worked example makes the gap the method does close concrete: a skill that summarizes fetched HTML declared only network-egress and cache-read capabilities, and the static-analysis layer flagged an undeclared filesystem-write effect on the cache directory that the manifest never listed. After the manifest was corrected, the refinement-type layer passed and the bounded model checker returned unsat for sessions up to 100 tool-call envelopes — no containment violation exists within that bound. The full toolchain, three checkers plus a bundle producer and re-checker, ships as zero-dependency JavaScript inside the open-source enclawed framework, backed by a 53-test unit suite and an end-to-end CLI demo.
Key numbers
| Composable verification layers | 3 |
| Unit tests passing in the enclawed suite | 53 |
| SMT bound cleared with zero violations (worked example) | 100 envelopes |
| Named residual left uncovered by the proof | 1 (LLM refusal to act) |
| Typical SMT parameters solved in seconds | |D| ≤ 10, K ≤ 8 |
Skills related to this research
Related notes
- 26.1% of Community Skills Ship With a Vulnerability →
- Coding agents violate their own skill's embedded logic in up to 70% of test cases →
- 80% of agent skills in a 49,943-skill registry don't do what they claim — most of it is sloppiness, not malice →
- SkillFortify doesn't just scan skills, it proves the scan -- 96.95% F1, 0% false positives →
- Curated Skills Lift Success Rates 16.2 Points — Self-Generated Ones Cost You 1.3 →
- Splitting SKILL.md into three layers lifts retrieval 12%, risk detection 24% →
- Skill shadowing — not context bloat — drives up to 68% of a 202-skill library's 21% pass-rate drop →
- Failure-only skill revision helps 1 model in 10, hurts the other 8 →
- One Rollout, 58.3% Success — Up to 61% Fewer Tokens Than Baseline Agents →
References
- A. Metere, "Methods for Formal Verification of Agent Skills: Three Layers Toward a Mechanically Checkable Capability-Containment Proof," arXiv:2605.23951 (2026).
- A. Metere, "Skills as Verifiable Artifacts: A Trust Schema and a Biconditional Correctness Criterion for Human-in-the-Loop Agent Runtimes," arXiv:2605.00424 (2026).
- A. Metere, "enclawed: A Configurable, Sector-Neutral Hardening Framework for Single-User AI Assistant Gateways," arXiv:2604.16838 (2026).