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.
Summary
compute_signal_scoreinpulseengine/core/signals.pyreturns a dict with two pairs of identical values under different keys: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
scorein-place will silently diverge fromsignal_scoreNo Dataearly-return path also duplicates both keys, doubling the footprintProposed fix
Choose one canonical key pair (
signal_scoreandsignal_labelto match the roadmap terminology) and migrate all callers. Add a# noqacompatibility shim if needed during a transition period:Update all call sites in
pulseengine/local/,pulseengine/web/, andtests/accordingly.