Skip to main content

Warden setup-gap snapshot

Re-runs the setup-gap sweep and saves its result, so that the Setup gaps tile on the Warden workspaces has rows a query can count. It owns no detection rules of its own.

At a glance​

Batch classMGCWardenSetupGapSnapshotBatch (all the work is in its static refresh())
Menu itemMGCWardenSetupGapSnapshotMenuItem, label Warden setup-gap snapshot
Menu pathSystem administration → Setup → Warden setup-gap snapshot
Who may run itMGCWardenPolicyAuthorPriv (granted at Delete) → MGCWardenPolicyAuthoringDuty → Warden guard administrator (MGCWardenGuardAdministrator). The API operation MGCWardenBatchService.runSetupGapSnapshot is granted on the same privilege and re-checks the same menu item
Feature toggleNone. The class reads no feature toggle; it runs whichever Warden features are on
Company scopePer legal entity. The snapshot table is per company, and each run replaces only the running company's rows
Scheduled by defaultNo. Nothing in the product creates a batch job for it
RecurrenceYou choose. The class summary says to schedule it beside Warden retention cleanup, per company; it states no interval
Setup-gap rules watching itNone. No MGCWardenSetupGapRule value reports whether this batch is scheduled or has run
Run recordNone. Each snapshot row carries the time of the run that wrote it (DetectedDateTime)
Overlap guardNot guarded by MGCWardenBatchOverlapGuard

Purpose and business justification​

The Warden setup gaps page (MGCWardenSetupGaps) lists everything Warden can detect that stops a control, a recovery or a piece of evidence from working as configured, across all five packages . The page computes its list live, into the in-memory table MGCWardenSetupGapTmp, each time it opens.

A workspace tile cannot count an in-memory table. An AxTile names an AxQuery, and the query runs against the database. So the product persists the last sweep in MGCWardenSetupGapSnapshot and points the tile at that. The table summary puts the result this way: the tile answers "how many gaps did the last sweep find, and when"; the page answers "what are the gaps right now".

The batch deliberately has no rules of its own. It calls the same MGCWardenSetupGapCheck::populate the page calls, so the tile and the page cannot disagree about what counts as a gap, only about when it was counted. MGCWardenSetupGapPackageTest asserts that a refresh writes as many rows as a live sweep finds.

How and when it is triggered​

  • A batch job you create from the menu item, with a recurrence on the Run in the background tab. The dialog has no fields of its own: pack() returns conNull().
  • Run now from the same menu item. canRunInNewSession() returns true, so the run happens in a second session for the same user.
  • The batch API. MGCWardenBatchService.runSetupGapSnapshot runs it synchronously in the caller's company. Its result carries the number of rows the snapshot now holds.

Opening the Warden setup gaps page does not refresh the snapshot. The form's init() calls populate into its own in-memory buffer and never calls refresh(). refresh() is public, and its summary names the form as a possible caller, but no product code other than run() calls it.

Configuration and scheduling options​

  • No dialog fields and no parameters.
  • Batch group: the class sets none. The customer chooses.
  • Choosing a recurrence. The tile is as old as the last run, so the interval is the most a tile count can lag behind the page. Each run costs one full setup-gap sweep, the same work as opening the page.
  • Schedule it in every legal entity whose workspaces you use. The tile counts the current company's snapshot only. In a company where the batch has never run the snapshot is empty and the tile shows zero, whatever the page lists.

What it does​

