feat(execpolicy): layered permission rulesets — defaults+agent+user (closes #415)#653
Conversation
All system prompts were English-only, causing DeepSeek V4 to reason and respond in English even when users wrote in Chinese or other languages. Add a Language Mirror section to base.md and base.txt that instructs the model to detect the user's primary language and use it for both reasoning (thinking tokens) and the final reply.
base.txt is not referenced via include_str! in prompts.rs. Only base.md is loaded (BASE_PROMPT). Remove the redundant change to base.txt as noted by Gemini Code Assist review.
…loses Hmbown#415) Add RulesetLayer enum (BuiltinDefault < Agent < User) and Ruleset struct so the engine can stack multiple named permission layers. Higher-priority layers shadow lower ones; within a layer, longest matching prefix wins. - ExecPolicyEngine::with_rulesets() builds from explicit layers - add_ruleset() inserts and re-sorts by priority - resolve_prefixes() merges all layers + legacy flat lists - Existing new(trusted, denied) constructor unchanged — backward compatible Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
谁家PR机器人 |
Review notes from v0.8.12 integrationReviewed the layered permission rulesets as part of merging into v0.8.12. One minor finding:
|
|
@Hmbown Thank you for the detailed review — you're exactly right on both points. Docstring fix (choosing option 1 — update docstring to match implementation): The current behavior is: all layers are concatenated in priority order (builtin → agent → user), then I'll update the docstring to say:
Pushing the fix to the PR branch now. |
47 fmt drifts had accumulated from the squash-merged community PRs on this branch (#653, #654, #655, #645, #658, #668, #659, #661, #660, #667, #656). Pure formatting — no behavioural changes — applied via `cargo fmt --all` to satisfy CI's `cargo fmt --all -- --check` gate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…g docstring Hmbown#651: fix test assertion — section_bg now Color::Reset (was DEEPSEEK_INK) Hmbown#645: replace expect() with Result in OpenSandboxBackend::new() Hmbown#653: correct resolve_prefixes docstring to describe deny-always-wins
…g docstring Hmbown#651: fix test assertion — section_bg now Color::Reset (was DEEPSEEK_INK) Hmbown#645: replace expect() with Result in OpenSandboxBackend::new() Hmbown#653: correct resolve_prefixes docstring to describe deny-always-wins
47 fmt drifts had accumulated from the squash-merged community PRs on this branch (Hmbown#653, Hmbown#654, Hmbown#655, Hmbown#645, Hmbown#658, Hmbown#668, Hmbown#659, Hmbown#661, Hmbown#660, Hmbown#667, Hmbown#656). Pure formatting — no behavioural changes — applied via `cargo fmt --all` to satisfy CI's `cargo fmt --all -- --check` gate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Replaces the flat allow/deny lists with a three-layer
Vec<Ruleset>system where higher-priority layers shadow lower ones and longest matching prefix wins within a layer.Layer priority (low → high):
BuiltinDefault→Agent→UserChanges
RulesetLayerenum (builtin_default = 0,agent = 1,user = 2)Rulesetstruct withlayer,trusted_prefixes,denied_prefixesExecPolicyEngine::with_rulesets(Vec<Ruleset>)— build from explicit layersExecPolicyEngine::add_ruleset()— insert and re-sort by priorityresolve_prefixes()— merges all layers; highest-priority last so they shadow lower entriesnew(trusted, denied)still works, flat lists treated as implicit User-layerExample
Closes #415
wangfengcsu@qq.com