# Test Infrastructure & Behavioral Specs (https://jackin.tailrocks.com/roadmap/test-infra-behavioral-specs/)



**Status**: Partially implemented — `insta` snapshot testing and `cargo-fuzz` (for `jackin-term`, scheduled nightly) are in use; a shared `jackin-test-support` crate, mega-test-file splits, behavioral specs for the capsule daemon and operator console, and `proptest`/fuzz coverage for parser surfaces all remain open

## Shipped facts [#shipped-facts]

Behavioral specs already exist for two components: `runtime/launch.rs` (published at [runtime/launch.rs Behavioral Spec](/reference/developer-reference/specs/runtime-launch/), tracked at [Behavioral spec: runtime/launch.rs](/roadmap/behavioral-spec-runtime-launch/)) and the console `op_picker` (published at [op\_picker Behavioral Spec](/reference/developer-reference/specs/op-picker/)), plus a related but differently-scoped spec for alternate agent credential/config folder sync ([Auth Source-Folder Sync](/reference/developer-reference/specs/auth-source-folder-sync/)).
`insta` is already a dev-dependency in `jackin-image`, `jackin-console`, `jackin`, `jackin-runtime`, and `jackin-capsule`, though not yet standardized through a shared harness.
`cargo-fuzz` exists for `jackin-term` (the `damage_grid_process` target) and runs nightly via <RepoFile path=".github/workflows/hygiene.yml">.github/workflows/hygiene.yml</RepoFile>; no parser crate has an equivalent target, and `proptest` is not in the dependency graph at all.
<RepoFile path="crates/jackin/tests/manager_flow.rs">crates/jackin/tests/manager\_flow\.rs</RepoFile> (1,528 lines) and <RepoFile path="crates/jackin/tests/dind_e2e.rs">crates/jackin/tests/dind\_e2e.rs</RepoFile> (1,669 lines) remain large, and test helpers (mock runners, config builders, workspace builders) are still duplicated across multiple test files rather than consolidated into a shared crate.

## Remaining work [#remaining-work]

1. Extract a `crates/jackin-test-support/` dev-dependency crate consolidating the duplicated mock runners, config/workspace builders, and role-seeding helpers scattered across test files; no such crate exists yet.
2. Split `tests/manager_flow.rs` and `tests/dind_e2e.rs` into smaller per-scenario files, after the helper extraction (companion to each source-file split in the codebase readability program).
3. Standardize `insta` snapshot/golden-file usage through the test-support crate (shared determinism harness: fixed size/theme/clock, redaction).
4. Write a behavioral spec for the capsule daemon (<RepoFile path="crates/jackin-capsule/src/daemon.rs">crates/jackin-capsule/src/daemon.rs</RepoFile>) — PID 1 contract, single-attach-client invariant, session lifecycle, PTY mutex poison recovery, sessions persistence and reattach.
5. Write a behavioral spec for the operator console TUI state machine (workspace to role to agent selection, instance lifecycle, keybinding dispatch, dialog stack).
6. Add `proptest` invariant tests and `cargo-fuzz` targets for parser surfaces: <RepoFile path="crates/jackin-manifest/src/validate.rs">crates/jackin-manifest/src/validate.rs</RepoFile>, <RepoFile path="crates/jackin-env/src/env_resolver.rs">crates/jackin-env/src/env\_resolver.rs</RepoFile>, and the migration chains (<RepoFile path="crates/jackin-config/src/migrations.rs">crates/jackin-config/src/migrations.rs</RepoFile>, <RepoFile path="crates/jackin-manifest/src/migrations.rs">crates/jackin-manifest/src/migrations.rs</RepoFile>); extend the existing nightly fuzz schedule to cover the new targets.

## Related work [#related-work]

* Research: [Test infrastructure: shared test-support crate, behavioral specs, and parser fuzzing](/reference/research/testing/test-infrastructure-consolidation/) — design rationale, phasing, and open questions for this item
* [Visual snapshot testing (CLI & TUI)](/reference/research/testing/visual-snapshots/visual-snapshot-testing/) — SVG golden-artifact format that would build on the shared test-support crate
* [Rust CI tooling & dependency hygiene](/reference/research/ci/rust-tooling/rust-ci-tooling/) — `cargo insta` for snapshot tests, `cargo-llvm-cov` for coverage
* [Behavioral spec: runtime/launch.rs](/roadmap/behavioral-spec-runtime-launch/) — existing spec item this extends to other components
* [Codebase map](/reference/getting-oriented/codebase-map/) — workspace crate structure the behavioral specs will cover
