Skip to content

trace: enumerate Traces(P) — correctness path + differential tests (#60) - #69

Merged
0xErgod merged 2 commits into
masterfrom
trace/60-enumerate
Jul 5, 2026
Merged

0xErgod merged 2 commits into
masterfrom
trace/60-enumerate

Conversation

@0xErgod

@0xErgod 0xErgod commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Phase 3 — the first user-visible milestone. Builds on #58 (stepper) and #59 (Trace).

What

traces(start, max_events, max_traces) -> (Vec<Trace>, bool) in crates/stratum-lts/src/trace.rs.

  • DFS over instrumented states following every enabled event (all interleavings, all branches); each maximal run → Trace::from_run; dedup on Trace::key().
  • Interleavings collapse for free: two orderings of independent events fire the same event set → same key → one trace. Genuine branches (a race, a different receiver) fire different events → distinct traces.
  • This is the correctness path (materializes the n! interleavings, then dedups — cheap-to-reason, optimized in trace: persistent-set optimization (trace-faithful enumeration) #64). Bounds: max_events per run, max_traces on the result; the boolean flags truncation as Lts::is_truncated does.

Differential guarantees (the trust-earning tests)

  • unfolding_round_trip_matches_full_lts — for a causal chain concurrent with an independent reaction, ⋃ linearizations over traces(P) equals, as label sequences, the set of maximal runs of the full Lts::explore(P). This mechanizes the "no truth hidden" theorem: the trace-set is a lossless compression of the interleaving LTS.
  • interleaving_absorbed_branching_kept — diamond → 1 trace (2 linearizations); chain → 1 trace (1 linearization); race → 2 traces.
  • terminal_start_is_one_empty_trace.

Also in this PR

  • Test-fixture fix (important): *⌜P⌝ ≡ P canonically, so the old ch() drop/quote nesting collapsed every channel to ⌜0⌝ — the phase-1/2 tests passed only because they never asserted channel-distinctness. Rebuilt ch() to nest a non-reducing lift, giving genuinely ≡N-distinct channels (touches event.rs + trace.rs test modules only). The diamond test is what surfaced this.
  • Exposes event.rs initial_state / Tagged as pub(crate) for the enumerator.

fmt / clippy -D warnings / cargo test --workspace green locally.

Closes #60

0xErgod and others added 2 commits July 5, 2026 02:00
Phase 3. `traces()` explores every branch of the reduction, turns each
maximal run into a `Trace`, and dedups on the set-of-events key: independent
interleavings share a key and collapse to one, genuine branches stay
distinct.

Differential guarantees (mechanized):
- unfolding round-trip: ⋃ linearizations over traces(P) equals the set of
  maximal label-runs of the full `Lts::explore(P)` — nothing hidden.
- interleaving absorbed / branching kept: diamond = 1 trace (2 linearizations),
  chain = 1 trace (1), race = 2 traces; terminal start = 1 empty trace.

Also fixes the test channel helper: `*⌜P⌝ ≡ P` collapses a drop/quote
nesting to `⌜0⌝`, so the previous `ch()` produced `≡N`-equal channels; nest
a non-reducing lift instead for genuinely distinct names. (The earlier
phase-1/2 tests still passed because they never asserted channel
distinctness — this makes them test what they claim.)

Exposes `event.rs` `initial_state`/`Tagged` as `pub(crate)` for the enumerator.

Refs #60

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Replace the stale `ch()` doc that still claimed the drop/quote nesting was
  pairwise ≢N (it canonically collapses to ⌜0⌝); document the lift nesting.
- Note `dfs` recursion depth is bounded by `max_events`.
- Note the `lts_label_runs` test helper assumes an acyclic LTS.

Refs #60

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@0xErgod
0xErgod merged commit 66a9303 into master Jul 5, 2026
3 checks passed
@0xErgod
0xErgod deleted the trace/60-enumerate branch July 5, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

trace: enumerate Traces(P) — correctness path + differential tests

1 participant