From 65a629c0e8251be15255f1c38fd350e260e65e61 Mon Sep 17 00:00:00 2001 From: abrichr Date: Mon, 23 Nov 2026 00:32:13 -0500 Subject: [PATCH 1/2] fix(flow): commit the test save before answering the probe test_probe_learns_reads_and_refuses_the_save failed on main when probe_read_routes digested the store after HTTP 200 but before the test server committed the SQLite update, so a real POST /rec/1 looked unchanged and was learned as a read. Send the response only after the connection context exits. The test assertions are unchanged. --- packages/flow/tests/test_tx_post_reads.py | 27 +++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/flow/tests/test_tx_post_reads.py b/packages/flow/tests/test_tx_post_reads.py index fd7961189e..4487478069 100644 --- a/packages/flow/tests/test_tx_post_reads.py +++ b/packages/flow/tests/test_tx_post_reads.py @@ -173,31 +173,34 @@ def do_GET(self) -> None: def do_POST(self) -> None: length = int(self.headers.get("Content-Length") or 0) body = json.loads(self.rfile.read(length) or b"{}") + # Commit (leave the with-block) before writing the HTTP + # response. probe_read_routes digests the store as soon as + # the status returns; a 200 sent before the implicit commit + # can make a real save look unchanged and be learned as a + # read — the fail-open store_reset is meant to prevent. with sqlite3.connect(app.db) as conn: if self.path == "/search": rows = conn.execute("select id from rec").fetchall() - self._json(200, {"ids": [r[0] for r in rows]}) + status, payload = 200, {"ids": [r[0] for r in rows]} elif self.path == "/rpc" and body.get("method") == "rec.read": - self._json( - 200, - { - "n": conn.execute( - "select count(*) from rec" - ).fetchone()[0] - }, - ) + status, payload = 200, { + "n": conn.execute( + "select count(*) from rec" + ).fetchone()[0] + } elif self.path == "/rpc" and body.get("method") == "rec.write": conn.execute( "update rec set note=? where id=1", (body["note"],) ) - self._json(200, {"ok": True}) + status, payload = 200, {"ok": True} elif self.path == "/rec/1": conn.execute( "update rec set note=? where id=1", (body["note"],) ) - self._json(200, {"id": 1, "note": body["note"]}) + status, payload = 200, {"id": 1, "note": body["note"]} else: - self._json(404, {}) + status, payload = 404, {} + self._json(status, payload) def _json(self, status: int, payload: Any) -> None: raw = json.dumps(payload).encode() From 498800d151af407b4c54705631564c88e6fd6bf6 Mon Sep 17 00:00:00 2001 From: abrichr Date: Mon, 23 Nov 2026 00:43:20 -0500 Subject: [PATCH 2/2] style(flow): wrap the rec.read test payload for ruff format --- packages/flow/tests/test_tx_post_reads.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/flow/tests/test_tx_post_reads.py b/packages/flow/tests/test_tx_post_reads.py index 4487478069..2a9ebf74b4 100644 --- a/packages/flow/tests/test_tx_post_reads.py +++ b/packages/flow/tests/test_tx_post_reads.py @@ -183,11 +183,14 @@ def do_POST(self) -> None: rows = conn.execute("select id from rec").fetchall() status, payload = 200, {"ids": [r[0] for r in rows]} elif self.path == "/rpc" and body.get("method") == "rec.read": - status, payload = 200, { - "n": conn.execute( - "select count(*) from rec" - ).fetchone()[0] - } + status, payload = ( + 200, + { + "n": conn.execute( + "select count(*) from rec" + ).fetchone()[0] + }, + ) elif self.path == "/rpc" and body.get("method") == "rec.write": conn.execute( "update rec set note=? where id=1", (body["note"],)