Skip to content

fix(strategy): make sentiment telemetry provider-neutral - #186

Merged
Trujillofa merged 2 commits into
mainfrom
fix/sentiment-telemetry-provider-neutral
Aug 27, 2026
Merged

fix(strategy): make sentiment telemetry provider-neutral#186
Trujillofa merged 2 commits into
mainfrom
fix/sentiment-telemetry-provider-neutral

Conversation

@Trujillofa

@Trujillofa Trujillofa commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Summary

Prospective-only telemetry fix: sentiment degradation and event attribution no longer hardcode Grok/xAI when DeepSeek or Z.AI is the configured provider. Successful DeepSeek and Z.AI replies count as live/answered. Failed provider requests are recorded as error_fallback with the configured provider and attempted model. Historical event logs are not rewritten.

Rebased onto current origin/main after #184 (feat/zai-provider) so zai_live is treated as answered and Z.AI failures are not labeled provider=xai.

This PR does not change strategy rules, thresholds, position sizing, trading mode, or execution. Fail-closed BUY blocking and rising-edge-only degradation paging are preserved.

Do not merge as a deploy authorization. Paper evidence window starts only after independent review and a separate deploy.

Type of Change

  • Bug fix
  • New feature
  • Refactoring
  • Documentation update
  • Tests

SHAs

  • Base (origin/main): 7d57c22498aebe75fdf98aa12042176cf07f1273
  • Head: dff7e1e7a7ba492438d534312658c5de6b67a21d

What changed and why

File Why
src/strategy/sentiment_mean_reversion.py Write error_fallback (provider-neutral); stamp configured provider/model on failures; alert names DeepSeek/xAI/Z.AI, not Grok; shared answered/error source sets (xai_live, deepseek_fallback, zai_live; historical xai_error_fallback).
src/main.py Honor payload provider on record; infer zai from zai_* sources; daily summary live% uses answered sources.
src/overseer/xai.py Public provider / model properties so failures can be attributed without poking privates.
scripts/sentiment_report.py Count successful DeepSeek and Z.AI as live; count both xai_error_fallback and error_fallback as errors; drop Grok-hardcoded health copy.
tests/test_sentiment_mean_reversion.py DeepSeek 402 attribution, Z.AI error attribution, provider-named alerts, 10-obs 50% gate, fail-closed BUY, pinned trading contract.
tests/test_settings_integration.py End-to-end DeepSeek 402 payload; Z.AI live provider=zai.
tests/test_sentiment_report.py Historical parse + DeepSeek/Z.AI success-is-live.

Compatibility for old event logs

Readers accept both old and new source names. Nothing in stored JSONL is rewritten.

Historical / existing source Parse Classification
xai_live yes answered / live
deepseek_fallback yes answered / live (successful DeepSeek; name kept)
zai_live yes answered / live (from #184)
xai_error_fallback yes no-answer / error
neutral_fallback yes no-answer

Prospective writes:

Event source provider model
xAI success xai_live xai answering model
DeepSeek success deepseek_fallback deepseek answering model
Z.AI success zai_live zai answering model
LLM failure error_fallback configured provider (deepseek, zai, or xai) attempted model when the client exposes it, else none
No client neutral_fallback none none

Degradation still uses a rolling 10-observation window at >= 50% no-answer (error_fallback + historical xai_error_fallback + neutral_fallback). Successful DeepSeek and Z.AI replies are not no-answer.

Strategy / trading

Unchanged: RSI/BB gates, sentiment thresholds, panic SELL, high-vol filter, fail-closed block of new BUY when degraded, rising-edge-only Telegram paging. Pinned by test_evaluate_trading_contract_is_unchanged and existing degrade/repage tests.

Testing

  • Tests pass locally: uv run pytest -q1399 passed
  • Lint passes: uv run ruff check .
  • Format check: uv run ruff format --check . (ruff is canonical; template black --check not run)
  • git diff --check clean

Focused: tests/test_sentiment_mean_reversion.py, tests/test_sentiment_report.py, tests/test_settings_integration.py, tests/test_xai_client.py, tests/test_config.py.

Checklist

  • Code follows project style
  • Self-review completed
  • Tests added/updated
  • No merge, deploy, restart, or production mutation from this change
  • Documentation updated (if needed) — not needed; telemetry-only

Notes

PR only. After independent review and a separate SHA-pinned deploy, begin a pre-registered DeepSeek paper evidence window. Do not treat the existing three paper trades as validation. Current sentiment-macro config on main is Z.AI; this PR does not change that provider setting.

Record LLM failures as error_fallback with the configured provider and
attempted model, page DeepSeek/xAI/Z.AI by name instead of Grok, and
treat successful DeepSeek and Z.AI replies as live in reports.
Historical xai_live, xai_error_fallback, neutral_fallback, and
deepseek_fallback events still parse. Strategy rules, fail-closed BUY
blocking, and rising-edge paging are unchanged.

Co-Authored-By: Grok 4.6 <noreply@x.ai>
@Trujillofa
Trujillofa force-pushed the fix/sentiment-telemetry-provider-neutral branch from 807691d to dff7e1e Compare August 27, 2026 16:52
Move source taxonomy to src/sentiment_sources.py so the report can run
from a file path or stdin without importing src.strategy.
@Trujillofa
Trujillofa merged commit 19167bc into main Aug 27, 2026
3 checks passed
@Trujillofa
Trujillofa deleted the fix/sentiment-telemetry-provider-neutral branch August 27, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant