Skip to content

fix(sidecar): 启动期 ACL 加固永不收敛 + 超时致命,数据目录膨胀后本地服务必崩 - #451

Closed
Ver-zhzh wants to merge 1 commit into
huiliyi37:mainfrom
Ver-zhzh:fix/issue-450-sidecar-acl-timeout
Closed

Ver-zhzh wants to merge 1 commit into
huiliyi37:mainfrom
Ver-zhzh:fix/issue-450-sidecar-acl-timeout

Conversation

@Ver-zhzh

Copy link
Copy Markdown
Collaborator

修复批次:sidecar 启动期 ACL 加固

issue #450:数据目录涨到 48k 文件后,本地服务每次启动期必崩且不自愈(3 次重试均超时,lastHealthyAt 始终 null)。根因经报告者实测定位,本 PR 按其建议方向做最小修复。

Closes #450

1. SDDL 比较永不收敛 → 每次启动重跑数十秒无效写入

现象:protectPrivatePath(src/platform/private-path.ts)的 PowerShell 脚本用整串 SDDL 比较决定是否重写 DACL;读回值 D:PAI(...) 与目标 D:P(...) 只差 AI(自动继承)标记,被判为不一致。
根因:P(不从父继承)已设置时 AI 只是来源标记,有效授权完全相同;且 Windows 侧该写入本就不生效(写前/写后读回 SDDL 完全相同),于是每次启动都在 48k 文件上重跑一次 24s+ 的无效写入。
修复:比较前归一化 D:PAI -> D:P(脚本内 -replace '^D:PAI', 'D:P',TS 侧新增 normalizeAclSddlForComparison 同规则导出以便测试)。未设保护的 D:AI 仍判为不同、照常写入加固;安全语义不变(仍是保护 + 仅当前用户/SYSTEM/Administrators FullControl,owner 校验保留)。

2. 加固超时一票否决服务启动

现象:execFileSync(powershell, ..., { timeout: 10_000 }) 在 runServe() 早期无 try/catch,异常冒泡导致 sidecar 在 listen 前 process.exit(1),/health 永远不通;桌面端 3 次重试后 circuit_open。
修复:新增 hardenServeDataDir()(src/server/serve.ts),runServe 启动期加固改走它:超时/失败时 serverLogger.warn 记录并降级继续 listen。加固只是纵深防御的一层,不应拥有否决服务启动的权力。

未修观察(如实报告,非本批引入)

  • issue 建议的第 4 点(desktop\\recovery-journal 无上限增长到 22.5k 文件)属数据治理范畴,不在本批范围内。
  • 首次真正需要写入的大目录仍可能撞 10s 超时:此时服务照常启动(warn),下次启动重试;属可接受的降级行为。

验证

项 结果
npx tsc --noEmit 0 新增报错
npm test 相关文件(private-path / serve-acl-hardening / server-info-protection / server-info) 28 pass,0 fail(2 个 Windows 原生用例在 Linux 上按既有 skip 规则跳过)
冒烟:用 issue 报告的实测 SDDL 对验证 旧逻辑判"需重写"=true,新逻辑=false;脚本已含归一化比较
冒烟:模拟 ETIMEDOUT 走 hardenServeDataDir 不抛错,warn 落盘含 #450 标识

- SDDL 比较前归一化 AI 继承标记(D:PAI -> D:P):只差 AI 标记时判已收敛,
  不再每次启动都在整棵子树上重跑数十秒的无效写入
- runServe 启动期 ensurePrivateDirectory 改走 hardenServeDataDir:
  加固超时/失败时 warn 降级继续 listen,不再 process.exit(1)

Closes huiliyi37#450
@Ver-zhzh
Ver-zhzh force-pushed the fix/issue-450-sidecar-acl-timeout branch from cd1872c to c4058c5 Compare October 11, 2026 18:45
@Ver-zhzh

Copy link
Copy Markdown
Collaborator Author

CI 状态说明(2026-10-12)

  • CLI frontend 三平台全绿(macos / ubuntu / windows),Type check 通过。
  • windows-smoke:卡在 Windows watchdog rescue and Git probe teardown(EPERM, Permission denied 写 runner 临时目录),属 Windows runner 环境问题;该步骤的三个测试文件(watchdog-rescue / git-freshness / git-freshness-lifecycle)与本 PR 改动无任何 import 关系,本地 26/26 通过。已按仓库惯例重跑一次,仍是同一 EPERM。
  • ci (24):失败集与上游 main(abb76289,run 38137254300)逐项一致,均为预存红(capsule/RSS/发布工具链/AtomGit 等);本 PR 引入的 serve.ts 行数棘轮已在第二轮提交中按惯例更新 scripts/source-budgets.manifest.json(ceiling 1534→1563,附理由),其余三处棘轮超标(env-registry / schema / read-file)为 main 预存,未动。

@Ver-zhzh

Copy link
Copy Markdown
Collaborator Author

CI 说明(非本 PR 引入):ci (24) / windows-smoke 两处红灯与上游 main 基线一致——main 分支最近 5 次 CI 全部 failure,最新一次(run 38137254300,纯 main 无改动)红灯检查与本 PR 完全相同:ci (24) 挂在 cognitive-capsule-router 系列断言,windows-smoke 挂在 watchdog-rescue 测试的 Windows EPERM 临时目录清理问题。均与本 PR 改动文件(src/platform/private-path.ts、src/server/serve.ts 及对应测试)无关。本 PR 相关测试本地 28 pass / 0 fail(见正文验证表),tsc 无新增报错。

@Ver-zhzh

Copy link
Copy Markdown
Collaborator Author

CI 说明(本轮复核结论):本 PR 的 ci (24) / windows-smoke 红与改动无关——main 分支最近 5 次 CI 全红(run 38137254300 等),失败签名完全一致。根因在 main 侧:ci (24) 的 failing test 为 release v3.30.0 缺少 manifest 引用的资产:Tianshu_3.30.0_aarch64.app.tar.gz Tianshu_3.30.0_x64.app.tar.gz Tianshu_3.30.0_x64-setup.exe Tianshu_3.30.0_aarch64.AppImage Tianshu_3.30.0_amd64.AppImage(发布资产缺失,属 release 打包侧问题,需维护者处理)。本 PR 代码侧验证见正文验证表(tsc 0 新增报错、相关测试 28 pass)。

@huiliyi37

Copy link
Copy Markdown
Owner

已通过 sync 流程合入 dev,感谢 @Ver-zhzh 的贡献 🎉

本 PR 的改动(fix(sidecar): 启动期 ACL 加固永不收敛 + 超时致命,数据目录膨胀后本地服务必崩)已经 sync 流程合入主仓(本次 sync),并已收录进 CONTRIBUTORS.md。

按仓库的双仓流程,公开仓 PR 不经 merge 按钮合入(保持 dev 主仓唯一事实源),现以 sync-merged 标记关闭。欢迎继续贡献!

@huiliyi37 huiliyi37 added the sync-merged 内容已通过 sync 流程合入 dev 主仓(PR 形态留痕,作者计入 CONTRIBUTORS) label Oct 12, 2026
@huiliyi37 huiliyi37 closed this Oct 12, 2026
huiliyi37 added a commit that referenced this pull request Oct 12, 2026
内容已经 sync 流程合入(本次 sync),本提交为作者署名落账:
GitHub 贡献者图谱按 Co-authored-by trailer 计入。

Co-authored-by: Ver-zhzh <Ver-zhzh@users.noreply.github.com>
huiliyi37 pushed a commit that referenced this pull request Oct 12, 2026
huiliyi37 added a commit that referenced this pull request Oct 23, 2026
内容已经 sync 流程合入(本次 sync),本提交为作者署名落账:
GitHub 贡献者图谱按 Co-authored-by trailer 计入。

Co-authored-by: Ver-zhzh <Ver-zhzh@users.noreply.github.com>
huiliyi37 pushed a commit that referenced this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sync-merged 内容已通过 sync 流程合入 dev 主仓(PR 形态留痕,作者计入 CONTRIBUTORS)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] sidecar 启动期 ACL 加固全树递归 + 10s 硬超时:数据目录涨到 48k 文件后本地服务必崩且不自愈

2 participants