Skip to content

FE-1882: Convert Petrinaut entity IDs to UUIDs - #9958

Merged
kube merged 11 commits into
mainfrom
claude/convert-entity-ids-to-uuids
Oct 9, 2026
Merged

kube merged 11 commits into
mainfrom
claude/convert-entity-ids-to-uuids

Conversation

@kube

@kube kube commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Before this PR, net and subnet ids and newly created entity ids were UUIDs. Places, transitions, types, type elements, parameters, equations, scenarios, metrics and component instances loaded from a document, or given by a host or an assistant, kept their ids, such as place__queue or p1.

Converts every entity id the same way as net ids: a UUID passes through lowercased, and any other id becomes its UUIDv5 in the same fixed namespace. Core converts each id together with every reference to it when a document, file, clipboard payload, recording or manifest loads. Mutation, command, assistant tool and experiment inputs convert the same way. CLI selectors and Brunch history match old ids against converted ones. Same legacy id always maps to the same UUID, so references converted at different boundaries stay linked.

Links

Changes

Petrinaut core

  • canonicalizePetrinautIds converts every entity id and every reference to it

    Arc endpoints, type and equation references, component instances' subnet ids and parameter value keys, and scenario overrides and initial states keyed by id convert with them, at the root and in subnets.
    Names, user code, metadata, scenario parameter identifiers and token values stay as written.

  • canonicalizeArcId converts the ids inside a generated arc id

    An arc id built from old ids names the same arc after its places and transitions convert.

  • Mutation, command and assistant tool inputs convert ids

    idSchema converts any non-UUID string, and records keyed by id convert their keys.
    idSchema replaces subnetIdSchema.
    Arc items in deleteItemsByIds use arcIdSchema, which runs canonicalizeArcId.

  • Experiment requests, optimization manifests and Actual mode recordings convert ids

    Actual mode markings and firings convert their place and transition ids.

  • Clipboard payloads convert as a whole, so a payload copied with old ids pastes with its arcs
  • File import converts reserved ids such as __proto__ instead of rejecting them

    Reserved names are still rejected.

Petrinaut

  • Preview checks precompiled scenarios against the converted document

Website

  • Core examples load with converted ids, in the catalog and in the build-time scenario compiler

    Precompiled scenarios match the document the Preview opens.

  • Stored nets convert every entity id on read
  • AI experiments demo reads its metric by converted id

CLI

  • Run selectors match an element's id or the converted form of an old id

    Parameters, places, metrics and scenarios resolve this way.
    Results report UUID keys.

HASH

  • Process embed opens saved nets with converted ids

    A net saved with old ids stores UUIDs on its next save.

Brunch

  • History attribution matches model-written ids against converted document ids

    namesId matches a written id as is, after toPetrinautId, or after canonicalizeArcId.

  • Draft experiments convert reportedByMetricId like their metric ids
  • Modelling guidance says supplied ids are stored as UUIDs

Review fixes

  • Experiment, optimization, scenario and Actual mode id fields share one petrinautIdSchema

    idSchema derives from it.

  • In-band browser calls parse both the issued and the admitted input before comparing them

    Ids compare converted whether or not the Brunch server converts them.

  • Actual mode converts the Brunch stream's definition

    Its places and transitions carry the converted ids that markings and firings name.

  • Assistant change summaries convert a call's ids themselves

    Rows for calls not yet applied target the existing items.

  • Synthesized ad-hoc scenario id is toPetrinautId("adhoc-scenario")
  • Brunch workpiece queries reuse namesId
  • Brunch attribution converts only id fields

    Names, kinds and code compare exactly, so they cannot match a converted id.

  • Recordings normalize their definition

    Omitted collections fill in before ids convert.

  • One release note per package

Known issues

  • Links that name an item or scenario by an old id open the default view

    Remapping old ids in links and showing names where raw ids appear are not part of this change.

Test coverage

  • petrinaut-id.test.ts:

    Every definition and every reference converts, at the root and in subnets.
    Names, metadata, scenario parameter identifiers and token values do not.
    Idempotence, identity preservation and canonicalizeArcId for place and component port arcs.

  • ai.test.ts:

    Entity id, arc id and id-keyed record key inputs export as plain JSON Schema strings.
    An assistant's own ids resolve across add place, add transition, add arc and delete by arc id.

  • parse-sdcpn-file.test.ts:

    Entity ids and references convert on import.
    A __proto__ place id imports as its UUID.
    A reserved colour element name is still rejected in the legacy format.

  • commands.test.ts, optimization.test.ts, host.test.ts, actual-mode.test.ts:

    Legacy clipboard payloads, manifests, experiment requests and recordings convert.

  • create-petrinaut-optimization-run-handler.test.ts:

    Handler forwards the parsed manifest, whose ids are converted.

  • net-change-attribution.test.ts, draft-experiment.test.ts:

    Brunch attributes a change written with the model's own ids, and a draft's reporting metric id converts.

  • Existing core, Petrinaut, website, CLI and Brunch suites and the Brunch browser witness, with expectations on converted ids

How to test

  • Open Petrinaut preview on Vercel
  • Menu > Load example > SIR Model
  • Menu > Export > JSON

    Expect every place, transition, scenario and metric id to be a UUID

  • Menu > Import > JSON file exported from production

    Expect the net to load and simulate

@kube kube self-assigned this Oct 6, 2026
@vercel

vercel Bot commented Oct 6, 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 Oct 8, 2026 6:47pm UTC
petrinaut Ready Ready Preview Oct 8, 2026 6:47pm UTC
petrinaut-docs Ready Ready Preview Oct 8, 2026 6:47pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Oct 8, 2026 6:47pm UTC

Request Review

@github-actions github-actions Bot added area/apps > hash* Affects HASH (a `hash-*` app) area/infra Relates to version control, CI, CD or IaC (area) area/apps > hash-api Affects the HASH API (app) 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 area/tests New or updated tests area/apps labels Oct 6, 2026
@kube
kube added this pull request to stack #9937 October 6, 2026 23:49
@kube
kube force-pushed the claude/convert-entity-ids-to-uuids branch from 9d48ad9 to bb845ce Compare October 7, 2026 01:53
@kube
kube force-pushed the claude/convert-entity-ids-to-uuids branch from bb845ce to 103b47f Compare October 7, 2026 03:07
@kube kube changed the title Convert every Petrinaut entity id to a UUID when it loads FE-1882: Convert every Petrinaut entity id to a UUID when it loads Oct 7, 2026
@kube
kube force-pushed the claude/convert-entity-ids-to-uuids branch from 103b47f to 92aadef Compare October 7, 2026 03:35
@kube
kube marked this pull request as ready for review October 7, 2026 03:36
@kube
kube requested review from a team as code owners October 7, 2026 03:36

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread libs/@hashintel/petrinaut-core/src/schemas/entity-schemas.ts

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread libs/@hashintel/petrinaut-core/src/actions.ts
CiaranMn
CiaranMn previously approved these changes Oct 8, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a1ad806. Configure here.

Comment thread libs/@hashintel/petrinaut-core/src/experiments/host.ts

This branch was successfully deployed

3 active deployments
Preview – petrinaut-docs — 64912850 Deployed Oct 8, 2026 by vercel[bot]
Preview – hash — 64912850 Deployed Oct 8, 2026 by vercel[bot]
Preview – petrinaut — 64912850 Deployed Oct 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps > hash* Affects HASH (a `hash-*` app) area/apps > hash-api Affects the HASH API (app) area/apps area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests 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.

4 participants