fix(build): Windows 树杀与错误码分阶段包裹;清残覆盖 manifest;反斜杠守卫与 stat 收窄

质量复审五修(Plan 4 Task 5):
- Fix 1 超时杀整棵进程树:win32 走 taskkill /PID /T /F(child.kill 只杀
  pnpm.cmd 壳层,astro/vite 孤儿会继续写 dist 并占句柄);POSIX detached
  进程组 + kill(-pgid, SIGKILL)。暂存 dist 预清 rm 包成 THEME_BUILD_FAILED
  (孤儿句柄 EPERM 不再裸抛误标 SNAPSHOT_FAILED)。
- Fix 2 五处裸抛分阶段裹码:媒体校验读回 → MEDIA_COPY_FAILED;sitemap/
  robots 写、dist 拷出、目录哈希 → MANIFEST_WRITE_FAILED;service 对
  building 期非 PipelineError 裸错误标 PIPELINE_INTERNAL(码位新增)。
- Fix 3 失败清残覆盖 route-manifest.json;build_artifacts 已登记行注明
  审计豁免(与快照行同语义)。
- Fix 4 媒体 public_path 反斜杠拒绝(Windows 路径解析会绕过 '/'-split
  的 '..' 段检测)。
- Fix 5 stat 缺席语义缩窄到 ENOENT,其余错误原样上抛。

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-10-22 11:30:05 +08:00
parent 1ed3ac062a
commit 41829e2665
3 changed files with 150 additions and 30 deletions
+3 -1
View File
@@ -369,8 +369,10 @@ describe('构建管线全链(mini 夹具 DB 物化输入)', () => {
expect(job[0].error_summary).toContain('Render Snapshot 文件缺失或不可读')
expect(job[0].error_summary).toContain('content.json')
// dist 清残:产物目录与主题暂存 dist 均无残留;input/ 同样清场(failed 无产物语义)
// dist 清残:产物目录与主题暂存 dist 均无残留;input/ 与 route-manifest.json
// 同样清场(failed 无产物语义——复审 Fix 3:清残面覆盖 manifest 文件)
expect(existsSync(join(artifactsRoot, 'jobs', failingJobId, 'dist'))).toBe(false)
expect(existsSync(join(artifactsRoot, 'jobs', failingJobId, 'route-manifest.json'))).toBe(false)
expect(existsSync(themeDistDir())).toBe(false)
expect(existsSync(join(artifactsRoot, 'jobs', failingJobId, 'input'))).toBe(false)
// 半途失败无 build_artifacts 行