Skip to content

Commit 814f123

Browse files
Pigbibicodex
andcommitted
ci: sync M0 research ingress token to Worker
Co-Authored-By: Codex <noreply@openai.com>
1 parent 8c920cc commit 814f123

6 files changed

Lines changed: 26 additions & 2 deletions

File tree

.github/workflows/deploy-strategy-switch-console.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ jobs:
4242
CONTROL_PLANE_SYNC_TOKEN: ${{ secrets.CONTROL_PLANE_SYNC_TOKEN }}
4343
RESEARCH_TASK_SYNC_TOKEN: ${{ secrets.RESEARCH_TASK_SYNC_TOKEN }}
4444
EXECUTION_EVIDENCE_SYNC_TOKEN: ${{ secrets.EXECUTION_EVIDENCE_SYNC_TOKEN }}
45+
# Only the Worker deployment receives this copy. The M0 publisher reads
46+
# the same value from its separate main-only Environment, never the
47+
# Cloudflare deployment credentials.
48+
M0_RESEARCH_SYNC_TOKEN: ${{ secrets.M0_RESEARCH_SYNC_TOKEN }}
4549
steps:
4650
- name: Checkout
4751
uses: actions/checkout@v6
@@ -152,6 +156,13 @@ jobs:
152156
set -euo pipefail
153157
printf '%s' "$EXECUTION_EVIDENCE_SYNC_TOKEN" | npx wrangler@4.106.0 secret put EXECUTION_EVIDENCE_SYNC_TOKEN --config wrangler.toml
154158
159+
- name: Sync optional M0 research-ledger ingress token
160+
if: env.M0_RESEARCH_SYNC_TOKEN != ''
161+
working-directory: web/strategy-switch-console
162+
run: |
163+
set -euo pipefail
164+
printf '%s' "$M0_RESEARCH_SYNC_TOKEN" | npx wrangler@4.106.0 secret put M0_RESEARCH_SYNC_TOKEN --config wrangler.toml
165+
155166
- name: Sync bundled strategy profiles to KV
156167
if: github.event_name != 'workflow_dispatch' || inputs.sync_strategy_profiles
157168
run: |

docs/m0_research_publisher_envelope_contract.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ run ID 和 artifact ID 都作为 `source_artifact` metadata 显式传给构建
125125
必须是不同的值和不同的最小权限用途:前者只能读取固定 QAR repository 的 Actions run/artifact,
126126
后者只能向 M0 接收端发布封套;不得复用、互相授予或写入运行时/平台配置。
127127

128+
同一个 `M0_RESEARCH_SYNC_TOKEN` 还必须以**同名、同值的独立 secret**配置到已有的
129+
`runtime-strategy-switch` Environment。它只会在控制台 Worker 的部署 workflow 中被写入
130+
Cloudflare 的 `M0_RESEARCH_SYNC_TOKEN` secret binding;该部署 workflow 不读取 QAR artifact token,
131+
而 M0 发布 workflow 也不读取 Cloudflare 凭据。不要在 repository-level 放置这个名字,避免未受
132+
Environment 保护的 fallback。轮换时,先同时更新两个 Environment 中的同值副本,再从 `main`
133+
部署控制台,最后手动发布一份已验证的 M0 ledger。
134+
128135
URL、发布 token 和 QAR 读取 token 不会写进封套、`GITHUB_STEP_SUMMARY` 或 workflow 输出。该
129136
workflow 不读取运行时、平台、selector、策略或券商配置;其唯一网络写入是构建器在
130137
`--publish` 明确指定时,对上述研究接收地址发送经过校验的 no-order 封套。

python/tests/test_runtime_settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,9 @@ def test_strategy_switch_console_deploy_workflow_syncs_bundled_profiles(self):
11671167
self.assertIn("secret put STRATEGY_HEALTH_SYNC_TOKEN", workflow)
11681168
self.assertIn("RESEARCH_TASK_SYNC_TOKEN", workflow)
11691169
self.assertIn("secret put RESEARCH_TASK_SYNC_TOKEN", workflow)
1170+
self.assertIn("M0_RESEARCH_SYNC_TOKEN", workflow)
1171+
self.assertIn("secret put M0_RESEARCH_SYNC_TOKEN", workflow)
1172+
self.assertIn("if: env.M0_RESEARCH_SYNC_TOKEN != ''", workflow)
11701173
self.assertIn("CLOUDFLARE_WRANGLER_CONFIG_TOML", workflow)
11711174
self.assertIn("STRATEGY_SWITCH_CONFIG_KV_NAMESPACE_ID", workflow)
11721175
self.assertIn("python/scripts/sync_strategy_switch_page_asset.py", workflow)

web/strategy-switch-console/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ wrangler secret put GITHUB_CLIENT_SECRET
195195
wrangler secret put SESSION_SECRET
196196
wrangler secret put RUNTIME_SETTINGS_DISPATCH_TOKEN
197197
wrangler secret put STRATEGY_SWITCH_SYNC_TOKEN # optional; defaults to RUNTIME_SETTINGS_DISPATCH_TOKEN
198+
wrangler secret put M0_RESEARCH_SYNC_TOKEN
198199
wrangler secret put ALLOWED_GITHUB_LOGINS
199200
wrangler secret put ALLOWED_GITHUB_ORGS
200201
wrangler secret put STRATEGY_SWITCH_ADMIN_LOGINS
@@ -210,7 +211,7 @@ wrangler kv namespace create STRATEGY_SWITCH_CONFIG
210211

