Skip to content

feat(policy): built-in policy presets (strict | permissive | shell_safe)#126

Merged
leo-aa88 merged 3 commits into
mainfrom
feat/policy-presets-104
Jun 2, 2026
Merged

feat(policy): built-in policy presets (strict | permissive | shell_safe)#126
leo-aa88 merged 3 commits into
mainfrom
feat/policy-presets-104

Conversation

@leo-aa88
Copy link
Copy Markdown
Member

@leo-aa88 leo-aa88 commented Jun 2, 2026

Summary

  • Adds built-in policy presets strict, permissive, and shell_safe (issue feat(policy): built-in policy presets (strict | permissive | shell_safe) #104), selectable via Project.spec.defaults.policy, direct agent/workflow policy references, or Policy.spec.preset with local overrides layered on top.
  • Presets expand during NormalizeProjectGraph so validate / plan show effective rules (requireAllTools, permissive, expanded gate-token patterns for shell_safe).
  • shell_safe classifies native shell operations (command.run, run, exec, shell) by first token: read-only commands (ls, cat, …) run unattended; risky/unknown tokens and side-effecting tools require --approve.
  • agentctl init scaffold policy now uses preset: shell_safe for safe defaults out of the box.

Test plan

  • make ci (gofmt, vet, go test -race ./...)
  • Unit tests: preset registry, merge/layering, shell token classification, strict/permissive/shell_safe evaluator paths
  • Spec tests: unknown preset fails validate, builtin preset references resolve, preset expansion on normalize
  • Integration: agentctl init → validate → plan → apply → run flow
  • Manual: project with defaults.policy: shell_safe gates command.run with rm -rf but allows ls

Closes #104

Made with Cursor

…104)

Ship named presets resolvable from Project defaults, direct policy references,
or Policy.spec.preset with local overrides layered on top. Expand presets during
normalize so validate/plan show effective rules. shell_safe classifies native
shell command tokens and integrates with tool safety metadata from #103.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

ReviewGate [WARN] WARN

Stats

  • Files changed: 21
  • Raw LOC changed: 1227
  • LOC after §10.4 exclusions (human_loc_changed): 1227
  • PR author class: human (human collaborator account) — login leo-aa88 (§10.4.2).

Warnings (2)

  • medium too_large_human_loc -- PR exceeds warn human_loc_changed threshold: 1227 lines (threshold 800).
  • medium many_config_files -- This PR touches 1 config files, at or above the warning threshold of 1 (config_files_changed).

Suggested labels: reviewability-warn, too-large, config-change

File categories: 21 files (0 risky)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

Automated review

Summary

Significant additions of policy presets with schemes for shell command safety.

Findings

  • high · internal/spec/shell_tokens.goShell command risk management needs further validation
    The implementation of shell_safe relies on first-token heuristics and basic shell metacharacter checks, but it is noted as 'not a sandbox'. This could lead to missed safety issues with complex shell commands.
  • medium · internal/policy/evaluator.goApproval gating complexities
    The use of multiple approval flags (e.g. RequireAllTools, Permissive) may lead to conflicting configurations that are not immediately obvious to users, increasing potential misuse.

leo-aa88 and others added 2 commits June 2, 2026 00:58
… merge

Fail closed on shell metacharacters; remove dead synthetic requiredFor
entries; use tri-state *bool merge for requireAllTools/permissive overlays;
unify shell command helpers; simplify evaluator decision path; add adversarial
and integration tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Combine shell_safe token gating with explicit approvals.requiredFor at
runtime; move EffectiveToolDecision shell_safe check outside Approvals
guard; drop unreachable requiresToolCallApproval branch.

Co-authored-by: Cursor <cursoragent@cursor.com>
@leo-aa88 leo-aa88 merged commit 743c2f2 into main Jun 2, 2026
7 checks passed
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.

feat(policy): built-in policy presets (strict | permissive | shell_safe)

1 participant