D31 — An ops batch is one unit of work: all of it lands, or none of it does¶
- Status: Accepted
- Date: 2026-09-21
- Origin: slice 5 build
- Area: writes
Decision¶
kg write --ops <file> and write(op="ops") take a list of operations and apply
them in one transaction. If any op fails, nothing from the batch is written, and
the error names the op that stopped it by position and kind.
A caller that wants per-record resilience sends one batch per record. kg import
does exactly that: one bad row is reported and skipped, the rest continue.
core/ops.py is also the single write dispatcher: the CLI, the MCP write tool
and every importer go through apply_op, so the three cannot drift (D17).
Why¶
Rows are append-only. A half-applied batch could not be tidied up — only rejected row by row, by hand, after working out which rows belonged to it. Atomicity means a failure leaves nothing to clean up.
Putting resilience one level up rather than inside the batch keeps both properties: an import survives a bad row, and no record is ever half written.