Frappe/ERPNext is the perfect meta framework for agentic harness

Hi, my background is in applied machine learning and harness engineering that recently have gotten involved with ERPNext agentic data migration project and I just want to make the case that ERPNext is perfect for agent native workflows from a technical perspective and here is why:

  1. Total uniformed inspection - one pattern, every entity. You can get every DocType via GET /api/routes/DocType/<name>, this returns the complete schema for every doctype. Agents just need to use this endpoint to “discover“ the data model of any custom ERPNext system. There are no no special cases like Customers vs Items. The schema itself is data.
  2. The schema is writable as data — the agent can extend the target. createfield = insert a Custom Field row → Frappe ALTER TABLEs → the field is live and visible in metadata. What this means is that, if you have an Excel data sheet with new columns, the agent can introspect the schema and create the new rows and links using it’s own judgement. We tested on data migration POC agent harness and it works surprisingly well.
  3. Uniform CRUD + a tiny generic tool set. /api/resource/<doctype> is auto-generated for every doctype, so 9 generic tools (describe, get, list, create, update, set-mapping, import, …) cover the entire domain. An agent harness doesn’t need 50 hand-written tools; it needs a handful of shape-generic ones.
  4. Structured, machine-actionable failures. Because validation is app-layer (zero FKs), failures come back as typed exceptions — LinkValidationError, LinkExistsError, MandatoryError — with the offending field name in the message. The agent can read “Could not find Item Group: Machinery” and know exactly what to do: create that Item Group. Agent conflict engine is literally a structured projection of these same signals.
  5. Relationships are declarative, so they’re plan-able. Link/Dynamic Link/Table/fetch_from are all visible in metadata. An agent can: build a dependency graph (masters → transactions), dedup by the name/autoname field, and know “this field is read-only because it’s fetched from that linked doc.”
  6. Auditability is built in. Every document carries creation/modified_by/docstatus/versions, plus the write-on-submit ledgers. An agent’s actions are inherently traceable — which can pairs with a JSONL run transcripts to give a full “what did the model do and what did the system accept” trail. This also gives the ability roll back any data schema in an agentic workflow.

However there are some challenges that agent builders need to work around:

  • Business logic is not 100% declarative - validate()/on_submit() live in Python controllers, not tabDocField. A Sales Order’s pricing, tax, and stock side-effects on submit are invisible to schema introspection. So “read the metadata” gives the agent the data contract, not the behavior contract.
  • Errors are stringly/HTML-ish, you have to manually parse some errors to get the structured data to feed the agents context.
  • Multi-step flows are orchestration, not one call. to create major schema changes, it involves orchestrating multiple API requests using tool use. There is not a single batch API which we can create columns A, B, C, and records X, and Y and link them to F, and G.
  • Naming semantics are subtle. name vs the autoname field vs naming-series, case-insensitivity, and fetch_from overwriting writes.
  • The REST surface is thin. CRUD is uniform, but batch/bulk and complex ops (submit, amend) have their own semantics — hence our Data Import path for volume.

In short: ERPNext/Frappe is unusually agent-friendly because it exposes schema-as-data and uniform CRUD — but the agent still needs a translation layer that turns “metadata + typed exceptions” into “conflicts + actions,” which is exactly what I have been building as a layer on top of ERPNext with ERPGen open-source agentic data migration tool.

Is anyone else exploring agentic workflows with, would love to chat about your experiences, discoveries, and challenges.

so i’ve been working on an agentic data migration harness that combines deterministic code and llm judgement to auto migrate csv files such as this example here. the tool can work with any master or transaction data:

