Skip to content

Conversation

@JadeCara
Copy link
Contributor

@JadeCara JadeCara commented Dec 9, 2025

Ticket ENG-2145

Description Of Changes

🎯 As a Privacy Admin, I want to create conditions that map request attributes to DSR policies, so that incoming privacy requests are automatically assigned the correct policy based on their characteristics.

Details

Policy conditions define when a specific DSR policy should be assigned to a privacy request. Each condition set is associated with a single policy and contains one or more rules that evaluate request data. Conditions can be simple (single field check) or complex (multiple fields with AND/OR logic).

This PR moves policy.py into a policy dir and adds src/fides/api/models/policy/conditional_dependency.py along with the alembic migration and tests. This follows the pattern established for both digest and manual tasks.

Code Changes

  • moved src/fides/api/models/policy.py into new policy dir
  • added new src/fides/api/models/policy/conditional_dependency.py
  • created migration
  • added tests

Steps to Confirm

  1. All current policy related things should not change with the file move.
  2. All tests should pass.

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
    • Updates unreleased work already in Changelog, no new entry necessary
  • UX feedback:
    • All UX related changes have been reviewed by a designer
    • No UX review needed
  • Followup issues:
    • Followup issues created
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

@vercel
Copy link

vercel bot commented Dec 9, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
fides-plus-nightly Ignored Ignored Preview Dec 11, 2025 3:55pm
fides-privacy-center Ignored Ignored Dec 11, 2025 3:55pm

@JadeCara JadeCara marked this pull request as ready for review December 9, 2025 21:22
@JadeCara JadeCara requested a review from a team as a code owner December 9, 2025 21:22
@JadeCara JadeCara requested review from johnewart and removed request for a team December 9, 2025 21:22
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 9, 2025

Greptile Overview

Greptile Summary

This PR introduces policy conditional dependencies by creating a new PolicyCondition model that follows the established ConditionalDependencyBase pattern. The changes enable automatic assignment of DSR policies to privacy requests based on request attributes.

Key Changes:

  • Restructured policy.py into a policy directory (src/fides/api/models/policy/) following the pattern used for digest and manual tasks
  • Added PolicyCondition model that inherits from ConditionalDependencyBase to support single-type hierarchical condition trees
  • Created migration 6d5f70dd0ba5 to add the policy_condition table with proper foreign keys, indexes, and CASCADE delete constraints
  • Added relationship from Policy to PolicyCondition with cascade delete
  • Comprehensive test coverage including CRUD operations, relationships, hierarchies, and conversions

Implementation Quality:

  • Follows existing patterns consistently (similar to ManualTaskConditionalDependency)
  • Proper use of TYPE_CHECKING to avoid circular imports
  • Migration includes proper downgrade path
  • All existing imports remain backward compatible via __init__.py wildcard exports

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation follows established patterns, includes comprehensive tests, has a clean migration with proper downgrade, and maintains backward compatibility. No logical issues or security concerns identified.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
src/fides/api/alembic/migrations/versions/xx_2025_12_09_1236_6d5f70dd0ba5_add_policy_conditions.py 5/5 Added clean migration for policy_condition table with proper indexes and CASCADE delete constraints
src/fides/api/models/policy/conditional_dependency.py 5/5 Added PolicyCondition model following established ConditionalDependencyBase pattern with proper relationships
src/fides/api/models/policy/policy.py 5/5 Moved from models/policy.py to models/policy/policy.py, added conditions relationship with cascade delete
tests/api/models/policy/test_policy_conditional_dependencies.py 5/5 Comprehensive test suite covering CRUD, relationships, hierarchies, conversions, and class methods

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

8 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.32%. Comparing base (44d6566) to head (25fd56c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7090      +/-   ##
==========================================
+ Coverage   87.31%   87.32%   +0.01%     
==========================================
  Files         532      534       +2     
  Lines       34970    34999      +29     
  Branches     4048     4050       +2     
==========================================
+ Hits        30533    30562      +29     
  Misses       3560     3560              
  Partials      877      877              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants