Skip to content

FE-1237: Add optional per-place token capacity - #9177

Draft
kube wants to merge 2 commits into
cf/fe-1314-run-experiment-runs-in-parallel-across-workersfrom
cf/fe-1237-place-token-capacity
Draft

FE-1237: Add optional per-place token capacity#9177
kube wants to merge 2 commits into
cf/fe-1314-run-experiment-runs-in-parallel-across-workersfrom
cf/fe-1237-place-token-capacity

Conversation

@kube

@kube kube commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

🌟 What is the purpose of this PR?

Adds an optional per-place token capacity, set from the place properties panel.

Requested for supply-chain modelling with finite storage. It also converts frames from growable to fixed-size, which the GPU backend (#9179) requires.

🔗 Related links

🚫 Blocked by

🔍 What does this change?

A transition cannot fire if firing would take an output place above its capacity. This is the standard Petri-net capacity constraint.

Detail Behaviour
Output tokens apply at the end of a frame The check counts what earlier transitions in the same frame already committed, so several transitions feeding one capped place cannot collectively overflow it
Deadlock detection uses the same check A net blocked only by full output places reports as deadlocked instead of stepping to maxTime
No capacities declared Constraint tables are empty and the hot path skips them
{ id: "p_buffer", name: "Buffer", capacity: 20 }

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • modifies an npm-publishable library and I have added a changeset file(s)

📜 Does this require a change to the docs?

The changes in this PR:

  • require changes to docs which are made as part of this PR

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

An initial marking that already exceeds a capacity is not rejected. Enablement blocks transitions; it does not repair state.

🐾 Next steps

The fixed-size frame layout (SoA, WASM linear memory) is not built here. The runtime still uses growable frames.

🛡 What tests cover this?

engine/capacity.test.ts (constraint tables, headroom check), monte-carlo/capacity.test.ts (end-of-frame accumulation across several transitions feeding one place, deadlock reporting).

❓ How to test this?

  1. Select a place, switch on Token capacity, set a small value.
  2. Run the simulation. Transitions feeding that place stop firing at the cap, and the run reports as deadlocked once nothing else can fire.

@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview Aug 15, 2026 12:59am
petrinaut Ready Ready Preview Aug 15, 2026 12:59am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Aug 15, 2026 12:59am

kube added 2 commits August 15, 2026 02:50
A place can declare a maximum token count, which participates in
transition enablement the standard way: a transition cannot fire if it
would take an output place above capacity. Output tokens apply at the
end of a frame, so the check folds in what earlier transitions this
frame already committed.

Deadlock detection uses the same check, so a net blocked only by full
output places is reported as deadlocked rather than stepping to
maxTime doing nothing. Nets without capacities keep empty constraint
tables and skip the check.
Replaces em dashes with full stops. No content change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

1 participant