fix: resolve open CodeQL alerts (float widening, workflow permissions) - #22
Conversation
Two high alerts (cpp/integer-multiplication-cast-to-long): forest serving multiplied f->lr (float) by a float tree value before widening to the double accumulator, so the product could overflow to infinity, and under x87 excess precision vary by platform, before the widening. Promote to double before the multiply in both spots, matching the trainer (predict-train.c already does). Two medium alerts (actions/missing-workflow-permissions): wheels.yml had no permissions block, so the build jobs got the default token scopes. Default the workflow token to contents:read; the publish job keeps its id-token:write override for PyPI OIDC. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughForest prediction now performs learning-rate multiplication in ChangesForest prediction precision
Workflow token permissions
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CHANGELOG.md`:
- Around line 14-15: The CHANGELOG precision note overstates that full
predictions are computed consistently in double precision. Update the entry to
specifically state that the learning-rate/tree-value product and forest
accumulation use f64, while acknowledging that predict0_reg_tree_value() and
forest_tree_value() still produce f32 values; keep the documentation standalone.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 4d41cbd0-b0fd-4226-95fc-34da08e6d306
📒 Files selected for processing (3)
.github/workflows/wheels.ymlCHANGELOG.mdpredict-student.c
Address review: the fix moved the learning-rate/tree-value product and the forest accumulation to double, but individual tree values are still f32. Say that precisely instead of claiming the whole prediction is computed in double. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Resolves the four open CodeQL alerts on the repo.
High: keep the forest product in double before it overflows (
predict-student.c)predict0_forest_predict_rowaccumulatedf->lr * forest_tree_value(...)withboth operands
float, so the product was computed infloatand only thenwidened to the
doubleaccumulator. That can overflow to infinity, and underx87 excess precision (
FLT_EVAL_METHOD) even differ by platform, before thewidening. Both spots now cast to
doublebefore the multiply, matching thetrainer (
predict-train.calready does this).Model weights and
content_hashare unchanged (training was already in double);only served predictions can shift in their least-significant digits, which the
CHANGELOG notes. Resolves the two
cpp/integer-multiplication-cast-to-longalerts.
Medium: explicit workflow permissions (
wheels.yml)wheels.ymldeclared nopermissionsblock, so its build jobs ran with thedefault token scopes. Added a top-level
permissions: contents: read; thepublishjob keeps its ownid-token: writeoverride for PyPI OIDC, sopublishing is unaffected. Resolves the two
actions/missing-workflow-permissionsalerts.
Verification
make test: 209 passed, 35 skipped.main: no findings.Merging re-runs CodeQL on
main, which auto-resolves the four alerts.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation