Skip to content

fix(watch): classify Linux undecodable and nameless inotify events instead of overflowing - #783

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

steipete merged 2 commits into
mainfrom
fix/linux-watch-event-classification

Conversation

@steipete

@steipete steipete commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Linux treated both undecodable child names and nameless directory self-events as backend overflow. A malformed-byte sibling beside a missing TREE anchor therefore invalidated that subscription despite being unable to match any validated scope component; ordinary directory chmod, rename and deletion also discarded structural detail.

Carry an explicit nameless-child marker through the bounded native queue and callback retry. TypeScript admits it only when that directory's children are selected within a TREE's remaining depth, including observed directory aliases. The guarded scan then fails closed with invalid-path if the undecodable name remains present. Ancestor/anchor-only activity is dropped. Non-root Linux self-events become structural hints for the directory; Root self-events, genuine kernel overflow and malformed transport remain conservative. Hints never publish unobserved names or supply child I/O authority.

macOS FSEvents previously discarded an undecodable path silently. It now retains the nearest fully decodable directory and uses the same guarded child admission. Windows already fails closed: RDCW decoding overflows on unpaired UTF-16 surrogates, and owned-directory enumeration rejects invalid UTF-16. Its behavior is unchanged and now has explicit surrogate regression tests.

Linux lifecycle measurements, one operation per case: chmod generated one nameless IN_ATTRIB; rename generated one IN_MOVE_SELF; deletion generated IN_DELETE_SELF and IN_IGNORED. Each produced one public overflow before this fix. The packed candidate produces zero public overflows for all three operations and retains structural directory detail. Kernel event counts remain 1 / 1 / 2.

Regression coverage includes Rust classification and callback-retry tests, macOS raw-byte decoding, Windows unpaired surrogates, TypeScript scope/depth/exclusion/alias admission, and real Linux events-mode integration driven by guarded reconcile() checkpoints. This follows the separately landed retirement-isolation fix #782. No release, tag or publication is included.

Packed AWS Linux proof (Node 24.21.0, matching the supplied diagnostic): the supplied standalone repro, with only its version assertion/report adapted for the packed candidate, now records missing TREE 0 and unrelated ENTRY 0 overflows. The unmodified original repro against published 0.21.3 and the main baseline both measured 4 / 2, and #782 alone was 2 / 0. Valid-name controls remain 0. Both selected malformed-name TREEs still fail scan / invalid-path and close successfully.

Validation: cargo test --workspace --locked, cargo clippy --workspace --locked -- -D warnings, pnpm build && pnpm native:build, all focused Linux watch tests (263 passed), and pnpm check (16,972 passed). macOS Rust tests and Clippy pass, as do 58 focused TypeScript admission/scheduling tests locally. Independent Codex review is clean at P0–P2 after rebasing onto main including #782 and #781.

@steipete
steipete requested a review from a team as a code owner October 1, 2026 01:31
@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, 10:12 PM ET / October 1, 2026, 02:12 UTC (Revision 3).

ClawSweeper review

What this changes

The branch classifies undecodable and nameless watcher events on Linux and macOS, routes relevant hints through guarded scans, and adds documentation and cross-platform regression coverage.

Merge readiness

✅ Ready for maintainer review

Keep this PR open. Current main and v0.21.3 still overflow on undecodable Linux names; the merged retirement fix addresses a separate cause. The branch remains useful, and this review found no blocking patch defect.

Priority: P2
Reviewed head: 9a0794690a2c2cb471c7692c633afcafb11c456c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has a coherent guarded implementation, focused coverage, and recorded packed Linux behavior for the central fix.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The changed Linux inotify-to-watch path was exercised through a packed Node 24.21.0 build on AWS Linux: recorded baseline overflows fell from 4/2 to 0/0, while selected malformed names still produced scan/invalid-path. macOS and Windows have supplemental platform regression tests; 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-to-watch path was exercised through a packed Node 24.21.0 build on AWS Linux: recorded baseline overflows fell from 4/2 to 0/0, while selected malformed names still produced scan/invalid-path. macOS and Windows have supplemental platform regression tests; no stored-data contract changes.
Evidence reviewed 9 items Current main behavior: The pinned main implementation sends undecodable or empty Linux event names to unconditional overflow.
Introduced native classification: The introduced Linux record path separates self-events, malformed transport names, valid names, and undecodable child names without retaining a lossy child spelling.
Guarded hint admission: Tree depth limits unnamed-child admission; the alias path checks observed directory identity before adding a structural hint.
Findings None None.
Security None None.

