Repository navigation
feat: pH interval, deviation ranges and the total-N urea rule (#303, #304, #305) - #306
Merged
Merged
Conversation
…red total N (#303) Total N is nitrate + ammonium + urea. A declared nitrate and a positive ammonium now determine the total, with urea declared or zero: the forms are scored once and a disagreeing total is rejected before fitting. An explicit zero N_NH4 asks for nothing (decision G24) and does not determine the total.
target_ph may be (low, high), a list in the JSON workflow, and flahax batch takes --ph-min with --ph-max. The interval is judged against its bounds with no midpoint: a mix already inside needs no reagent and a mix outside is moved to the nearest bound. Stages that plan a reagent to one pH (nitric, titration, acid selection) report unsupported_ph_interval instead of choosing a point. The summary and report state the interval and the bound aimed at.
…Q24, Q26, Q28, Q30) (#305) A user-declared symmetric percentage with per-nutrient shortage and excess overrides in percent or mg/L, none by default. Assess classifies the result as inside, below or above each range; Require fits with each upper bound as a hard maximum and doubles the weight of a nutrient below its lower bound, keeping an unmet candidate and naming it without widening any range. Ranges apply to positive targets only and never relax a zero target or a declared maximum. Available on recommend, the workflow, the JSON workflow and flahax batch (--range-percent, --range, --require-ranges); the report prints the ranges and the settings are saved with the inputs.
…uired range missed on a blocked recipe The exact coverage gate found the non-mapping override guards, the --ph / --ph-min / --ph-max command errors and the branch where a missed required range meets an already blocked status unexecuted.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #306 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 140 141 +1
Lines 17186 17416 +230
Branches 3494 3550 +56
==========================================
+ Hits 17186 17416 +230
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rafatahmed
marked this pull request as ready for review
November 25, 2026 19:23
This was referenced Nov 25, 2026
Glossary describes fixed A/B; group_tanks returns more than two groups (D7); D4 acceptance runs
#308
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #303. Closes #304. Closes #305.
Closes the remaining Phase 3 items of the contract audit that need code: the total-N urea rule (D2), the pH interval (C5, Q31) and acceptable deviation ranges (C2, Q24/26/28/30). Decisions of 2026-11-25: contract Q8/Q9 amended to match decision G24 and the urea-zero rule; keep decisions G1-G4 for omitted alkalinity (C7); pH interval as
target_ph=(low, high); build Assess and Require together.N150 withN_NO3100 andN_NH430 is now rejected before fitting; a consistent total is scored once. An explicit zeroN_NH4does not determine the total (G24).target_phaccepts(low, high), a list in the JSON workflow, andflahax batchtakes--ph-minwith--ph-max. A mix already inside needs no reagent; otherwise the plan aims at the nearest bound, never a midpoint. Stages that plan a reagent to one pH (nitric, titration, acid selection) reportunsupported_ph_intervalinstead of choosing a point. The summary and report state the interval and the bound aimed at.deviation_rangesonrecommendand the workflow, and--range-percent,--rangeand--require-rangesonflahax batch. A symmetric percentage with per-nutrient shortage/excess overrides in percent or mg/L, none by default; effective ranges are shown. Assess classifies the result as inside, below or above. Require fits with each upper bound as a hard maximum and doubles the weight of a nutrient below its lower bound; an unmet candidate is kept,feasibleis false, the unmet nutrients are named and no range is widened. A zero target and a declared maximum are never relaxed.Limits stated in the docs: Require constrains the nutrient fit before the pH reagent; the final recipe with the reagent is classified in the summary and a miss asks for review. The interactive
flahax mixtakes one pH and no ranges. The Require search is a candidate, not a proof.No conversion, speciation, saturation or EC input changed, so the PHREEQC fixture needs no re-capture (it was re-captured on
maintoday: every number matches).Local checks: ruff clean; 204 of 214 test modules pass (1,798 tests); the 10 heavy modules were run test by test where they exercise the fit (102 of 112 tests OK, 2 over the time cap, 8 not reached). CI is the verifier for the rest.