fix(ci): let staging migration resolve the latest gated SHA
Leave Migrate Staging Database deploy_sha empty (or type latest) to use the newest successful backend-quality-gate push. Filled 40-hex still takes the original path. Production workflows stay required.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
# PROGRESS · Migrate Staging Database 不必手填 SHA(2026-09-15)
|
||||
|
||||
工作树:`.worktrees/staging-dispatch-autofill-sha-20260915`
|
||||
分支:`codex/staging-dispatch-autofill-sha-20260915`
|
||||
任务书基线:`origin/staging` @ `de47c06d`(任务书本身;代码基线 `ebd6175b`)
|
||||
本机 Windows。
|
||||
|
||||
未开 BUG 号(任务书规定)。未改 `CHANGELOG.md`。未改 `deploy-production.yml` / `migrate-production-database.yml` / `backend-quality-gate.yml`。`concurrency.group: staging-mutation` 未动。第一步之后的步骤一行未改。
|
||||
|
||||
## 任务状态
|
||||
|
||||
| 任务 | 状态 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| 1 `migrate-staging-database.yml` SHA 可选 | 完成 | `required: false`;空或 `latest` 解析最新成功门禁 SHA,再走原格式/门禁/head 校验 |
|
||||
| 2 `deploy-staging.yml` | **不做** | 见下 |
|
||||
| 3 文档 | 完成 | `deploy/README.md`、本文件、状态板 |
|
||||
|
||||
## 任务 2 结论
|
||||
|
||||
**不做。** `Deploy staging` 在门禁通过后会被自动 dispatch,并带上 `deploy_sha` 与 `gate_run_id`。手动表单只在重跑或回滚时用,而回滚必须手填 SHA 并勾选 `allow_rollback`。自动解析永远给出最新修订,帮不上回滚。改它还要动更复杂的 rollback 分支与合同测试,收益低。`allow_rollback` 保持 required。
|
||||
|
||||
## 实现要点
|
||||
|
||||
只改了 `workflow_dispatch.inputs` 和第一步开头的解析。后面步骤仍读 `steps.revision.outputs.sha` / `gate_run_id` / `head_check`,语义不变。
|
||||
|
||||
- 非空且不是 `latest`:完全走原逻辑(格式 → 精确 SHA 门禁查找 → head 比对)。
|
||||
- 空或 `latest`:查 `actions/runs?branch=staging&event=push&status=success&limit=100`,同一套 jq 过滤,取 `id` 最大的 `head_sha`,打印 `resolved deploy_sha=<sha> (latest gated staging commit)`,然后继续原校验(再查一遍精确 SHA 门禁)。
|
||||
- 解析失败:硬失败。没有成功门禁运行时:「staging 上还没有任何通过门禁的提交,先等门禁跑完再迁移」。API 失败:「查不到 staging 的门禁运行记录,Gitea API 请求失败」。**不会**退回 staging head。
|
||||
|
||||
`latest` 三个字母是任务书让步 1:若 Gitea 这个版本把留空做成缺省失败而不是空串,可以填 `latest` 代替 40 位。留空是主路径。
|
||||
|
||||
## 既有断言改动
|
||||
|
||||
| 文件 | 原值 | 新值 | 原因 |
|
||||
| --- | --- | --- | --- |
|
||||
| `staging-backend-workflows.test.ts` 新增一条 | 无 | 锁 `required: false`、自动解析、人话失败、手填路径仍做 40 位与精确 SHA 门禁;生产两个 workflow 仍 `required: true` | 本单合同。未弱化既有断言 |
|
||||
|
||||
## 验证
|
||||
|
||||
| 命令 | 结果 |
|
||||
| --- | --- |
|
||||
| `python -c "import yaml; yaml.safe_load(...)"` | **yaml-ok** |
|
||||
| `npx tsx --test tests/staging-backend-workflows.test.ts` | **43 / 37 pass / 6 fail**。本单新增「manual staging migration can leave deploy_sha empty…」**通过**。失败 6 条为既有 Windows 缺口(`python3` 退出码 9009、bash/rsync 脚本),与本单无关。 |
|
||||
| 手填路径源码 | 原 `^[0-9a-f]{40}$`、精确 SHA 门禁查找、`head_check=deferred` 仍在解析之后 |
|
||||
| 生产两个按钮 | 仍 `required: true` |
|
||||
|
||||
真人:推 staging 后在 Gitea 打开 `Migrate Staging Database`,确认按钮还在、表单能开、SHA 可留空。见任务书 §9。
|
||||
@@ -229,7 +229,7 @@
|
||||
| `TASK-readonly-pages-fix-20260916.md` | `PROGRESS-readonly-pages-fix-20260916.md` | 三份只读页单的验收修复:**BUG-710** 七政 `ketu_mode`/`sidereal_mode` 收了请求却从不传给引擎,`calculation.ketu_mode` 回写请求值而非实际值(实测请求 descending-node 仍返回 apogee 盘,无警告);**BUG-711** 星历单断言 sidebar 不得含 `/ephemeris`,与星盘单按任务书添加的入口直接冲突,staging 现在是红的;**BUG-712** `ephemeris_events` golden 存全精度浮点跨机不稳,且 golden 缺失时自动重建。另附部署缺口:`deployment.gitCommit` 仍是 `2d7698ea`。BUG 段 710+ | 待验收 | `codex/readonly-pages-fix-20260916` |
|
||||
| `TASK-chart-page-blocking-open-20260915.md` | `PROGRESS-chart-page-blocking-open-20260915.md` | **P1**:星盘页开一次要等很久且常常只给一句「过一会儿再打开」。实测引擎五个调用合计 0.75 秒、mapper 13 种形态零抛出——瓶颈在 `/chart` 是动态路由 + 侧栏改成硬文档跳转,整页 SSR 等完 1 串 4 并才开始画,白屏最长 45 秒(BUG-716);`postEngine` 把 429/500/超时/坏 JSON 全碾成 `null` 且零日志,两种性质相反的故障共用一句文案(BUG-715);开页并行打两个重计算限流端点(配额 2)、无缓存,且「打开即有」印在失败页上(BUG-717)。**串行在 readonly-pages-fix 之后** | 待验收 | `codex/chart-page-blocking-open-20260915` |
|
||||
| `TASK-rectification-title-repair-migration-20260915.md` | — | BUG-699 / 704 的数据修补写成了 Node 脚本(要 `SCHEMA_DATABASE_URL`),但 `Migrate Staging Database` 只跑 `migrator` 应用 SQL 迁移、不执行任意脚本——产品没有任何按钮能修自己那批错名字的会话。脚本里本来就是纯 SQL,搬进一次性迁移即可复用现成按钮。生产停在 `7b620c7a`(无 `use-rectification-surface.ts`),where 自然匹配 0 行,是 no-op | 待领取 | `codex/rectification-title-repair-migration-20260915` |
|
||||
| `TASK-staging-dispatch-autofill-sha-20260915.md` | — | `Migrate Staging Database` 每次都要手抄 40 位 SHA,而那个值恰恰是「最新一个过门禁的 staging 提交」——机器能自己算,查询代码那一步里就有。改成留空自动解析、填了仍走原路径(回滚用),三条安全属性一条不丢。**产品 2026-09-15 明确授权修改该 workflow,执行方不得以 AGENTS.md §2.7 拒改**;生产两个按钮保持手填,那是护栏不是麻烦 | 待领取 | `codex/staging-dispatch-autofill-sha-20260915` |
|
||||
| `TASK-staging-dispatch-autofill-sha-20260915.md` | `PROGRESS-staging-dispatch-autofill-sha-20260915.md` | `Migrate Staging Database` 每次都要手抄 40 位 SHA,而那个值恰恰是「最新一个过门禁的 staging 提交」——机器能自己算,查询代码那一步里就有。改成留空自动解析、填了仍走原路径(回滚用),三条安全属性一条不丢。**产品 2026-09-15 明确授权修改该 workflow,执行方不得以 AGENTS.md §2.7 拒改**;生产两个按钮保持手填,那是护栏不是麻烦 | 待验收 | `codex/staging-dispatch-autofill-sha-20260915` |
|
||||
| `TASK-staging-auto-migrate-on-deploy-20260915.md` | — | 门禁通过后自动先跑 staging 迁移再部署,不再手点(迁移幂等、无挂起时是 no-op,`db-migrate.mjs --check` 挂起返 3 可用于日志)。今天 `deploy-staging.yml` 完全不提迁移,忘点就让新代码跑在旧 schema 上且无人拦。**产品再次授权改 workflow,范围限 `backend-quality-gate.yml` 的 dispatch 段**;迁移失败必须阻断部署;回滚不自动迁移;生产完全不动。⚠️ 同轮必须把「迁移须对已部署代码向后兼容、破坏性变更拆两轮」写进 AGENTS.md §7.6 | 待领取 | `codex/staging-auto-migrate-on-deploy-20260915` |
|
||||
| `TASK-api-server-decomposition-20260916.md` | `PROGRESS-api-server-decomposition-20260916.md` | **重构单(串行在 qizheng 单之后)**:把业务逻辑搬出 `JyotishAPIHandler`。核心不是行数,是全仓 3 处靠 `JyotishAPIHandler.__new__` 伪造空壳 handler 借方法(`consultation_workflow_service` ×2、`capture_report_blocked_repairs_golden`、`local_accuracy_report`,MCP 也走这条),依赖方向反了、handler 没有 `headers`/`wfile` 随时可炸。四阶段:拆 `__new__` 后门 → 抽 ≥150 行业务方法 → `do_POST`/`do_GET` 改路由表 → 重新冻结行数 baseline(余量 300→50)。纯搬运不改行为,`test_api_server_security.py` 3841 行断言一条不许改。预计 11,314 → 约 9,230 行。BUG 段 710+ | 待领取 | — |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user