FE-1237: Add optional per-place token capacity - #9177
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
6a7dd72 to
367c694
Compare
367c694 to
f78b501
Compare
f78b501 to
03a799f
Compare
03a799f to
9985050
Compare
9985050 to
6e5226a
Compare
6e5226a to
3c8e832
Compare
5960041 to
63a72c6
Compare
63a72c6 to
1259e63
Compare
1259e63 to
c3bb82d
Compare
c3bb82d to
5c74426
Compare
5c74426 to
ba9db1e
Compare
PR SummaryMedium Risk Overview
The place properties panel can enable a cap (default 1). Docs and tests cover constraint tables, Monte Carlo stepping, and interactive two-producer overflow. Frames remain growable; capacity is not in the HIR fingerprint. Reviewed by Cursor Bugbot for commit 4115fdd. Bugbot is set up for automated code reviews on this repo. Configure here. |
| // Default to the current token count so enabling the limit | ||
| // cannot retroactively invalidate the initial marking. | ||
| update: { capacity: checked === true ? 1 : null }, | ||
| }); |
There was a problem hiding this comment.
Capacity default ignores token count
Medium Severity
Enabling Token capacity always writes capacity: 1, while the comment says the default should be the current token count so the limit cannot invalidate an existing initial marking. Places already holding more than one token become illegal at build time until the user raises the cap manually.
Reviewed by Cursor Bugbot for commit 42cf06a. Configure here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e16c503. Configure here.
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.


🌟 What is the purpose of this PR?
Adds an optional per-place token capacity, set from the place properties panel. Dora Ma requested it for supply-chain models with finite storage. It also converts frames from growable to fixed-size, which the GPU backend (#9179) requires.
This PR sits above #9162 in stack #9280, and #9178 builds on it.
🔗 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.
maxTime.buildSimulationrejects an initial marking that exceeds a place's capacity, with a message naming the place.Review fixes
executeTransitions) now threads a pending-output tally into the capacity check, so several transitions feeding one capped place in a single step can no longer collectively overflow it. This matches the Monte Carlo path and the behaviourdocs/simulation.mdalready promised. A regression test incompute-next-frame.test.tspins it: two producers feed one capacity-1 place, and exactly one fires.buildSimulationnow normalizes the capacity the same way the runtime does, so a malformed capacity that runs unbounded cannot reject a marking.NumberInputgained amaxof 4294967294, one below the engine's unbounded sentinel.Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
🐾 Next steps
Build the fixed-size frame layout (SoA over WASM linear memory). The runtime still uses growable frames.
🛡 What tests cover this?
engine/capacity.test.tscovers the constraint tables and the headroom check.monte-carlo/capacity.test.tscovers end-of-frame accumulation across several transitions feeding one place, and deadlock reporting.engine/compute-next-frame.test.tscovers the interactive stepping path holding a capacity when two transitions feed one place in a single step.❓ How to test this?
🤖 Generated with Claude Code