Repository navigation
fix(watch): use kqueue for macOS entry scopes - #753
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 28, 2026, 6:30 AM ET / 10:30 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch uses identity-checked kqueue descriptors for macOS entry watches, retains FSEvents for tree watches, and adds documentation, regression coverage, and a comparative workflow. Merge readiness⛔ Blocked before merge - 8 items remain Current main and v0.21.1 still expose macOS entry scopes to recursive FSEvents traffic, so this PR addresses a distinct remaining problem. The hosted comparison supports the repair, while filesystem safety and upgrade compatibility still need resolution. Priority: P2 Review scores
Verification
How this fits togetherThe watch subsystem receives selected paths beneath an admitted filesystem Root. Native events prompt guarded scans, which publish advisory invalidations to callers. flowchart LR
A[Admitted Root and scopes] --> B[Guarded scan]
B --> C{Scope kind}
C -->|Entry| D[kqueue descriptors]
C -->|Tree| E[FSEvents stream]
D --> F[Guarded reconciliation]
E --> F
F --> G[Caller invalidations]
Decision needed
Why: The branch changes the availability contract for existing auto-mode users, and the PR body describes failure without an explicit acceptance of that upgrade tradeoff. Before merge
Findings
Agent review detailsSecurityNeeds attention: The new watcher duplicates security-sensitive native path admission outside the shared guarded helper; no reachable escape was established. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep kqueue for entry scopes, centralize literal no-follow descriptor admission, preserve a usable auto-mode path under descriptor exhaustion, and verify fresh and upgraded package behavior. Do we have a high-confidence way to reproduce the issue? Yes. The exact-main macOS baseline in the linked ancestor workflow overflowed under deep unselected churn, while the candidate reported zero entry overflows on both macOS architectures. Is this the best way to solve the issue? Not yet. The kqueue split addresses the observed pressure, but descriptor admission should share the guarded filesystem boundary and auto-mode capacity behavior needs an explicit compatibility choice. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ff0bfa4f74f0. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
Entry scopes anchored above a busy macOS subtree previously received recursive FSEvents traffic from unrelated descendants. That traffic could exhaust pending detail or trigger native overflow even when none of the selected entries changed. Entry scopes now use identity-checked kqueue descriptors for the admitted parent and, when present, the entry itself. Guarded scans re-arm replacements and finish transport admission before publishing readiness.
Parent activity requests a coalesced scan without filenames or pathname-budget pressure. Entry descriptors deliver content and attribute changes; symlink descriptors observe the link itself using
O_EVTONLY | O_SYMLINK. Registration retains at most two descriptors per entry scope, counts them in health pressure, and fails explicitly on descriptor exhaustion. The shared hub blocks on kqueue and command wakes without native timers, and removal remains joined.Tree scopes at every depth retain FSEvents, tree-only anchors, and the existing exclusion paths. Root identity and guarded pathname admission remain authoritative.
Reproduction and measurements
The hosted regression churns an unselected deep subtree beneath the entry anchor. Historical main is pinned at
ff0bfa4f74f09a1bf08bd1ed9c1bce83d2fde45d; the candidate is3ee42e2d7770e8d14a37e04bebebe9d4bec9c754. Each measurement lasted approximately 8.5 seconds.Candidate macOS entry workloads sustained 15,653 operations/second on arm64 and 5,451 on Intel. Both delivered all nine selected-change phases: creation, content, file attributes, directory attributes, symlink retarget, symlink attributes after re-arm, deletion, recreation, and content after re-arm.
Windows measurements use its unchanged transport. Shallow tree scopes still receive recursive traffic and can overflow; those results are recorded without changing their transport or suppressing loss notifications. No Windows transport, version, or changelog changes are included.
Validation
All runs below are green on the exact candidate head:
pnpm checkpassed with 16,569 tests and package validation; 500 poll + 500 event model seeds passed. The VM and lease are retired.Ready for coordinator review. Do not merge as part of this work order.