ADR-0310:
Cross-Surface Differential Equivalence Oracle
(app_test_parity / app_test.parity)
- Status: Accepted (Wave 4, Rank 11, Idea #37)
- Date: 2026-11-28
- Depends on: ADR-0291 (Freeze Rust, Grow in
Tenon), ADR-0301 (
tui.a11y), ADR-0304 (app_surface)
Context
derive AppSurface (ADR-0304) projects a single
annotated action catalog onto multiple user and agent surfaces:
direct ActionSession, dual-era MCP JSON-RPC 2.0
(2026-07-28 and 2025-11-25), CLI
(app_surface.cli), loopback HTTP
(app_surface.http_router), and TUI palette /
tui.a11y triggers.
While each surface has its own unit tests, subtle cross-surface
drift can occur whenever a surface adapter parses flags
differently, omits expected_rev or
approval_token, misclassifies an
ActionErrorKind (e.g., returning
InvalidArgs instead of UnknownAction or
StaleRev), or serializes StateSnapshot
JSON differently. Manually writing parallel test suites for all
five surfaces does not scale and misses multi-step stateful
interactions.
Decision
Introduce a pure (capabilities = []) differential
equivalence oracle in plugins/app_test_parity/
(parity.tn, re-exported by lib.tn and
exposed under app_test.parity at the Wave 4
barrier):
- Single Abstract Trace
(
vec<ParityStep>):- Each
ParityStepencodesaction_name,args_json, optionalexpected_rev,approval_token,presented_approval_id, optional humancli_argv, optionaltui_trigger_id, and optionalpersisted_path. - The oracle executes the identical trace in parallel isolated
instances across all 5 surfaces (6 concrete protocol lanes):
direct:app_actions.session.execute+snapshot.mcp_2026_07_28:app_actions_mcp.bridge.serve_linemodern JSON-RPC 2.0 (_metaprotocol version2026-07-28,app_act+app_state).mcp_2025_11_25:app_actions_mcp.bridge.serve_linelegacy JSON-RPC 2.0 (initializehandshake +app_act+app_state).cli:app_surface.cli.dispatch_cli(actor humancli_argv+stateJSON output).http:app_surface.http_router.handle_httploopbackPOST /act+GET /state.tui:app_surface.tui_palette.build_palette+tui.a11y(A11yNodebutton resolution and unclipped visibility check) mapped toActionSession.
- Each
- Canonical Equivalence Checks:
- Byte-identical
StateSnapshotJSON: Both the underlying session snapshot and each surface's wirestatepayload (app_state, CLIstate, HTTPGET /state) are normalized withstate_delta.patch.canonicalize_valueand compared byte-for-byte against the direct reference oracle. - Identical Error Classifications: Wire errors
from JSON-RPC
isError/payload, CLI exit codes + stderr, HTTP RFC-7807problemtitles, and TUIActionSessionoutcomes are normalized toActionErrorKindnames (invalid_args,disabled_action,approval_required,stale_rev,unknown_action,policy_denied,execution_failed,circuit_broken,job_error). - Optional
VirtualFsPersisted-Bytes Comparison: Pure in-memoryVirtualFsrecords persisted state snapshots andfs.writeeffects per surface and asserts byte-identical persisted files across all surfaces without requiringfficapabilities.
- Byte-identical
- Structured Pinpointing
(
ParityReport):- Returns
ParityReportwithok,steps_executed,surfaces_checked,final_snapshot_json,final_rev,divergences, andfirst_divergence: option<ParityDivergence>pinpointing exactstep_index,action_name,surface,DivergenceKind,expected_snapshot_jsonvsactual_snapshot_json, andexpected_errorvsactual_error. - Includes deterministic fault-injection hooks
(
ParityFault) so tests can prove single-surface divergences are caught and pinpointed on both native C andtenon interp.
- Returns
Consequences
- Zero Rust changes: 100% pure
.tn(capabilities = []), obeying ADR-0291 and running identically on native C (tenon test) andtenon interp. - Fast in-memory verification: 50 deterministic
multi-step traces across all 5 surfaces execute completely
in-memory in
< 25 mson native C with zero network sockets or filesystem I/O. - No
ffidependency required: BecauseVirtualFsis implemented purely in Tenon,app_test_paritystayscapabilities = []and can be used by any pure package orapp_testsuite.