FE-740: Add Read Arcs#8774
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
PR SummaryMedium Risk Overview Core: Editor: Arc properties offer Read; transition arc lists show Read/Inhibitor badges; canvas uses a dotted stroke and dot marker for read arcs. Docs and AI prompts describe read semantics and shared-state patterns. Reviewed by Cursor Bugbot for commit bf513b9. Bugbot is set up for automated code reviews on this repo. Configure here. |
🤖 Augment PR SummarySummary: Adds Read Arcs to Petrinaut SDCPNs: input arcs that require and expose tokens to transition code but do not consume them on firing. Changes:
Technical Notes: Adds targeted unit tests covering schema preservation, enablement logic, lambda/kernel inputs, and non-consuming behavior for read arcs. 🤖 Was this summary useful? React with 👍 or 👎 |
59cbd83 to
4c57aa3
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds Read Arcs to Petrinaut/SDCPN as a new input-arc type ("read") that participates in structural enablement and provides tokens to lambda/kernel input (like standard arcs), but does not consume tokens when the transition fires. This extends core simulation semantics (engine + Monte Carlo), propagates the new arc type through schemas/import/clipboard/LSP, and updates the editor UI + docs to support authoring and visualization.
Changes:
- Extend the core SDCPN model and schemas to support
InputArcType = "standard" | "read" | "inhibitor"and preserve"read"through file/clipboard formats and mutations. - Update simulation execution paths (engine + Monte Carlo) so only standard arcs remove tokens, while read arcs remain available in the same frame.
- Add UI affordances and documentation for selecting/readability/rendering of read arcs, plus tests covering semantics, import/clipboard, and LSP typing.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| libs/@hashintel/petrinaut/src/ui/views/SDCPN/reactflow-types.ts | Types UI edge data arcType from core InputArc["type"] so "read" is representable. |
| libs/@hashintel/petrinaut/src/ui/views/SDCPN/components/arc.tsx | Render read arcs with distinct dash pattern/linecap; refactor dash selection. |
| libs/@hashintel/petrinaut/src/ui/views/Editor/panels/PropertiesPanel/transition-properties/subviews/main.tsx | Pass input arc.type into arc list items so read arcs are visible in transition panel. |
| libs/@hashintel/petrinaut/src/ui/views/Editor/panels/PropertiesPanel/arc-properties/main.tsx | Allow selecting "read" in arc properties for input arcs; align types with core. |
| libs/@hashintel/petrinaut/src/ui/components/arc-item.tsx | Display a “Read”/“Inhibitor” badge for non-standard input arcs in lists. |
| libs/@hashintel/petrinaut/docs/useful-patterns.md | Add a modeling pattern section recommending read arcs for shared-state checks. |
| libs/@hashintel/petrinaut/docs/simulation.md | Document read-arc behavior during discrete transition evaluation/consumption. |
| libs/@hashintel/petrinaut/docs/README.md | Update docs index blurb to include read arcs. |
| libs/@hashintel/petrinaut/docs/petri-net-extensions.md | Define read arcs and clarify tokensByPlace inclusion/consumption semantics. |
| libs/@hashintel/petrinaut/docs/drawing-a-net.md | Update editor guidance to mention Standard/Read/Inhibitor input arc types. |
| libs/@hashintel/petrinaut/ANALYSIS.md | Add internal design/edge-case/test coverage analysis for read arcs. |
| libs/@hashintel/petrinaut-core/src/types/sdcpn.ts | Introduce InputArcType and extend InputArc.type to include "read". |
| libs/@hashintel/petrinaut-core/src/simulation/monte-carlo/transition-effect.ts | Ensure Monte Carlo effects only remove tokens for standard arcs (not read). |
| libs/@hashintel/petrinaut-core/src/simulation/monte-carlo/monte-carlo-simulator.test.ts | Add test proving read arcs don’t consume tokens in Monte Carlo runs. |
| libs/@hashintel/petrinaut-core/src/simulation/monte-carlo/frame-operations.ts | Clarify deadlock/structural enablement checks include read arc availability. |
| libs/@hashintel/petrinaut-core/src/simulation/engine/types.ts | Widen compiled input arc typing to InputArcType for engine paths. |
| libs/@hashintel/petrinaut-core/src/simulation/engine/execute-transitions.test.ts | Add engine test ensuring read tokens remain after firing while still being readable. |
| libs/@hashintel/petrinaut-core/src/simulation/engine/compute-possible-transition.ts | Exclude read arcs from removal map while still enumerating their token combinations. |
| libs/@hashintel/petrinaut-core/src/simulation/engine/compute-possible-transition.test.ts | Add test asserting read tokens reach lambda/kernel input and are not removed. |
| libs/@hashintel/petrinaut-core/src/simulation/engine/check-transition-enablement.ts | Extend enablement logic/comments so inhibitors invert condition; read behaves like standard. |
| libs/@hashintel/petrinaut-core/src/simulation/engine/check-transition-enablement.test.ts | Add enablement tests specifically for read arcs. |
| libs/@hashintel/petrinaut-core/src/schemas/entity-schemas.ts | Extend Zod schemas/docs for input arcs to include "read" and updated semantics. |
| libs/@hashintel/petrinaut-core/src/lsp/lib/generate-virtual-files.ts | Ensure read arcs contribute typed input properties like standard arcs (inhibitors excluded). |
| libs/@hashintel/petrinaut-core/src/lsp/lib/create-sdcpn-language-service.test.ts | Add completions test covering read-arc input token properties. |
| libs/@hashintel/petrinaut-core/src/file-format/types.ts | Preserve "read" during file import while defaulting missing type to "standard". |
| libs/@hashintel/petrinaut-core/src/file-format/parse-sdcpn-file.test.ts | Add import test verifying "read" arc types are preserved. |
| libs/@hashintel/petrinaut-core/src/default-codes.ts | Update default code comments to mention coloured standard/read inputs. |
| libs/@hashintel/petrinaut-core/src/clipboard/types.ts | Preserve "read" during clipboard parse while defaulting missing type to "standard". |
| libs/@hashintel/petrinaut-core/src/clipboard/serialize.test.ts | Add clipboard test verifying "read" arc types are preserved. |
| libs/@hashintel/petrinaut-core/src/ai.ts | Update AI-facing guidance to describe read arc token exposure without consumption. |
| libs/@hashintel/petrinaut-core/src/actions.ts | Allow addArc to create input arcs with explicit type (including "read"). |
| libs/@hashintel/petrinaut-core/src/actions.test.ts | Add mutation test for adding/updating read input arcs. |
| libs/@hashintel/petrinaut-core/src/action-schemas.ts | Extend mutation schemas so addArc supports optional input type, and updateArcType supports "read". |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🌟 What is the purpose of this PR?
This PR introduces Read Arcs in Petrinaut.
Read Arcs work like normal input arcs for enablement: the source place must contain at least
weighttokens. For coloured places, those tokens are provided toLambdaandTransitionKernelunderinput.<PlaceName>, with tuple length equal to the arc weight.The difference from standard arcs is consumption. When a transition fires, standard input arc tokens are removed immediately, while read arc tokens remain in their source place. This lets a transition inspect shared state or token attributes without moving that token through the transition.
They are almost syntactic sugar for a self-loop (same Place as input and output of transition with same token), but they are convenient in the sense that they prevent the user from accidentally modifying the data they are trying to read.
Change in runtime behaviour
Currently, for simulating the same behaviour you could use this self-loop pattern.
Though given the tokens of Reader A would be consumed temporarily in the frame during which the transition would be happening, Reader B would not be able to consume it until the next frame.
With Read Arcs, both these transitions would be triggered in the same frame.
Impacted areas
InputArc.typenow accepts"read"alongside"standard"and"inhibitor"."standard".addArccan create typed input arcs directly, andupdateArcTypecan switch an input arc to read.Edge cases
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:
🛡 What tests cover this?
"read"arc types.addArcinputs.Verified with:
yarn workspace @hashintel/petrinaut-core test:unityarn workspace @hashintel/petrinaut-core lint:tscyarn workspace @hashintel/petrinaut-core lint:eslintyarn workspace @hashintel/petrinaut-core buildyarn workspace @hashintel/petrinaut test:unityarn workspace @hashintel/petrinaut lint:tscyarn workspace @hashintel/petrinaut lint:eslint❓ How to test this?