Per-Entity State Sequence Auditor with Gap, Regression, Duplicate and Conflict Detection
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.Manual Trigger starts the local run.
- 2.Set defines field names, the expected increment and the identical-duplicate policy.
- 3.Code emits fictional acceptance data covering clean chain, gap, regression, duplicate and conflict.
- 4.Code groups records per entity and classifies transitions, violations and missing states.
- 5.IF splits entities by the passed flag into success and failure branches.
- 6.Set on each branch adds decision and decision_message while keeping all fields.
- 7.Merge (append) combines both branches into one list.
- 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
- Import the JSON into n8n and click Execute Workflow.
- Inspect Audit Result Endpoint: one item with total_entities=6, passed_entities=3, failed_entities=3.
- Confirm ENT-200 has a gap violation with missing_states=[2]; ENT-300 has gap and regression.
- Confirm ENT-400 logs a conflict at state 2 and a duplicate warning at state 1.
- Edge case: set identical_duplicate_policy to failure, ENT-600 then fails.
- Edge case: remove entity_id from one row to see the __INVALID_RECORDS__ report.
- 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
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (10)
Run Audit Manually
Manual Trigger
Configure Audit Policy
Set
Generate Fictional Test Records
Code
Sequence Audit Engine
Code
Is Entity Clean
If
Tag Clean Entity Report
Set
Tag Defective Entity Report
Set
Merge Both Report Branches
Merge
Build Final Summary Report
Code
Audit Result Endpoint
No Op
Stage 1 - Setup and Input
Sticky Note
Stage 2 - Audit Rules
Sticky Note
Stage 3 - Routing and Merge
Sticky Note
Stage 4 - Final Report
Sticky Note
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