eduaguilera / eduaguilera/whep

build_trade: CBS coverage granularity is discarded in time extension (only year is used)

Open
#232 2 comments 0 reactions 1 assignee Claimed by @lbm364dl View on GitHub
area:trade bug needs-expert priority:low
Dominant language
R
Stars
1
Forks
5
Avg merge
1d 11h
Merged PRs (30d)
186

Description

## What

`.extract_cbs_ie_for_dtm(cbs)` (`R/build_trade.R:290`) returns `(year, area_code, item_cbs_code, element)`, but `.extend_dtm_time` consumes only `cbs_ie$year` (line 329). The area/item/element columns are dead computation.

## Why it matters

Shares are completed and gap-filled across the union of **all** CBS years for **every** trade `(area, item, partner, element)` combo, regardless of whether CBS actually reports that item/area/element in that year. The intended CBS-driven scoping of the extension is not enforced — `cbs_ie` could be replaced by `unique(cbs$year)` with no behavior change, revealing the granularity was meant to matter but doesn't.

## Suggested fix / check

Scope the completion/extension to the `(area, item, element, year)` tuples CBS actually reports, or drop the unused columns if uniform extension is intended.

---
_From deep static audit (2026-07-23), round 2, parallel subsystem review. Deduplicated against open+closed issues. Not verified by running unless stated._

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.