Skip to content

Thread per-WSG cw/mad habitat model through classify (#286) - #298

Merged
NewGraphEnvironment merged 9 commits into
mainfrom
286-thread-fresh-params-method-per-wsg-cw-ma
Oct 2, 2026
Merged

NewGraphEnvironment merged 9 commits into
mainfrom
286-thread-fresh-params-method-per-wsg-cw-ma

Conversation

@NewGraphEnvironment

Copy link
Copy Markdown
Owner

Summary

  • Every bundle declares a per-watershed-group habitat model table, parameters_habitat_method.csv (cw or mad). lnk_pipeline_classify() passes it to fresh::frs_habitat_classify(params_method =), and a new method_csv = argument overrides it. A custom bundle without the file falls back to fresh's copy, which is hashed into config_hash.
  • Shipped tables are all cw: a frozen copy of smnorris/bcfishpass@1fae4ea parameters/example_newgraph. They are deliberately not csv-synced. sync_bcfishpass_csvs.R selects on source:, and byte drift auto-merges, so an upstream cw→mad flip would otherwise have changed default unreviewed.
  • mad_m3s is joined onto the working streams from fwa_stream_networks_discharge. It is never persisted, so the persist shape is unchanged. log_input now fingerprints the discharge table.
  • A mad group skips the stream-order rearing bypass; bcfishpass applies it only in its cw branch.
  • fresh is pinned at v0.36.2, with the floor at 0.35.0. lnk_preflight_fresh() gains required_formals and asserts the params_method argument rather than a version.
  • fresh 0.36.0 reversed frs_db_conn()'s env precedence. data-raw/wsg_vignette_data.R therefore moves to lnk_db_conn().

Related Issues

Test plan

  • devtools::test(): FAIL 0, PASS 2298, WARN 16 (the warning baseline).
  • devtools::check(): 0 errors. The 3 warnings and 3 notes were already there; no added line is non-ASCII.
  • Live no-change proof (local fwapg, scratch schemas, config default). The per-species streams_habitat digests are identical across branch, main + fresh 0.36.2, and main + fresh 0.33.0, on ADMS (5 species) and BULK (7 species). ADMS also matches with mad_m3s dropped.
  • ADMS on mad. No stream segment falls outside its MAD range, and BT/RB lose all stream habitat. BULK on mad (no discharge coverage) loses all stream habitat, without an error.
  • Mutation checks. A stubbed formals check turns 3 preflight tests red, and dropping the fallback hash turns test-lnk_log.R red.
  • Code review: 3 /code-check rounds plus a plan review. One real bug was found (the csv-sync enrollment) and fixed.

Evidence: data-raw/logs/params_method_286/. Mechanics: RUNBOOK §7, "Channel width or discharge, per watershed group".

Notes

  • Re-prep cyphers before the next dispatch. An image on fresh < 0.35 fails preflight, by design.
  • config_hash changes for every bundle, because a new file is declared. No model output changed.
  • Not done here:
    • lnk_habitat_validate() is still cw-only. A follow-up issue body is drafted in planning/archive/2026-10-issue-286-params-method/findings.md and has not been filed.
    • fresh's own bundled method table is missing PINE (187 vs 188 rows). That has no effect, since an unlisted group is cw.

Draft NEWS (for the release commit):

Each config can now choose channel width or discharge per watershed group (#286). Bundles declare parameters_habitat_method.csv, which lnk_pipeline_classify() passes to fresh as params_method; every shipped bundle is all cw, so outputs are unchanged. A mad group classifies on mad_m3s, joined onto the working streams (never persisted), and skips the stream-order rearing bypass. Requires fresh >= 0.35.0 (pinned at v0.36.2), and lnk_preflight_fresh() now checks for the argument, so re-prep cypher images before the next run. config_hash changes for every bundle.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx

NewGraphEnvironment and others added 9 commits October 1, 2026 22:54
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
fresh 0.35.0 added params_method to frs_habitat_classify(); the floor
moves there and Remotes to the latest tag. lnk_preflight_fresh() gains
required_formals so an install that exports the function but predates
the argument fails before a WSG reaches classify.

fresh 0.36.0 reversed frs_db_conn()'s env precedence (PG* before
PG_*_SHARE). The vignette context fetch moves to lnk_db_conn(), which
still reads PG_*_SHARE first, and stale v0.33.0 / frs_db_conn() notes
are corrected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
Each base bundle declares parameters_habitat_method.csv, a frozen copy
of bcfishpass example_newgraph (188 groups, all cw). Its provenance
source is deliberately not the bcfishpass URL: csv-sync auto-merges
any entry with that source, which would let an upstream cw -> mad flip
change default unreviewed. A bundle that declares none falls back to
fresh's copy, hashed into config_hash by a fixed name.

The discharge table joins log_input's primitives, and the thresholds
dictionary no longer says *_mad_* never apply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
lnk_pipeline_classify() resolves method_csv (argument, then the bundle's
files, then fresh's copy) and hands it to
fresh as params_method. Prepare joins mad_m3s from
fwa_stream_networks_discharge onto the working streams only; the
persisted shape is unchanged. A mad group skips the stream-order
rearing bypass, which bcfishpass applies in its cw branch alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJE2szSCkeV9R3qKhuSwyx
ADMS and BULK classify byte-identically on branch and main, on fresh
0.33.0 and 0.36.2, and with or without mad_m3s on the working streams.
Putting ADMS on mad keeps every stream segment inside its MAD range
and removes all BT/RB stream habitat; BULK, which has no discharge,
loses all stream habitat without an error.

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
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
NewGraphEnvironment merged commit 2284944 into main Oct 2, 2026
1 check passed
@NewGraphEnvironment
NewGraphEnvironment deleted the 286-thread-fresh-params-method-per-wsg-cw-ma branch October 2, 2026 07:07
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.

Thread fresh params_method (per-WSG cw/mad) through lnk_pipeline_classify

1 participant