# Write Gates & Versioned Change Control

Canonical URL: https://naditu.com/docs/write-gates
Section: 04 · ERP APIs · Replay

Writing directly into ERP tables with INSERT or UPDATE statements bypasses tax calculation, stock reservation, credit-limit checks and statutory e-invoice numbering. Naditu blocks all SQL mutations and routes every operational or ontology change through typed API gates and versioned approvals.

- **SQL mutations:** Permanently disabled (read-only DB credentials)
- **Write execution:** Official ERP APIs after named human approval
- **Ontology releases:** Versioned diffs with historical query replay & 1-step rollback

## Executing approved writes through official ERP business objects (#official-erp-apis)

Enterprise ERPs enforce thousands of invariants inside their application layer: lot/serial allocation, BOM backflushing, VAT/withholding rounding, GİB UBL-TR e-invoice sequences and SAP authorization objects. An AI agent issuing a direct SQL UPDATE corrupts ledger integrity in milliseconds.

In Naditu, database connections use strictly read-only accounts or replicas. When an assistant proposes a business action—such as creating a purchase order draft, updating a promised delivery date or releasing a block—Naditu validates the payload against the ontology schema, pauses for named human approval and executes the write exclusively through the vendor’s supported API.

| Target platform | Read path (zero-copy) | Governed write-gate API | Invariants preserved by API |
| --- | --- | --- | --- |
| SAP S/4HANA | CDS Views & HANA read replica | RAP OData V4 business objects & BAPI | SAP DCL authorizations, ATP check, FI/CO document posting |
| Logo Tiger 3 / Netsis | SQL Server read replica (period-routed) | Logo Objects REST / NetOpenX | Stock lot tracking, cari risk ceiling, e-Logo UBL-TR numbering |
| Nebim V3 / ERA | SQL Server read replica | Nebim V3 Integrator REST API | Color/size matrix allocation, store POS sync, tax rules |
| Microsoft Dynamics 365 | Read replica / Dataverse views | Dynamics OData V4 / Business Central API | Posting groups, dimension validation, approval workflows |

## Named approval workflow before touching the source system (#human-approval-lifecycle)

When an interactive assistant calls a write-gated action, Naditu never touches the ERP immediately. Instead, it computes a pre-flight diff against live read-replica state (confirming customer terms, item codes and open tolerances) and creates an approval ticket bound to the responsible role.

Only when the named approver (for example, Purchasing lead or Planning lead) signs off with their own SSO identity does Naditu invoke the ERP API and record both the requester and approver principals in the immutable audit log.

### Write-gate approval envelope · purchase order creation

```json
{
  "gate_id": "wg_20261204_8841",
  "status": "awaiting_named_approval",
  "requested_by": {
    "role": "purchasing.buyer",
    "via": "Claude MCP"
  },
  "required_approver_role": "purchasing.lead",
  "target_connector": "sap-s4hana-rap-odata-v4",
  "business_object": "API_PURCHASEORDER_2",
  "pre_flight_checks": {
    "vendor_active": true,
    "account_matched": "Mandel Tooling",
    "items_verified": 3,
    "sql_mutation_used": false
  }
}
```

## Versioned ontology changes with historical query simulation (#versions)

Changing a status-code definition, a table join or a masking rule alters every future AI answer across every connected assistant. Editing ontology definitions in place without review creates silent regressions.

Naditu treats ontology updates like production code releases: models or engineers may propose a Term, Link or Rule change, automated replay simulates the candidate version against historical questions to surface what stayed the same, what changed and what became withheld, a named domain owner approves it, and any live version can be rolled back in one step while preserving the full version ledger.

- **v15 (Waiting for approval · Link):** Link MES work orders (WO_HDR.LINREF) to ERP order lines (ORD_LIN.REF) — Proposed by: Naditu, from plant planning report · Named approver: Planning lead · Replay: 54 same answer, 6 answer changed, 0 now withheld. Six historical questions about late production orders now resolve end-to-end instead of returning incomplete lineage.
- **v14 (Live · Rule):** Restrict Item.unit_cost visibility to Purchasing and Finance roles — Proposed by: IT Security · Named approver: Finance lead · Replay: 51 same answer, 0 answer changed, 9 now withheld. Nine past answers requested by roles outside Purchasing and Finance now mask unit_cost before serialization.
- **v13 (Earlier version · Term):** Confirm ORD_HDR.STAT = 4 means "shipped, not yet invoiced" rather than "closed" — Proposed by: Naditu proposal, corrected by Sales · Named approver: Sales lead · Replay: 48 same answer, 12 answer changed, 0 now withheld. Twelve historical receivable and fulfilment answers that previously undercounted shipped unbilled orders were corrected.
