[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71G169G00G7V5MZ452P6962":3,"skill-same:01M71G169G00G7V5MZ452P6962":68},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":26,"linkOnly":27,"markdownContent":28,"markdownBody":29,"frontMatter":30,"refName":32,"commitSha":33,"skillDirectory":34,"forksCount":14,"repositoryHtmlUrl":35,"repositoryHomepageUrl":6,"ownerHtmlUrl":36,"ownerBlogUrl":37,"ownerDescription":38,"updatedAt":39,"install":40,"resources":53},"01M71G169G00G7V5MZ452P6962","rust-test-standards",null,"Rust test standards enforced across all skills. Loaded by other skills, not invoked directly.","outcomeeng\u002Fplugins","outcomeeng","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F257335685?v=4","01M71FRVRF36XYR3HRSCGFHK2R","Outcome Engineering","01M71FRVS4BZG17DWANFJ7EPNY",1,"MIT","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Frust\u002Fskills\u002Frust-test-standards\u002FSKILL.md",[],[19,20,21,22,23,24,25],"standards","rust test standards","test","rust","false","read","across","2026-11-10 10:12:30",false,"---\nname: rust-test-standards\nuser-invocable: false\ndescription: >-\n  Rust test standards enforced across all skills. Loaded by other skills, not invoked directly.\nallowed-tools: Read\n---\n\n\u003Cobjective>\nThe canonical Rust test standards — filename conventions, level mapping, acceptable test doubles, native tooling, property testing, compile-fail testing, snapshot boundaries, shared fixtures, script testing, and coverage.\n\u003C\u002Fobjective>\n\n\u003Csuccess_criteria>\nRust test guidance follows this standard when:\n\n- `\u002Ftest` determines the assertion type, execution level, and exception path before implementation\n- `\u002Frust-code-standards` is loaded before this reference\n- co-located spec tests use `\u003Csubject>.\u003Cevidence>.\u003Clevel>[.\u003Crunner>].rs` or the repo-local overlay\n- executed `#[test]`\u002F`#[tokio::test]` functions own every predicate and assertion macro; harnesses and collaborators expose observations without verdict logic\n- test-file bindings introduce no data or policy — `let`\u002F`const`\u002F`static`\u002Fparameter bindings are valid only when they receive values selected by their semantic owner\n- every case and expected result passes the assertion-type provenance and oracle-independence litmus in `\u003Cpredicate_and_oracle_litmus>`\n- doubles preserve coupling to the real trait, function, protocol, or binary seam\n- property assertions run through a harness that owns `proptest` \u002F `quickcheck` runner policy and emits replay evidence\n- compile-time claims use compile-fail evidence\n- shared harnesses, generators, and fixtures live in a separate workspace-member crate as test-infrastructure production code\n- deterministic coverage measurement uses the repository's real coverage tool or records that measurement as unavailable; audit-time evidence coverage is a structural reachability judgment made by reading\n\n\u003C\u002Fsuccess_criteria>\n\n\u003Creference_note>\nThis is a reference skill. Composing Rust test skills load these standards explicitly before producing tests or judging their evidence quality. It is not a standalone workflow.\n\u003C\u002Freference_note>\n\n\u003Cportable_test_crate>\nUse `\u003Cproduct>-testing` for the workspace directory and Cargo package, and\n`\u003Cproduct>_testing` for its Rust import path. Cargo maps package hyphens to\nunderscores in crate imports. Every occurrence of these forms is a placeholder\nfor the consumer repository's product-owned test-infrastructure crate.\n\u003C\u002Fportable_test_crate>\n\n\u003Crepo_local_overlay>\nWhen another skill loads this reference inside a repository, it must also check for `spx\u002Flocal\u002Frust.md` and `spx\u002Flocal\u002Frust-tests.md` at the repository root. Read each file that exists after this reference and apply each as repo-local routing to the product's governing specs and decisions. A local overlay supplements skill behavior; it does not declare product truth.\n\u003C\u002Frepo_local_overlay>\n\n\u003Ccore_model>\nEvery co-located Rust spec test file name encodes two orthogonal dimensions: the assertion type (what kind of claim is being tested) and the execution level (what infrastructure is required to run it). The canonical pattern is:\n\n```text\nspx\u002F...\u002Ftests\u002F\u003Csubject>.\u003Cevidence>.\u003Clevel>[.\u003Crunner>].rs\n```\n\n**Evidence tokens** — the assertion type from `\u002Ftest`:\n\n| Token         | Assertion type | Meaning                                                                      |\n| ------------- | -------------- | ---------------------------------------------------------------------------- |\n| `scenario`    | Scenario       | Concrete inputs and outputs through the governed function, module, or binary |\n| `mapping`     | Mapping        | Table-driven or parameterized cases over a finite input\u002Foutput mapping       |\n| `conformance` | Conformance    | Parser, schema, protocol, CLI contract, or `trybuild` compile-time check     |\n| `property`    | Property       | Harness-owned property invariant over a generated domain                     |\n| `compliance`  | Compliance     | Violating fixture, lint harness, or rule oracle                              |\n\n**Level tokens** — the execution level, whose infrastructure `\u003Clevel_tooling>` details:\n\n| Token | Level |\n| ----- | ----- |\n| `l1`  | 1     |\n| `l2`  | 2     |\n| `l3`  | 3     |\n\n**Optional runner token** — appended after the level token when the test requires a specific async executor or test harness (e.g., `tokio`, `actix`).\n\nExamples:\n\n```text\nspx\u002F55-example.enabler\u002F21-auth.outcome\u002Ftests\u002Fsession_token.scenario.l1.rs\nspx\u002F55-example.enabler\u002F21-auth.outcome\u002Ftests\u002Fregistry_fetch.conformance.l2.rs\nspx\u002F55-example.enabler\u002F21-auth.outcome\u002Ftests\u002Flogin_flow.scenario.l3.rs\n```\n\nProduct specs or decisions may restrict which levels the product supports. Follow the repo-local Rust test overlay when it points to the governing spec or decision.\n\u003C\u002Fcore_model>\n\n\u003Clevel_tooling>\nChoose the level from execution pain and dependency availability:\n\n| Level | Infrastructure                                                                 | Typical mechanisms                                              |\n| ----- | ------------------------------------------------------------------------------ | --------------------------------------------------------------- |\n| 1     | Rust stdlib, `cargo test`, temp dirs, repo-required dev tools                  | `#[test]`, pure functions, trait seams, `tempfile`, `rstest`    |\n| 2     | Workspace binaries, local services, Docker, databases, local browser harnesses | `assert_cmd`, real adapters, `tokio::test`, `testcontainers`    |\n| 3     | External network, deployed systems, SaaS APIs, browser UI, shared environments | live API probes, browser automation, deployed CLI\u002FAPI workflows |\n\nLevel rules:\n\n- Pure computation, parsing, serialization, config loading, command building, and cheap temp-dir filesystem behavior belong at Level 1\n- Real workspace binaries, local DBs, local queues, local HTTP services, and containerized collaborators belong at Level 2\n- Remote APIs, deployed systems, SaaS collaborators, browser UI, and shared environments belong at Level 3\n- Product specs or decisions may disable Level 3 when the suite cannot safely stand up or isolate those collaborators; repo-local overlays only route skills to those declarations\n\n\u003C\u002Flevel_tooling>\n\n\u003Crouter_mapping>\nAfter `\u002Ftest` chooses the evidence and level, implement it with these Rust patterns:\n\n| Router Decision                            | Rust implementation                                                                  |\n| ------------------------------------------ | ------------------------------------------------------------------------------------ |\n| Stage 2 -> Level 1                         | `#[test]`, pure functions, `tempfile`, hand-written trait impls                      |\n| Stage 2 -> Level 2                         | `assert_cmd`, real local adapters, `tokio::test`, local services                     |\n| Stage 2 -> Level 3                         | live API probes, deployed workflow tests, browser automation, remote contract checks |\n| Stage 3A: pure computation                 | direct function tests with structural assertions                                     |\n| Stage 3B: extract pure part                | pure function at Level 1, boundary at the outer level                                |\n| Stage 5 exception 1: failure simulation    | trait impl returning deterministic errors                                            |\n| Stage 5 exception 2: interaction protocols | recorder struct capturing calls                                                      |\n| Stage 5 exception 3: time\u002Fconcurrency      | injected clock, paused runtime time, deterministic channels                          |\n| Stage 5 exception 4: safety                | recorder or no-op implementation preserving the seam                                 |\n| Stage 5 exception 5: combinatorial cost    | configurable in-memory implementation with real-shaped behavior                      |\n| Stage 5 exception 6: observability         | capture struct for spans, logs, events, or serialized output                         |\n| Stage 5 exception 7: contract probes       | local stub validated against the same contract schema                                |\n| compile-time contract                      | `trybuild`                                                                           |\n| universal invariant                        | property harness backed by `proptest` or `quickcheck`                                |\n\n\u003C\u002Frouter_mapping>\n\n\u003Cacceptable_doubles>\nRust tests preserve evidence quality when they keep coupling to the real seam.\n\nPreferred controlled implementations:\n\n- small hand-written structs implementing the same trait\n- recorder structs that capture inputs for later assertions\n- deterministic closures passed into function-based seams\n- local harness services that exercise the real protocol\n\nReject by default:\n\n- `mockall`, `faux`, or generated mocks as the primary strategy\n- spying on the function or method under test instead of exercising it\n- replacing the module under test with a fake implementation\n\nA controlled implementation or recording collaborator implements the same trait boundary as production and exposes observations only. It NEVER accepts an expected outcome, calls an assertion macro, exposes a matcher-style verdict method (`is_valid`, `succeeds`, `was_called_with`), or returns a pass\u002Ffail verdict — the linked test asserts against the observations it exposes.\n\nIf `\u002Ftest` reaches a Stage 5 exception, the double must still preserve coupling to the real interface or protocol. The exception explains why a controlled implementation is needed; it does not justify severing the seam.\n\u003C\u002Facceptable_doubles>\n\n\u003Cpredicate_and_oracle_litmus>\n\nApply every question in `\u002Ftest-evidence-standards` `\u003Ccommon_litmus_questions>`, every per-assertion-type source-and-oracle rule in its `\u003Cassertion_type_litmus>`, every mutation in its `\u003Cmutation_litmus>`, and every field of its `\u003Cassertion_design_record>`. That shared set is the complete list; the items below render the ones whose form is Rust-specific and never replace or bound it.\n\n- Invert the `assert!`\u002F`assert_eq!` expression. Only the linked `#[test]` changes; no harness, generator, or collaborator code changes.\n- Read the test function alone. Every pass\u002Ffail predicate is visible there.\n- Trace each case to the spec scenario, complete source-owned enumeration, `proptest`\u002F`quickcheck` domain, external conformance oracle, governing compliance rule, or inert whole-payload fixture.\n- Trace each expected result to an oracle outside the production table, algorithm, parser, branch logic, or collaborator verdict method under test.\n- Mutate the assertion-relevant production behavior. The test fails.\n- Read each fixture and harness. It returns observations, state, or handles — never a verdict, and never an `is_valid`, `succeeds`, `was_called_with`, or `assert_*` method.\n- Read a failure message. It reports actual against expected at the `assert_eq!` site, not `assert!(helper(...))`.\n- Ask whether the same fixture or harness could serve a test claiming the opposite about the same observation. It can when the predicate is test-owned.\n\n\u003C\u002Fpredicate_and_oracle_litmus>\n\n\u003Ctooling>\nUse the lightest Rust-native tool that preserves evidence:\n\n| Need                          | Preferred tooling                                              |\n| ----------------------------- | -------------------------------------------------------------- |\n| L1 scenario and mapping tests | `#[test]`, `assert_eq!`, `rstest` when parameterization helps  |\n| temp files or dirs            | `tempfile`                                                     |\n| async tests                   | `#[tokio::test]` or runtime-specific test macro                |\n| property testing              | harness wrapper backed by `proptest` or `quickcheck`           |\n| CLI binaries                  | `assert_cmd` to build and run the binary, `Output` to the test |\n| textual golden output         | `insta` when the output surface itself is the assertion        |\n| compile-fail or diagnostics   | `trybuild`                                                     |\n| local services or containers  | `testcontainers` or repo-native harnesses                      |\n| coverage                      | `cargo llvm-cov` when available                                |\n\nSnapshot tests are valid only when the textual or structured output surface is itself the contract. They are weak evidence for business logic that has a stronger structural assertion available.\n\u003C\u002Ftooling>\n\n\u003Ctest_data_policy>\n\n**Every value in a test has exactly one valid origin.** Run through this table for each test value before writing it.\n\n| Origin             | What it means                                                 | Where it lives                      |\n| ------------------ | ------------------------------------------------------------- | ----------------------------------- |\n| Source-owned       | The production module defines and exports the value           | Import from that module             |\n| Generator-produced | Pure code emits varied values each run                        | `\u003Cproduct>-testing\u002Fsrc\u002Fgenerators\u002F` |\n| Harness-managed    | Infrastructure mediates interaction with an external resource | `\u003Cproduct>-testing\u002Fsrc\u002Fharnesses\u002F`  |\n| Fixture files      | An inert whole payload the code under test reads by path      | `\u003Cproduct>-testing\u002Ffixtures\u002F`       |\n| Assertion-assigned | The case the assertion type fixes rather than the test author | Inline in the `#[test]` body        |\n| Descriptive inline | Human-readable text in the test name or assertion message     | Inline in the test file             |\n\nEach origin below has its own section; assertion-assigned and descriptive inline are the two exceptions and need none. An assertion-assigned case is one the assertion type places in the test itself — a scenario's exact interaction as the spec declares it, a conformance expectation from the external oracle, or the violating input a compliance rule names. Such a literal is correct in the `#[test]` body, and moving it into a production module so the test can import it gives the case a production address without a production contract. A vocabulary token inside that case — a command name, status value, or rule identifier — stays source-owned and is imported per `\u003Csource_owned_values>`; the origin covers the case, never the vocabulary the case is written in. `\u003Ctest_infrastructure_layout>` is a layout note, not an origin: it closes the section by placing harnesses, generators, and fixtures inside the infrastructure crate, with fixtures split into loader code and data.\n\n**TEST FILES OWN NO DATA OR POLICY.** A named constant in a test file that duplicates a value the production module should own means the production code needs refactoring.\n\nExecuted Rust test files are typed assertion files: the `#[test]`\u002F`#[tokio::test]` function or its callbacks own every behavioral predicate and assertion macro. A `let`, `const`, `static`, closure parameter, or macro parameter is valid when it only receives or renames an actual result, source-owned contract, generated value, harness observation, or resource handle and introduces no data or policy. A binding that chooses case data the assertion type does not assign to the test, an expected output, a runner setting, a seed, setup policy, a fixture payload, or a generator domain belongs in the `\u003Cproduct>-testing` workspace crate, source contracts, inert whole-payload fixtures, or justified eval case data. An assertion-assigned case is the exception the origin table names: it is chosen by the assertion type rather than the test author, so its binding stays in the `#[test]` body.\n\n\u003Csource_owned_values>\nALWAYS import command names, rule names, matcher tokens, status values, domain identifiers, and public constants from the owning production module. If the module does not export them yet, refactor it to export them before writing the test.\n\n```rust\n\u002F\u002F ❌ rejected: duplicates a value the production module should own\nconst PASS_STATUS: &str = \"pass\";\n\n\u002F\u002F ✅ preferred: import from the production module and assert against governed behavior\nuse product::audit::GateStatus;\nassert_eq!(run_gate(&input).status, GateStatus::Pass);\n```\n\n\u003C\u002Fsource_owned_values>\n\n\u003Cgenerator_produced_values>\nUse generators for inputs that vary per run. A generator is a pure function — it emits values, holds no state, and has no side effects.\n\n- Use generator strategies for randomized inputs consumed by the property harness\n- Write strategy factories for domain-shaped values\n\nA generated value reaches an executed test only through the property harness, which owns the seed and the replay diagnostics. Sampling a generator once inside an ordinary `#[test]` or `#[tokio::test]` produces evidence no one can reproduce: the failing value is never reported, and the next run draws a different one, so the failure disappears. A scenario at any level takes the case its assertion assigns instead, and a claim that genuinely ranges over a domain is a property assertion.\n\n```rust\n\u002F\u002F \u003Cproduct>-testing\u002Fsrc\u002Fgenerators\u002Faudit.rs\n\nfn valid_gate_statuses() -> impl Strategy\u003CValue = GateStatus> {\n    prop_oneof![\n        Just(GateStatus::Pass),\n        Just(GateStatus::Fail),\n        Just(GateStatus::Skipped),\n    ]\n}\n```\n\n\u003C\u002Fgenerator_produced_values>\n\n\u003Charness_managed_values>\nUse harnesses for tests that interact with external systems — filesystems, APIs, binaries, testcontainers. A harness manages setup and teardown; it is not self-contained.\n\n```rust\n\u002F\u002F \u003Cproduct>-testing\u002Fsrc\u002Fharnesses\u002Fproduct_tree.rs\n\npub struct TestEnv {\n    pub root: tempfile::TempDir,\n}\n\nimpl TestEnv {\n    pub fn new() -> Self {\n        TestEnv { root: tempfile::tempdir().expect(\"temp dir\") }\n    }\n}\n```\n\nConsumers depend on the workspace-member crate via `[dev-dependencies]` and import as `use \u003Cproduct>_testing::harnesses::product_tree::TestEnv;`.\n\n\u003C\u002Fharness_managed_values>\n\n\u003Cfixture_files>\nUse fixture files for real-world data the code under test would encounter: a captured JSONL from a chat session, a saved API response, a document the parser must handle. Fixture files live in the `\u003Cproduct>-testing\u002F` workspace-member crate under `\u003Cproduct>-testing\u002Ffixtures\u002F` and are read from disk by path — never compiled in or imported as modules. This is the cross-language test-infrastructure rule.\n\nStrings and numbers are never valid fixtures. A string literal representing a domain value belongs in the production module or a generator, not a static file.\n\n\u003C\u002Ffixture_files>\n\n\u003Ctest_infrastructure_layout>\nHarnesses, generators, and inert fixtures are production code. They live in the separate workspace-member crate named in `\u003Cportable_test_crate>`, declared as a `[dev-dependencies]` entry of consumers:\n\n- `\u003Cproduct>-testing\u002Fsrc\u002Fharnesses\u002F\u003Cname>.rs` — modules that mediate access to external resources.\n- `\u003Cproduct>-testing\u002Fsrc\u002Fgenerators\u002F\u003Cname>.rs` — factories producing valid inputs for proptest\u002Fquickcheck\u002Fparameterized tests.\n- `\u003Cproduct>-testing\u002Fsrc\u002Ffixtures\u002F\u003Cname>.rs` — fixture-loading code that reads inert data files by path.\n- `\u003Cproduct>-testing\u002Ffixtures\u002F` (data subdirectory) — inert input files.\n\nDo not create co-located test-infrastructure modules as homes for setup, data, generator selection, fixture loading, harness behavior, diagnostics, credentials, or source vocabulary. Those concerns belong in `\u003Cproduct>-testing\u002F` even when one test file consumes them today. Never use `tests\u002Fsupport\u002F`, `crate::test_support`, `super::tests`, or `#[cfg(test)] mod` patterns as homes for shared test infrastructure — those keep ungoverned utility code inside production crates or under `tests\u002F`.\n\n\u003C\u002Ftest_infrastructure_layout>\n\n\u003C\u002Ftest_data_policy>\n\n\u003Cscript_testing>\nChecked-in Rust script or utility binary entrypoints get thin tests:\n\n- argument parsing through the repository's canonical parser\n- dispatch into the imported orchestrator\n- exit-code mapping and observable terminal output\n\nThe orchestrator carries the main behavioral evidence. Entry files stay small and route to tested modules.\n\u003C\u002Fscript_testing>\n\n\u003Calignment_rules>\nMatch test strategy to assertion type:\n\n| Assertion Type | Rust testing shape                                                    |\n| -------------- | --------------------------------------------------------------------- |\n| Scenario       | example-based tests with concrete inputs and outputs                  |\n| Mapping        | table-driven tests or `rstest` case matrices                          |\n| Property       | property harness over generated domains with meaningful invariants    |\n| Conformance    | validator tooling, parsers, schema checks, `trybuild` if compile-time |\n| Compliance     | targeted assertions, lint harnesses, or rule oracles                  |\n\nProperty claims about parsers, serializers, math, ordering, or invariants require property-based tests unless the spec itself narrows the claim to a finite example set.\n\nCompile-time contracts such as trait bounds, derive behavior, or diagnostic guarantees require `trybuild` or equivalent compile-fail evidence.\n\u003C\u002Falignment_rules>\n\n\u003Clevel_1_patterns>\nUse Level 1 when the governed logic can run with Rust stdlib, normal developer tooling, and temporary local fixtures.\n\nPure function example:\n\n```rust\n#[test]\nfn rejects_empty_url_sets() {\n    assert!(validate_config(ConfigInput {\n        url_sets: BTreeMap::new(),\n    }).is_err());\n}\n```\n\nDependency seam example:\n\n```rust\nuse \u003Cproduct>_testing::harnesses::commands::success_runner;\n\n#[test]\nfn command_builder_reports_success() {\n    let config = product::sync::SyncConfig::new(\"origin\", product::sync::Mode::Push);\n\n    let result = sync_repo(&config, &success_runner()).unwrap();\n\n    assert!(result.success);\n}\n```\n\nTempdir example. The harness owns the temporary product and its cleanup; the fixture arrives by path; the `#[test]` calls the governed function and asserts:\n\n```rust\nuse \u003Cproduct>_testing::fixtures::configs::valid_site_config_path;\nuse \u003Cproduct>_testing::harnesses::filesystem::TempProduct;\n\n#[test]\nfn loads_yaml_from_temp_dir() {\n    let product = TempProduct::seeded_from(valid_site_config_path());\n\n    let config = load_config(product.path()).unwrap();\n\n    assert_eq!(config.base_url, product::config::DEFAULT_BASE_URL);\n}\n```\n\n\u003C\u002Flevel_1_patterns>\n\n\u003Cproperty_and_compile_time_patterns>\nUse the product property harness for universal invariants. The harness runs the domain; the invariant and its `prop_assert*` macro stay in the `#[test]` closure:\n\n```rust\nuse proptest::prop_assert_eq;\nuse \u003Cproduct>_testing::generators::configs::valid_config_strategy;\nuse \u003Cproduct>_testing::harnesses::properties::run_property;\n\n#[test]\nfn config_roundtrips() {\n    run_property(valid_config_strategy(), |config| {\n        let encoded = encode_config(&config);\n\n        prop_assert_eq!(decode_config(&encoded).unwrap(), config);\n        Ok(())\n    });\n}\n```\n\nProperty tests MUST run through a harness or wrapper that owns `proptest` \u002F `quickcheck` configuration, seed policy, case count, failure persistence, and replay diagnostics. The test file supplies the invariant and imports generated domains; it does not declare runner tuning or seed policy. On failure, output must include the seed, regression file path, or replay command needed to reproduce the generated case.\n\nThat split is exact: the harness owns everything about *how many* cases run and *which* seed produced a failure, and the `#[test]` closure owns *what makes a case pass*. A harness signature that accepts the encode and decode functions and asserts inside itself moves the invariant out of the test and fails the seam.\n\nUse `trybuild` for compile-time guarantees. This is the one shape whose `#[test]` body ends in no assertion macro, and it is a named exception rather than a delegated predicate: `pass` and `compile_fail` are themselves the assertion API for a compile-time claim, they are called in the test where a reader sees them, and the verdict comes from the compiler — an oracle outside the product — against an inert `.stderr` fixture. Inverting the claim still changes only the test, by moving a path between the two calls. A harness that wrapped both calls and reported success would be the delegation this standard rejects.\n\n```rust\n#[test]\nfn ui_contracts_hold() {\n    let cases = trybuild::TestCases::new();\n\n    cases.pass(\u003Cproduct>_testing::fixtures::ui::case_path(\"builder_accepts_typed_field\"));\n    cases.compile_fail(\u003Cproduct>_testing::fixtures::ui::case_path(\"builder_rejects_untyped_field\"));\n}\n```\n\n\u003C\u002Fproperty_and_compile_time_patterns>\n\n\u003Clevel_2_patterns>\nUse Level 2 when governed behavior needs a real binary, runtime, adapter, or local collaborator. The harness starts the binary, container, or service and hands back a handle; the `#[test]` drives the governed behavior through that handle and asserts on what it observes. Worked CLI, async-adapter, and containerized-collaborator examples are in `${CLAUDE_SKILL_DIR}\u002Freferences\u002Flevel-2.md`.\n\u003C\u002Flevel_2_patterns>\n\n\u003Clevel_3_patterns>\nUse Level 3 when governed behavior depends on a real remote collaborator, deployed environment, external network, SaaS system, browser UI, or shared runtime that cannot be replaced by a local Level 2 harness without changing the claim. The harness owns credential resolution, sandbox isolation, and cleanup; the `#[test]` owns the contract claim. Worked remote-API, sandboxed-CLI, and browser-workflow examples are in `${CLAUDE_SKILL_DIR}\u002Freferences\u002Flevel-3.md`.\n\nLevel 3 tests must declare their isolation boundary, credentials, cleanup behavior, and expected runtime. If the repository has no safe Level 3 lane, stop and surface that product decision rather than hiding the dependency behind a skipped test.\n\u003C\u002Flevel_3_patterns>\n\n\u003Ccoverage_rules>\nKeep deterministic measurement and audit-time evidence judgment distinct:\n\n- The deterministic gate prefers `cargo llvm-cov`, compares the baseline without the test against the run with the test, and reports the actual per-file or per-function delta. When tooling is unavailable, the gate records that limitation.\n- `\u002Faudit-rust-test` runs no coverage command. It reads the evidence chain and judges whether the test drives execution into the assertion-relevant source path, marking trivially total paths `saturated`.\n- A structural reachability judgment never claims a measured percentage or replaces the deterministic gate's coverage result.\n\n\u003C\u002Fcoverage_rules>\n\n\u003Cfailure_modes>\n\n**Failure 1: Placed shared generated domains under `tests\u002F`.** Claude wrote `tests\u002Fgenerators\u002Faudit.rs` because the file was only imported by tests. Why it failed: a reusable generator is test-infrastructure production code, so placing it under `tests\u002F` hides ownership and discovery behind an executed-test tree. How to avoid: put reusable Rust generators in `\u003Cproduct>-testing\u002Fsrc\u002Fgenerators\u002F` and import them through the `\u003Cproduct>_testing` dev-dependency crate.\n\n**Failure 2: Copied an owned example into an async harness.** Claude passed `user` by value into `save(user)` and then read `user.id()` and `user.email()` afterward. Why it failed: the example no longer compiled for normal non-`Copy` data and taught consumers to work around ownership rather than express the tested behavior. How to avoid: write Rust examples as executable ownership models; borrow shared generated values when later assertions still need them.\n\n**Failure 3: Taught the predicate seam in prose and broke it in every example.** Claude stated the seam correctly in `\u003Csuccess_criteria>`, `\u003Cacceptable_doubles>`, `\u003Cpredicate_and_oracle_litmus>`, and `\u003Canti_patterns>`, then wrote every worked example as a single call to an `assert_*` harness function with no assertion macro in the `#[test]` body. Why it failed: a reader copies the example, not the prose, so the shipped guidance taught the exact pattern the standard rejects — and the resulting tests pass the reader's own reading of this skill. How to avoid: read each example as the artifact it will become. Every `#[test]` body ends in an `assert!`, `assert_eq!`, `assert_ne!`, `matches!`, or `prop_assert*` the reader can see, or — for a compile-time claim alone — in the `trybuild` `pass` and `compile_fail` registrations that are themselves that claim's assertion API. A harness call that both acts and judges is the defect, whatever it is named.\n\n**Failure 4: Accepted property runner tuning in a test file.** Claude treated a local `const CASES` or seed setting as harmless test configuration. Why it failed: property seed policy, case count, persistence, and replay diagnostics belong to the harness or wrapper, while the test file owns only the invariant. How to avoid: route property assertions through the `\u003Cproduct>-testing` property harness and require reproducible failure output.\n\n\u003C\u002Ffailure_modes>\n\n\u003Canti_patterns>\nReject or rewrite these patterns:\n\n| Anti-pattern                                                                       | Why it fails                                                                                                                                 |\n| ---------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |\n| generated mocks for the main seam                                                  | severs evidence from the real interface                                                                                                      |\n| snapshots of hand-written values                                                   | proves serialization of the fixture more than governed logic                                                                                 |\n| example-only tests for property claims                                             | misses the universal claim stated by the spec                                                                                                |\n| async tests holding locks across await                                             | creates deadlocks and hides the real concurrency design                                                                                      |\n| browser tooling for non-browser code                                               | adds cost without stronger evidence                                                                                                          |\n| compile-time claims tested at runtime                                              | misses the actual contract                                                                                                                   |\n| source text read from tests                                                        | proves implementation text rather than behavior                                                                                              |\n| missing harness cleanup                                                            | leaves shared state that changes later test outcomes                                                                                         |\n| test-file bindings that choose data, expectations, configuration, or verdict rules | valid bindings receive values selected by source contracts, harnesses, generators, or fixtures, or carry the case the assertion type assigns |\n| a case value moved into a production module so the test can cite that module       | a production address is not a production contract; nothing outside the test requires the symbol                                              |\n| `.assert().success()` or a `predicates` matcher as the verdict                     | the library owns the predicate; take the `Output` and assert on it with the declared assertion API                                           |\n| a command name, subcommand, or flag written as a literal in the test               | the binary's argument vocabulary is a source contract the owning module exports                                                              |\n| predicate or assertion macro moved into a harness, generator, or collaborator      | the linked `#[test]` function owns every predicate and assertion macro                                                                       |\n| property runner tuning in a test file                                              | the property harness owns seed, case count, persistence, and replay diagnostics                                                              |\n\nDo not require `spx validation literal` for Rust tests. The literal validator is TypeScript-only. Enforce source-owned values through review and Rust test standards instead.\n\n\u003C\u002Fanti_patterns>\n\n\u003Creference_guides>\nLevels 2 and 3 carry no inline examples — their reference files are the only worked examples for those levels.\n\n- `${CLAUDE_SKILL_DIR}\u002Freferences\u002Flevel-1.md` - the trait-seam and recording-collaborator shapes beyond the inline patterns\n- `${CLAUDE_SKILL_DIR}\u002Freferences\u002Flevel-2.md` - the worked CLI binary, async adapter, and containerized collaborator examples\n- `${CLAUDE_SKILL_DIR}\u002Freferences\u002Flevel-3.md` - the worked remote API, sandboxed CLI, and browser workflow examples, with credentials, isolation, and cleanup\n\n\u003C\u002Freference_guides>\n","\u003Cobjective>\nThe canonical Rust test standards — filename conventions, level mapping, acceptable test doubles, native tooling, property testing, compile-fail testing, snapshot boundaries, shared fixtures, script testing, and coverage.\n\u003C\u002Fobjective>\n\n\u003Csuccess_criteria>\nRust test guidance follows this standard when:\n\n- `\u002Ftest` determines the assertion type, execution level, and exception path before implementation\n- `\u002Frust-code-standards` is loaded before this reference\n- co-located spec tests use `\u003Csubject>.\u003Cevidence>.\u003Clevel>[.\u003Crunner>].rs` or the repo-local overlay\n- executed `#[test]`\u002F`#[tokio::test]` functions own every predicate and assertion macro; harnesses and collaborators expose observations without verdict logic\n- test-file bindings introduce no data or policy — `let`\u002F`const`\u002F`static`\u002Fparameter bindings are valid only when they receive values selected by their semantic owner\n- every case and expected result passes the assertion-type provenance and oracle-independence litmus in `\u003Cpredicate_and_oracle_litmus>`\n- doubles preserve coupling to the real trait, function, protocol, or binary seam\n- property assertions run through a harness that owns `proptest` \u002F `quickcheck` runner policy and emits replay evidence\n- compile-time claims use compile-fail evidence\n- shared harnesses, generators, and fixtures live in a separate workspace-member crate as test-infrastructure production code\n- deterministic coverage measurement uses the repository's real coverage tool or records that measurement as unavailable; audit-time evidence coverage is a structural reachability judgment made by reading\n\n\u003C\u002Fsuccess_criteria>\n\n\u003Creference_note>\nThis is a reference skill. Composing Rust test skills load these standards explicitly before producing tests or judging their evidence quality. It is not a standalone workflow.\n\u003C\u002Freference_note>\n\n\u003Cportable_test_crate>\nUse `\u003Cproduct>-testing` for the workspace directory and Cargo package, and\n`\u003Cproduct>_testing` for its Rust import path. Cargo maps package hyphens to\nunderscores in crate imports. Every occurrence of these forms is a placeholder\nfor the consumer repository's product-owned test-infrastructure crate.\n\u003C\u002Fportable_test_crate>\n\n\u003Crepo_local_overlay>\nWhen another skill loads this reference inside a repository, it must also check for `spx\u002Flocal\u002Frust.md` and `spx\u002Flocal\u002Frust-tests.md` at the repository root. Read each file that exists after this reference and apply each as repo-local routing to the product's governing specs and decisions. A local overlay supplements skill behavior; it does not declare product truth.\n\u003C\u002Frepo_local_overlay>\n\n\u003Ccore_model>\nEvery co-located Rust spec test file name encodes two orthogonal dimensions: the assertion type (what kind of claim is being tested) and the execution level (what infrastructure is required to run it). The canonical pattern is:\n\n```text\nspx\u002F...\u002Ftests\u002F\u003Csubject>.\u003Cevidence>.\u003Clevel>[.\u003Crunner>].rs\n```\n\n**Evidence tokens** — the assertion type from `\u002Ftest`:\n\n| Token         | Assertion type | Meaning                                                                      |\n| ------------- | -------------- | ---------------------------------------------------------------------------- |\n| `scenario`    | Scenario       | Concrete inputs and outputs through the governed function, module, or binary |\n| `mapping`     | Mapping        | Table-driven or parameterized cases over a finite input\u002Foutput mapping       |\n| `conformance` | Conformance    | Parser, schema, protocol, CLI contract, or `trybuild` compile-time check     |\n| `property`    | Property       | Harness-owned property invariant over a generated domain                     |\n| `compliance`  | Compliance     | Violating fixture, lint harness, or rule oracle                              |\n\n**Level tokens** — the execution level, whose infrastructure `\u003Clevel_tooling>` details:\n\n| Token | Level |\n| ----- | ----- |\n| `l1`  | 1     |\n| `l2`  | 2     |\n| `l3`  | 3     |\n\n**Optional runner token** — appended after the level token when the test requires a specific async executor or test harness (e.g., `tokio`, `actix`).\n\nExamples:\n\n```text\nspx\u002F55-example.enabler\u002F21-auth.outcome\u002Ftests\u002Fsession_token.scenario.l1.rs\nspx\u002F55-example.enabler\u002F21-auth.outcome\u002Ftests\u002Fregistry_fetch.conformance.l2.rs\nspx\u002F55-example.enabler\u002F21-auth.outcome\u002Ftests\u002Flogin_flow.scenario.l3.rs\n```\n\nProduct specs or decisions may restrict which levels the product supports. Follow the repo-local Rust test overlay when it points to the governing spec or decision.\n\u003C\u002Fcore_model>\n\n\u003Clevel_tooling>\nChoose the level from execution pain and dependency availability:\n\n| Level | Infrastructure                                                                 | Typical mechanisms                                              |\n| ----- | ------------------------------------------------------------------------------ | --------------------------------------------------------------- |\n| 1     | Rust stdlib, `cargo test`, temp dirs, repo-required dev tools                  | `#[test]`, pure functions, trait seams, `tempfile`, `rstest`    |\n| 2     | Workspace binaries, local services, Docker, databases, local browser harnesses | `assert_cmd`, real adapters, `tokio::test`, `testcontainers`    |\n| 3     | External network, deployed systems, SaaS APIs, browser UI, shared environments | live API probes, browser automation, deployed CLI\u002FAPI workflows |\n\nLevel rules:\n\n- Pure computation, parsing, serialization, config loading, command building, and cheap temp-dir filesystem behavior belong at Level 1\n- Real workspace binaries, local DBs, local queues, local HTTP services, and containerized collaborators belong at Level 2\n- Remote APIs, deployed systems, SaaS collaborators, browser UI, and shared environments belong at Level 3\n- Product specs or decisions may disable Level 3 when the suite cannot safely stand up or isolate those collaborators; repo-local overlays only route skills to those declarations\n\n\u003C\u002Flevel_tooling>\n\n\u003Crouter_mapping>\nAfter `\u002Ftest` chooses the evidence and level, implement it with these Rust patterns:\n\n| Router Decision                            | Rust implementation                                                                  |\n| ------------------------------------------ | ------------------------------------------------------------------------------------ |\n| Stage 2 -> Level 1                         | `#[test]`, pure functions, `tempfile`, hand-written trait impls                      |\n| Stage 2 -> Level 2                         | `assert_cmd`, real local adapters, `tokio::test`, local services                     |\n| Stage 2 -> Level 3                         | live API probes, deployed workflow tests, browser automation, remote contract checks |\n| Stage 3A: pure computation                 | direct function tests with structural assertions                                     |\n| Stage 3B: extract pure part                | pure function at Level 1, boundary at the outer level                                |\n| Stage 5 exception 1: failure simulation    | trait impl returning deterministic errors                                            |\n| Stage 5 exception 2: interaction protocols | recorder struct capturing calls                                                      |\n| Stage 5 exception 3: time\u002Fconcurrency      | injected clock, paused runtime time, deterministic channels                          |\n| Stage 5 exception 4: safety                | recorder or no-op implementation preserving the seam                                 |\n| Stage 5 exception 5: combinatorial cost    | configurable in-memory implementation with real-shaped behavior                      |\n| Stage 5 exception 6: observability         | capture struct for spans, logs, events, or serialized output                         |\n| Stage 5 exception 7: contract probes       | local stub validated against the same contract schema                                |\n| compile-time contract                      | `trybuild`                                                                           |\n| universal invariant                        | property harness backed by `proptest` or `quickcheck`                                |\n\n\u003C\u002Frouter_mapping>\n\n\u003Cacceptable_doubles>\nRust tests preserve evidence quality when they keep coupling to the real seam.\n\nPreferred controlled implementations:\n\n- small hand-written structs implementing the same trait\n- recorder structs that capture inputs for later assertions\n- deterministic closures passed into function-based seams\n- local harness services that exercise the real protocol\n\nReject by default:\n\n- `mockall`, `faux`, or generated mocks as the primary strategy\n- spying on the function or method under test instead of exercising it\n- replacing the module under test with a fake implementation\n\nA controlled implementation or recording collaborator implements the same trait boundary as production and exposes observations only. It NEVER accepts an expected outcome, calls an assertion macro, exposes a matcher-style verdict method (`is_valid`, `succeeds`, `was_called_with`), or returns a pass\u002Ffail verdict — the linked test asserts against the observations it exposes.\n\nIf `\u002Ftest` reaches a Stage 5 exception, the double must still preserve coupling to the real interface or protocol. The exception explains why a controlled implementation is needed; it does not justify severing the seam.\n\u003C\u002Facceptable_doubles>\n\n\u003Cpredicate_and_oracle_litmus>\n\nApply every question in `\u002Ftest-evidence-standards` `\u003Ccommon_litmus_questions>`, every per-assertion-type source-and-oracle rule in its `\u003Cassertion_type_litmus>`, every mutation in its `\u003Cmutation_litmus>`, and every field of its `\u003Cassertion_design_record>`. That shared set is the complete list; the items below render the ones whose form is Rust-specific and never replace or bound it.\n\n- Invert the `assert!`\u002F`assert_eq!` expression. Only the linked `#[test]` changes; no harness, generator, or collaborator code changes.\n- Read the test function alone. Every pass\u002Ffail predicate is visible there.\n- Trace each case to the spec scenario, complete source-owned enumeration, `proptest`\u002F`quickcheck` domain, external conformance oracle, governing compliance rule, or inert whole-payload fixture.\n- Trace each expected result to an oracle outside the production table, algorithm, parser, branch logic, or collaborator verdict method under test.\n- Mutate the assertion-relevant production behavior. The test fails.\n- Read each fixture and harness. It returns observations, state, or handles — never a verdict, and never an `is_valid`, `succeeds`, `was_called_with`, or `assert_*` method.\n- Read a failure message. It reports actual against expected at the `assert_eq!` site, not `assert!(helper(...))`.\n- Ask whether the same fixture or harness could serve a test claiming the opposite about the same observation. It can when the predicate is test-owned.\n\n\u003C\u002Fpredicate_and_oracle_litmus>\n\n\u003Ctooling>\nUse the lightest Rust-native tool that preserves evidence:\n\n| Need                          | Preferred tooling                                              |\n| ----------------------------- | -------------------------------------------------------------- |\n| L1 scenario and mapping tests | `#[test]`, `assert_eq!`, `rstest` when parameterization helps  |\n| temp files or dirs            | `tempfile`                                                     |\n| async tests                   | `#[tokio::test]` or runtime-specific test macro                |\n| property testing              | harness wrapper backed by `proptest` or `quickcheck`           |\n| CLI binaries                  | `assert_cmd` to build and run the binary, `Output` to the test |\n| textual golden output         | `insta` when the output surface itself is the assertion        |\n| compile-fail or diagnostics   | `trybuild`                                                     |\n| local services or containers  | `testcontainers` or repo-native harnesses                      |\n| coverage                      | `cargo llvm-cov` when available                                |\n\nSnapshot tests are valid only when the textual or structured output surface is itself the contract. They are weak evidence for business logic that has a stronger structural assertion available.\n\u003C\u002Ftooling>\n\n\u003Ctest_data_policy>\n\n**Every value in a test has exactly one valid origin.** Run through this table for each test value before writing it.\n\n| Origin             | What it means                                                 | Where it lives                      |\n| ------------------ | ------------------------------------------------------------- | ----------------------------------- |\n| Source-owned       | The production module defines and exports the value           | Import from that module             |\n| Generator-produced | Pure code emits varied values each run                        | `\u003Cproduct>-testing\u002Fsrc\u002Fgenerators\u002F` |\n| Harness-managed    | Infrastructure mediates interaction with an external resource | `\u003Cproduct>-testing\u002Fsrc\u002Fharnesses\u002F`  |\n| Fixture files      | An inert whole payload the code under test reads by path      | `\u003Cproduct>-testing\u002Ffixtures\u002F`       |\n| Assertion-assigned | The case the assertion type fixes rather than the test author | Inline in the `#[test]` body        |\n| Descriptive inline | Human-readable text in the test name or assertion message     | Inline in the test file             |\n\nEach origin below has its own section; assertion-assigned and descriptive inline are the two exceptions and need none. An assertion-assigned case is one the assertion type places in the test itself — a scenario's exact interaction as the spec declares it, a conformance expectation from the external oracle, or the violating input a compliance rule names. Such a literal is correct in the `#[test]` body, and moving it into a production module so the test can import it gives the case a production address without a production contract. A vocabulary token inside that case — a command name, status value, or rule identifier — stays source-owned and is imported per `\u003Csource_owned_values>`; the origin covers the case, never the vocabulary the case is written in. `\u003Ctest_infrastructure_layout>` is a layout note, not an origin: it closes the section by placing harnesses, generators, and fixtures inside the infrastructure crate, with fixtures split into loader code and data.\n\n**TEST FILES OWN NO DATA OR POLICY.** A named constant in a test file that duplicates a value the production module should own means the production code needs refactoring.\n\nExecuted Rust test files are typed assertion files: the `#[test]`\u002F`#[tokio::test]` function or its callbacks own every behavioral predicate and assertion macro. A `let`, `const`, `static`, closure parameter, or macro parameter is valid when it only receives or renames an actual result, source-owned contract, generated value, harness observation, or resource handle and introduces no data or policy. A binding that chooses case data the assertion type does not assign to the test, an expected output, a runner setting, a seed, setup policy, a fixture payload, or a generator domain belongs in the `\u003Cproduct>-testing` workspace crate, source contracts, inert whole-payload fixtures, or justified eval case data. An assertion-assigned case is the exception the origin table names: it is chosen by the assertion type rather than the test author, so its binding stays in the `#[test]` body.\n\n\u003Csource_owned_values>\nALWAYS import command names, rule names, matcher tokens, status values, domain identifiers, and public constants from the owning production module. If the module does not export them yet, refactor it to export them before writing the test.\n\n```rust\n\u002F\u002F ❌ rejected: duplicates a value the production module should own\nconst PASS_STATUS: &str = \"pass\";\n\n\u002F\u002F ✅ preferred: import from the production module and assert against governed behavior\nuse product::audit::GateStatus;\nassert_eq!(run_gate(&input).status, GateStatus::Pass);\n```\n\n\u003C\u002Fsource_owned_values>\n\n\u003Cgenerator_produced_values>\nUse generators for inputs that vary per run. A generator is a pure function — it emits values, holds no state, and has no side effects.\n\n- Use generator strategies for randomized inputs consumed by the property harness\n- Write strategy factories for domain-shaped values\n\nA generated value reaches an executed test only through the property harness, which owns the seed and the replay diagnostics. Sampling a generator once inside an ordinary `#[test]` or `#[tokio::test]` produces evidence no one can reproduce: the failing value is never reported, and the next run draws a different one, so the failure disappears. A scenario at any level takes the case its assertion assigns instead, and a claim that genuinely ranges over a domain is a property assertion.\n\n```rust\n\u002F\u002F \u003Cproduct>-testing\u002Fsrc\u002Fgenerators\u002Faudit.rs\n\nfn valid_gate_statuses() -> impl Strategy\u003CValue = GateStatus> {\n    prop_oneof![\n        Just(GateStatus::Pass),\n        Just(GateStatus::Fail),\n        Just(GateStatus::Skipped),\n    ]\n}\n```\n\n\u003C\u002Fgenerator_produced_values>\n\n\u003Charness_managed_values>\nUse harnesses for tests that interact with external systems — filesystems, APIs, binaries, testcontainers. A harness manages setup and teardown; it is not self-contained.\n\n```rust\n\u002F\u002F \u003Cproduct>-testing\u002Fsrc\u002Fharnesses\u002Fproduct_tree.rs\n\npub struct TestEnv {\n    pub root: tempfile::TempDir,\n}\n\nimpl TestEnv {\n    pub fn new() -> Self {\n        TestEnv { root: tempfile::tempdir().expect(\"temp dir\") }\n    }\n}\n```\n\nConsumers depend on the workspace-member crate via `[dev-dependencies]` and import as `use \u003Cproduct>_testing::harnesses::product_tree::TestEnv;`.\n\n\u003C\u002Fharness_managed_values>\n\n\u003Cfixture_files>\nUse fixture files for real-world data the code under test would encounter: a captured JSONL from a chat session, a saved API response, a document the parser must handle. Fixture files live in the `\u003Cproduct>-testing\u002F` workspace-member crate under `\u003Cproduct>-testing\u002Ffixtures\u002F` and are read from disk by path — never compiled in or imported as modules. This is the cross-language test-infrastructure rule.\n\nStrings and numbers are never valid fixtures. A string literal representing a domain value belongs in the production module or a generator, not a static file.\n\n\u003C\u002Ffixture_files>\n\n\u003Ctest_infrastructure_layout>\nHarnesses, generators, and inert fixtures are production code. They live in the separate workspace-member crate named in `\u003Cportable_test_crate>`, declared as a `[dev-dependencies]` entry of consumers:\n\n- `\u003Cproduct>-testing\u002Fsrc\u002Fharnesses\u002F\u003Cname>.rs` — modules that mediate access to external resources.\n- `\u003Cproduct>-testing\u002Fsrc\u002Fgenerators\u002F\u003Cname>.rs` — factories producing valid inputs for proptest\u002Fquickcheck\u002Fparameterized tests.\n- `\u003Cproduct>-testing\u002Fsrc\u002Ffixtures\u002F\u003Cname>.rs` — fixture-loading code that reads inert data files by path.\n- `\u003Cproduct>-testing\u002Ffixtures\u002F` (data subdirectory) — inert input files.\n\nDo not create co-located test-infrastructure modules as homes for setup, data, generator selection, fixture loading, harness behavior, diagnostics, credentials, or source vocabulary. Those concerns belong in `\u003Cproduct>-testing\u002F` even when one test file consumes them today. Never use `tests\u002Fsupport\u002F`, `crate::test_support`, `super::tests`, or `#[cfg(test)] mod` patterns as homes for shared test infrastructure — those keep ungoverned utility code inside production crates or under `tests\u002F`.\n\n\u003C\u002Ftest_infrastructure_layout>\n\n\u003C\u002Ftest_data_policy>\n\n\u003Cscript_testing>\nChecked-in Rust script or utility binary entrypoints get thin tests:\n\n- argument parsing through the repository's canonical parser\n- dispatch into the imported orchestrator\n- exit-code mapping and observable terminal output\n\nThe orchestrator carries the main behavioral evidence. Entry files stay small and route to tested modules.\n\u003C\u002Fscript_testing>\n\n\u003Calignment_rules>\nMatch test strategy to assertion type:\n\n| Assertion Type | Rust testing shape                                                    |\n| -------------- | --------------------------------------------------------------------- |\n| Scenario       | example-based tests with concrete inputs and outputs                  |\n| Mapping        | table-driven tests or `rstest` case matrices                          |\n| Property       | property harness over generated domains with meaningful invariants    |\n| Conformance    | validator tooling, parsers, schema checks, `trybuild` if compile-time |\n| Compliance     | targeted assertions, lint harnesses, or rule oracles                  |\n\nProperty claims about parsers, serializers, math, ordering, or invariants require property-based tests unless the spec itself narrows the claim to a finite example set.\n\nCompile-time contracts such as trait bounds, derive behavior, or diagnostic guarantees require `trybuild` or equivalent compile-fail evidence.\n\u003C\u002Falignment_rules>\n\n\u003Clevel_1_patterns>\nUse Level 1 when the governed logic can run with Rust stdlib, normal developer tooling, and temporary local fixtures.\n\nPure function example:\n\n```rust\n#[test]\nfn rejects_empty_url_sets() {\n    assert!(validate_config(ConfigInput {\n        url_sets: BTreeMap::new(),\n    }).is_err());\n}\n```\n\nDependency seam example:\n\n```rust\nuse \u003Cproduct>_testing::harnesses::commands::success_runner;\n\n#[test]\nfn command_builder_reports_success() {\n    let config = product::sync::SyncConfig::new(\"origin\", product::sync::Mode::Push);\n\n    let result = sync_repo(&config, &success_runner()).unwrap();\n\n    assert!(result.success);\n}\n```\n\nTempdir example. The harness owns the temporary product and its cleanup; the fixture arrives by path; the `#[test]` calls the governed function and asserts:\n\n```rust\nuse \u003Cproduct>_testing::fixtures::configs::valid_site_config_path;\nuse \u003Cproduct>_testing::harnesses::filesystem::TempProduct;\n\n#[test]\nfn loads_yaml_from_temp_dir() {\n    let product = TempProduct::seeded_from(valid_site_config_path());\n\n    let config = load_config(product.path()).unwrap();\n\n    assert_eq!(config.base_url, product::config::DEFAULT_BASE_URL);\n}\n```\n\n\u003C\u002Flevel_1_patterns>\n\n\u003Cproperty_and_compile_time_patterns>\nUse the product property harness for universal invariants. The harness runs the domain; the invariant and its `prop_assert*` macro stay in the `#[test]` closure:\n\n```rust\nuse proptest::prop_assert_eq;\nuse \u003Cproduct>_testing::generators::configs::valid_config_strategy;\nuse \u003Cproduct>_testing::harnesses::properties::run_property;\n\n#[test]\nfn config_roundtrips() {\n    run_property(valid_config_strategy(), |config| {\n        let encoded = encode_config(&config);\n\n        prop_assert_eq!(decode_config(&encoded).unwrap(), config);\n        Ok(())\n    });\n}\n```\n\nProperty tests MUST run through a harness or wrapper that owns `proptest` \u002F `quickcheck` configuration, seed policy, case count, failure persistence, and replay diagnostics. The test file supplies the invariant and imports generated domains; it does not declare runner tuning or seed policy. On failure, output must include the seed, regression file path, or replay command needed to reproduce the generated case.\n\nThat split is exact: the harness owns everything about *how many* cases run and *which* seed produced a failure, and the `#[test]` closure owns *what makes a case pass*. A harness signature that accepts the encode and decode functions and asserts inside itself moves the invariant out of the test and fails the seam.\n\nUse `trybuild` for compile-time guarantees. This is the one shape whose `#[test]` body ends in no assertion macro, and it is a named exception rather than a delegated predicate: `pass` and `compile_fail` are themselves the assertion API for a compile-time claim, they are called in the test where a reader sees them, and the verdict comes from the compiler — an oracle outside the product — against an inert `.stderr` fixture. Inverting the claim still changes only the test, by moving a path between the two calls. A harness that wrapped both calls and reported success would be the delegation this standard rejects.\n\n```rust\n#[test]\nfn ui_contracts_hold() {\n    let cases = trybuild::TestCases::new();\n\n    cases.pass(\u003Cproduct>_testing::fixtures::ui::case_path(\"builder_accepts_typed_field\"));\n    cases.compile_fail(\u003Cproduct>_testing::fixtures::ui::case_path(\"builder_rejects_untyped_field\"));\n}\n```\n\n\u003C\u002Fproperty_and_compile_time_patterns>\n\n\u003Clevel_2_patterns>\nUse Level 2 when governed behavior needs a real binary, runtime, adapter, or local collaborator. The harness starts the binary, container, or service and hands back a handle; the `#[test]` drives the governed behavior through that handle and asserts on what it observes. Worked CLI, async-adapter, and containerized-collaborator examples are in `${CLAUDE_SKILL_DIR}\u002Freferences\u002Flevel-2.md`.\n\u003C\u002Flevel_2_patterns>\n\n\u003Clevel_3_patterns>\nUse Level 3 when governed behavior depends on a real remote collaborator, deployed environment, external network, SaaS system, browser UI, or shared runtime that cannot be replaced by a local Level 2 harness without changing the claim. The harness owns credential resolution, sandbox isolation, and cleanup; the `#[test]` owns the contract claim. Worked remote-API, sandboxed-CLI, and browser-workflow examples are in `${CLAUDE_SKILL_DIR}\u002Freferences\u002Flevel-3.md`.\n\nLevel 3 tests must declare their isolation boundary, credentials, cleanup behavior, and expected runtime. If the repository has no safe Level 3 lane, stop and surface that product decision rather than hiding the dependency behind a skipped test.\n\u003C\u002Flevel_3_patterns>\n\n\u003Ccoverage_rules>\nKeep deterministic measurement and audit-time evidence judgment distinct:\n\n- The deterministic gate prefers `cargo llvm-cov`, compares the baseline without the test against the run with the test, and reports the actual per-file or per-function delta. When tooling is unavailable, the gate records that limitation.\n- `\u002Faudit-rust-test` runs no coverage command. It reads the evidence chain and judges whether the test drives execution into the assertion-relevant source path, marking trivially total paths `saturated`.\n- A structural reachability judgment never claims a measured percentage or replaces the deterministic gate's coverage result.\n\n\u003C\u002Fcoverage_rules>\n\n\u003Cfailure_modes>\n\n**Failure 1: Placed shared generated domains under `tests\u002F`.** Claude wrote `tests\u002Fgenerators\u002Faudit.rs` because the file was only imported by tests. Why it failed: a reusable generator is test-infrastructure production code, so placing it under `tests\u002F` hides ownership and discovery behind an executed-test tree. How to avoid: put reusable Rust generators in `\u003Cproduct>-testing\u002Fsrc\u002Fgenerators\u002F` and import them through the `\u003Cproduct>_testing` dev-dependency crate.\n\n**Failure 2: Copied an owned example into an async harness.** Claude passed `user` by value into `save(user)` and then read `user.id()` and `user.email()` afterward. Why it failed: the example no longer compiled for normal non-`Copy` data and taught consumers to work around ownership rather than express the tested behavior. How to avoid: write Rust examples as executable ownership models; borrow shared generated values when later assertions still need them.\n\n**Failure 3: Taught the predicate seam in prose and broke it in every example.** Claude stated the seam correctly in `\u003Csuccess_criteria>`, `\u003Cacceptable_doubles>`, `\u003Cpredicate_and_oracle_litmus>`, and `\u003Canti_patterns>`, then wrote every worked example as a single call to an `assert_*` harness function with no assertion macro in the `#[test]` body. Why it failed: a reader copies the example, not the prose, so the shipped guidance taught the exact pattern the standard rejects — and the resulting tests pass the reader's own reading of this skill. How to avoid: read each example as the artifact it will become. Every `#[test]` body ends in an `assert!`, `assert_eq!`, `assert_ne!`, `matches!`, or `prop_assert*` the reader can see, or — for a compile-time claim alone — in the `trybuild` `pass` and `compile_fail` registrations that are themselves that claim's assertion API. A harness call that both acts and judges is the defect, whatever it is named.\n\n**Failure 4: Accepted property runner tuning in a test file.** Claude treated a local `const CASES` or seed setting as harmless test configuration. Why it failed: property seed policy, case count, persistence, and replay diagnostics belong to the harness or wrapper, while the test file owns only the invariant. How to avoid: route property assertions through the `\u003Cproduct>-testing` property harness and require reproducible failure output.\n\n\u003C\u002Ffailure_modes>\n\n\u003Canti_patterns>\nReject or rewrite these patterns:\n\n| Anti-pattern                                                                       | Why it fails                                                                                                                                 |\n| ---------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |\n| generated mocks for the main seam                                                  | severs evidence from the real interface                                                                                                      |\n| snapshots of hand-written values                                                   | proves serialization of the fixture more than governed logic                                                                                 |\n| example-only tests for property claims                                             | misses the universal claim stated by the spec                                                                                                |\n| async tests holding locks across await                                             | creates deadlocks and hides the real concurrency design                                                                                      |\n| browser tooling for non-browser code                                               | adds cost without stronger evidence                                                                                                          |\n| compile-time claims tested at runtime                                              | misses the actual contract                                                                                                                   |\n| source text read from tests                                                        | proves implementation text rather than behavior                                                                                              |\n| missing harness cleanup                                                            | leaves shared state that changes later test outcomes                                                                                         |\n| test-file bindings that choose data, expectations, configuration, or verdict rules | valid bindings receive values selected by source contracts, harnesses, generators, or fixtures, or carry the case the assertion type assigns |\n| a case value moved into a production module so the test can cite that module       | a production address is not a production contract; nothing outside the test requires the symbol                                              |\n| `.assert().success()` or a `predicates` matcher as the verdict                     | the library owns the predicate; take the `Output` and assert on it with the declared assertion API                                           |\n| a command name, subcommand, or flag written as a literal in the test               | the binary's argument vocabulary is a source contract the owning module exports                                                              |\n| predicate or assertion macro moved into a harness, generator, or collaborator      | the linked `#[test]` function owns every predicate and assertion macro                                                                       |\n| property runner tuning in a test file                                              | the property harness owns seed, case count, persistence, and replay diagnostics                                                              |\n\nDo not require `spx validation literal` for Rust tests. The literal validator is TypeScript-only. Enforce source-owned values through review and Rust test standards instead.\n\n\u003C\u002Fanti_patterns>\n\n\u003Creference_guides>\nLevels 2 and 3 carry no inline examples — their reference files are the only worked examples for those levels.\n\n- `${CLAUDE_SKILL_DIR}\u002Freferences\u002Flevel-1.md` - the trait-seam and recording-collaborator shapes beyond the inline patterns\n- `${CLAUDE_SKILL_DIR}\u002Freferences\u002Flevel-2.md` - the worked CLI binary, async adapter, and containerized collaborator examples\n- `${CLAUDE_SKILL_DIR}\u002Freferences\u002Flevel-3.md` - the worked remote API, sandboxed CLI, and browser workflow examples, with credentials, isolation, and cleanup\n\n\u003C\u002Freference_guides>\n",{"name":5,"description":7,"allowed-tools":31,"user-invocable":27},"Read","main","978d51c51d68c99cffb2ba48f7cad9d2f07e5738","src\u002Fplugins\u002Frust\u002Fskills\u002Frust-test-standards","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins","https:\u002F\u002Fgithub.com\u002Foutcomeeng","https:\u002F\u002Foutcome.engineering","Spec-driven development for AI-assisted engineering","2026-11-14 20:33:56",{"source":8,"skillName":5,"commands":41,"prompt":51,"zipAvailable":52},[42,45,48],{"tool":43,"command":44},"npx","npx skills add outcomeeng\u002Fplugins --skill rust-test-standards",{"tool":46,"command":47},"bunx","bunx skills add outcomeeng\u002Fplugins --skill rust-test-standards",{"tool":49,"command":50},"pnpm","pnpm dlx skills add outcomeeng\u002Fplugins --skill rust-test-standards","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Frust\u002Fskills\u002Frust-test-standards\u002FSKILL.md",true,[54,60,64],{"path":55,"resourceType":56,"resourceTypeDesc":57,"sizeBytes":58,"sourceHtmlUrl":59},"references\u002Flevel-1.md","REFERENCE","参考文档",2972,"https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Frust\u002Fskills\u002Frust-test-standards\u002Freferences\u002Flevel-1.md",{"path":61,"resourceType":56,"resourceTypeDesc":57,"sizeBytes":62,"sourceHtmlUrl":63},"references\u002Flevel-2.md",3620,"https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Frust\u002Fskills\u002Frust-test-standards\u002Freferences\u002Flevel-2.md",{"path":65,"resourceType":56,"resourceTypeDesc":57,"sizeBytes":66,"sourceHtmlUrl":67},"references\u002Flevel-3.md",4424,"https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Frust\u002Fskills\u002Frust-test-standards\u002Freferences\u002Flevel-3.md",[69,75,102,118,127,137],{"skillNo":70,"name":71,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":26},"01M71G25RZTPQG9KJ00JCHC1F7","plugin","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Ftemplates\u002Fplugin\u002FSKILL.md",[],[71],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":26},"01M71G23DCX3SV60H63HBBKQ6J","sanitize-powerpoint","ALWAYS invoke this skill when sanitizing, cleaning up, auditing, or aligning a PowerPoint (.pptx) deck — slide-master and layout structure, layout type attributes, stray fonts, non-theme colors, or layout naming. NEVER hand-edit pptx XML without this skill.","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Fwork\u002Fskills\u002Fsanitize-powerpoint\u002FSKILL.md",[],[82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101],"sanitize powerpoint","powerpoint","sanitize","fonts","type","cleaning","structure","never","attributes","theme","pptx","naming","layout","deck","up","edit","xml","master","invoke","when",{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":26},"01M71G21PQKBCDECHGVYSKPJW5","draw-excalidraw","ALWAYS invoke this skill when creating Excalidraw diagrams, visualizing workflows, architectures, or concepts. NEVER generate Excalidraw JSON without this skill.","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Fwork\u002Fskills\u002Fdraw-excalidraw\u002FSKILL.md",[],[109,110,111,112,113,89,100,114,115,101,116,117],"draw excalidraw","excalidraw","draw","diagrams","architectures","generate","workflows","concepts","json",{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":26},"01M71G1ZMNGFD37RZYM620XM2C","typescript-test-standards","TypeScript test standards enforced across all skills. Loaded by other skills, not invoked directly.","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Ftypescript\u002Fskills\u002Ftypescript-test-standards\u002FSKILL.md",[],[125,126,21,19,23,24,25],"typescript","typescript test standards",{"skillNo":128,"name":129,"nameZh":6,"description":130,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":26},"01M71G1XBH0X1VCTR7269MDGSY","typescript-code-standards","TypeScript code standards enforced across all skills. Loaded by other skills, not invoked directly.","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Ftypescript\u002Fskills\u002Ftypescript-code-standards\u002FSKILL.md",[],[125,134,135,136,19,23,24,25],"code","typescript code standards","code standards",{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":143,"publishedAt":26},"01M71G1TQ3VN45SJ75DFMJDB9W","typescript-architecture-standards","TypeScript ADR conventions enforced across architect and auditor skills. Loaded by other skills, not invoked directly.","https:\u002F\u002Fgithub.com\u002Foutcomeeng\u002Fplugins\u002Fblob\u002Fmain\u002Fsrc\u002Fplugins\u002Ftypescript\u002Fskills\u002Ftypescript-architecture-standards\u002FSKILL.md",[],[144,19,145,146,125,147,148,25,24,149,23,150],"architecture standards","typescript architecture standards","architecture","adr","architect","auditor","conventions"]