Skip to content

FE-725: Create @hashintel/petrinaut-core package#8730

Open
kube wants to merge 13 commits into
cf/experiments-iterationfrom
cf/fe-725-extract-hashintelpetrinautcore-into-hashintelpetrinaut-core
Open

FE-725: Create @hashintel/petrinaut-core package#8730
kube wants to merge 13 commits into
cf/experiments-iterationfrom
cf/fe-725-extract-hashintelpetrinautcore-into-hashintelpetrinaut-core

Conversation

@kube
Copy link
Copy Markdown
Collaborator

@kube kube commented May 19, 2026

🌟 What is the purpose of this PR?

Extracts the headless Petrinaut model, simulation, Monte Carlo, and LSP logic into @hashintel/petrinaut-core so @hashintel/petrinaut can focus on React/UI integration while consuming a publishable core package.

🔗 Related links

🔍 What does this change?

  • Adds @hashintel/petrinaut-core with headless exports, package/build config, tests, README, and dedicated worker entry points for LSP, simulation, and Monte Carlo.
  • Moves shared Petrinaut constants and browser-agnostic worker protocol types into core; keeps SNAP_GRID_SIZE as a UI alias of core GRID_SIZE.
  • Updates @hashintel/petrinaut and @apps/petrinaut-website to consume core APIs from @hashintel/petrinaut-core.
  • Re-exports the LSP types/enums needed by UI consumers from core, removing the UI package’s direct vscode-languageserver-types dependency.
  • Adds changesets for publishing @hashintel/petrinaut-core and bumping @hashintel/petrinaut.

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:

  • are internal and do not require a docs change

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

The changes in this PR:

  • affected the execution graph, and the turbo.json's have been updated to reflect this

🐾 Next steps

  • Continue simplifying the exported surface of @hashintel/petrinaut and @hashintel/petrinaut-core in follow-up PRs.

🛡 What tests cover this?

  • yarn workspace @hashintel/petrinaut-core lint:tsc && yarn workspace @hashintel/petrinaut-core build && yarn workspace @hashintel/petrinaut-core test:unit run
  • yarn workspace @hashintel/petrinaut lint:tsc && yarn workspace @hashintel/petrinaut build && yarn workspace @hashintel/petrinaut test:unit run
  • yarn workspace @apps/petrinaut-website lint:tsc && yarn workspace @apps/petrinaut-website build
  • yarn constraints

❓ How to test this?

  1. Build @hashintel/petrinaut-core, @hashintel/petrinaut, and @apps/petrinaut-website.
  2. Open Petrinaut and confirm editor loading, LSP diagnostics, simulation, and Monte Carlo experiments still work.

@kube kube requested a review from a team as a code owner May 19, 2026 00:10
@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

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

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment May 19, 2026 1:57pm
petrinaut Ready Ready Preview, Comment May 19, 2026 1:57pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview May 19, 2026 1:57pm

@cursor
Copy link
Copy Markdown

cursor Bot commented May 19, 2026

PR Summary

Medium Risk
Medium risk because it restructures public package boundaries/exports (removing @hashintel/petrinaut/core) and changes worker/abort typing in core simulation/LSP, which can break downstream builds and runtime worker wiring if misconfigured.

Overview
Extracts the headless engine into a new publishable package, @hashintel/petrinaut-core. This adds a standalone build (Vite/Rolldown + types), dual-license files, stricter lint/tsconfig, and expands the core public surface (LSP types/enums, authoring helpers, clipboard/file-format helpers, selection/arc-id utilities, GRID_SIZE, etc.). It also introduces environment-agnostic runtime types (WorkerLike, AbortSignalLike) and refactors simulation/LSP/Monte-Carlo transports and worker entrypoints to use them, avoiding DOM-only globals and DOMException.

Removes the @hashintel/petrinaut/core compatibility export and migrates consumers. @hashintel/petrinaut now depends on and re-exports from @hashintel/petrinaut-core, and the website/editor code switches imports (including examples via @hashintel/petrinaut-core/examples and worker entrypoints via @hashintel/petrinaut-core/workers/*).

Improves editor UX around long-running experiments/simulation. Adds a shared notifications system (NotificationsProvider + Ark UI toaster), blocks window unload while Monte Carlo experiments are active, emits success/error notifications for experiments and simulation completion, and adds a TopBar RunningExperimentsPopover plus a reusable Table component; minor UI tweaks include Popover userSelect: none and moving CODE_FONT_FAMILY to constants/fonts.

Reviewed by Cursor Bugbot for commit 6ff0fa5. Bugbot is set up for automated code reviews on this repo. Configure here.

@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented May 19, 2026

This pull request is abnormally large and would use a significant amount of tokens to review. If you still wish to review it, comment "augment review" and we will review it.

@github-actions github-actions Bot added area/deps Relates to third-party dependencies (area) 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 area/apps type/legal Owned by the @legal team area/apps > hash.design Affects the `hash.design` design site (app) labels May 19, 2026
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 a9d4c58. Configure here.

const value: NotificationsContextValue = {
addNotification,
dismissNotification,
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unstable context value causes simulation subscription churn

Medium Severity

NotificationsProvider defines addNotification and dismissNotification as plain functions recreated on every render, and the value object is also recreated without useMemo. This makes every consumer re-render when NotificationsProvider re-renders. Critically, SimulationProvider includes addNotification in its useEffect dependency array (line 159), so every re-render of NotificationsProvider tears down and re-creates the simulation event subscription. Other providers in the codebase use useStableCallback or useCallback to avoid exactly this pattern.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a9d4c58. Configure here.

scope.postMessage(message);
},
onMessage(listener) {
scope.addEventListener("message", ({ data }) => listener(data));
@kube kube requested a review from CiaranMn May 19, 2026 14:00
@kube kube changed the base branch from main to cf/experiments-iteration May 19, 2026 14:06
@kube kube force-pushed the cf/experiments-iteration branch from 2505197 to 36ba6da Compare May 19, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps > hash.design Affects the `hash.design` design site (app) area/apps area/deps Relates to third-party dependencies (area) 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/legal Owned by the @legal team

Development

Successfully merging this pull request may close these issues.

2 participants