Skip to content
Data & Databases

Per-Entity State Sequence Auditor with Gap, Regression, Duplicate and Conflict Detection

10 nodes 14 1 Manual trigger
Download

Loading workflow…

Workflow Description

This workflow audits a set of records carrying an entity id, a state number and a record id, verifying the rule current = previous + declared increment inside each entity separately. A Code node groups records per entity, validates state-number types, classifies every input-order transition as valid, gap or regression, separates identical duplicates from content conflicts at the same state number, and derives missing states. An IF node routes clean and defective entity reports to two branches, Merge in append mode joins them, and a final Code node builds exactly one summary report with totals and failed entity ids without mutating the source records.

How it works

  1. 1.Manual Trigger starts the local run.
  2. 2.Set defines field names, the expected increment and the identical-duplicate policy.
  3. 3.Code emits fictional acceptance data covering clean chain, gap, regression, duplicate and conflict.
  4. 4.Code groups records per entity and classifies transitions, violations and missing states.
  5. 5.IF splits entities by the passed flag into success and failure branches.
  6. 6.Set on each branch adds decision and decision_message while keeping all fields.
  7. 7.Merge (append) combines both branches into one list.
  8. 8.A final runOnceForAllItems Code node returns one summary item; NoOp marks the endpoint.

Use cases

  • Verify per-entity document version numbering.
  • Audit order stages for skipped or reverted steps.
  • Detect two versions with the same state number but different content.
  • Acceptance test for workflows generating sequential counters.

Requirements

  • n8n 2.49.x core nodes only; no credentials needed.
  • Records with entity id, numeric-convertible state number and record id.
  • Field names and increment configured in the Set node.
  • Optional content_hash field to distinguish identical duplicates from conflicts.

Setup and testing in n8n

  1. Import the JSON into n8n and click Execute Workflow.
  2. Inspect Audit Result Endpoint: one item with total_entities=6, passed_entities=3, failed_entities=3.
  3. Confirm ENT-200 has a gap violation with missing_states=[2]; ENT-300 has gap and regression.
  4. Confirm ENT-400 logs a conflict at state 2 and a duplicate warning at state 1.
  5. Edge case: set identical_duplicate_policy to failure, ENT-600 then fails.
  6. Edge case: remove entity_id from one row to see the __INVALID_RECORDS__ report.
  7. For real data: replace the rows array with records of the same schema.

Service Value

Ready-made workflow template for automation delivery and service execution.

Apps Used

Manual Trigger Set Code If Merge No Op

Details

Trigger Manual trigger
Nodes 10
Apps 6
Views 14
Downloads 1

How to Use

  1. 1.Click "Download Template"
  2. 2.Open your n8n dashboard
  3. 3.Go to Workflows > Import from File
  4. 4.Select downloaded file and configure credentials

Nodes Used (10)

/

Run Audit Manually

Manual Trigger

#1

Configure Audit Policy

Set

#2

Generate Fictional Test Records

Code

#3

Sequence Audit Engine

Code

#4

Is Entity Clean

If

#5

Tag Clean Entity Report

Set

#6

Tag Defective Entity Report

Set

#7

Merge Both Report Branches

Merge

#8

Build Final Summary Report

Code

#9

Audit Result Endpoint

No Op

#10

Stage 1 - Setup and Input

Sticky Note

#11

Stage 2 - Audit Rules

Sticky Note

#12

Stage 3 - Routing and Merge

Sticky Note

#13

Stage 4 - Final Report

Sticky Note

#14
Stay in the loop

Fresh workflows, straight to your inbox

Get newly published DROPIDEA workflows, a clear overview of what they do, and a link to explore them.

  • New workflows
  • Clear overviews
  • Setup guides

Be first to discover what is new

Your name, your email, and one confirmation.

Email confirmation · Unsubscribe anytime