Skip to content

Feature upgrades: deterministic source-specific and RV features with preprocessing metadata #67

Description

@gabrool

Goal

Add the deterministic feature upgrades needed before the preprocessing/tensor layer. These are features that are useful for Brazil low-frequency relative value and should not be left for a transformer to rediscover from raw levels alone.

This issue must also update preprocessing metadata for every new feature and demote superseded/useless raw features from first-model defaults.

Scope

In scope:

  • Add deterministic feature panels for currently implemented source families.
  • Add cross-market/RV features that are central to Brazil rates/FX/equity RV.
  • Add preprocessing metadata rules for every new feature.
  • Mark superseded raw features model_default: false in configs/modeling/feature_preprocessing.yaml.
  • Add PIT-safe warmup/history handling for rolling features.
  • Add formula and metadata tests.

Out of scope:

  • No fitted scalers or actual preprocessing execution.
  • No tensors or model training.
  • No new external data sources.
  • No new raw ingestion endpoints.
  • No target/label changes except using already available feature dates for tests if needed.

Global implementation requirements

  1. All new feature builders must emit daily-long-compatible rows:
ref_date
available_date
source_family
feature_id
value_name
value
unit
observation_ref_date
observation_available_date
is_available
staleness_days
source_version

If the source family carries PIT fields, preserve them too:

availability_policy
availability_basis
revision_policy
vintage_id
model_usable
model_usable_reason
  1. Features must be computed as of ref_date only. No rolling/statistical feature may use observations with observation_available_date > ref_date.

  2. Rolling features must receive enough warmup history before the requested output window. Use the model contract defaults:

lookback_business_days = 256
feature_warmup_business_days = 504

Feature builders may accept extended history and then filter output back to [start, end]. Add tests proving first output dates can use pre-window history.

  1. Use these shared naming conventions:
source_family = <source>_<feature_group>_feature
feature_id = stable family/entity key
value_name = stable metric name
  1. Do not delete raw/research panels. “Remove useless features” means: update preprocessing metadata so superseded/noisy/raw features are model_default: false, and ensure new upgraded feature panels are the first-model defaults.

  2. Add configs/derived/model_feature_upgrades.yaml if useful for enabling/disabling groups, but Codex must not move feature selection decisions into vague config defaults. The feature list below is mandatory.

Stack plan

Implement as stacked PRs:

  1. Feature-upgrade foundation and B3 market/rates features.
  2. BCB, FRED, Tesouro, and Brazil/global RV features.
  3. IBGE and Focus macro-release features.
  4. ANP, ONS, CVM, Novo CAGED, Receita features.
  5. Metadata cleanup/removals and full coverage tests.

Each PR must run:

python -m ruff check .
python -m pytest

Acceptance criteria

This issue is complete when:

  1. Every feature listed in the follow-up comments exists and has tests.
  2. Every new feature has exactly one preprocessing metadata rule.
  3. Superseded/noisy raw features are marked model_default: false.
  4. Rolling features are PIT-safe and use warmup history.
  5. Daily-long upgraded feature panels contain no future leakage and preserve availability metadata.

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