A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Apply conditional edits to notebook documents (#11263)
Trevor Manzfcab3fc570e9
diff --git a/marimo/_core/document.py b/marimo/_core/document.pyindex 8732dbfe62..e9952da3fb 100644--- a/marimo/_core/document.py+++ b/marimo/_core/document.py@@ -9,7 +9,10 @@ from copy import deepcopyfrom dataclasses import dataclass, fieldfrom typing import TYPE_CHECKING, Any, Literal+from msgspec import UNSET+from marimo._core import protocol+from marimo._core.errors import EditConflict, Invalidif TYPE_CHECKING:from collections.abc import Iterator, Mapping, Sequence@@ -125,10 +128,20 @@ class Changed:return bool(self.cells or self.removed or self.document)+@dataclass(frozen=True)+class Applied:+ """An edit's effects and the etags of the cells it touched."""++ changed: Changed+ cells: dict[str, protocol.CellEtags | None]+ """By id, for each cell the edit put, and `None` for each it deleted."""++class Document:"""A notebook document with content-derived revisions.- Cell source uses newline line endings.+ Cell source uses newline line endings. Edits change cells and their+ order. The app config comes from the store or the editor."""def __init__(@@ -249,6 +262,91 @@ class Document:self._app_config = dict(app_config)return Changed(changed, removed, self._refresh())+ def apply(self, changes: Sequence[protocol.Change]) -> Applied:+ """Apply `changes` in order as one unit, or none of them.++ Every precondition is compared with the document as it was when+ the request arrived, so one request can create a cell and then+ place it with the order etag the client read.++ Raises:+ EditConflict: If a precondition names a state the document no+ longer has. Nothing is applied.+ Invalid: If a change could not apply to any state.+ """+ staged: dict[str, CellSource] = {+ cell.id: CellSource(cell.id, cell.code, cell.name, cell.config)+ for cell in self+ }+ order = list(self._order)+ touched: dict[str, bool] = {}+ before = self._record++ def matches(base: str, cell_id: str) -> bool:+ if base == "*":+ return True+ current = self._cells.get(cell_id)+ return current is not None and base == current.etag++ def stale(index: int, cell_id: str | None) -> EditConflict:+ return EditConflict(+ f"change {index} names a state the document no longer has",+ change=index,+ cell=None if cell_id is None else self._cells.get(cell_id),+ document=before,+ )++ for index, change in enumerate(changes):+ if isinstance(change, protocol.PutCell):+ source = _source(change.cell)+ cell_id = source.id+ if change.base_etag is None:+ # A cell deleted earlier in the batch still existed+ # when the client read, so creating it is a conflict.+ if cell_id in self._cells or cell_id in staged:+ raise stale(index, cell_id)+ order.insert(_slot(order, change, index), cell_id)+ elif cell_id not in staged or not matches(+ change.base_etag, cell_id+ ):+ raise stale(index, cell_id)+ staged[cell_id] = source+ touched[cell_id] = True+ elif isinstance(change, protocol.DeleteCell):+ if change.id not in staged or not matches(+ change.base_etag, change.id+ ):+ raise stale(index, change.id)+ del staged[change.id]+ order.remove(change.id)+ touched[change.id] = False+ elif isinstance(change, protocol.SetOrder):+ if change.base_etag not in ("*", before.order_etag):+ raise stale(index, None)+ if sorted(change.order) != sorted(order) or len(+ set(change.order)+ ) != len(change.order):+ raise Invalid(+ f"change {index} must name every cell exactly once"+ )+ order = [*change.order]+ else:+ raise Invalid(f"change {index} has an unknown kind")++ changed = self.replace(+ [staged[cell_id] for cell_id in order], self._app_config+ )+ cells: dict[str, protocol.CellEtags | None] = {}+ for cell_id, put in touched.items():+ if put:+ cell = self._cells[cell_id]+ cells[cell_id] = protocol.CellEtags(+ etag=cell.etag, code_hash=cell.code_hash+ )+ else:+ cells[cell_id] = None+ return Applied(changed, cells)+def mark_saved(self, etag: protocol.Etag | None = None) -> protocol.Document | None:@@ -295,3 +393,39 @@ class Document:return Noneself._document = documentreturn document+++def _source(cell: protocol.CellInput) -> CellSource:+ name = "_" if cell.name is UNSET else cell.name+ config = cell.config+ if config is UNSET:+ return CellSource(cell.id, cell.code, name)+ return CellSource(+ cell.id,+ cell.code,+ name,+ protocol.CellConfig(+ column=None if config.column is UNSET else config.column,+ disabled=False if config.disabled is UNSET else config.disabled,+ hide_code=False if config.hide_code is UNSET else config.hide_code,+ expand_output=False+ if config.expand_output is UNSET+ else config.expand_output,+ ),+ )+++def _slot(order: list[str], change: protocol.PutCell, index: int) -> int:+ """Where a created cell goes: after or before an anchor, or at the end."""+ after = None if change.after is UNSET else change.after+ before = None if change.before is UNSET else change.before+ if after is not None and before is not None:+ raise Invalid(f"change {index} names both after and before")+ anchor = after if after is not None else before+ if anchor is None:+ return len(order)+ if anchor not in order:+ raise Invalid(+ f"change {index} places a cell by {anchor}, which does not exist"+ )+ return order.index(anchor) + (1 if after is not None else 0)diff --git a/marimo/_core/errors.py b/marimo/_core/errors.pyindex 19afd0b071..1c406d8062 100644--- a/marimo/_core/errors.py+++ b/marimo/_core/errors.py@@ -3,6 +3,11 @@from __future__ import annotations+from typing import TYPE_CHECKING++if TYPE_CHECKING:+ from marimo._core import protocol+class HostError(Exception):"""Base exception for host and notebook commands."""@@ -18,3 +23,28 @@ class Conflict(HostError):class NoRuntime(Conflict):"""The command requires a runtime, but the notebook has none."""+++class Invalid(HostError):+ """The request could not apply to any state."""+++class EditConflict(Conflict):+ """A change named a state the document no longer has.++ Carries the index of the first stale change, the cell it named as it+ now is, and the document as it now is.+ """++ def __init__(+ self,+ message: str,+ *,+ change: int,+ cell: protocol.Cell | None,+ document: protocol.Document,+ ) -> None:+ super().__init__(message)+ self.change = change+ self.cell = cell+ self.document = documentdiff --git a/marimo/_core/notebook.py b/marimo/_core/notebook.pyindex c458cddd61..f7fab4b3eb 100644--- a/marimo/_core/notebook.py+++ b/marimo/_core/notebook.py@@ -114,10 +114,24 @@ class Notebook:self._require_open()changed = self.document.replace(cells, app_config)self._publish_changed(changed, request_id)- if changed.document is not None:- self._request_analysis(request_id)return changed+ def edit(+ self, changes: Sequence[protocol.Change], *, request_id: str+ ) -> protocol.EditResponse:+ """Apply an edit as one unit and publish its effects.++ Raises:+ EditConflict: If a precondition is stale. Nothing is applied.+ Invalid: If a change could not apply to any state.+ """+ self._require_open()+ applied = self.document.apply(changes)+ self._publish_changed(applied.changed, request_id)+ return protocol.EditResponse(+ document=self.document._record, cells=applied.cells+ )+def mark_saved(self, *, request_id: str | None = None) -> None:"""Mark the current document revision as saved."""self._require_open()@@ -128,6 +142,7 @@ class Notebook:def _publish_changed(self, changed: Changed, request_id: str | None) -> None:+ """Publish a document change, then analyze the new revision."""with self.sink.deferred():for cell in changed.cells:self._publish(cell, request_id)@@ -138,6 +153,8 @@ class Notebook:self._remove("cell", cell_id, request_id)if changed.document is not None:self._publish(changed.document, request_id)+ if changed.document is not None:+ self._request_analysis(request_id)# ---- analysis ------------------------------------------------------diff --git a/marimo/_core/protocol.py b/marimo/_core/protocol.pyindex ee3378a6e9..7545f7c945 100644--- a/marimo/_core/protocol.py+++ b/marimo/_core/protocol.py@@ -509,20 +509,6 @@ class SaveRequest(Struct, frozen=True):) = UNSET-class SetAppConfig(- Struct, frozen=True, tag_field="kind", tag="set_app_config"-):- app_config: Annotated[- dict[str, Any], Meta(description="The new app config, whole.")- ]- base_etag: Annotated[- str,- Meta(- description="The document's `app_config_etag` as last read, or `*`."- ),- ]--class SetOrder(Struct, frozen=True, tag_field="kind", tag="set_order"):base_etag: Annotated[str,@@ -740,7 +726,7 @@ class CellMessage(Struct, frozen=True):Change: TypeAlias = Annotated[- PutCell | DeleteCell | SetOrder | SetAppConfig,+ PutCell | DeleteCell | SetOrder,Meta(description="One change to the document, tagged on `kind`."),]@@ -868,7 +854,7 @@ class Document(Struct, frozen=True):app_config: Annotated[dict[str, Any],Meta(- description="Notebook-level settings, the keyword arguments to `marimo.App` such as `width` and `title`."+ description="Notebook-level settings, the keyword arguments to `marimo.App` such as `width` and `app_title`. Informational for now; no change sets it over this protocol."),]app_config_etag: Annotated[@@ -942,7 +928,7 @@ class EditConflict(Struct, frozen=True):Annotated[Cell,Meta(- description="The cell the change named, as it now is. Null when the document does not have it, or when the change named the order or the app config."+ description="The cell the change named, as it now is. Null when the document does not have it, or when the change named the order."),]| Nonediff --git a/protocols/host/fixtures/edit-response.json b/protocols/host/fixtures/edit-response.jsonindex 5107900a64..6a35fcb5b9 100644--- a/protocols/host/fixtures/edit-response.json+++ b/protocols/host/fixtures/edit-response.json@@ -7,14 +7,13 @@"c3"],"app_config": {- "width": "full",- "app_title": "Forecasts"+ "width": "full"},"policy": "autorun",- "etag": "949c0dd20bc77042",+ "etag": "f01a47d5aa0cad55","saved_etag": "e59d9c2af02f5814","order_etag": "162e15055422ed71",- "app_config_etag": "1d79ec53fdad1a23"+ "app_config_etag": "283513048dfeb45b"},"cells": {"c2": {diff --git a/protocols/host/fixtures/edit.json b/protocols/host/fixtures/edit.jsonindex a7ae2965d6..3bcbc27a00 100644--- a/protocols/host/fixtures/edit.json+++ b/protocols/host/fixtures/edit.json@@ -35,14 +35,6 @@"kind": "delete_cell","id": "k7f2","base_etag": "f199b5f48ae0aabb"- },- {- "kind": "set_app_config",- "base_etag": "283513048dfeb45b",- "app_config": {- "width": "full",- "app_title": "Forecasts"- }}]}diff --git a/protocols/host/fixtures/edits.sse b/protocols/host/fixtures/edits.sseindex 7bd0343ec9..cdf28ea1e8 100644--- a/protocols/host/fixtures/edits.sse+++ b/protocols/host/fixtures/edits.sse@@ -12,9 +12,9 @@ data: {"id":"k7f2","request_id":"9b1c6d2e-0f3a-4b5c-8d7e-1f2a3b4c5d6e","time":"2id: 113event: document-data: {"document":{"notebook_id":"n1","order":["c1","c2","c3"],"app_config":{"width":"full","app_title":"Forecasts"},"policy":"autorun","etag":"949c0dd20bc77042","saved_etag":"e59d9c2af02f5814","order_etag":"162e15055422ed71","app_config_etag":"1d79ec53fdad1a23"},"request_id":"9b1c6d2e-0f3a-4b5c-8d7e-1f2a3b4c5d6e","time":"2026-10-01T09:21:00Z"}+data: {"document":{"notebook_id":"n1","order":["c1","c2","c3"],"app_config":{"width":"full"},"policy":"autorun","etag":"f01a47d5aa0cad55","saved_etag":"e59d9c2af02f5814","order_etag":"162e15055422ed71","app_config_etag":"283513048dfeb45b"},"request_id":"9b1c6d2e-0f3a-4b5c-8d7e-1f2a3b4c5d6e","time":"2026-10-01T09:21:00Z"}id: 114event: document-data: {"document":{"notebook_id":"n1","order":["c1","c2","c3"],"app_config":{"width":"full","app_title":"Forecasts"},"policy":"autorun","etag":"949c0dd20bc77042","saved_etag":"949c0dd20bc77042","order_etag":"162e15055422ed71","app_config_etag":"1d79ec53fdad1a23"},"request_id":"save-9b1c6d2e","time":"2026-10-01T09:21:02Z"}+data: {"document":{"notebook_id":"n1","order":["c1","c2","c3"],"app_config":{"width":"full"},"policy":"autorun","etag":"f01a47d5aa0cad55","saved_etag":"f01a47d5aa0cad55","order_etag":"162e15055422ed71","app_config_etag":"283513048dfeb45b"},"request_id":"save-9b1c6d2e","time":"2026-10-01T09:21:02Z"}diff --git a/protocols/host/fixtures/problems/edit-conflict.json b/protocols/host/fixtures/problems/edit-conflict.jsonindex 6c9e3fffc0..411fbcabc9 100644--- a/protocols/host/fixtures/problems/edit-conflict.json+++ b/protocols/host/fixtures/problems/edit-conflict.json@@ -27,14 +27,13 @@"c3"],"app_config": {- "width": "full",- "app_title": "Forecasts"+ "width": "full"},"policy": "autorun",- "etag": "949c0dd20bc77042",+ "etag": "f01a47d5aa0cad55","saved_etag": "e59d9c2af02f5814","order_etag": "162e15055422ed71",- "app_config_etag": "1d79ec53fdad1a23"+ "app_config_etag": "283513048dfeb45b"}}}diff --git a/protocols/host/openapi.yaml b/protocols/host/openapi.yamlindex 4e99d0dd68..7ebb316d2f 100644--- a/protocols/host/openapi.yaml+++ b/protocols/host/openapi.yaml@@ -277,12 +277,12 @@ paths:had when the client read it, so two writers never silentlyoverwrite each other. Every etag is compared with the document asit was when the request arrived, so one request can create a cell- and then place it with the order etag the client read. Cells, the- order, and the app config each have their own etag, so writers- touching different parts never conflict. An etag of `*` skips the- check. A `put_cell` with a null etag creates the cell, after or- before an existing cell or at the end; placement has no- precondition, so two clients inserting at once both succeed.+ and then place it with the order etag the client read. Cells and+ the order each have their own etag, so writers touching different+ parts never conflict. An etag of `*` skips the check. A `put_cell`+ with a null etag creates the cell, after or before an existing cell+ or at the end; placement has no precondition, so two clients+ inserting at once both succeed.If any precondition is stale, nothing is applied and the hostanswers `conflict` with `edit` naming the first stale change and@@ -1403,7 +1403,7 @@ components:app_config:type: objectadditionalProperties: true- description: Notebook-level settings, the keyword arguments to `marimo.App` such as `width` and `title`.+ description: Notebook-level settings, the keyword arguments to `marimo.App` such as `width` and `app_title`. Informational for now; no change sets it over this protocol.policy:type: stringenum: [autorun, lazy]@@ -1752,35 +1752,18 @@ components:type: arrayitems: { $ref: '#/components/schemas/CellId' }description: Every cell id exactly once, in the new order, counting cells this edit creates and leaving out cells it deletes.- SetAppConfig:- type: object- description: Replaces the app config.- required: [kind, base_etag, app_config]- properties:- kind:- type: string- enum: [set_app_config]- base_etag:- type: string- description: The document's `app_config_etag` as last read, or `*`.- app_config:- type: object- additionalProperties: true- description: The new app config, whole.Change:description: One change to the document, tagged on `kind`.oneOf:- $ref: '#/components/schemas/PutCell'- $ref: '#/components/schemas/DeleteCell'- $ref: '#/components/schemas/SetOrder'- - $ref: '#/components/schemas/SetAppConfig'discriminator:propertyName: kindmapping:put_cell: '#/components/schemas/PutCell'delete_cell: '#/components/schemas/DeleteCell'set_order: '#/components/schemas/SetOrder'- set_app_config: '#/components/schemas/SetAppConfig'EditRequest:type: objectrequired: [changes]@@ -1818,7 +1801,7 @@ components:description: The index of the stale change in the request's `changes`, or of the stale cell in a run's `cells`. `0` for a save with a stale `If-Match`.cell:oneOf: [{ $ref: '#/components/schemas/Cell' }, { type: 'null' }]- description: The cell the change named, as it now is. Null when the document does not have it, or when the change named the order or the app config.+ description: The cell the change named, as it now is. Null when the document does not have it, or when the change named the order.document: { $ref: '#/components/schemas/Document' }SaveRequest:type: objectdiff --git a/tests/_core/test_notebook_document.py b/tests/_core/test_notebook_document.pyindex 56a283d097..700a020688 100644--- a/tests/_core/test_notebook_document.py+++ b/tests/_core/test_notebook_document.py@@ -20,6 +20,7 @@ from marimo._core.document import (order_etag,revision,)+from marimo._core.errors import EditConflict, Invalidfrom marimo._core.executions import Executionsfrom marimo._core.host import Hostfrom marimo._core.notebook import Notebook@@ -50,6 +51,34 @@ def fixture_cells() -> list[CellSource]:]+def put(+ cell_id: str,+ code: str,+ base_etag: str | None,+ *,+ after: str | None = None,+ before: str | None = None,+) -> protocol.PutCell:+ return protocol.PutCell(+ base_etag=base_etag,+ cell=protocol.CellInput(id=protocol.CellId(cell_id), code=code),+ after=UNSET if after is None else protocol.CellId(after),+ before=UNSET if before is None else protocol.CellId(before),+ )+++def delete(cell_id: str, base_etag: str) -> protocol.DeleteCell:+ return protocol.DeleteCell(+ id=protocol.CellId(cell_id), base_etag=base_etag+ )+++def set_order(base_etag: str, *cell_ids: str) -> protocol.SetOrder:+ return protocol.SetOrder(+ base_etag=base_etag, order=tuple(protocol.CellId(c) for c in cell_ids)+ )++class TestEtags:def test_reordering_cell_ids_with_newlines_changes_the_revision(self,@@ -185,6 +214,123 @@ class TestReplace:assert behind.saved_etag == saved.etag != behind.etag+class TestApply:+ def test_creates_replaces_deletes_and_reorders_as_one_unit(self) -> None:+ document = Document(NOTEBOOK, fixture_cells(), {"width": "full"})+ before = document._record+ c3 = document.cell("c3")+ k7f2 = document.cell("k7f2")+ assert c3 is not None+ assert k7f2 is not None++ applied = document.apply(+ [+ put("c2", "print('hi')", None, after="c1"),+ put("c3", "x = 22", c3.etag),+ delete("k7f2", k7f2.etag),+ set_order(before.order_etag, "c3", "c2", "c1"),+ ]+ )++ assert document.order == ["c3", "c2", "c1"]+ assert [c.id for c in applied.changed.cells] == ["c3", "c2"]+ assert applied.changed.removed == ["k7f2"]+ assert applied.changed.document is not None+ assert applied.changed.document.app_config == {"width": "full"}+ assert set(applied.cells) == {"c2", "c3", "k7f2"}+ assert applied.cells["k7f2"] is None+ new_c3 = document.cell("c3")+ assert new_c3 is not None+ assert applied.cells["c3"] == protocol.CellEtags(+ etag=new_c3.etag, code_hash=new_c3.code_hash+ )+ assert new_c3.etag != c3.etag++ def test_a_stale_etag_applies_nothing_and_names_the_change(self) -> None:+ document = Document(NOTEBOOK, fixture_cells(), {})+ before = document._record++ with pytest.raises(EditConflict) as raised:+ document.apply(+ [+ put("new", "z = 1", None),+ put("c3", "x = 22", "0000000000000000"),+ ]+ )++ assert raised.value.change == 1+ assert raised.value.cell == document.cell("c3")+ assert raised.value.document == before+ assert document._record == before+ assert document.cell("new") is None++ def test_creating_an_existing_cell_or_replacing_a_missing_one_conflicts(+ self,+ ) -> None:+ document = Document(NOTEBOOK, fixture_cells(), {})+ c3 = document.cell("c3")+ assert c3 is not None++ with pytest.raises(EditConflict) as raised:+ document.apply([put("c3", "x = 1", None)])+ assert raised.value.cell == c3++ with pytest.raises(EditConflict) as raised:+ document.apply([put("nope", "x = 1", "*")])+ assert raised.value.cell is None++ # The cell existed when the client read, even if the same batch+ # deletes it first.+ with pytest.raises(EditConflict) as raised:+ document.apply([delete("c3", c3.etag), put("c3", "x = 1", None)])+ assert raised.value.change == 1+ assert document.cell("c3") == c3++ def test_star_skips_the_check(self) -> None:+ document = Document(NOTEBOOK, fixture_cells(), {})++ document.apply(+ [put("c3", "x = 23", "*"), set_order("*", "k7f2", "c3", "c1")]+ )++ assert document.order == ["k7f2", "c3", "c1"]++ def test_placement_has_no_precondition(self) -> None:+ document = Document(NOTEBOOK, fixture_cells(), {})++ document.apply([put("a", "1", None, before="c1")])+ document.apply([put("b", "2", None, after="c1")])+ document.apply([put("c", "3", None)])++ assert document.order == ["a", "c1", "b", "c3", "k7f2", "c"]++ def test_malformed_changes_are_invalid(self) -> None:+ document = Document(NOTEBOOK, fixture_cells(), {})+ before = document._record++ with pytest.raises(Invalid):+ document.apply([set_order("*", "c1", "c3")])+ with pytest.raises(Invalid):+ document.apply([set_order("*", "c1", "c3", "c3")])+ with pytest.raises(Invalid):+ document.apply([put("a", "1", None, after="nope")])+ with pytest.raises(Invalid):+ document.apply([put("a", "1", None, after="c1", before="c3")])+ assert document._record == before++ def test_an_edit_that_changes_nothing_reports_nothing(self) -> None:+ document = Document(NOTEBOOK, fixture_cells(), {})+ c3 = document.cell("c3")+ assert c3 is not None++ applied = document.apply([put("c3", "x = 21", c3.etag)])++ assert not applied.changed+ assert applied.cells["c3"] == protocol.CellEtags(+ etag=c3.etag, code_hash=c3.code_hash+ )++class TestFromRecords:def test_preserves_the_saved_revision(self) -> None:source = Document(@@ -270,6 +416,27 @@ class TestNotebook:assert all(e.data.request_id == "edit-1" for e in log) # type: ignore[union-attr]assert log[1].data.id == "k7f2" # type: ignore[union-attr]+ def test_edit_publishes_as_one_unit_with_the_request_key(+ self, notebook: Notebook, log: list[Event]+ ) -> None:+ notebook.replace(fixture_cells(), {})+ log.clear()+ k7f2 = notebook.document.cell("k7f2")+ assert k7f2 is not None++ response = notebook.edit(+ [+ put("c2", "print('hi')", None, after="c1"),+ delete("k7f2", k7f2.etag),+ ],+ request_id="edit-1",+ )++ assert names(log) == ["cell", "cell.removed", "document"]+ assert request_ids(log) == ["edit-1"] * 3+ assert response.document == log[-1].data.document # type: ignore[union-attr]+ assert set(response.cells) == {"c2", "k7f2"}+def cell_analyses(document: Document,@@ -358,6 +525,34 @@ class TestAnalysis:assert notebook.analysis is not Noneassert notebook.analysis.document_etag == latest.document.etag+ async def test_an_edit_is_analyzed_under_its_request_key(+ self, host: Host, log: list[Event]+ ) -> None:+ host.update_project(project())+ analyzer = ScriptedAnalyzer()+ document = Document(NOTEBOOK, fixture_cells(), {})+ notebook = await add_notebook(+ host,+ record(),+ ScriptedBackend(),+ document=document,+ analyzer=analyzer,+ )+ _, result = await analyzer.next_request()+ result.set_result(cell_analyses(document))+ await asyncio.sleep(0)++ log.clear()+ notebook.edit([put("c9", "z = 1", None)], request_id="edit-1")+ snapshot, result = await analyzer.next_request()+ assert snapshot == document.snapshot()+ assert [c.id for c in snapshot.cells] == ["c1", "c3", "k7f2", "c9"]++ result.set_result(cell_analyses(document))+ await asyncio.sleep(0)+ assert names(log) == ["cell", "document", "analysis"]+ assert request_ids(log) == ["edit-1"] * 3+async def test_the_previous_analysis_stays_until_the_next_arrives(self, host: Host) -> None:diff --git a/tests/_core/test_protocol.py b/tests/_core/test_protocol.pyindex c8fff3ce95..b22cbab539 100644--- a/tests/_core/test_protocol.py+++ b/tests/_core/test_protocol.py@@ -493,14 +493,12 @@ def test_edit_request_response_and_events() -> None:touched[cell["id"]] = {key: updated[key] for key in ("etag", "code_hash")}- elif change["kind"] == "delete_cell":+ else:+ assert change["kind"] == "delete_cell"assert change["base_etag"] == cells.pop(change["id"])["etag"]order.remove(change["id"])touched[change["id"]] = None- else:- assert change["kind"] == "set_app_config"- assert change["base_etag"] == before["app_config_etag"]- assert change["app_config"] == response["document"]["app_config"]+ assert response["document"]["app_config"] == before["app_config"]assert response["document"]["order"] == orderassert response["cells"] == touchedassert_document_hash(response["document"], cells)