Skip to main content

Role event retention

Role event retention deletes role events older than seven years. It never deletes a role event that has not yet been forwarded to the audit store.

At a glance​

Batch classMGCWardenAuditRoleEventRetention
Menu itemMGCWardenAuditRoleRetentionMenuItem, label Role event retention
Menu pathSystem administration → Setup → Role event retention
Who may run itMGCWardenAuditAdministrationPriv (granted at Delete) → MGCWardenAuditAdministrationDuty → Warden audit administrator (MGCWardenAuditAdministrator). The API operation MGCWardenBatchService.runAuditRoleRetention is granted on the same privilege and re-checks the same menu item
Feature toggleNone. Retention is an obligation, not reporting; MGCWardenAuditReportingFeature's own summary names this class as one the toggle must never govern
Company scopePer legal entity. MGCWardenAuditRoleEvent is a per-company table and the run reads only the company it runs in. Schedule it in every company where role capture runs
Scheduled by defaultNo. Nothing in the product creates a batch job for it
RecurrenceYou choose. The floor is measured in months, so anything from daily to monthly removes rows within that margin of the seven-year point
Setup-gap rules watching itRoleRetentionNotScheduled (code ROLERETENTION): no job of this class carries a recurrence in this company, while Warden Evidence & Compliance is on or role events are already kept here. Only a recurrence in this company clears it
Run recordNone. The batch log carries one summary line
Overlap guardNot guarded by MGCWardenBatchOverlapGuard

Purpose and business justification​

Role events contain personal data (who received which role). Keeping them for ever is a data minimisation failure; deleting them early loses access-control evidence. The class fixes a hard, audit-grade floor of seven years. It is not configurable.

It is the only sanctioned deleter of role events: MGCWardenAuditRoleEvent.delete() throws by design.

How and when it is triggered​

  • Scheduled from the menu item, with a recurrence, per company.
  • Run now from the same menu item. canRunInNewSession() returns true.
  • API: MGCWardenBatchService.runAuditRoleRetention.

Configuration and scheduling options​

None. No dialog fields (pack() returns conNull()) and no parameter is read. The cutoff is DateTimeUtil::addMonths(DateTimeUtil::utcNow(), -84).

What it does​

  1. Computes the cutoff: now less 84 months.
  2. In one transaction, selects every role event in this company with EventDateTime before the cutoff and StoreForwarded = Yes, and deletes each with skipDeleteMethod(true) and doDelete().
  3. Writes Warden role-event retention: N row(s) beyond the 7-year floor purged (store-forwarded rows only).

EventDateTime is the time role capture noticed the change, not the time of the grant.

Transaction boundary. The whole purge is one transaction. A failure rolls all of it back.

Idempotency. A second run finds nothing more to delete until more rows pass the floor.

Dependencies and prerequisites​

  • Role capture running in the same company, or there is nothing to retain.
  • Role events forwarded to the store. A row whose forward failed is kept indefinitely.

Inputs and outputs​

DirectionTableWhat
Reads, deletesMGCWardenAuditRoleEventForwarded rows older than 84 months
InsertsMGCWardenExecutionExceptionOne Error if the run fails

The copy of each role event in the audit store is not touched. It is governed by the audit retention classes and the dual-control purge.

Logging and monitoring​

  • Batch history: the summary line above.
  • Execution exceptions: Role-event retention batch failed, document key ROLE-RETENTION.
  • Setup gaps: RoleRetentionNotScheduled when role events are captured or kept in this company and the batch has no recurrence here. No health rule watches this batch.

Errors, recovery and troubleshooting​

SymptomCause and recovery
Error exception Role-event retention batch failedThe transaction rolled back; nothing was deleted. There is no Retry handler; run it again once the cause is fixed
Old role events are not removedEither the batch is not scheduled in that company (its setup gaps page shows RoleRetentionNotScheduled), or the rows have StoreForwarded = No. Unforwarded rows are kept by design

The class does not implement BatchRetryable, and run() catches every failure itself.

Impact on other functionality​

  • Evidence packs for a period more than seven years back no longer list those role changes from the role event table.
  • Erasure. Role events on their seven-year floor are one of the retention holders that defer an erasure; see Erasure execution. This batch is what eventually releases that hold.
  • Audit store. Untouched. The store copy of a role event stays until a certified purge removes it.