Data-drive species residence (species_resident/anadromous/spawn_only) from dimensions.csv #189
Description
Context
After link#187 (v0.40.0) lands, lnk_pipeline_mapping_code() and lnk_mapping_code() accept species-residence categorization via three params:
species_resident = c("bt", "wct")species_anadromous = c("ch", "cm", "co", "pk", "sk", "st")species_spawn_only = c("cm", "pk")
These defaults are hardcoded to bcfp's species residence model. They're flex args (caller can override) but the categorization itself is baked into function bodies, not data-driven from any bundle CSV.
Problem
Operators modelling species outside the bcfp default set — sea-run cutthroat, Dolly Varden, other regional variants — can override at the call site, but the override is invisible to downstream code that re-reads the defaults. Long-term we want species residence to be a property of the bundle's data (which species are modelled + their residence type), not a runtime arg.
Tour-driven motivation: as the user adds custom species mixes per study area, hardcoded defaults become an obstacle. Every override has to land at every call site.
Goals
- Add a
residencecolumn (values:resident/anadromous) +spawn_onlyboolean toparameters_habitat_dimensions.csv(link's bundle CSV ininst/extdata/configs/<name>/dimensions.csv). lnk_pipeline_mapping_code()andlnk_mapping_code()derive the three species lists fromloaded$parameters_habitat_dimensionswhen not explicitly passed. Function-arg defaults become last-resort fallback (e.g., for callers that don't have aloadedmanifest).- Each bundle's
dimensions.csvdocuments its species' residence — bcfp bundle keeps the current mapping;defaultand custom bundles override per study area. - Cross-repo: investigate whether fresh's
parameters_fresh.csvneeds aresidencecolumn too, or whether the link-side categorization is sufficient.
Acceptance
-
parameters_habitat_dimensions.csv(link's bcfp + default bundles) hasresidence+spawn_onlycolumns populated for current species. -
lnk_pipeline_mapping_code()resolvesspecies_<role>frompresencearg OR fromloaded$parameters_habitat_dimensionswhen callable; falls back to current hardcoded defaults when neither is available. -
lnk_mapping_code()passes through the resolved lists. - A custom-species smoke (e.g., a bundle with only BT + sea-run cutthroat) produces correct
mapping_code_<sp>columns without monkey-patching function defaults. - Fresh-side investigation outcome documented — either fresh#N filed for the corresponding column add, or "no change needed" rationale captured.
References
R/lnk_pipeline_mapping_code.R— the function whose defaults this issue data-drives.R/lnk_mapping_code.R(new in v0.40.0) — pass-through caller.inst/extdata/configs/bcfishpass/dimensions.csvandinst/extdata/configs/default/dimensions.csv— schema receivers.R/lnk_load_overrides.R/ crate ingest — howparameters_habitat_dimensionslands inloaded.- Follows from mapping_code build decoupled from tunnel — persist streams_access + lnk_pipeline_run phase + rename with_mapping_code → mapping_code #187 (mapping_code tunnel decouple + portable build).
Activity
v0.40.1: lnk_pipeline_run mapping_code uses active_species (#192) (#193)
#223 Phase 1: accessible_km fix-validation script (fails pre-fix)
#221+#223 Phase 5: provincial accessible+spawn+rear parity proof (11 …
Consolidate 3 accessible-km scripts into one parity_crosssection.R
Code-check round 3 fixes (#246)