Skip to content

Policy Engine: Make 'modes' field mandatory in TOML rules #24797

@kschaab

Description

@kschaab

Problem

Currently, the modes field in policy rules and safety checkers defined in TOML files is optional. Rules that omit this field apply to all approval modes by default. This can lead to unintended tool behavior in specific modes (like Plan Mode) if the user/admin isn't careful.

Proposed Solution

Make the modes field mandatory for all rules and safety checkers defined in TOML policy files.

Key Changes:

  • Schema Enforcement: Update the Zod validation schema in toml-loader.ts to require the modes array.
  • Type Safety: Update the PolicyRule and SafetyCheckerRule interfaces in types.ts to make modes a required property.
  • Documentation: Update the policy engine documentation to reflect that modes is now required.
  • Migration: Update all existing test policies and default policies to include explicit modes.
  • Legacy Support: The policy engine (policy-engine.ts) will still match rules without modes to all modes to ensure backward compatibility for rules injected programmatically, but the loader will enforce it for TOML files.

Metadata

Metadata

Assignees

Labels

area/enterpriseIssues related to Telemetry, Policy, Quota / Licensing🔒 maintainer only⛔ Do not contribute. Internal roadmap item.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions