Skip to content

fix(watch): ignore Linux watch-retirement echoes instead of invalidating every subscription - #782

Merged
steipete merged 2 commits into
mainfrom
fix/linux-watch-retirement
Oct 1, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/linux-watch-retirement

Conversation

@steipete

@steipete steipete commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Closing a Linux TREE subscription used to overflow every subscription sharing the process-wide inotify hub, including an ENTRY on a different Root. inotify_rm_watch queues IN_IGNORED, but fs-safe removed the descriptor's ownership immediately and interpreted that echo as a genuinely unknown descriptor.

Keep retiring descriptors known until their echo arrives, discard earlier queued events for those descriptors, and clear leftover retirement records after the queue drains. This includes EINVAL after kernel auto-removal and watch replacement. Descriptor reuse conservatively invalidates its new owner; genuinely unknown descriptors and kernel queue overflow retain global invalidation.

Regression coverage includes Rust hub tests and real Linux events-mode subscriptions, with explicit close and invalid-path scan-failure retirement. The unrelated ENTRY must remain ready with zero overflow and continue observing edits. The new tests fail on the main baseline.

Linux AWS proof installs a packed candidate and runs the supplied standalone reproduction, with only its version assertion/report adapted for the candidate version. Baseline main: missing-descendant TREE 4 overflows, unrelated ENTRY 2, valid-name controls 0. Selected invalid names fail closed with invalid-path. Candidate: missing TREE 2 (only undecodable sibling create/remove), unrelated ENTRY 0, valid-name controls 0; both selected TREEs still fail invalid-path. Nameless chmod, rename and delete each still produce one overflow and belong to the separate classification fix.

Validation: cargo test --workspace --locked; cargo clippy --workspace --locked -- -D warnings; pnpm build && pnpm native:build; all focused watch tests (255 passed on Linux); pnpm check (16,838 passed on Linux); independent Codex autoreview clean at P0–P2. An additional local macOS full check had eight event-delivery/timing failures; its Rust tests and Clippy passed. Exact-head native macOS ARM and Intel CI lanes both passed. No release, tag or publication is included.

@steipete
steipete requested a review from a team as a code owner October 1, 2026 00:48
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 30, 2026, 9:20 PM ET / October 1, 2026, 01:20 UTC (Revision 3).

ClawSweeper review

What this changes

The branch teaches the shared Linux watch hub to discard events from retired inotify watches, and adds regression tests, watch documentation, and a changelog entry.

Merge readiness

✅ Ready for maintainer review

Current main and v0.21.3 still have the reported cross-subscription overflow path. This focused PR has credible Linux before-and-after evidence and no identified blocking defect.

Priority: P2
Reviewed head: 0e320cfb5a6ce92c40930514e3ae670449f098b3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair has relevant regression coverage and concrete real Linux before-and-after observations.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The changed Linux inotify hub was exercised through packed-candidate events-mode subscriptions on Linux AWS; the captured baseline and candidate counts show unrelated ENTRY overflows falling from 2 to 0 while invalid paths still fail closed. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The changed Linux inotify hub was exercised through packed-candidate events-mode subscriptions on Linux AWS; the captured baseline and candidate counts show unrelated ENTRY overflows falling from 2 to 0 while invalid paths still fail closed. No stored-data contract changes.
Evidence reviewed 8 items Current main failure path: Removing a subscription drops its descriptor from the ownership map; an event subsequently read for that descriptor reaches the unknown-descriptor branch and overflows every pending subscription.
Introduced retirement handling: The introduced patch records successful or already-removed watch retirements, discards queued events through IN_IGNORED, and retains global invalidation for genuine unknown descriptors and queue overflow.
Production-boundary regression coverage: The added Linux events-mode test retires a TREE subscription by close or scan failure, then checks that an unrelated ENTRY subscription remains ready, receives no overflow, and observes a later edit.
Findings None None.
Security None None.

How this fits together

Linux filesystem events enter one inotify hub shared by multiple watch subscriptions. The hub sends advisory hints or overflow signals to subscriptions, whose guarded scans determine reportable changes.

flowchart LR
 A[Filesystem activity] --> B[Linux inotify queue]
 B --> C[Shared watch hub]
 C --> D{Descriptor state}
 D -->|Active| E[Subscription hints]
 D -->|Retired| F[Discard old events]
 D -->|Unknown or overflow| G[Global invalidation]
 E --> H[Guarded scan]
 G --> H
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Code and test growth production +21, tests +123, docs and changelog +6 The production change is small relative to the targeted Linux regression coverage and user-facing explanation.

Technical review

Best possible solution:

Keep peer subscriptions independent during watch retirement while preserving guarded reconciliation for genuine event loss and ambiguous filesystem state.

Do we have a high-confidence way to reproduce the issue?

Yes. Current-main source exposes the retired-descriptor route to global overflow, and the PR reports a baseline Linux run showing the failure; this review did not execute it.

Is this the best way to solve the issue?

Yes. The shared Linux hub owns descriptor lifetimes, so handling retirement there addresses the cause while leaving guarded scans and genuine overflow handling intact.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ecec23e10f15.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The fix addresses unintended invalidation across Linux watch subscriptions with a bounded affected surface and specific real-setup evidence.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed Linux inotify hub was exercised through packed-candidate events-mode subscriptions on Linux AWS; the captured baseline and candidate counts show unrelated ENTRY overflows falling from 2 to 0 while invalid paths still fail closed. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed Linux inotify hub was exercised through packed-candidate events-mode subscriptions on Linux AWS; the captured baseline and candidate counts show unrelated ENTRY overflows falling from 2 to 0 while invalid paths still fail closed. No stored-data contract changes.

Evidence

What I checked:

  • Current main failure path: Removing a subscription drops its descriptor from the ownership map; an event subsequently read for that descriptor reaches the unknown-descriptor branch and overflows every pending subscription. (native/src/watch_linux.rs:249, ecec23e10f15)
  • Introduced retirement handling: The introduced patch records successful or already-removed watch retirements, discards queued events through IN_IGNORED, and retains global invalidation for genuine unknown descriptors and queue overflow. (native/src/watch_linux.rs:239, 0e320cfb5a6c)
  • Production-boundary regression coverage: The added Linux events-mode test retires a TREE subscription by close or scan failure, then checks that an unrelated ENTRY subscription remains ready, receives no overflow, and observes a later edit. (test/watch-linux-retirement.test.ts:21, 0e320cfb5a6c)
  • Guarded reporting boundary: Native overflow triggers reconciliation; raw backend hints remain advisory and reported changes pass through guarded scan and Root identity checks. (src/watch.ts:169, 0e320cfb5a6c)
  • Real Linux behavior evidence: The captured PR body reports a packed-candidate run on Linux AWS: unrelated ENTRY overflows fell from 2 on baseline main to 0 on the candidate, while selected invalid paths still failed closed. These are contributor-reported measurements; this read-only review did not execute the run. (0e320cfb5a6c)
  • Release comparison: The latest release's Linux backend has removal and IN_IGNORED handling but no retirement tracking; the fix is absent from both that release and the supplied current-main revision. (native/src/watch_linux.rs:252, fe6e61d2df3e)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-01T00:56:12.779Z sha d4d2361 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-01T01:06:55.464Z sha 0e320cf :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the fix/linux-watch-retirement branch from d4d2361 to 0e320cf Compare October 1, 2026 01:02
@steipete
steipete merged commit 1ad5769 into main Oct 1, 2026
47 checks passed
@steipete
steipete deleted the fix/linux-watch-retirement branch October 1, 2026 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant