[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6994M064H0MZB58RKHS35DV":3,"skill-same:01M6994M064H0MZB58RKHS35DV":91},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":45,"repositoryHtmlUrl":46,"repositoryHomepageUrl":17,"ownerHtmlUrl":47,"ownerBlogUrl":48,"ownerDescription":49,"updatedAt":50,"install":51,"resources":64},"01M6994M064H0MZB58RKHS35DV","dev-testing","Capsem 测试策略与流程","Capsem testing policy and workflow. Use whenever running or writing tests. For VM, hypervisor, frontend, or Python specifics see the dev-testing-* skills.","Capsem 测试策略与工作流。在运行或编写测试时使用。有关 VM、hypervisor（虚拟机管理程序）、前端或 Python 的具体细节，请参见 dev-testing-* 系列技能。","google\u002Fcapsem","google","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1342004?v=4","01M698VYEFDM0VJBZDYYJ2T83S","Google","01M69939YZJTP726NQK4NZNB48",186,"Apache-2.0",null,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Fdev-testing\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQGD5WG86P4AQ5GPSSKBFR","测试工程师","PROFESSION","适用职业",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQJH394GT47X57A9Q8G7HX","测试与质量保障","SCENARIO","使用场景",[31,32,33,34,35,36],"testing","dev testing","frontend","writing","python","policy","2026-11-10 10:12:30",false,"---\nname: dev-testing\ndescription: Capsem testing policy and workflow. Use whenever running or writing tests. For VM, hypervisor, frontend, or Python specifics see the dev-testing-* skills.\n---\n\n# Testing\n\nRead `tests\u002FREADME.md` before adding or moving test fixtures. Test-only config\nbelongs under `tests\u002Ffixtures\u002F`, not root `config\u002F`.\n\n## Where a new guard belongs\n\nA test that records an architectural mistake -- something that must not be\nrepeated, checkable from source -- is a Citadel guard, in `tests\u002Fcitadel\u002F`, not\nanother file at `tests\u002F` root. It runs in the fast phase, so it costs seconds\nrather than waiting on an asset build.\n\nTwo rules the existing guards follow:\n\nState the reason in a named `*_RATIONALE` appended to the assertion, so a\nviolation teaches. `test_db_boundary.py` is the model. Where the reason is\nalready stated canonically -- `config\u002Fgate.toml [boundary]`, AGENTS.md, a skill\n-- cite it instead of restating it.\n\nWrite the adversarial case, not just the conformance case. A guard proved only\nby inputs it was built for is not proved. `test_workflow_enforcement.py` carries\nfourteen evasions and four legitimate shapes because enumerating bad spellings\nlet five through; the rule is now a whitelist for that reason.\n\n## Test execution\n\nWrite code first with TDD and minimal focused feedback. During routine edits\nrun the regression being changed and only necessary file\u002Fbehavior checks.\nBroad workspace, contract, Citadel, VM, installed-package and performance runs\nbelong at major phase boundaries, not after every edit or commit. Pending full\nproof must not block independent implementation. Qualify the complete phase\nbefore calling it qualified, and retain the exact-source merge\u002Frelease gates.\nThe bounded wrapper provides timeout and cleanup without a default machine\nlease; reserve `--machine-lease` for explicitly isolated qualification work.\n\nFinish a focused build\u002Ftest command before editing its inputs. Cargo may have\nalready compiled a test when a later edit lands, so its green result can cover\nolder bytes. If inputs changed during compilation or execution, that result\ndoes not verify the final source; rerun the focused regression after the edit.\n\nSDK acceptance launchers use `uv run --frozen --no-sync` against the environment\nprepared by the gate. Snapshot refresh changes source mtimes; an implicit sync\ncan rebuild the editable SDK and fetch its backend inside the sealed namespace.\nDependency preparation belongs to the earlier environment owner.\n\nLinux managed-supervisor acceptance hands the private manager's runtime and PID\nexplicitly through the privilege transition. The worker checks its socket peer,\nnative owner and network namespace before restoring the manager environment.\nNever adopt an ambient user manager outside the sealed worker's namespace:\nits service can be healthy while localhost is unreachable from the test.\nPass that authenticated manager's runtime and bus address explicitly into the\nservice unit too. A user manager's default unit environment can point at a\ndifferent session; worker-only binding leaves a healthy service unable to\nverify its own restart policy.\n\nFocused Ruff commands must select `--config build_system\u002Fpyproject.toml`, as\nthe gate does. Auto-discovery from a root-level test used a different Python\nversion and reversed `tomllib` import grouping, passing locally then failing\nthe canonical source phase.\n\n| Command | What | VM? |\n|---------|------|-----|\n| `just fast-test` | Incomplete source feedback only | No |\n| `just focus-test \u003Cgroup>` | One existing owner; `rust` selects changed crates and reverse dependents | Depends on group |\n| `just install` | Complete local macOS package build and native install for hands-on testing | Yes |\n| `just test` | Complete local verification; required, passing, before a release | Yes |\n\nA release normally needs passing `just test`; explicitly approved release `force`\nmay follow focused test-only fixes. Source guards, audits and hosted proof remain.\n`just fast-test` and `just focus-test \u003Cgroup>` are broader feedback tools for a\nphase boundary or a failure that needs their scope. During TDD use the smallest\nnative test directly; use complete verification at major phase boundaries.\n\nPick the narrowest lens, in this order: one test file run directly with pytest\nin the latest `cache\u002Fworktrees\u002F\u003Crun>` (it reuses that run's built assets; rebuild\nand re-sign only what changed), then `focus-test \u003Cowner>` (`kingslanding` for\ncontainers, `assets` to rebuild the guest), then `functional --slow` once on the\nfinal head. Ask the user before adding a new owner.\n\nThe full gate is a construction boundary, not the edit loop. During TDD,\nreproduce the failure with the smallest focused test, run that test red\u002Fgreen,\nand batch adjacent parity fixes before paying for the complete gate. Run it\nonly when explicitly requested. Later fixes use focused owners; a gate-policy\nedit is not permission for another full run. The one full run a change always\nneeds by default is the passing `just test` a release of it requires. Use the\ndocumented operator-approved release override only when explicitly authorized.\n\n`just test` deliberately accepts committed or uncommitted developer work. It\nrecords `HEAD` plus a digest of every tracked and untracked non-ignored source\nbyte, then fails if either changes while the gate runs. Generated output stays\nunder ignored build directories. The local proof therefore covers the exact\nsource state the developer asked to test without forcing commit choreography.\nAutomatic gate benchmark output belongs under ignored\n`cache\u002Ftarget\u002Ftests\u002Fbenchmarks\u002F`. Historical benchmark publication uses the owning\npytest\u002Fbenchmark command and an explicit review; it is not a Just convenience\nrecipe.\n\n## Release CI invariant\n\nRelease CI reuses the same checked-in private modules as local `just test`:\n\n- `_test-fast`\n- `_test-static`\n- `_test-artifacts`\n- `_test-functional`\n- `_test-glowup`\n- `_test-release-contracts`\n\nThe build scope is selective; the quality scope is not. Binary CI builds only\npackages and resolves the channel's runtime by recorded digest. Runtime CI\nbuilds the runtime for one channel and resolves the current package by recorded\ndigest. The resolved complementary artifacts are staged into the production\ntest harness, not replaced by source-built substitutes.\n\nEvery activated pairing must pass artifact validation, all VM suites,\nWinterfell\u002FMCP lifecycle, IronBank, injection, integration, benchmarks, full\n`capsem-doctor`, exact native install, and update glow-up. A staged runtime\nwhose minimum package is not yet satisfied may run only the self-consistency,\nintegrity, isolation, and boot proof; the following binary lane must run the\ncomplete functional and glow-up modules before activation.\n\nBoth macOS and Linux must install their exact publishable native packages,\nincluding their real post-install scripts, before publication. Notarization and\nthe public stable-to-nightly switch\u002Fupgrade glow-up remain mandatory\nend-to-end proof.\n\nOn Apple Silicon macOS, `just test` owns the pre-publication macOS package\nboundary through `build_system\u002Fpackaging\u002Fmacos\u002Fmacos_release_glowup.py`: it builds the package with the\nproduction assembler, installs that exact file in a disposable headless Tart\nguest, verifies the receipt, app bundle, complete binary cohort, service and\ngateway health, then extracts the same package on the physical Mac and boots a\nreal Capsem guest VM from its exact binary\u002Fruntime payload to a shell marker.\nThe local package is unsigned; its postinstall ad-hoc signs the installed\nMach-O payload with the required entitlements. Local qualification must not\nload Developer ID material or create a signing keychain. The tagged publication\nworkflow alone signs, notarizes, staples, and installs the final publishable\npackage.\nTart macOS guests do not support nested virtualization, so these are two\nexplicit halves of one script rather than a claimed nested proof. `just fast-test`\ndeliberately excludes Tart and therefore cannot be used for release.\n\nRust is pinned to `1.97.1` across the workspace file, workflow steps,\nhost-builder, and bootstrap. Change all pin surfaces together in a deliberate\ntoolchain-bump PR. RustSec and JavaScript bulk advisories are blocking in\n`just fast-test`, local `just test`, ordinary CI, and both release lanes,\nas well as the scheduled\u002Fmanual audit. A new advisory fails the candidate\nuntil it is remediated or explicitly reviewed in checked-in scanner policy.\n\nLinux proof is host-aware: a cross-built non-host package receives structural\nvalidation in qualification and exact native installation in its tagged release\njob. `CAPSEM_REQUIRE_LINUX_DEB_PROOF=1` must not reject that non-host package\nbefore the host package reaches its mandatory KVM proof. The hosted arm64 runner\ndoes not expose `\u002Fdev\u002Fkvm`, so it proves exact package\u002Fservice operation while\nthe x86_64 runner additionally owns the guest-shell marker.\n\nExpensive harnesses need a cheap clean-environment bootstrap proof at the\nstart of `just test`, before Docker\u002FColima or artifact preparation. The one\nprivate `_test-fast` module is also called by `just fast-test`, ordinary CI, and\nboth release lanes. It owns YAML\u002Fworkflow and source syntax, source contracts,\ndependency audits, Clippy, Python lint\u002Ftype checks, and JavaScript\u002Ffrontend\nchecks; no caller may reproduce a subset inline. Only a green fast gate may\nbuild the Linux install-test image. That preflight must use a\ncontainer-owned `UV_PROJECT_ENVIRONMENT` and prove `python -m pytest` launches\nbefore VM, package, or asset work consumes hours. Keep an ordering contract.\nIt is fail-fast infrastructure\nvalidation only: the later Docker\u002Fsystemd install E2E remains mandatory and\nmust still exercise the installed package and post-install behavior.\nUse the configured localhost hostname for sealed install probes: Docker's\nrandom hostname is absent from `\u002Fetc\u002Fhosts` with `network=none`, so sudo warns.\n\nCopied macOS system executables need `sign_binary(path, relocated=True)` from\n`tests\u002Fhelpers\u002Fsign.py`. Their original Apple signature may verify strictly\nyet still carry launch constraints that cause SIGKILL after relocation.\nThis mode replaces only ordinary fixture signatures; selected runtime,\nrelease, and frozen-cohort artifacts must remain immutable consumers.\n\nSeatbelt can silently strip set-id bits even when `chmod` succeeds. Verify a\nfixture's real mode before blaming admission. Test mode decisions with concrete\ninputs through the shared production predicate, keeping real filesystem tests\nfor both consumers; do not mock `Path.stat` or relax the sandbox to set a bit.\n\n## Local\u002FCI execution parity\n\nRead `references\u002Flocal-ci-parity.md` before editing any release workflow, gate\nrecipe, or CI job. It holds the Ironbank parity rule (every portable release\ngate must be owned by `just test`), scanner\u002Ftool pinning, Docker platform and\nprune discipline, common cache contracts, and the source-guard contracts.\n\n## TDD workflow\n\nFocused Ruff checks must include `--config build_system\u002Fpyproject.toml`, as\nthe canonical source gate does. Implicit configuration can classify imports\ndifferently and produce changes that fail the actual repository policy.\n\nWrite tests first:\n1. Write failing tests that capture expected behavior\n2. Verify they fail for the right reason\n3. Write minimal implementation to pass them\n4. Refactor\n\nWithout a failing test first, tests can pass by accident. Cargo fixtures, including tiny probes, use `tests\u002Fhelpers\u002Fbounded.py`: its `env` argument applies explicit probe compiler and target overrides after containment; never serialize inherited secrets. The wrapper owns the finite child timeout and cleanup; routine probes do not acquire a machine lease. Do not add an outer subprocess timeout.\n\n## Functional slice proof matrix\n\nUse the matrix below for qualification at each major phase boundary. During implementation run only the focused checks needed for the changed behavior and record outstanding phase proof. A green unit suite or a benchmark is not a substitute for complete phase qualification.\n\n| Category | What it proves | Minimum expectation |\n|----------|----------------|---------------------|\n| Unit\u002Fcontract | Pure logic, parser state machines, schema migration, helper APIs | Red\u002Fgreen tests for normal and edge behavior at the smallest useful boundary |\n| Functional | The feature works through its production-facing API, not just private helpers | Exercise the real module boundary with realistic inputs and assert outputs plus side effects |\n| Adversarial | The feature preserves security, privacy, and policy invariants when attacked | Malformed, oversized, denied, missing, racing, timeout, permission, and leak-prevention cases |\n| E2E\u002FVM | The user-visible path works in a real Capsem session | Boot\u002Frun a VM or use the black-box CLI\u002FMCP\u002Fservice path, then inspect externally visible behavior |\n| Telemetry | Audit data is present, accurate, and queryable | Query `session.db` or logger readers for required rows, fields, decisions, errors, and attribution |\n| Performance | Hot paths stayed inside the accepted budget | Benchmarks or timing assertions with recorded numbers and regression criteria |\n\nIf a category is genuinely impossible or deliberately deferred, record it as missing with a reason, owner, and follow-up task. Silent deferral is the bug. \"Covered by later E2E\" is not enough unless the tracker names the later test and the current milestone is explicitly scoped as internal-only.\n\nFor policy, MITM, MCP, telemetry, networking, filesystem, process lifecycle, or sandbox-boundary work, the functional slice matrix is mandatory. The tests should prove not only that the happy path succeeds, but also that enforcement happens at the intended boundary: a blocked MCP tool does not dispatch, a blocked return does not leak, a denied URL does not reach the network, a malformed frame does not poison the stream, and telemetry records the truth.\n\n## Ironbank ledger tests\n\nUse `\u002Fironbank` for release-critical VM, network, model, MCP, credential\nbroker, package-manager, doctor, benchmark, and security acceptance proof.\nIronbank lives in `tests\u002Fironbank\u002F` and is full black-box: tests are written\nfrom public contracts, CLI help, docs, generated schemas, hermetic fixtures,\nroute responses, logs, DB rows, and installed package metadata. Do not inspect\nRust\u002Fproduct internals to decide expected behavior.\n\nIronbank cannot use:\n- `skip`, `skipif`, `slow`, optional markers, or public-network dependencies\n- status-code-only replay\n- row-exists checks\n- parser-only assertions\n- manual OAuth\u002Fclient runs as release proof\n\nOne deterministic stimulus must prove the whole ledger path: client result,\nparsed facts, CEL\u002Fsecurity decision, detection\u002Fenforcement rows, protocol DB\nrows, structured logs, status counters, UDS route, HTTP route, and UI-facing\nJSON. Every emitted DB\u002Flog\u002Froute field is exact-value asserted, covered by a\ntyped invariant, or explicitly marked not applicable. Unknown fields fail the\ntest until the field ledger is updated.\n\nPackage-manager tests prove function. Installing `zstd`, for example, means\ncompressing known bytes, decompressing them, and comparing the exact output;\nnot just checking dpkg output.\n\n## Logged-data DB ownership\n\nTelemetry and security ledgers are database-owned. Service routes, UI handlers,\nMCP helpers, and benchmark harnesses must not build their own logged-data\nprojection caches and must not open SQLite directly. They may own query intent\n(for example the fields a route needs), but they call the logger DB object to\nexecute it. The logger DB object owns connection threads, `mem`\u002Fdisk table\nlayout, write buffering, flush, reload-from-disk behavior, WAL tuning, and\nfuture FTS5\u002Fsearch tables.\n\nDo not move route-specific SQL into `DbWriter` or turn the DB layer into a pile\nof route helper methods such as `stats_detail_payload()` just to hide SQL. The\nboundary is execution and storage mechanics:\n\n```rust\ndb.ready().await?;\ndb.query(sql, params).await?;\ndb.write(event).await?;\n```\n\n`db.write(event).await` means the DB object accepted the event into its\nproducer buffer. Tests that assert read-after-write rows must use the DB flush\nbarrier or shutdown\u002Freopen. Do not paper over visibility with sleeps, route\nprojections, or direct SQLite readers.\n\nEmpty table means empty result. Missing table or column means the schema\ncontract is broken and must fail loudly; never add compatibility branches that\ntreat missing ledger shape as empty data.\n\nRegression tests must guard the boundary. If a route needs ledger data, add a\ntest that proves the route uses the DB object and a source guard that rejects\nraw `rusqlite` opens, direct `DbReader::open`, and service-owned projection\nstate in production route code. Add a companion guard that prevents\nroute-specific DB writer methods or missing-schema fallbacks from being\nintroduced.\n\n## Mock server boundary\n\n`crates\u002Fcapsem-mock-server` is the single reusable local fixture server for\nbenchmarks, doctor, protocol recording\u002Freplay, gateway\u002Fintegration tests, and\nIronbank. It owns mock protocol responses and deterministic local upstream\nbehavior. Tests may launch it through `build_system\u002Fscripts\u002Ftest\u002Fmock_server.py`,\n`tests\u002Fhelpers\u002Fmock_server.py`, or `CAPSEM_MOCK_SERVER_BASE_URL`.\n\nDo not add another local HTTP\u002FMCP\u002FOAuth\u002Fmodel mock server for a feature. Extend\nthe shared mock server and its fixtures instead, then assert the route through\nthe relevant black-box test.\n\n## Parallel VM and process lifecycle tests\n\nRead [parallel-lifecycle-tests.md](references\u002Fparallel-lifecycle-tests.md) before\nchanging VM concurrency, companion supervision, or Apple VZ lifecycle tests.\n\n## Adversarial testing\n\nCapsem is a security product. Every security-relevant feature needs tests that actively try to break invariants. Think like an attacker:\n- Can a corp-blocked domain be snuck through another provider's list?\n- Does an overlapping wildcard in allow+block always deny?\n- Does malformed input (empty strings, unicode, huge payloads, invalid JSON) get rejected?\n- Can path traversal escape the VirtioFS sandbox?\n- Can a guest process modify its own binaries?\n\nStress-test boundary conditions. Write tests for the attacks you'd attempt yourself.\n\n### Security invariants to verify in tests\n\nWhen touching security-relevant code, check these invariants have test coverage:\n\n| Invariant | What to test | Where |\n|-----------|-------------|-------|\n| VirtioFS share is `guest\u002F` only | `session_dir\u002Fguest\u002F` exists, symlinks resolve, host-only files (`session.db`, `serial.log`) are outside the share | `capsem-core::lib::tests` |\n| UDS sockets are 0600 | After bind, verify permissions exclude other users | `capsem-process` |\n| Process env is cleared | `env_clear()` called, only allowlisted vars passed | `capsem-service` spawn tests |\n| No `process::exit` on guest I\u002FO | Control channel close causes loop break, not exit | `capsem-process` |\n| Sensitive logs are 0600 | `serial.log` created with restricted permissions | `capsem-process` |\n| Gateway auth on all routes | Every route except `GET \u002F` returns 401 without token | `capsem-gateway::auth::tests` |\n| Auth rate limiting | 429 after threshold, resets after window | `capsem-gateway::auth::tests` |\n| CORS rejects external origins | Only localhost\u002F127.0.0.1\u002Ftauri allowed | `capsem-gateway::tests` |\n| Body size limit | 413 for >10MB payloads | `capsem-gateway::proxy::tests` |\n| VM ID validation | Path traversal (`..\u002F`), dots, spaces, null bytes rejected | `capsem-gateway::terminal::tests` |\n| Rootfs read-only | runtime rootfs asset mounted ro, guest binaries 555 | `capsem-doctor` in-VM tests |\n| Suspend reports errors | IPC failure and timeout both return 500, not silent success | `capsem-service` tests |\n\n## Test fixture anti-pattern: masking races with polling\n\nIf all test fixtures wait\u002Fpoll before asserting, the tests will never catch server-side race conditions. For every endpoint that talks to a VM socket, write at least one test that calls it IMMEDIATELY after provision (no `wait_exec_ready`, no `ready_vm` fixture). The server must handle readiness internally.\n\n**Pattern to avoid** (masks the bug -- server never needs wait logic because client always waits):\n```\nfixture calls provision -> fixture polls wait_exec_ready -> test calls exec\n```\n\n**Required test pattern** (catches the bug -- if server doesn't wait, test fails):\n```\ntest calls provision -> test immediately calls exec -> server handles wait\n```\n\nSee `tests\u002Fcapsem-service\u002Ftest_svc_exec_ready.py` for the regression tests that enforce this.\n\n### wait_exec_ready is a single call, not a loop\n\n`wait_exec_ready` (in `tests\u002Fhelpers\u002Fservice.py`, `tests\u002Fhelpers\u002Fmcp.py`, `tests\u002Fcapsem-gateway\u002Ftest_gw_e2e.py`) makes one exec call with the server-side timeout passed through. The server's `handle_exec` calls `wait_for_vm_ready` internally, which polls until the VM is ready. Do NOT add client-side retry loops -- that creates a double-wait where each retry can block for the full server timeout (30s client retries x 30s server wait = pathological cascade). One wait, one place.\n\nFor gateway readiness and selected native-binary provenance, read\n[native gateway fixtures](references\u002Fnative-gateway-fixtures.md).\n\n### Exec latency regression gate\n\n`tests\u002Fcapsem-serial\u002Ftest_boot_timing.py::test_exec_latency_within_gate` asserts that provision-to-first-exec completes within `EXEC_LATENCY_GATE`. If this test fails, investigate boot time (process.log boot_timeline spans), not the wait mechanism.\n\n## Where tests live\n\n- **Rust unit: sibling `tests.rs` file, not inline `mod tests { ... }`.** See the next subsection.\n- Rust integration: `crates\u002Fcapsem-core\u002Ftests\u002F`\n- In-VM diagnostics: `guest\u002Fartifacts\u002Fdiagnostics\u002Ftest_*.py` (see dev-testing-vm)\n- Hypervisor: KVM + Apple VZ tests (see dev-testing-hypervisor)\n- Frontend: `web\u002Fapp\u002Fsrc\u002Flib\u002F__tests__\u002F` (see dev-testing-frontend)\n- Python (builder): `tests\u002Ftest_*.py`\n- Python integration (service daemon): `tests\u002Fcapsem-*\u002F` directories, each with its own conftest.py and pytest marker\n- Ironbank release ledger: `tests\u002Fironbank\u002F` (black-box only; no Rust\n  implementation-derived expectations)\n\n### Rust unit tests: sibling `tests.rs` pattern\n\n**Every Rust module keeps its unit tests in a sibling `tests.rs`, not an inline `mod tests { ... }` block.** The parent module declares:\n\n```rust\n\u002F\u002F foo.rs  OR  foo\u002Fmod.rs\n\u002F\u002F ... production code ...\n\n#[cfg(test)]\nmod tests;\n```\n\nand the tests go in `tests.rs` in the same directory:\n\n```rust\n\u002F\u002F tests.rs -- sibling of foo.rs or child of foo\u002F\nuse super::*;\n\n#[test]\nfn roundtrip() { ... }\n```\n\n**Why.** Inline `#[cfg(test)] mod tests { ... }` blocks are appended at the bottom of prod files and commonly hit 50–99% of the file's line count. That means every Read, grep, and scroll to reach production code walks past thousands of test lines first. Several modules in this codebase hit 4,000+ lines that way before extraction. Agents and humans both read faster when prod code isn't buried.\n\n**Mechanics.**\n- `tests.rs` is a submodule of the parent file -- `use super::*;` works, private items are visible, `#[cfg(test)]` on the `mod tests;` declaration still gates compilation.\n- For files that don't yet have a sibling directory (e.g. `lib.rs`, `foo.rs`), put `tests.rs` next to them in the same `src\u002F` directory.\n- For files that are already `foo\u002Fmod.rs`, put `tests.rs` inside `foo\u002F`.\n- Attributes on the inline `mod tests` block (e.g. `#[allow(unused_imports)]`) move onto the declaration: `#[cfg(test)]\\n#[allow(unused_imports)]\\nmod tests;`.\n\n**Extraction recipe** (for any remaining inline `mod tests { ... }`):\n1. Move the block body (everything between the outer `{` and `}`) into a new sibling `tests.rs`.\n2. Dedent one indentation level so contents read as top-level items.\n3. Replace the old inline block with `#[cfg(test)] mod tests;` (plus any attributes that were on the original).\n4. `cargo test -p \u003Ccrate>` -- should pass identically.\n\n**When to push back.** If you see a new PR or agent output adding an inline `mod tests { ... }` block, request it be moved to `tests.rs` before merge. Exceptions are narrow: tiny helper modules under ~50 lines total where inline tests plus prod code fit on one screen, or a module that's already a test-only helper.\n\n### Source contracts must read the sibling, not the production file\n\nA Python contract asserting that some Rust test *exists* must read the sibling\n`tests.rs`, never the production `.rs` the test moved out of. Use\n`tests\u002Frust_sources.py`:\n\n```python\nfrom rust_sources import production, sibling_tests\n\nassert \"pub enum Status\" in production(RELEASE_GRAPH)          # prod symbol\nassert \"release_graph_enums_reject_unknown\" in sibling_tests(RELEASE_GRAPH)\n```\n\nKeep the two sources **separate**. Several contracts assert a symbol is\n*absent* from production (`\"Removed\" not in source`), and a test module\nlegitimately names the thing it proves is rejected -- concatenating them lets a\nfixture falsify a claim about shipped code.\n\n`sibling_tests()` resolves `mod tests;` the way Rust does (`foo.rs` →\n`foo\u002Ftests.rs`; `main.rs`\u002F`lib.rs`\u002F`mod.rs` → `tests.rs` beside it) and raises\nwhen the module is missing rather than passing on an empty string. The helper is\nnot named `tests_of` on purpose: pytest collects `test*`, so the obvious name\nbecomes a phantom failing test in every importer.\n\n`tests\u002Ftest_rust_test_name_assertions.py` enforces this repo-wide and fails in\nseconds. It resolves each assertion's target through the AST, per function\nscope, so a contract that legitimately names a relocated test while asserting it\nagainst a test module or spec document is not flagged.\n\n**Why it matters.** This layout change broke sixteen contracts under\n`tests\u002Fcapsem-release\u002F`, then five more under `tests\u002Fcapsem_install\u002F` that run\nonly inside the Docker install gate -- invisible until forty minutes into a\nrelease run. Nothing about the failure pointed at a moved function; it read as a\nbroken release.\n\n## Integration test suites\n\nAll Python integration tests live under `tests\u002Fcapsem-*\u002F` and use pytest markers. Each suite has a dedicated `just` recipe.\n\n| Suite | Directory | Marker | VM? | What it tests |\n|-------|-----------|--------|-----|---------------|\n| Service API | `capsem-service\u002F` | `integration` | Yes | HTTP endpoints: provision, list, info, exec, logs, file I\u002FO, delete |\n| CLI | `capsem-cli\u002F` | `integration` | Yes | CLI subcommands via subprocess |\n| npm MCP | `ironbank\u002Ftest_mcp_settings_ledger.py` | `ironbank` | Yes | Packed npm stdio -> authenticated gateway -> guest MCP ledger proof |\n| Session DB | `capsem-session\u002F` | `session` | Yes | Telemetry: net\u002Fmodel\u002Ftool\u002Fmcp\u002Ffs events |\n| Isolation | `capsem-isolation\u002F` | `isolation` | Yes | Multi-VM filesystem + network isolation |\n| Security | `capsem-security\u002F` | `security` | Yes | Binary perms, codesigning, asset integrity, env blocklist |\n| Config | `capsem-config\u002F` | `config` | Yes | Limits, resource bounds, hot-reload |\n| Bootstrap | `capsem-bootstrap\u002F` | `bootstrap` | No | Setup flow, dev tools, asset checks |\n| Stress | `capsem-stress\u002F` | `stress` | Yes | 5 concurrent VMs, rapid create\u002Fdelete |\n| Build chain | `capsem-build-chain\u002F` | `build_chain` | Yes | cargo build -> codesign -> pack -> manifest -> boot |\n| Guest | `capsem-guest\u002F` | `guest` | Yes | Network, services, filesystem, env inside guest |\n| Cleanup | `capsem-cleanup\u002F` | `cleanup` | Yes | Process killed, socket removed, session dir removed |\n| Codesign | `capsem-codesign\u002F` | `codesign` | No | All binaries signed, entitlements present (FAIL not skip) |\n| Serial | `capsem-serial\u002F` | `serial` | Yes | Console logs, boot timing \u003C 30s |\n| Session lifecycle | `capsem-session-lifecycle\u002F` | `session_lifecycle` | Yes | DB exists, schema, events, survives shutdown |\n| Config runtime | `capsem-config-runtime\u002F` | `config_runtime` | Yes | CPU\u002FRAM applied in guest, blocked domains |\n| Recipes | `capsem-recipes\u002F` | `recipe` | No | just run-service, just doctor, cargo build |\n| Recovery | `capsem-recovery\u002F` | `recovery` | Yes | Stale socket\u002Finstances, orphaned process, double service |\n| Rootfs artifacts | `capsem-rootfs-artifacts\u002F` | `rootfs` | No | Artifact files, build context, doctor consistency |\n| Session exhaustive | `capsem-session-exhaustive\u002F` | `session_exhaustive` | Yes | Per-table data validation, cross-table FK integrity |\n| Install | `capsem_install\u002F` | `install` | No | Native package installer: layout, auto-launch, service install, manifest placement, update, uninstall, lifecycle, reinstall, error paths |\n\n`just test` is the only public complete local verification. `just fast-test`\nis incomplete feedback, `just focus-test` selects a closed existing owner, and\n`just install` is the complete local product install. Do not add another\ncomposite; use the owning native test for narrower diagnosis.\n\nPublic Just recipes, Capsem CLI command paths, and service HTTP method\u002Fpath\npairs are exact approval-gated surfaces. Any change must pass\n`tests\u002Ftest_public_surface_contract.py` and requires explicit approval before\nediting `config\u002Fpublic-surface.toml`.\n\n## Test matrix and coverage\n\nRead `references\u002Ftest-matrix.md` for the per-crate Rust CI matrix, coverage\nenforcement, and Python suite tiers. Rust workspace and per-crate floors are\nowned only by `config\u002Fgate.toml`; the per-crate checker rejects stale headroom,\nso meaningful coverage gains raise their ratchets in the same change.\n\n## Fast debug with capsem MCP tools\n\nRead `references\u002Fmcp-debug-tools.md` for interactive VM debugging through the\ncapsem MCP server: tool table, one-shot vs iterative workflows, and common\nsession-DB queries. MCP tools are for fast targeted checks; just recipes are\nfor complete validation at major phase boundaries and before merge or release.\n\n## End-to-end validation is not optional\n\nAt the major phase boundary for changes touching guest binaries, network policy, telemetry, MCP, or VM lifecycle:\n\n1. `just exec \"capsem-doctor\"` -- verifies sandbox integrity inside the VM\n2. After telemetry\u002Flogging changes: run a real session and verify the exercised\n   protocols through the typed timeline, history, statistics, and security\n   routes. Use `check_session.py --db` only on a coherent, quiesced evidence\n   copy after its ledger worker has stopped.\n\n## When tests fail\n\nNever dismiss a test failure as \"pre-existing\" or \"unrelated.\" Every failure must be investigated. Follow the dev-debugging workflow:\n\n1. **Do not change the test to make it pass.** The test is evidence. Changing the assertion to match broken behavior destroys that evidence.\n2. **Reproduce and diagnose first.** Understand *why* it fails before writing any fix. See the dev-debugging skill for the full methodology: reproduce with a test, diagnose root cause, then fix comprehensively.\n3. **Fix the code, not the test.** If the test is genuinely wrong (not the code), explain in detail why the test's expectation is incorrect before changing it.\n\n### Measuring a gate's result\n\n**Never take the last line of a multi-part result as the result.** Two shapes of\none mistake, both of which report success while the thing measured failed:\n\n**`$?` after a pipe is the pipe's status.** `just test | tail` reports what\n`tail` did. Redirect, then read the code separately:\n\n```bash\njust test > \u002Ftmp\u002Fgate.log 2>&1; echo \"EXIT=$?\"\n```\n\n**`tail -n1` across a multi-part result returns the last part, not the whole.**\n`cargo test -p capsem-service` runs three test binaries; the last prints\n`0 passed`, so `| tail -1` reads as though the crate had no tests while 91 and\n264 passed above it. Aggregate instead of sampling:\n\n```bash\ncargo test -p capsem-service 2>&1 | grep -E \"^test result:\"   # every binary\n```\n\nBoth errors are silent and both flatter you: one turns a failed gate into a\npass, the other turns a passing crate into a phantom regression. If a command\ncan emit more than one verdict, read them all.\n\nRead the *first* real error, not the recipe cascade under it — `grep -aE \"^FAILED|^E \"` lands on the cause, while the trailing `error: Recipe ... failed` lines are only the unwind.\n\n`build_system\u002Ftests\u002Fgate\u002Ftest_exit_status_integrity.py` keeps this out of committed recipes,\nscripts, and workflows, and requires `set -o pipefail` in any bash recipe that\npipes. It cannot see an agent's ad-hoc shell — that part is on you.\n\n### Fixtures use the wrapper, never the raw variable\n\nRedirect Capsem paths with `paths::CapsemPathsGuard::redirect(root)`. It sets\n`CAPSEM_HOME`, `CAPSEM_RUN_DIR`, and `CAPSEM_ASSETS_DIR` from one root and\nrestores on drop, so a fixture cannot set one and inherit the rest.\n\nRead logs with `telemetry::read_log_tail`, including in assertions: a test that\nopens a `*.log` path directly stops exercising what the product does the moment\nthat stream rotates.\n\nBoth are enforced by `build_system\u002Ftests\u002Fgate\u002Ftest_path_and_log_wrappers_are_mandatory.py`. See\n`\u002Fdev-rust-patterns` \"One rule, one function\" for why.\n\n### Verify with the gate's environment, not a bare shell\n\n`just test` exports `CAPSEM_HOME`, `CAPSEM_RUN_DIR`, and\n`CAPSEM_BENCHMARK_OUTPUT_ROOT`. A test that reads ambient state passes in your\nshell and fails in the gate:\n\n```bash\nCAPSEM_HOME=\"$PWD\u002Fcache\u002Ftarget\u002Ftests\u002Fhome\u002F.capsem\" \\\nCAPSEM_RUN_DIR=\"$PWD\u002Fcache\u002Ftarget\u002Ftests\u002Fhome\u002F.capsem\u002Frun\" \\\n  cargo test -p \u003Ccrate>\n```\n\nA fixture that overrides `CAPSEM_HOME` must override `CAPSEM_RUN_DIR` too —\nthe run dir takes precedence over the home-derived default, so setting only the\nfirst sends production code to the ambient run directory while the fixture\nwrites into a temp one. Bisect by exporting one variable at a time; that names\nthe culprit in two runs instead of guessing.\n\n### Cache limits belong in the cache contract\n\nA number copied next to a rule drifts from it silently. Three separate gate\nfailures in one session traced to this: a coverage floor copied into a test, a\nguest kernel major copied beside its pin, and a Docker fixture restating a\nstorage assumption outside the cache policy.\n\nEach read as a broken product, and each surfaced minutes-to-an-hour into a gate rather than at the edit. Derive the value from its source, or name it once and pin config and contract together:\n\n```python\nmaximum = load_policy(ROOT).runtimes[\"docker\"].max_size_bytes\nassert registry.contract(\"docker\").max_size_bytes == maximum\n```\n\nProve it derives rather than hardcodes: change the source value and confirm the test *follows* instead of breaking.\nRead `\u002Fdev-cache` for the common cache model; tests must not recreate backend\naccounting or machine-capacity rails.\n\n## Source guards and testable design\n\nSee [source-guards-and-design.md](references\u002Fsource-guards-and-design.md) for\nplatform gating, exact guard exclusions and separating pure decisions from runtime adapters.\n","# Testing\n\nRead `tests\u002FREADME.md` before adding or moving test fixtures. Test-only config\nbelongs under `tests\u002Ffixtures\u002F`, not root `config\u002F`.\n\n## Where a new guard belongs\n\nA test that records an architectural mistake -- something that must not be\nrepeated, checkable from source -- is a Citadel guard, in `tests\u002Fcitadel\u002F`, not\nanother file at `tests\u002F` root. It runs in the fast phase, so it costs seconds\nrather than waiting on an asset build.\n\nTwo rules the existing guards follow:\n\nState the reason in a named `*_RATIONALE` appended to the assertion, so a\nviolation teaches. `test_db_boundary.py` is the model. Where the reason is\nalready stated canonically -- `config\u002Fgate.toml [boundary]`, AGENTS.md, a skill\n-- cite it instead of restating it.\n\nWrite the adversarial case, not just the conformance case. A guard proved only\nby inputs it was built for is not proved. `test_workflow_enforcement.py` carries\nfourteen evasions and four legitimate shapes because enumerating bad spellings\nlet five through; the rule is now a whitelist for that reason.\n\n## Test execution\n\nWrite code first with TDD and minimal focused feedback. During routine edits\nrun the regression being changed and only necessary file\u002Fbehavior checks.\nBroad workspace, contract, Citadel, VM, installed-package and performance runs\nbelong at major phase boundaries, not after every edit or commit. Pending full\nproof must not block independent implementation. Qualify the complete phase\nbefore calling it qualified, and retain the exact-source merge\u002Frelease gates.\nThe bounded wrapper provides timeout and cleanup without a default machine\nlease; reserve `--machine-lease` for explicitly isolated qualification work.\n\nFinish a focused build\u002Ftest command before editing its inputs. Cargo may have\nalready compiled a test when a later edit lands, so its green result can cover\nolder bytes. If inputs changed during compilation or execution, that result\ndoes not verify the final source; rerun the focused regression after the edit.\n\nSDK acceptance launchers use `uv run --frozen --no-sync` against the environment\nprepared by the gate. Snapshot refresh changes source mtimes; an implicit sync\ncan rebuild the editable SDK and fetch its backend inside the sealed namespace.\nDependency preparation belongs to the earlier environment owner.\n\nLinux managed-supervisor acceptance hands the private manager's runtime and PID\nexplicitly through the privilege transition. The worker checks its socket peer,\nnative owner and network namespace before restoring the manager environment.\nNever adopt an ambient user manager outside the sealed worker's namespace:\nits service can be healthy while localhost is unreachable from the test.\nPass that authenticated manager's runtime and bus address explicitly into the\nservice unit too. A user manager's default unit environment can point at a\ndifferent session; worker-only binding leaves a healthy service unable to\nverify its own restart policy.\n\nFocused Ruff commands must select `--config build_system\u002Fpyproject.toml`, as\nthe gate does. Auto-discovery from a root-level test used a different Python\nversion and reversed `tomllib` import grouping, passing locally then failing\nthe canonical source phase.\n\n| Command | What | VM? |\n|---------|------|-----|\n| `just fast-test` | Incomplete source feedback only | No |\n| `just focus-test \u003Cgroup>` | One existing owner; `rust` selects changed crates and reverse dependents | Depends on group |\n| `just install` | Complete local macOS package build and native install for hands-on testing | Yes |\n| `just test` | Complete local verification; required, passing, before a release | Yes |\n\nA release normally needs passing `just test`; explicitly approved release `force`\nmay follow focused test-only fixes. Source guards, audits and hosted proof remain.\n`just fast-test` and `just focus-test \u003Cgroup>` are broader feedback tools for a\nphase boundary or a failure that needs their scope. During TDD use the smallest\nnative test directly; use complete verification at major phase boundaries.\n\nPick the narrowest lens, in this order: one test file run directly with pytest\nin the latest `cache\u002Fworktrees\u002F\u003Crun>` (it reuses that run's built assets; rebuild\nand re-sign only what changed), then `focus-test \u003Cowner>` (`kingslanding` for\ncontainers, `assets` to rebuild the guest), then `functional --slow` once on the\nfinal head. Ask the user before adding a new owner.\n\nThe full gate is a construction boundary, not the edit loop. During TDD,\nreproduce the failure with the smallest focused test, run that test red\u002Fgreen,\nand batch adjacent parity fixes before paying for the complete gate. Run it\nonly when explicitly requested. Later fixes use focused owners; a gate-policy\nedit is not permission for another full run. The one full run a change always\nneeds by default is the passing `just test` a release of it requires. Use the\ndocumented operator-approved release override only when explicitly authorized.\n\n`just test` deliberately accepts committed or uncommitted developer work. It\nrecords `HEAD` plus a digest of every tracked and untracked non-ignored source\nbyte, then fails if either changes while the gate runs. Generated output stays\nunder ignored build directories. The local proof therefore covers the exact\nsource state the developer asked to test without forcing commit choreography.\nAutomatic gate benchmark output belongs under ignored\n`cache\u002Ftarget\u002Ftests\u002Fbenchmarks\u002F`. Historical benchmark publication uses the owning\npytest\u002Fbenchmark command and an explicit review; it is not a Just convenience\nrecipe.\n\n## Release CI invariant\n\nRelease CI reuses the same checked-in private modules as local `just test`:\n\n- `_test-fast`\n- `_test-static`\n- `_test-artifacts`\n- `_test-functional`\n- `_test-glowup`\n- `_test-release-contracts`\n\nThe build scope is selective; the quality scope is not. Binary CI builds only\npackages and resolves the channel's runtime by recorded digest. Runtime CI\nbuilds the runtime for one channel and resolves the current package by recorded\ndigest. The resolved complementary artifacts are staged into the production\ntest harness, not replaced by source-built substitutes.\n\nEvery activated pairing must pass artifact validation, all VM suites,\nWinterfell\u002FMCP lifecycle, IronBank, injection, integration, benchmarks, full\n`capsem-doctor`, exact native install, and update glow-up. A staged runtime\nwhose minimum package is not yet satisfied may run only the self-consistency,\nintegrity, isolation, and boot proof; the following binary lane must run the\ncomplete functional and glow-up modules before activation.\n\nBoth macOS and Linux must install their exact publishable native packages,\nincluding their real post-install scripts, before publication. Notarization and\nthe public stable-to-nightly switch\u002Fupgrade glow-up remain mandatory\nend-to-end proof.\n\nOn Apple Silicon macOS, `just test` owns the pre-publication macOS package\nboundary through `build_system\u002Fpackaging\u002Fmacos\u002Fmacos_release_glowup.py`: it builds the package with the\nproduction assembler, installs that exact file in a disposable headless Tart\nguest, verifies the receipt, app bundle, complete binary cohort, service and\ngateway health, then extracts the same package on the physical Mac and boots a\nreal Capsem guest VM from its exact binary\u002Fruntime payload to a shell marker.\nThe local package is unsigned; its postinstall ad-hoc signs the installed\nMach-O payload with the required entitlements. Local qualification must not\nload Developer ID material or create a signing keychain. The tagged publication\nworkflow alone signs, notarizes, staples, and installs the final publishable\npackage.\nTart macOS guests do not support nested virtualization, so these are two\nexplicit halves of one script rather than a claimed nested proof. `just fast-test`\ndeliberately excludes Tart and therefore cannot be used for release.\n\nRust is pinned to `1.97.1` across the workspace file, workflow steps,\nhost-builder, and bootstrap. Change all pin surfaces together in a deliberate\ntoolchain-bump PR. RustSec and JavaScript bulk advisories are blocking in\n`just fast-test`, local `just test`, ordinary CI, and both release lanes,\nas well as the scheduled\u002Fmanual audit. A new advisory fails the candidate\nuntil it is remediated or explicitly reviewed in checked-in scanner policy.\n\nLinux proof is host-aware: a cross-built non-host package receives structural\nvalidation in qualification and exact native installation in its tagged release\njob. `CAPSEM_REQUIRE_LINUX_DEB_PROOF=1` must not reject that non-host package\nbefore the host package reaches its mandatory KVM proof. The hosted arm64 runner\ndoes not expose `\u002Fdev\u002Fkvm`, so it proves exact package\u002Fservice operation while\nthe x86_64 runner additionally owns the guest-shell marker.\n\nExpensive harnesses need a cheap clean-environment bootstrap proof at the\nstart of `just test`, before Docker\u002FColima or artifact preparation. The one\nprivate `_test-fast` module is also called by `just fast-test`, ordinary CI, and\nboth release lanes. It owns YAML\u002Fworkflow and source syntax, source contracts,\ndependency audits, Clippy, Python lint\u002Ftype checks, and JavaScript\u002Ffrontend\nchecks; no caller may reproduce a subset inline. Only a green fast gate may\nbuild the Linux install-test image. That preflight must use a\ncontainer-owned `UV_PROJECT_ENVIRONMENT` and prove `python -m pytest` launches\nbefore VM, package, or asset work consumes hours. Keep an ordering contract.\nIt is fail-fast infrastructure\nvalidation only: the later Docker\u002Fsystemd install E2E remains mandatory and\nmust still exercise the installed package and post-install behavior.\nUse the configured localhost hostname for sealed install probes: Docker's\nrandom hostname is absent from `\u002Fetc\u002Fhosts` with `network=none`, so sudo warns.\n\nCopied macOS system executables need `sign_binary(path, relocated=True)` from\n`tests\u002Fhelpers\u002Fsign.py`. Their original Apple signature may verify strictly\nyet still carry launch constraints that cause SIGKILL after relocation.\nThis mode replaces only ordinary fixture signatures; selected runtime,\nrelease, and frozen-cohort artifacts must remain immutable consumers.\n\nSeatbelt can silently strip set-id bits even when `chmod` succeeds. Verify a\nfixture's real mode before blaming admission. Test mode decisions with concrete\ninputs through the shared production predicate, keeping real filesystem tests\nfor both consumers; do not mock `Path.stat` or relax the sandbox to set a bit.\n\n## Local\u002FCI execution parity\n\nRead `references\u002Flocal-ci-parity.md` before editing any release workflow, gate\nrecipe, or CI job. It holds the Ironbank parity rule (every portable release\ngate must be owned by `just test`), scanner\u002Ftool pinning, Docker platform and\nprune discipline, common cache contracts, and the source-guard contracts.\n\n## TDD workflow\n\nFocused Ruff checks must include `--config build_system\u002Fpyproject.toml`, as\nthe canonical source gate does. Implicit configuration can classify imports\ndifferently and produce changes that fail the actual repository policy.\n\nWrite tests first:\n1. Write failing tests that capture expected behavior\n2. Verify they fail for the right reason\n3. Write minimal implementation to pass them\n4. Refactor\n\nWithout a failing test first, tests can pass by accident. Cargo fixtures, including tiny probes, use `tests\u002Fhelpers\u002Fbounded.py`: its `env` argument applies explicit probe compiler and target overrides after containment; never serialize inherited secrets. The wrapper owns the finite child timeout and cleanup; routine probes do not acquire a machine lease. Do not add an outer subprocess timeout.\n\n## Functional slice proof matrix\n\nUse the matrix below for qualification at each major phase boundary. During implementation run only the focused checks needed for the changed behavior and record outstanding phase proof. A green unit suite or a benchmark is not a substitute for complete phase qualification.\n\n| Category | What it proves | Minimum expectation |\n|----------|----------------|---------------------|\n| Unit\u002Fcontract | Pure logic, parser state machines, schema migration, helper APIs | Red\u002Fgreen tests for normal and edge behavior at the smallest useful boundary |\n| Functional | The feature works through its production-facing API, not just private helpers | Exercise the real module boundary with realistic inputs and assert outputs plus side effects |\n| Adversarial | The feature preserves security, privacy, and policy invariants when attacked | Malformed, oversized, denied, missing, racing, timeout, permission, and leak-prevention cases |\n| E2E\u002FVM | The user-visible path works in a real Capsem session | Boot\u002Frun a VM or use the black-box CLI\u002FMCP\u002Fservice path, then inspect externally visible behavior |\n| Telemetry | Audit data is present, accurate, and queryable | Query `session.db` or logger readers for required rows, fields, decisions, errors, and attribution |\n| Performance | Hot paths stayed inside the accepted budget | Benchmarks or timing assertions with recorded numbers and regression criteria |\n\nIf a category is genuinely impossible or deliberately deferred, record it as missing with a reason, owner, and follow-up task. Silent deferral is the bug. \"Covered by later E2E\" is not enough unless the tracker names the later test and the current milestone is explicitly scoped as internal-only.\n\nFor policy, MITM, MCP, telemetry, networking, filesystem, process lifecycle, or sandbox-boundary work, the functional slice matrix is mandatory. The tests should prove not only that the happy path succeeds, but also that enforcement happens at the intended boundary: a blocked MCP tool does not dispatch, a blocked return does not leak, a denied URL does not reach the network, a malformed frame does not poison the stream, and telemetry records the truth.\n\n## Ironbank ledger tests\n\nUse `\u002Fironbank` for release-critical VM, network, model, MCP, credential\nbroker, package-manager, doctor, benchmark, and security acceptance proof.\nIronbank lives in `tests\u002Fironbank\u002F` and is full black-box: tests are written\nfrom public contracts, CLI help, docs, generated schemas, hermetic fixtures,\nroute responses, logs, DB rows, and installed package metadata. Do not inspect\nRust\u002Fproduct internals to decide expected behavior.\n\nIronbank cannot use:\n- `skip`, `skipif`, `slow`, optional markers, or public-network dependencies\n- status-code-only replay\n- row-exists checks\n- parser-only assertions\n- manual OAuth\u002Fclient runs as release proof\n\nOne deterministic stimulus must prove the whole ledger path: client result,\nparsed facts, CEL\u002Fsecurity decision, detection\u002Fenforcement rows, protocol DB\nrows, structured logs, status counters, UDS route, HTTP route, and UI-facing\nJSON. Every emitted DB\u002Flog\u002Froute field is exact-value asserted, covered by a\ntyped invariant, or explicitly marked not applicable. Unknown fields fail the\ntest until the field ledger is updated.\n\nPackage-manager tests prove function. Installing `zstd`, for example, means\ncompressing known bytes, decompressing them, and comparing the exact output;\nnot just checking dpkg output.\n\n## Logged-data DB ownership\n\nTelemetry and security ledgers are database-owned. Service routes, UI handlers,\nMCP helpers, and benchmark harnesses must not build their own logged-data\nprojection caches and must not open SQLite directly. They may own query intent\n(for example the fields a route needs), but they call the logger DB object to\nexecute it. The logger DB object owns connection threads, `mem`\u002Fdisk table\nlayout, write buffering, flush, reload-from-disk behavior, WAL tuning, and\nfuture FTS5\u002Fsearch tables.\n\nDo not move route-specific SQL into `DbWriter` or turn the DB layer into a pile\nof route helper methods such as `stats_detail_payload()` just to hide SQL. The\nboundary is execution and storage mechanics:\n\n```rust\ndb.ready().await?;\ndb.query(sql, params).await?;\ndb.write(event).await?;\n```\n\n`db.write(event).await` means the DB object accepted the event into its\nproducer buffer. Tests that assert read-after-write rows must use the DB flush\nbarrier or shutdown\u002Freopen. Do not paper over visibility with sleeps, route\nprojections, or direct SQLite readers.\n\nEmpty table means empty result. Missing table or column means the schema\ncontract is broken and must fail loudly; never add compatibility branches that\ntreat missing ledger shape as empty data.\n\nRegression tests must guard the boundary. If a route needs ledger data, add a\ntest that proves the route uses the DB object and a source guard that rejects\nraw `rusqlite` opens, direct `DbReader::open`, and service-owned projection\nstate in production route code. Add a companion guard that prevents\nroute-specific DB writer methods or missing-schema fallbacks from being\nintroduced.\n\n## Mock server boundary\n\n`crates\u002Fcapsem-mock-server` is the single reusable local fixture server for\nbenchmarks, doctor, protocol recording\u002Freplay, gateway\u002Fintegration tests, and\nIronbank. It owns mock protocol responses and deterministic local upstream\nbehavior. Tests may launch it through `build_system\u002Fscripts\u002Ftest\u002Fmock_server.py`,\n`tests\u002Fhelpers\u002Fmock_server.py`, or `CAPSEM_MOCK_SERVER_BASE_URL`.\n\nDo not add another local HTTP\u002FMCP\u002FOAuth\u002Fmodel mock server for a feature. Extend\nthe shared mock server and its fixtures instead, then assert the route through\nthe relevant black-box test.\n\n## Parallel VM and process lifecycle tests\n\nRead [parallel-lifecycle-tests.md](references\u002Fparallel-lifecycle-tests.md) before\nchanging VM concurrency, companion supervision, or Apple VZ lifecycle tests.\n\n## Adversarial testing\n\nCapsem is a security product. Every security-relevant feature needs tests that actively try to break invariants. Think like an attacker:\n- Can a corp-blocked domain be snuck through another provider's list?\n- Does an overlapping wildcard in allow+block always deny?\n- Does malformed input (empty strings, unicode, huge payloads, invalid JSON) get rejected?\n- Can path traversal escape the VirtioFS sandbox?\n- Can a guest process modify its own binaries?\n\nStress-test boundary conditions. Write tests for the attacks you'd attempt yourself.\n\n### Security invariants to verify in tests\n\nWhen touching security-relevant code, check these invariants have test coverage:\n\n| Invariant | What to test | Where |\n|-----------|-------------|-------|\n| VirtioFS share is `guest\u002F` only | `session_dir\u002Fguest\u002F` exists, symlinks resolve, host-only files (`session.db`, `serial.log`) are outside the share | `capsem-core::lib::tests` |\n| UDS sockets are 0600 | After bind, verify permissions exclude other users | `capsem-process` |\n| Process env is cleared | `env_clear()` called, only allowlisted vars passed | `capsem-service` spawn tests |\n| No `process::exit` on guest I\u002FO | Control channel close causes loop break, not exit | `capsem-process` |\n| Sensitive logs are 0600 | `serial.log` created with restricted permissions | `capsem-process` |\n| Gateway auth on all routes | Every route except `GET \u002F` returns 401 without token | `capsem-gateway::auth::tests` |\n| Auth rate limiting | 429 after threshold, resets after window | `capsem-gateway::auth::tests` |\n| CORS rejects external origins | Only localhost\u002F127.0.0.1\u002Ftauri allowed | `capsem-gateway::tests` |\n| Body size limit | 413 for >10MB payloads | `capsem-gateway::proxy::tests` |\n| VM ID validation | Path traversal (`..\u002F`), dots, spaces, null bytes rejected | `capsem-gateway::terminal::tests` |\n| Rootfs read-only | runtime rootfs asset mounted ro, guest binaries 555 | `capsem-doctor` in-VM tests |\n| Suspend reports errors | IPC failure and timeout both return 500, not silent success | `capsem-service` tests |\n\n## Test fixture anti-pattern: masking races with polling\n\nIf all test fixtures wait\u002Fpoll before asserting, the tests will never catch server-side race conditions. For every endpoint that talks to a VM socket, write at least one test that calls it IMMEDIATELY after provision (no `wait_exec_ready`, no `ready_vm` fixture). The server must handle readiness internally.\n\n**Pattern to avoid** (masks the bug -- server never needs wait logic because client always waits):\n```\nfixture calls provision -> fixture polls wait_exec_ready -> test calls exec\n```\n\n**Required test pattern** (catches the bug -- if server doesn't wait, test fails):\n```\ntest calls provision -> test immediately calls exec -> server handles wait\n```\n\nSee `tests\u002Fcapsem-service\u002Ftest_svc_exec_ready.py` for the regression tests that enforce this.\n\n### wait_exec_ready is a single call, not a loop\n\n`wait_exec_ready` (in `tests\u002Fhelpers\u002Fservice.py`, `tests\u002Fhelpers\u002Fmcp.py`, `tests\u002Fcapsem-gateway\u002Ftest_gw_e2e.py`) makes one exec call with the server-side timeout passed through. The server's `handle_exec` calls `wait_for_vm_ready` internally, which polls until the VM is ready. Do NOT add client-side retry loops -- that creates a double-wait where each retry can block for the full server timeout (30s client retries x 30s server wait = pathological cascade). One wait, one place.\n\nFor gateway readiness and selected native-binary provenance, read\n[native gateway fixtures](references\u002Fnative-gateway-fixtures.md).\n\n### Exec latency regression gate\n\n`tests\u002Fcapsem-serial\u002Ftest_boot_timing.py::test_exec_latency_within_gate` asserts that provision-to-first-exec completes within `EXEC_LATENCY_GATE`. If this test fails, investigate boot time (process.log boot_timeline spans), not the wait mechanism.\n\n## Where tests live\n\n- **Rust unit: sibling `tests.rs` file, not inline `mod tests { ... }`.** See the next subsection.\n- Rust integration: `crates\u002Fcapsem-core\u002Ftests\u002F`\n- In-VM diagnostics: `guest\u002Fartifacts\u002Fdiagnostics\u002Ftest_*.py` (see dev-testing-vm)\n- Hypervisor: KVM + Apple VZ tests (see dev-testing-hypervisor)\n- Frontend: `web\u002Fapp\u002Fsrc\u002Flib\u002F__tests__\u002F` (see dev-testing-frontend)\n- Python (builder): `tests\u002Ftest_*.py`\n- Python integration (service daemon): `tests\u002Fcapsem-*\u002F` directories, each with its own conftest.py and pytest marker\n- Ironbank release ledger: `tests\u002Fironbank\u002F` (black-box only; no Rust\n  implementation-derived expectations)\n\n### Rust unit tests: sibling `tests.rs` pattern\n\n**Every Rust module keeps its unit tests in a sibling `tests.rs`, not an inline `mod tests { ... }` block.** The parent module declares:\n\n```rust\n\u002F\u002F foo.rs  OR  foo\u002Fmod.rs\n\u002F\u002F ... production code ...\n\n#[cfg(test)]\nmod tests;\n```\n\nand the tests go in `tests.rs` in the same directory:\n\n```rust\n\u002F\u002F tests.rs -- sibling of foo.rs or child of foo\u002F\nuse super::*;\n\n#[test]\nfn roundtrip() { ... }\n```\n\n**Why.** Inline `#[cfg(test)] mod tests { ... }` blocks are appended at the bottom of prod files and commonly hit 50–99% of the file's line count. That means every Read, grep, and scroll to reach production code walks past thousands of test lines first. Several modules in this codebase hit 4,000+ lines that way before extraction. Agents and humans both read faster when prod code isn't buried.\n\n**Mechanics.**\n- `tests.rs` is a submodule of the parent file -- `use super::*;` works, private items are visible, `#[cfg(test)]` on the `mod tests;` declaration still gates compilation.\n- For files that don't yet have a sibling directory (e.g. `lib.rs`, `foo.rs`), put `tests.rs` next to them in the same `src\u002F` directory.\n- For files that are already `foo\u002Fmod.rs`, put `tests.rs` inside `foo\u002F`.\n- Attributes on the inline `mod tests` block (e.g. `#[allow(unused_imports)]`) move onto the declaration: `#[cfg(test)]\\n#[allow(unused_imports)]\\nmod tests;`.\n\n**Extraction recipe** (for any remaining inline `mod tests { ... }`):\n1. Move the block body (everything between the outer `{` and `}`) into a new sibling `tests.rs`.\n2. Dedent one indentation level so contents read as top-level items.\n3. Replace the old inline block with `#[cfg(test)] mod tests;` (plus any attributes that were on the original).\n4. `cargo test -p \u003Ccrate>` -- should pass identically.\n\n**When to push back.** If you see a new PR or agent output adding an inline `mod tests { ... }` block, request it be moved to `tests.rs` before merge. Exceptions are narrow: tiny helper modules under ~50 lines total where inline tests plus prod code fit on one screen, or a module that's already a test-only helper.\n\n### Source contracts must read the sibling, not the production file\n\nA Python contract asserting that some Rust test *exists* must read the sibling\n`tests.rs`, never the production `.rs` the test moved out of. Use\n`tests\u002Frust_sources.py`:\n\n```python\nfrom rust_sources import production, sibling_tests\n\nassert \"pub enum Status\" in production(RELEASE_GRAPH)          # prod symbol\nassert \"release_graph_enums_reject_unknown\" in sibling_tests(RELEASE_GRAPH)\n```\n\nKeep the two sources **separate**. Several contracts assert a symbol is\n*absent* from production (`\"Removed\" not in source`), and a test module\nlegitimately names the thing it proves is rejected -- concatenating them lets a\nfixture falsify a claim about shipped code.\n\n`sibling_tests()` resolves `mod tests;` the way Rust does (`foo.rs` →\n`foo\u002Ftests.rs`; `main.rs`\u002F`lib.rs`\u002F`mod.rs` → `tests.rs` beside it) and raises\nwhen the module is missing rather than passing on an empty string. The helper is\nnot named `tests_of` on purpose: pytest collects `test*`, so the obvious name\nbecomes a phantom failing test in every importer.\n\n`tests\u002Ftest_rust_test_name_assertions.py` enforces this repo-wide and fails in\nseconds. It resolves each assertion's target through the AST, per function\nscope, so a contract that legitimately names a relocated test while asserting it\nagainst a test module or spec document is not flagged.\n\n**Why it matters.** This layout change broke sixteen contracts under\n`tests\u002Fcapsem-release\u002F`, then five more under `tests\u002Fcapsem_install\u002F` that run\nonly inside the Docker install gate -- invisible until forty minutes into a\nrelease run. Nothing about the failure pointed at a moved function; it read as a\nbroken release.\n\n## Integration test suites\n\nAll Python integration tests live under `tests\u002Fcapsem-*\u002F` and use pytest markers. Each suite has a dedicated `just` recipe.\n\n| Suite | Directory | Marker | VM? | What it tests |\n|-------|-----------|--------|-----|---------------|\n| Service API | `capsem-service\u002F` | `integration` | Yes | HTTP endpoints: provision, list, info, exec, logs, file I\u002FO, delete |\n| CLI | `capsem-cli\u002F` | `integration` | Yes | CLI subcommands via subprocess |\n| npm MCP | `ironbank\u002Ftest_mcp_settings_ledger.py` | `ironbank` | Yes | Packed npm stdio -> authenticated gateway -> guest MCP ledger proof |\n| Session DB | `capsem-session\u002F` | `session` | Yes | Telemetry: net\u002Fmodel\u002Ftool\u002Fmcp\u002Ffs events |\n| Isolation | `capsem-isolation\u002F` | `isolation` | Yes | Multi-VM filesystem + network isolation |\n| Security | `capsem-security\u002F` | `security` | Yes | Binary perms, codesigning, asset integrity, env blocklist |\n| Config | `capsem-config\u002F` | `config` | Yes | Limits, resource bounds, hot-reload |\n| Bootstrap | `capsem-bootstrap\u002F` | `bootstrap` | No | Setup flow, dev tools, asset checks |\n| Stress | `capsem-stress\u002F` | `stress` | Yes | 5 concurrent VMs, rapid create\u002Fdelete |\n| Build chain | `capsem-build-chain\u002F` | `build_chain` | Yes | cargo build -> codesign -> pack -> manifest -> boot |\n| Guest | `capsem-guest\u002F` | `guest` | Yes | Network, services, filesystem, env inside guest |\n| Cleanup | `capsem-cleanup\u002F` | `cleanup` | Yes | Process killed, socket removed, session dir removed |\n| Codesign | `capsem-codesign\u002F` | `codesign` | No | All binaries signed, entitlements present (FAIL not skip) |\n| Serial | `capsem-serial\u002F` | `serial` | Yes | Console logs, boot timing \u003C 30s |\n| Session lifecycle | `capsem-session-lifecycle\u002F` | `session_lifecycle` | Yes | DB exists, schema, events, survives shutdown |\n| Config runtime | `capsem-config-runtime\u002F` | `config_runtime` | Yes | CPU\u002FRAM applied in guest, blocked domains |\n| Recipes | `capsem-recipes\u002F` | `recipe` | No | just run-service, just doctor, cargo build |\n| Recovery | `capsem-recovery\u002F` | `recovery` | Yes | Stale socket\u002Finstances, orphaned process, double service |\n| Rootfs artifacts | `capsem-rootfs-artifacts\u002F` | `rootfs` | No | Artifact files, build context, doctor consistency |\n| Session exhaustive | `capsem-session-exhaustive\u002F` | `session_exhaustive` | Yes | Per-table data validation, cross-table FK integrity |\n| Install | `capsem_install\u002F` | `install` | No | Native package installer: layout, auto-launch, service install, manifest placement, update, uninstall, lifecycle, reinstall, error paths |\n\n`just test` is the only public complete local verification. `just fast-test`\nis incomplete feedback, `just focus-test` selects a closed existing owner, and\n`just install` is the complete local product install. Do not add another\ncomposite; use the owning native test for narrower diagnosis.\n\nPublic Just recipes, Capsem CLI command paths, and service HTTP method\u002Fpath\npairs are exact approval-gated surfaces. Any change must pass\n`tests\u002Ftest_public_surface_contract.py` and requires explicit approval before\nediting `config\u002Fpublic-surface.toml`.\n\n## Test matrix and coverage\n\nRead `references\u002Ftest-matrix.md` for the per-crate Rust CI matrix, coverage\nenforcement, and Python suite tiers. Rust workspace and per-crate floors are\nowned only by `config\u002Fgate.toml`; the per-crate checker rejects stale headroom,\nso meaningful coverage gains raise their ratchets in the same change.\n\n## Fast debug with capsem MCP tools\n\nRead `references\u002Fmcp-debug-tools.md` for interactive VM debugging through the\ncapsem MCP server: tool table, one-shot vs iterative workflows, and common\nsession-DB queries. MCP tools are for fast targeted checks; just recipes are\nfor complete validation at major phase boundaries and before merge or release.\n\n## End-to-end validation is not optional\n\nAt the major phase boundary for changes touching guest binaries, network policy, telemetry, MCP, or VM lifecycle:\n\n1. `just exec \"capsem-doctor\"` -- verifies sandbox integrity inside the VM\n2. After telemetry\u002Flogging changes: run a real session and verify the exercised\n   protocols through the typed timeline, history, statistics, and security\n   routes. Use `check_session.py --db` only on a coherent, quiesced evidence\n   copy after its ledger worker has stopped.\n\n## When tests fail\n\nNever dismiss a test failure as \"pre-existing\" or \"unrelated.\" Every failure must be investigated. Follow the dev-debugging workflow:\n\n1. **Do not change the test to make it pass.** The test is evidence. Changing the assertion to match broken behavior destroys that evidence.\n2. **Reproduce and diagnose first.** Understand *why* it fails before writing any fix. See the dev-debugging skill for the full methodology: reproduce with a test, diagnose root cause, then fix comprehensively.\n3. **Fix the code, not the test.** If the test is genuinely wrong (not the code), explain in detail why the test's expectation is incorrect before changing it.\n\n### Measuring a gate's result\n\n**Never take the last line of a multi-part result as the result.** Two shapes of\none mistake, both of which report success while the thing measured failed:\n\n**`$?` after a pipe is the pipe's status.** `just test | tail` reports what\n`tail` did. Redirect, then read the code separately:\n\n```bash\njust test > \u002Ftmp\u002Fgate.log 2>&1; echo \"EXIT=$?\"\n```\n\n**`tail -n1` across a multi-part result returns the last part, not the whole.**\n`cargo test -p capsem-service` runs three test binaries; the last prints\n`0 passed`, so `| tail -1` reads as though the crate had no tests while 91 and\n264 passed above it. Aggregate instead of sampling:\n\n```bash\ncargo test -p capsem-service 2>&1 | grep -E \"^test result:\"   # every binary\n```\n\nBoth errors are silent and both flatter you: one turns a failed gate into a\npass, the other turns a passing crate into a phantom regression. If a command\ncan emit more than one verdict, read them all.\n\nRead the *first* real error, not the recipe cascade under it — `grep -aE \"^FAILED|^E \"` lands on the cause, while the trailing `error: Recipe ... failed` lines are only the unwind.\n\n`build_system\u002Ftests\u002Fgate\u002Ftest_exit_status_integrity.py` keeps this out of committed recipes,\nscripts, and workflows, and requires `set -o pipefail` in any bash recipe that\npipes. It cannot see an agent's ad-hoc shell — that part is on you.\n\n### Fixtures use the wrapper, never the raw variable\n\nRedirect Capsem paths with `paths::CapsemPathsGuard::redirect(root)`. It sets\n`CAPSEM_HOME`, `CAPSEM_RUN_DIR`, and `CAPSEM_ASSETS_DIR` from one root and\nrestores on drop, so a fixture cannot set one and inherit the rest.\n\nRead logs with `telemetry::read_log_tail`, including in assertions: a test that\nopens a `*.log` path directly stops exercising what the product does the moment\nthat stream rotates.\n\nBoth are enforced by `build_system\u002Ftests\u002Fgate\u002Ftest_path_and_log_wrappers_are_mandatory.py`. See\n`\u002Fdev-rust-patterns` \"One rule, one function\" for why.\n\n### Verify with the gate's environment, not a bare shell\n\n`just test` exports `CAPSEM_HOME`, `CAPSEM_RUN_DIR`, and\n`CAPSEM_BENCHMARK_OUTPUT_ROOT`. A test that reads ambient state passes in your\nshell and fails in the gate:\n\n```bash\nCAPSEM_HOME=\"$PWD\u002Fcache\u002Ftarget\u002Ftests\u002Fhome\u002F.capsem\" \\\nCAPSEM_RUN_DIR=\"$PWD\u002Fcache\u002Ftarget\u002Ftests\u002Fhome\u002F.capsem\u002Frun\" \\\n  cargo test -p \u003Ccrate>\n```\n\nA fixture that overrides `CAPSEM_HOME` must override `CAPSEM_RUN_DIR` too —\nthe run dir takes precedence over the home-derived default, so setting only the\nfirst sends production code to the ambient run directory while the fixture\nwrites into a temp one. Bisect by exporting one variable at a time; that names\nthe culprit in two runs instead of guessing.\n\n### Cache limits belong in the cache contract\n\nA number copied next to a rule drifts from it silently. Three separate gate\nfailures in one session traced to this: a coverage floor copied into a test, a\nguest kernel major copied beside its pin, and a Docker fixture restating a\nstorage assumption outside the cache policy.\n\nEach read as a broken product, and each surfaced minutes-to-an-hour into a gate rather than at the edit. Derive the value from its source, or name it once and pin config and contract together:\n\n```python\nmaximum = load_policy(ROOT).runtimes[\"docker\"].max_size_bytes\nassert registry.contract(\"docker\").max_size_bytes == maximum\n```\n\nProve it derives rather than hardcodes: change the source value and confirm the test *follows* instead of breaking.\nRead `\u002Fdev-cache` for the common cache model; tests must not recreate backend\naccounting or machine-capacity rails.\n\n## Source guards and testable design\n\nSee [source-guards-and-design.md](references\u002Fsource-guards-and-design.md) for\nplatform gating, exact guard exclusions and separating pure decisions from runtime adapters.\n",{"name":5,"description":7},"main","d357170bb677125c80cebed720e62bf47bf083ad","skills\u002Fdev-testing",26,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem","https:\u002F\u002Fgithub.com\u002Fgoogle","https:\u002F\u002Fopensource.google\u002F","Google ❤️ Open Source","2026-11-14 00:49:59",{"source":9,"skillName":5,"commands":52,"prompt":62,"zipAvailable":63},[53,56,59],{"tool":54,"command":55},"npx","npx skills add google\u002Fcapsem --skill dev-testing",{"tool":57,"command":58},"bunx","bunx skills add google\u002Fcapsem --skill dev-testing",{"tool":60,"command":61},"pnpm","pnpm dlx skills add google\u002Fcapsem --skill dev-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Fdev-testing\u002FSKILL.md",true,[65,71,75,79,83,87],{"path":66,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":70},"references\u002Flocal-ci-parity.md","REFERENCE","参考文档",12252,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Fdev-testing\u002Freferences\u002Flocal-ci-parity.md",{"path":72,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fmcp-debug-tools.md",3373,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Fdev-testing\u002Freferences\u002Fmcp-debug-tools.md",{"path":76,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fnative-gateway-fixtures.md",809,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Fdev-testing\u002Freferences\u002Fnative-gateway-fixtures.md",{"path":80,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fparallel-lifecycle-tests.md",4699,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Fdev-testing\u002Freferences\u002Fparallel-lifecycle-tests.md",{"path":84,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Fsource-guards-and-design.md",1245,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Fdev-testing\u002Freferences\u002Fsource-guards-and-design.md",{"path":88,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":89,"sourceHtmlUrl":90},"references\u002Ftest-matrix.md",6225,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Fdev-testing\u002Freferences\u002Ftest-matrix.md",[92,109,125,142,155,167],{"skillNo":93,"name":94,"nameZh":95,"description":96,"descriptionZh":97,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":98,"categories":99,"keywords":106,"publishedAt":37},"01M699558T2T4DJMBN08ZCQ79K","use-capsem","Capsem 虚拟机任务执行","Run tasks in Capsem VMs through MCP. Use when an agent needs isolated execution, file analysis, or reports returned to the host.","通过 MCP 在 Capsem 虚拟机中运行任务。在智能体需要隔离执行、文件分析，或将报告返回到主机时使用。","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Fuse-capsem\u002FSKILL.md",[100,103],{"categoryNo":101,"categoryName":102,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BRN0DBCRG4XGJMB6QQEP11","编码任务委派",{"categoryNo":104,"categoryName":105,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BRZZF9D7PVFN5MXSPWWD61","AI 工程师",[107,108],"use capsem","MCP",{"skillNo":110,"name":111,"nameZh":112,"description":113,"descriptionZh":114,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":115,"categories":116,"keywords":123,"publishedAt":37},"01M69953Z1CSVQ4N07QX529CZY","site-marketing","营销网站内容维护","The marketing website, capsem.org. Use when editing copy, adding sections, or changing the site theme.","营销网站 capsem.org。在编辑文案、添加板块或更改网站主题时使用。","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Fsite-marketing\u002FSKILL.md",[117,120],{"categoryNo":118,"categoryName":119,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQGD6C0J544QTJ9R38Z7ZG","营销专员",{"categoryNo":121,"categoryName":122,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQV98WRP4APE9VKKKKJ6FV","社交媒体与内容平台管理",[124],"site marketing",{"skillNo":126,"name":127,"nameZh":128,"description":129,"descriptionZh":130,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":131,"categories":132,"keywords":139,"publishedAt":37},"01M69952B33KBBV37N8QTC4191","site-infra","文档站基础设施维护","The documentation site, docs.capsem.org. Use for user-directed Diátaxis documentation and Astro Starlight changes.","文档站点 docs.capsem.org。用于面向用户的 Diátaxis 文档和 Astro Starlight 相关更改。","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Fsite-infra\u002FSKILL.md",[133,136],{"categoryNo":134,"categoryName":135,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQ6TK1MPB82068236GSXDE","文档处理",{"categoryNo":137,"categoryName":138,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师",[140,141],"site infra","docs",{"skillNo":143,"name":144,"nameZh":145,"description":17,"descriptionZh":146,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":147,"categories":148,"keywords":153,"publishedAt":37},"01M69950YKCZKCDB98JDQNBBRJ","site-architecture","站点架构设计","","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Fsite-architecture\u002FSKILL.md",[149,152],{"categoryNo":150,"categoryName":151,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQ6TKQDF2K4KQS863Q79P4","开发参考",{"categoryNo":137,"categoryName":138,"taxonomyType":23,"taxonomyTypeDesc":24},[154],"site architecture",{"skillNo":156,"name":157,"nameZh":158,"description":17,"descriptionZh":146,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":159,"categories":160,"keywords":165,"publishedAt":37},"01M6994Z61JWZ0G2YRJTWFH933","release-process","版本发布流程","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Frelease-process\u002FSKILL.md",[161,162],{"categoryNo":137,"categoryName":138,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":163,"categoryName":164,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQNXPY1AV6BSR5VKHDMWRH","部署与发布管理",[166],"release process",{"skillNo":168,"name":169,"nameZh":170,"description":171,"descriptionZh":172,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":173,"categories":174,"keywords":179,"publishedAt":37},"01M6994XKHADM6FBTYTAPG7FYC","meta-skill-creation","智能体技能创建与优化","Create, improve, and evaluate skills. Use when writing a new skill, editing an existing one, or tuning a description for better triggering.","创建、改进和评估技能。在编写新技能、编辑现有技能或调整 description 以优化触发效果时使用。","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fcapsem\u002Fblob\u002Fmain\u002Fskills\u002Fmeta-skill-creation\u002FSKILL.md",[175,178],{"categoryNo":176,"categoryName":177,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BRN0CV1NMDZ5TEJX1GVM29","插件与技能管理",{"categoryNo":104,"categoryName":105,"taxonomyType":23,"taxonomyTypeDesc":24},[180,34],"meta skill creation"]