# pflow.xyz > Explanations you can run. LLM-written code got good in the last year, and > understanding it didn't get faster. You can only move as fast as you > comprehend what you've built. pflow turns each model into something you can > see, run and check, with proofs and provenance attached. Under the hood every > model is a Petri net, so runs replay and proofs check. > > A comprehension, in the programmer's sense, builds a thing from its > description. pflow does that for systems: describe it, and get a model you > can run, check and understand. > > The visual editor comes with an embeddable, dependency-free ES module > library for discrete simulation and continuous (ODE) analysis. All modules > are served from this origin with `Access-Control-Allow-Origin: *` — import > them directly from any ad-hoc HTML page, no build step, no npm. ODE > semantics are behaviorally identical to go-pflow (enforced by a parity > test suite). Models are JSON-LD (`@context: https://pflow.xyz/schema`): `places` and `transitions` are objects keyed by id, `arcs` is an array of `{source, target, weight}`. `initial`, `capacity`, and `weight` are vectors (one entry per token color); capacity 0 means unbounded; an explicit 0 weight component means "this color is not involved". ## Docs - [Full guide](https://pflow.xyz/llms-full.txt): model format, copy-paste recipes for solving/plotting/embedding, discrete simulation, related services - [JSON-LD schema](https://pflow.xyz/schema): the @context served as JSON-LD - [Book](https://book.pflow.xyz): Petri nets as a universal abstraction - [Composition views](https://pflow.xyz/compose.html): one composition of three Petri nets drawn in many conventions (cospans, spiders, operad, string diagrams, flat net, …); every link rule runs in the page as WebAssembly. Each view has a link (#view=&ex=); the index is https://pflow.xyz/compose.html#view=index ## Ontology The terms in `@context: https://pflow.xyz/schema` are defined formally, with their relations to the rest of the pflow ecosystem, in a public ontology. Every term here is declared there as `owl:equivalentClass` / `owl:equivalentProperty` to its `https://pflow.xyz/schema#` IRI (`Arrow` is `Arc` there). - [Ontology](https://ontology.pflow.xyz): download as Turtle, JSON-LD, N-Triples or RDF/XML; checksums and a verifier script are published with it - [SPARQL endpoint](https://ontology.pflow.xyz/sparql): read-only, SELECT / ASK / CONSTRUCT / DESCRIBE - [MCP server](https://ontology.pflow.xyz/mcp): `claude mcp add --transport http pflow-ontology https://ontology.pflow.xyz/mcp` - [Ontology llms.txt](https://ontology.pflow.xyz/llms.txt): the details for agents ## Modules - [petri-solver.js](https://pflow.xyz/petri-solver.js): mass-action ODE solver (Tsit5, adaptive) + SVGPlotter interactive charts - [petri-sim.js](https://pflow.xyz/petri-sim.js): discrete firing semantics, pure functions - [petri-colors.js](https://pflow.xyz/petri-colors.js): colored-net unfolding - [petri-view.js](https://pflow.xyz/petri-view.js): the full `` editor web component (with tabbed ODE analysis workbench) - [petri-view.css](https://pflow.xyz/petri-view.css): editor styles, light + dark themes - [petri-learn.js](https://pflow.xyz/petri-learn.js): differentiable fitting for Petri-net ODE models — forward + reverse-mode (adjoint) sensitivities, MSE/relative loss gradients, Adam / Nelder-Mead / coordinate-descent, `fitRates` convenience - [petri-ssa.js](https://pflow.xyz/petri-ssa.js): portable Gillespie SSA (discrete-stochastic simulation) — byte-exact with go-pflow, pflow-rs and pflow-jl via a fixed PRNG (SplitMix64 → xoshiro256**) and a ported log; `simulate(model, {horizon, samples, realizations, seed})` → ensemble mean/stddev/final per place - [petri-sde.js](https://pflow.xyz/petri-sde.js): chemical Langevin SDE — continuous state with the net's own intrinsic firing noise (Euler-Maruyama over the same propensities/stoichiometry `petri-ssa.js` compiles); `simulateSDE(model, {horizon, samples, realizations, seed})` → same shape as `simulate`, plus `diverged`/`reason`/`caveats` when the model gates (read arc, inhibitor, reached capacity — no continuous analogue). Not yet byte-exact cross-language the way SSA is. **Which one for which question**: `petri-solver.js` refuses (rather than silently mismodeling) a net with a read arc, inhibitor, reached capacity or guard — use `petri-ssa.js` (or `petri-sde.js`, same refusal) for those, or whenever token counts are small enough that variance is the answer, not noise around it; `petri-sde.js` sits between the two — noise, but no individual discrete events. Above arc weight 1 the three compute genuinely different rate laws, not a continuous vs. discrete version of the same one. Full rules: `docs/engine-selection.md` (vendored from go-pflow, `scripts/docs-sync.sh check`). ## MCP server `https://pflow.xyz/mcp` runs these tools on the server, on the net or composition passed in the call. It is stateless Streamable HTTP: POST JSON-RPC, no event stream. `claude mcp add --transport http pflow https://pflow.xyz/mcp`. Only `pflow_save` needs a sign-in. [Setup and every tool](https://pflow.xyz/mcp.html). - Nets: pflow_edit, pflow_info, pflow_check, pflow_validate, pflow_verify, pflow_fire, pflow_reachability, pflow_invariants, pflow_incidence, pflow_simulate, pflow_ssa, pflow_sde, pflow_what_if, pflow_rate_scan, pflow_optimize, pflow_cid, pflow_get, pflow_export, pflow_links, pflow_save, pflow_skill (a ready-to-save Claude skill: the model-check-show procedure with this tool list filled in live), pflow_artifact (an interactive page of the net, to publish as an Artifact; `net` or a stored net's `cid`; always pass `title`, a short specific name for the model (the artifact's name in the tab and gallery); engine "wasm" (default, ~50 KB and up with the net; loads the pinned @pflow-xyz/engine script from cdn.jsdelivr.net to re-analyze in the page) or "wasm-inline" (~500 KB, most clients truncate it). The page leads with what suits the net: the graph (values over time, phase plane; mass-action flow with the net's optional per-transition `rate`) for a few places and transitions or an unbounded net, the token game and verdicts for a small bounded net, verdicts and P-invariants for ~60+ nodes. Every view can be exposed from the bottom of the page, and "Explore this model" opens a dialog to edit marking, rates and arc weights, re-analyze, export and open the editor. The summary's `views.lead` says what it led with. Coloured nets are drawn in their colours via their unfolding) - Two-sided games, solved exactly by alpha-beta search over the firing rule. The net's marking is the position. Both tools need `net`, `sides` (transition-id prefix to sign, `{"x_": 1, "o_": -1}`) and `reward` (place to weight, read from the final marking from the +1 side's view, `{"win_x": 1, "win_o": -1}`); `auto`, `plan`, `nodes` and `book` are optional. Past the node budget the answer is `exact: false` with a null value. - pflow_game_value: the position's value with both sides playing perfectly - pflow_game_move: a best move and the value; the move is not played - Compositions (`PetriNetBundle`): subnets, the ports on their boundaries and typed links between them (token, data, event, guard). The bundle travels in the call and nothing is stored. - pflow_canvas: open a composition for a person to join parts by hand (an MCP App on a host that can show one; the same result as text elsewhere) - pflow_bundle_example: a composition to start from (an order queue, a worker pool and a payment saga), with its catalog and four scenarios - pflow_bundle_validate: check the subnets, then every link - pflow_bundle_candidates: the links a port could take, each with its verdict; only declared ports count here - pflow_bundle_add_link: add a link if it is legal; a refusal gives the reasons - pflow_bundle_flatten: one flat net, with maps back to the subnets - pflow_bundle_run: fire a script of members (`payment/do_charge`, the transition's own id, not the port id `do:charge`) or a scenario, and check what it expects - pflow_bundle_incidence: the flat net's incidence matrix, and whether each declared constraint is a conservation law of the composition The flat net is not a pflow.xyz net: pflow_simulate, pflow_fire and the other net tools cannot read it, so fire it with pflow_bundle_run. Give every arc an explicit weight. A failed `expect` in a run's answer is a finding about the composition, not a tool error: the example's `refund` and `charge-fails` both leave a worker out of the pool, and its `second-order` stops at a transition that cannot fire. ## Services - [Sim MCP server](https://sim.pflow.xyz/mcp): JSON-RPC tools to build, run and check models (sim_create_model, sim_scenario, sim_invariants, sim_reach, sim_verify, …) - [Server-side SVG rendering](https://pflow.xyz/api/svg): POST a model, get an SVG - [sim.pflow.xyz](https://sim.pflow.xyz/mcp): describe a process, get a model you can run and check — seeded scenarios, invariant and reachability proofs, calibration, and diagnostics that rank every knob by measured effect on the objective - [pflow-native](https://github.com/pflow-xyz/pflow-native): native desktop editor and simulator for the same models, with a CLI and an MCP server ## Optional - CDN mirrors for strict-CSP hosts that block pflow.xyz — pin a tag, `@main` is cached ~12h by jsDelivr: - [jsDelivr](https://cdn.jsdelivr.net/gh/pflow-xyz/pflow-xyz@v1.27.0/public/petri-solver.js) - npm-backed (`@pflow-xyz/pflow-xyz` on npm since 2026-08-01): `https://esm.sh/@pflow-xyz/pflow-xyz@1.27.0/petri-solver.js` or `https://unpkg.com/@pflow-xyz/pflow-xyz@1.27.0/petri-solver.js` - cdnjs (pending acceptance — needs 800+ npm downloads/month or 200 GitHub stars; placeholder, 404s until then): `https://cdnjs.cloudflare.com/ajax/libs/pflow-xyz//petri-solver.js` - **claude.ai artifacts cannot load these modules today.** Their CSP allows scripts only from `cdnjs.cloudflare.com`; pflow.xyz, jsDelivr, esm.sh, and unpkg are all refused (`Failed to fetch dynamically imported module`). Do not emit an import-with-fallback loader for artifacts — host the page elsewhere instead. Also note `file://` pages can't load ES modules at all; open local pages via `python3 -m http.server`.