ADR-0309:
Automatic ActionApp Property & Fuzz Explorer
(app_test &
tenon test --explore)
- Status: Accepted
- Date: 2026-11-28
- Scope:
plugins/app_test/,crates/tenon/src/app_test/
Context
Hand-written unit tests for ActionApp
implementations rarely cover the combinatorial state-space bugs
that emerge in real agentic and interactive sessions: unredacted
secret leaks triggered only after specific state transitions,
destructive actions that lose requires_approval: true
in alternate modes, dry_run previews that diverge
from execute, malformed RFC-6901
state_delta patches, corrupted
undo()/rollback_to_rev history, and TUI
layout/contrast regressions on narrow or wide viewports.
Following ADR-0291 ("Freeze Rust, Grow in Tenon"), we want a
pure, deterministic, zero-capability Tenon plugin
(plugins/app_test/) that automatically explores any
ActionApp (and optional tui.runtime.App)
directly from its live ActionSpec.input_schema_json,
verifies 7 universal oracles on every transition with zero
user-written assertions, and shrinks any failing trace into a
minimal copy-pasteable .tn regression test, paired
with thin tenon test --explore CLI support.
Decision
New Pure Library Plugin
plugins/app_test/(capabilities = [])- Depends strictly on
json,app_actions,state_delta,tui, andtui_lint. - Deterministic Seeded PRNG & Schema Synthesizer
(
explore.tn):- Implements an overflow-free Park-Miller PRNG
(
Rng) that produces identical sequences on both native C andtenon interp. - Synthesizes schema-valid JSON payloads directly from live
ActionSpec.input_schema_json(synthesize_args), exercising boundary values ("",minLength,maxLength,minimum,maximum,0,-1,1), Unicode/CJK/emoji strings (日本語テスト,🚀✨🎉,café naïve 界), the canary secret (sk-live-CANARY-9f8e7d6c5b4a), enums, booleans, nested arrays, and nested objects.
- Implements an overflow-free Park-Miller PRNG
(
- 7 Universal Oracles (
explore_action_app&explore_harness):- Zero Runtime Traps:
actions,project_state,state_summary,apply, and optional TUIview(80x24,48x16,160x50) execute without trapping. - Dry-Run Parity:
dry_runmatchesexecute(rev,WireUpdate,actions_changed,effects,note, and error classification) without mutating prior state. - RFC-6901 Delta Exactness:
state_delta.apply.apply_delta(prev, ops)equalsnextStateSnapshot.state, and recomputeddiff_valuesround-trips identically. - Undo / Rollback Restoration:
undo()restores the exact priorStateSnapshot.stateandrestored_from_revafter every state-mutating transition. - Canary Secret Redaction:
canary_secretnever appears unredacted inproject_state,state_summary, orStateSnapshot. - ADR-0225 Approval Enforcement: Every enabled
ActionRisk.Destructiveaction must declarerequires_approval: true, and everyrequires_approval: trueaction must fail closed (ApprovalRequired/PolicyDenied) when called without a matching presented approval token. - TUI Lint Invariants:
tui_lint.lib.audit_screenpasses across sampled viewports (80x24,48x16,160x50).
- Zero Runtime Traps:
- Delta-Debugging Trace Shrinking & Regression
Generation (
shrink_trace,format_regression_tn):- Deterministically minimizes failing traces in-memory
(
< 50 ms) via binary chunk removal followed by a 1-minimal pass, preserving the exact targetOracleKind. - Formats the minimized trace into a standalone
.tntest regression_<app>_<oracle> { ... }snippet and structured JSON report (report_to_json).
- Deterministically minimizes failing traces in-memory
(
- Depends strictly on
CLI Support in
crates/tenon/src/app_test/- Extends
tenon testwith--explore [--seeds N] [--depth N](boundedseedsin1..=10000, default32;depthin1..=256, default12; rejecting--seeds/--depthwithout--explore). - In
--exploremode, discovers and runsexplore_*unit tests (falling back to package unit tests when noexplore_*filter match exists) and reports exploration metadata (explore: seeds=N depth=Nin human output;"explore":{"seeds":N,"depth":N}in--jsonoutput) while leaving non-exploretenon testoutput byte-for-byte unchanged.
- Extends
Consequences
- Any
ActionAppgains zero-boilerplate property/fuzz testing across all 7 universal invariants with deterministic< 50 mscounterexample shrinking. - Full dual-backend parity across native C
(
tenon test) andtenon interp. - Zero changes to compiler hotspots (
main.rs,editions.rs,build.rs) and zero new Cargo dependencies.