Skip to content

feat(watch): add guarded advisory filesystem observation - #666

Closed
roboclaw-bot wants to merge 11 commits into
mainfrom
openclaw/fs-safe-watch-contract-20260925
Closed

roboclaw-bot wants to merge 11 commits into
mainfrom
openclaw/fs-safe-watch-contract-20260925

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Filesystem consumers need one Root-bound owner for observation, guarded reconciliation, recovery and joined shutdown instead of maintaining separate watcher engines.

User Impact

Adds the unreleased @openclaw/fs-safe/watch API for literal entry/tree scopes, bounded advisory dirty hints, health, updates, reconciliation and terminal awaited close. Native observation is supported only on Linux Node.js with verified procfs. macOS, Windows, Bun and other unproven native routes fail readiness with helper-unavailable/watch provenance and no worker; callers must explicitly select portable mode: "poll". There is no silent fallback.

Observation failures remain in readiness/reconciliation/health, but successful joined retirement resolves close. Actual worker or directory-pin cleanup failures remain rejected, retain prior context and prevent rearm.

Hosted qualification is complete for this limited contract; the PR remains draft. Current-head review reports no actionable code/security findings and says the earlier registration issue is addressed. Its verdict remains needs-human/blocked for package-owner acceptance of the platform/resource policy—not merge approval. Readiness/hints are not complete-event, permanent-path-membership, atomic-snapshot, completed-write or content-freshness receipts. One worker per native subscription plus retained directory descriptors has material cost; there is no aggregate pool/cap or performance-win claim. Maintainer acceptance of this limited support/resource contract remains a landing decision. No release or completed OpenClaw migration is claimed.

Why This Change Was Made

  • Reuse exact admitted Root context, guarded resolution/listing and existing directory-pin identity primitives. Linux registration uses the scanner’s original exact receipt and a genuine retained pin, never fresh replacement-path authority. Trusted procfs type and exact descriptor/followed-target identities are checked before using /proc/self/fd/N. Pins remain owned through native detach and worker join.
  • Address the reported registration/activity finding: a pathname watcher could bind a different outside inode during swap-and-restore. Withholding filenames alone was insufficient. Qualified registrations are now descriptor-bound; unprovable routes fail closed instead of claiming that advisory hints excuse outside activity. Detectable moves still retire/reconcile; no continuous-membership guarantee is invented.
  • Defer Node’s pathname-based macOS/Windows transports. Bun1.4.2 also resolves descriptor paths back to canonical names before inotify registration (pinned source), so it is not a descriptor-bound native route. Explicit polling keeps the same Root guards and bounded lifecycle.
  • Preserve private raw hints, guarded relative detail, generation fences, bounded queues, symlink-entry/target separation, exact filesystem alias lookup and independent reconciliation. Neither case folding nor pathname spelling establishes authority.
  • Released notify8.2.0 was evaluated and deferred because its Linux/Windows worker lifetime does not expose the required joined shutdown. No new native dependency, daemon or Watchman service.

See docs/watch.md for the full contract. Application settling, retries, content-freshness policy and indexing remain with consumers.

Evidence

