Wire frs_order_child as link methodology (default off)#97
Merged
NewGraphEnvironment merged 3 commits intomainfrom May 1, 2026
Merged
Wire frs_order_child as link methodology (default off)#97NewGraphEnvironment merged 3 commits intomainfrom
NewGraphEnvironment merged 3 commits intomainfrom
Conversation
Document the wire-up state and design decisions before parking. Anchored on fresh#158 issue body as canonical design doc — this PWF captures the implementation summary, HORS calibration, and methodology decision deferred to next session. The link wiring code itself stays uncommitted on this branch until a methodology decision is made (ship default-on after BABL inspection, or ship infrastructure with bypass=no defaults). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…parking bypass Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds parametric infrastructure for the rearing stream-order bypass — small streams plugging into large rivers credited as rearing despite low/missing FWA channel-width estimates. Closes fresh#158 on the link side. Four per-species columns in dimensions.csv (both bundles), all opt-in via rear_stream_order_bypass: yes/no: rear_stream_order_parent_min parent_order_min (default 5) rear_stream_order_child_min child_order_min (default 1) rear_stream_order_child_max child_order_max (default 1) rear_stream_order_distance_max distance_max (default empty) lnk_rules_build emits the values into a channel_width_min_bypass: block on the rear stream-edge rule. lnk_pipeline_classify reads the block and calls fresh::frs_order_child per species post-classification, gated on rear_stream_order_bypass. Both bundles ship bypass: no for all species. The infrastructure is parametric and tested but disabled by default. Re-enable per species via dimensions.csv. The 4-WSG regression (HARR / HORS / LFRA / BABL) is byte-identical to the pre-wire baseline with bypass=off, confirming the wiring is purely additive when disabled. Updates inst/extdata/configs/dimensions_columns.csv xref doc with all four new columns and refreshes the rear_stream_order_bypass entry (was stale — said "currently inert"). Map-helper data-raw/maps/_lnk_map_compare.R updated alongside: split the categorical axis layer into separate link_only / bcfp_only / both toggles (plus split spawning_link / spawning_bcfp), and add popups to the streams_all underlay for segment-level inspection. Bumps fresh dep to >= 0.27.5 for the renamed bypass YAML schema (stream_order → stream_order_min + stream_order_max). Related: link#23 (CH spawning misread, closed not-a-bug). PWF for the wire-up at planning/active/. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 1, 2026
NewGraphEnvironment
added a commit
that referenced
this pull request
May 3, 2026
…le tests (#109) * Refresh config provenance + regenerate rules.yaml + fix stale tests Pre-trifecta homework: catch staleness in the config layer before launching the 3-host distributed run, so we're not chasing ghosts. Findings (from new `data-raw/audit_configs.R` + lnk_config_verify): - Both bundles' rules.yaml diverged from `lnk_rules_build()` regen (committed via the v0.21-v0.25 PR series; no follow-up regen). - `provenance:` checksums in both config.yaml were stale for 4 files each (rules.yaml + dimensions.csv + parameters_fresh.csv + overrides/wsg_species_presence.csv) reflecting the recent edits in #94/#96/#97/#103/#106. - 4 stale tests in test-lnk_rules_build.R asserted on the old `stream_order` field name (since renamed to `stream_order_min`/ `stream_order_max` in fresh#198) and on the bcfishpass-bundle's old "every species' rear stream rule has in_waterbody=false" invariant (CO + ST flipped to `rear_stream_in_waterbody=yes` in dimensions.csv). Fixes: - Regenerate both bundles' rules.yaml (only date-stamp diff vs old — byte-identical-after-strip, semantically identical). - Recompute provenance: checksum + shape_checksum for the 4 drifted files in each bundle's config.yaml. Surgical line-replace preserves comments + key order. - Update 3 test assertions: rename `stream_order` -> `stream_order_min` + `stream_order_max`; scope the in_waterbody check to spawn rules (universal in bcfishpass) instead of all stream-edge rules. - New `data-raw/audit_configs.R` reports drift across all layers (provenance, rules-regen, species axis consistency, undeclared override files) — re-runnable before each trifecta or provincial run. - New `data-raw/regen_provenance.R` runs the surgical fixes. Verification: - `lnk_config_verify` reports drifted=0/12 for both bundles. - ADMS rollup post-regen byte-identical to cached pre-regen baseline (data-raw/logs/20260502_09_post_regen_adms.rds vs comparison_bcfishpass_ADMS in _targets/). - `devtools::test()` 668 PASS / 0 FAIL (was 10 FAIL pre-homework). Out of scope (filed separately or deferred): - 3 orphan CSVs per bundle in overrides/ (`dfo_known_sockeye_lakes.csv`, `wcrp_watersheds.csv`, `user_modelled_crossing_fixes_20240825.csv`) not declared in config.yaml and not referenced by any R/test. - Legacy top-level `parameters_habitat_*` files still consumed by `data-raw/run_nge.R`; migrate to per-bundle config first then remove. Relates to NewGraphEnvironment/sred-2025-2026#24 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * compare_bcfishpass_wsg: NA semantic + species filter (link#108 evidence) Two related changes for cleaner rollup output when running default-bundle species (GR / KO / RB) that bcfp doesn't model. - Reference values fall back to NA (not 0) when bcfp doesn't have a `habitat_linear_<sp>` table for the species. Applied to all three reference paths: linear km, lake_rearing_ha, wetland_rearing_ha. Distinguishes "real measured zero" from "not modelled by bcfp". diff_pct then cleanly resolves to NA for these species via the existing logic (NA bcfp_value → NA diff_pct). - New `species` parameter (default NULL) filters the rollup to the intersection of the requested set with `lnk_pipeline_species()`. Pass `c("BT","CH","CM","CO","PK","SK","ST","WCT")` to drop GR/KO/RB entirely from the comparison table. Verification: PARS default run (data-raw/logs/20260502_10_pars_default_grkorb.rds) shows GR/KO/RB classified end-to-end: - KO: spawning 3.83 km, lake_rearing 377 ha (lake-only methodology) - RB: spawning 1,557 km, rearing 2,462 km, lake 1,839 ha, wetland 7,796 ha - GR: spawning 984 km, rearing 1,366 km, lake 1,566 ha All three correctly show bcfishpass_value=NA + diff_pct=NA. Closes #108 Relates to NewGraphEnvironment/sred-2025-2026#24 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Wires
fresh::frs_order_child(fresh#158) into link's pipeline as link methodology, not bcfp parity. Captures the biology of small streams plugging directly into large rivers — fish use these reaches for rearing despite low/missing FWA channel-width estimates.Four new per-species columns in
dimensions.csv(both bundles), all opt-in viarear_stream_order_bypass: yes/no:frs_order_childargrear_stream_order_parent_minparent_order_minrear_stream_order_child_minchild_order_minrear_stream_order_child_maxchild_order_maxrear_stream_order_distance_maxdistance_maxlnk_rules_buildemits the values into achannel_width_min_bypass:block on the rear stream-edge rule.lnk_pipeline_classifyreads the block and callsfrs_order_childper species post-classification, gated onrear_stream_order_bypass.Both bundles ship
bypass: nofor all species. The infrastructure is parametric and tested but disabled by default. Re-enable per species viadimensions.csvonce a methodology decision is made (BABL inspection per fresh#158).Verification
4-WSG regression (HARR / HORS / LFRA / BABL) byte-identical to pre-wire baseline with bypass=off — confirming the wiring is purely additive when disabled. Log:
data-raw/logs/20260501_26_regress_4wsg_bypass_off_v2.txt.Calibration runs with bypass enabled (saved as comparison snapshots in
data-raw/maps/):rearing_streamThese are exploration data — not the shipped defaults. Methodology decision parked pending wider sample.
Map helper improvements
data-raw/maps/_lnk_map_compare.Rupdated alongside:link_only/bcfp_only/bothtoggles (plusspawning_link/spawning_bcfp)streams_allunderlay (linear_feature_id | blue_line_key | DRM | edge | order | grad | gnis_name)Test plan
devtools::test()— new tests for therear_stream_order_child_min/maxcolumns pass; pre-existing failures unchangedinst/extdata/configs/dimensions_columns.csvxref updated with all four new columns + correctedrear_stream_order_bypassentry (was stale — said "currently inert")Bumps fresh dep to
>= 0.27.5for the renamed bypass YAML schema (stream_order→stream_order_min+stream_order_max).Related: link#23 (CH spawning misread, closed not-a-bug). fresh#158 is the canonical design doc. PWF at
planning/active/.🤖 Generated with Claude Code