Repository navigation
Conversation
|
I ran a branch-neutral ownership/concurrency comparison against exact PR head What passed
This is materially stronger than #174's first-owner-note CAS: under the same 200-round process harness, #174 admitted both the claim and first message in all 200 rounds. Two authorization windows remainThe same neutral harness found two commit-time fencing gaps:
So my read is: this is the stronger consolidation target for atomic room birth, and the birth race itself is well covered. Before merge, it would be valuable either to fence transfer/message authorization through commit under the relevant room lock, or to define the weaker semantics explicitly and pin them with regression tests. I did not push a branch or open a competing PR. I can provide the small branch-neutral reproducer if useful. |
djd39448
left a comment
There was a problem hiding this comment.
Rebased #179 onto current main and tested it independently. It fixes both #173 and #176, stays in scope, and is green on the checks that gate this area. Reviewing as a contributor — this is a review, not a merge.
Rebase is a one-line CHANGELOG conflict, resolved trivially:
$ gh pr checkout 179 && git rebase origin/main # only CHANGELOG.md [Unreleased] conflicts
The race is fixed. I applied #174's three race regression tests against this branch — all pass:
test_two_concurrent_first_claims_do_not_both_succeed PASSED
test_claim_vs_first_message_do_not_both_succeed PASSED
test_first_message_vs_claim_do_not_both_succeed PASSED
Same shape as the approach in #174: an unowned / require_unowned_room flag re-checked under the append lock, with the first claim serialized against room creation.
The checks that gate this area pass on current main:
$ uv run ruff check . # clean
$ uv run sz.py --check # ok
$ uv run python -m pytest tests/unit/test_store_doc.py # 2 passed
That last one matters here: the change adds unowned: bool = False to store.append, and this PR regenerates docs/store.md to match (the generated-doc test enforces it). CHANGELOG updated, baselines in sync, full suite green. Complete from where I sit.
Gate returns its own first-claim snapshot so the write lane forces create-if-absent without re-reading after the nonce burn. Re-reading reintroduces the split-read: B completes between the two reads, A sees present and overwrites unconditionally. Zero store churn: uses existing expect_absent inside the note lock. Caller ?if preserved: stale if still 409 via normal CAS path. Both lanes: GET note_write_signed and POST note_post. Tests: GET + POST distinct-nonce race, forced at the owner-note lock. Fixes flop-labs#173. Handover/allow/message fencing stays with flop-labs#501/flop-labs#499/flop-labs#179. Caps: app 1027/1030, store untouched.
…le test The marker carried strict=True but no raises=, so every failure inside the test counted as the expected one. A dead hook or a moved helper reported "1 xfailed" -- including the test's own `assert raced` guard, whose entire job was to refuse to prove nothing. Verified on 1d8baac by breaking `_race_before_lock` two ways: both reported XFAIL, and under --runxfail both stopped at line 63, never reaching the ownership invariant. That is not only a reporting fault. A harness that breaks while flop-labs#173 is open never reaches the invariant, so it keeps reporting xfail after a fix lands: no XPASS, no removed marker, and the acceptance bar disappears with a green build. - raises=AssertionError scopes the expectation to the defect's own failure. - Every check upstream of the invariant goes through _plumbing(), which calls pytest.fail. Failed is not an AssertionError, so it falls outside raises= and reports FAILED from inside an xfail-marked test. Covers the race-happened guard and a new refusal of a 5xx from the losing claim. - test_a_broken_harness_fails_the_build_instead_of_reporting_the_bug runs both shapes under a real pytest and asserts the report separates them. pytest.xfail() was the other option and loses the ratchet: the imperative form has no strict mode, so once the race closes the test would simply pass. The measurement note is re-taken at today's heads: flop-labs#629 (22c7e43) xpasses, flop-labs#501 (3209cb8) still xfails, flop-labs#179 (bcdfdf2) still conflicts in four files. Raised by @Minh3132.
Gate returns its own first-claim snapshot so the write lane forces create-if-absent without re-reading after the nonce burn. Re-reading reintroduces the split-read: B completes between the two reads, A sees present and overwrites unconditionally. Zero store churn: uses existing expect_absent inside the note lock. Caller ?if preserved: stale if still 409 via normal CAS path. Both lanes: GET note_write_signed and POST note_post. Tests: GET + POST distinct-nonce race, forced at the owner-note lock. Fixes flop-labs#173. Handover/allow/message fencing stays with flop-labs#501/flop-labs#499/flop-labs#179. Caps: app 1027/1030, store untouched.
|
Carrying over from look-alike #629 (closed as this PR's duplicate):
|
|
Reviewed PR #179 (fix: make room ownership atomic at birth). Files changed: CHANGELOG.md,docs/store.md,src/app.py,src/store.py,tests/http/test_rooms.py, Verdict: LGTM. Reviewed code changes; no issues found. |
Summary
Why this is separate from #174
#174 protects two owner-note writes from each other. It does not serialize the owner note with the room JSONL commit, so both cross-resource interleavings in #176 still return 200: a conversation can be claimed after its first message, or an unsigned message can land after ownership commits.
This PR makes the first owner note and first room record share the existing room creation/room lock domain.
Tests
Two deterministic regressions cover both orderings:
Validation:
uv run --no-sync coverage run -m pytest tests -q— 381 passeduv run --no-sync ty checkuv run --no-sync ruff check .uv run --no-sync ruff format --check .uv run --no-sync python sz.py --check— 2010 core code-lines vs 2012 baselinegit diff --checkCloses #176