Score each watershed group on its own habitat model in lnk_habitat_validate() (#299) - #301
Merged
NewGraphEnvironment merged 7 commits intoOct 2, 2026
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
.lnk_habitat_method_read() and .lnk_wsg_model() sit beside .lnk_habitat_method_csv(); classify now uses them, and the validator will in the next commit, so the two cannot resolve a group differently. The resolver is fresh's .frs_habitat_models(), registered as a required internal in the preflight. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
lnk_habitat_validate() rebuilt every predicate on the channel-width model, so on a group a bundle puts on mad the miss reasons tested a size the classification never used. It now resolves each scored group's model from cfg's method table (fresh's own rule, shared with classify), builds the predicates with frs_habitat_predicates(model =), relaxes the model's size column, and tests width_null on mad_m3s for mad groups. mad_m3s is joined from fwa_stream_networks_discharge on linear_feature_id, since the persist does not carry it. Reason labels are unchanged (width means the group's size dimension); observations gain model and mad_m3s, summary gains model. New reason no_mad_threshold: a mad miss that a MAD range alone would admit, for the species that have none (BT, GR, KO, RB). cw output is identical apart from the new columns (ADMS on fresh_default, branch vs main). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
Roxygen, RUNBOOK §7, research/habitat_validation.md and CLAUDE.md now say how a mad group is scored and what the shared reason labels mean there. data-raw/habitat_validate.R carries model into misses.csv and bins a mad row's size under "mad", so misses_binned.csv still sums to misses.csv. A follow-up issue for adding MAD thresholds to BT, GR, KO and RB is drafted in planning/active/, not filed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
cw: validator output on fresh_default identical to main apart from the new columns. mad: ADMS modelled into a scratch schema with the method table swapped; main labels 27 BT rearing misses post_predicate (the cw predicate it rebuilds is looser than the one that classified the run), the branch labels them no_mad_threshold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
NewGraphEnvironment
deleted the
299-lnk-habitat-validate-scores-mad-watersh
branch
October 2, 2026 13:56
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.
Summary
lnk_habitat_validate()re-tests each observation's segment on the habitat model its watershed group classified on (cwormad), from the method table in thecfgit is given. The model is resolved by fresh's own.frs_habitat_models(), whichlnk_pipeline_classify()now shares.madgroup, the predicates come fromfrs_habitat_predicates(model = "mad"), size relaxation movesmad_m3s(joined fromfwa_stream_networks_dischargeonlinear_feature_id, since the persist does not carry it), andwidth_nulltests discharge. Reason labels are shared across models;observationsgainsmodelandmad_m3s,summarygainsmodel.no_mad_threshold: amadmiss that a MAD range alone would admit, for the species that have none (BT, GR, KO, RB). A miss whose gradient also fails readsfails_gradient_and_width; one with no discharge on its line readswidth_null, as on cw.frs_habitat_predicates(model)and.frs_habitat_models. The miss-binning driver carriesmodel.Related Issues
madmodel against observations) and Tune MAD (discharge) thresholds for BT, GR, KO and RB rather than leave them missing #302 (adding MAD thresholds)Test plan
R CMD check: 0 errors. The 3 warnings and 2 notes are pre-existing (non-ASCII in other files, Rd cross-refs,setNames/getFromNamespaceglobals) and touch no line this branch addsfresh_default, branch vs main,observationsidentical apart from the new columns andsummaryidentical apart frommodel(94 locations)madlive: ADMS modelled onmadinto a scratch schema, then validated with branch and with main. Main calls 27 BT rearing missespost_predicate, the branchno_mad_threshold. Seedata-raw/logs/habitat_validate_299/README.mdNotes
no_mad_thresholdfixes: it relaxed gradient too, and it ignored a NULL discharge. Round 3 named the mechanism, a hand-copied relaxation ladder, and the loop ended on two enumerations rather than a quiet round. The first covered every miss arm × model × NULL pattern, evaluated in Postgres. The second was a test of the missing-range rule against fresh, case by case.post_predicate, which is now recorded in CLAUDE.md.lnk_pipeline_classify(method_csv =)) is not detected; swap the table on thecfgpassed to the validator.🤖 Generated with Claude Code
https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx