Skip to content

test(permissions): item 21 auto-mode 本地规则分类器测试覆盖 (CC 2.1.210-234, #119) - #120

Merged
dahai80 merged 1 commit into
mainfrom
test/automode-classifier-item21
Aug 22, 2026
Merged

dahai80 merged 1 commit into
mainfrom
test/automode-classifier-item21

Conversation

@dahai80

@dahai80 dahai80 commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Closes #119.

缺口

item 21 (auto-mode 权限分类器, CC 2.1.210-234): 本地规则分类器已存在+已连线 (committed c718fbe, wired bashPermissions.ts:1161), LLM 分类器 + 并行缓存全 ANT-only/OSS-死/纯函数缓存无价值。唯一真缺口 = 安全敏感分类逻辑零测试覆盖 (Rule 9)。

改动 (test-only, surgical)

1 新测试文件, 零 prod 改动 (`git diff --stat` = +1 file)。

81 单测覆盖:

  • `classifyAllShell` 全分支: hard_deny (16 模式: git push --force/reset --hard/clean -fd/stash drop/branch -D/kubectl delete/terraform destroy/DROP|TRUNCATE TABLE/DELETE FROM/rm -rf //dd of=/dev//chmod 000/shutdown/reboot), dangerous ask (rm -rf/sudo/git push/ssh/scp/eval/exec/interpreter prefixes), safe allow (ls/cat/grep/git status/npm test/bun/cargo/pytest/biome/tsc/read-only base), write-redirect, pipe-to-interpreter, compound, likely-write-base, default-fail-deny (unclassified→ask NOT allow), empty→safe。
  • precedence: hard_deny beats dangerous (git push --force), hard_deny regex 扫全串 (ls && rm -rf / → hard_deny)。
  • `modeValidation` wiring: auto safe→allow/ask→ask/hard_deny→deny (+decisionReason), acceptEdits+filesystem→allow, bypassPermissions/dontAsk/default→passthrough, compound first-wins, empty→passthrough。
  • 文档化已知 precedence 限制: safe-prefix 检查在 compound 检查前 → `ls && rm -rf tmp` (rm-rf-tmp 逃逸 /-anchored regex) 分类 `safe`。记录防静默回归 (Rule 3: test-only 不改行为)。

验证

检查 结果
`bun test src/tests/utils/autoModeClassifier.test.ts` 81 pass, 0 fail
`bun test src/tests/` 363 pass, 0 fail, 无回归
`bun run typecheck` 0 errors
`bun run build:dev` pass
biome check (新文件) clean
`git diff --stat` +1 test 文件, 零 prod 改动

Tier 判定

memory audit (tier23-backlog) 判 item 21 "L, 安全敏感, Tier-3 学模式, defer 或最小本地等价"。选最小本地等价 = 测试覆盖闭 Rule 9 缺口。LLM + 缓存缺口全 ANT-only/OSS-死/纯函数无价值, OSS 无可建。标 item 21 ✅ 最小本地等价。

Co-Authored-By: Claude Fable 5 [email protected]

安全敏感 bash 权限判定零测试覆盖 (Rule 9 缺口)。本地规则分类器
(autoModeDangerList.ts classifyAllShell + modeValidation.ts auto 模式
wiring, committed c718fbe) 已存在且已连线 bashPermissions.ts:1161,
但 src/__tests__/ 无任何引用。LLM 分类器 (Sonnet 5 模型固定) + 并行
缓存 (CC 2.1.221) 全 ANT-only/OSS-死/纯函数缓存无价值, OSS 无可建。

test-only PR, 最小本地等价 (memory audit "defer 或最小本地等价"):
- 81 单测覆盖 classifyAllShell 全分支: hard_deny 16 模式, dangerous
  ask, safe allow, write-redirect, pipe-to-interpreter, compound,
  likely-write-base, default-fail-deny (NOT allow), empty safe。
- modeValidation wiring: auto safe→allow/ask→ask/hard_deny→deny,
  acceptEdits+fs→allow, bypass/dontAsk/default→passthrough, compound
  first-wins, empty→passthrough。
- 文档化 1 已知 precedence 限制: safe-prefix 在 compound 前, 故
  'ls && rm -rf tmp' (rm-rf-tmp 逃逸 /-anchored regex) → safe。
  记录防静默回归 (Rule 3 test-only 不改行为)。

验证: 81 新测 pass / 363 全套 pass 无回归 / typecheck 0 / build:dev pass。
surgical: +1 test 文件, 零 prod 改动。

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit ec8854e into main Aug 22, 2026
1 check passed
@dahai80
dahai80 deleted the test/automode-classifier-item21 branch August 22, 2026 08:42
dahai80 added a commit that referenced this pull request Aug 22, 2026
Patch release bundling 17 commits since v0.4.23:
- item 15(a) MLX OOM auto-recovery gc+retry (#129)
- #7 one-click diagnostic fixAction framework (#131)
- 维度5 background-default spawn FUSION_SUBAGENT_DEFAULT_BACKGROUND (#127)
- #4 proactive MLX OOM detection via /v1/health (#125)
- item 17 fullscreen pre-compact history + :598 synthetic decouple (#123)
- item 25B workflow stagger fan-out (#122)
- item 21 auto-mode local rule classifier test coverage (#120)
- item 23 archive plugin source + SHA-256 lock (#118)
- item 24 marketplace command source (#116)
- item 6 transcript disk trimming + crash-safe checkpoint (#114)
- item 5 normalizeMessages secondary normalize cache (#112)
- item 19 screen-reader plaintext render (#110)
- item 16 compact retry countdown + stall hint (#108)
- item 25A workflow execution runtime docs (#106)
- item 25A minimal workflow execution runtime (#105)
- item 12 subagent auto-background threshold (#103)
- item 20 vimInsertModeRemaps dual-key INSERT sequence (#101)

Co-Authored-By: Claude Fable 5 <[email protected]>
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.

item 21: auto-mode 本地规则分类器零测试覆盖 (CC 2.1.210-234)

1 participant