feat(sessions): load and apply user policy - #733
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughUser policy loading and enforcement now flow through minimal activation. Policy expansion supports non-absolute patterns, rejects per-user tilde prefixes, and applies deny-over-ignore precedence. Activation passes loaded policy and compose options through contribution composition and pending handling. ChangesUser policy flow
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant cmd_activate
participant config_read_user_policy
participant read_user_policy_or_default
participant compose_user_contribution
participant drive_pending_to_active
participant handle_response
cmd_activate->>config_read_user_policy: load user_policy.toml
config_read_user_policy->>read_user_policy_or_default: read policy or return empty policy
read_user_policy_or_default-->>config_read_user_policy: UserPolicy
cmd_activate->>compose_user_contribution: compose loadouts with UserPolicy and ComposeOptions
cmd_activate->>drive_pending_to_active: pass UserPolicy and ComposeOptions
drive_pending_to_active->>handle_response: handle pending response with policy and options
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
twitchyliquid64
left a comment
There was a problem hiding this comment.
cargo fmt && cargo clippy --all-targets --fix --allow-dirty -- -D warnings && cargo fmt
b72188a to
4e87874
Compare
Load
user_policy.tomlfrom<config>/minimal/and thread it throughactivation. Fills in the placeholder
UserPolicy::empty()/UserPolicy::default()sites that were shipping unenforced.sessions::core::policy—read_user_policy_file/_or_defaultloaders (empty policy on
NotFound).minimal::config::read_user_policy— helper mirroringread_client_config. Loaded once incmd_activate, passed intoboth
compose_user_contributionanddrive_pending_to_active.drive_pending_to_activenow takesUserPolicy+ComposeOptions(was defaults) — daemon-response pending items get gated against
the real policy.
Policy semantics fixes
Two behavior corrections uncovered while wiring this up:
VarsPolicyandExpandedPatchPolicy. Deny is the emergency stop — it can't besilently hidden behind an overlapping ignore glob.
PathDecision::combinewas already correct; single-path
decide/checkwere inverted.expand_source(patch-source, must-be-absolute walker input) fromexpand_policy_pattern(matcher against real paths).deny = ["**/*.pem"]inuser_policy.tomlnow works.~name/tilde-userform still rejected loudly (was previously caught by the absolute
check; now has its own
ExpandError::UnsupportedTildeUservariantso both code paths surface the footgun).
Summary by CodeRabbit
user_policy.toml, with missing files defaulting to an empty policy.denyrules now consistently take precedence overignorefor both variables and patch matching, including overlapping rules.~name/...) are rejected earlier with a clearer error.