Skip to content

fix(flow): commit the test save before answering the probe - #2574

Merged
abrichr merged 2 commits into
mainfrom
grok/fix-tx-post-reads-commit-before-response
Nov 23, 2026
Merged

abrichr merged 2 commits into
mainfrom
grok/fix-tx-post-reads-commit-before-response

Conversation

@abrichr

@abrichr abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member

Why

Packages 45114218278 failed flow unit shard 1/2 on tests/test_tx_post_reads.py::test_probe_learns_reads_and_refuses_the_save (assert not by_path["/rec/1"].read_only; reason was "every replay returned 2xx and left the store unchanged").

This is a flake, not a deterministic #2413 regression. #2413 did not touch read_probe.py or this test. The same test passed on shard 1/2 of Packages 45102046058 (#2413 itself), 45103688016, and 45106115775.

Cause

The test server sent HTTP 200 inside with sqlite3.connect(...), before the implicit commit on context exit. probe_read_routes digests the store as soon as the replay status returns. If that digest wins the race, a real POST /rec/1 looks unchanged and is learned as a read — the fail-open that store_reset is meant to prevent (test_without_a_reset_a_replayed_save_would_look_like_a_read).

What

Send the HTTP response only after the SQLite connection context exits, so the write is committed before the probe digests. No test assertions loosened, deleted, or skipped.

Test plan

  • tests/test_tx_post_reads.py still passes, including test_probe_learns_reads_and_refuses_the_save and test_without_a_reset_a_replayed_save_would_look_like_a_read.

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.
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude
Reviewed-Head: 498800d

Cross-vendor review; Grok wrote this PR. The change is test-only, in packages/flow/tests/test_tx_post_reads.py. The fake server now leaves the sqlite with block, which commits, before writing the HTTP response. Previously a 200 could be sent before the implicit commit, so probe_read_routes could digest the store too early: a real save then looked unchanged and could be learned as a read. That's the race behind the flaky main failure in test_probe_learns_reads_and_refuses_the_save. No product code changes, and the assertion is not weakened: the save is still refused. The new commit is only a ruff format wrap.

@abrichr
abrichr merged commit 19fde9e into main Nov 23, 2026
52 checks passed
@abrichr
abrichr deleted the grok/fix-tx-post-reads-commit-before-response branch November 23, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant