Skip to content

cabd_additions dams carry barrier_ind = t but can never become barriers (psc NULL) #244

Description

@NewGraphEnvironment

Problem

cabd_additions.csv rows carry barrier_ind = t, but they are structurally incapable of becoming barriers. The US placeholder dams — Grand Coulee, Chief Joseph, Ross — are in the CSV precisely so the model knows the Columbia is blocked downstream, and they do nothing.

Mechanism

.lnk_pipeline_prep_dams()'s usa CTE (R/lnk_pipeline_prepare.R, the cabd_additions branch) hardcodes:

NULL::integer AS passability_status_code

.lnk_crossings_union() then maps that code to barrier_status:

CASE
  WHEN d.passability_status_code = 1 THEN 'BARRIER'
  WHEN d.passability_status_code = 2 THEN 'POTENTIAL'
  ...
END AS barrier_status

There is no NULL arm, so barrier_status is NULL, and every downstream consumer filters barrier_status IN ('BARRIER','POTENTIAL'). The rows are dropped.

Verified

SELECT count(*) FROM fresh.barriers WHERE id_barrier ~ '^12000';
-- 0

(usa synthesises dam_id as row_number() + 1200000000, so ^12000 selects exactly the additions.)

Why it matters

The CSV column says these are barriers and the model says they are not. Anyone reading cabd_additions.csv reasonably concludes the Columbia is modelled as blocked at the border. It is not.

It also constrains link#227's downstream guard, which must mirror this behaviour exactly — a guard that treated the additions as blocking would demand an override for every Columbia watershed group. That is pinned by a test (test-lnk_pipeline_prepare.R, "applies the cabd_additions psc-NULL rule") so a fix here is deliberate rather than incidental.

Options

  1. Map barrier_indpassability_status_code in the usa CTE (t → 1). Makes the additions behave as the CSV advertises; changes access results for Columbia groups, so it needs a parity check.
  2. Add a WHEN ... IS NULL THEN 'BARRIER' arm to the CASE — narrower, same effect for additions only.
  3. Decide the additions are documentation-only and rename the column so it stops implying otherwise.

Worth settling deliberately: (1) and (2) change modelled access in the Columbia; (3) changes nothing but stops the file misleading readers.

Refs

  • Found during link#227 (downstream-state guard); pinned by the test above.
  • RUNBOOK.md §8c documents the guard's mirroring of this rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions