test(G5): cross-process port-allocation race over the flock - #71
Merged
Conversation
Adds the two-terminal concurrency guarantee at the layer that matters, across REAL OS processes (subprocess-helper pattern), with no daemon and no flakiness: the ledger is pre-created, then 5 copies of the test binary each allocate 6 host ports under the machine-global flock. Port allocation is the mutation that cannot be made idempotent — two processes handing out the same host port is a hard bug — so "every allocated port is distinct across every process" is a direct proof the cross-process flock serialized the critical section. A no-op flock would let two processes pick the same lowest-free port and collide. Note: writing this surfaced that concurrent FIRST-open of a brand-new ledger from several processes relies on a reliable-flock filesystem (the WAL switch + migrate race otherwise); that hazard is already mitigated by `doctor`'s 9p/networked-FS warning (internal/cli fsCheck). The test deliberately pre-migrates so it validates the allocation flock specifically, independent of that. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Closes G5 — the two-terminal concurrency guarantee, validated across real OS processes (subprocess-helper pattern), daemon-free and non-flaky.
How
The ledger is pre-created, then 5 copies of the test binary each allocate 6 host ports under the machine-global flock. Port allocation is the mutation that cannot be made idempotent — two processes handing out the same host port is a hard bug — so "every allocated port is distinct across every process" directly proves the cross-process flock serialized the critical section. A no-op flock would let two processes pick the same lowest-free port and collide.
Validates the repo's #1 architectural rule (lock-first concurrency) at the cross-process layer the existing
internal/lockgoroutine test can't reach. Verified-race -count=5.Finding (already mitigated)
Writing this surfaced that concurrent first-open of a brand-new ledger from several processes relies on a reliable-flock filesystem (the WAL switch + migrate otherwise race) — already mitigated by
doctor's 9p/networked-FS warning (fsCheck). The test pre-migrates so it isolates the allocation flock specifically.🤖 Generated with Claude Code