Customer Name,Customer Type,Group,Territory,Contact Name,Email,Phone,Address Type,Address Line 1,City,State,Postal Code,Country,Tax ID,Website,Loyalty Tier,Customer Since
Acme Steel Works,Company,Commercial,All Territories,Alicia Henderson,[email protected],+1 555 2100,Billing,100 Foundry Way,Cleveland,Ohio,44101,United States,US-11-22-3333,https://acmesteel.example,Gold,2015-03-12
Acme Steel Works,Company,Commercial,All Territories,Alicia Henderson,[email protected],+1 555 2100,Shipping,200 Dockside Ave,Cleveland,Ohio,44102,United States,,,,
Maple Grove Organics,Individual,Commercial,United States,Carla Ng,[email protected],,Billing,7 Orchard Ln,Sacramento,California,95814,United States,,https://maplegrove.example,Silver,2018-07-01
Ironclad Fasteners Co,Company,Commercial,All Territories,Ravi Patel,[email protected],+1 555 4100,Billing,55 Rivet Rd,Akron,Ohio,44306,United States,US-44-55-6666,,Bronze,
Prairie Wind Machinery,Company,Commercial,All Territories,Sam Reyes,[email protected],+1 555 4102,Office,12 Plains Hwy,Omaha,Nebraska,68102,United States,,,,2020-01-15
Falcon Ridge Plastics,Company,Commercial,All Territories,Gina Alvarez,[email protected],+1 555 4105,Billing,300 Polymer Pkwy,Detroit,Michigan,48201,United States,,,,
Blackwater Steel Supply,Company,Commercial,United States,Dana Whitfield,[email protected],+1 555 4101,Billing,88 Ingot Ln,Pittsburgh,Pennsylvania,15201,United States,,,,
Copperline Electric,Company,Commercial,Rest Of The World,Oliver Chen,[email protected],+44 20 555 4103,Billing,14 Copper Row,Manchester,,M1 2AB,United Kingdom,,,,
Sterling Oak Furniture,Company,Commercial,United States,Margaret Doyle,[email protected],+1 555 4104,Office,9 Cabinet St,Portland,Oregon,97205,United States,,,,
Granite Peak Mining Supply,Company,Commercial,All Territories,Hector Ruiz,[email protected],+1 555 4106,Billing,220 Quarry Rd,Butte,Montana,59701,United States,,,,
Harborview Marine Parts,Company,Commercial,United States,Nina Petrov,[email protected],+1 555 4107,Shipping,77 Pier Ave,Seattle,Washington,98107,United States,,,,
Juniper Textile Mills,Company,Commercial,All Territories,Aisha Khan,[email protected],+1 555 4108,Billing,31 Loom Way,Greensboro,North Carolina,27406,United States,,,,
Keystone Conveyor Co,Company,Commercial,All Territories,Walter Briggs,[email protected],+1 555 4109,Billing,600 Beltline Dr,Allentown,Pennsylvania,18103,United States,,,,
Lakeshore Beverage Group,Company,Commercial,United States,Priya Shah,[email protected],+1 555 4110,Billing,410 Soda Rd,Milwaukee,Wisconsin,53202,United States,,,,
Monarch Gear Works,Company,Government,All Territories,Raymond Holt,[email protected],+1 555 4111,Billing,900 Arsenal Way,Huntsville,Alabama,35805,United States,,,,
Northgate Industrial Supply,Company,Commercial,All Territories,Sofia Marino,[email protected],+1 555 4112,Billing,45 Fastener Blvd,Columbus,Ohio,43215,United States,,,,
Orchard Valley Foods,Company,Commercial,United States,Ethan Brooks,[email protected],+1 555 4113,Billing,120 Harvest Ln,Fresno,California,93720,United States,,,,
Polaris Hydraulics,Company,Commercial,All Territories,Iris Novak,[email protected],+1 555 4114,Billing,900 Pressure Ave,Minneapolis,Minnesota,55413,United States,,,,
Quicksilver Tooling,Company,Commercial,Rest Of The World,Jonas Weber,[email protected],+49 30 555 4115,Billing,5 Schneide Weg,Stuttgart,,70173,Germany,,,,
Redstone Fabrication,Company,Commercial,United States,Marco Silva,[email protected],+1 555 4116,Billing,300 Weld Rd,Houston,Texas,77020,United States,,,,
Sierra Filtration Systems,Company,Government,All Territories,Lena Okafor,[email protected],+1 555 4117,Billing,44 Filter Pkwy,Reno,Nevada,89501,United States,,,,
Timberline Pallet Works,Company,Commercial,All Territories,Owen Dale,[email protected],+1 555 4118,Billing,78 Timber Rd,Eugene,Oregon,97401,United States,,,,
Upstream Robotics,Individual,Commercial,United States,Casey Lin,[email protected],,Office,5 Automation Ct,Austin,Texas,78701,United States,,,,
Summit Forge Co,Company,Commercial,All Territories,Maria Flores,[email protected],+1 555 3100,Shipping,33 Forge Rd,Cleveland,Ohio,44114,United States,,,,
Cascade Auto Parts,Company,Commercial,All Territories,Tom Nguyen,[email protected],+1 555 3102,Billing,900 Motor Ave,Detroit,Michigan,48226,United States,,,,
Ironclad Fasteners Co,Company,Commercial,All Territories,Ravi Patel,[email protected],,Office,55 Rivet Rd,Akron,Ohio,44306,United States,,,,
Falcon Ridge Plastics,Company,Commercial,All Territories,Mark Alvarez,[email protected],+1 555 4200,Billing,300 Polymer Pkwy,Detroit,Michigan,48201,United States,,,,
Granite Bay Landscaping,Company,Commercial,United States,Colin Foster,,+1 555 4201,Billing,88 Garden Grove Rd,Roseville,California,95678,United States,,,,
,Company,Commercial,All Territories,Edge Contact,[email protected],+1 555 0001,Billing,1 Edge St,Edgeville,EdgeState,00000,EdgeCountry,,,,
Hollow Core Drilling,Company,Commercial,All Territories,Edge Driller,[email protected],+1 555 0002,Billing,,,,,,,,,

