Repository navigation
fix(kimi-code): correct permission rule precedence and warn on rules Kimi never applies - #3931
Merged
Merged
Conversation
…Kimi never applies Kimi Code ranks matching permission rules deny > ask > allow regardless of their order; it does not let the first match win. Correct the docs, and warn when a `kimi-code.rules` allow/ask is outranked by a stricter rule with the same pattern or on the bare tool, and when a rule uses the `turn-override` or `session-runtime` scope, which Kimi silently ignores in `config.toml`. Refs #2502 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
Warn about canonical allow/ask rules outranked by a stricter rule too, skip rules whose own scope Kimi ignores so they are not reported twice, and share one pattern splitter between the shadow check and the specificity sort. Refs #2502 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…mi-permission-precedence # Conflicts: # src/generated/docs-content.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follows up the 2026-11-19 upstream re-check on #2502 (Kimi Code 2.6.0).
Kimi Code's config docs now say "Matching
denyrules take precedence over matchingaskrules, which take precedence over matchingallowrules". Rule order does not decide the result. Rulesync's docs still said Kimi evaluates rules first-match-wins, and they suggested thatkimi-code.rulesentries, which are emitted first, could carve exceptions out of broader canonical rules. They can't: anallowforBash(git status)under a canonicalBashdeny never takes effect.docs/reference/file-formats.mdnow describes the deny > ask > allow precedence. The fail-closed ordering is kept, so the file reads the way Kimi decides. The generated output does not change.kimi-code.rulesallow/askis outranked by a stricter rule that has the same pattern or is the bare name of the same tool. Wildcard overlaps are not detected, so the check never reports a false shadow, but it can miss one.turn-overrideorsession-runtimescope. Kimi silently ignores those scopes in the userconfig.toml. The rule is kept as authored so import/regenerate round-trips stay intact, and such a rule is not counted as shadowing another.Still open on #2502 (not in this PR)
.kimi-code/local.toml(Kimi Code 2.6.0, feat(agent-core-v2): persist user and project permission rules MoonshotAI/kimi-code#4550). This needs design calls:local.toml, which also holds the legacy[workspace] additional_dir;kimi-code.*overrides apply at project scope (defaultPermissionMode,toolsanddangerousCommandGuardare user-config keys);kimi.plugin.jsonmanifest.[permission]allow/deny/askarray form (the ownership trade-off).executor: "kaos".Test plan
src/features/permissions/kimi-code-permissions.test.tspnpm cicheck🤖 Generated with Claude Code
https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4