Skip to content

fix(policy): report correct rule count in /policy status when using policy_file#1901

Merged
bug-ops merged 2 commits intomainfrom
1898-policy-status-rule-count
Mar 16, 2026
Merged

fix(policy): report correct rule count in /policy status when using policy_file#1901
bug-ops merged 2 commits intomainfrom
1898-policy-status-rule-count

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 16, 2026

Summary

  • /policy status reported rules: 0 when all rules came from an external policy_file
  • Root cause: handle_policy_command() used policy_config.rules.len() which only counts inline TOML entries; file-loaded rules are merged in PolicyEnforcer::compile() and never written back to policy_config.rules
  • Fix: added PolicyEnforcer::rule_count() accessor; status handler now calls PolicyEnforcer::compile() to get the merged total, with fallback to the inline count on compile error

Test plan

  • All 6006 unit tests pass (cargo nextest run --workspace --features full --lib --bins)
  • cargo clippy --features full --workspace --lib --bins -- -D warnings passes
  • cargo +nightly fmt --check passes
  • Manual: config with policy_file only shows correct non-zero rule count in /policy status

Closes #1898.

@github-actions github-actions bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate bug Something isn't working size/S Small PR (11-50 lines) labels Mar 16, 2026
…olicy_file

handle_policy_command() was using policy_config.rules.len() which only
counts inline TOML rules. Rules loaded via policy_file are merged during
PolicyEnforcer::compile() and never reflected in that field.

Add PolicyEnforcer::rule_count() accessor and use PolicyEnforcer::compile()
in the status handler to get the merged total, falling back to inline count
on compile error.

Closes #1898.
@bug-ops bug-ops force-pushed the 1898-policy-status-rule-count branch from 65bad32 to d818379 Compare March 16, 2026 00:01
@bug-ops bug-ops enabled auto-merge (squash) March 16, 2026 00:01
@bug-ops bug-ops merged commit 9e5e089 into main Mar 16, 2026
20 checks passed
@bug-ops bug-ops deleted the 1898-policy-status-rule-count branch March 16, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate documentation Improvements or additions to documentation rust Rust code changes size/S Small PR (11-50 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(policy): /policy status shows rules: 0 when rules loaded from policy_file only

1 participant