zshanhui@macbook data-migration % .venv/bin/python scripts/agent.py --source samples/customers-smb.csv                    
Starting agent for customers_full — 4 conflicts
  [error  ] unmapped_column        Tax ID
  [error  ] unmapped_column        Website
  [error  ] unmapped_column        Loyalty Tier
  [error  ] unmapped_column        Customer Since

=== Round 1/20 — 4 error conflict(s), 4 total ===
    [error] unmapped_column: Tax ID
    [error] unmapped_column: Website
    [error] unmapped_column: Loyalty Tier
    [error] unmapped_column: Customer Since
--- Round 1: 0 error(s) remain

=== AGENT CONVERGED (no error-severity conflicts) ===

All conflicts resolved and data imported successfully. Here's the summary:

## Migration Summary

**Source:** `samples/customers-smb.csv` → doctype `customers_full` (Customer + Contact + Address flat sheet, 30 rows)

### Conflicts resolved (4 error-severity)
| Column | Resolution | Action |
|---|---|---|
| Tax ID | extend_contract | `set_mapping → customer.tax_id` |
| Website | extend_contract | `set_mapping → customer.website` |
| Loyalty Tier | extend_contract | `set_mapping → customer.loyalty_program_tier` |
| Customer Since | create_custom_field | `create_field('Customer', 'Customer Since', 'Date')` → fieldname `customer_since`, then `set_mapping → customer.customer_since` |

> Note: the initial parallel `set_mapping` batch suffered a concurrent-write clobber that dropped the Tax ID override; I re-issued it sequentially and confirmed via `run_map` that **all 17 columns were mapped with zero conflicts and zero extra columns** before importing.

### Import (apply=True)
- **Customer:** 26 created, 3 skipped, 1 failed
- **Contact:** 26 created, 2 skipped
- **Address:** 27 created, 1 skipped, 1 failed

The two data warnings are source-data issues, not mapping problems: one row lacked a Customer Name (skipped), and one address row (Hollow Core Drilling) lacked required `address_line1`/`city` and was rejected with HTTP 417 — imports remain idempotent so these can be retried once source data is corrected.

