Expand description
Testbench: hermetic-execution composition primitive.
Wires the four pluggable axes Harn already had — virtual time, mocked
LLM, filesystem overlay, recorded subprocess — behind a single
Testbench handle. Production wires real impls; tests/demos pick a
config and get an audit trail of everything that crossed the host
boundary.
§Axes
-
Clock (
crate::clock_mock). Pinned wall-clock + monotonic time honored by stdlibnow_ms/sleep/monotonic_ms, the trigger dispatcher, and the cron scheduler. Tests advance withcrate::clock_mock::advanceor the script-sideadvance_time(...). -
LLM (
crate::llm). The CLI replay/record path (install_cli_llm_mocks/enable_cli_llm_mock_recording) is the workhorse; [crate::llm::FakeLlmProvider] adds streaming/error fidelity for tests that care about per-token order. -
Filesystem (
overlay_fs). Copy-on-write overlay rooted at a real worktree: reads pass through, writes land in an in-memory layer, andoverlay_fs::OverlayFs::diffsurfaces a unified-style diff that can be applied back or discarded. -
Subprocess (
process_tape). Records(program, args, cwd) → (stdout, stderr, exit, virtual Δt)tuples in record mode and replays them deterministically in replay mode. Env-var matching is documented as future work — the JSON tape carries anenvfield reserved for it.
§Network
Network egress is deny-by-default in testbench mode — outbound HTTP
and connector requests fail fast unless an explicit allowlist names
the destination. The deny pass routes through crate::egress, the
same policy engine production uses.
Modules§
- annotations
- Annotation sidecar for testbench tapes.
- fidelity
- Replay fidelity oracle.
- overlay_
fs - Copy-on-write filesystem overlay.
- process_
tape - Subprocess record/replay tape for the testbench.
- tape
- Unified event tape for the testbench.
Structs§
- Emitted
Tape - Summary metadata for a unified tape that was emitted at finalize-time.
- Testbench
- Declarative configuration for
Testbench::activate. Every axis is optional so callers can compose only the surfaces they need. - Testbench
Builder - Fluent constructor for
Testbench. - Testbench
Finalize - Outcome of a finalized testbench session — the artifacts the operator inspects after a hermetic run.
- Testbench
Session - RAII handle returned by
Testbench::activate. Holds every guard for the active axes; dropping it tears them all down in order.
Enums§
- Clock
Config - Configures the unified mock clock. Defaults to the runtime’s real clock so the testbench stays opt-in.
- Filesystem
Config - Filesystem overlay configuration.
- LlmConfig
- LLM provider configuration. Mirrors
harn run --llm-mock/--llm-mock-recordso the testbench is a strict superset of that flag pair. The testbench does not install LLM mocks itself — it stays declarative socrate::llm::install_cli_llm_mocks(or itsharn-cliwrapper) remains the single mutator of LLM state. - Network
Config - Network policy. Defaults to the production egress policy (no
override). Testbench callers usually pick
DenyByDefault. - Subprocess
Config - Subprocess record/replay configuration.
- Tape
Config - Unified-tape configuration. Recording is opt-in:
Off(the default) installs nothing and pays nothing in production;Emit { path }installs atape::TapeRecorderconsulted by every host-capability axis, then persists the result topath(pluspath.cas/for large payloads) whenTestbenchSession::finalizeruns. - Testbench
Error - Errors surfaced when activating or finalizing a testbench session.