Audit purge execution
The purge execution batch carries out every approved audit-store purge. For each one it checks dual control and the retention floor again, re-screens the rows, exports and reads them back where an export applies, writes the permanent purge certificate, and only then deletes. Approval alone deletes nothing.
At a glance
| Batch class | MGCWardenAuditPurgeExecutionBatch, which calls MGCWardenAuditPurgeEngine::execute once per approved proposal |
| Menu item | MGCWardenAuditPurgeExecuteMenuItem, label Execute approved audit purges |
| Menu path | System administration → Setup → Execute approved audit purges, and the same button on the Purge workbench |
| Who may run it | MGCWardenAuditPurgeExecutePriv (Execute approved Warden audit purges, granted at Delete) → MGCWardenAuditAdministrationDuty → Warden audit administrator (MGCWardenAuditAdministrator). The API operation MGCWardenBatchService.runAuditPurgeExecute is granted on the same privilege and re-checks the same menu item. Retry on one of its execution exceptions runs the same path for one proposal and is not gated on this menu item |
| Feature toggle | None, deliberately. An approval already taken is not undone by switching a feature off |
| Company scope | Installation-wide. Proposals, certificates and the store are shared tables and holds are read across companies, so one schedule in any company executes every approved proposal. The Purge approved event is read across companies |
| Scheduled by default | No. Nothing in the product creates a batch job for it |
| Recurrence | You choose. Until it runs, an approved purge stays Approved, awaiting execution and blocks new proposals for its partition |
| Setup-gap rules watching it | PurgeExecutionNotScheduled (code PURGEEXEC): no job of this class carries a recurrence, while purge is in use or approved proposals wait. A recurrence in any company clears it |
| Run record | None of its own. Each executed purge leaves a certificate, a manifest row, store rows and a governance row; each failure leaves an execution exception |
| Overlap guard | Not guarded by MGCWardenBatchOverlapGuard. execute() locks the proposal (pessimisticlock) and re-reads its state, so two executions serialize and the second finds it already executed |
Purpose and business justification
Approval and deletion used to happen in one step, inside the workflow's completion transaction. A Key Vault that could not be reached then faulted the workflow and left no Warden record, and a large purge held the completion for the whole transfer. The user decided on 2026-10-06 to split them: approval marks the proposal Approved and records the approver; this batch does the rest outside the workflow, where every failure becomes a recorded execution exception and the proposal stays Approved to be tried again. The exceptions are a proposal that can never pass dual control, and one that straddles the identity cutover: each is closed as Closed: propose again rather than left Approved for ever.
The certificate is written before any row is deleted, in the same transaction, and can never be changed or deleted. A purge therefore cannot happen without its certificate, and the certificate cannot outlive a purge that rolled back.
How and when it is triggered
- Scheduled from the menu item, with a recurrence, in any one company.
- Run now from the menu item or the workbench button.
canRunInNewSession()returns true. - API:
MGCWardenBatchService.runAuditPurgeExecute. - Retry on an execution exception it filed runs
MGCWardenAuditPurgeExecutionRetryfor that one proposal.
Upstream, the Warden dual-control purge approval workflow's completion
(MGCWardenPurgeApprovalWFEventHandler::completed) moves a proposal to Approved and writes the Purge
approved governance event. That step runs on the workflow runtime, not in this batch.
Configuration and scheduling options
No dialog fields; pack() returns conNull(). The work list is every proposal in state Approved when the
run starts.
| Setting | Where | Effect |
|---|---|---|
| Export container | Warden audit parameters, ExportContainer | The Azure Blob container purged rows are written to as JSON lines |
| Export secret name | Warden audit parameters, ExportSecretName | Name of a Key Vault parameters secret reference whose secret is the container's connection string |
| Export secret company | Warden audit parameters, ExportSecretCompany | The legal entity whose Key Vault parameters hold that reference |
| Export before purge | Audit retention classes | When any class sets it, every purge must export |
| Retention classes | Audit retention classes | Re-read at execution. With none, every purge is refused |
The export runs when any class demands it or any of the three export fields is set. A half-set destination refuses every purge from the parameters alone, with no network call.
Choosing a recurrence. Daily is enough for most sites; approval is a human step and a day's delay costs nothing. A shorter recurrence re-attempts failing proposals more often; the exception row counts occurrences rather than adding rows. A large purge holds its transaction for the whole export and deletion, so run it outside busy hours.
What it does
read every Approved proposal (RecIds)
for each, at transaction level 0:
read Warden's approval record; build the archive store (Key Vault read)
execute(), one transaction:
lock proposal --> still Approved? --> dual control --> retention floor
--> re-screen --> export + read-back --> manifest + certificate
--> delete rows --> deleted == exported? --> retire anchors --> Executed
refusal or error --> execution exception (Critical, Retry lever), stays Approved
dual control that can never pass, or cutover --> Closed: propose again (Error, no Retry lever)
- Reads the RecIds of every Approved proposal. A proposal approved after this read waits for the next run.
- For each proposal (
executeOne), outside any transaction:- reads Warden's own record of the approval (
MGCWardenAuditPurgeEngine::approvalOnRecord): the proposal's Approved by and the Purge approved governance event, read across companies. The platform's workflow history is not read; - builds the archive store when an export applies and the destination is complete, which reads the Key Vault secret. A vault that cannot be reached fails here, where the catch runs.
- reads Warden's own record of the approval (
execute()then runs as one transaction:- still Approved, under
pessimisticlock. If not, it reports the proposal as already finished; - dual control (
executionApprovalRefusal): the event and Approved by must name the same person; that person and every recorded route approver must be neither the accountable proposer nor the account that inserted the proposal. If the stored identities are of two generations (proposed before Warden recorded people by subject reference, approved after), the proposal is closed as Closed: propose again instead. A dual-control refusal that can never pass is closed the same way (settledDualControlCause): Approved by is blank; the Purge approved event names nobody, or no legal entity holds it any more; the event and Approved by name two people; the recorded route leaves out Approved by or holds an entry that is not a person; or an approver on record is the proposer or the inserting account. Nothing rewrites those records, so retrying could not help. A missing event closes the proposal only when a read past data security, into every legal entity, confirms it is absent from all of them, behind the same guard erasure uses (MGCWardenErasureLegalEntities). If any legal entity cannot be confirmed read, or the event is found there, the refusal stays a plain refusal and the proposal stays Approved. A disabled approver account does not close anything: such a proposal executes; - a retention floor still exists;
- re-screen with the same carve-outs the proposal used (control evidence, unanchored, legal hold, retention window). Nothing left in scope is a refusal;
- export and read-back, when it applies: rows to the container as JSON lines with a SHA-256 manifest, read back and compared. A failure is a refusal;
- writes the export manifest row and the purge certificate, moves the proposal to Certified,
and appends a
PurgeCertificatestore row; - deletes each surviving row older than the cutoff, with its detail parameters and field
exposure lines, through
skipDeleteMethod(true)anddoDelete(). This is the only sanctioned deleter of audit evidence; - checks that what it deleted is exactly what it exported, or throws and rolls everything back;
- retires the hash anchors the deletion emptied or thinned (
MGCWardenAuditHashChain:: reconcileAfterPurge), writing reconciliation rows the integrity batch publishes; - moves the proposal to Executed.
- still Approved, under
- After the commit: a
PurgeExecutedself-audit row and a governance event-log row narrating the approvers, the retention floor at execution against the floor at proposal, and the export. - Records the outcome:
- refused (dual control, floor, scope, export) or failed (a throw): one Critical execution
exception per proposal per cause through
createDeduped, cause keyPURGEEXEC:<proposal>:<kind>, with the Retry lever. An export failure is filed in area Integration. The proposal stays Approved; - closed across the cutover: one Error exception with no Retry lever, telling you to raise a fresh proposal;
- closed on a dual control that can never pass: one Error exception with no Retry
lever, under its own cause key, carrying the full refusal so you can see which record refused. The
engine has already written a
PurgeClosedProposeAgainself-audit row and a governance row; both carry a cause that names nobody. Nothing is deleted and the partition is free; - already finished: nothing filed.
- refused (dual control, floor, scope, export) or failed (a throw): one Critical execution
exception per proposal per cause through
- Writes Warden audit purge execution: N approved proposal(s) examined; N executed, N refused, N failed, N already finished by another execution ..., and a second line for closed proposals.
No governance event-log row is written for a refusal, so a refusal that repeats every run does not grow the store.
Catches and transactions. executeOne and run() run at transaction level 0, so their catches run.
Inside execute()'s transaction, a catch naming UpdateConflict or DuplicateKeyException would run and
every other catch would not; execute() relies on none, and a throw rolls back the whole purge to the
catch in executeOne.
Dependencies and prerequisites
- At least one proposal approved through Warden dual-control purge approval. See Audit purge proposals.
- The Purge approved event still present. It is a governance event: forwarded to the store by guard ingestion it stays in the event log; unforwarded, it ages out at the evidence retention period and the purge is then refused. See Guard event ingestion.
- Where an export applies: the container created by you, a Manual secret reference on Key Vault parameters in the named company, and a connection string with create, write and read permission.
- Retention classes still configured.
Inputs and outputs
| Direction | Table or object | What |
|---|---|---|
| Reads, locks, updates | MGCWardenAuditPurgeProposal | State: Approved → Certified → Executed, or Closed: propose again |
| Reads | MGCWardenEventLog (all companies) | The Purge approved event |
| Reads, deletes | MGCWardenAuditEvent, MGCWardenAuditDetailParam, MGCWardenAuditFieldExposure | The purged rows |
| Inserts | MGCWardenAuditExportManifest, MGCWardenAuditPurgeCertificate | One each per executed purge; the certificate is permanent |
| Inserts | MGCWardenAuditAnchorReconciliation | One per anchor retired |
| Inserts | MGCWardenAuditEvent | PurgeCertificate and PurgeExecuted rows |
| Inserts | MGCWardenEventLog | One narration per executed or closed purge |
| Writes, reads | Azure Blob container | Exported rows and manifest |
| Reads | Key Vault secret | Connection string, at the moment of export |
| Inserts | MGCWardenExecutionException | One per proposal per cause |
Logging and monitoring
- Purge workbench: proposals by state, with the certificate and manifest of each executed purge.
- Execution exceptions: Critical rows for refusals and failures, each with an occurrence count and a Retry lever.
- Setup gaps:
PURGEEXECwhen no recurrence exists. - Evidence packs: the SOX ITGC ApprovedPurges section lists purges still waiting and when this batch will next run; PurgeCertificates lists executed purges.
- Integrity: verification reports Reconciled for ranges a purge thinned.
Errors, recovery and troubleshooting
| Symptom | Cause and recovery |
|---|---|
| Critical Purge proposal P is Approved and was NOT executed; no evidence was deleted. ... | Read the reason in the row. Fix it and press Retry, or wait for the next run |
| Reason names the Key Vault, the secret or the container | The archive could not be reached or written. Check the secret reference, the connection string's permissions and the container name |
| Reason names the read-back | The archive did not return what was written. Nothing was deleted |
| Reason: a missing approval record | This account cannot see the Purge approved event, and Warden could not confirm it is absent from every legal entity: a legal entity could not be confirmed read, or the event is there but this account may not read it. The proposal stays Approved and is tried again. Run the batch under an account that can read every legal entity, or run Initialize Warden where the setup gaps page lists a legal entity |
| Reason: no retention floor | Retention classes were removed after approval. Restore them |
| Error Purge proposal P was approved and was NOT executed: its approval can never pass the dual control ... | The approval records refuse for good (blank Approved by, an approver who is the proposer or the inserting account, records that disagree, or an approval event gone from every legal entity). The proposal is Closed: propose again and its partition is free. Raise a fresh proposal (the proposal generator raises one on its next run), have a second person approve it, then dismiss this row and any earlier Critical dual-control row for the proposal |
| Error ... closed as Closed: propose again ... | A proposal straddled the identity cutover. Raise a fresh proposal for the partition, then dismiss the row |
| Retry on an older Critical dual-control row warns that the proposal was closed | An earlier run filed the row while the proposal was still Approved. Retry does not resolve it, because no purge happened. Raise a fresh proposal and dismiss the row |
| Proposals stay Approved, awaiting execution | The batch is not scheduled. The setup gaps page shows PURGEEXEC |
Error under document key PURGE-EXECUTION | The run itself failed. Proposals it did not reach are still Approved |
The class does not implement BatchRetryable. Every failure is caught and recorded, so the task ends
normally; the batch re-attempts every Approved proposal on every run. A proposal that can never pass dual
control no longer blocks its partition: the execution closes it as Closed:
propose again, which frees the partition for a fresh proposal.
Impact on other functionality
- Proposals. While a proposal is Approved its partition cannot be proposed for again. Execution or closure frees it.
- Integrity verification. Reconciliation rows let verification tell a certified purge from tampering.
- Erasure. Erasure does not delete store rows; this is the only path that does.
- Store size. Each executed purge removes rows and adds two control-evidence rows that are never purged.