← Back to Pull requests

Normalize cause names: 44 real causes include duplicates and plan names #34

Open
unknown opened this pull request with 450 lines diff across 5 files
View on GitHub
unknown unknown commented on Oct 24, 2026 12:44 UTC
Author

Summary


Staging now normalizes cause with a new cause_name macro (same idea as crop_name): strips quotes, backticks and doubled spaces; merges the Other (Snow…), Mycotoxin and Failure of Irrigation Supply variants; maps every plan-name pseudo-cause (names containing "Crops Only", GRP, GRIP, ARPI, STAX or SCO/ECO) to Area plan (no cause recorded); maps blanks to Not recorded. The UI reads causes from the data, so the filter and county legend show the clean names with no UI change. Shape of county-losses.json is unchanged.

Seams: pytest through the published county-losses.json (pipeline end to end on fixtures); Playwright journey for the cause filter.

Two-way-door choices: canonical names are Other (Snow, Lightning, Etc.), Mycotoxin, Failure of Irrigation Supply. The plan-name rule is a pattern, not a list of the eleven names, so new plan names are caught too.

Evidence


  • New test test_cause_spellings_merge_and_plan_names_and_blanks_get_their_own_causes (fixture rows for every variant in the ticket, distinct amounts) failed before the macro and passes now; amounts sum per merged cause, so totals are unchanged by construction (group-by only).

  • ui/e2e/causes.spec.ts saves test-results/causes.png.

  • just check is green (the cause-filter journey now waits for the map data before reading the options).

  • just publish-live gives 31 distinct causes (ticket: about 30):

  • - All Other Causes
    - Area plan (no cause recorded)
    - Asian Soybean Rust
    - Cold Wet Weather
    - Cold Winter
    - Cyclone
    - Decline in Price
    - Drought
    - Earthquake
    - Excess Moisture/Precipitation/Rain
    - Failure of Irrigation Equipment
    - Failure of Irrigation Supply
    - Federal or State Ordered Destruction
    - Fire
    - Flood
    - Freeze
    - Frost
    - Hail
    - Heat
    - Hot Wind
    - Hurricane/Tropical Depression
    - Inability to Prepare Land for Irrigation
    - Insects
    - Mycotoxin
    - Not recorded
    - Other (Snow, Lightning, Etc.)
    - Plant Disease
    - Tornado
    - Volcanic Eruption
    - Wildlife
    - Wind/Excess Wind

    Merge Danger


    Low. Rename-only in staging. Risk: a live cause I haven't seen that matches the plan pattern (e.g. a real cause containing "grip") would be folded into Area plan; none of the 31 live causes were affected. Saved bookmarks/URLs using old cause names (?cause=...) will show no filter match.

    Closes #33

    Follow-ups (filed as tickets when this PR merges)

  • Plan pattern is a loose substring match (pipeline/macros/cause_name.sql:9): A future real cause containing grip or arpi would silently be folded into Area plan. Anchor the pattern to known plan prefixes or add a dbt test that flags new causes in that bucket.

  • Renamed causes break saved ?cause= links (pipeline/models/staging/stg_cause_of_loss.sql:7): Old links with the previous cause names match nothing after this change. Check what the UI does with an unknown cause and add a fallback and a test if needed.
  • <!-- factory-follow-ups
    [{"kind":"follow-up","title":"Plan pattern is a loose substring match","path":"pipeline/macros/cause_name.sql","line":9,"body":"A future real cause containing grip or arpi would silently be folded into Area plan. Anchor the pattern to known plan prefixes or add a dbt test that flags new causes in that bucket."},{"kind":"follow-up","title":"Renamed causes break saved ?cause= links","path":"pipeline/models/staging/stg_cause_of_loss.sql","line":7,"body":"Old links with the previous cause names match nothing after this change. Check what the UI does with an unknown cause and add a fallback and a test if needed."}]
    -->

    Diff: 450 lines (+337 / -113) across 5 files Reviewer: claude[bot] Review duration: 2m
    All Vouch review confidence checks passed
    Residual risk 0.37 = Change Risk (0.45) × (1 − Review Confidence (0.19)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 450 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 25% · Reviewer familiarity: 35%
    19%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.366
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #34"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 19.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.4% (MEDIUM) · Higher = larger blast radius
    45.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 19.3% · Lower = rushed or shallow review
    19.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 36.6% · Moderate risk
    36.6%