The execution plan is strict JSON. task_id is part of the plan digest and signed payload; obtain it from the approved workflow obligation. TestGuard does not approve or reduce the required test set.
{"schema_version":"testguard.execution-plan/v1","task_id":"change-42","runner":"maven","required_tests":["ExampleTest#accepts"],"timeout_seconds":300}For Cargo use runner: "cargo" and stable libtest IDs such as tests::accepts. Unknown fields, arbitrary argv/shell commands, empty/duplicate required sets and timeouts outside 1..3600 seconds are rejected.
testguard keygen --private /outside/private.key --public /outside/public.key
testguard run --project /isolated/project --plan /approved/plan.json --output /outside/new-run --executable /tools/maven/bin/mvn --execute --private-key /outside/private.key
testguard verify --project /isolated/project --plan /approved/plan.json --receipt /outside/new-run/receipt.json --public-key /outside/public.key --max-age-seconds 3600Paths must be absolute. Output must be a new directory outside the project; its parent must exist. Keys and trust anchors must be outside the candidate. Key generation is explicit and refuses overwrite. Protect private keys and pin the public key through an independent trusted channel. Omitting --private-key produces guard.unsigned-evidence/v1 with trust: untrusted; verification rejects it. A locally generated key alone does not establish organizational trust.
run executes project code only with --execute. Maven plugins, build scripts, proc macros, tests and toolchain configurations can run code with the caller's permissions. Use a reviewed isolated checkout and OS/CI sandbox; this runner is not a sandbox. MCP exposes only testguard_verify_execution (project, plan, receipt, public_key, max_age_seconds) and the existing imported-JUnit verifier. It cannot execute tests or generate keys.
Maven runs the fixed test -B -ntp goal with explicit repository/user-home paths and skip flags disabled. On Windows pass the Maven distribution's mvn.cmd and set an explicit JAVA_HOME; TestGuard starts its real Java classworlds launcher directly without a shell, binding Java, Maven launch script, bootstrap jar and configuration hashes. Launch environment MAVEN_ARGS, MAVEN_OPTS, JAVA_TOOL_OPTIONS, _JAVA_OPTIONS, and JDK_JAVA_OPTIONS are removed. Root .mvn/maven.config, jvm.config, or extensions.xml are rejected in this initial adapter. Existing reactor target/surefire-reports/TEST-*.xml are rejected before execution: prepare a clean isolated checkout rather than deleting reports from a business checkout. The adapter recursively collects fresh reports from all reactor modules, copies them into immutable run output, and uses the strict JUnit checks for counts, skipped/failed/retried/zero cases and required test IDs. Duplicate IDs across reactor modules are conservatively rejected.
Cargo runs fixed test --offline --locked -- --test-threads=1; preserve the approved Cargo.lock and prepopulate dependencies. CARGO_TARGET_DIR points outside the source checkout. The adapter reads stable libtest text, requires observed successful test IDs and successful summaries, and rejects failed/ignored mandatory execution. It does not require nightly JSON. Select an explicit trusted executable; the executable hash is recorded and rechecked, not compared against a vendor allowlist.
Source snapshots are taken immediately before and after the child process. Timeout or source/executable drift produces INDETERMINATE, nonzero/assertion/report failures produce FAIL, and only exit 0 plus observed required tests plus stable inputs can produce execution PASS. Windows timeout termination includes child processes. Signatures bind exact plan/task, canonical absolute project, snapshot, times, actual argv, program hash, required/observed tests and artifact hashes. verify also rereads current source, plan, executable, artifacts, explicit public key and maximum evidence age. Signature verification establishes integrity relative to that key; it is not merge authorization or proof that hostile project code could not forge its own stdout/reports. Source scope excludes .git, target, node_modules, .guard-build; external dependencies, all runtime environment and the full toolchain are not completely captured. Coverage, Gradle and JS adapters remain planned.
Exit 0 means successful execution or successful signed verification; inspect trust and command type. Exit 2 means completed failed/indeterminate execution; exit 4 means invalid/unsupported input or verification failure. Infrastructure/spawn/input failures never produce PASS and may have no receipt.
- Existing 29 imported-JUnit CLI/MCP regression tests remain passing.
- Real Cargo assertion failure → source repair → signed PASS → current-input verification; source drift and log tampering reject verification. Implemented in
tests/execution_cli.rs, no mocked runner. - Real Maven 3.9.9 + JDK 17, JUnit 4.13.2 / Surefire 3.5.2: assertion failure, preserved failed build directory, source repair, new run PASS and signed verification PASS. Required ID
ExampleTest#accepts, one executed case, zero skipped. Generated evidence remains outside the repository under the workspace.guard-build/testguard-real-20261016/directory; private keys are not committed.
Reproduce the real multi-module Maven test explicitly (requires Maven and JDK 17): set TESTGUARD_MAVEN to the absolute native Maven distribution launcher, JAVA_HOME to the JDK, and TEMP/TMP to the intended fixture volume, then run:
cargo test --locked --offline --test real_maven -- --ignored --nocaptureThis opt-in test was actually executed successfully: two modules a/b, failed B assertion, preserved both failed target directories, repaired B, both ATest#accepts and BTest#accepts observed, signed verification successful, stale reactor reports rejected. It took 112.30 seconds including first dependency downloads. Routine tests additionally run actual Cargo timeout and runtime source-mutation cases; both must return INDETERMINATE. Read-only MCP tests verify signed evidence and reject execute input.
Stable Cargo summaries are reconciled per suite and across all suites: passed counts must equal observed successful cases; failed, ignored, measured and filtered counts must be zero. Zero-case doc suites are allowed only alongside actual required successful cases. Reactor report imports are bounded to 4 MiB each, 64 MiB aggregate, 1000 XML reports, XML depth 16/nodes 100000 and 100000 filesystem inventory entries.