Design decisions

27. Interpreter, debugger and traces

27.1. Runtime traps carry call stacks, multitest case numbers, and concrete values. cpl_interp::Trap records call_stack: Vec<Frame> (summarized when deeper than 32 frames to avoid allocating on runaway recursion) and case: Option<u64>, populated on the error path from a zero-allocation (&str, Span) frame stack in Interp. Division/remainder by zero and integer overflow include the concrete operands. Trap::to_diagnostic is shared by cpl-cli and cpl-wasm so native and WASM diagnostics stay identical. Reason: plan/50-debugging.md §5 requires runtime errors to explain what happened in one screen with values, call path, and test case without slowing normal execution. Reverse: remove call_stack/case from Trap, call_frames/current_case from Interp, and Trap::to_diagnostic.

27.2. Unboxed OptVal::Int / TupleVal::OneInt and zero-allocation interpreter hot paths. Value::Opt stores OptVal::{None, Int(i64), Boxed(Rc<Value>)} and Value::Tuple stores TupleVal::{OneInt(i64), Boxed(Rc<Vec<Value>>)} (promoting to Boxed only on in-place field/option mutation), keeping size_of::<Value>() unchanged while eliminating heap Rc/Vec allocations for domain steps (?Pos) and 1-field Int structs (Mod<P>). Untraced assign, 1D/2D index, 0–3-arg call_feeding, step-1 Iter::Range, and primitive Cmp avoid temporary heap Vecs and i128 loop arithmetic. Measured speedup on ports: dph 884ms -> 693ms (-22%), dpm 1288ms -> 1028ms (-20%), dpl 542ms -> 483ms (-11%), dpk 770ms -> 728ms (-5%). Remaining gap to <= 30x is tree-walking eval/stmt dispatch overhead (future bytecode VM). Reverse: revert OptVal, TupleVal, and assign_untraced in crates/cpl-interp.

27.3. Trace filtering (--trace globs/exclusions, --test, --watch, --last, --depth) and Bound(d) cut labels. TraceConfig gains test_cases, watch, last_steps (O(1) VecDeque ring buffer), and max_depth, while only_fn parses comma-separated globs (*, ?) and !pat exclusions tracked via pos_inside/neg_inside counters in Tracer. Bound(d) labels and values now shift by view.domains[d].0 to match value::show and 1-based domain semantics. Reason: plan/50-debugging.md §1 requires surgical trace capture on large/multitest runs and consistent domain-base cut labels. Reverse: remove the extra fields from TraceConfig, restore single-fn only_fn matching, and remove --test/--watch/--last/--depth from RunArgs in crates/cpl-cli/src/lib.rs.