Skip to content

bug: compute_signal_score returns dict with duplicate keys score/signal_score and label/signal_label #54

@Codex-Crusader

Description

@Codex-Crusader

Summary

compute_signal_score in pulseengine/core/signals.py returns a dict with two pairs of identical values under different keys:

return {
    "score": total,
    "label": label,
    "signal_score": total,   # duplicate of "score"
    "signal_label": label,   # duplicate of "label"
    ...
}

This redundancy exists for backwards compatibility with callers using either key name, but it violates the DRY (Don't Repeat Yourself) principle and makes the returned schema ambiguous.

Impact

  • Any caller that updates score in-place will silently diverge from signal_score
  • Consumers don't know which key is canonical, leading to inconsistent access patterns across the dashboard and backtest code
  • The No Data early-return path also duplicates both keys, doubling the footprint

Proposed fix

Choose one canonical key pair (signal_score and signal_label to match the roadmap terminology) and migrate all callers. Add a # noqa compatibility shim if needed during a transition period:

return {
    "signal_score": total,
    "signal_label": label,
    "low_news_confidence": low_news_confidence,
    "news_article_count": news_article_count,
    "components": components,
    "raw_components": raw,
    "category": category,
}

Update all call sites in pulseengine/local/, pulseengine/web/, and tests/ accordingly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions