litellm/tests/test_litellm/proxy/policy_engine
Cursor Agent 33cceafa54 fix: address remaining policy engine reliability issues
1. Fix race condition in update_version_status promote-to-production:
   - Wrap demote (update_many) + promote (update) in a Prisma transaction
   - Prevents concurrent promote calls from leaving two versions as production

2. Fix stale _policies_by_id cache in delete methods:
   - delete_policy_from_db: remove entry from _policies_by_id when deleting
     a draft/published version
   - delete_all_versions: scan and remove all _policies_by_id entries
     matching the deleted policy_name

3. Fix docstring for update_version_status:
   - Remove documented-but-unimplemented 'production -> published' transition
   - Clarify which transitions are valid vs invalid

4. Add tests for new behavior:
   - test_published_to_production_removes_from_policies_by_id
   - test_delete_draft_removes_from_policies_by_id_cache
   - test_delete_all_versions_cleans_policies_by_id_cache
   - Update existing promote-to-production tests to mock transaction

Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2026-02-22 03:58:23 +00:00
..
__init__.py [Feat] New LiteLLM Policy engine - create policies to manage guardrails, conditions - permissions per Key, Team (#19612) 2026-01-22 19:49:53 -08:00
test_attachment_registry.py [Feat] Policies - Allow connecting Policies to Tags, Simulating Policies, Viewing how many keys, teams it applies on (#20904) 2026-02-10 17:50:37 -08:00
test_condition_evaluator.py [Feat] New LiteLLM Policy engine - create policies to manage guardrails, conditions - permissions per Key, Team (#19612) 2026-01-22 19:49:53 -08:00
test_pipeline_executor.py [Guardrails] Add guardrail pipeline support for conditional sequential execution (#21177) 2026-02-13 19:49:12 -08:00
test_policy_matcher.py [Feat] Policies - Allow connecting Policies to Tags, Simulating Policies, Viewing how many keys, teams it applies on (#20904) 2026-02-10 17:50:37 -08:00
test_policy_resolver.py [Feat] New LiteLLM Policy engine - create policies to manage guardrails, conditions - permissions per Key, Team (#19612) 2026-01-22 19:49:53 -08:00
test_policy_validator.py [Feat] New LiteLLM Policy engine - create policies to manage guardrails, conditions - permissions per Key, Team (#19612) 2026-01-22 19:49:53 -08:00
test_policy_versioning.py fix: address remaining policy engine reliability issues 2026-02-22 03:58:23 +00:00
test_policy_versioning_e2e.py fix: address remaining policy engine reliability issues 2026-02-22 03:58:23 +00:00