[18.0][FIX] ddmrp_cron_actions_as_job: procure only on fully refreshed buffer #659
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 322 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.346
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #659"
general
weight: 0.35
divad1196
Alternative to #644 that keeps its fix but avoids most of its cost.
Problem (from #644, by @divad1196)
When a move is confirmed,
stock.move._update_ddmrp_nfpdelays onecron_actionsjob per buffer side:only_nfp="out"for demand and"in"for supply. Each job refreshes one side of the net flow position and then runsdo_auto_procure. If the job for the other side of the same buffer is still pending, the procurement is based on an outdated quantity for that side. It can then order something that a confirmed receipt already covers.Approach
The first two commits are @divad1196's from #644, cherry-picked unchanged:
The ddmrp core change from #644 (
stock_move.py) is left out.The third commit refreshes both sides only when it is needed. Before running a partial refresh, the job looks for a pending job that refreshes the other side of the same buffer:
queue_jobdoes when enqueuing.Without
queue_jobdelaying the jobs, behaviour doesn't change.Measurements
On a production copy with ~50k buffers, I validated a bunch of deliveries and receipts, then ran the same resulting jobs under each variant:
|
cron_actionsjob time | Partial (current) | Always full (#644) | Conditional (this PR) ||---|---|---|---|
| Deliveries (202 jobs) | 54.5 s | 78.8 s (+45%) | 56.8 s (+4%) |
| Receipts (253 jobs) | 53.1 s | 77.3 s (+46%) | 55.5 s (+4.5%) |
inand anoutjob pending, caused by the chained moves of the receipt.How often the issue happens
Over 40 days of job history on the same database:
So the race is real but rare. Making every job ~45% more expensive to cover it seemed too high a price.
Tests