Two bcfishpass-parity fixes: cluster phase-1 + trace_downstream#188
Merged
NewGraphEnvironment merged 1 commit intomainfrom Apr 30, 2026
Merged
Two bcfishpass-parity fixes: cluster phase-1 + trace_downstream#188NewGraphEnvironment merged 1 commit intomainfrom
NewGraphEnvironment merged 1 commit intomainfrom
Conversation
Fixes #186 — frs_cluster phase-1 + confluence-boost over-credits clusters .frs_cluster_both previously excluded on-spawning rearing segments from the clustering CTE. Removing those segments could shift cluster_minimums into the confluence-boost zone (DRM less than confluence_m) and validate clusters that bridge_gradient should deny. bcfishpass keeps on-spawning segments in clusters so its cluster_min stays high and the confluence boost does not fire. Phase-1 protection now lives only in the final UPDATE: on-spawning segments retain label_cluster TRUE regardless of cluster outcome, but cluster boundaries used for phase-2 / phase-3 testing are unchanged. Reproduction case: link MORR ST cluster 502 (Nado Creek + tributary 360704379, 12.58 percent gradient between trib confluence and downstream spawning) — bcfp denies the trib; fresh now matches. Fixes #187 — frs_trace_downstream FWA-averaged gradient hides barriers .frs_trace_downstream previously used whse_basemapping.fwa_downstreamtrace which iterates FWA-original linear_feature_id rows with feature-averaged gradients. Localized barriers on a sub-piece of a long FWA feature (e.g. a 7 m, 84 percent lake-outlet drop inside an otherwise flat 3 km feature) are invisible to that approach. Switched to a FWA_Downstream predicate join against the broken streams table arg — same pattern .frs_cluster_both phase-3 already uses. Localized gradients produced by frs_network_segment are now visible to the trace. New required columns in origins_sql: wscode_ltree, localcode_ltree (.frs_connected_waterbody is the only caller; updated). Reproduction case: link KISP SK at Kitwancool Lake (waterbody_key 329229702, area 780.6 ha). bcfp s load_habitat_linear_sk correctly stops at the lake-outlet drop; fresh now matches. Verified end-to-end: KISP SK spawning rollup pre-fix +42.3 percent, post-fix 0.0 percent exact match. Pre-existing test failure on test-frs_params.R:92 is unrelated to these changes (was failing on main before this branch). Version bump 0.24.1 -> 0.25.0. 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
Two bcfishpass-parity fixes surfaced during link's WSG-coverage expansion (link's MORR + KISP runs, 2026-04-30).
Fixes #186 —
frs_clusterphase-1 + confluence-boost over-credits clusters.frs_cluster_bothpreviously excluded on-spawning rearing segments from the clustering CTE. Removing those segments could shiftcluster_minimumsinto the confluence-boost zone (DRM <confluence_m) and validate clusters thatbridge_gradientshould deny. bcfishpass keeps on-spawning segments in clusters so itscluster_minstays high and the confluence boost doesn't fire.Phase-1 protection now lives only in the final
UPDATEstep. Cluster boundaries used for phase-2 / phase-3 testing are unchanged.Reproduction: link's MORR ST cluster 502 (Nado Creek + tributary 360704379, 12.58% gradient between trib confluence and downstream spawning). bcfp denies the trib; fresh now matches.
Fixes #187 —
.frs_trace_downstreamFWA-averaged gradient hides barriers.frs_trace_downstreampreviously usedwhse_basemapping.fwa_downstreamtrace, an iterator returning FWA-originallinear_feature_idrows with feature-averaged gradients. Localized barriers on a sub-piece of a long FWA feature (e.g. a 7 m, 84% lake-outlet drop inside an otherwise flat 3 km feature) are invisible to that approach.Switched to a
FWA_Downstreampredicate join against the broken streamstablearg — same pattern.frs_cluster_bothphase-3 already uses. New required columns inorigins_sql:wscode_ltree,localcode_ltree(.frs_connected_waterbodyis the only caller; updated).Reproduction: link's KISP SK at Kitwancool Lake (waterbody_key 329229702, 780.6 ha). bcfp's
model/02_habitat_linear/sql/load_habitat_linear_sk.sqlcorrectly stops at the lake-outlet drop; fresh now matches.Test plan
devtools::test()— 837 PASS, 1 FAIL pre-existing ontest-frs_params.R:92(unrelated to these changes)tar_make()for parity rollupSRED ref
Relates to NewGraphEnvironment/sred-2025-2026#24
🤖 Generated with Claude Code