Knowledge that lasts / 13SI · L00P.AI

Batch import: a conflict does not undo earlier writes

An original trial shows the difference between rejecting a record and rolling back an entire batch.

2026-11-19 · 1.0 · PL / EN

01 / A final error does not describe the whole state

You submit a batch of documents. The first is new; the second has a known identifier but changed content. The importer reports a conflict. Does that mean nothing was saved? Reading the accepted records answers that question. An error message does not establish the commit boundary.

The corpus with a correction history distinguishes repeated data from a change. Here we ask a different acceptance question: does a rejected batch leave earlier writes behind? An original trial ran on 19 November 2026 in local SQLite 3.47.1, using fictional documents. It did not examine a production archive.

02 / Establish the identity rule first

The initial state contains DOC-A and DOC-B. Both have the text “The archive opens Friday.” but different manually assigned identifiers and speakers A and B. They remain two records. The trial does not recognise similar recordings or infer identity from identical words.

The same body and speaker under the same ID means an unchanged repeat. A different body or speaker under a known ID means a conflict. Repeating the entire valid batch twice preserved two records; after each pass the database was closed and reopened. Ordered record values were compared, rather than database-file bytes.

03 / One batch, two different outcomes

The batch adds DOC-C, then encounters a DOC-A conflict. Commit per record leaves A, B and C. One transaction with explicit ROLLBACK leaves A and B.
state: DOC-A, DOC-B
batch: new DOC-C; changed DOC-A -> CONFLICT

commit per record ----------> DOC-A, DOC-B, DOC-C
one transaction + ROLLBACK -> DOC-A, DOC-B

In the deliberately unsafe variant, each valid record was committed separately. DOC-C was saved before the changed body of DOC-A was detected. Rolling back the current transaction did not remove the previously committed DOC-C. After reopening, the database contained three records; the original DOC-A remained unchanged.

The second variant opened one transaction for the entire batch. After detecting the conflict, it executed an explicit ROLLBACK. The earlier DOC-C was visible within the open transaction, but after rollback and reopening only DOC-A and DOC-B remained. This is the result of an executed error path, not a promise about every importer.

04 / Aborting a statement is a separate mechanism

Our code detected the content conflict. A separate case forced a PRIMARY KEY constraint error: after adding DOC-C, an ordinary INSERT used the existing DOC-A ID. SQLite raised IntegrityError with the name SQLITE_CONSTRAINT_PRIMARYKEY. The transaction remained active and the earlier DOC-C remained in its working state. Only an explicit ROLLBACK removed that change too.

SQLite documentation describes this behaviour for the default ABORT algorithm: it backs out the current statement while preserving earlier statements in the active transaction. It should not be confused with the ROLLBACK algorithm, nor should an exception be assumed to roll back the entire batch. The trial used explicit transaction commands BEGIN, COMMIT and ROLLBACK; Python library settings can change how transactions begin.

05 / An import acceptance card

commit unit: entire batch
identical ID + body + speaker: unchanged
known ID + changed body/speaker: conflict
batch error: explicit ROLLBACK
check: close, reopen, compare records

The result covers 27 checks: initial writes, repeats, state after a conflict, a separate SQL error path, a changed speaker and integrity checks on four databases. These are checks within one small trial, not 27 independent experiments. The pre-execution expectations protocol, inputs, script, results and artifact hashes were preserved.

Before accepting your own importer, decide whether the business rule accepts an entire batch or valid records with a partial-result report. If you choose the latter, show exactly what was accepted and rejected. Our trial compares the consequences of both; it does not settle the right policy for every application.

06 / Evidence limits and the next step

Power was not cut, the process was not interrupted and concurrent writers were not run. Closing and reopening a database is not a hardware-failure resilience test. Search, exports and external services were not checked. If an importer updates them, they need separate checks; a transaction in one database does not automatically include them.

Codex produced the Polish and English text, fictional data, script and diagram, performing the agent editorial and checking functions. No second model independently reviewed the work. No third-party recordings or records were used. A change to the conflict rule, transaction boundary or exception handling triggers renewed acceptance. After your importer reports an error, does the reader know which records actually remain?