agentleFS
GoogleKnown publishergoogle/capsem/skills/dev-capsem-doctor/SKILL.md

dev-capsem-doctor

Skill179 starsChanged 12 days agoApache-2.0View on GitHub

The capsem-doctor in-VM diagnostic suite. Use when writing, running, or extending doctor tests, or debugging VM sandbox issues.

  • Installs packages

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Add test functions to the appropriate guest/artifacts/diagnostics/test_*.py file, or create test_<category>.py

    line 66
  2. Very specific:

    Use from conftest import run for shell commands, output_dir fixture for temp files

    line 67
  3. Very specific:

    Test one thing per function.

    line 80
  4. Very specific:

    Use run() for shell commands, check .returncode and .stdout/.stderr

    line 81

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

capsem-doctor

capsem-doctor is a pytest-based diagnostic suite that runs inside the guest VM. It verifies sandbox integrity, network isolation, runtime environment, and AI agent functionality. It's the smoke test gate -- every change must pass it before shipping.

Doctor is also an Ironbank input. When doctor is used to close a release-critical VM/security/protocol/package-manager gate, load /ironbank and assert the full ledger through tests/ironbank/: client result, DB rows, structured logs, UDS/HTTP route output, counters, and UI-facing JSON. A doctor exit code or "row exists" check is not enough.

Running

just exec "capsem-doctor"              # Full suite (~10s total including VM boot)
just exec "capsem-doctor -k sandbox"   # Only sandbox tests
just exec "capsem-doctor -k network"   # Only network tests
just exec "capsem-doctor -x"           # Stop on first failure
just exec "capsem-doctor -v"           # Extra verbose

Test categories

FileWhat it validates
test_sandbox.pyRead-only rootfs, binary permissions (chmod 555), no setuid/setgid, kernel hardening (no modules, no debugfs, no IPv6, no swap, no kallsyms), process integrity (pty-agent, dnsmasq running; no systemd, sshd, cron), network isolation (dummy0, fake DNS, iptables, no real NICs)
test_network.pyMITM CA in system store, curl without -k works, Python urllib HTTPS, CA env vars set (SSL_CERT_FILE, REQUESTS_CA_BUNDLE, NODE_EXTRA_CA_CERTS), HTTP/80 blocked, non-443 ports blocked, direct IP blocked, multi-domain DNS faking, AI provider domains reachable
test_environment.pyTERM/HOME/PATH env vars correct, shell is bash, kernel version, aarch64 arch, mount points (/proc, /sys, /dev, /dev/pts), tmpfs verification
test_runtimes.pypython3/pip3 versions; hermetic pip install into the venv; hermetic apt install of a local .deb; apt sandbox TLS trust; Python file I/O
test_workflows.pyText write/read, Python JSON roundtrip, shell pipes, large file (10MB)
test_virtiofs.pyVirtioFS root mount, ext4 loopback upper, loop device active, workspace write/read/large file/subdir, system overlay writable, pip install works, file delete+recreate (skipped in block mode)
test_mcp.pyGuest MCP endpoint tool routing, domain blocking via MCP
test_injection.pySecurity injection tests
test_lifecycle.pycapsem-sysutil lifecycle symlinks, read-only sysutil, VM identity env vars, hostname
test_storage_write_probes.pyBounded create/read/delete probes on package-manager and workspace paths, _apt partial cache
conftest.pyTest infrastructure (auto-skip outside VM, output dir fixture); run() lives in diagnostic_support.py

The runtime rootfs is minimal (Debian base plus runc, umoci, python3, iptables, iproute2, curl, procps, pytest, rich, venv). Tests may only use those: node, uv, git, AI CLIs and pip packages like certifi or fastmcp live in the OCI images under images/, proven by tests/images/.

Infrastructure (conftest.py)

# Auto-skip if not in capsem VM (checks root + writable /root)
def pytest_ignore_collect(collection_path, config):
    if os.geteuid() != 0 or not os.access("/root", os.W_OK):
        return True

# Shell command runner
def run(cmd, timeout=10):
    return subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout)

# Shared output directory: /root/tests
@pytest.fixture
def output_dir():
    return TESTS_OUTPUT_DIR

Adding a new test

  1. Add test functions to the appropriate guest/artifacts/diagnostics/test_*.py file, or create test_<category>.py
  2. Use from conftest import run for shell commands, output_dir fixture for temp files
  3. Tests auto-skip outside the capsem VM (no special guards needed)
  4. just exec "capsem-doctor" picks up changes immediately (diagnostics repacked into initrd)
  5. For rootfs-baked changes: just _build-assets then just exec "capsem-doctor"

Where tests live on disk

  • Source: guest/artifacts/diagnostics/test_*.py (in the repo)
  • In rootfs: /usr/local/lib/capsem-tests/test_*.py (baked by Dockerfile.rootfs)
  • In initrd: overrides rootfs copies via _pack-initrd (fast iteration)

Writing good diagnostic tests

  • Test one thing per function. Name clearly: test_readonly_rootfs, test_mitm_ca_in_system_bundle
  • Use run() for shell commands, check .returncode and .stdout/.stderr
  • Set reasonable timeouts (default 10s). Network tests may need longer.
  • Think adversarially: test what should be blocked, not just what should work
  • For VirtioFS tests, skip gracefully in block mode: pytest.mark.skipif
  • For Ironbank/release gates, do not skip. If a package manager, protocol, or diagnostic dependency is unavailable, the product or harness is broken.
  • Package-manager diagnostics must prove function, not installation presence: run the installed binary/module and verify deterministic behavior.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.