Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions services/03-vpp-aggregator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ app.get('/capacity/available', authenticateToken, async (req, res) => {
if (safetyContext && typeof safetyContext === 'string') {
try {
const context = JSON.parse(safetyContext);
physicsScoreVal = parseFloat(safeFloat(context.physics_score, 1.0));
confidenceScoreVal = parseFloat(safeFloat(context.confidence_score, 1.0));
physicsScoreRaw = parseFloat(context.physics_score);
confidenceScoreRaw = parseFloat(context.confidence_score);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing scores zero capacity

Medium Severity

Replacing safeFloat-backed parsing with bare parseFloat on context.physics_score and context.confidence_score leaves missing or invalid fields as NaN, which the multiplier path maps to 0.0 and drives physicsMultiplier to zero. The same inputs still surface as 1.0000 in responses via safeFloat, so capacity can be wiped while telemetry looks healthy, and a single valid score no longer derates capacity the way it did when the missing side defaulted to 1.0.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6bbda96. Configure here.


// High-Fidelity Standard: (physics_score > 0.95 OR confidence_score > 0.95)
isHighFidelity = physicsScoreRaw > 0.95 || confidenceScoreRaw > 0.95;
Expand Down Expand Up @@ -287,8 +287,8 @@ const updateGlobalCapacity = async () => {
if (context.fleet_id) {
lockedFleetId = context.fleet_id;
}
rawPhysicsScore = parseFloat(safeFloat(context.physics_score, 1.0));
confidenceScore = parseFloat(safeFloat(context.confidence_score, 1.0));
rawPhysicsScore = parseFloat(context.physics_score);
rawConfidenceScore = parseFloat(context.confidence_score);

// Sentinel Fidelity logic: Prioritize explicit flag (boolean, string, or integer)
isSentinelFidelity = context.is_sentinel_fidelity === true || context.is_sentinel_fidelity === 'true' || context.is_sentinel_fidelity === 1 || rawPhysicsScore > 0.99;
Expand Down