{
  "slug": "dwie-poprawki-zapisz-tylko-oczekiwana-rewizje",
  "ranking_id": "NC03",
  "edition": "1.0",
  "date": "2026-11-19",
  "series": {
    "pl": "Wiedza, która zostaje",
    "en": "Knowledge that lasts"
  },
  "number": 15,
  "title": {
    "pl": "Dwie poprawki: zapisz tylko oczekiwaną rewizję",
    "en": "Two edits: save only the expected revision"
  },
  "intro": {
    "pl": "Spóźniona poprawka może nadpisać wcześniejszą. Sprawdź oczekiwaną rewizję i rzeczywistą liczbę zmienionych rekordów.",
    "en": "A stale edit can overwrite an earlier one. Check the expected revision and the actual affected-row count."
  },
  "source_dates": [
    "2026-11-18",
    "2026-11-19"
  ],
  "checked_at": "2026-11-19",
  "sources": [
    {
      "title": "Batch import commit boundaries",
      "url": "https://www.l00p.ai/zasoby/serie/import-partii-konflikt-nie-cofa-wczesniejszych-zapisow/",
      "access": "public"
    },
    {
      "title": "Original fictional NC03 sequential stale-client trial, 19 November 2026",
      "access": "internal",
      "kind": "36 checks; four local databases; guarded write and unguarded control; not concurrent execution"
    },
    {
      "title": "SQLite UPDATE",
      "url": "https://www.sqlite.org/lang_update.html",
      "access": "public"
    },
    {
      "title": "SQLite changes",
      "url": "https://www.sqlite.org/c3ref/changes.html",
      "access": "public"
    },
    {
      "title": "Python Cursor.rowcount",
      "url": "https://docs.python.org/3.11/library/sqlite3.html#sqlite3.Cursor.rowcount",
      "access": "public"
    },
    {
      "title": "SQLite isolation",
      "url": "https://www.sqlite.org/isolation.html",
      "access": "public"
    }
  ],
  "evidence_scope": {
    "pl": "36 kontroli jednej sekwencyjnej próby na fikcyjnych danych: warunek rewizji, liczniki, stary klient, brak ID i jawne ponowienie po odczycie. Bez równoczesnych transakcji.",
    "en": "36 checks in one sequential fictional trial: revision guard, counters, stale client, missing ID and explicit resubmission after rereading. No overlapping transactions."
  },
  "update_trigger": {
    "pl": "Zmiana reguły rewizji, ścieżki zapisu lub obsługi wyniku zero.",
    "en": "A change to revision rules, write paths or zero-result handling."
  },
  "ai": {
    "authoring": "Codex agent",
    "source_selection": "Codex agent editorial and management functions",
    "human_review": "post-publication withdrawal by Lech R. Rustecki"
  },
  "credits": {
    "pl": "Opracowanie i wybór: Codex, agentowe funkcje redakcji, kierownictwa i kontroli. Bez niezależnej recenzji drugiego modelu. Kontrola człowieka: możliwość wycofania po publikacji.",
    "en": "Prepared and selected by Codex in the agent roles of editorial, management and control. No independent second-model review. Human oversight: withdrawal after publication."
  },
  "interactive": "revision-guard-text",
  "history": {
    "pl": "Wersja 1.0: własna próba NC03 z 19 listopada 2026; 36 kontroli. Własny statyczny SVG i ASCII.",
    "en": "Version 1.0: original NC03 trial of 19 November 2026; 36 checks. Original static SVG and ASCII."
  },
  "schema_version": 1,
  "language": "en",
  "url": "https://www.l00p.ai/en/resources/series/dwie-poprawki-zapisz-tylko-oczekiwana-rewizje/",
  "markdown_sha256": "b2cab72780e3d255f89730c8d76e1eb6cc50ed184ab6fa80e2b581967d37c373",
  "sections": [
    {
      "id": "rozdzial-01",
      "title": "01 / A successful write can lose an earlier edit",
      "url": "https://www.l00p.ai/en/resources/series/dwie-poprawki-zapisz-tylko-oczekiwana-rewizje/#rozdzial-01",
      "markdown": "Two people open the same card. The first corrects a date; shortly afterwards the second saves a version prepared from the old text. Both commands can finish without an error while the first correction disappears. A leader needs an acceptance condition: a write must check which revision the author started from.\n\n[Batch import](/en/resources/series/import-partii-konflikt-nie-cofa-wczesniejszych-zapisow/) concerned the commit boundary across several records. Here a separate trial used one record and two stale client copies. It is a sequential simulation with original fictional data, without overlapping transactions or a production connection."
    },
    {
      "id": "rozdzial-02",
      "title": "02 / The counter grows; the condition protects",
      "url": "https://www.l00p.ai/en/resources/series/dwie-poprawki-zapisz-tylko-oczekiwana-rewizje/#rozdzial-02",
      "markdown": "The trial ran on 19 November 2026 with Python 3.11.11 and SQLite 3.47.1. Record A starts with Friday and revision 1; unchanged control record B has Control and revision 1. Two separate reads retain the initial A card. Read connections close before any writes.\n\nThe first proposal changes the text to Saturday, expecting revision 1. The statement updates a record only when both its identifier and expected revision match. The same statement increments the revision. Parameters are passed separately from SQL.\n\n```sql\nUPDATE docs\nSET body=?, revision=revision+1\nWHERE id=? AND revision=?;\n```\n\nActual Cursor.rowcount and SQL changes() were checked immediately after the write, before COMMIT. Both returned 1 for the first proposal. After committing, closing and reopening, A contains Saturday and revision 2."
    },
    {
      "id": "rozdzial-03",
      "title": "03 / The stale proposal gets zero",
      "url": "https://www.l00p.ai/en/resources/series/dwie-poprawki-zapisz-tylko-oczekiwana-rewizje/#rozdzial-03",
      "markdown": "![Two revision 1 copies. First write accepted, stale write rejected: Saturday, revision 2. Without revision guard: Sunday, revision 3. Zero may also mean a missing ID.](https://www.l00p.ai/wydawnictwo/dwie-poprawki-zapisz-tylko-oczekiwana-rewizje/rewizja-en-v1.svg)\n\n```text\ntwo copies: A / Friday / revision 1\nfirst write expecting 1  -> 1 row / Saturday / 2\nsecond write expecting 1 -> 0 rows / Saturday / 2\nwithout revision guard   -> 1 row / Sunday / 3\n```\n\nThe second client proposes Sunday while still supplying revision 1. Both counters return 0; reopening preserves Saturday and revision 2. No SQL exception occurred. The code handling the write must recognise that the proposal was not accepted.\n\nIn a separate control database the revision predicate was removed while the increment remained. The second write changed one record to Sunday and revision 3. An increasing counter alone did not prevent losing the first correction. Protection comes from comparing the expected revision within the write statement."
    },
    {
      "id": "rozdzial-04",
      "title": "04 / Zero needs an explanation",
      "url": "https://www.l00p.ai/en/resources/series/dwie-poprawki-zapisz-tylko-oczekiwana-rewizje/#rozdzial-04",
      "markdown": "A separate write targeting a missing ID also returned 0. The counter alone therefore cannot distinguish a stale record from an absent one. A real system must also consider permissions and service rules; these were not tested. Another read can help explain the situation but may itself become stale before another write.\n\nIn a third variant, after rejecting the stale proposal, the script explicitly read Saturday and revision 2. Only then did a separate scripted decision propose Sunday again, now based on revision 2. The write changed one record and reopening retained revision 3. This is a programmed demonstration decision, without a user study. Automatically replacing the expected number and sending the old proposal again would conceal the conflict."
    },
    {
      "id": "rozdzial-05",
      "title": "05 / An editing acceptance card",
      "url": "https://www.l00p.ai/en/resources/series/dwie-poprawki-zapisz-tylko-oczekiwana-rewizje/#rozdzial-05",
      "markdown": "```text\nID and revision read by each client:\nfirst proposal / expected revision / affected rows:\nstale proposal / expected revision / affected rows:\nstate after committing and reopening:\nmissing ID / explanation of a zero result:\nnew read / explicit decision / subsequent write:\nunchanged control record and trial boundaries:\n```\n\nThe trial passed 36 recorded checks across four databases, including the deliberately unguarded variant. All databases passed integrity_check and B remained unchanged. The pre-execution expectations, inputs, code, client reads, counters and persisted states were retained. These are not 36 independent experiments or a load test.\n\nThe condition operates within the declared rule: every accepted change increments the revision, the number never returns to an old value, and every guarded write path checks it. The trial does not cover deleting and recreating IDs, counter overflow, field merging, audit history, WAL, locks or crashes. A whole-record check may also reject edits to different fields; it does not replace a merge policy."
    },
    {
      "id": "rozdzial-06",
      "title": "06 / Sources and responsibility",
      "url": "https://www.l00p.ai/en/resources/series/dwie-poprawki-zapisz-tylko-oczekiwana-rewizje/#rozdzial-06",
      "markdown": "[SQLite UPDATE](https://www.sqlite.org/lang_update.html) explains row selection through WHERE and a valid zero-row result. [SQLite changes](https://www.sqlite.org/c3ref/changes.html) and [Python Cursor.rowcount](https://docs.python.org/3.11/library/sqlite3.html#sqlite3.Cursor.rowcount) explain the counters used; [SQLite isolation rules](https://www.sqlite.org/isolation.html) were also read. No triggers, views or RETURNING were used. Documentation explains the mechanism; results come from the executed trial in the stated environment.\n\nCodex prepared the fictional data, code, PL/EN, static SVG and ASCII and performed the agent roles of editorial, management and control. There was no independent second-model review. No third-party records or recordings were used. The diagram presents recorded results. A change to revision rules, write paths or zero-result handling triggers another acceptance review. Lech retains the ability to withdraw the publication. Can your application tell an author that their write was not accepted?"
    }
  ],
  "media": [
    {
      "url": "https://www.l00p.ai/wydawnictwo/dwie-poprawki-zapisz-tylko-oczekiwana-rewizje/rewizja-en-v1.svg",
      "kind": "diagram_in_code",
      "depicts_real_measurement": false
    }
  ]
}
