Skip to main content

Audit chain integrity: anchoring, publication and verification

The audit chain integrity batch is the audit store's tamper evidence. Each run seals new store rows under hash-chain anchors, publishes the anchors (and each company's leaver intake chain head) outside the store, publishes the retirement of any anchor a certified purge emptied, and re-walks every anchored range to attest that it still reproduces.

At a glance​

Batch classMGCWardenAuditIntegrityBatch, which runs the four steps of MGCWardenAuditHashChain (computeAnchors, publishAnchors, publishReconciliations, verify) and calls MGCWardenAuditLeaverIntakeChain::publishHeads from inside publishAnchors
Menu itemMGCWardenAuditIntegrityMenuItem, label Audit chain integrity
Menu pathSystem administration → Setup → Audit chain integrity
Who may run itMGCWardenAuditAdministrationPriv (granted at Update) → MGCWardenAuditAdministrationDuty → Warden audit administrator (MGCWardenAuditAdministrator). The API operation MGCWardenBatchService.runAuditIntegrity is granted on the same privilege and re-checks the same menu item
Feature toggleNone. MGCWardenAuditReportingFeature's summary names this class as one no toggle may govern, because gating it would let a reporting checkbox stop tamper detection
Company scopeInstallation-wide. Anchors (MGCWardenAuditHashAnchor), reconciliations (MGCWardenAuditAnchorReconciliation), verification runs (MGCWardenAuditVerificationRun) and the store are shared, so one run in any company covers every partition. The ANCHOR-FEED event-log rows are written in the company the run executes in, and the business-event switch is read there
Scheduled by defaultNo. Nothing in the product creates a batch job for it
RecurrenceYou choose, and the audit parameters declare what you intend: Anchor cadence target (hours) and Verification schedule target (hours), both 24 by default. The class does not schedule or throttle itself; it measures the actual gap against the targets and files a Warning when the recurrence falls short
Setup-gap rules watching itAnchorFeedNoDestination, AnchorFeedNeverPublished, AnchorFeedStale (last publication older than three times the anchor cadence)
Run recordMGCWardenAuditVerificationRun rows (one per anchored range per run) and the anchors themselves
Overlap guardYes. MGCWardenBatchOverlapGuard::refuses runs first and refuses while another task of this class is executing in any company

Purpose and business justification​

The store is append-only in code, but a system administrator cannot be role-blocked on this platform. The guarantee Warden offers is therefore detection, not prevention: a chained digest over every row, sealed in anchors, with the anchors published to places a database editor does not control. If someone edits or deletes a sealed row, the next verification fails for that range.

Publication is what makes the anchors worth having: a digest held only inside the system it attests can be recomputed by whoever edits the rows. Publishing anchor retirements as well lets an outside verifier tell a certified purge from tampering.

How and when it is triggered​

  • Scheduled from the menu item, with a recurrence, in any one company.
  • Run now from the same menu item. canRunInNewSession() returns true.
  • API: MGCWardenBatchService.runAuditIntegrity.

MGCWardenAuditHashChain::reconcileAfterPurge is not part of this batch: it runs inside the purge execution's transaction and creates the reconciliation rows that this batch later publishes.

Configuration and scheduling options​

No dialog fields; pack() returns conNull().

ParameterTable and fieldDefaultEffect
Anchor cadence target (hours)MGCWardenAuditParameters.AnchorCadenceHours24Declared target. A gap since the newest anchor longer than this files a Warning. Also the base of the AnchorFeedStale setup gap. The table refuses a value outside 1..8760
Verification schedule target (hours)MGCWardenAuditParameters.VerificationScheduleHours24Declared target. A gap since the newest verification run longer than this files a Warning. Same bounds
Anchor feed destinationMGCWardenAuditParameters.AnchorFeedDestinationblankA directory (trailing backslash or an existing directory, where the file is MGCWardenAnchorFeed.txt) or a file path. Blank means no file channel
Publish business eventsMGCWardenParameters.BusinessEventsEnabled (Warden guard parameters, per company)-Gates the Warden audit anchor published business event, read in the company the run executes in

MaxRowsPerAnchor is a constant, 5,000 rows, not a parameter.

