1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
//! # wasm4pm-compat
//!
//! A **nightly-only, paper-complete, structure-only** Rust process-evidence
//! standard.
//!
//! > **Start with compatibility. Graduate to execution.**
//!
//! ## Nightly requirement
//!
//! This crate **requires nightly Rust** unconditionally. The `rust-toolchain.toml`
//! pins the toolchain to nightly. The following features are declared at the
//! crate root with no cfg gate:
//!
//! - `generic_const_exprs` — law machinery and `WfNetConst<SOUNDNESS>`
//! - `adt_const_params` — `ConditionCell<BITS>`, `Between01<NUM,DEN>`, and
//! `Metric<KIND,NUM,DEN>`
//! - `const_trait_impl` — compile-time trait dispatch in law surfaces
//! - `min_specialization` — type-law narrowing in `nightly_foundry`
//! - `portable_simd` — SIMD-width type-law surface in `nightly_foundry`
//!
//! There is no stable build target and no MSRV. Applications must conform
//! *upward* to the type law, not the other way around.
//!
//! ## What this crate IS
//!
//! - A *structure-only* standard: the **shape** of process evidence and the
//! **laws** of admission, refusal, and lossy projection.
//! - A boundary layer: external formats are admitted into typed compat values,
//! then exported back out (or graduated to `wasm4pm`) — never laundered
//! raw-to-raw.
//! - A place where **refusal is first-class**: every serious surface refuses
//! with a *specific named law* (e.g. `DanglingEventObjectLink`,
//! `MissingFinalMarking`, `UnsoundWfNet`), never a bare `InvalidInput`.
//! - Built from **small, transparent, strongly-named types**: `PhantomData`
//! witness/state markers and zero-cost `#[repr(transparent)]` ID wrappers.
//!
//! ## What this crate is NOT
//!
//! - **Not** a lite version of `wasm4pm`. It contains **no engines**: no
//! discovery, no conformance checking, no replay, no alignment, no
//! optimization, no visualization.
//! - **Not** a data-laundering tool. Lossy projection always requires a named
//! projection, a [`crate::loss::LossPolicy`], a [`crate::loss::LossReport`], and a refusal
//! path.
//!
//! ## The one-way door
//!
//! The central invariant is a typed, one-way lifecycle enforced by the type system:
//!
//! ```text
//! Raw ──parse──▶ Parsed ──admit──▶ Admitted ──▶ {Projected | Exportable | Receipted}
//! │ ▲
//! └────────────── refuse ────────────┴──▶ Refused (terminal; carries a named law)
//! ```
//!
//! [Evidence<T, State, W>](crate::evidence::Evidence) is the universal carrier. `State` and `W`
//! are zero-sized `PhantomData` tags — zero runtime cost. `Evidence<T, Raw, W>` and
//! `Evidence<T, Admitted, W>` are **different types**. A function demanding admitted
//! evidence cannot be called with raw evidence. The `Admitted` constructor is
//! `pub(crate)` — the **only** public path to admitted evidence is
//! [`crate::admission::Admit::admit`].
//!
//! ## Feature model
//!
//! The public feature surface is **exactly three**. They control *capability
//! stages*, not *canon knowledge* — the base profile already knows every shape.
//!
//! | Feature | Default | Meaning |
//! |------------|:-------:|----------------------------------------------------------------|
//! | `formats` | yes | import/export contracts, round-trip claims, loss surfaces |
//! | `strict` | no | opt-in boundary judgment: strict admission/refusal surfaces |
//! | `wasm4pm` | no | graduation bridge traits toward the `wasm4pm` execution engine |
//!
//! There are **no per-format flags** (no `ocel`/`xes`/`bpmn`/…). Nightly is
//! **not** a Cargo feature: the crate requires nightly unconditionally.
//! `nightly_foundry.rs` is a staging module that is always on.
//!
//! ## Test surfaces
//!
//! Three distinct surfaces with different purposes and cadences:
//!
//! - **Fast loop** — `cargo test --all-features --tests`: unit and integration
//! tests; sub-second after the initial build. Run on every change.
//! - **ALIVE gate** — `cargo test --test ui_tests -- --ignored`: trybuild
//! compile-fail and compile-pass fixtures that certify the type law. Explicit
//! opt-in; ~4 min cold. A compile-fail fixture failing for the *wrong* reason
//! is not a valid type-law receipt.
//! - **Documentation audit** — `cargo test --doc --all-features`: verifies
//! every public doctest compiles. Explicit opt-in; slow on nightly (each
//! doctest touching nightly features is a separate `rustc` invocation).
//!
//! Doctests are **disabled** in the default test run (`doctest = false` in
//! `Cargo.toml`) to keep the dev loop fast.
//!
//! ## Adoption example
//!
//! Build the core event-log shape via the [`crate::prelude`]:
//!
//! ```ignore
//! use wasm4pm_compat::prelude::*;
//!
//! // Build a single event, fold it into a trace, and a trace into a log.
//! let event = Event::new("place_order");
//! let trace = Trace::from_events([event]);
//! let log = EventLog::from_traces([trace]);
//! assert_eq!(log.trace_count(), 1);
//! ```
//!
//! The full `Raw → Admitted` path:
//!
//! ```ignore
//! use wasm4pm_compat::admission::{Admit, Admission, Refusal};
//! use wasm4pm_compat::evidence::Evidence;
//! use wasm4pm_compat::state::Raw;
//! use wasm4pm_compat::witness::Ocel20;
//!
//! enum LinkedOcel {}
//!
//! impl Admit for LinkedOcel {
//! type Raw = bool;
//! type Admitted = bool;
//! type Reason = &'static str;
//! type Witness = Ocel20;
//! fn admit(raw: Evidence<bool, Raw, Ocel20>)
//! -> Result<Admission<bool, Ocel20>, Refusal<&'static str, Ocel20>>
//! {
//! if raw.value { Ok(Admission::new(true)) }
//! else { Err(Refusal::new("DanglingEventObjectLink")) }
//! }
//! }
//!
//! let admitted = LinkedOcel::admit(Evidence::raw(true)).unwrap().into_evidence();
//! let exportable = admitted.into_exportable();
//! assert_eq!(exportable.value, true);
//! ```
//!
//! Examples are `ignore`d here; see the `examples/` directory for runnable
//! walkthroughs of each capability stage.
//!
//! ## Graduation path
//!
//! When you need to *run* something — discover a model, check conformance, replay a
//! log — you graduate. With the `wasm4pm` feature, bridge traits hand your typed
//! compat evidence to the execution engine. The compat crate stays structure-only;
//! the engine does the work.
// ── Nightly features — unconditional (nightly toolchain required) ────────────
// ── Always-on: the canon of process-evidence structure ──────────────────────
/// Admission and refusal: the first-class boundary verdict surface.
/// BPMN model shape.
/// Causal net structural shapes (Heuristics Miner output — Weijters & Ribeiro 2011).
/// Causal consistency law: CausalChain, CausalLink, CausalConsistency, CausallyOrderedEvidence.
/// Conformance verdict shape (structure only — no checking engine).
/// Cross-log correlation law: CorrelationKey, CorrelatedLog, CorrelationSchema shapes.
/// Declare constraint shape.
/// Directly-follows graph (DFG) shape.
/// Diagnostic shapes for explaining admission and refusal.
/// Event, trace, and event-log shapes.
/// Receipt-shaped evidence values (structure only).
/// Zero-cost `#[repr(transparent)]` identifier wrappers.
/// Interop traits: import, export, round-trip claim plumbing.
/// Compile-time law kernel: `ConstParamTy` enums, bounds machinery, `ConditionCell`, `Between01`.
/// Loss policy, loss report, and named projection law.
/// Multi-perspective process evidence: ControlFlow/Data/Resource/Time perspective markers.
/// Object lifecycle law: typed phase markers and lawful phase transitions.
/// Object-centric event log (OCEL) shape.
/// Object-centric process query (OCPQ) shape.
/// Petri net shape.
/// POWL (partially ordered workflow language) shape.
/// POWL8 operator discriminant — compact `u8` wire-format companion to [`crate::powl::PowlNodeKind`].
/// Prediction problem shape (structure only — no predictor).
/// Core adoption surface — re-exports the most-needed shapes and laws.
/// Process cube dimensional structure (van der Aalst 2013 — multi-perspective comparison).
/// Process tree shape.
/// Receipt shape: provenance-bearing evidence envelope.
/// Typestate tokens: `Raw`, `Parsed`, `Admitted`, `Refused`, `Projected`, …
/// Streaming evidence context law: online vs. offline collection markers and EventWindow.
/// Temporal ordering and profile law surfaces.
/// Witness markers and witness families (type-level proof carriers).
/// Compiled witness marker declarations — one entry per WitnessMarker in the ontology.
/// Generated by `ggen sync --rule witness-markers`; maintained via TTL + ggen, not by hand.
/// Typestate-based parallel workflow tracking.
/// XES interchange shape.
// ── Feature-gated: capability stages ────────────────────────────────────────
/// Graduation bridge traits toward the `wasm4pm` execution engine.
/// Import/export contracts, round-trip claims, and loss surfaces.
/// Opt-in boundary judgment: strict admission/refusal declaration surfaces.
// ── Test helper builders (test-only) ────────────────────────────────────────
/// Test helper builders for common law-compliant constructions.
///
/// Available only under `#[cfg(test)]`. Provides zero-boilerplate constructors
/// for shapes most frequently needed in unit and integration tests.
// ── Nightly foundry — always-on staging area for paper-derived law surfaces ──
/// Nightly foundry: zero-cost type-law surfaces from process-mining papers.
///
/// Contains `petri_law`, `powl_law`, `evidence_law`, and `token_law` —
/// four surfaces that use `generic_const_exprs`, `adt_const_params`,
/// `min_specialization`, and `portable_simd` respectively. This is an
/// experimental staging module; the main type law lives in [`crate::law`], [`crate::petri`],
/// [`crate::conformance`], [`crate::process_tree`], [`crate::powl`], [`crate::formats`], and [`crate::strict`].
// ── Flat re-exports: most-used types available at the crate root ─────────────
//
// These re-exports let users write `wasm4pm_compat::EventId` instead of
// `wasm4pm_compat::ids::EventId`. They do not replace the submodule paths.
pub use crate;
pub use crate;
pub use crate;
pub use crateEvidence;
pub use crate;
pub use crate;
pub use crateOcelLog;
pub use crate;
pub use crate;
pub use crateBlake3Hash;
pub use crateProvenanceChain;
pub use crateReceiptEnvelope;
pub use crate;
pub use crate;
pub use crate;
pub use crateXesLog;