Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

docs: document invariantModes and disabledInvariants policy overrides#1527

Merged
jpleva91 merged 1 commit intomainfrom
docs/invariant-overrides
Apr 5, 2026
Merged

docs: document invariantModes and disabledInvariants policy overrides#1527
jpleva91 merged 1 commit intomainfrom
docs/invariant-overrides

Conversation

@jpleva91
Copy link
Copy Markdown
Collaborator

@jpleva91 jpleva91 commented Apr 5, 2026

Summary

  • Adds an "Invariant Configuration (Policy Overrides)" section to CLAUDE.md under Architecture & Key Patterns
  • Documents the two policy YAML mechanisms for overriding built-in invariants: invariantModes (monitor mode — warn but allow) and disabledInvariants (completely disable)
  • Includes a YAML example and references the source files where these are defined and composed

Test plan

  • Verify the new section renders correctly in the CLAUDE.md
  • Confirm the referenced source files (packages/invariants/src/definitions.ts, packages/policy/src/yaml-loader.ts, packages/policy/src/composer.ts) are accurate

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 5, 2026 12:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds documentation to CLAUDE.md describing how operators can override built-in invariant behavior via policy configuration.

Changes:

  • Adds an “Invariant Configuration (Policy Overrides)” section under Architecture & Key Patterns.
  • Documents two override mechanisms (invariantModes / disabledInvariants) and provides a YAML example.
  • References the source files responsible for parsing and composing these settings.

Comment on lines +238 to +242
The 26 built-in invariants (defined in `packages/invariants/src/definitions.ts`) enforce by default, but operators can override them in policy YAML via two mechanisms. **`invariantModes`** sets an invariant to `monitor` mode — it still evaluates and emits warnings but does not block the action, useful for rolling out new invariants or during planned maintenance. **`disabledInvariants`** completely removes an invariant from evaluation — use sparingly, as it eliminates the safety check entirely. Both fields are parsed in `packages/policy/src/yaml-loader.ts` and merged across composed policies in `packages/policy/src/composer.ts` (disabled invariants union across all sources).

```yaml
# Set a specific invariant to monitor mode (warn but don't block)
invariantModes:
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc refers to a policy YAML field invariantModes and the example uses invariantModes:, but the YAML loader actually expects an invariants: mapping at the top level (parsed into policy.invariantModes). As written, the example/config key won’t be recognized by parseYamlPolicy() in packages/policy/src/yaml-loader.ts.

Suggested change
The 26 built-in invariants (defined in `packages/invariants/src/definitions.ts`) enforce by default, but operators can override them in policy YAML via two mechanisms. **`invariantModes`** sets an invariant to `monitor` mode — it still evaluates and emits warnings but does not block the action, useful for rolling out new invariants or during planned maintenance. **`disabledInvariants`** completely removes an invariant from evaluation — use sparingly, as it eliminates the safety check entirely. Both fields are parsed in `packages/policy/src/yaml-loader.ts` and merged across composed policies in `packages/policy/src/composer.ts` (disabled invariants union across all sources).
```yaml
# Set a specific invariant to monitor mode (warn but don't block)
invariantModes:
The 26 built-in invariants (defined in `packages/invariants/src/definitions.ts`) enforce by default, but operators can override them in policy YAML via two mechanisms. **`invariants`** is the top-level mapping used in YAML to set an invariant to `monitor` mode — it still evaluates and emits warnings but does not block the action, useful for rolling out new invariants or during planned maintenance. This mapping is parsed into `policy.invariantModes` by `packages/policy/src/yaml-loader.ts`. **`disabledInvariants`** completely removes an invariant from evaluation — use sparingly, as it eliminates the safety check entirely. Both fields are merged across composed policies in `packages/policy/src/composer.ts` (disabled invariants union across all sources).
```yaml
# Set a specific invariant to monitor mode (warn but don't block)
invariants:

Copilot uses AI. Check for mistakes.

### Invariant Configuration (Policy Overrides)

The 26 built-in invariants (defined in `packages/invariants/src/definitions.ts`) enforce by default, but operators can override them in policy YAML via two mechanisms. **`invariantModes`** sets an invariant to `monitor` mode — it still evaluates and emits warnings but does not block the action, useful for rolling out new invariants or during planned maintenance. **`disabledInvariants`** completely removes an invariant from evaluation — use sparingly, as it eliminates the safety check entirely. Both fields are parsed in `packages/policy/src/yaml-loader.ts` and merged across composed policies in `packages/policy/src/composer.ts` (disabled invariants union across all sources).
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph says both invariantModes and disabledInvariants are “merged across composed policies in composer.ts”, but composePolicies() only unions disabledInvariants—it does not merge/resolve invariant mode overrides. Invariant mode precedence is resolved elsewhere (e.g., CLI’s buildModeConfig() reads the first policy with invariantModes, and resolveInvariantMode() applies defaults), so the doc should reflect that (or reference those files instead).

Suggested change
The 26 built-in invariants (defined in `packages/invariants/src/definitions.ts`) enforce by default, but operators can override them in policy YAML via two mechanisms. **`invariantModes`** sets an invariant to `monitor` mode — it still evaluates and emits warnings but does not block the action, useful for rolling out new invariants or during planned maintenance. **`disabledInvariants`** completely removes an invariant from evaluation — use sparingly, as it eliminates the safety check entirely. Both fields are parsed in `packages/policy/src/yaml-loader.ts` and merged across composed policies in `packages/policy/src/composer.ts` (disabled invariants union across all sources).
The 26 built-in invariants (defined in `packages/invariants/src/definitions.ts`) enforce by default, but operators can override them in policy YAML via two mechanisms. **`invariantModes`** sets an invariant to `monitor` mode — it still evaluates and emits warnings but does not block the action, useful for rolling out new invariants or during planned maintenance. **`disabledInvariants`** completely removes an invariant from evaluation — use sparingly, as it eliminates the safety check entirely. Both fields are parsed in `packages/policy/src/yaml-loader.ts`, but only **`disabledInvariants`** is merged across composed policies in `packages/policy/src/composer.ts` (unioned across all sources). **`invariantModes`** overrides are resolved later by the CLI/runtime configuration rather than merged in the policy composer.

Copilot uses AI. Check for mistakes.
@jpleva91 jpleva91 merged commit 41c02ff into main Apr 5, 2026
9 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants