Skip to content

fix(release): offline DB schema init + preflight digest-pin env - #226

Merged
nghqqa merged 1 commit into
mainfrom
offline-schema-init
Sep 13, 2026
Merged

nghqqa merged 1 commit into
mainfrom
offline-schema-init

Conversation

@nghqqa

@nghqqa nghqqa commented Sep 13, 2026

Copy link
Copy Markdown
Owner

问题

0912 外部 Windows 机器烟测:镜像 load 9/9、digest 9/9,但栈起不来 — 控制器报 relation "task_runs" does not exist(离线包缺 DB 迁移),随后又连环暴露 5 个启动门禁问题。

修复(release/offline/)

文件 解决的故障
000-roles.sql 迁移引用的角色不存在(PG 未加引号标识符折叠为小写,"MERGEPILOT_APPROVER" ≠ mergepilot_approver)→ 幂等 DO 块小写预建
001-init.sql tools/audit-db 13 个迁移按字母序执行时 approvals 尚未创建 → 按表依赖拓扑排序
002-console.sql demo_console 自身两个迁移未入包(environment_identity + mergepilot_reader ACL)
003-logins.sql 运行时 LOGIN 角色 + reader 会话 default_transaction_read_only=on(NOT_READ_ONLY fail-closed 门)
004-environment.sql ISOLATED_LIVE 环境标记行
005-seed.sql demo task_runs 行(RUN_NOT_FOUND fail-closed 门)

compose 增加两处:postgres 挂载 docker-entrypoint-initdb.d;preflight 传 MERGEPILOT_DECLARED_PG_IMAGE(IMAGE_DIGEST_MISMATCH 门,tag 引用与 digest 声明分离的 §4 方案)。

start-stack.{bat,sh} 两阶段启动器:先单起 postgres 测桥接 IP 写入 MERGEPILOT_PG_EXPECTED_SERVER_ADDRESSES(WRONG_SERVER pin),再全量启动。

验证(全新卷端到端)

ZIP 布局(compose 与 db-init 同级)已按测试字节原样随 v0.2.1 发布;仓库内挂载路径为 ./release/offline/db-init(唯一文本差异,PR 内说明)。

External-machine test (0912) failed at startup: the offline bundle had no
DB migrations, so the controller died on 'relation task_runs does not
exist'. Ship a docker-entrypoint-initdb.d bundle under release/offline/db-init/:

- 000-roles.sql       idempotent pre-create of every role the migrations
                      reference (PG folds unquoted identifiers to lowercase
                      - the mergepilot_approver trap)
- 001-init.sql        tools/audit-db/*.sql topologically sorted so
                      m3b_policy (approvals) precedes the b4 series
- 002-console.sql     demo_console migrations (environment_identity +
                      mergepilot_reader ACL)
- 003-logins.sql      runtime LOGIN roles + passwords + reader
                      default_transaction_read_only (NOT_READ_ONLY gate)
- 004-environment.sql ISOLATED_LIVE environment marker row
- 005-seed.sql        demo task_runs row (RUN_NOT_FOUND fail-closed)

compose: mount the init dir into postgres and pass
MERGEPILOT_DECLARED_PG_IMAGE to the preflight digest gate
(IMAGE_DIGEST_MISMATCH). start-stack.{bat,sh} two-phase launcher measures
the compose bridge IP for MERGEPILOT_PG_EXPECTED_SERVER_ADDRESSES
(WRONG_SERVER pin).

Verified end-to-end from a fresh volume: 6 services healthy, preflight
PREFLIGHT_OK (exit 0), 8600/8090 return 200, 29 tables + l2_* functions
present.
@nghqqa
nghqqa merged commit ed3b41d into main Sep 13, 2026
3 checks passed
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