Route drains
Warden ships four route drain batches. Each one raises approval work items that Warden owes but was not allowed to raise at the moment it held the document. This page describes what the four have in common once, then each drain under the standard process headings.
| Drain | Class | Raises the approval owed for |
|---|---|---|
| Delta route drain | MGCWardenDeltaRouteDrainBatch | Purchase order changes held for delta or excluded-class re-approval |
| Firming route drain | MGCWardenFirmingRouteDrainBatch | Planned-order firmings held for firming approval |
| Trade agreement route drain | MGCWardenTARouteDrainBatch | Classic trade agreement journals gated for price governance approval |
| Journal route drain | MGCWardenJournalRouteDrainBatch | Inventory journals that meet a banded review |
The scheduling instruction for customers is in Getting started. How Warden batches work in general is in Warden batch framework.
Shared behaviour
Why the drains exist
Warden places its holds inside the transaction of the native action that it governs: the purchase line update, the firming transaction, the trade agreement journal write or posting, the inventory journal posting. The hold commits or rolls back with that action, so the document is gated the moment the action lands.
Workflow activation cannot safely happen inside that transaction. Inside a transaction, a catch naming
UpdateConflict or DuplicateKeyException runs and every other catch does not, so a failed activation
there would either refuse the user's action or go unrecorded. So the seam places the hold, leaves a
record that an approval is owed, and stops. The drain is the transaction-free process that later raises
the approval. A batch task starts outside any transaction, so the drains' own catch blocks run.
Without a scheduled drain, a document that was held and then left alone stays held with no work item, and nobody can release it.
native action (inside its own transaction) route drain (no transaction)
------------------------------------------- -----------------------------
Warden seam places hold --------+ finds owed records
Warden writes owed record | commits asks the workflow runtime: route exists?
(diff set Pending, firming +--------------> no -> claims the record
request PendingApproval, submits the approval workflow
gate state Gated, ...) announces the deferred HoldPlaced event
yes -> settles, raises nothing
How they are built
- Each drain is a
RunBaseBatchclass with no dialog fields.pack()returnsconNull()andunpack()accepts anything, so there is nothing to configure and nothing a stored batch task can lose. main()isprompt()thenrunOperation().canRunInNewSession()returnstrue, so an interactive run from the menu goes through the platform's operation sandbox and the client shows a progress form.- Each run writes one summary line to the infolog (and so to the batch task's log). The wording is quoted under each drain below.
- None implements
BatchRetryable.
Nothing schedules them
No Warden code creates a batch job for any drain. Each ships inert until an administrator gives it a
recurrence. The decision is recorded in the class summaries and on
MGCWardenSetupGapCheck::routeDrainGap: the interval is the control's latency, and a job that appears
because metadata was installed has no owner, company, batch group or chosen interval.
Instead, Warden setup gaps (System administration → Setup → Warden setup gaps) raises three rules per drain, twelve in total:
| Rule | Fires when | Conditioned on the area being in use? |
|---|---|---|
*DrainOwed | No recurring job for the drain in this company, and at least one owed record exists. The row names the count. | No. An owed record is its own evidence. |
*DrainNotScheduled | No recurring job for the drain in this company. | Yes (see each drain). |
*DrainStale | A recurring job exists, and the oldest owed record is at least 4 hours old (#DrainStaleHours). | No. |
The rule names are DeltaDrain*, FirmingDrain*, TaDrain* and JournalDrain*; the area codes on
the page are ROUTEDRAIN, FIRMDRAIN, TADRAIN and JOURNALDRAIN.
How the page decides that a drain is scheduled:
- It reads the platform
BatchandBatchJobtables for a task of the drain's class whoseBatch.Companyis the current company. A drain scheduled in another legal entity does not count, because each drain reads only the company it runs in. - The job must be Waiting, Ready or Executing.
- The job must carry recurrence data. A one-off run is not a schedule.
The page is computed per company, so a multi-company deployment sees one row for each company whose drain is unscheduled.
The Stranded hold rule (StrandedHold, 4 hours, #StrandedHoldHours) is a separate, wider monitor
over every Warden hold. It catches held documents that no drain, retry or lever will route.
Exactly one work item per document
The drains must not raise a second approval for a document that already has one. They rely on three things rather than on the overlap guard:
- The workflow runtime is asked. Each drain asks
MGCWardenRouteExistenceCheckwhether an approval exists before it raises one, and asks again after it has taken its claim. A workflow that stopped with an error and that the runtime still holds counts as a route, so no second one is raised beside it. - A claim. The delta drain moves the diff set to
Claimed. The other three stamp a claim time on their own record (RouteClaimedDateTimeonMGCWardenFirmingRequest,MGCWardenTAGateStateandMGCWardenJournalGovState). A claim younger than 60 minutes blocks every other raiser; an older one is treated as abandoned (MGCWardenStaleClaimPolicy,#StaleClaimMinutes= 60, a constant and not a parameter). - One pass, one record at a time. Each drain first reads the RecIds of its candidates, then re-reads each record before acting on it.
Because of these, two runs of the same drain at the same time do not duplicate work, and
MGCWardenBatchOverlapGuard does not cover the drains. The MGCWardenBatchService summary records this.
Give-up rules
Two rules stop a drain from retrying the same failure for ever.
| Rule | Applies to | Counts | Outcome |
|---|---|---|---|
| Lost-activation bound | Firming, trade agreement, journal | Activations the runtime accepted and then lost (canceled, given up, or faulted and released) for one document. #MaxLostActivations = 3 in each class. | The drain stops re-raising that document and files one Critical execution exception for it, with a Retry lever. Counted in the tally as escalated. |
| Written-off workflow type | All four | Activation failures of one workflow type, on one execution exception row (MGCWardenExecutionExceptionManager::causeIsExhausted). The type is written off when the row has at least 10 occurrences (#MinCauseFailures) spread over at least 15 minutes (#MinCauseFailureSpanSeconds = 900). | The drain does not attempt that workflow type. Counted as not attempted because the approval workflow has been written off (firming, trade agreement, journal). |
Resolving or dismissing the execution exception row re-arms the drain. The next pass attempts the activation again. The Retry lever on the workbench is not bound by either rule, so it is the way to test a configuration fix.
Failure handling common to all four
run()never lets an exception out. An unexpected failure of the whole pass is caught and recorded as one Error-severity execution exception with no record reference. The batch task itself ends normally, so batch job history does not show a failed drain. Look at Execution exceptions (System administration → Setup → Execution exceptions).- Each document is processed in its own failure region. One document that cannot be routed does not stop the rest.
- A per-document activation failure releases the claim and files one execution exception per workflow
type, counted up on each further failure (
createDeduped). The row names the first document affected and carries the family's Retry handler.
Who the approval is raised by
The drain submits the workflow as the user the run executes as. A scheduled run stamps the account the
batch job runs as; Run now from the menu and the API stamp the person who pressed it. The
MGCWardenBatchService summary records this. Choose the batch job's account with that in mind, because
it becomes the originator of every approval the drain raises.
The deferred HoldPlaced business event
A hold placed inside a native transaction does not announce itself, because the transaction could still
roll back. The drains are where the MGCWardenHoldPlaced business event is emitted later:
- the delta drain announces after it submits (
MGCWardenHoldManager::emitDeferredHoldPlaced); - the firming, trade agreement and journal drains announce the hold first, before any route question,
through
MGCWardenHoldManager::emitDeferredHoldPlacedForType. Each hold is announced at most once.
An integration that listens for HoldPlaced therefore hears about firming, trade agreement and journal
holds only when the corresponding drain runs.
The cancel dialog reads the schedule
When a user cancels a firming, trade agreement or banded journal review approval from the workflow
history, the cancel dialog says whether the drain will raise a fresh one, how often, and how many
cancellations are left before it stops (MGCWardenCancelWarning, MGCWardenTACancelWarning).
The interval it quotes is read from the drain's batch job in that company. With no schedule, the dialog
says nothing unattended will raise it.
Choosing an interval
Only the delta drain has a stated recurrence: every 5 minutes, a service-level promise. For the other three you choose. What the choice trades:
- The interval is the longest time a held document waits with nobody asked to decide it.
- The pass cost on a healthy system is small for the delta, firming and trade agreement drains (an indexed read of a small owed set). The journal drain reads every unposted inventory journal in the company on each pass, so its cost grows with the number of open journals.
- An interval close to 4 hours lets the stale rule fire on a working schedule, because the rule fires whenever a record has been owed for 4 hours despite a recurrence.
Warden defines no batch group for any drain. Use whichever batch group your batch servers serve.
Delta route drain
At a glance
| Batch class | MGCWardenDeltaRouteDrainBatch |
| Menu item | MGCWardenDeltaRouteDrainMenuItem, label Warden delta route drain |
| Menu path | System administration → Setup → Warden delta route drain |
| Who may run it | MGCWardenPolicyAuthorPriv (Update) → MGCWardenPolicyAuthoringDuty → Warden guard administrator (MGCWardenGuardAdministrator). The API operation MGCWardenBatchService.runDeltaRouteDrain checks the same menu item. |
| Feature toggle | None. It runs with Warden Order Guard off, because the purchase gates refuse a held order whether the toggle is on or off. |
| Company scope | Per legal entity. Reads MGCWardenDiffSet in the company the task runs in. |
| Scheduled by default | No. |
| Recurrence | Every 5 minutes. A service-level promise, not a parameter. |
| Setup-gap rules | DeltaDrainOwed, DeltaDrainNotScheduled, DeltaDrainStale (area ROUTEDRAIN); StrandedHold. |
Purpose and business justification
PurchTable.update and PurchLine.update always run inside a transaction, so
MGCWardenChangeInterceptor classifies every purchase edit inside one. It places the hold and marks the
diff set Pending, and the approval is raised later. The first transaction-free point is the purchase
posting gate: when anyone attempts a governed purchase status (confirmation, confirmation request,
receipts list, product receipt, vendor invoice, invoice approval journal),
MGCWardenPurchFormLetter_Extension and MGCWardenPurchPostingGate drain that document's owed routes.
The drain covers the case where nobody attempts a posting. Without it, an order edited and then left alone stays held with no work item. With it, the approval appears at most one interval late. Nothing escapes governance in the gap, because the hold already stands.
The same class drains both purchase change routes: the delta approval (standard purchase orders) and the excluded-class approval (direct delivery, intercompany and TMS orders). The process from edit to approval is described in Purchase order change and delta re-approval.
How and when it is triggered
- By a batch job with a recurrence that an administrator creates from the menu item's batch dialog.
- By Run now from the menu item.
- By
MGCWardenBatchService.runDeltaRouteDrainover the API.
The posting gate's per-document drain (MGCWardenChangeInterceptor::drainPendingRoutes) is a separate
entry point that serves one document at a time. It is not this batch.
Configuration and scheduling options
There are no dialog fields and no parameters. Schedule every 5 minutes in each legal entity that governs
purchase changes. Warden setup gaps raises DeltaDrainNotScheduled when an Active policy would hold and
route a purchase change, delta or excluded class (MGCWardenSetupGapCheck::changeGovernanceInUse).
What it does
- Reaps stale claims (
reapStaleClaims). It reads every diff set inClaimed. For each one stillClaimedwhose claim is at least 60 minutes old, or has no claim time, it asks the workflow runtime whether an approval exists.- If one exists, the diff set is settled to
Routed, the workflow correlation is recovered from the runtime's tracking row, and an event-log row (DiffRecorded) says so. - If none exists, the claim is released to
Pendingand an event-log row says so. The sweep below routes it in the same pass. - The reaper runs in its own failure region. If it fails, a Warning-severity execution exception is filed and the sweep continues.
- If one exists, the diff set is settled to
- Snapshots the RecIds of every diff set with
RoutingState=Pending. - Completes each route through
MGCWardenChangeInterceptor::completePendingRoute(diffSet, true). Thetruemarks the call as unattended, so the give-up rule applies.- Before any transaction, it asks whether the delta and the excluded-class approval workflow types have been written off.
- In one transaction it locks the document's change-route hold
(
MGCWardenSubmitGuard::lockChangeRouteHold), reads it, and claims the diff set (Pending→Claimed) unless that hold's workflow type is written off. Hold first, then diff set: the lock order every writer of the two rows uses. - If there is no active change-route hold, the hold was released after the edit (approved,
break-glass or canceled). The diff set goes to
NotRequiredand the event log records that the route was abandoned. When another Warden control still holds the order, the row says so. - If it did not win the claim, it stops. Another drain point has the route, or the type is written off.
- If the runtime already has an approval, it settles the diff set to
Routedwithout submitting again. - Otherwise it submits
MGCWardenExcludedClassApprovalSubmitManagerorMGCWardenDeltaApprovalSubmitManager(chosen by the hold type), stampsRouted, and emits the deferredHoldPlacedevent. - On failure it releases the claim back to
Pending, files a Critical execution exception keyed on the workflow type with theMGCWardenDeltaRouteRetryhandler, and writes an ungoverned-action event-log row.
- Writes the summary line:
Warden delta route drain: N pending approval route(s) processed.When the reaper acted, a second line:Warden stale-claim reaper: N stranded claim(s) released for routing, M settled as already routed.
Transaction boundaries. The claim is one short transaction per diff set. The workflow submission happens after that transaction commits. The claim is committed before the submission, so a hold released in the instant between the two can still meet a raised approval. That window was accepted on 2026-10-07 : it can produce one unnecessary work item, never a document let through.
Concurrency and idempotency. Only Pending and stale Claimed rows are touched. A run with nothing
owed reads an empty set and does nothing. Running it twice, or alongside a posting attempt on the same
order, raises at most one approval per diff set.
Dependencies and prerequisites
- An active Warden delta approval workflow (
MGCWardenDeltaApprovalTemplate) and, if you govern direct delivery, intercompany or TMS orders, an active Warden excluded-class change approval workflow (MGCWardenExcludedClassApprovalTemplate). See Getting started. - Active purchase guard policies. With none, nothing is ever
Pending.
Inputs and outputs
| Reads | Writes |
|---|---|
MGCWardenDiffSet (Pending, Claimed) | MGCWardenDiffSet routing state, claim, workflow correlation (the diff itself is never modified) |
MGCWardenHold (the change-route hold, locked) | MGCWardenHold workflow correlation |
Workflow tracking (through MGCWardenRouteExistenceCheck, MGCWardenRouteCorrelation) | Workflow instances (delta or excluded-class approval), with work items for the approvers |
MGCWardenExecutionException (give-up rule) | MGCWardenEventLog (DiffRecorded, ungoverned action) |
MGCWardenExecutionException (reaper Warning, per-type Critical, batch Error) | |
MGCWardenHoldPlaced business event |
Logging and monitoring
- Batch task log: the summary line(s) above.
- Change diff sets (System administration → Setup → Change diff sets): the routing state of each diff set.
- Governance event log (System administration → Setup → Governance event log): the reaper, settle and abandon rows.
- Execution exceptions: activation failures (Critical, one row per workflow type) and a failed pass
(Error, on
MGCWardenDiffSetwith no record). - Warden setup gaps: the three
DeltaDrain*rules andStrandedHold.
Errors, recovery and troubleshooting
| Symptom | Cause | What to do |
|---|---|---|
DeltaDrainOwed on the setup-gap page | No recurring job in this company, routes owed | Schedule the drain every 5 minutes in this company. The next pass raises the owed approvals. |
DeltaDrainStale | Scheduled, but a route has been owed for 4 hours or more | Open the batch job: is it held, failing, or on a long interval? Then check Execution exceptions for a written-off workflow type. |
| Critical row Deferred routing failed: the … workflow could not be activated | The workflow type is not configured or not active | Configure and activate the workflow. Press Retry on the row to test the fix, then resolve the row so the drain re-arms. |
| Error row Delta route drain batch failed | The whole pass failed | Read the batch task log for the cause. Run it again; it is safe to re-run. |
| A held order whose approval was canceled | A canceled delta approval leaves the diff set Routed, which the drain does not scan | Re-raise it with Submit on Change diff sets. Warden setup gaps lists it as a stranded hold after 4 hours. |
Re-running is always safe.
Impact on other functionality
- While the drain does not run, held purchase orders stay unconfirmable and unreceivable with no approver asked. Nothing else is blocked: users can keep editing, and each edit is governed as it lands.
- Approvers see delta work items up to one interval after the edit. With the promised 5-minute interval this is the latency described in Getting started.
- It takes a row lock on one hold and one diff set at a time, for the duration of the claim transaction. A release of the same hold waits for it.
Related documentation
- Purchase order change and delta re-approval
- Getting started and §5b
- Warden batch framework
- Standard batch and periodic processes with Warden installed
Firming route drain
At a glance
| Batch class | MGCWardenFirmingRouteDrainBatch |
| Menu item | MGCWardenFirmingRouteDrainMenuItem, label Warden firming route drain |
| Menu path | System administration → Setup → Warden firming route drain |
| Who may run it | MGCWardenPolicyAuthorPriv (Update) → MGCWardenPolicyAuthoringDuty → Warden guard administrator. API: MGCWardenBatchService.runFirmingRouteDrain. |
| Feature toggle | None. It runs with Warden Order Guard off. |
| Company scope | Per legal entity. Reads MGCWardenFirmingRequest in the task's company. |
| Scheduled by default | No. The same sweep also runs at the end of every firming run (see below). |
| Recurrence | You choose. No interval is stated in code or docs. |
| Setup-gap rules | FirmingDrainOwed, FirmingDrainNotScheduled, FirmingDrainStale (area FIRMDRAIN); StrandedHold. |
Purpose and business justification
When a planned order is firmed over a policy threshold, MGCWardenFirmingGate holds the new purchase
order and writes a firming request in PendingApproval inside the firming transaction. The gate does not activate the workflow inside that transaction, because a failed activation there
aborted the firming and, with Abort if errors set, the whole run. So an over-threshold firming commits
its hold and request and leaves the approval owed.
The same happens when firming adds planned orders to a purchase order it created earlier. The gate
measures the whole order each time (decided 2026-11-16): an order that passed through and now needs
approval, or an approved order that has grown, gets a new hold, its request goes back to
PendingApproval, and the new approval is owed to this drain. A request can therefore carry more than
one approval over its life. The drain, the retry and Submit ask only about the current one: the
approvals raised since the request's current hold was placed (MGCWardenFirmingRequest::episodeStart),
so the completed approval of an earlier hold does not count as this one's route.
The drain raises those owed approvals. It also recovers approvals the runtime accepted and then lost,
including a canceled approval: canceling leaves the request PendingApproval with its
hold standing, so the drain raises a fresh one.
How and when it is triggered
- At the end of every firming run.
MGCWardenReqTransPoMarkFirm_ExtensioncallsMGCWardenFirmingRouteDrainBatch::drainDeferredRoutes. It runs only outside a transaction and writes a line only when it raised, escalated or suppressed something. This covers most firmings without a schedule. See Standard batch and periodic processes with Warden installed. - By a scheduled batch job, Run now, or
MGCWardenBatchService.runFirmingRouteDrain. This is the backstop for what the end-of-run point misses: a run that dies after its commit, a nested firming, or a firming path that does not go throughReqTransPoMarkFirm.run().
Configuration and scheduling options
No dialog fields and no parameters. FirmingDrainNotScheduled fires only when an Active policy would
route a firming approval (firmingGovernanceInUse). Its text says that most firmings complete through
the end-of-run point, and that the batch is still needed for the rest.
What it does
- Snapshots every
MGCWardenFirmingRequestinPendingApproval. - For each (
drainOne), in this order:- Re-reads the request. Not
PendingApprovalany more: skipped. - Announces the order's Firming hold if it has not been announced (
HoldPlaced). - Asks the runtime whether an approval exists. Yes: already routed.
- Checks that the order still carries an active Firming hold (by type). No: skipped.
The request is left in
PendingApproval; the drain does not change the business status. - Lost activations for this request at or above 3: escalates (one Critical execution exception per
order, Retry
MGCWardenFirmingRouteRetry, filed only if no open one exists). - Firming approval workflow type written off: not attempted.
- Takes the claim (
MGCWardenFirmingRequest::claimRoute). Lost: skipped; a Retry or the manual Submit on the firming queue has it. - Asks the runtime again under the claim. If an approval now exists, releases the claim: already routed.
- Submits
MGCWardenFirmingApprovalSubmitManager::submit, releases the claim, and writes aFirmingRequestedevent-log row: raised. - On failure: releases the claim and files one Error execution exception per workflow type, counted
up (Retry
MGCWardenFirmingRouteRetry): escalated.
- Re-reads the request. Not
- Writes:
Warden firming route drain: N firming approval(s) raised, N already routed, N escalated to the exception workbench, N left alone, N not attempted because the approval workflow has been written off.
The claim is released on success as well as failure (MGCWardenFirmingRequest::releaseRoute). The
request has no "routed" status to move to, and a lost activation must be re-raisable at once.
Dependencies and prerequisites
- An active Warden firming approval workflow (
MGCWardenFirmingApprovalTemplate). - An Active planned-order firming policy.
Inputs and outputs
| Reads | Writes |
|---|---|
MGCWardenFirmingRequest (PendingApproval) | MGCWardenFirmingRequest.RouteClaimedDateTime (set and cleared) |
MGCWardenHold (Firming hold on the PurchTable record) | Workflow instances (firming approval) |
| Workflow tracking (route exists, lost-activation count) | MGCWardenEventLog (FirmingRequested) |
MGCWardenExecutionException (give-up rule, open escalation) | MGCWardenExecutionException; MGCWardenHoldPlaced business event |
Logging and monitoring
- Batch task log and, for the end-of-run point, the firming run's infolog.
- Firming approval queue (System administration → Setup → Firming approval queue).
- Execution exceptions, Governance event log, Warden setup gaps (
FirmingDrain*,StrandedHold).
Errors, recovery and troubleshooting
| Symptom | What to do |
|---|---|
FirmingDrainOwed or FirmingDrainStale | Schedule the drain in this company, or check the batch job and the workbench for a written-off workflow type. |
| Critical row … accepted and then lost every activation raised for it | The drain has stopped re-raising that order. Fix the workflow configuration, then press Retry. |
| Error row The firming route drain could not activate the Firming approval workflow | Configure and activate the workflow, Retry the row, then resolve it. |
| Error row The end-of-run firming route drain failed | The orders are already in the batch drain's population. Let the scheduled drain pick them up, or run it. |
Impact on other functionality
- An owed firming leaves the purchase order held: confirmation, receipt and invoice are refused, and master planning still treats it as supply (class summary).
- Canceling a firming approval does not stop it. The drain raises a fresh one until three activations have been lost.
- The end-of-run point adds a short sweep to each firming run. It is silent when it moves nothing.
Related documentation
- Standard batch and periodic processes with Warden installed for the firming run itself
- User guide on canceling approvals
- Warden batch framework
Trade agreement route drain
At a glance
| Batch class | MGCWardenTARouteDrainBatch |
| Menu item | MGCWardenTARouteDrainMenuItem, label Warden trade agreement route drain |
| Menu path | System administration → Setup → Warden trade agreement route drain |
| Who may run it | MGCWardenPolicyAuthorPriv (Update) → MGCWardenPolicyAuthoringDuty → Warden guard administrator. API: MGCWardenBatchService.runTARouteDrain. |
| Feature toggle | Warden Trade Agreement Governance (MGCWardenTradeAgreementGovFeature, on by default). Stands down when it is off. |
| Company scope | Per legal entity. Reads MGCWardenTAGateState in the task's company. |
| Scheduled by default | No. |
| Recurrence | You choose. No interval is stated. |
| Setup-gap rules | TaDrainOwed, TaDrainNotScheduled, TaDrainStale (area TADRAIN); StrandedHold. |
Purpose and business justification
A gated classic trade agreement journal can be neither posted nor edited: the posting seam
(MGCWardenPriceDiscAdmCheckPost_Extension) and the write seam (MGCWardenPriceDiscAdmTable_Extension)
both refuse it. If the approval activation fails, or the runtime later loses the approval, the journal
stays gated with nobody asked to decide it.
Every other recovery for this route is attended: Retry on the workbench, Submit for approval, and the Critical workbench row. The trade agreement route has no end-of-run drain point. So without this batch, a journal gated on a Friday stays blocked until somebody reads the workbench.
How and when it is triggered
By a scheduled batch job, Run now, or MGCWardenBatchService.runTARouteDrain. Nothing else calls it.
Configuration and scheduling options
No dialog fields and no parameters. TaDrainNotScheduled fires only when trade agreement governance is
in use: the feature is on and an effective Active price-guard policy would gate a journal
(tradeAgreementGovernanceInUse).
What it does
- If
MGCWardenTradeAgreementGovFeature::isOn()is false, writesWarden trade agreement route drain: Trade Agreement Governance is off; nothing to route.and stops. With the toggle off nothing refuses a gated journal, so raising an approval would ask somebody to decide a journal nobody is stopping. - Snapshots every
MGCWardenTAGateStatewithRefTableId=PriceDiscAdmTableandGated= Yes. Unified pricing management agreements are out of scope: nothing in that module enforces the gate. - For each (
drainOne):- Re-reads the row. No longer gated: skipped.
- Announces the journal's TradeAgreement hold if not yet announced.
- Route exists in the current gating episode (
MGCWardenTAGateState::routeExists): already routed. - Journal deleted or posted: skipped.
- Lost activations in this episode at or above 3: escalates (one Critical row per journal, Retry
MGCWardenTARouteRetry). - Trade agreement approval workflow type written off: not attempted.
- Takes the claim (
MGCWardenTAGateState::claimRoute). Lost: skipped. - Route exists now: releases the claim, already routed.
- Submits
MGCWardenTAApprovalSubmitManager::submit(state), releases the claim, writes aDeltaRequestedevent-log row: raised. - On failure: releases the claim, files one Error row per workflow type, counted up (Retry
MGCWardenTARouteRetry): escalated.
- Writes:
Warden trade agreement route drain: N price governance approval(s) raised, N already routed, N escalated to the exception workbench, N left alone, N not attempted because the approval workflow has been written off.
Two rules specific to this drain:
- It does not re-measure the journal. The approval step (
RequiredStepTag) stamped when the journal was gated is what the workflow's step conditions read. The drain re-raises that route; it never re-runs the effective-date check against today's date, which could downgrade the required approver. - It does not ask whether the journal is still held.
Gatedis what the seams enforce. A journal whose hold was released by break-glass whileGatedstayed Yes is still refused, so it is still drained.
Dependencies and prerequisites
- Warden Trade Agreement Governance switched on.
- An active Warden trade agreement approval workflow (
MGCWardenTAApprovalTemplate). - An Active price-guard policy.
Inputs and outputs
| Reads | Writes |
|---|---|
MGCWardenTAGateState (Gated) | MGCWardenTAGateState.RouteClaimedDateTime |
PriceDiscAdmTable (exists, Posted) | Workflow instances (trade agreement approval) |
| Workflow tracking (episode-scoped) | MGCWardenEventLog (DeltaRequested) |
MGCWardenExecutionException | MGCWardenExecutionException; MGCWardenHoldPlaced business event |
Logging and monitoring
- Batch task log.
- Trade agreement gated journals (System administration → Setup → Trade agreement gated journals).
- Execution exceptions, Governance event log, Warden setup gaps (
TaDrain*,StrandedHold).
Errors, recovery and troubleshooting
| Symptom | What to do |
|---|---|
| Run log says Trade Agreement Governance is off | Expected when the toggle is off. Gated journals are not refused while it is off. |
TaDrainOwed | Schedule the drain in this company. |
TaDrainStale | Check the batch job, then the workbench. A written-off workflow makes the drain suppress, which also leaves journals owed. |
| Critical row … accepted and then lost every activation raised for it | Nothing will recover the journal unattended. Fix the workflow, then Retry. |
A deleted gated journal is not re-raised by the drain. See the cancellation notes in User guide.
Impact on other functionality
- While the drain does not run, a gated journal with no route blocks the pricing desk: it cannot be posted or edited.
- Canceling a trade agreement approval does not stop it; the drain raises a fresh one until three have been lost.
Related documentation
- Trade agreement approval sweep
- Standard batch and periodic processes with Warden installed for trade agreement journal posting
- Getting started
Journal route drain
At a glance
| Batch class | MGCWardenJournalRouteDrainBatch |
| Menu item | MGCWardenJournalRouteDrainMenuItem, label Warden journal route drain |
| Menu path | System administration → Setup → Warden journal route drain |
| Who may run it | MGCWardenPolicyAuthorPriv (Update) → MGCWardenPolicyAuthoringDuty → Warden guard administrator. API: MGCWardenBatchService.runJournalRouteDrain. |
| Feature toggle | Warden Journal Governance (MGCWardenJournalGovFeature). Stands down when it is off. |
| Company scope | Per legal entity. Reads InventJournalTable and MGCWardenJournalGovState in the task's company. |
| Scheduled by default | No. |
| Recurrence | You choose. No interval is stated. |
| Setup-gap rules | JournalDrainOwed, JournalDrainNotScheduled, JournalDrainStale (area JOURNALDRAIN); StrandedHold. |
Purpose and business justification
Journal governance routes a banded review before native posting opens its transaction
(MGCWardenInventJournalRoute_Extension). That works when the journal is posted from the
journal form. Most other inventory journal posting paths run inside a caller's transaction: warehouse
mobile counting, ITM over/under, Rental transfers, BOM report-finish, retail kit assembly and field
service work orders (the class summary's census: 26 of 30 shipping call sites). On those paths Warden
must not route, because the caller could roll the work back. The posting is refused, because the band was
really crossed, and no approver is asked. This drain is the only thing that raises those reviews.
It also re-raises a review that was raised and then lost: the review is Pending, the hold stands, and
the runtime has no approval.
How and when it is triggered
By a scheduled batch job, Run now, or MGCWardenBatchService.runJournalRouteDrain. There is no
end-of-run point (class summary, "No second entry point").
Configuration and scheduling options
No dialog fields and no parameters. JournalDrainNotScheduled fires only when banded review is in use:
the feature is on and an effective Active journal policy has at least one band whose step is not None
(bandedReviewGovernanceInUse).
What it does
- If
MGCWardenJournalGovFeature::isOn()is false, writesWarden journal route drain: journal governance is off; nothing to route.and stops. - If called inside a transaction, returns without doing anything.
- If no journal policy is Active and in its effective window, returns with every count at zero. The summary line still prints.
- Snapshots every
InventJournalTablethat is unposted and not of typeTagCounting. Tag-counting journals are excluded because the band gate does not cover them. - For each (
drainOne):- Re-reads the journal. Posted or gone: skipped.
- Announces the journal's JournalGovernance (reversal) hold and JournalReview hold if
either is not yet announced (
announceHeldJournal). ReviewState=Rejected(shown as Canceled): skipped. Nothing writes this state; only older rows carry it.ReviewState=Pending: the stranded path (reRaiseStrandedReview):- review route exists in this episode: already routed;
- lost activations at or above 3: escalates (Critical, per journal, Retry
MGCWardenJournalRouteRetry); - workflow type written off: not attempted;
- claim (
MGCWardenJournalGovState::claimRoute), re-check, thenMGCWardenJournalReviewSubmitManager::submitwithout re-measuring the step: re-raised; - on failure: one Error row per workflow type, counted up.
- Otherwise the owed path: resolves the journal policy for the journal name, measures the bands
(
MGCWardenJournalGuard::reviewRequirement) and compares the required step with the step already approved. Nothing owed: skipped. Workflow type written off: not attempted. Otherwise callsMGCWardenJournalReviewRouter::evaluate(the one routing entry point), then asks the runtime whether the review now exists. Yes: routed, with aDeltaRequestedevent-log row. No: escalated (the submit manager has already filed its exception).
- Writes:
Warden journal route drain: N banded review(s) routed, N lost review(s) re-raised, N already routed, N escalated to the exception workbench, N left alone, N not attempted because the approval workflow has been written off.
The owed path measures the journal as it stands. A journal edited below its band since the refused posting owes nothing and is left alone. The stranded path keeps the step that was stamped.
This drain announces reversal holds but does not raise reversal approvals. See Journal reversal router.
Dependencies and prerequisites
- Warden Journal Governance switched on.
- An active Warden journal banded review workflow (
MGCWardenJournalReviewTemplate). - An Active journal policy with cost bands whose step tag is not None.
Inputs and outputs
| Reads | Writes |
|---|---|
InventJournalTable, InventJournalTrans (read only, never for update) | MGCWardenJournalGovState (through the router; claim time) |
MGCWardenJournalPolicy, MGCWardenJournalPolicyBand | MGCWardenHold (JournalReview hold, through the router) |
MGCWardenJournalGovState | Workflow instances (journal banded review) |
| Workflow tracking (episode-scoped, by workflow type) | MGCWardenEventLog (DeltaRequested); MGCWardenExecutionException; MGCWardenHoldPlaced |
Logging and monitoring
- Batch task log.
- Journal governance queue (System administration → Setup → Journal governance queue).
- Execution exceptions, Governance event log, Warden setup gaps (
JournalDrain*,StrandedHold).
The JournalDrainOwed count covers only the stranded population (a Pending review with no route). A
journal refused on a nested posting path leaves no row until the drain routes it, so it is not counted.
The page does not re-measure every open journal; JournalDrainNotScheduled is what tells you to schedule.
Errors, recovery and troubleshooting
| Symptom | What to do |
|---|---|
| A journal posted from warehouse counting or another nested path is refused and no work item appears | Expected until the drain runs. Schedule it, or run it now. |
| Run log says journal governance is off | Expected; banded journals are not refused while it is off. |
| Every count is zero | No journal policy is Active and effective, or nothing is owed. |
| Error row The journal route drain could not route the banded review | Configure and activate the banded review workflow, then Retry the row. |
Impact on other functionality
- While it does not run, banded journals posted through nested paths stay unpostable at their current size, with nobody asked.
- Each pass reads every unposted, non-tag-counting inventory journal and, for each journal under a policy, its lines. Its duration grows with the number of open journals.
- It reads native journal tables without locks. It writes only Warden rows and workflow instances.
Related documentation
- Standard batch and periodic processes with Warden installed for inventory journal posting
- Journal reversal router
- Getting started
- Warden batch framework