211212
Add the returned namespace id to `wrangler.toml`.
212213

213-
For GitHub Actions auto-deploy, configure `STRATEGY_SWITCH_CONFIG_KV_NAMESPACE_ID`, `STRATEGY_SWITCH_CONSOLE_URL`, `STRATEGY_SWITCH_SYNC_TOKEN`, and either `CLOUDFLARE_API_TOKEN` or `CLOUDFLARE_WRANGLER_CONFIG_TOML` in the `runtime-strategy-switch` environment (or reuse `RUNTIME_SETTINGS_GH_TOKEN` only if it matches the Worker sync secret). `CLOUDFLARE_ACCOUNT_ID` is optional when Wrangler can infer it from the token. The workflow deploys the Worker and then syncs the bundled strategy profile catalog into KV so the website is not left with stale profile/plugin metadata.
214+
For GitHub Actions auto-deploy, configure `STRATEGY_SWITCH_CONFIG_KV_NAMESPACE_ID`, `STRATEGY_SWITCH_CONSOLE_URL`, `STRATEGY_SWITCH_SYNC_TOKEN`, `M0_RESEARCH_SYNC_TOKEN`, and either `CLOUDFLARE_API_TOKEN` or `CLOUDFLARE_WRANGLER_CONFIG_TOML` in the `runtime-strategy-switch` environment (or reuse `RUNTIME_SETTINGS_GH_TOKEN` only if it matches the Worker sync secret). `CLOUDFLARE_ACCOUNT_ID` is optional when Wrangler can infer it from the token. `M0_RESEARCH_SYNC_TOKEN` must match the separately protected `m0-research-publisher` environment secret; it is only copied to the Worker binding. The workflow deploys the Worker and then syncs the bundled strategy profile catalog into KV so the website is not left with stale profile/plugin metadata.
214215

215216
Deploy:
216217

web/strategy-switch-console/README.zh-CN.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ wrangler secret put RUNTIME_SETTINGS_DISPATCH_TOKEN
332332
wrangler secret put STRATEGY_SWITCH_SYNC_TOKEN # 可选;默认复用 RUNTIME_SETTINGS_DISPATCH_TOKEN
333333
wrangler secret put STRATEGY_HEALTH_SYNC_TOKEN
334334
wrangler secret put CONTROL_PLANE_SYNC_TOKEN
335+
wrangler secret put M0_RESEARCH_SYNC_TOKEN
335336
wrangler secret put ALLOWED_GITHUB_LOGINS
336337
wrangler secret put ALLOWED_GITHUB_ORGS
337338
wrangler secret put STRATEGY_SWITCH_ADMIN_LOGINS
@@ -347,7 +348,7 @@ wrangler kv namespace create STRATEGY_SWITCH_CONFIG
347348

348349
然后把返回的 namespace id 加到 `wrangler.toml`
349350

350-
GitHub Actions 自动部署需要在 `runtime-strategy-switch` environment 配置 `STRATEGY_SWITCH_CONFIG_KV_NAMESPACE_ID``STRATEGY_SWITCH_CONSOLE_URL``STRATEGY_SWITCH_SYNC_TOKEN`,以及 `CLOUDFLARE_API_TOKEN``CLOUDFLARE_WRANGLER_CONFIG_TOML` 二选一(只有当 `RUNTIME_SETTINGS_GH_TOKEN` 与 Worker 同步密钥相同时才复用它)。如果 Wrangler 能从 token 推断账号,`CLOUDFLARE_ACCOUNT_ID` 可不配。workflow 会先部署 Worker,再把内置策略 profile 目录同步到 KV,避免网站继续使用旧的 profile/plugin 元数据。
351+
GitHub Actions 自动部署需要在 `runtime-strategy-switch` environment 配置 `STRATEGY_SWITCH_CONFIG_KV_NAMESPACE_ID``STRATEGY_SWITCH_CONSOLE_URL``STRATEGY_SWITCH_SYNC_TOKEN``M0_RESEARCH_SYNC_TOKEN`,以及 `CLOUDFLARE_API_TOKEN``CLOUDFLARE_WRANGLER_CONFIG_TOML` 二选一(只有当 `RUNTIME_SETTINGS_GH_TOKEN` 与 Worker 同步密钥相同时才复用它)。如果 Wrangler 能从 token 推断账号,`CLOUDFLARE_ACCOUNT_ID` 可不配`M0_RESEARCH_SYNC_TOKEN` 必须与另一个受保护的 `m0-research-publisher` Environment 中的同名 secret 一致;它只会被复制到 Worker binding。workflow 会先部署 Worker,再把内置策略 profile 目录同步到 KV,避免网站继续使用旧的 profile/plugin 元数据。
351352

352353
部署:
353354

web/strategy-switch-console/wrangler.toml.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ workers_dev = true
1212
# - STRATEGY_HEALTH_SYNC_TOKEN # dedicated outbound health snapshot token; never reuse dispatch token
1313
# - CONTROL_PLANE_SYNC_TOKEN # dedicated global dashboard snapshot token; never reuse dispatch token
1414
# - RESEARCH_TASK_SYNC_TOKEN # dedicated immutable research-task source token; never reuse another token
15+
# - M0_RESEARCH_SYNC_TOKEN # dedicated read-only M0 research-ledger ingress token; never reuse another token
1516
# - ALLOWED_GITHUB_LOGINS
1617
# - ALLOWED_GITHUB_ORGS
1718
# - STRATEGY_SWITCH_ADMIN_LOGINS

0 commit comments

Comments
 (0)