FE-1665: Validate explicit model snapshots for AI requests - #9675
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
PR SummaryMedium Risk Overview Core ( UI / AI ( Also: patch changesets, arch docs/diagram, voice integration test LSP stub, test mocks for Reviewed by Cursor Bugbot for commit aefac2a. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
🟡 Changes recommended
Four unresolved findings remain, including one critical metric-ID collision and three moderate optimization/UI issues.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds correlated snapshot diagnostics for AI checks and expands browser optimization with pause/resume, constraints, parameter importance, sweep orchestration, and related UI/documentation updates.
Changes:
- Correlates diagnostic requests with explicit model snapshots.
- Adds optimization lifecycle, constraint, importance, and sweep workflows.
- Updates simulation UI, tests, documentation, and changesets.
Final findings: Moderate (2 votes) for dropped paused-event importances; Critical (1 vote) for objective/auxiliary metric ID collisions; Moderate (2 votes) for unreleased sweep studies; and Moderate (1 vote) for stale experiment selections.
File summaries
| File | Review status |
|---|---|
libs/@local/petrinaut-optimizer-core/tests/test_importance.py |
Reviewed. |
libs/@local/petrinaut-optimizer-core/src/petrinaut_optimizer_core/pyodide_entry.py |
Reviewed. |
libs/@local/petrinaut-optimizer-core/src/petrinaut_optimizer_core/importance.py |
Reviewed. |
libs/@local/petrinaut-optimizer-core/src/petrinaut_optimizer_core/ask_tell.py |
Reviewed. |
libs/@local/petrinaut-optimizer-core/src/petrinaut_optimizer_core/__init__.py |
Reviewed. |
libs/@local/petrinaut-arch-docs/content/experiments/sweep-orchestration.mdx |
Reviewed. |
libs/@local/petrinaut-arch-docs/content/experiments/parameter-sweeps.mdx |
Reviewed. |
libs/@local/petrinaut-arch-docs/content/diagrams/sweep-surface-feed.d2 |
Reviewed. |
libs/@local/petrinaut-arch-docs/content/diagrams/sweep-orchestration.d2 |
Reviewed. |
libs/@local/petrinaut-arch-docs/content/diagrams/snapshot-diagnostics.d2 |
Reviewed. |
libs/@local/petrinaut-arch-docs/content/ai/snapshot-diagnostics.mdx |
Reviewed. |
libs/@hashintel/petrinaut/vite.config.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/shared/experiment-progress.test.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/simulate-view.test.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/simulate-view.stories.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/surface-frame.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/surface-field.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/summary-strip.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/results.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/drawer-frame/use-prefers-reduced-motion.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/drawer-frame/use-overflow-end.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/drawer-frame/use-header-engaged.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/drawer-frame/use-body-scrolled.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/drawer-frame/frame-test-helpers.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/drawer-frame/frame-layout-signature.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/drawer-frame/frame-columns.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/drawer-frame/frame-animate-context.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/compute-backend-badge.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/chart-card.test.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/shared/chart-card.stories.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/view-optimization-drawer/study-summary-strip.test.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/view-optimization-drawer/shared/study-progress.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/view-optimization-drawer/optimization-metrics.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/view-optimization-drawer/navigator-band.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/study-results/study-steps.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/study-results/study-phase.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/study-results/shared/study-progress.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/study-results/parameter-values.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/study-results/objective-history-data.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/study-results/convergence.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/study-results/convergence.test.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/study-results/continue-control.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/optimizations-view.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/optimization-surface/surface-plot.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/optimization-surface/surface-plot.test.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/optimization-surface.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/optimization-status.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/optimization-full-view.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/optimization-full-view.stories.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/optimizations/create-optimization-drawer.test.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/metrics/create-metric-drawer.test.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/experiments/view-experiment-drawer/experiment-metrics.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/experiments/sweep-surface.stories.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/experiments/sweep-navigator/range-slider.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/experiments/sweep-navigator.stories.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/experiments/create-experiment-drawer.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/experiments/create-experiment-drawer.test.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/format-diagnostics-for-ai.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/format-diagnostics-for-ai.test.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel.test.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/ui/index.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/react/state/editor-provider.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/react/state/editor-provider.test.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/react/state/editor-context.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/react/optimizations/sir-optimization-input.fixtures.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/react/optimizations/provider/connected-study.test.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/react/optimizations/channel/create-optimization-channel/trial-outcome.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/react/optimizations/channel/create-optimization-channel/trial-constraints.test.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/react/optimizations/channel/create-optimization-channel.test.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/react/navigation/index.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/react/navigation/index.test.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/react/lsp/provider.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/react/lsp/context.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/react/index.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/react/hooks/use-petrinaut-mutations.test.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/react/hooks/use-petrinaut-commands.test.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/react/experiments/sweep-session/README.md |
Reviewed. |
libs/@hashintel/petrinaut/src/react/experiments/sweep-session/cell-batch.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/react/experiments/provider/sweep-batch-instantiation/backend-lanes.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/react/experiments/provider/detached-objective.ts |
Critical finding (1 vote): auxiliary metric IDs can collide with the objective ID. |
libs/@hashintel/petrinaut/src/react/experiments/provider/detached-objective.test.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/react/experiments/provider/create-experiment.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/react/experiments/provider.tsx |
Reviewed. |
libs/@hashintel/petrinaut/src/panda-preset.ts |
Reviewed. |
libs/@hashintel/petrinaut/src/main.ts |
Reviewed. |
libs/@hashintel/petrinaut/docs/ai-assistant.md |
Reviewed. |
libs/@hashintel/petrinaut-core/src/simulation/monte-carlo/metrics/user-defined.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/simulation/monte-carlo/metrics/user-defined.test.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/simulation/monte-carlo/metrics/types.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/optimization/optimization.test.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/optimization/browser/worker/study-runner/as-importances.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/optimization/browser/worker/study-runner/as-importances.test.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/optimization/browser/worker/study-runner.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/optimization/browser/worker/study-runner.pyodide.test.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/optimization/browser/worker/attach-optimizer-worker.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/optimization/browser/worker/attach-optimizer-worker.test.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/optimization/browser/run-log.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/optimization/browser/run-log.test.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/optimization/browser/README.md |
Reviewed. |
libs/@hashintel/petrinaut-core/src/optimization/browser/python-sources.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/optimization/browser/messages.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/lsp/worker/protocol.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/lsp/worker/language-server.worker.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/lsp/lib/check-snapshot.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/lsp/lib/check-snapshot.test.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/lsp/language-client.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/lsp/language-client.test.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/index.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/hir/interpret.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/constraint/indicator-metric.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/constraint/constraint.ts |
Reviewed. |
libs/@hashintel/petrinaut-core/src/ai.ts |
Reviewed. |
libs/@hashintel/ds-components/src/main.ts |
Reviewed. |
libs/@hashintel/ds-components/src/components/Drawer/drawer.tsx |
Reviewed. |
apps/petrinaut-website/src/main/app/voice-interview/voice-browser-tools.integration.test.tsx |
Reviewed. |
apps/petrinaut-website/src/examples/use-shared-search-navigation.ts |
Reviewed. |
apps/petrinaut-website/src/examples/navigation-search.ts |
Reviewed. |
apps/petrinaut-website/src/examples/navigation-search.test.ts |
Reviewed. |
apps/petrinaut-website/src/examples/example-search.ts |
Reviewed. |
apps/petrinaut-website/src/examples/example-search.test.ts |
Reviewed. |
.claude/launch.json |
Reviewed. |
.changeset/snapshot-language-diagnostics.md |
Reviewed. |
.changeset/simulate-drawer-frame.md |
Reviewed. |
.changeset/shared-results-view.md |
Reviewed. |
.changeset/optimization-paused-event.md |
Reviewed. |
.changeset/optimization-pause-resume.md |
Reviewed. |
.changeset/optimization-parameter-importance.md |
Reviewed. |
.changeset/optimization-importance-events.md |
Reviewed. |
.changeset/optimization-dedicated-view.md |
Reviewed. |
.changeset/optimization-constraint-verdicts.md |
Reviewed. |
.changeset/optimization-constraint-margins.md |
Reviewed. |
.changeset/ds-slider-plain-variant.md |
Reviewed. |
.changeset/drawer-focus-refs-nullable.md |
Reviewed. |
.changeset/await-ai-diagnostics.md |
Reviewed. |
Review details
Suppressed comments (1)
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/SimulateView/experiments/sweep-optimize-control.tsx:88
- This state is initialized only on the first mount, but
ViewExperimentDrawerkeeps the same drawer mounted while the selected experiment can change. Switching to another experiment therefore leaves the prompt'smetricIdpointing at the previous experiment (and Start can reject it with “Pick a metric to optimize”); the same one-time initialization affectsxAxisId,yAxisId, andmetricIdinsweep-surface.tsx:64-66, leaving the new surface blank or showing invalid selections. Reset these selections when the experiment changes, or key the experiment content byexperiment.id.
- Files reviewed: 170/209 changed files
- Comments generated: 3
- Review effort level: Lite (auto)
Note
Copilot is running an experiment and ran this review at Lite.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ...(request.auxiliaryMetrics ?? []).map( | ||
| (auxiliary): ExperimentRequest["metricSpecs"][number] => ({ | ||
| kind: "expression", | ||
| id: auxiliary.id, | ||
| label: auxiliary.label, |
| type: "paused", | ||
| requestedTrials: summary.requestedTrials, | ||
| completedTrials: summary.completedTrials, | ||
| prunedTrials: summary.prunedTrials, | ||
| failedTrials: summary.failedTrials, | ||
| best: summary.best, | ||
| }, |
| const removeOptimization: OptimizationsContextValue["removeOptimization"] = ( | ||
| optimizationId, | ||
| ) => { |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9675 +/- ##
===========================================
- Coverage 65.90% 15.35% -50.55%
===========================================
Files 1887 210 -1677
Lines 198443 6677 -191766
Branches 8248 1154 -7094
===========================================
- Hits 130774 1025 -129749
+ Misses 66139 5551 -60588
+ Partials 1530 101 -1429 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
e1cfa8b to
aefac2a
Compare
Summary
AI compilation checks now await diagnostics for the net snapshot they requested. Before this PR, a check could return stale diagnostics after a fixed wait, or miss a response when the diagnostics were unchanged.
The language worker returns a correlated response for each snapshot. The React provider exposes this request to the AI compilation tool and its checks after model changes.
Links
Changes
LanguageClient.requestDiagnostics()for an explicit model snapshotKnown issues
Requests have no timeout; an unresponsive worker can leave a check pending. Moving diagnostics onto
PetrinautInstanceneeds a headless contract, tracked in FE-754.Test coverage
After the 14 September rebase, affected package builds, unit tests, types, lint and architecture checks passed on the integrated stack. Browser recordings and manual checks listed below predate this rebase.
Local package builds, unit tests, TypeScript, lint, architecture validation, and the docs site build pass.
How to test
yarn workspace @hashintel/petrinaut-core test:unit --run src/lsp/language-client.test.ts src/lsp/lib/check-snapshot.test.tsyarn workspace @hashintel/petrinaut test:unit --run src/ui/views/Editor/panels/ai-assistant-panel.test.tsx