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 class | MGCWardenAuditIntegrityBatch, which runs the four steps of MGCWardenAuditHashChain (computeAnchors, publishAnchors, publishReconciliations, verify) and calls MGCWardenAuditLeaverIntakeChain::publishHeads from inside publishAnchors |
| Menu item | MGCWardenAuditIntegrityMenuItem, label Audit chain integrity |
| Menu path | System administration → Setup → Audit chain integrity |
| Who may run it | MGCWardenAuditAdministrationPriv (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 toggle | None. MGCWardenAuditReportingFeature's summary names this class as one no toggle may govern, because gating it would let a reporting checkbox stop tamper detection |
| Company scope | Installation-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 default | No. Nothing in the product creates a batch job for it |
| Recurrence | You 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 it | AnchorFeedNoDestination, AnchorFeedNeverPublished, AnchorFeedStale (last publication older than three times the anchor cadence) |
| Run record | MGCWardenAuditVerificationRun rows (one per anchored range per run) and the anchors themselves |
| Overlap guard | Yes. 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().
| Parameter | Table and field | Default | Effect |
|---|---|---|---|
| Anchor cadence target (hours) | MGCWardenAuditParameters.AnchorCadenceHours | 24 | Declared 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.VerificationScheduleHours | 24 | Declared target. A gap since the newest verification run longer than this files a Warning. Same bounds |
| Anchor feed destination | MGCWardenAuditParameters.AnchorFeedDestination | blank | A directory (trailing backslash or an existing directory, where the file is MGCWardenAnchorFeed.txt) or a file path. Blank means no file channel |
| Publish business events | MGCWardenParameters.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.
- Overlap guard. Refused runs measure nothing and seal nothing; the running task covers the gap.
- Cadence attestation (
attestCadence). Reads the newest anchor'sAnchoredDateTimeand the newest verification run'sRunDateTimeand 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. - Anchoring (
computeAnchors→computeAnchorForPartition, one partition at a time):- seals from the last anchor's
ToSequence + 1up 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).rowDigestcovers 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 withPublished = No; - a failing partition files an Error and the next partition carries on.
- seals from the last anchor's
- Publication (
publishAnchors), per unpublished anchor:- claims the anchor under
pessimisticlockand, in one transaction, writes anANCHOR-FEEDgovernance event (AnchorPublished, Audit hash anchor: partition P, sequences F..T, digest D) and marks the anchorPublishedwith a timestamp (skipDataMethods(true)anddoUpdate(); 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
BusinessEventsEnabledis 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 insidechangecompany. Each head produces anANCHOR-FEEDevent in that company, the business event (record kindLeaverIntakeChainHead) and anINTAKEHEAD;company;publication number;sequence;digest;records removed by retention;previous publication's sequence;digest at that sequence now;timefeed line. A company that fails files its own Error and stays unmarked.
- claims the anchor under
- Retirement publication (
publishReconciliations), per unpublished reconciliation: claims it underpessimisticlock, writes anANCHOR-FEEDevent (Audit hash anchor RETIRED by certified purge ...) and marks it published, then appends aRETIRED;partition;from;to;reconciledDigest;certificate;rows removed;timefeed line. There is deliberately no business event for a retirement. - Verification (
verify), per anchor in partition and sequence order:- recomputes the range's digest from the previous anchor's published digest
(
seedDigestFor); assessdecides: 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
MGCWardenAuditVerificationRunrow and appends oneVerificationResultstore row (SourceRefVERIFY:<RecId>). A range that cannot be verified files an Error and the next range carries on.
- recomputes the range's digest from the previous anchor's published digest
(
- 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
BusinessEventsEnabledon in the running company, if you want the business-event channel.
Inputs and outputs
| Direction | Table, object or channel | What |
|---|---|---|
| Reads | MGCWardenAuditEvent | Rows to seal and to verify |
| Reads, inserts, updates | MGCWardenAuditHashAnchor | New anchors; Published, PublishedDateTime |
| Reads, updates | MGCWardenAuditAnchorReconciliation | Published, PublishedDateTime |
| Reads, updates | MGCWardenAuditLeaverIntakeChainHead (every company) | Publication of each head |
| Inserts | MGCWardenAuditVerificationRun | One row per anchored range per run |
| Inserts | MGCWardenAuditEvent | One VerificationResult store row per anchored range per run |
| Inserts | MGCWardenEventLog | ANCHOR-FEED rows (AnchorPublished), never forwarded to the store |
| Reads | MGCWardenAuditParameters, MGCWardenParameters | Targets, destination, business-event switch |
| Sends | MGCWardenAuditAnchorPublished | Business event Warden audit anchor published |
| Appends | Anchor feed file | Anchor, RETIRED and INTAKEHEAD lines |
| Inserts | MGCWardenExecutionException | Cadence 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
| Symptom | Cause 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 P | That 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 Fail | A sealed range no longer reproduces and no certificate explains it. Treat it as a tamper finding. |
| Verification result Reconciled | A certified purge removed rows from the range and the survivors still match what the purge recorded. Not a finding |
| Warning from the overlap guard | Two 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
AnchorFeedNeverPublishedonce a destination is set, and nothing outside the system can corroborate the store. - Purge. The purge never deletes a row above the sealed frontier (
Unanchoredcarve-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
VerificationResultrow 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.