run()
'-- refresh()
|-- detectedAt = now
|-- try
| |-- MGCWardenSetupGapCheck::populate(gapTmp) (outside any transaction)
| |-- ttsbegin
| | delete_from MGCWardenSetupGapSnapshot (this company's rows)
| | insert one snapshot row per gapTmp row (DetectedDateTime = detectedAt)
| '-- ttscommit
'-- catch: file a Warning execution exception, return 0 (previous snapshot left in place)
'-- info: "Warden setup-gap snapshot refreshed: N gap(s) recorded for <company>."
  1. refresh() takes the time once. Every row it writes carries that time as DetectedDateTime.
  2. It runs MGCWardenSetupGapCheck::populate before opening its transaction. Some gap readers depend on this: MGCWardenLicensing::populateSetupGaps returns nothing when called inside a transaction, and its summary names this ordering.
  3. In one transaction it deletes the company's whole snapshot and inserts one row per gap found: PolicyCode, PolicyVersion (an area code and version 0 for rows that belong to no policy version), GapDescription and DetectedDateTime.
  4. run() prints the count.

Replace, never merge. A gap fixed since the last run disappears on the next run; nothing has to be cleared by hand. Running it twice leaves what running it once leaves.

What the sweep covers is whatever populate covers on the day; the live page is its catalog. That includes the three schedule rules for each route drain (see Route drains), the purge execution, deprovisioning scan and deprovisioning overdue monitor schedule rows, workflow configuration, stranded holds and versions, parameter values, count and recount gaps, audit-store and evidence-pack gaps, the license, and legal entities without Warden parameters.

Concurrency. There is no overlap guard. Each run does all its writes in one transaction. MGCWardenBatchService records the argument that a concurrent run rolls back rather than writes twice. Not confirmed: the end state of two overlapping refreshes on a live estate; nothing in the repository exercises it.

Dependencies and prerequisites​

  • Nothing must run first. The sweep reads configuration and live state directly.
  • The snapshot is only useful if someone opens the Warden Controls or Warden Audit workspace in that company.

Inputs and outputs​

Reads: everything MGCWardenSetupGapCheck::populate reads (policies of every family, workflow configuration, batch jobs, holds, parameters, the audit register and store, and more).

Writes: MGCWardenSetupGapSnapshot (per company), deleted and rewritten in full. The table is not evidence: it has no append-only guard, and retention cleanup does not touch it.

On failure: one MGCWardenExecutionException (area Other, reason Other, severity Warning, table MGCWardenSetupGapSnapshot, no record) with the text Warden setup-gap snapshot refresh failed; the workspace gap tile is showing the previous sweep. If BusinessEventsEnabled is set on the parameters, MGCWardenExecutionExceptionManager::create also sends the MGCWardenExecutionExceptionCreated business event.

Infolog: Warden setup-gap snapshot refreshed: N gap(s) recorded for <company>.

Who reads the snapshot:

ConsumerWhat it does with itWho can open it
MGCWardenSetupGapsTile (label Setup gaps, type Count) through MGCWardenSetupGapsQueryCounts the company's snapshot rows. Pressing it opens the live Warden setup gaps pageShown on the Warden Controls workspace (MGCWardenControlsWorkspace) and the Warden Audit workspace (MGCWardenAuditWorkspace), both under System administration → Setup
MGCWardenSetupGapSnapshotEntity (public collection WardenSetupGapSnapshots, read-only, data management enabled)Serves the rows, including DetectedDateTime, over OData and data management exportRead granted by MGCWardenGuardEvidenceEntityPriv, through MGCWardenAuditPackExportDuty, to Warden audit administrator
MGCWardenBatchServiceCounts the rows after an API run, as the call's evidenceThe API caller

No form shows the snapshot rows or their timestamp. The workspace summaries say the row timestamp keeps a stale count honest, but in the client the timestamp is not on screen: it is readable through the data entity only.

Screenshot to add: the Setup gaps tile on the Warden Controls workspace beside the live Warden setup gaps page, showing that the tile counts the last run and the page the current state.

Logging and monitoring​

  • Batch job history holds the info line with the count.
  • Execution exceptions (System administration → Setup → Execution exceptions) holds the Warning row when a refresh fails.
  • The snapshot's own age: export or query WardenSetupGapSnapshots and read DetectedDateTime.
  • No setup-gap rule watches this batch. An unscheduled snapshot shows as a tile that never changes, or as zero in a company where it never ran.

Errors, recovery and troubleshooting​

  • A failure is swallowed. refresh() wraps the sweep and the rewrite in one try that starts outside the transaction. If the sweep or the rewrite throws, the transaction is rolled back, the previous snapshot stays as it was, the catch files the Warning exception and refresh() returns 0. The catch is a bare catch, which runs here because the try began at transaction level 0: a catch naming UpdateConflict or DuplicateKeyException runs inside a transaction and every other catch does not.
  • The batch task still ends successfully after a failure, and its info line then reads "0 gap(s)". MGCWardenBatchService reports such a run as Failed by looking for the Warning exception; a scheduled run gives no such signal. Check the execution exceptions workbench, not only the batch status.
  • Re-running is safe: the next successful run replaces the snapshot in full.
  • The tile disagrees with the page. Expected between runs. Run the batch, or open the page for the current list. If the tile shows zero and the page does not, the batch has not run in this company.
  • What to look at first: the execution exceptions workbench for a refresh failure, then the batch job for this company.

Impact on other functionality​

  • When it does not run: nothing is blocked and no control changes. Only the tile goes stale (or stays at zero in a company it never ran in). The Warden setup gaps page is unaffected, because it computes live.
  • While it runs: the delete and inserts on MGCWardenSetupGapSnapshot are one short transaction. The sweep before it is read-only.