Repository navigation
Conversation
_sweep_orphan_locks spares a lock whose data file is gone while the lock itself is still fresh, and takes it only once it has been idle for IDLE_SECONDS. The existing tests bound the os.access clause and a lock aged well past the threshold, so the age guard itself was never exercised with the data file absent. `<=` and `<` behaved identically for every caller, and an off-by-one there unlinks a lock a writer recreating the room is about to hold, which splits the lock domain. The sweep never raises, so nothing would fail from a stack trace. The test calls _sweep_orphan_locks with an explicit now, so the boundary is exact rather than raced: spared at exactly IDLE_SECONDS, swept one microsecond later. Tests only, no src change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Open pull requests citing the same issues:
If one already covers this change, review or build on it instead of racing it (CONTRIBUTING.md "Overlapping work"). |
WIZARDspace
approved these changes
Oct 9, 2026
WIZARDspace
left a comment
Contributor
There was a problem hiding this comment.
Approving at 330c839. I re-verified on current main@0e47f77 (the branch is behind, and the merge is clean), since the body measures against e4c4f73:
_sweep_orphan_locksand its guard are unchanged on0e47f77, and no existing test reaches the age guard with the data file absent. With the guard flipped<=→<, the whole suite minus this test still passes (860 passed, 1 skipped). So the gap is real today.- The new test fails against that
<mutant, and also against dropping the age clause entirely (os.access(data, os.F_OK)alone). It passes on the clean merge. just checkon the merge exits 0: 861 passed, 1 skipped,core/store.py1030/1030 (nosrc/change). Thetest_contributing_recipesfailure the body mentions no longer occurs onmain.- It still passes with #815 (
eecfb7c) merged on top. The overlap bot's link is through #311, and #815 doesn't touch the sweep.
One nit, not blocking: the second call adds + 1, which is one second (now and st_mtime are in seconds), but the docstring and the assert message both say "one microsecond".
Contributor
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
One test,
+35/-0, on the age guard in_sweep_orphan_locks. Nosrc/change, noCHANGELOG.md, nosz-baseline.json.Everything asserted here holds on
maintoday and I verified it in both directions before writing any of it. What the PR buys is a tripwire on a boundary two existing tests step around on both sides, so no current test would notice if it were wrong.The gap
The sweep keeps a lock whose data file is gone while the lock itself is still fresh, then takes it only once it has been idle as long as any reaped room:
Two tests bound this from the sides.
test_a_lock_is_never_swept_while_its_data_file_is_therecovers theos.accessclause with the data present.test_orphan_locks_are_sweptages a lock toIDLE_SECONDS + 60and confirms it goes. Neither exercises the age guard itself with the data file absent, so<=and<are indistinguishable to every existing caller and an off-by-one is silent. The sweep never raises, so nothing would surface from a stack trace either.The direction that costs something is dropping the lock early. The lock outlives its data by design so a writer recreating the room takes the lock beside its file. Unlinking a fresh one splits the lock domain: two writers then flock different inodes and append at once. So a lock idle for exactly
IDLE_SECONDSmust be spared and one microsecond older swept.The mutant
_sweep_orphan_locks, the age guard:now - entry.stat().st_mtime <= IDLE_SECONDSflipped to<. The two spellings disagree on exactly one instant.nowis passed to_sweep_orphan_locksrather than read off the clock, so the boundary is exact here rather than raced, the same reason_reapabletakesnowintest_a_room_idle_for_exactly_the_threshold_is_not_reapable_yet.Both ways
Verified against upstream main at
e4c4f73, with the mutant applied and reverted, running only the new test:Full suite on the branch:
782 passed, 1 skipped, 1 failed. The one failure istests/unit/test_contributing_recipes.py::test_contributing_names_only_things_that_exist, a pre-existing docs-vs-justfile mismatch on upstreame4c4f73(just serveandjust mutatenamed in CONTRIBUTING.md, not in the justfile). It is unrelated to this change and fails identically on cleanmain..venv/bin/python sz.py --capsis unchanged: nosrc/line moves,store.pystays at 987 of 1010 code lines.ruff checkandruff format --checkpass on the file.Checks
CHANGELOG.mduntouched, sincequeue-guard'sprotected-filesjob fails a fork PR that edits it. Nothing here is user-visible in any case: one test.sz-baseline.jsonuntouched, since a pull request runssz.py --capsand no core line moves.test_a_lock_is_never_swept_while_its_data_file_is_there, the behaviour it bounds.AI disclosure
Written with AI assistance (Claude). What was verified by a human before submit: the test passes on upstream
e4c4f73, the<=-to-<mutant makes it fail while reverting restores it, the full suite result above, plus that the diff is additive tests-only with nosrc/,CHANGELOG.mdorsz-baseline.jsonchange.Rival overlap
The one open PR that touches this line is #311, which proposes changing the orphan-lock
grace. It is CONFLICTING and last moved 2026-09-10, so it is out of the merge window.
This test pins the behavior shipping on main today. If #311's design is ever adopted the
test moves with it, the same as any characterization test.
Provenance
did:key:z6MkoA8xuzKJRGtHa5hr6znFCZq164mb45JHx6kktdJ6tMdL
fingerprint f15ddb2552fee06f
Ed25519 signature over the file manifest (base64url, no padding). Rebuild the digest with
git show <sha>:<path> | sha256sum, join under the header line, verify against the rawkey decoded from the DID. A tampered manifest fails.
signature oF414IZls-BPxLSckKXEnncMXu4qw7gmadT8pPS-uUL3KZRJ3ynuU4rwGGkIRKbs2eURmuhZDdzStxj2gpbGCg
DID note /kv/did/f15ddb2552fee06f
signed post /r/technocore seq 11256407