Choosing a recurrence. Set the job's recurrence to meet the two targets, or lower the targets to what the schedule delivers; either clears the Warning. Every run re-walks every anchored range, so the duration grows with the store. Every run also appends one verification-result store row per anchored range (see Impact), so a recurrence much shorter than you need grows the store for no extra assurance.

What it does​

overlap guard --> attestCadence (Warnings only)
|
+-- computeAnchors ........... per partition: walk unlocked, seal under lockChainHead
+-- publishAnchors ........... per unpublished anchor: event log (record), then
| business event + feed file (mirrors);
| then every company's leaver intake chain head
+-- publishReconciliations ... per unpublished retirement: event log, then feed file
+-- verify ................... per anchor: recompute, assess, record run row + store row

Each of the four steps sits in its own try block, so a failure in one never starves the next.

  1. Overlap guard. Refused runs measure nothing and seal nothing; the running task covers the gap.
  2. Cadence attestation (attestCadence). Reads the newest anchor's AnchoredDateTime and the newest verification run's RunDateTime and compares each gap with its target (isCadenceOverdue). An overdue step files a Warning execution exception telling you to raise the recurrence or lower the target. A target of 0 or less, or a step that has never run, is not overdue. This step never throws.
  3. Anchoring (computeAnchors → computeAnchorForPartition, one partition at a time):
    • seals from the last anchor's ToSequence + 1 up to the highest sequence the partition held when the run started, in anchors of at most 5,000 rows;
    • walks each range without a lock, chaining hashString(previous digest + rowDigest(row)) with SHA-256 (base64). rowDigest covers partition, sequence, event kind, actor, record key and Last occurred. A genesis range seeds from the empty digest;
    • then, in one short transaction, takes lockChainHead. If another run sealed meanwhile, it inserts nothing and starts again from the new head. If the range's row count and occurrence total changed during the walk (a dedup fold landed), it walks the range again under the lock. It then inserts the anchor with Published = No;
    • a failing partition files an Error and the next partition carries on.
  4. Publication (publishAnchors), per unpublished anchor:
    • claims the anchor under pessimisticlock and, in one transaction, writes an ANCHOR-FEED governance event (AnchorPublished, Audit hash anchor: partition P, sequences F..T, digest D) and marks the anchor Published with a timestamp (skipDataMethods(true) and doUpdate(); the digest never changes). The event-log row is the publication of record;
    • after the commit, two best-effort mirrors: the Warden audit anchor published business event (when BusinessEventsEnabled is Yes) and a line in the feed file (partition;fromSeq;toSeq;hash;anchoredDateTime). A mirror failure files a Warning and does not unmark the anchor;
    • then MGCWardenAuditLeaverIntakeChain::publishHeads: for every company whose leaver intake chain has sealed at least one record, it publishes the head again on every run, moved or not, under that head's lock inside changecompany. Each head produces an ANCHOR-FEED event in that company, the business event (record kind LeaverIntakeChainHead) and an INTAKEHEAD;company;publication number;sequence;digest;records removed by retention;previous publication's sequence;digest at that sequence now;time feed line. A company that fails files its own Error and stays unmarked.
  5. Retirement publication (publishReconciliations), per unpublished reconciliation: claims it under pessimisticlock, writes an ANCHOR-FEED event (Audit hash anchor RETIRED by certified purge ...) and marks it published, then appends a RETIRED;partition;from;to;reconciledDigest;certificate;rows removed;time feed line. There is deliberately no business event for a retirement.
  6. Verification (verify), per anchor in partition and sequence order:
    • recomputes the range's digest from the previous anchor's published digest (seedDigestFor);
    • assess decides: Pass if the digest matches; Reconciled if it does not, a reconciliation exists, and the surviving rows reproduce the reconciled digest and count; Fail otherwise;
    • inserts one MGCWardenAuditVerificationRun row and appends one VerificationResult store row (SourceRef VERIFY:<RecId>). A range that cannot be verified files an Error and the next range carries on.
  7. Writes Warden audit integrity batch completed (anchors, feed, verification).

Concurrency. The overlap guard keeps two batch tasks apart. It cannot see an interactive Run now or an API call, so the steps also protect themselves: anchoring re-checks the head under its lock, publication claims each anchor and retirement under pessimisticlock, and the writer and the anchoring share lockChainHead.

