-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Labels
Description
Description
Implement and document a Casbin watcher strategy to keep the enforcers’ in-memory policy state fresh. The watcher should notify enforcers when policies change and trigger a synchronization callback that aligns with our Policy Lifecycle Load/Clear approach.
MVP note: This must remain simple and reliable sufficient to validate the approach during the MVP, without complex orchestration.
Problem
- Notification-only today: The watcher broadcasts changes, but our callback only logs; no real sync occurs.
- Heavy reloads are costly: Blindly calling
enforcer.load_policy()on every change may be too expensive. - Risk of staleness: Without a proper callback, in-memory state can drift from the datastore and cause incorrect enforcement (and potential duplicates).
Requirements
- Provide a minimal, MVP-ready watcher integration: redis-wather properly configured
- Implement a synchronization callback that:
- Prefers a lightweight refresh (e.g., filtered/targeted where feasible), falling back to a safe simple path when needed.
- Coordinates with the Load/Clear lifecycle so both mechanisms stay consistent.
- Make behavior configurable for MVP (if needed):
- Enable/disable watcher.
- Select simple full reload vs. lighter refresh if adapter support exists.
- Document how the watcher is wired, what the callback does, and how it interacts with lifecycle and duplicate prevention.
- Ensure compliance with MVP goals: prioritize correctness and predictability over optimization.
Acceptance Criteria
- On policy changes, the enforcer receives watcher notifications and performs a meaningful sync beyond logging.
- Under common change scenarios, the enforcer becomes fresh without requiring heavy reloads by default (fallback allowed).
- Tests show:
- Watcher-driven sync updates in-memory policies appropriately.
- No conflicts with Load/Clear lifecycle.
- No duplicates introduced as a side effect.
Notes
- Related to Policy Lifecycle Load and Clear Management and Policy Duplicate Management the watcher can drive invalidation that lifecycle then resolves.
- Keep scope minimal for MVP; defer advanced strategies to post-MVP iterations.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done