fix: macOS portability for core locking and test assertions - #142
Open
aymandakirgh wants to merge 1 commit into
Open
fix: macOS portability for core locking and test assertions#142aymandakirgh wants to merge 1 commit into
aymandakirgh wants to merge 1 commit into
Conversation
Two independent macOS issues surfaced on a clean install (macOS 15, bash 3.2.57, arm64) following docs/install-guide.md. 1. flock(1) is absent on macOS but required by the CORE concurrency layer, not just the optional DragonScale extension. Both scripts/wiki-lock.sh and scripts/allocate-address.sh invoke it, and both are referenced from CLAUDE.md as core v1.7 surfaces. On a stock Mac every lock call returns "flock: command not found", so the PostToolUse hook hits LOCK_RC != 0 and silently defers the wiki auto-commit on every write, permanently. It fails safe, but the advertised feature is simply off with no user-visible signal. install-guide.md mentioned flock only inside the optional DragonScale callout. Promoted to its own prerequisite note with the `brew install flock` remedy. 2. With flock installed, 6 assertions still failed because BSD wc -l pads its output with leading spaces where GNU wc -l does not: assert_eq compared "10" against " 10". The counts were numerically correct throughout, so this was a harness bug rather than a defect in the locking or allocator code. Wrapped each capture in arithmetic expansion $(( ... )), which normalizes on both platforms without changing behavior on Linux. make test: 9/9 suites pass on macOS (was 3 suites failing). Co-Authored-By: Claude Opus 5 (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.
Summary
Two independent macOS issues surfaced on a clean install (macOS 15, bash 3.2.57, arm64) following
docs/install-guide.md. One is a real functional gap in the core concurrency layer, the other is a test-harness portability bug. Neither affects Linux.Type
fix:)docs:)Changes
docs/install-guide.md— promotedflock(1)from a line inside the optional DragonScale callout to its own macOS prerequisite note, with thebrew install flockremedy.tests/test_allocate_address.sh— wrapped 2wc -lcaptures in$(( ... )).tests/test_concurrent_write.sh— wrapped 3wc -lcaptures in$(( ... )).tests/test_wiki_lock.sh— wrapped 1wc -lcapture in$(( ... )).CHANGELOG.md— entry under## [Unreleased].1.
flock(1)is a core prerequisite, not a DragonScale-only oneflock(1)ships withutil-linuxon Linux and is absent on macOS. It is invoked by two scripts that are core v1.7 surfaces referenced fromCLAUDE.md, not DragonScale extras:scripts/wiki-lock.sh:156— per-file advisory locksscripts/allocate-address.sh:36— address allocatorOn a stock Mac every call returns
flock: command not found:The downstream effect is quiet. The
PostToolUsehook gates its auto-commit onLOCK_RC, so a failingwiki-lock listmakes itexit 0and defer, on every write, for the life of the vault. It fails safe, which is the right design, but the advertised auto-commit never runs and nothing tells the user why.install-guide.md:8mentionedflockonly inside the optional DragonScale block ("Extra prerequisites beyond the base"), so a base-install user has no reason to install it.Worth noting the Python helpers (
bm25-index.py,rerank.py,tiling-check.py) usefcntl.flock(2)from the stdlib and are unaffected. Only the two Bash callers of the CLI utility are.2. BSD
wc -lpadding failed 6 assertionsWith
flockinstalled, 6 assertions still failed. BSDwc -lpads output with leading spaces, GNUwc -ldoes not:Every value was numerically correct, so this is a harness bug rather than a defect in the locking or allocator code. Arithmetic expansion normalizes on both platforms with no behavior change on Linux.
Six-cut self-review
$(( ))over a new helper for 6 call sites)git revertis a clean undo)Testing
make teston macOS 15 / bash 3.2.57 / arm64, withflock 0.4.0installed via Homebrew:Before this change, on the same machine:
test_allocate_address.sh,test_concurrent_write.shandtest_wiki_lock.shall failed. Per-suite after:Verifier
Not dispatched. The change is 7 modified lines across 3 test files plus a docs note, with no production-code surface, so I applied the six-cut manually rather than spending an agent pass. Happy to run
agents/verifier.mdif you'd prefer it on record.CHANGELOG
## [Unreleased]inCHANGELOG.mdNotes for reviewer
The docs half is the part worth a second opinion. I framed
flockas a hard macOS prerequisite for the base install. If you'd rather keep the base install dependency-free, the alternative is a shell fallback inwiki-lock.sh(mkdir-based locking is atomic on POSIX and needs no external binary), which would make the vault work on a stock Mac with no Homebrew step. That is a larger change and a design call that is yours, so I went with the documentation fix here.🤖 Generated with Claude Code