FE-1212: Read net parameters from a metric#9043
Conversation
Metric code can now read net parameters ambiently as `parameters.<name>`, bound to the run's resolved values (defaults + scenario parameter overrides). Scenario parameters remain unavailable to metrics. - HIR: metric surface context exposes net parameters; lowering treats `parameters` as ambient; `instantiateHirMetric` binds `__params`. - Runtime: `createHirMetricEvaluator` accepts parameter values; threaded through the compiled model, Monte-Carlo local/worker paths, and the simulation timeline. Adds a shared `resolveNetParameterValues` helper. - TypeScript LSP: declares ambient `parameters` in the metric editor. - Docs, AI prompt and metric schema updated.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
PR SummaryMedium Risk Overview The HIR metric surface treats Runtime wiring adds Reviewed by Cursor Bugbot for commit 153bfab. Bugbot is set up for automated code reviews on this repo. Configure here. |
Expression metrics baked the shared config's resolved net parameters into the evaluator once at experiment init. Monte Carlo runs can override parameters per run, so a metric reading ambient `parameters.<name>` would report the shared values rather than the parameters each run actually used. Expose each run's resolved `parameterValues` on the frame raw view and have the metric evaluator bind `__params` from the frame (falling back to the construction-time values when a frame source carries none), so per-run overrides are honoured.
|
Confirmed this was a real bug — thanks. The Monte-Carlo simulator resolves parameters per run ( Fixed in 153bfab:
Added an end-to-end test in |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 153bfab. Configure here.

🌟 What is the purpose of this PR?
Lets metric code read the net's parameters — previously metrics could only read place state (
state.places.<Name>.count/.tokens). A metric can now be expressed relative to a tunable model parameter, e.g. utilisation against acapacityparameter.Resolves FE-1212.
🔗 Related links
🔍 What does this change?
Net parameters are exposed to metrics as an ambient value (there is no
parametersfunction argument to declare, unlike dynamics/lambdas/kernels):Values are bound to the run's resolved net parameter values (defaults overridden by scenario parameter overrides), matching how dynamics/lambdas/kernels resolve them. Scenario parameters remain unavailable to metrics.
buildMetricContextnow populatesparametersfrom the root net (gated by theparametersextension).parametersas ambient in the metric surface, soparameters.xandconst { x } = parameterslower to parameter reads. Typecheck / emit / analyze / lint already handle parameter reads generically.instantiateHirMetricbinds__paramsto the resolved values instead of{}.createHirMetricEvaluatoracceptsparameterValues; threaded through the single-run compiled model, the Monte-Carlo local + worker paths, and the simulation-timeline hook (which rebinds when values change, including scenario overrides).resolveNetParameterValueshelper (mirrorsbuildSimulation's resolution).const parameters: Parameters, so completion and type-checking work.petri-net-extensions.md, the AI metric prompt inai.ts, and the metric schema description (all previously stated parameters were unavailable in metrics).Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
📜 Does this require a change to the docs?
🕸️ Does this require a change to the Turbo Graph?
None.
🛡 What tests cover this?
parameters.<name>andconst { x } = parameterslower to param reads; bareparametersis rejected (lower-typescript.test.ts).emit-buffer-js.test.ts).hir-metric.test.ts).metric-session.test.ts).lint:tsc+lint:eslintclean on both.❓ How to test this?
return state.places.Infected.count * parameters.infection_rate;.parameters.), the metric plots on the timeline, and overriding the parameter (directly or via a scenario) changes the plotted values.