8000 fix: use measured stock solubility and the A/B tank layout (G15-G22) by rafatahmed · Pull Request #230 · rafatahmed/Flahax · GitHub
[go: up one dir, main page]

Skip to content

fix: use measured stock solubility and the A/B tank layout (G15-G22) - #230

Merged
rafatahmed merged 1 commit into
mainfrom
fix/stock-and-tanks
Nov 6, 2026
Merged

rafatahmed merged 1 commit into
mainfrom
fix/stock-and-tanks

Conversation

@rafatahmed
Copy link
Copy Markdown
Owner

Summary

 check_stock_solubility(tanks, ratio, temperature_c, *, table, product_grades, products)
-  historical table only; "assumed floors" -> screening_only / inconclusive
+  1. catalogue physicalProperties.waterSolubility
+  2. historical table (nearest point, no interpolation)
+  3. none -> not_checked "no solubility data"
+  row: basis, source_temperature_c, tank_temperature_c; ok | exceeds (blocks) | not_checked

 group_tanks
-  CLASS_RULES: Ca-P, Ca-SO4 ("gypsum" reason), Mg-P
+  CLASS_RULES: Ca-P, Ca-SO4 (macro products only)
+  micronutrient -> tank A (screened against phosphate only); MgSO4 prefers the phosphate tank
 summarize_batch
-  "needs N tanks; only M supplied"
+  "needs a third tank: P cannot share with Q (rule)"

Evidence

  • Before: Tomato (Howard Resh) needed 3 tanks and ended blocked (exit 3); EDTA chelates and KNO3 had no usable solubility result.
    After: same batch fits tanks A/B, ends requires_review (exit 0); Mn EDTA 400 g/L, Iron EDTA 45 g/L, KNO3 316 g/L are compared with their basis and temperatures shown.
  • New tests/test_tank_layout.py and rewritten solubility tests; a caller rule produces a real "third tank" blocked batch. Full per-module suite passes; scoped coverage of every changed line and branch: no gaps.
  • ~35 older tests encoded the three-tank block and are rewritten to the A/B outcome; blocked-sheet tests now use a batch blocked by a solubility exceedance (ratio=500).
  • PHREEQC golden fixture: not affected (no conversion, speciation or EC change).

Merge Danger

Door: one-way for API/file consumers.

Removed: row statuses screening_only and inconclusive, assumed_density_floor, the screening_g_per_l field, grade/review/interpolation qualification of limits, the Mg-P separation. SolubilityRow gains basis, source_temperature_c, tank_temperature_c. Common tomato/chilli batches change from blocked to requires_review.

Blast Radius: batch/mix status and exit codes, tank assignments, solubility rows in summary/report/sheet.

Deviations to review:

  • The micronutrient-phosphate separation is kept (decision), though G22 lists only Ca-P and Ca-SO4.
  • Magnesium sulfate prefers the phosphate tank (added so B holds it without a calcium product).
  • group_tanks keeps max_tanks=None; the two-tank default is summarize_batch(available_tanks=2).
  • Removed the byte-hash pin on the historical table (it only marked assumed floors). limit_at and product_grades are kept; grades select nothing.
  • Plan named tests/test_tank_grouping.py, which never existed; tests are in tests/test_tank_layout.py.
  • Follow-ups from review (not done): duplicated solubility wording, 4-tuples between helpers, _extra_tank_note belongs on the grouping object. Related bug found: fix: batch console prints "Not available mL" for a solid pH reagent #229.

Closes #226
Closes #227

Stock solubility compares each product with its own catalogue value, then the
historical table, in the value's own basis, with the source and tank
temperatures shown and nothing interpolated. Statuses are ok, exceeds (blocks)
and not_checked ("no solubility data"); screening_only, inconclusive and the
assumed floors are removed.

Tanks follow the A/B layout: calcium and every micronutrient product in tank A,
phosphates, magnesium sulfate and macro sulfates in tank B. The
magnesium-phosphate rule is removed and calcium-sulfate applies to macro
products only. A batch that needs a tank beyond the available ones names the
pair and the rule. Tests that encoded the old three-tank block are rewritten.

Closes #226
Closes #227
@rafatahmed rafatahmed added the bug Something isn't working label Nov 6, 2026
@rafatahmed rafatahmed self-assigned this Nov 6, 2026
@read-the-docs-community
Copy link
Copy Markdown

@codecov
codecov Bot commented Nov 6, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5ed52d6) to head (f7e81a6).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #230   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines        13130     13142   +12     
  Branches      2573      2571    -2     
=========================================
+ Hits         13130     13142   +12     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rafatahmed
rafatahmed marked this pull request as ready for review November 6, 2026 18:18
@rafatahmed
rafatahmed merged commit be38e16 into main Nov 6, 2026
13 checks passed
@rafatahmed
rafatahmed deleted the fix/stock-and-tanks branch November 6, 2026 18:18
rafatahmed added a commit that referenced this pull request Nov 7, 2026
fix: use measured stock solubility and the A/B tank layout (G15-G22)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

1 participant

0