Idempotency. Anchors are published once. Leaver intake heads are restated on every run by design. Verification is repeated on every run by design.

Dependencies and prerequisites​

  • The audit writer and guard ingestion running, so there are store rows to seal.
  • An anchor feed destination the AOS can write to, if you want the file channel. On a cloud-hosted environment that path must be reachable from the AOS process.
  • Business events configured and BusinessEventsEnabled on in the running company, if you want the business-event channel.

Inputs and outputs​

DirectionTable, object or channelWhat
ReadsMGCWardenAuditEventRows to seal and to verify
Reads, inserts, updatesMGCWardenAuditHashAnchorNew anchors; Published, PublishedDateTime
Reads, updatesMGCWardenAuditAnchorReconciliationPublished, PublishedDateTime
Reads, updatesMGCWardenAuditLeaverIntakeChainHead (every company)Publication of each head
InsertsMGCWardenAuditVerificationRunOne row per anchored range per run
InsertsMGCWardenAuditEventOne VerificationResult store row per anchored range per run
InsertsMGCWardenEventLogANCHOR-FEED rows (AnchorPublished), never forwarded to the store
ReadsMGCWardenAuditParameters, MGCWardenParametersTargets, destination, business-event switch
SendsMGCWardenAuditAnchorPublishedBusiness event Warden audit anchor published
AppendsAnchor feed fileAnchor, RETIRED and INTAKEHEAD lines
InsertsMGCWardenExecutionExceptionCadence Warnings, mirror Warnings, step and per-range Errors

Logging and monitoring​

  • Hash-chain anchors (System administration → Setup → Hash-chain anchors) and Chain verification results (same menu), both also on the Warden Audit workspace.
  • Data entities Warden audit hash anchors (WardenAuditHashAnchors) and Warden audit anchor reconciliations (WardenAuditAnchorReconciliations); reconciliations have no page of their own.
  • Setup gaps: no destination, a destination with nothing ever published, or the last publication older than three times the anchor cadence (24 hours if the cadence is not positive).
  • Execution exceptions: cadence drift (Warning), mirror failures (Warning, IntegrationFailure), step and range failures (Error).
  • Evidence packs: the coverage statement prints the latest verification run and the latest published anchor for the pack's partition, and the feed destination or NOT CONFIGURED.

Errors, recovery and troubleshooting​

SymptomCause and recovery
Warning Audit anchoring is behind its declared cadence ... or Audit chain verification is behind its declared schedule ...The job's recurrence is longer than the target, or the job stopped. Raise the recurrence or lower the target. The row has no Retry lever on purpose: re-running does not close a gap that already happened
Error Warden audit anchoring failed for partition PThat partition was not sealed this run; the next run tries again
Error ... anchor publication failed ...The anchor stays unpublished and the next run publishes it
Warning ... business event failed or ... feed file append failed ...A mirror failed. The anchor is still published on the event log; the mirror is not retried for that anchor
Verification result FailA sealed range no longer reproduces and no certificate explains it. Treat it as a tamper finding.
Verification result ReconciledA certified purge removed rows from the range and the survivors still match what the purge recorded. Not a finding
Warning from the overlap guardTwo integrity tasks overlap. Remove the duplicate or lengthen the recurrence

The class does not implement BatchRetryable. Every step is caught, so the task ends normally unless the overlap guard itself throws.

Impact on other functionality​

  • If it never runs: nothing is sealed, nothing is published, every evidence pack's coverage statement says no verification and no published anchor, the setup gaps page shows AnchorFeedNeverPublished once a destination is set, and nothing outside the system can corroborate the store.
  • Purge. The purge never deletes a row above the sealed frontier (Unanchored carve-out), so rows wait for this batch before they can be purged. A purge that empties or thins an anchored range writes a reconciliation in its own transaction; this batch then publishes it and verification reports Reconciled.
  • Store growth. Each run appends one VerificationResult row per anchored range. Those rows are control evidence (MGCWardenAuditPurgeScope::isControlEvidence) and can never be purged.
  • Writer. The anchoring holds the partition's chain head only while it checks and inserts one anchor, so the writer waits at most for one count or one walk of 5,000 rows.
  • Leaver intake. The walk of the intake chain itself is done by the HR deprovisioning scan; this batch only publishes the heads. See HR deprovisioning scan and leaver intake.