微应用服务端编译:部署与灰度 Runbook

服务端编译(spec 192)的灰度开关、回滚操作、监控入口与 Phase 3 前置检查单

微应用服务端编译 Runbook(spec 192)

概念与开关

开关类型默认作用
appCompile.previewEnabledsystem config预览走服务端编译;关 = 整部署回浏览器 CDN 编译路径(部署级回滚)
appCompile.publishSourceEnabledsystem config发布链路接受源码包(buildMode: source)的 kill switch,与预览开关解耦

两个开关均为 system config(管理后台可改、免重启热生效);registry/缓存/并发等部署级参数走 env(.env.exampleAPP_COMPILE_* 段)。

灰度步骤(Phase 2 云端验证)

  1. 前置确认:Phase 1 验收报告结论为达标(specs/192-app-server-compile/reports/phase1-perf-acceptance.md)
  2. 开预览 flag:管理后台 → 系统配置 → 微应用编译配置 → appCompile.previewEnabled = true(或 PUT /api/v1/admin/config/appCompile.previewEnabled
  3. 验证 1-2 周:每日检查下方监控项;任一告警线触发按处置动作执行
  4. 发布链路灰度(独立于预览):skill 新版随组织同步后,appCompile.publishSourceEnabled = true;期间旧格式包(已编译包)始终兼容入库
  5. 翻转默认值:连续稳定后,将 appCompile.previewEnabled 默认值翻转为开(代码默认值变更 + 发版)

回滚操作

  • 预览回滚appCompile.previewEnabled = false——立即回退到 CDN 编译路径(存量已发布应用零影响)
  • 发布回滚appCompile.publishSourceEnabled = false——回到仅接受已编译包;旧版 skill 的源码包上传会被拒绝(skill 侧有 backend 能力探测,自动打已编译包兜底)
  • 单次编译失败不回滚:失败展示错误 + 保留上次成功产物(spec 决策 Q4=B:不静默回退 CDN)

监控入口与告警线

指标与告警线定义见验收报告"告警线"表(编译成功率/p95/缓存水位/registry 错误率/关键 API 劣化)。dashboard(Grafana)随云端灰度接入;日志检索按 request-id 关联(脱敏规则 R3-F7)。

关键命令(任意环境可重复验收):

node apps/backend/scripts/app-compile/bench.js --base <环境地址> node apps/backend/scripts/app-compile/bench-concurrent.js --base <环境地址>

Phase 3 前置检查单(不可逆操作四条确认)

删除 CDN/V1 浏览器编译路径与 Agent 侧 build-panels.mjs 前,逐条确认:

  • appCompile.previewEnabled 默认开且线上无回滚诉求(稳定一个版本周期)
  • appCompile.publishSourceEnabled 稳定一个版本周期
  • V1 Worker 遥测归零(浏览器 CDN 编译调用计数连续一周为 0)
  • 旧格式上传遥测归零(已编译包上传计数连续一周为 0)

四条全满足才执行删除;删除版本保留一个周期的回滚版本边界。

环境变量清单

apps/backend/.env.exampleAPP_COMPILE_* 段(registry、缓存根/配额、安装/编译超时、两级并发参数)。黑名单判定:两侧(session-manager / sandbox-rs filtered_env)均豁免——依据见 specs/192-app-server-compile/reports/env-blacklist-adjudication.md。