Skip to content

Implement Scheduled Case Retention Evaluation and Automated Case Deletion#8721

Merged
sanjacornelius merged 18 commits intoepic/FOUR-29101from
task/FOUR-29110
Feb 12, 2026
Merged

Implement Scheduled Case Retention Evaluation and Automated Case Deletion#8721
sanjacornelius merged 18 commits intoepic/FOUR-29101from
task/FOUR-29110

Conversation

@sanjacornelius
Copy link
Contributor

@sanjacornelius sanjacornelius commented Feb 5, 2026

This PR introduces a scheduled background job that evaluates case retention rules and automatically deletes cases that exceed their configured retention period.

Solution

  • Added a new command: cases:retention:evaluate
    • Dispatches the EvaluateProcessRetentionJob
  • Implemented chunked processing (default chunk size: 100) to improve performance and scalability
  • Added a feature flag (CASE_RETENTION_POLICY_ENABLED)
    • The job will not execute unless the flag is enabled
  • Set a default case retention period of 1 year
  • Added unit tests to validate retention evaluation and deletion logic

How to Test

  1. Runtests/Jobs/EvaluateCaseRetentionJobTest.php
  2. Verify all tests pass successfully

Related Tickets & Packages

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

Note

Medium Risk
Automates background deletion of case records on a schedule, so misconfiguration or cutoff logic bugs could lead to unintended data loss. Guarded by a feature flag and chunked queries, but still touches production data lifecycle.

Overview
Adds a new feature-flagged case retention evaluator: a daily scheduled cases:retention:evaluate command dispatches EvaluateProcessRetentionJob per process to delete CaseNumber records past the process’s configured retention window (defaulting to 1 year and accounting for retention_updated_at).

Introduces CASE_RETENTION_POLICY_ENABLED/app.case_retention_policy_enabled, adds a CaseNumberFactory, and includes a comprehensive EvaluateProcessRetentionJobTest suite covering deletion cutoffs, batching, policy updates, and the disabled-flag no-op behavior.

Written by Cursor Bugbot for commit 888d7a9. This will update automatically on new commits. Configure here.

@vladyrichter
Copy link

QA server K8S was successfully deployed https://ci-4c7e0ec47b.engk8s.processmaker.net

@sanjacornelius sanjacornelius changed the base branch from develop to epic/FOUR-29101 February 10, 2026 19:51
@sanjacornelius sanjacornelius changed the title [WIP] EPIC FOUR-29110 - Cases Retention Policy Implement Scheduled Case Retention Evaluation and Automated Case Deletion Feb 10, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@processmaker-sonarqube
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube

@sanjacornelius sanjacornelius merged commit 72daa9a into epic/FOUR-29101 Feb 12, 2026
10 of 14 checks passed
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.

3 participants