Skip to content

FE-1509: Add the structural analyses β€” cycles and initial places - #9431

Draft
kube wants to merge 1 commit into
mainfrom
claude/fe-1509-notebook-analyses-algorithms
Draft

FE-1509: Add the structural analyses β€” cycles and initial places#9431
kube wants to merge 1 commit into
mainfrom
claude/fe-1509-notebook-analyses-algorithms

Conversation

@kube

@kube kube commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Important

Pure algorithms and tests, nothing user-facing on its own.

Summary

Before this PR, the notebook lists cells and draws the whole-net graph, but computes nothing structural about the net. Feedback loops and places the initial state must seed are invisible, and both are the questions a reader of a net asks first.

Adds the two analyses as pure functions over places, transitions and arcs: cycle detection and initial-place analysis. Nothing consumes them yet; the layer above surfaces both, so this PR reviews as two algorithms and their test suites, plus an authored page recording why each algorithm was chosen.

Links

Changes

  • net-cycles finds every feedback group as a strongly connected component

    Iterative Tarjan, so deep nets cannot blow the call stack. Components sized above one, labelled in document order.
    SCCs rather than elementary cycles because their count can be exponential and the reader's question is which nodes feed back into each other.

  • net-siphons finds the place groups the initial marking must cover

    A minimal siphon is a place set nothing in the net can seed, which unifies plain source places with resource pools that only circulate what they start with.
    Found per place by a greedy shrink from the maximal siphon. Groups overlapping a smaller reported group are dropped for readability.

  • Stale arcs exclude their transition from the siphon analysis

    A transition referencing a deleted place can never fire, so reading it as a live source would wrongly suppress a seeding requirement.

  • Nets above 100 places skip the siphon analysis

    The shrink is cubic in the place count. A dense 100-place net computes in about 100ms; larger nets skip rather than stall a render.

Test coverage

  • net-cycles.test.ts:

    Chains, two-node and four-node loops, disjoint loops, membership lookup, document-order labels.

  • net-siphons.test.ts:

    Source places, circulating pools, containment dedupe, stale-arc exclusion, and the example models end to end.

How to test

  • npx turbo run test:unit --filter @hashintel/petrinaut
  • Expect net-cycles and net-siphons suites green

@kube kube self-assigned this Aug 29, 2026
@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
hash Ready Ready Preview Sep 3, 2026 10:54pm UTC
petrinaut Ready Ready Preview Sep 3, 2026 10:54pm UTC
petrinaut-docs Ready Ready Preview Sep 3, 2026 10:54pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Sep 3, 2026 10:54pm UTC

Request Review

@github-actions github-actions Bot added 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 type/eng > backend Owned by the @backend team labels Aug 29, 2026
@kube
kube force-pushed the claude/fe-1509-notebook-analyses-algorithms branch from a010820 to 759a5dc Compare August 29, 2026 14:09
@kube
kube force-pushed the claude/fe-1509-notebook-analyses-algorithms branch from 759a5dc to b18fcc2 Compare August 30, 2026 04:54
@kube
kube force-pushed the claude/fe-1509-notebook-analyses-algorithms branch from b18fcc2 to 55f49d7 Compare August 30, 2026 13:07
Base automatically changed from claude/fe-1509-notebook-explorer to main August 30, 2026 13:55
@kube
kube force-pushed the claude/fe-1509-notebook-analyses-algorithms branch from 55f49d7 to 548c49f Compare August 30, 2026 13:55
Two pure, unit-tested analyses over the net's arc structure:

- Cycle detection as iterative Tarjan strongly connected components,
  sized above one, labelled in document order.
- Initial-place analysis as minimal siphons β€” the place sets nothing
  in the net can seed, unifying plain source places with resource
  pools that only circulate what they start with. Found by a
  polynomial greedy shrink; transitions referencing deleted places are
  excluded because they can never fire; capped at 100 places.

Nothing consumes them yet; the layer above surfaces both in the cell
list and the graph explorer. An authored arch-docs deep-dive records
why each algorithm was chosen.
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 > backend Owned by the @backend team type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

1 participant