Skip to content

refactor: remove default_strategy_profile — single source of truth is GitHub variables#173

Merged
Pigbibi merged 1 commit into
mainfrom
refactor/remove-default-strategy-profile
Jul 7, 2026
Merged

refactor: remove default_strategy_profile — single source of truth is GitHub variables#173
Pigbibi merged 1 commit into
mainfrom
refactor/remove-default-strategy-profile

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

动机

default_strategy_profile 字段存在于 platform-config.json、KV 账号配置、前端回退链等多个位置,但它不影响运行时策略(运行时读的是 GitHub 变量 RUNTIME_TARGET_JSON)。这造成了改了配置但没生效的假象——上次 LongBridge TQQQ→SOXL 的问题就是典型案例。

改动

核心原则:一个平台 = 一个策略来源 = GitHub 变量 RUNTIME_TARGET_JSON

操作 文件
删除 platform-config.json 6 个平台的 default_strategy_profile
删除 build_config.pyreport_default_strategy_profile_drift() 函数和 gate check
删除 build_platform_config.py / inject_platform_config.py 对该字段的生成
删除 app.js 硬编码回退链、account.default_strategy_profile 读取
删除 worker.js KV 同步中的 default_strategy_profile 写入
删除 account-options.example.json 所有账户的 default_strategy_profile
删除 test_runtime_settings.py 6 个测试方法
更新 test_cash_financing.js / strategy_switch_worker_validation.mjs 测试数据
更新 README.md / README.zh-CN.md / qmt README 文档
重新生成 config.js / index.html / page_asset.js / app_js.js

架构变化

之前:

platform-config.json → default_strategy_profile (改了没用)
GitHub 变量          → RUNTIME_TARGET_JSON (真正生效)
KV account options   → default_strategy_profile (第三份拷贝)
app.js 回退          → 硬编码 tqqq_growth_income

之后:

GitHub 变量 → RUNTIME_TARGET_JSON.strategy_profile ← 唯一策略来源
platform-config.json → 只管平台能力和部署配置
app.js → 读 GitHub 变量,没设置就显示未配置

净删除 255 行,新增 28 行。

🤖 Generated with Claude Code

… GitHub variables

Problem: default_strategy_profile in platform-config.json created a false
impression that changing it would change the running strategy. In reality,
the runtime reads RUNTIME_TARGET_JSON from GitHub variables, and the two
sources could diverge silently (LongBridge TQQQ bug).

Changes:
- platform-config.json: delete default_strategy_profile from all 6 platforms
- build_config.py: delete report_default_strategy_profile_drift() and gate
- build_platform_config.py / inject_platform_config.py: stop generating it
- app.js: simplify defaultStrategyForAccount → reads only GitHub variables;
  remove hardcoded fallback; remove account.default_strategy_profile reads
- worker.js: remove default_strategy_profile from KV sync/clean logic
- account-options.example.json: remove all default_strategy_profile fields
- tests: delete 6 test methods; update assertions and test data
- docs: update README.md / README.zh-CN.md / qmt README
- Regenerated: config.js, index.html, page_asset.js, app_js.js

Architecture after: one platform = one strategy source = GitHub variable
RUNTIME_TARGET_JSON. platform-config.json owns capabilities and deployment
config only. No more silent divergence between config and runtime.

Co-Authored-By: Claude <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 7, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

🤖 Codex PR Review

⚠️ Human review required: The Codex review could not be completed.

No Codex service URL or API key configured. Set CODEX_AUDIT_SERVICE_URL, ANTHROPIC_API_KEY, or OPENAI_API_KEY.

Please ensure a human reviewer checks this PR before merging.

@Pigbibi
Pigbibi merged commit bd82faa into main Jul 7, 2026
8 checks passed
@Pigbibi
Pigbibi deleted the refactor/remove-default-strategy-profile branch July 7, 2026 21:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5def960ff0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (hinted && strategyAllowedForAccount(platform, account, hinted)) return hinted;
if (fallback && strategyAllowedForAccount(platform, account, fallback)) return fallback;
return strategyChoicesForAccount(platform, account)[0] || "";
return "";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve empty strategy when no runtime target exists

When /api/config has no matching RUNTIME_TARGET_JSON/STRATEGY_PROFILE for an account, returning an empty profile here does not actually leave the form unconfigured: renderControls() later sees form.strategy is empty and assigns choices[0]. That makes the page show an arbitrary runnable strategy instead of the intended empty state, and if the operator changes only another control such as cash/plugin/runtime-target mode, buildInputs() submits that auto-selected strategy and can initialize or overwrite the runtime target with the first catalog choice.

Useful? React with 👍 / 👎.

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