Skip to content

FE-711: Add Metrics to Experiments#8751

Merged
kube merged 22 commits into
mainfrom
cf/fe-711-add-metrics-to-monte-carlo-experiments
Jun 1, 2026
Merged

FE-711: Add Metrics to Experiments#8751
kube merged 22 commits into
mainfrom
cf/fe-711-add-metrics-to-monte-carlo-experiments

Conversation

@kube
Copy link
Copy Markdown
Collaborator

@kube kube commented May 25, 2026

🌟 What is the purpose of this PR?

Adds Monte Carlo experiment metrics to Petrinaut, so experiments can define metric outputs, run them in a worker, and inspect scalar/distribution timelines.

🔗 Related links

🚫 Blocked by

None.

🔍 What does this change?

  • Adds Monte Carlo metric specs, accumulators, and worker/runtime plumbing in @hashintel/petrinaut-core.
  • Updates experiment creation in @hashintel/petrinaut to require explicit metrics, validate metric LSP diagnostics, and default to model scenarios when present.
  • Adds experiment metric timeline visualizations for scalar and distribution outputs, including per-frame distribution popovers.
  • Adds Simulate stories for running SIR and Satellites Launcher experiments.

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:

  • do not affect the execution graph

⚠️ Known issues

  • Metric frame storage/downsampling may need follow-up optimization for long experiments.

🐾 Next steps

  • Follow up on streaming/downsampling distribution data from the worker to the visualization layer.

🛡 What tests cover this?

  • @hashintel/petrinaut-core Monte Carlo simulator, runtime, and accumulator tests.
  • @hashintel/petrinaut experiment provider and metric LSP validation tests.
  • Package lint and TypeScript checks were run during development.

❓ How to test this?

  1. Open the Simulate Storybook stories for SIR or Satellites Launcher.
  2. Create an experiment with at least one metric.
  3. Confirm experiment progress updates and metric timelines render, including distribution popovers on timeline click/drag.

📹 Demo

Not included.

@kube kube self-assigned this May 25, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

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

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment Jun 1, 2026 10:57am
hashdotdesign-tokens Ready Ready Preview, Comment Jun 1, 2026 10:57am
petrinaut Ready Ready Preview, Comment Jun 1, 2026 10:57am

@cursor
Copy link
Copy Markdown

cursor Bot commented May 25, 2026

PR Summary

Medium Risk
Large change to Monte Carlo experiment and worker messaging plus user-supplied expression compilation, but covered by tests and scoped to simulation/metrics—not security-critical paths.

Overview
Replaces the old place token count distribution experiment output with a configurable Monte Carlo metrics pipeline: declarative metric specs (expression, place mean, transition firing), mergeable numeric/histogram accumulators, and per-frame scalar or distribution frames streamed from the simulator, local experiment loop, and worker (metricSpecs on init, metricFrames on the wire).

@hashintel/petrinaut now requires at least one metric when creating an experiment, validates duplicate metric ids and expression LSP diagnostics, and surfaces metricFrames / latestMetricFramesById instead of distribution frames. The create-experiment drawer adds a metrics section (built-in kinds, model metrics, custom code with LSP). Simulation settings default to the first scenario when the model has scenarios; the editor defaults to the experiments simulate view.

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

@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 labels May 25, 2026
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented May 25, 2026

🤖 Augment PR Summary

Summary: This PR introduces first-class Monte Carlo “experiment metrics” for Petrinaut experiments, including runtime/user-defined metric evaluation and UI controls to configure and view metric outputs.

Changes:

  • Exports new Monte Carlo metric APIs and types from @hashintel/petrinaut-core (metric specs, user-defined metrics, accumulators).
  • Adds a SimulationFrameReader-based per-run frame reader so metrics can safely inspect place/transition state.
  • Implements numeric and histogram accumulator utilities plus tests for merge/monoid behavior.
  • Adds metric spec compilation (including expression metrics via compileMetric) into user-defined metric configs.
  • Extends createMonteCarloExperiment() with a local execution path when metric callbacks/specs are provided (worker cannot receive executable code).
  • Updates experiments React state/provider to store metric specs, metric frames, and latest-by-id.
  • Adds UI for defining metrics when creating an experiment (including LSP diagnostics for expression metrics).
  • Updates experiment viewing UI to optionally show token-count timeline and a new metrics summary section.
  • Adds architecture/proposal/usage docs for Monte Carlo metrics direction.

Technical Notes: Worker-backed experiments remain distribution-only; experiments with expression/aggregated metrics run locally to avoid posting JS code across the worker boundary.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

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

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread libs/@hashintel/petrinaut/src/react/experiments/provider.tsx Outdated
Base automatically changed from cm/petrinaut-ai-assistant-mvp to main May 26, 2026 17:11
@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) type/eng > backend Owned by the @backend team area/apps area/apps > hash.design Affects the `hash.design` design site (app) labels May 26, 2026
@kube kube force-pushed the cf/fe-711-add-metrics-to-monte-carlo-experiments branch from 1e2973a to 74a64da Compare May 26, 2026 21:03
@github-actions github-actions Bot removed area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) type/eng > backend Owned by the @backend team labels May 26, 2026
kube added 3 commits June 1, 2026 12:33
- Remove seed input
- Single line for Runs and Time inputs
- Remove Scenario label
@kube kube force-pushed the cf/fe-711-add-metrics-to-monte-carlo-experiments branch from f1bcecf to e766adc Compare June 1, 2026 10:34
@kube kube enabled auto-merge June 1, 2026 10:34
CiaranMn
CiaranMn previously approved these changes Jun 1, 2026
@kube kube force-pushed the cf/fe-711-add-metrics-to-monte-carlo-experiments branch from 788b0e7 to 457e39a Compare June 1, 2026 10:47
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 079dd75. Configure here.

@kube kube added this pull request to the merge queue Jun 1, 2026
Merged via the queue into main with commit 3b5ff88 Jun 1, 2026
54 of 60 checks passed
@kube kube deleted the cf/fe-711-add-metrics-to-monte-carlo-experiments branch June 1, 2026 11:19
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/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

Development

Successfully merging this pull request may close these issues.

2 participants