How this fits together

The filesystem watcher receives operating-system notifications beneath an admitted Root. It checks native hints against configured scopes and guarded scans before reporting invalidations or scan failures to callers.

flowchart LR
A[Filesystem notifications] --> B[Bounded native hint queue]
B --> C[Scope and alias admission]
D[Admitted Root and watch scopes] --> C
C --> E[Guarded directory scan]
D --> E
E --> F[Scoped invalidation or scan failure]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Source and test growth production-path files +112 net lines, standalone test files +136 net lines The source growth, which includes inline Rust tests, supports the new classification and guarded admission paths.

Technical review

Best possible solution:

Keep guarded Root scans authoritative for child names while preserving scoped detail for Linux directory lifecycle events.

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

Yes. The captured packed AWS Linux comparison measured the failure on the published and main baselines, and current-main source shows the unconditional overflow path; this reviewer did not run the reproduction.

Is this the best way to solve the issue?

Yes. The branch classifies native events before scope admission while leaving name discovery and filesystem access to guarded scans.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded watcher correctness fix for spurious overflow and lost structural detail.
  • 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-to-watch path was exercised through a packed Node 24.21.0 build on AWS Linux: recorded baseline overflows fell from 4/2 to 0/0, while selected malformed names still produced scan/invalid-path. macOS and Windows have supplemental platform regression tests; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed Linux inotify-to-watch path was exercised through a packed Node 24.21.0 build on AWS Linux: recorded baseline overflows fell from 4/2 to 0/0, while selected malformed names still produced scan/invalid-path. macOS and Windows have supplemental platform regression tests; no stored-data contract changes.

Evidence

What I checked:

  • Current main behavior: The pinned main implementation sends undecodable or empty Linux event names to unconditional overflow. (native/src/watch_linux.rs:265, 900a77074fcd)
  • Introduced native classification: The introduced Linux record path separates self-events, malformed transport names, valid names, and undecodable child names without retaining a lossy child spelling. (native/src/watch_linux.rs:265, 9a0794690a2c)
  • Guarded hint admission: Tree depth limits unnamed-child admission; the alias path checks observed directory identity before adding a structural hint. (src/watch-alias.ts:106, 9a0794690a2c)
  • Fail-closed scan boundary: The guarded directory listing rejects invalid UTF-8 names with invalid-path. (src/root-directory-list.ts:39, 9a0794690a2c)
  • Focused integration coverage: The added Linux events-mode tests cover unrelated malformed siblings, selected malformed children, and watched-directory chmod, rename, and deletion. (test/watch-linux-classification.test.ts:31, 9a0794690a2c)
  • Contributor real-behavior proof: The captured PR body reports a packed AWS Linux run on Node 24.21.0: the published and main baselines measured 4 missing-tree and 2 unrelated-entry overflows, versus 0 and 0 on the candidate. Selected malformed-name trees still failed scan with invalid-path. These are contributor-recorded measurements, not a reviewer-run test.

Likely related people:

  • Peter Steinberger: Raw commit 1ad5769 adds native/src/watch_linux.rs:239 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1ad57695bf87; files: native/src/watch_linux.rs)

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-01T01:37:33.219Z sha 2ab511f :: needs maintainer review before merge. :: none
  • reviewed 2026-10-01T01:44:22.972Z sha 2ab511f :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the fix/linux-watch-event-classification branch from 2ab511f to 9a07946 Compare October 1, 2026 02:06
@steipete
steipete merged commit b042946 into main Oct 1, 2026
47 checks passed
@steipete
steipete deleted the fix/linux-watch-event-classification branch October 1, 2026 02:24
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