Skip to content

Add falls to break_order — fix segmentation drift (Fixes #96)#99

Merged
NewGraphEnvironment merged 4 commits intomainfrom
96-falls-break-order
May 2, 2026
Merged

Add falls to break_order — fix segmentation drift (Fixes #96)#99
NewGraphEnvironment merged 4 commits intomainfrom
96-falls-break-order

Conversation

@NewGraphEnvironment
Copy link
Copy Markdown
Owner

Summary

falls was loaded into <schema>.falls and consumed for access gating + obs/habitat lift but never used as a segmentation break source, despite R/lnk_pipeline_break.R lines 10-13 documenting bcfp's order as observations → gradient_minimal → falls → barriers_definite → habitat_endpoints → crossings. When two falls sat close together with no other break source between them, the resulting fresh.streams segment spanned the second fall, leaving its upper portion incorrectly classified as accessible.

Fix

  • falls = paste0(schema, ".falls") added to source_tables in R/lnk_pipeline_break.R
  • "falls" added to break_order default vector (between gradient_minimal and barriers_definite)
  • "falls" added to pipeline.break_order in both inst/extdata/configs/{bcfishpass,default}/config.yaml
  • Falls are NOT minimal-reduced — each fall is its own barrier (unlike gradient barriers which go through frs_barriers_minimal)

Verification

HORS BLK 356357296 evidence case: segment 12671 (1447 m straddling fall #2 at DRM 67565) split into 12677 (17 m below, accessible) + 12678 (1429 m above, accessible=FALSE). Log: data-raw/logs/20260501_27_preflight_hors_falls_break.txt.

HARR BLK 356361157 (7 falls in 13 km): all 7 fall positions now have segment breaks. Log: data-raw/logs/20260501_28_preflight_harr_falls_break.txt.

4-WSG regression (HARR/HORS/LFRA/BABL) vs pre-#96 baseline at data-raw/logs/provincial_parity/:

WSG diff_rows Total km removed Notes
HARR 2 −1.27 BT only
HORS 2 −2.89 BT only; affected segment is edge_type 1250 (Horsefly River construction line) so rearing_stream metric unchanged
LFRA 14 ~−6 7 species × ~0.43 km each
BABL 12 ~−12 4 species × 0.94–1.59 km each

All deltas negative — fix correctly removes segments above falls. Direction is structurally right regardless of whether each removal closes or slightly deepens the bcfp gap.

Test plan

Map cache helper data-raw/maps/_lnk_map_compare.R hardened alongside — stale 0-row caches (left when the pipeline runs for one WSG and the map is rendered for another) now refetch instead of erroring on missing CRS.

🤖 Generated with Claude Code

NewGraphEnvironment and others added 4 commits May 1, 2026 15:51
Methodology decision parked pending BABL inspection — see archive README.
Clears planning/active for link#96 (falls in break_order) work.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Falls not used as segmentation break source — implementation drift
from documented break_order. Five-phase plan: fix + tests + HORS
verification + 4-WSG regression + research doc + ship.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
R/lnk_pipeline_break.R lines 10-13 documented the bcfp break order as
observations → gradient_minimal → falls → barriers_definite →
habitat_endpoints → crossings, but the source_tables list and
break_order default both omitted falls. Result: the FWA stream network
was never broken at fall positions. Where two falls sit close together
(no other break source in between), the resulting segment spanned
across the second fall, leaving its upper portion incorrectly
classified as accessible.

Fix:
- Add `falls = paste0(schema, ".falls")` to source_tables.
- Add "falls" to the break_order default vector.
- Add "falls" to both bundle configs' pipeline.break_order
  (bcfishpass + default).
- Update the # Break sources documentation table to include the falls
  entry (each fall is its own barrier; not minimal-reduced).

HORS verification (the issue's evidence case): BLK 356357296 segment
12671 (1447m straddling the second fall at DRM 67565) split into
12677 (17m below) + 12678 (1429m above, now accessible=FALSE).
Total rearing_stream unchanged on HORS (the affected segment is
edge_type 1250 Horsefly River construction line, excluded from the
rearing_stream metric); broader `rearing` total dropped 1.43 km.

HARR verification: BLK 356361157 (7 falls in 13km range) — all 7
fall positions now have segment breaks. Rollup diff vs pre-#96
baseline: BT rearing -0.63 km, BT rearing_stream -0.64 km. Other
species/metrics unchanged.

Map cache helper hardened — stale 0-row caches (left behind when the
pipeline runs for one WSG and the map is rendered for another) now
refetch instead of erroring on missing CRS.

PWF Phase 1 + 3 checkbox-flipped, Phase 4 (4-WSG regression) next.

Fixes #96

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Phase 2 (tests) folded into Phase 5 ship commit:

- 2 new unit tests in tests/testthat/test-lnk_pipeline_break.R:
  1. Falls is wired into source_tables — calling the pipeline with
     break_order=c("falls","observations") hits w_bulk.falls then
     w_bulk.observations_breaks in that order
  2. Default break_order (cfg$pipeline$break_order = NULL) includes
     falls between gradient_minimal and barriers_definite per the
     docstring's documented order
- 33 PASS in test-lnk_pipeline_break.R (was 29 — 4 new expectations
  across 2 test_that blocks)

Research doc:
- New § "falls in break_order (#96)" in research/bcfishpass_comparison.md
  with evidence trace (HORS BLK 356357296 segment 12671 split at
  DRM 67565) and 4-WSG regression table
- Added row to "Key fixes during comparison" table

DESCRIPTION + NEWS bumped 0.22.0 → 0.23.0.

Closes the implementation drift surfaced in link#96. PWF Phase 1+3
already shipped at commit 743e1f8; this commit closes Phase 2 + 5.

Fixes #96

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@NewGraphEnvironment NewGraphEnvironment merged commit 5fdd378 into main May 2, 2026
1 check passed
@NewGraphEnvironment NewGraphEnvironment deleted the 96-falls-break-order branch May 2, 2026 08:47
NewGraphEnvironment added a commit that referenced this pull request May 2, 2026
PR #99 merged. Clears planning/active for the next task.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant