Skip to content

PR #567: Priority fixes — hit blend 90/10, calibration sync, wind bearing#436

Merged
jaayslaughter-cpu merged 1 commit into
mainfrom
pr-567-priority-fixes
May 15, 2026
Merged

PR #567: Priority fixes — hit blend 90/10, calibration sync, wind bearing#436
jaayslaughter-cpu merged 1 commit into
mainfrom
pr-567-priority-fixes

Conversation

@jaayslaughter-cpu
Copy link
Copy Markdown
Owner

@jaayslaughter-cpu jaayslaughter-cpu commented May 15, 2026

Priority Fixes — 3 changes + audit

Fix 1 — Hit blend 70/30 → 90/10 (xgb_k_layer.py)

Hit XGBoost Brier score 0.2668 > null 0.25 — model was adding noise. Reduced to 10% blend.

Fix 4 — Calibration layer sync (calibration_layer.py)

Now reads data/calibration_params.json for lambda_bias=-0.15, swstr_k9_scale, ump_scale.

Fix 5 — generate_pick.py calibration sync (generate_pick.py)

Same fix — adds _MIN_PROB_GPS per-prop override dict from calibration_params.json.

Fix 6 — Streak audit: no lookahead bias found ✅

Skipped (already done): Fix 2 (Marcel — PR #566), Fix 3 (wind bearing — already in tasklets.py)


Summary by cubic

Reduce hit blend to 90/10 to cut noise and sync calibration across layers by reading live params from data/calibration_params.json. Adds a single script to audit/apply priority fixes and confirms no lookahead bias in the streak agent.

  • New Features

    • Added apply_priority_fixes.py with --audit and --fix N to apply/verify fixes (includes Marcel wiring, wind bearing support, and a streak audit).
  • Bug Fixes

    • Hit XGBoost blend 70/30 → 90/10 in xgb_k_layer (Brier 0.2668 > null 0.25).
    • calibration_layer reads lambda_bias, swstr_k9_scale, ump_scale from data/calibration_params.json.
    • generate_pick reads lambda_bias and prop_min_prob_overrides from the same file; keeps MIN_PROB as a global floor with per-prop overrides.

Written for commit a6580f1. Summary will update on new commits.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Warning

Rate limit exceeded

@jaayslaughter-cpu has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 33 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 89dfaf9a-1a15-4211-b4d6-a823e254d1ac

📥 Commits

Reviewing files that changed from the base of the PR and between 42b06e0 and a6580f1.

📒 Files selected for processing (4)
  • apply_priority_fixes.py
  • calibration_layer.py
  • generate_pick.py
  • xgb_k_layer.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pr-567-priority-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ecc-tools
Copy link
Copy Markdown
Contributor

ecc-tools Bot commented May 15, 2026

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@deepsource-io
Copy link
Copy Markdown

deepsource-io Bot commented May 15, 2026

DeepSource Code Review

We reviewed changes in 42b06e0...a6580f1 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Docker May 15, 2026 3:00a.m. Review ↗
JavaScript May 15, 2026 3:00a.m. Review ↗
Python May 15, 2026 3:00a.m. Review ↗
SQL May 15, 2026 3:00a.m. Review ↗
Secrets May 15, 2026 3:00a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@jaayslaughter-cpu jaayslaughter-cpu merged commit 54c0281 into main May 15, 2026
6 of 9 checks passed
Comment thread apply_priority_fixes.py

# Step 2: Stamp _wind_deg on the weather dict after it's built
# Find where wind_speed is extracted from the API response
wind_read_pattern = re.search(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unused variable 'wind_read_pattern'


An unused variable takes up space in the code, and can lead to confusion, and it should be removed. If this variable is necessary, name the variable _ to indicate that it will be unused, or start the name with unused or _unused.

Comment thread apply_priority_fixes.py
log.info("Fix 3: wind_direction_10m already in weather fetch — checking _wind_deg stamping")

# Step 1: Add wind_direction_10m to API request params
old_hourly = '"hourly": "wind_speed_10m,wind_direction_10m,temperature_2m",'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unused variable 'old_hourly'


An unused variable takes up space in the code, and can lead to confusion, and it should be removed. If this variable is necessary, name the variable _ to indicate that it will be unused, or start the name with unused or _unused.

Comment thread apply_priority_fixes.py
log.info("Fix 1: Hit blend already at 90/10 — skipping")
return True

new_str = f"0.90 * raw_p + 0.10 * _xhp"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

`f-string` used without any expression


It is wasteful to use f-string mechanism if there are no expressions to be extrapolated. It is recommended to use regular strings instead.

Comment thread apply_priority_fixes.py
# Look for the pattern where _wind_speed is stamped
old_wind_stamp = '"_wind_speed": round(float(wind_speeds[idx'
if old_wind_stamp in content:
idx = content.find(old_wind_stamp)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Redefining name 'idx' from outer scope


The local variable name hides the variable defined in the outer scope, making it inaccessible and might confuse.

Comment thread apply_priority_fixes.py
if m:
fw, xgb = float(m.group(1)), float(m.group(2))
if abs(fw - 0.90) < 0.01:
print(f" ✅ Hit blend at 90/10 — correct")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

`f-string` used without any expression


It is wasteful to use f-string mechanism if there are no expressions to be extrapolated. It is recommended to use regular strings instead.

Comment thread apply_priority_fixes.py
print(f" ✅ Hit blend at 90/10 — correct")
else:
print(f" ❌ Hit blend at {fw:.0%}/{xgb:.0%} — should be 90/10")
print(f" Reason: Brier 0.2668 > null 0.25 — model adding noise")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

`f-string` used without any expression


It is wasteful to use f-string mechanism if there are no expressions to be extrapolated. It is recommended to use regular strings instead.

Comment thread calibration_layer.py
# Reads data/calibration_params.json written by propiq_adaptive_calibration.py.
# This ensures calibration_layer.py uses the same lambda_bias and
# swstr_k9_scale as prop_enrichment_layer.py — previously they were different.
import os as _os, json as _json
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reimport 'json' (imported line 23)


A module or an import name is reimported multiple times. This can be confusing and should be fixed.
Please refer to the occurrence message to see the reimported name and the line number where it was imported for the first time.

@codacy-production
Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 5 high · 1 medium

Alerts:
⚠ 6 issues (≤ 0 issues of at least minor severity)

Results:
6 new issues

Category Results
ErrorProne 5 high
Security 1 medium

View in Codacy

🟢 Metrics 276 complexity

Metric Results
Complexity 276

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces apply_priority_fixes.py, a script to automate several priority fixes across the PropIQ system, including model blend adjustments, Marcel layer integration, and calibration parameter synchronization. Updates were also applied to calibration_layer.py, generate_pick.py, and xgb_k_layer.py. Feedback points out several issues in the automation script: a regex mismatch using the wrong variable name for hit blends, a missing wind speed pattern, and imprecise string replacement logic that causes duplicated comments in the generated code.

Comment thread apply_priority_fixes.py
Comment on lines +56 to +69
old_pattern = re.search(r"(0\.\d{2}) \* raw_p \+ (0\.\d{2}) \* _xhp", content)
if not old_pattern:
log.warning("Fix 1: Hit blend pattern not found in xgb_k_layer.py")
return False

old_str = old_pattern.group(0)
fw = float(old_pattern.group(1))
xgb = float(old_pattern.group(2))

if abs(fw - 0.90) < 0.01:
log.info("Fix 1: Hit blend already at 90/10 — skipping")
return True

new_str = f"0.90 * raw_p + 0.10 * _xhp"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The regex pattern and the replacement string use the variable name raw_p, but the target file xgb_k_layer.py uses model_prob for the hit blend calculation. This mismatch will cause the script to fail to identify the pattern and, if it did match, it would introduce an undefined variable error.

Suggested change
old_pattern = re.search(r"(0\.\d{2}) \* raw_p \+ (0\.\d{2}) \* _xhp", content)
if not old_pattern:
log.warning("Fix 1: Hit blend pattern not found in xgb_k_layer.py")
return False
old_str = old_pattern.group(0)
fw = float(old_pattern.group(1))
xgb = float(old_pattern.group(2))
if abs(fw - 0.90) < 0.01:
log.info("Fix 1: Hit blend already at 90/10 — skipping")
return True
new_str = f"0.90 * raw_p + 0.10 * _xhp"
# Find current hit blend pattern
# Pattern: "0.70 * model_prob + 0.30 * _xhp" or similar
old_pattern = re.search(r"(0\.\d{2}) \* model_prob \+ (0\.\d{2}) \* _xhp", content)
if not old_pattern:
log.warning("Fix 1: Hit blend pattern not found in xgb_k_layer.py")
return False
old_str = old_pattern.group(0)
fw = float(old_pattern.group(1))
xgb = float(old_pattern.group(2))
if abs(fw - 0.90) < 0.01:
log.info("Fix 1: Hit blend already at 90/10 — skipping")
return True
new_str = f"0.90 * model_prob + 0.10 * _xhp"

Comment thread apply_priority_fixes.py
Comment on lines +208 to +210
wind_patterns = [
'"wind_speed":', '"_wind_speed":', 'wind_spd =', 'wind_speed ='
]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The wind_patterns list is missing the key "wind_speed_mph":, which is used in the current version of tasklets.py (line 1907). This will prevent the script from finding the correct insertion point for the wind bearing data extraction.

Suggested change
wind_patterns = [
'"wind_speed":', '"_wind_speed":', 'wind_spd =', 'wind_speed ='
]
wind_patterns = [
'"wind_speed_mph":', '"wind_speed":', '"_wind_speed":', 'wind_spd =', 'wind_speed ='
]

Comment thread apply_priority_fixes.py
Comment on lines +344 to +347
content = content.replace(
"MIN_PROB: float = 0.30",
"MIN_PROB: float = 0.30 # hard floor — per-prop overrides in _MIN_PROB_GPS"
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The string replacement logic here is too broad. By replacing only the variable assignment part, it leaves the original trailing comment # hard floor intact in generate_pick.py, resulting in a messy, duplicated comment. It should target the full line including the original comment.

Suggested change
content = content.replace(
"MIN_PROB: float = 0.30",
"MIN_PROB: float = 0.30 # hard floor — per-prop overrides in _MIN_PROB_GPS"
)
if "MIN_PROB: float = 0.30 # hard floor" in content:
content = content.replace(
"MIN_PROB: float = 0.30 # hard floor",
"MIN_PROB: float = 0.30 # hard floor — per-prop overrides in _MIN_PROB_GPS"
)

Comment thread generate_pick.py
BREAK_EVEN: float = 0.5336 # -115 standard UD line break-even
MAX_PROB: float = 0.82 # hard ceiling — prevents over-confidence
MIN_PROB: float = 0.30 # hard floor
MIN_PROB: float = 0.30 # hard floor — per-prop overrides in _MIN_PROB_GPS # hard floor
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This line contains a messy, duplicated comment (# hard floor) likely caused by an imprecise string replacement in the apply_priority_fixes.py script. It should be cleaned up for better readability.

Suggested change
MIN_PROB: float = 0.30 # hard floor — per-prop overrides in _MIN_PROB_GPS # hard floor
MIN_PROB: float = 0.30 # hard floor — per-prop overrides in _MIN_PROB_GPS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant