Skip to content

[PR] fix: Root cause detection for Windows startup EPERM-type issues — self-check on startup and provide remediation command | fix: Windows 启动 EPERM 一类问题的根因检测——node.exe 被 Low 完整性标签污染时启动即自检并给出修复命令 (#5154) - #5159

Merged
ranxianglei merged 13 commits into
masterfrom
2026-10-30_startup-integrity-selfcheck
Oct 30, 2026

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

(ai: zai/glm-5.3)

修什么

#5154 实测根因:node.exe 被 NTFS Low 强制完整性标签污染(通常继承自某个曾被 icacls <dir> /setintegritylevel "(OI)(CI)Low" /T 打过的父目录)。Low 进程对 Medium 级文件的每次写入都被 Windows 完整性控制直接 EPERM 拒绝——CA bundle 重建、index.db、会话信封全中招,而所有 ACL 检查都通过。这正是 #5096「崩溃循环但看不到原因」一类的机制,标签重启不消失。

改动

  • src/integrity-label.ts(新):parseIcaclsMandatoryLabel() 解析 icacls 输出的标签行;warnIfLowIntegrityRuntime() 启动自检——对 process.execPath 跑 icacls(绝对路径 C:\Windows\System32\icacls.exe,因为现场 PATH 解析失败),发现 Low/Untrusted 就打一条醒目 [integrity] 告警,附修复命令。不阻断(issue 要求 warn 不 stop),探测失败静默。
  • 启动失败提示重排(startupFailureHints 从 index.ts 移出):完整性标签检查放第一位,AV 排除第二位(SQLite unified storage degraded to legacy-only (bili v0.1.202, node v24.21.0, win32-x64) #3823)——现场走 AV 弯路最费时间。
  • src/ca.ts / src/storage/shadow.ts CANTOPEN 提示同样重排为 integrity-first。
  • CONFIGURATION.md / .zh-CN.md 新增 "Windows: node runtime labeled Low" 小节:机制、判别、修复(恢复 Medium,不是把数据目录打 Low——[PR] fix: name the win32 READONLY index.db open failure; drop the delete advice under OS-level refusals (#4614) #4625 曾给出方向相反的建议,本 PR 链上已一并修正)、目录只改根不递归即收敛、/save 备份。

测试

tests/issue5154-low-integrity-selfcheck.test.ts 10 例:解析器(含全大写输出、Medium、无标签、空输出)、提示顺序 pin(integrity < antivirus)、非 win32 无操作。typecheck 通过;回归 issue5103 / storage-cantopen-hint / ca-combined / issue5096 共 29 例全绿。

关系

Stacked on #5157(先合 #5157)。同链:#5097(冲突已解,可先合)→ #4625(方向修正已推)→ #5157 → 本 PR。

Closes #5154

ci-check and others added 13 commits October 25, 2026 06:44
…ot this PR's

master 146b34f fails the unused-exports gate on this exact line
(INTERNAL_ONLY src/agent/client-build-note.ts: ClientBuildCheck): the
type-only export #4545 introduced was missed by the 4d34abf de-export
sweep. This PR touches none of it — every PR rebased past that master
inherits the red (#4599 storm log). Same one-word fix as #4606 commit 1
and the in-branch precedents (#4607/#4595/#4540/#4618/#4622): drop the
leading export on a symbol referenced only within its own file. Drop
this commit when rebasing after #4606 merges.
…-open-hint

# Conflicts:
#	src/storage/shadow.ts
A forced power loss left the DSH-spawned child dying on EPERM at the
combined-CA bundle rewrite while a manually started proxy held the lane
port for 11 hours; every failure surface stayed silent or unactionable.

- ca: a write-refused combined-bundle rebuild now reuses the existing
  bundle when it still carries the current root CA (loud warn pointing
  at the AV-exclusion remedy) instead of exiting before the port binds;
  stays fail-fast when no usable bundle exists
- launcher: the "port answers health but is not the proxy this launcher
  spawned" info line and the final timeout error now carry the remedy
  (kill pid X / native.attachExternal); an explicit attachUrl target
  that is found but refused gets one loud line naming the reason
  (e.g. code-fingerprint-mismatch after a version skew) and the remedy;
  a dead/absent target says so instead of waiting silently
- index: "bili: failed to start" gains errno-classified hints
  (EPERM/EACCES -> OS-level write-refusal guidance)
- storage: the FIRST unified-store ingest failure now warns naming the
  db file (was silent until strike three); the disable warning keeps
  naming it; sqliteOpenFailureHint also matches "attempt to write a
  readonly database" (the field shape where the db opens but writes
  are refused)

Tests: tests/issue5103-startup-recovery-visibility.test.ts (new),
tests/ca-combined.test.ts (+2), tests/storage-cantopen-hint.test.ts (+1)
…p; Low-label-aware failure hints (#5154)

A node.exe carrying an inherited Low mandatory-integrity label cannot
write Medium-labeled files: the CA bundle rebuild, index.db, and session
envelopes all fail EPERM while every ACL check passes — the field repro
of the whole #5096 crash-loop class. The label usually arrives from a
parent dir once labeled Low (OI)(CI) and survives reboots; ACL tooling
never shows it.

- src/integrity-label.ts: parseIcaclsMandatoryLabel() + a non-blocking
  startup self-check (icacls by ABSOLUTE path on process.execPath — PATH
  resolution fails under some PowerShell/cmd profiles) that logs a loud
  [integrity] warn with the exact fix command when the runtime is
  Low/Untrusted. Observability, not a gate: the proxy keeps running.
- startupFailureHints (moved out of index.ts): integrity-label check
  FIRST (#5154: the label was the real switch; the AV detour cost the
  most hours), antivirus exclusions second (#3823).
- ca.ts / shadow.ts CANTOPEN hints reordered integrity-first.
- CONFIGURATION.md / .zh-CN.md: 'Windows: node runtime labeled Low'
  section — mechanism, diagnosis, fix (Medium, not Low!), non-recursive
  dir-root convergence, ACL backup tip.

Stacked on #5157 (#5103) — merge that first.
@ranxianglei ranxianglei changed the title [PR] fix: Windows 启动 EPERM 一类问题的根因检测——node.exe 被 Low 完整性标签污染时启动即自检并给出修复命令 (#5154) [PR] fix: Root cause detection for Windows startup EPERM-type issues — self-check on startup and provide remediation command | fix: Windows 启动 EPERM 一类问题的根因检测——node.exe 被 Low 完整性标签污染时启动即自检并给出修复命令 (#5154) Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-30_startup-integrity-selfcheck (64b0866)

Latest build — install this exact version

npm install -g billion-context@0.0.6830-pr.5159.e8c0680

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
64b0866 billion-context@0.0.6830-pr.5159.e8c0680 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr5159.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei
ranxianglei merged commit 4bb2bc1 into master Oct 30, 2026
75 of 82 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.920-master.4bb2bc1 (rolling master tag).

npm install -g billion-context@0.0.920-master.4bb2bc1  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant