Skip to content

fix(kimi-code): correct permission rule precedence and warn on rules Kimi never applies - #3931

Merged
dyoshikawa merged 3 commits into
mainfrom
resolve-issue-2502-kimi-permission-precedence
Nov 22, 2026
Merged

dyoshikawa merged 3 commits into
mainfrom
resolve-issue-2502-kimi-permission-precedence

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

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 deny rules take precedence over matching ask rules, which take precedence over matching allow rules". Rule order does not decide the result. Rulesync's docs still said Kimi evaluates rules first-match-wins, and they suggested that kimi-code.rules entries, which are emitted first, could carve exceptions out of broader canonical rules. They can't: an allow for Bash(git status) under a canonical Bash deny never takes effect.

  • Docs: docs/reference/file-formats.md now 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.
  • Shadowed overrides: on generate, Rulesync warns when a kimi-code.rules allow/ask is 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.
  • Ignored scopes: on generate, Rulesync warns when a rule uses the turn-override or session-runtime scope. Kimi silently ignores those scopes in the user config.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)

  • Project-scope permissions in .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:
    • a new shared-file ownership entry for local.toml, which also holds the legacy [workspace] additional_dir;
    • which kimi-code.* overrides apply at project scope (defaultPermissionMode, tools and dangerousCommandGuard are user-config keys);
    • how to treat the trust gate, and the fail-closed session block when a rule is invalid;
    • gitignore handling.
  • Plugin MCP/hooks behind the kimi.plugin.json manifest.
  • Importing the [permission] allow/deny/ask array form (the ownership trade-off).
  • Whether to accept executor: "kaos".

Test plan

  • New unit tests in src/features/permissions/kimi-code-permissions.test.ts
  • pnpm cicheck

🤖 Generated with Claude Code

https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4

dyoshikawa and others added 3 commits November 22, 2026 17:26
…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
@dyoshikawa
dyoshikawa merged commit d3514db into main Nov 22, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-2502-kimi-permission-precedence branch November 22, 2026 08:48
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.

1 participant