Warden batch framework
This page describes how Warden's periodic and batch processes are built, run and monitored, and lists every one of them. Each process has its own page; this one holds what they share.
Every Warden batch at a glance
Twenty-five RunBaseBatch classes ship in MGCWarden. Each has an action menu item on
System administration → Setup, labeled as below. Nothing in the product schedules any of them.
Order Guard and governance batches
| Process | Class | Menu item label | Feature toggle; stands down when off? | Company scope | Run record | Setup-gap rules on its schedule | Page |
|---|---|---|---|---|---|---|---|
| Delta route drain | MGCWardenDeltaRouteDrainBatch | Warden delta route drain | None; runs regardless | Per legal entity | None | DeltaDrainOwed, DeltaDrainNotScheduled, DeltaDrainStale | Route drains |
| Firming route drain | MGCWardenFirmingRouteDrainBatch | Warden firming route drain | None; runs regardless | Per legal entity | None | FirmingDrainOwed, FirmingDrainNotScheduled, FirmingDrainStale | Route drains |
| Trade agreement route drain | MGCWardenTARouteDrainBatch | Warden trade agreement route drain | Trade Agreement Governance; yes | Per legal entity | None | TaDrainOwed, TaDrainNotScheduled, TaDrainStale | Route drains |
| Journal route drain | MGCWardenJournalRouteDrainBatch | Warden journal route drain | Journal Governance; yes | Per legal entity | None | JournalDrainOwed, JournalDrainNotScheduled, JournalDrainStale | Route drains |
| Sales governance policy sweep | MGCWardenSalesGovSweep | Sales governance policy sweep | Sales Governance; yes (Skipped run) | Per legal entity | MGCWardenSalesGovSweepRun, MGCWardenSalesGovSweepLine | None | Sales governance policy sweep |
| Trade agreement approval sweep | MGCWardenTAGovSweep | Trade agreement approval sweep | Trade Agreement Governance; yes (Skipped run) | Per legal entity | MGCWardenTAGovSweepRun, MGCWardenTAGovSweepLine | None | Trade agreement approval sweep |
| Duplicate requisition sweep | MGCWardenDuplicateSweepBatch | Warden duplicate requisition sweep | Sales Governance; yes (Skipped run) | Per legal entity, or every company when a policy asks for cross-company detection | MGCWardenDuplicateSweepRun | None | Duplicate requisition sweep |
| Break-glass grant expiry | MGCWardenBreakGlassExpiryBatch | Warden break-glass grant expiry | None; runs regardless | Role assignments are system-wide; the grant duration is read from the running company's parameters | None | BreakGlassExpiryNotScheduled; BreakGlassGrantNotTimeBoxed watches the duration | Break-glass grant expiry |
| Count consolidation | MGCWardenCountConsolidationRun | Count consolidation run | Count Governance; yes | Per legal entity | None (queue rows show the outcome) | None | Count consolidation run |
| Aged-MISSING monitor | MGCWardenMissingQueueMonitor | Aged-MISSING monitor | Count Governance; yes | Per legal entity | None | None | Aged-MISSING monitor |
| Count case retention | MGCWardenCountRetention | Count case retention cleanup | None; runs regardless | Per legal entity | None | None | Count case retention cleanup |
| Retention cleanup | MGCWardenRetentionCleanup | Warden retention cleanup | None; runs regardless | Per legal entity, plus three shared tables cleaned by any company's run | None | None | Warden retention cleanup |
| Setup-gap snapshot | MGCWardenSetupGapSnapshotBatch | Warden setup-gap snapshot | None | Per legal entity | None (the snapshot rows carry their detection time) | None | Warden setup-gap snapshot |
The journal reversal router (MGCWardenJournalReversalRouter) is not a batch. It runs when the
standard inventory journal Copy process runs; see Journal reversal router.
How Warden changes standard periodic processes such as journal posting, trade agreement posting and
planned order firming is in Standard batch and periodic processes with Warden installed.
Auditor batches
These are documented on their own pages.
| Process | Class | Menu item label | Overlap guard | Setup-gap rules on its schedule | Page |
|---|---|---|---|---|---|
| Guard event ingestion | MGCWardenAuditGuardIngestion | Guard event ingestion | No (locks each row) | GuardIngestionNotScheduled | Guard event ingestion |
| Audit queue writer | MGCWardenAuditWriter | Audit queue writer | Yes, any company | AuditWriterNotScheduled | Audit queue writer |
| Role event capture | MGCWardenAuditRoleCapture | Role event capture | Yes, own company | RoleCaptureNotScheduled | Role event capture |
| Role event retention | MGCWardenAuditRoleEventRetention | Role event retention | No | RoleRetentionNotScheduled | Role event retention |
| Audit chain integrity | MGCWardenAuditIntegrityBatch | Audit chain integrity | Yes, any company | AnchorFeedNoDestination, AnchorFeedNeverPublished, AnchorFeedStale watch the feed it publishes | Audit chain integrity: anchoring, publication and verification |
| Audit health monitor | MGCWardenAuditHealthBatch | Audit health monitor | No (locks each rule) | AuditHealthNotScheduled | Audit sensor health monitor |
| Evidence pack builder | MGCWardenAuditPackBuilder | Evidence pack builder | No | PackNoCompletedRun (a legal entity in the audit store with no completed pack) and PackScopeUnmapped; neither checks a schedule | Evidence pack builder |
| Purge proposals | MGCWardenAuditPurgeProposalGenerator | Propose audit store purge | Yes, any company | None | Audit purge proposals |
| Purge execution | MGCWardenAuditPurgeExecutionBatch | Execute approved audit purges | No | PurgeExecutionNotScheduled | Audit purge execution |
| HR deprovisioning scan | MGCWardenAuditDeprovisioning | HR deprovisioning scan | Yes, own company | DeprovisioningScanNotScheduled | HR deprovisioning scan and leaver intake |
| Deprovisioning overdue monitor | MGCWardenDeprovisioningOverdueMonitor | Deprovisioning overdue monitor | No | DeprovisioningOverdueNotScheduled, DeprovisioningOverdueNoRecipients | Deprovisioning overdue monitor |
| Erasure execution | MGCWardenErasureExecutionBatch | Execute due erasures | No | ErasureExecutionNotScheduled | Erasure execution |
Two more action menu items on the same menu run once and are not batches: Initialize Warden
(MGCWardenInitialize) and Refresh shipped sensitivity catalog (MGCWardenAuditCatalogSeed).
How a Warden batch is built
Every batch above follows the same shape.
- A
RunBaseBatchclass withmain()asnew,prompt(),runOperation(). The menu item opens the class's dialog. The dialog has the platform's standard background-processing options, which is where you set the batch group and the recurrence. No Warden class overridescanGoBatch. - Dialog fields are packed. What the dialog collects is carried by
pack()andunpack(), because the batch framework stores a scheduled task's parameters by packing them and unpacks them to run it. Of the Order Guard batches, only the three sweeps have dialog fields; the other ten take no input and packconNull(). canRunInNewSession()returnstrueon every Order Guard batch, so Run now from the menu runs through the platform's operation sandbox and shows a progress form.MGCWardenAuditPackBuilderis the one batch that answersfalse(MGCWardenBatchServicesummary).- No batch implements
BatchRetryable. A failed run is recovered by the next recurrence or by running it again, not by a platform retry. - No Warden code creates a batch job or a recurrence, and Warden defines no batch group. Every schedule is an administrator's decision.
The fail-open doctrine and what batch history shows
Most Warden batches follow the product's blocking doctrine: run() does not let an exception out. A
failure is caught and recorded as an execution exception, and the run ends. The consequence for
operators:
A Warden batch task that failed usually still ends normally in batch job history. The evidence of the failure is on Execution exceptions (System administration → Setup → Execution exceptions), and often in the task's infolog.
The exceptions to this are stated on each page. For example, MGCWardenBatchService records that
MGCWardenRetentionCleanup and MGCWardenCountRetention have no fail-open catch, so an error escapes
run() and the batch task fails in the usual way.
Batches that process many documents isolate each document in its own failure region, so one bad
document does not stop the rest. A batch task starts outside any transaction, so these catch blocks run.
Inside a transaction, a catch naming UpdateConflict or DuplicateKeyException runs and every other
catch does not; that is why Warden's in-transaction seams hand work to batches instead of doing it
themselves.
Execution exceptions: one row per cause
Unattended batches that meet the same fault on many documents file one row per cause and count the
repeats (MGCWardenExecutionExceptionManager::createDeduped). The row's occurrence count is
the number of failed attempts, not the number of documents affected.
The route drains also apply a give-up rule: a cause met at least 10 times over at least 15 minutes is
treated as exhausted, and the drains stop attempting it (causeIsExhausted). Resolving or
dismissing the row re-arms them. See Route drains.
Running a batch
There are three ways to run one:
| Way | Runs as | Notes |
|---|---|---|
| Scheduled batch job (recurrence set in the dialog) | The account the batch job runs as | The normal production path. |
| Run now from the menu item | The person who pressed it | Interactive; the progress form can be canceled. |
MGCWardenBatchService over the API | The API caller | See The batch API. |
Whoever runs it is stamped wherever the batch records a user: run records, the event log and, for the route drains, the originator of every workflow they activate. Pick the batch job's account with that in mind.
Company scope
A batch task runs in the company its batch job was created in (curExt()). The platform's Batch and
BatchJob tables are shared across companies, but Warden's working tables are per company, so:
- Per legal entity batches read only the company they run in. Schedule one job in each legal entity that uses the area. The four route drains are of this kind, and Warden setup gaps asks about their schedule in the current company only.
- Cross-company batches read shared tables, so one job serves every company. The audit queue, the audit store's anchor chain and the purge proposals are shared tables.
The scope of each batch is in the tables above and on its page.
Choosing a recurrence
Only one Warden batch has a stated recurrence: the delta route drain, every 5 minutes, a service-level promise (Getting started). For every other batch you choose. Each page says what the choice trades.
Feature toggles and standing down
Warden's feature toggles are entry-point switches, not stop buttons (Getting started). A batch follows one rule: it raises an owed approval while its feature is off if and only if the document is still blocked while the feature is off.
- The delta and firming route drains test no toggle, because the purchase gates refuse a held order whatever the Warden Order Guard toggle says.
- The trade agreement and journal route drains stand down when their toggle is off, because their enforcement seams test the same toggle and nothing refuses the document.
- Batches with a run record close a stood-down run as
Skipped. Others write an infolog line.
Run records
Three Order Guard sweeps and the purge proposal generator write a run record per run. They share the
status enum MGCWardenSweepRunStatus:
| Value | Label | Meaning |
|---|---|---|
Running | Running | The run has started and not closed. A row left here means the run died. |
Completed | Completed (full scope examined) | Every document in scope was examined. |
Partial | Partial (document cap reached) | The run stopped at its cap. |
Failed | Failed | The run hit its own failure handler. |
Skipped | Skipped (feature off or run refused; nothing examined) | The feature was off, a prerequisite was missing, or the overlap guard refused the run. |
| Run table | Written by | Screen |
|---|---|---|
MGCWardenSalesGovSweepRun (with MGCWardenSalesGovSweepLine) | MGCWardenSalesGovSweep | Sales governance sweep runs |
MGCWardenTAGovSweepRun (with MGCWardenTAGovSweepLine) | MGCWardenTAGovSweep | Trade agreement approval sweep runs |
MGCWardenDuplicateSweepRun | MGCWardenDuplicateSweepBatch | Duplicate requisition sweep runs |
MGCWardenAuditPurgeProposalRun | MGCWardenAuditPurgeProposalGenerator | Audit purge proposal runs |
Each run row carries a RunId, start and end times, the status, the filter and cap the run was given,
its counters, a ParameterSnapshot and an OutputSummary. The three sweep tables are per company;
MGCWardenAuditPurgeProposalRun is shared (SaveDataPerCompany = No).
Per-document outcomes on the sales governance sweep use MGCWardenSweepOutcome: Re-evaluated: breached
and routed, Re-evaluated: compliant under current policy, Skipped: already held, Skipped: no longer
an open document, Not evaluated: evaluation failed, Re-evaluated: breached a Warn policy, recorded
and not held. The trade agreement sweep's lines use their own enum, MGCWardenTASweepOutcome.
The other batches write no run record. Their evidence is the infolog line in the batch task's log, the rows they write, and any execution exception.
The overlap guard
MGCWardenBatchOverlapGuard refuses to start a run while another batch task of the same class is
executing (status Executing or Canceling in the platform Batch table). It protects exactly the six
classes for which reason() returns text, because each has no claim or lock of its own and two
overlapping runs would duplicate evidence:
| Class | What an overlap would duplicate | Scope of the check |
|---|---|---|
MGCWardenAuditWriter | A capture stored twice | Any company |
MGCWardenAuditRoleCapture | Role events, store rows and sensitive-role alerts | Own company |
MGCWardenAuditIntegrityBatch | An anchoring failure and double attestation | Any company |
MGCWardenAuditPurgeProposalGenerator | Two undecided proposals for one partition | Any company |
MGCWardenDuplicateSweepBatch | One duplicate pair filed as two audit cases | Own company, or any company when a policy asks for cross-company detection (MGCWardenDuplicateDetector::detectionIsCrossCompany) in either company |
MGCWardenAuditDeprovisioning | One user proposed twice | Own company |
How it decides:
- A scheduled task excludes itself (
ownTask), otherwise it would find its own Executing row and refuse for ever. - Of two tasks claimed at the same time, the one claimed earlier proceeds; in the same second, the lower
RecId proceeds (
yieldsTo). Two jobs that share a recurrence therefore do not refuse each other every time. - Run now and API runs are not batch tasks. They yield to any running task, and a scheduled task cannot see them.
- A task left at Executing by a server that died blocks every other run of the class until the platform's dead-task cleanup resets it.
What a refusal leaves:
- A warning in the batch log that names the running task (caption, batch job, task, company, start time, account) and quotes the reason.
- For the two classes with a run record, a run closed as
Skippedwith the refusal as its summary. - For the four without one, one open execution exception per class and company (Warning, cause key
BATCHOVERLAP:<class>), whose occurrence count rises with each further refusal (createOncePerOpenCause).
The remedy the refusal names: space the schedules out, or chain the tasks as dependent tasks of one batch
job. That section also lists
the steps the X++ suite now automates: MGCWardenBatchOverlapRuntimeTest schedules real one-off audit writer
jobs on the batch server. These tests have not yet run on the UDE.
Batches that protect themselves instead
The other batches carry no overlap guard because concurrent runs cannot duplicate their work
(MGCWardenBatchService summary):
- the four route drains claim each document before routing it;
- audit ingestion re-reads each event-log row under a pessimistic lock;
- the trade agreement sweep supersedes through a conditional update in one transaction;
- the sales governance sweep goes through the same evaluation engine as interactive edits, whose hold placement resolves the race;
- the health monitor decides each alert inside a transaction on the locked rule row;
- the pack builder shares no mutable state between runs;
- the purges, the missing-queue monitor, break-glass expiry, count consolidation and the setup-gap refresh each write inside one transaction whose locks make a concurrent loser roll back. The loser may then read as failed.
Setup gaps that watch schedules
Warden setup gaps (System administration → Setup → Warden setup gaps) lists batch jobs Warden depends
on that are not scheduled or have stopped. The page treats a batch as scheduled when the platform
Batch table has a task of that class whose job is Waiting, Ready or Executing and carries recurrence
data; a one-off run does not count.
| Batch | Rules | Company |
|---|---|---|
| Delta, firming, trade agreement and journal route drains | *DrainOwed (no recurrence and records owed; names the count), *DrainNotScheduled (no recurrence; only when the area is in use), *DrainStale (recurrence, but a record owed 4 hours or more) | A task in this company only |
| Purge execution | PurgeExecutionNotScheduled | See Audit purge execution |
| HR deprovisioning scan | DeprovisioningScanNotScheduled | See HR deprovisioning scan and leaver intake |
| Deprovisioning overdue monitor | DeprovisioningOverdueNotScheduled, DeprovisioningOverdueNoRecipients | See Deprovisioning overdue monitor |
| Audit queue writer | AuditWriterNotScheduled: Warden Auditor is on with an Active register entry, or captured reads wait in the queue | A task in any company |
| Guard event ingestion | GuardIngestionNotScheduled: a governance event-log row here is not yet forwarded | A task in this company only |
| Role event capture | RoleCaptureNotScheduled: Warden Evidence & Compliance is on | A task in this company only |
| Role event retention | RoleRetentionNotScheduled: Warden Evidence & Compliance is on, or role events are kept here | A task in this company only |
| Audit health monitor | AuditHealthNotScheduled: an audit health rule is enabled | A task in any company |
| Erasure execution | ErasureExecutionNotScheduled: an erasure request is Approved or Deferred | A task in any company |
| Break-glass grant expiry | BreakGlassExpiryNotScheduled: a security role carries the break-glass release privilege, even with nobody assigned | A task in any company |
The last seven rows are raised by MGCWardenUnscheduledBatchSetupGaps. Each
row appears only while its area is in use, and the company column follows what the batch sweeps: a batch
over shared tables is covered by one recurrence in any company.
The drain rules are explained in Route drains. No setup-gap
rule watches the schedule of any other batch: the sweeps, count consolidation, the aged-MISSING monitor,
count case retention, retention cleanup, the setup-gap snapshot, audit chain integrity, the evidence pack
builder and the purge proposal generator. Some rules watch their prerequisites instead,
for example the break-glass grant duration (BreakGlassGrantNotTimeBoxed) and the count consolidation
journal (CountNoConsolidationJournal, CountConsolidationJournalUnusable); each page names them.
The Stranded hold rule (StrandedHold) watches the whole recovery layer: it lists a held document
that has had nothing routing it for 4 hours, whatever the reason.
The batch API: MGCWardenBatchService
MGCWardenBatchService is a custom service in the MGCWardenServices service group
(AutoDeploy = Yes), shipped in the product package. It has 27 operations, one per action menu item on
the Setup menu that starts a process: runInitialize, runAuditCatalogSeed and one run… operation
for each of the 25 batches. Its purpose, stated in the class summary, is backend test automation: run a
batch now, synchronously, so a test can act, run the drain or sweep, and assert.
What it does and does not do:
- It starts batches; it does not schedule or inspect them. No operation creates a batch job, sets a recurrence or reads batch history.
- Same permission as the menu item. Each operation first refuses inside a transaction, then checks
that the caller could run the menu item (
MGCWardenApiDispatch::canRun) and returnsDeniedif not. The service operations are granted in the same privileges as their menu items. - Same code path as a scheduled task. For the 25 batches it builds the class, sets the dialog
parameters through the class's own
parmScope(), round-trips them throughpack()andunpack(), callsvalidate(), asks the overlap guard, then callsrun()in the caller's session.runInitializeandrunAuditCatalogSeedrun their menu items directly. - Stricter overlap check. For the six guarded classes it refuses when a task of the class is executing in any company, whatever the class's own scope.
- Parameters. Only the three Order Guard sweeps and two Auditor batches take any:
runDuplicateSweep(customerAccount, maxIndexRows, resumeFromLastRun),runSalesGovSweep(customerAccount, maxDocuments, includeUnstamped),runTAGovSweep(journalFilter, maxJournals, includeUnstamped), and the pack builder and purge proposal operations (see their pages). - Session company. Every operation runs in the session's company; none takes a company parameter.
- Result.
MGCWardenApiResultwith statusDenied,Refused(invalid parameter, the batch's own refusal such as a feature that is off, or the overlap guard),Failed(an exception escaped, the batch's own failure handler fired, or its parameters did not survivepack()/unpack()) orCompleted.Completeddoes not mean anything was done: a drain with nothing to drain completes. The result carries the run record key where one exists, the batch's infolog summary and the number of execution exceptions the call raised. - Long runs. The calls are synchronous. Several batches grow with the estate, so a call can outlast an HTTP client's timeout; the run continues on the server.
Two points from the class summary are out of date: it says 26 operations and 23 RunBaseBatch classes.
The service has 27 operations, 25 of them batches, since runErasureExecute was added.
Security
Each batch is secured by its action menu item. For the Order Guard batches:
| Menu items | Privilege | Duty | Role |
|---|---|---|---|
| The four route drains, break-glass expiry, retention cleanup, setup-gap snapshot, count consolidation, count retention, aged-MISSING monitor | MGCWardenPolicyAuthorPriv | MGCWardenPolicyAuthoringDuty | Warden guard administrator |
| Sales governance policy sweep | MGCWardenSalesGovSweepPriv | MGCWardenPolicyActivationDuty | Warden controls owner |
| Trade agreement approval sweep | MGCWardenTAGovSweepPriv | MGCWardenPolicyActivationDuty | Warden controls owner |
| Warden duplicate requisition sweep | MGCWardenDuplicateSweepPriv | MGCWardenPolicyActivationDuty | Warden controls owner |
The three sweeps sit on the activation duty, not the authoring duty, because a sweep re-governs live documents across the estate (the privilege descriptions say so). Scheduling a batch job starts from the menu item's dialog, so the person who schedules it needs the menu item. The full role design is in Security model.
Related documentation
- Getting started (toggles) and §5b (the route drains)
- Form reference, Part 4 (periodic tasks)