Qualified candidate head: 39c949e88e4de3381db008e8ab18e27faf0bce8d; tree: bea39cf60db109e87446964f0e6d8a18c90a3e5e.

  • All four attempt-1 workflows succeeded: CI 18 executed / 3 skipped, coverage 4 executed, mutation 3 executed, and benchmarks 1 executed / 2 skipped. All 26 attempted jobs' completed logs were audited; five conditional/manual skips are not passes. Method-smoke and shared pin/mode/receipt regressions passed.
  • All 14 watch files were inventoried. Per Node22/24 check and Node22 coverage run, watch pass/skip counts were Linux 69/3, macOS 37/35, Windows 39/33, with no failures. Linux Node actually executes all eight retirement and six new pin/authority tests. Unsupported platforms execute native refusal/no-worker/no-fallback and portable polling/lifecycle/scanner/alias proofs; native-only skips are scope limits, never native passes.
  • Bun1.4.2 targeted watch suites passed Linux 38/34, macOS 37/35, Windows 39/33 (pass/skip). Normal and JITless proofs on all three hosts execute native refusal plus explicit polling under auto/require/off/missing-auto. Missing-require is a hash-helper refusal, not an executed watch case. Parser/ownership mocks remain non-OS proof.
  • Ordinary suites tested merge f394a0dc04995f4511a135146b4f4f66afddef85, tree 5a6e484d91dc616c1bce6271a5a98fbb45f90034, not the candidate tree. Four baseline-file differences were recorded (native/src/clone_windows.rs, native/src/windows.rs, src/errors.ts, and the Windows readonly fallback fixture); no watch/pin delta. Installed-package jobs explicitly checked out the exact candidate head.
  • Actual Linux Node24 artifact 10863096644 and macOS Node22 artifact 10862016913 were downloaded and verified: ZIP digest/size, root+host tarball SHA512/size, exact source commit/tree and dirty:false. Full 275-file executable inventories × 16 installed receipts = 4,400 hash comparisons, including all seven watch modules and the three authority helpers, matched the actual tarballs.
  • All four npm/pnpm normal/omitted cases per artifact retain complete watchModes and recovery receipts. Linux proves labeled real-OS ENOENT → successful close → new native subscription → later native edit, with zero workers after close; the 30-second reconciliation interval exceeds the 5-second proof deadline. macOS separately proves actual Root loss → successful close → new explicitly selected polling subscription. No refusal or polling result is presented as native success.
  • Local Linux/Node26.8.2: 217 passed / 6 expected skips, 24 files. Real Root/descendant swap tests prove allowed inside native delivery, zero raw/public outside activity for matching and unknown names in bounded negative windows, and restored descriptor counts. Fresh required independent autoreview is scoped-clean at P0/P1. Local TypeScript, size, boundary, docs, script syntax and whitespace gates pass; local full check remains wasm32-clang-blocked, while hosted builds/checks succeeded.

The artifacts contain metadata version 0.19.0 as an unreleased test candidate, not an npm release or production dependency pin. Use their manifests/integrities for isolated consumer tests; do not commit local tarball paths or invent a released version. Earlier artifacts do not contain this complete repair. Platform/resource acceptance, package release and dependent OpenClaw landing remain separate.

  • Tests added or updated when behavior changed
  • Security and compatibility impact considered
  • CHANGELOG.md updated when release-relevant
  • No credentials, private paths, private hosts, or sensitive contents included

Contributor: @vincentkoc.

Work sessions


View the OpenClaw team session

@clawsweeper

clawsweeper Bot commented Sep 25, 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.

OpenClaw-Publication: 892a37e5-8597-4b13-a12e-acf75bb69f6f
Co-authored-by: vincentkoc <[email protected]>
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/fs-safe-watch-contract-20260925 branch from 8722dbd to 3503230 Compare September 25, 2026 05:58
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 25, 2026, 6:17 PM ET / 22:17 UTC (Revision 9).

ClawSweeper review

What this changes

The branch adds a Root-bound filesystem watch API with guarded advisory hints, Linux Node.js native observation, explicit portable polling, reconciliation, joined shutdown, documentation, tests, and package checks.

Merge readiness

⛔ Blocked before merge - 6 items remain

Current main and v0.19.0 lack this watch API, so the PR remains useful. The earlier native-registration finding is addressed in the current source and focused tests. Publishing the limited platform, resource, and advisory-authority contract still needs package-owner approval, and GitHub currently reports merge conflicts.

Priority: P2
Reviewed head: c5bbb25fd7a4bab9b991cb010e0f68fa5bb8e0bb
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has substantial focused validation and no established code defect; public-contract approval and merge conflicts remain.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The bot-authored PR is exempt from the contributor proof gate. Linked installed-package artifacts from the earlier 39c949e head demonstrate native readiness, injected registration failure, joined close, recovery, and explicit polling; they do not cover the latest Root-metadata and separator additions. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The bot-authored PR is exempt from the contributor proof gate. Linked installed-package artifacts from the earlier 39c949e head demonstrate native readiness, injected registration failure, joined close, recovery, and explicit polling; they do not cover the latest Root-metadata and separator additions. No stored-data contract changes.
Evidence reviewed 11 items Repository policy: The full root policy treats filesystem identity, fail-closed behavior, public exports, and package subpaths as security and compatibility contracts.
Current-main capability: Current main exports the walk subpath but has no watch subpath; the proposed observation subscription is still absent.
Release boundary: The identified latest release, v0.19.0, also lacks a watch export.
Findings None None.
Security None None.

