8000 fix: report precipitation by evidence, never refuse for saturation (G12-G14) by rafatahmed · Pull Request #223 · rafatahmed/Flahax · GitHub
[go: up one dir, main page]

Skip to content

fix: report precipitation by evidence, never refuse for saturation (G12-G14) - #223

Merged
rafatahmed merged 1 commit into
mainfrom
fix/precipitation-screen
Nov 5, 2026
Merged

rafatahmed merged 1 commit into
mainfrom
fix/precipitation-screen

Conversation

@rafatahmed
Copy link
Copy Markdown
Owner

Closes #221

Summary

 assess_saturation(state, conditions, evidence, si_uncertainty)
-  any SI > 0 blocks unless a reviewed evidence record exists (none ships)
-  returns blocking / review / thermodynamic / applicability / blocks
+assess_saturation(state)
+  risk         CaHPO4:2H2O, Gypsum, Calcite above saturation, or an allocated solid
+  information  every other supersaturated phase, with the basis of its constant
+  advisories   Iron(II) fixed oxidation state
+  solids       allocated solids by amount

 callers (acid_selection, ph_adjustment, delivery_plan, equilibrium_delivery)
-  blocks -> reject the candidate / refuse the plan ("precipitation_risk")
+  risk   -> label + warning "The recipe carries a precipitation risk: CaHPO4:2H2O SI 0.16."
+  nothing refuses

 summary.chemistry:  blocking[], review[]  ->  risk[], information[]
 summary.statuses.phase:  blocked | requires_review | assessed  ->  requires_review (risk) | assessed

Documentation (water-to-delivery.md saturation section, five more pages), changelog, 0.7.0 notes and the glossary ("Phase information") are updated.

Evidence

  • Before: Lettuce 2 (Howard Resh), RO water, 0.6 % nitric acid: ph_adjustment was blocked (no_acceptable_reagent); every candidate was rejected with "precipitation risk at the target pH: Hydroxylapatite SI 4.04 (blocks); MnHPO4 SI 3.29 (blocks); Vivianite SI 0.18 (blocks)".
    After: ph_adjustment is requires_review with a reagent selected; the three phases are chemistry.information, MnHPO4 with the basis "unmeasured constant (Plummer et al. 1976 program data)". At --ph 6.5 brushite reads SI 0.16 and the warning is "The recipe carries a precipitation risk: CaHPO4:2H2O SI 0.16."
test_slow_forming_phases_are_information_and_the_recipe_is_produced
  information[MnHPO4].basis == "unmeasured constant (Plummer et al. 1976 program data)"; risk == []; salts non-empty
test_a_supersaturated_phase_no_longer_rejects_every_reagent
  ph_adjustment.status != blocked; error_code != no_acceptable_reagent
test_brushite_above_saturation_labels_the_recipe_without_refusing_it
  risk == [CaHPO4:2H2O SI 0.16]; warnings contain the label; statuses.phase == requires_review
  • New tests/test_precipitation_report.py (batch runs) and a rewritten tests/test_saturation_policy.py (12 tests); tests/test_phase_applicability.py is deleted because every test in it exercised the removed evidence inputs. About 25 older tests that asserted the refusal now assert the report; none was weakened beyond the removed behaviour.
  • Local: the full suite passed in four shards with the optional dependencies (test_file_headers excluded because of a stray untracked .venv on this machine), and a scoped coverage run of the touched modules shows no uncovered changed line or branch. The exact three-OS gate runs in CI.
  • PHREEQC golden fixture: no re-capture was needed, because this change does not alter conversion or speciation numbers. The capture tool itself cannot run on the packaged catalogue (PHREEQC golden fixture: capture tool cannot run on the packaged catalogue; test bypasses label reconciliation #222).

Merge Danger

Door: one-way for API and file consumers.

Removed: the blocks, blocking, review, thermodynamic, applicability, mixing_approved and invalid_solids keys, the conditions, evidence and si_uncertainty parameters, and the precipitation_risk rejection. Anything reading summary.chemistry.blocking/review or statuses.phase == "blocked" must read risk/information instead.

Blast Radius: results and API

  • Plans that used to end blocked on saturation now select a reagent. Overall status can still read blocked for other reasons (for example Lettuce 2 needs three tanks, which is a later change).
  • qualification_lines no longer prints an EC qualifier line when a warning already states it. This is not in the spec; without it the notes view printed the same sentence twice once the reagent was selected (test_notes_once).
  • The supersaturation warnings from irrigation_ec ("X supersaturated ... no kinetic interpretation") are unchanged; the EC rework belongs to the next change.

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

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

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (12abaa2) to head (d2ed741).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #223   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines        13186     13111   -75     
  Branches      2599      2570   -29     
=========================================
- Hits         13186     13111   -75     
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 5, 2026 23:25
@rafatahmed
rafatahmed merged commit 976864a into main Nov 5, 2026
13 checks passed
@rafatahmed
rafatahmed deleted the fix/precipitation-screen branch November 5, 2026 23:26
rafatahmed added a commit that referenced this pull request Nov 7, 2026
fix: report precipitation by evidence, never refuse for saturation (G12-G14)
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

Development

Successfully merging this pull request may close these issues.

Precipitation screen: report risk by evidence, never block on unknowns (G12–G14)

1 participant

0