Wire XGBoost ML model into review UI #65
Loading…
Reference in a new issue
No description provided.
Delete branch "refs/pull/65/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
ml_confidence_scorecolumn to posts (nullable float, scored at fetch time by XGBoost classifier)MLInferenceServicesingleton loads model artifacts at startup; gracefully degrades when absentABS(score - 0.5) ASC, NULLs last).prev, offloads CPU work withasyncio.to_threadCloses #64
Re: pickle deserialization without integrity verification (WuMing HIGH)
Valid finding —
load_artifactscallsjoblib.loadon user-controlled file paths, and joblib uses pickle internally.In this deployment context the threat model is fairly narrow: an attacker needs write access to the mounted models volume. If they have that, they likely already have container exec or FS access that yields more direct attack paths. The models are generated by this application itself (the same service writes at 02:00, then reads at startup), so the trust chain is: application trains → application loads.
That said, the concern is real. On serialisation format alternatives:
Pipelineobjects or TF-IDF vocabulary dictsskl2onnx, but adds non-trivial dependency weight and the TF-IDF vocabulary round-trip through ONNX is awkward; disproportionate for a hobby projectMore appropriate mitigations for this deployment pattern:
save_artifacts, write a.sha256file; verify it beforeload_artifacts; this catches race-condition tampering between the training write and the load callWill track as a follow-up issue rather than adding complexity to this PR.
Re: ML_INTEGRATION_GUIDE.md checklist
Good catch — those three items (Alembic migration, model inference in review UI, nightly retraining) are all done in this PR. Committed
d09901aticking them off, also updated the status header from "not started" to "in progress" and corrected the Inference architecture line which still said "not yet wired into the web app".The fourth item (per-stream model thresholds) remains open — not in scope for this PR.