FE-711: Add Metrics to Experiments#8751
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
PR SummaryMedium Risk Overview
Petrinaut UI requires at least one metric when creating an experiment (drawer editor with LSP for expressions), stores Reviewed by Cursor Bugbot for commit 74a64da. Bugbot is set up for automated code reviews on this repo. Configure here. |
🤖 Augment PR SummarySummary: 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:
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 👎 |
| color: "neutral.s120", | ||
| cursor: "pointer", | ||
| }); | ||
|
|
||
| const metricCollapseIconStyle = css({ | ||
| transition: "[transform 200ms ease-in-out]", | ||
| "&[data-state=open]": { | ||
| transform: "[rotate(90deg)]", | ||
| }, |
There was a problem hiding this comment.
Metric ID validation inconsistency allows duplicate IDs with different whitespace. The code trims the ID when checking if empty (line 136) but adds the untrimmed ID to the Set (line 142), and checks for duplicates using the untrimmed ID (line 139). This means metric IDs like " test" and "test" would both pass validation as unique IDs, causing potential conflicts.
for (const metricSpec of input.metricSpecs) {
const trimmedId = metricSpec.id.trim();
if (trimmedId === "") {
throw new Error("Metric id is required");
}
if (metricIds.has(trimmedId)) {
throw new Error(`Metric id "${trimmedId}" is duplicated`);
}
metricIds.add(trimmedId);
// ...
}Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c8d52c6. Configure here.
| time: firstRunSummary.currentTime, | ||
| runCount: simulator.runCount, | ||
| }; | ||
| } |
There was a problem hiding this comment.
Progress reports run 0's frame, not global frame
Medium Severity
getProgressFromResult and progressFromResult derive frameNumber and time from simulator.getRunSummary(0), which returns run 0's individual frame number. If run 0 completes early (e.g., no firable transitions), its frameNumber freezes while other runs continue advancing. The old code sourced these values from the distribution metric's context.frameNumber, which was the global simulator frame number — always reflecting the latest advance across all runs.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c8d52c6. Configure here.
| case "cancel": { | ||
| isRunning = false; | ||
| simulator = null; | ||
| distributionMetric = null; |
There was a problem hiding this comment.
Worker cancel handler doesn't reset userMetrics array
Low Severity
The cancel handler sets simulator = null and isInitialized = false but does not reset userMetrics = []. The old code cleared distributionMetric = null at this point, and the init error handler in the same file correctly resets userMetrics = []. This inconsistency leaves stale metric objects and their accumulated frame data in worker memory after cancellation until the worker is re-initialized or terminated.
Reviewed by Cursor Bugbot for commit c8d52c6. Configure here.
1e2973a to
74a64da
Compare


🌟 What is the purpose of this PR?
🔗 Related links
🚫 Blocked by
🔍 What does this change?
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:
turbo.json's have been updated to reflect this🐾 Next steps
🛡 What tests cover this?
❓ How to test this?
📹 Demo