How this fits together

The watch subsystem receives an admitted filesystem Root and caller-selected paths. It uses guarded scans and either native observation or explicit polling to send advisory invalidations that callers can follow with guarded reads.

flowchart LR
A[Admitted Root and scopes] --> B{Observation mode}
B -->|Linux Node| C[Retained directory watches]
B -->|Explicit poll| D[Timed scan]
C --> E[Guarded reconciliation]
D --> E
E --> F[Advisory invalidations]
F --> G[Caller guarded reads]
Loading

Decision needed

Question Recommendation
Should fs-safe publish this Linux Node.js native-only advisory watch API with explicit polling elsewhere and one worker plus retained descriptors per native subscription? Accept the limited contract: Approve the documented advisory semantics, platform refusal, and per-subscription resource costs for the first release.

Why: The implementation supports a coherent limited contract, but defining a new security-sensitive public package policy requires package-owner intent.

Before merge

  • Resolve merge risk (P1) - The public API defaults to native mode, which fails readiness on macOS, Windows, Bun, and unverified runtimes unless callers explicitly select polling; the package owner has not accepted this support policy.
  • Resolve merge risk (P1) - Each Linux native subscription retains a worker and directory descriptors without an aggregate pool or cap; the package owner must accept the resulting deployment resource policy.
  • Resolve merge risk (P1) - Descriptor-bound registration and guarded hints do not guarantee continuous pathname membership or a complete event history; the package owner must accept that advisory authority boundary.
  • Resolve merge risk (P1) - GitHub currently reports merge conflicts against main, so the branch needs a conflict resolution and refreshed review before landing.
  • Complete next step (P2) - Obtain package-owner approval for the documented watch contract and resolve the current merge conflicts against main before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Review surface 50 files changed The new public API spans guarded source, tests, documentation, consumer checks, and packaging.
Source and test growth production net +1110 lines, tests net +1264 lines The production growth implements a new bounded watch subsystem and is accompanied by substantial focused coverage.

Merge-risk options

Maintainer options:

  1. Accept the bounded watch contract (recommended)
    Approve the stated advisory authority limits, native support policy, and per-subscription resource cost, then resolve the merge conflicts.
  2. Defer publication
    Pause the public export while a different support or resource policy is selected.

Technical review

Best possible solution:

Publish the watch API after its package owner approves the documented platform, resource, and advisory-authority contract and the branch merges cleanly with current main.

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

Not applicable as a bug reproduction: this PR introduces an API. Source, focused tests, and earlier installed-package receipts establish the intended central behavior, with the latest scope additions covered by source and tests.

Is this the best way to solve the issue?

Yes for the stated limited contract: guarded reconciliation and retained descriptor registration form a coherent observation boundary. Whether to publish that contract is a package-owner choice.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a substantial new package capability with bounded impact and an unresolved public-contract decision.
  • merge-risk: 🚨 security-boundary: The new watcher consumes Root authority, while its lack of continuous pathname-membership guarantees needs explicit acceptance.
  • merge-risk: 🚨 availability: Unsupported native routes fail readiness, and supported native subscriptions each retain a worker and directory descriptors.
  • 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. Not applicable: The bot-authored PR is exempt from the contributor proof gate. Linked installed-package artifacts from the earlier 39c949e head demonstrate native readiness, injected registration failure, joined close, recovery, and explicit polling; they do not cover the latest Root-metadata and separator additions. No stored-data contract changes.

Evidence

