Skip to content

Fold subsurfaceflow into natural barriers for per-species obs/habitat lift#89

Merged
NewGraphEnvironment merged 4 commits into
mainfrom
88-fold-subsurfaceflow-natural
May 1, 2026
Merged

Fold subsurfaceflow into natural barriers for per-species obs/habitat lift#89
NewGraphEnvironment merged 4 commits into
mainfrom
88-fold-subsurfaceflow-natural

Conversation

@NewGraphEnvironment
Copy link
Copy Markdown
Owner

Summary

Subsurfaceflow positions (FWA edge_type IN (1410, 1425)) were unioned into fresh.streams_breaks with label blocked but never entered <schema>.natural_barriers. lnk_barrier_overrides() runs on natural_barriers, so the per-species observation/habitat-upstream lift never fired for subsurfaceflow — every position hard-blocked all species, even where bcfishpass lifts it.

Folds the standalone .lnk_pipeline_prep_subsurfaceflow body into .lnk_pipeline_prep_natural, gated on cfg$pipeline$break_order containing "subsurfaceflow". bcfishpass's source-of-truth (model_access_bt.sql, model_access_ch_cm_co_pk_sk.sql) defines the natural-barrier set as gradient + falls + subsurfaceflow + user_definite. prep_natural already implemented three of those four — the missing entry was the bug.

Six prep helpers → five.

Behaviour

  • bcfishpass bundle (subsurfaceflow opted in): subsurfaceflow positions appended to natural_barriers → per-species lift applies → bcfp parity restored on Lower-Fraser/coastal WSGs.
  • default bundle (subsurfaceflow not in break_order): early-return inside prep_natural skips the entire subsurfaceflow code path. No <schema>.barriers_subsurfaceflow table, no natural_barriers rows, no streams_breaks rows downstream. Verified bit-identical default rollup (0 of 581 rows changed).

Verification (15-WSG tar_make)

WSG/sp metric pre post
HARR CH rearing_stream km -14.8% -0.32%
HARR CO rearing_stream km -13.3% -0.31%
HARR ST rearing_stream km -11.6% -0.24%
HARR BT rearing_stream km -10.4% -4.19%
LFRA CH/CO/ST all gap <0.6%
HARR blkey 356286055 BT km 0.0 6.509
HORS BT rearing_stream km -7.68% -7.68% (separate mechanism — follow-up)

Distribution: 162 → 171 within ±5%, 123 within ±1%. Per-WSG n_over_5: HARR 11→4, LFRA 6→4, HORS unchanged.

Reproducibility: Second tar_make byte-identical to first. 0 of 1057 link_value rows differ. digest::digest(link_value) matches across runs (5a641892b82604259b0ba168ea093661).

Test plan

  • devtools::test(filter = "lnk_pipeline_prepare") — 44/44 pass
  • /code-check — 3 rounds, fragile cross-statement regex tightened to per-statement match
  • HARR single-WSG pre-flight — 89.5 s, blkey 356286055 → 6.509 km BT
  • Full 15-WSG tar_make — 53m 2s, 33/33 targets
  • Default-bundle invariance — 0 of 581 rows changed
  • Reproducibility re-run — 52m 55s, byte-identical

Architecture note

.lnk_pipeline_prep_subsurfaceflow (added in #82) treated subsurfaceflow as a parallel pipeline phase needing its own helper. prep_natural was always the right home — bcfp's natural-barrier union is gradient + falls + subsurfaceflow, and prep_natural already built the first two. Folding back keeps a single function responsible for "natural barriers in bcfp's sense."

Follow-ups (out of scope)

  • HORS rearing_stream gap (~7%) is unchanged by this PR — separate mechanism, will diagnose in a follow-up issue.
  • Species-dependent dam-class handling in dimensions.csv #83 (anthropogenic dam design) — unaffected by this PR; barrier/potential labels for crossings still don't gate by default.

Fixes #88
Relates to NewGraphEnvironment/sred-2025-2026#24

NewGraphEnvironment and others added 4 commits April 30, 2026 16:59
Baseline planning files: task_plan, findings, progress.

Relates to #88
Subsurfaceflow positions (FWA edge_type 1410/1425) are unioned into
fresh.streams_breaks with label 'blocked' but never entered
<schema>.natural_barriers. lnk_barrier_overrides() runs on
natural_barriers, so the per-species observation/habitat-upstream lift
never fired for subsurfaceflow — every position hard-blocked all
species, even where bcfishpass lifts it.

bcfishpass model_access_bt.sql + model_access_ch_cm_co_pk_sk.sql
define the natural-barrier set as gradient + falls + subsurfaceflow +
user_definite. .lnk_pipeline_prep_natural already implemented three of
those four; the missing entry was the bug.

Folds the standalone .lnk_pipeline_prep_subsurfaceflow body into
.lnk_pipeline_prep_natural, gated on cfg$pipeline$break_order
containing "subsurfaceflow". Default-bundle off-switch preserved
verbatim (no entry, no code path, default rollup bit-identical).

Six prep helpers, five now.

Verification (15-WSG tar_make, bcfishpass-bundle parity):
- HARR CH/CO/ST rearing_stream: -14.8/-13.3/-11.6% to within +/- 0.32%
- HARR BT rearing_stream: -10.4% to -4.19% (residual separate mechanism)
- LFRA CH/CO/ST: closed to within +/- 0.6%
- HARR blkey 356286055: BT credits 6.509 km (was 0)
- Default-bundle bit-identical (0 of 581 rows changed)
- HORS rearing_stream unchanged (-7.68%), follow-up needed

Fixes #88

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- task_plan: tick Phases 2-5 except reproducibility (running)
- progress: code change, code-check, pre-flight, 15-WSG outcome
- verification logs:
  - 20260430_11_preflight_harr_link88.txt (HARR single-WSG, 89.5s)
  - 20260430_12_tar_make_15wsg_link88.txt (full 15-WSG, 53m 2.2s, 33/33)
  - 20260430_1802_rollup_full_post88.csv
  - 20260430_1802_parity_post88.csv
  - 20260430_1802_methodology_post88.csv

Relates to #88
Second tar_make landed byte-identical to first:
- 33/33 targets, 52m 55s
- 0 of 1057 link_value rows differ
- digest of link_value vector: 5a641892b82604259b0ba168ea093661 (matches first run)

Closes verification phase. Ready to PR.

Relates to #88
@NewGraphEnvironment NewGraphEnvironment merged commit aa50df2 into main May 1, 2026
1 check passed
@NewGraphEnvironment NewGraphEnvironment deleted the 88-fold-subsurfaceflow-natural branch May 1, 2026 03:24
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.

Fold subsurfaceflow into natural barriers so per-species obs/habitat lift fires

1 participant