### Verification
Spot-checked **Acme Steel Works** — all four extended columns landed correctly:
- `customer_since` = 2015-03-12 (new custom field)
- `tax_id` = US-11-22-3333
- `website` = https://acmesteel.example
- `loyalty_program_tier` = Gold

26 customers, 26 contacts, and 27 addresses now exist in the system.

Agent transcript (thinking + tool calls + responses): /Users/zshanhui/oss/nyauto/erpgen/data-migration/logs/agent-customers_full-20260909-174623647281.jsonl

deterministic code creates an analysis json file which is feed into an LLM agent loop, that fixes the conflicts that was surfaced until everything is cleaned and it converges:

{
  "schema_version": 1,
  "generated_at": "2026-09-09T17:24:08+00:00",
  "doctype": "customers_full",
  "source": "samples/customers-smb.csv",
  "source_rows": 30,
  "base_url": "http://localhost:8082",
  "known_mappings": [
    {
      "header": "Customer Name",
      "doctype": "customer",
      "target": "customer_name",
      "method": "flat_contract"
    },
    {
      "header": "Customer Type",
      "doctype": "customer",
      "target": "customer_type",
      "method": "flat_contract"
    },
    {
      "header": "Group",
      "doctype": "customer",
      "target": "customer_group",
      "method": "flat_contract"
    },
    {
      "header": "Territory",
      "doctype": "customer",
      "target": "territory",
      "method": "flat_contract"
    },
    {
      "header": "Contact Name",
      "doctype": "contact",
      "target": "contact_name",
      "method": "flat_contract"
    },
    {
      "header": "Email",
      "doctype": "contact",
      "target": "email",
      "method": "flat_contract"
    },
    {
      "header": "Phone",
      "doctype": "contact",
      "target": "phone",
      "method": "flat_contract"
    },
    {
      "header": "Address Type",
      "doctype": "address",
      "target": "address_type",
      "method": "flat_contract"
    },
    {
      "header": "Address Line 1",
      "doctype": "address",
      "target": "address_line1",
      "method": "flat_contract"
    },
    {
      "header": "City",
      "doctype": "address",
      "target": "city",
      "method": "flat_contract"
    },
    {
      "header": "State",
      "doctype": "address",
      "target": "state",
      "method": "flat_contract"
    },
    {
      "header": "Postal Code",
      "doctype": "address",
      "target": "pincode",
      "method": "flat_contract"
    },
    {
      "header": "Country",
      "doctype": "address",
      "target": "country",
      "method": "flat_contract"
    }
  ],
  "extra_columns": [
    {
      "header": "Tax ID",
      "non_empty": 0.067,
      "sample": [
        "US-11-22-3333",
        "US-44-55-6666"
      ],
      "inferred_type": "text",
      "best_match": {
        "doctype": "Customer",
        "target": "tax_id",
        "label": "Tax ID",
        "score": 1.0,
        "method": "exact"
      },
      "resolution": "extend_contract"
    },
    {
      "header": "Website",
      "non_empty": 0.067,
      "sample": [
        "https://acmesteel.example",
        "https://maplegrove.example"
      ],
      "inferred_type": "text",
      "best_match": {
        "doctype": "Customer",
        "target": "website",
        "label": "Website",
        "score": 1.0,
        "method": "exact"
      },
      "resolution": "extend_contract"
    },
    {
      "header": "Loyalty Tier",
      "non_empty": 0.1,
      "sample": [
        "Gold",
        "Silver",
        "Bronze"
      ],
      "inferred_type": "text",
      "best_match": {
        "doctype": "Customer",
        "target": "loyalty_program_tier",
        "label": "Loyalty Program Tier",
        "score": 0.85,
        "method": "token"
      },
      "resolution": "extend_contract"
    },
    {
      "header": "Customer Since",
      "non_empty": 0.1,
      "sample": [
        "2015-03-12",
        "2018-07-01",
        "2020-01-15"
      ],
      "inferred_type": "date",
      "best_match": null,
      "resolution": "create_custom_field",
      "suggested_doctype": "Customer"
    }
  ],
  "column_profiles": [
    {
      "header": "Customer Name",
      "non_empty": 0.967,
      "unique": 0.897,
      "sample": [
        "Acme Steel Works",
        "Maple Grove Organics",
        "Ironclad Fasteners Co",
        "Prairie Wind Machinery",
        "Falcon Ridge Plastics"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Customer Type",
      "non_empty": 1.0,
      "unique": 0.067,
      "sample": [
        "Company",
        "Individual"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Group",
      "non_empty": 1.0,
      "unique": 0.067,
      "sample": [
        "Commercial",
        "Government"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Territory",
      "non_empty": 1.0,
      "unique": 0.1,
      "sample": [
        "All Territories",
        "United States",
        "Rest Of The World"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Contact Name",
      "non_empty": 1.0,
      "unique": 0.933,
      "sample": [
        "Alicia Henderson",
        "Carla Ng",
        "Ravi Patel",
        "Sam Reyes",
        "Gina Alvarez"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Email",
      "non_empty": 0.967,
      "unique": 0.931,
      "sample": [
        "[email protected]",
        "[email protected]",
        "[email protected]",
        "[email protected]",
        "[email protected]"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Phone",
      "non_empty": 0.9,
      "unique": 0.963,
      "sample": [
        "+1 555 2100",
        "+1 555 4100",
        "+1 555 4102",
        "+1 555 4105",
        "+1 555 4101"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Address Type",
      "non_empty": 1.0,
      "unique": 0.1,
      "sample": [
        "Billing",
        "Shipping",
        "Office"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Address Line 1",
      "non_empty": 0.967,
      "unique": 0.931,
      "sample": [
        "100 Foundry Way",
        "200 Dockside Ave",
        "7 Orchard Ln",
        "55 Rivet Rd",
        "12 Plains Hwy"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "City",
      "non_empty": 0.967,
      "unique": 0.828,
      "sample": [
        "Cleveland",
        "Sacramento",
        "Akron",
        "Omaha",
        "Detroit"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "State",
      "non_empty": 0.9,
      "unique": 0.556,
      "sample": [
        "Ohio",
        "California",
        "Nebraska",
        "Michigan",
        "Pennsylvania"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Postal Code",
      "non_empty": 0.967,
      "unique": 0.931,
      "sample": [
        "44101",
        "44102",
        "95814",
        "44306",
        "68102"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Country",
      "non_empty": 0.967,
      "unique": 0.138,
      "sample": [
        "United States",
        "United Kingdom",
        "Germany",
        "EdgeCountry"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Tax ID",
      "non_empty": 0.067,
      "unique": 1.0,
      "sample": [
        "US-11-22-3333",
        "US-44-55-6666"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Website",
      "non_empty": 0.067,
      "unique": 1.0,
      "sample": [
        "https://acmesteel.example",
        "https://maplegrove.example"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Loyalty Tier",
      "non_empty": 0.1,
      "unique": 1.0,
      "sample": [
        "Gold",
        "Silver",
        "Bronze"
      ],
      "inferred_type": "text",
      "messy": []
    },
    {
      "header": "Customer Since",
      "non_empty": 0.1,
      "unique": 1.0,
      "sample": [
        "2015-03-12",
        "2018-07-01",
        "2020-01-15"
      ],
      "inferred_type": "date",
      "messy": []
    }
  ],
  "conflicts": [
    {
      "kind": "unmapped_column",
      "severity": "info",
      "source": "Tax ID",
      "target": "tax_id",
      "doctype": "Customer",
      "detail": "Column 'Tax ID' is not in the flat contract but matches Customer.tax_id (exact, score 1.00).",
      "suggested_action": "add 'Tax ID' -> Customer.tax_id to the customers_full contract so the values import."
    },
    {
      "kind": "unmapped_column",
      "severity": "info",
      "source": "Website",
      "target": "website",
      "doctype": "Customer",
      "detail": "Column 'Website' is not in the flat contract but matches Customer.website (exact, score 1.00).",
      "suggested_action": "add 'Website' -> Customer.website to the customers_full contract so the values import."
    },
    {
      "kind": "unmapped_column",
      "severity": "info",
      "source": "Loyalty Tier",
      "target": "loyalty_program_tier",
      "doctype": "Customer",
      "detail": "Column 'Loyalty Tier' is not in the flat contract but matches Customer.loyalty_program_tier (token, score 0.85).",
      "suggested_action": "add 'Loyalty Tier' -> Customer.loyalty_program_tier to the customers_full contract so the values import."
    },
    {
      "kind": "unmapped_column",
      "severity": "info",
      "source": "Customer Since",
      "detail": "Column 'Customer Since' has no matching field in Customer/Contact/Address.",
      "suggested_action": "create a custom field on Customer (see suggested_custom_fields)."
    }
  ],
  "suggested_custom_fields": [
    {
      "source": "Customer Since",
      "doctype": "Customer",
      "fieldname": "customer_since",
      "label": "Customer Since",
      "fieldtype": "Date",
      "reason": "unmapped non-empty source column (flat customers_full)",
      "create_command": "python3 erpgen.py createfield Customer --label 'Customer Since' --fieldtype Date"
    }
  ],
  "agent_instructions": "You are the migration-fix agent for a flat customers_full sheet (Customer + Contact + Address in one file). The columns below are NOT in the fixed mapping contract and are dropped at import. Resolve each:\n- resolution=extend_contract -> add the header->field mapping to the customers_full contract so the values import into the matched field.\n- resolution=create_custom_field -> run the suggested create_command, then extend the contract to map the column to the new field.\nDo not import until every unmapped column is resolved."
}

it’s still wip, but i think the concept is pretty neat and could be useful in real world data migration projects from csv/excel/other erps?

Hi there,

This framework-focus is a direction that Frappe/ERPNext has been headed for several years now, and the benefits are really paying off with the rise of agentic tools.

Regarding the limitations you describe, I think these are inherent to the problem space. It’s true that the business logic is not 100% declarative, but how could it be? Event hooks trigger python code, which allows arbitrary, domain-specific complexity. No declarative interface could ever cover that.

true, a declarative interface can not cover all the business logic in the code. i think the solution for this is to expose the entire ERPNext codebase as data to the agent through an RAG search tool. and have the code auto indexed as new PRs are made to the upstream.

just an update of the data migration agent i am working on here: GitHub - zshanhui/erpgen-data-migration-agent: Deterministic data migration agent for ERPNext · GitHub

i have implemented a append-only journal for all changes so every change is 100% reversible. every record add, schema change, link creation is auditable and can be reverse by an AI agent. some ideas are borrowed from the DSH Cordis spatial-temporal plugins paper.

half of master doctypes are supported now including Customers, Contacts, Addresses, Items, Suppliers, and Sales Order from CSV/Excel files. now working on supporting Employees, Assets, and the rest of master data records.

erpgen can now handle SMBs who have flat sheets that include customers, contacts, and address columns on one worksheet, same for suppliers. it will split up the columns deterministically into the proper ERPNext DocTypes with the correct links between the records.

the tool will only use llm agent if there are mapping conflicts that can not be fixed with deterministic python code. currently working on a way for the user to steer the agent judgement for difficult cases.

agent tool use and remote calls will now stream to terminal stdout instead of failing silently. Deepseek has been added to reduce cost vs OpenAI.

the next step is to implement specialised mapping logic for the rest of the master and transaction data. and to implement an interface for a generic DataSource so that any ERP export can be used as the data source to the migration agent, not just CSV and Excel.

Can confirm, agents work very efficiently even on custom apps (not just ERPNext); it feels like Frappe is their natural language, despite not being the most popular development framework.

Want the next level? Meet https://www.frameworkm.dev/

So agentic-friendly that it might be worth migrating brownfield projects if they are not on Frappe

so today, i’m working on data quality check for erpgen.

data quality has been called out as one of the main area that make ERP data migration tedious, error prone, and labour intensive. and it is often the source of in-accurate reporting downstream from the initial migration.

data quality issues include duplicated data, missing values, and outdated values. duplicated values and missing values can be programmatically handled, flagged and surfaced to the user doing the data importation work.

missing values for required fields are easily identified and flagged so the end user can correct them using an intermediate worksheet. duplicated values are more nuance because it might not be an exact string, for e.g. “Acme Steel Corp” vs “Acme Steel” vs “Amce Steel”. there might be slight variations in the spelling or drop of suffixes like LLC, Corp. these slight variations can be solved using some type of Levenstein distance algorithm and a word bank.

every row will be to be compared with every other row, so the 0(N) is quadratic. for 5000 rows, it shouldn’t be too much of an issue, and optimisations can be made later to speed things up.

so the quality check engine will need to surface all of these cases so either a human or llm agent can make the correction. this requires a intermediate WorkSheet schema such as this

{
  "worksheet_version": 1,
  "source": {
    "path": "samples/customers_smb.csv",
    "sha256": "9f2c8a6d4e1b7f30c5a92d8e6b41f70a3c9d2e5f8b1a4c7d0e3f6a9b2c5d8e1f",
    "rows": 52,
    "doctype": "Customer",
    "key_column": "Customer Name",
    "key_source": "guessed"
  },
  "generated_at": "2026-09-14T10:22:31+00:00",
  "generator": { "tool": "erpgen.py", "k": 2, "max_pairs_rows": 2000 },
  "plan": {},
  "column_profiles": [],
  "conflicts": [
    {
      "kind": "duplicate_row",
      "severity": "error",
      "source": "Customer Name",
      "target": "customer_name",
      "detail": "2 rows share the key 'Acme Steel Works' with different values.",
      "suggested_action": "resolve the conflicting cell, or drop one row",
      "detected": {},
      "status": "open",
      "resolution": null,
      "history": [
        { "at": "2026-09-14T10:22:31+00:00", "event": "detected" }
      ]
    }
  ],
  "corrections": []
}

and shared set of verb action operations that can be performed on data quality errors

[
  { "action": "set_value", "at": { "row": 7 }, "column": "Customer Name",
    "value": "Harbourfront Supplies", "note": "blank name; taken from the PO" },

  { "action": "skip_row", "at": "Acme Steel Work",
    "reason": "stale row from the 2024 export" },

  { "action": "merge_rows", "keep": "Acme Steel Works", "drop": [{ "row": 52 }],
    "field_overrides": { "Phone": "+65 6221 4400" },
    "note": "row 52 is the same customer with a stale phone" },

  { "action": "dismiss_conflict", "conflict": "possible_duplicate_row:Customer Name",
    "reason": "two separate legal entities trading under the same name" },

  { "action": "change_key", "column": "Tax ID",
    "reason": "customer names are not unique across branches" },

  { "action": "set_value", "at": { "row": 44 }, "column": "Phone",
    "value": "+65 6777 1234", "revoked_at": "2026-09-14T11:02:00+00:00",
    "revoked_reason": "wrong row; the operator corrected the sheet instead" }
]

then humans or agents can make the required corrections in the intermediate worksheet without modifying the original data source csv/xml. the worksheet can be the json to a web ui for instance. or agents can act upon if the workflow is automated.

{
  "worksheet_version": 1,
  "source": {
    "path": "samples/customers_smb.csv",
    "sha256": "9f2c8a6d4e1b7f30c5a92d8e6b41f70a3c9d2e5f8b1a4c7d0e3f6a9b2c5d8e1f",
    "rows": 52,
    "doctype": "Customer",
    "key_column": "Customer Name",
    "key_source": "guessed"
  },
  "generated_at": "2026-09-14T10:40:02+00:00",
  "generator": { "tool": "erpgen.py", "k": 2, "max_pairs_rows": 2000 },
  "conflicts": [
    {
      "kind": "missing_value",
      "severity": "error",
      "source": "Customer Name",
      "target": "customer_name",
      "detail": "2 row(s) have no value in the key column.",
      "detected": { "roles": ["key", "required"], "rows": [7, 19], "count": 2 },
      "status": "corrected",
      "resolution": { "by": "correction", "ids": ["c1", "c2"] },
      "history": [
        { "at": "2026-09-14T10:22:31+00:00", "event": "detected" },
        { "at": "2026-09-14T10:35:10+00:00", "event": "corrected" }
      ]
    },
    {
      "kind": "duplicate_row",
      "severity": "error",
      "source": "Customer Name",
      "target": "customer_name",
      "detail": "2 rows share a key with differing values.",
      "detected": {
        "groups": [
          { "key_value": "acme steel works", "rows": [4, 52], "count": 2,
            "identical": false, "differing_fields": ["Phone"] }
        ]
      },
      "status": "corrected",
      "resolution": { "by": "correction", "ids": ["c3"] },
      "history": [
        { "at": "2026-09-14T10:22:31+00:00", "event": "detected" },
        { "at": "2026-09-14T10:36:44+00:00", "event": "corrected" }
      ]
    },
    {
      "kind": "possible_duplicate_row",
      "severity": "warning",
      "source": "Customer Name",
      "detail": "2 rows have similar keys.",
      "detected": {
        "pairs": [
          { "a": { "row": 4, "value": "Acme Steel Works" },
            "b": { "row": 31, "value": "Acme Steel Work" },
            "edit_distance": 1, "signals": ["key_fuzzy"], "shared_fields": [] }
        ]
      },
      "status": "waived",
      "resolution": { "by": "dismiss_conflict", "reason": "two legal entities" },
      "history": [
        { "at": "2026-09-14T10:22:31+00:00", "event": "detected" },
        { "at": "2026-09-14T10:38:20+00:00", "event": "waived" }
      ]
    }
  ],
  "corrections": [
    { "id": "c1", "created_at": "2026-09-14T10:35:02+00:00", "created_by": "human",
      "conflict": "missing_value:Customer Name:customer_name",
      "action": "set_value", "at": { "row": 7 }, "column": "Customer Name",
      "value": "Harbourfront Supplies", "note": "blank name; taken from the PO" },
    { "id": "c2", "created_at": "2026-09-14T10:35:08+00:00", "created_by": "human",
      "conflict": "missing_value:Customer Name:customer_name",
      "action": "set_value", "at": { "row": 19 }, "column": "Customer Name",
      "value": "Kestrel Engineering" },
    { "id": "c3", "created_at": "2026-09-14T10:36:44+00:00", "created_by": "human",
      "conflict": "duplicate_row:Customer Name:customer_name",
      "action": "merge_rows", "keep": "Acme Steel Works", "drop": [{ "row": 52 }],
      "key_column": "Customer Name",
      "field_overrides": { "Phone": "+65 6221 4400" },
      "note": "row 52 is the same customer with a stale phone" },
    { "id": "c4", "created_at": "2026-09-14T10:38:20+00:00", "created_by": "human",
      "conflict": "possible_duplicate_row:Customer Name",
      "action": "dismiss_conflict",
      "reason": "two legal entities trading under the same name" }
  ]
}

the goal is to eventually automate the most tedious and time consuming parts of ERPNext data migration from any prior system.

the data quality gate is one part of a multiple step work flow that includes DocType auto discovery, auto mappings, audit journal, and agentic conflict resolution, and finally the actual row by row data importation via the REST API with full reversibility and trace of every action.