What I checked:

  • Repository policy: The full root policy treats filesystem identity, fail-closed behavior, public exports, and package subpaths as security and compatibility contracts. (AGENTS.md:25, c5bbb25fd7a4)
  • Current-main capability: Current main exports the walk subpath but has no watch subpath; the proposed observation subscription is still absent. (package.json:98, bd376aee38e3)
  • Release boundary: The identified latest release, v0.19.0, also lacks a watch export. (package.json:98, b7beb3e42997)
  • New public surface: The branch adds the watch package subpath and defaults the new API to native mode; unsupported native routes fail readiness while polling must be selected explicitly. (src/watch.ts:40, c5bbb25fd7a4)
  • Registration boundary: Native registration uses the scanner's guarded directory identity to acquire a retained pin and a checked procfs descriptor path; pins are held through backend retirement. (src/watch.ts:234, c5bbb25fd7a4)
  • Latest head change: The final commit adds Root metadata observation and trailing-separator normalization with focused scope tests. Its commit patch was inspected through the GitHub commit endpoint because local partial-clone parent blobs were unavailable. (src/watch-scan.ts:24, c5bbb25fd7a4)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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 (8 earlier review cycles)
  • reviewed 2026-09-25T06:03:03.755Z sha 3503230 :: needs real behavior proof before merge. :: [P2] Document every exported watch type | [P2] Compare registration hooks with canonical paths
  • reviewed 2026-09-25T06:39:52.698Z sha 077614d :: needs real behavior proof before merge. :: [P2] Remove the Windows fixture's outside-event requirement
  • reviewed 2026-09-25T07:05:11.305Z sha 818eeb5 :: blocked before merge. :: none
  • reviewed 2026-09-25T07:19:55.918Z sha 818eeb5 :: blocked before merge. :: none
  • reviewed 2026-09-25T11:04:54.029Z sha 7d6dd4e :: needs real behavior proof before merge. :: [P1] Prevent native watchers from binding outside the admitted Root
  • reviewed 2026-09-25T11:25:08.949Z sha 041c7f0 :: needs real behavior proof before merge. :: [P1] Bind native watches to the admitted directory identity
  • reviewed 2026-09-25T12:11:26.111Z sha 39c949e :: blocked before merge. :: none
  • reviewed 2026-09-25T12:34:19.515Z sha 39c949e :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 25, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient Contributor real behavior proof is sufficient. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 25, 2026
@clawsweeper clawsweeper Bot added P1 Urgent regression or broken agent/channel workflow affecting real users now. and removed P2 Normal priority bug or improvement with limited blast radius. labels Sep 25, 2026
Fail closed on native runtimes that reopen pathnames; retain explicitly selected portable polling and preserve observation versus retirement outcomes.

Co-authored-by: vincentkoc <[email protected]>
@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. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Sep 25, 2026
@clawsweeper clawsweeper Bot removed the proof: sufficient Contributor real behavior proof is sufficient. label Sep 25, 2026
steipete added a commit that referenced this pull request Sep 26, 2026
Keep guarded Root scans authoritative, multiplex Linux advisory hints in one joined native hub, and select portable polling on unqualified platforms. Supersedes the design in #666 without changing its branch.

Co-authored-by: Vincent Koc <[email protected]>
steipete added a commit that referenced this pull request Sep 26, 2026
Keep guarded Root scans authoritative, multiplex Linux advisory hints in one joined native hub, and select portable polling on unqualified platforms. Supersedes the design in #666 without changing its branch.

Co-authored-by: Vincent Koc <[email protected]>
steipete added a commit that referenced this pull request Sep 26, 2026
Add @openclaw/fs-safe/watch with bounded advisory invalidations, literal scopes, guarded reconciliation, generation fencing, scope replacement, and joined close. Events remain hints; the admitted Root and guarded scans retain filesystem authority.

Replace the per-subscription Node Worker transport from #666 with a shared Rust hub using inotify on Linux, FSEvents on macOS, and overlapped ReadDirectoryChangesW with IOCP on Windows. The hub blocks until events or commands arrive and joins native work at retirement; portable polling remains available.

Native CI verifies real event delivery, idle cost, and bounded joined shutdown across Linux, macOS, and Windows. Linux idle proof reduced voluntary hub context switches from 994 to 0 over ten seconds; measured edit latency was about 26–28 ms. Hosted macOS and Windows event and lifecycle proofs passed without relaxing timing thresholds.

Co-authored-by: Vincent Koc <[email protected]>
@steipete

Copy link
Copy Markdown
Contributor

Superseded by #690, now merged. It keeps this PR's guarded advisory model—scopes, guarded reconciliation, generation fencing, and joined close—and replaces the Node Worker transport with a shared Rust hub on inotify, FSEvents, and ReadDirectoryChangesW.

Thank you @vincentkoc for the design and contribution. Vincent Koc is credited as co-author in the squash commit. This PR's branch is retained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. 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.

2 participants