feat: add runtime traits crate for circular deps#229
Conversation
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.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on March 22
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| /// Create a measurement from aggregate data (no samples) | ||
| pub fn from_aggregate(iterations: u64, total_nanos: u64) -> Self { | ||
| let nanos_per_op = total_nanos as f64 / iterations as f64; | ||
| let ops_per_sec = if nanos_per_op > 0.0 { 1_000_000_000.0 / nanos_per_op } else { 0.0 }; |
There was a problem hiding this comment.
Division by zero produces NaN, breaking JSON serialization
High Severity
from_aggregate divides total_nanos as f64 / iterations as f64 with no guard for iterations == 0, producing NaN. Both aggregate_runs and aggregate_runs_memory call from_aggregate(0, 0) for empty input. The resulting NaN in nanos_per_op, raw_nanos_per_op, and filtered_nanos_per_op will cause serde_json serialization to fail at runtime, since serde_json cannot serialize NaN by default. The from_samples_with_options method correctly guards against this with an if effective_iterations > 0 check, but from_aggregate does not.
Additional Locations (2)
| timed_out: Some(false), | ||
| run_nanos_per_op: Some(run_nanos_per_op), | ||
| } | ||
| } |
There was a problem hiding this comment.
Near-complete duplication between two aggregation methods
Medium Severity
aggregate_runs_memory is ~140 lines that are identical to aggregate_runs, differing only in how bytes_per_op and allocs_per_op are aggregated (mean vs. median — about 5 lines). This duplication means any future bug fix or field addition needs to be applied in two places, risking inconsistency. A shared helper accepting an aggregation strategy parameter would eliminate this.


Auto-generated PR from staged changes.
Note
Medium Risk
Adds a large new shared API surface (traits + statistical aggregation logic) that other crates will depend on, so bugs or API churn could ripple widely once adopted.
Overview
Introduces a new
poly-bench-runtime-traitscrate that centralizes the public interfaces runtimes must implement (Runtime,RuntimeFactory,RuntimePlugin) plus common support traits/types for project root detection, compiler error line remapping, and language display metadata.Adds a unified, serde-serializable
Measurementmodel with helpers for outlier filtering, stability metrics (CV/RME), multi-run aggregation with bootstrap confidence intervals, timeout markers, and aComparisontype for reporting cross-language speedups.Written by Cursor Bugbot for commit cab88f9. This will update automatically on new commits. Configure here.