Repository navigation
improve(skills): reduce watcher work during unrelated file activity - #146309
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: needs changes before merge. Reviewed September 12, 2026, 3:01 PM ET / 19:01 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch rejects unrelated skill-watcher events earlier and updates a QA scenario to select its renamed diagnostics browser test. Merge readiness⛔ Needs changes before merge - 1 item remains This remains a useful, bounded optimization absent from the inspected main and latest release. No actionable correctness or security findings were found; the maintainer-protected PR should remain open. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw watches skill directories and invalidates cached skill snapshots when relevant files change. Agent preparation consumes those invalidations so subsequent turns receive refreshed skills. flowchart LR
A[Filesystem activity] --> B[Skills watcher]
B --> C{Relevant skill file?}
C -->|No| D[Discard event]
C -->|Yes| E[Containment and stability checks]
E --> F[Invalidate skill snapshot]
F --> G[Refresh on next agent turn]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Other 0. Total 0 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep the optimization within the existing watcher owner while preserving its filtering, containment, and snapshot-invalidation contracts. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug reproduction: this is a behavior-preserving optimization. Source confirms avoidable predicate work, and the body supplies a scoped callback benchmark. Is this the best way to solve the issue? Yes. Reordering existing pure checks is a narrow solution that avoids adding caches, configuration, or another refresh owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e14b3ddac2e5. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
90bbd66 to
21edefa
Compare
|
Merged via squash.
|
…penclaw#146309) * fix(qa): select the renamed diagnostics browser test * improve(skills): reduce watcher work during unrelated file activity
Related: #145579
What Problem This Solves
Busy workspaces spend avoidable CPU time and allocate temporary paths while skill watchers discard unrelated file activity. This is especially visible while a missing skill directory is watched through an existing parent directory.
Why This Change Was Made
Check the existing
SKILL.mdfilename predicate before ignored-directory scans and containment work. Actual skill changes still use the same resolved paths, ignore rules, containment checks, stability polling, and refresh lifecycle.User Impact
Unrelated file activity creates less allocation and CPU work in the Gateway's skills watcher. Skill refresh behavior stays the same.
Evidence
ensureSkillsWatcherhandled 100,000 synthetic raw events for an absent skill root watched through its existing parent. Sampled allocation fell from 324,180,152 to 83,502,392 bytes (74.2%). Median of five unprofiled iterations fell from 349.61 to 102.46 ms (70.7%). Both produced zero refreshes after a separate 500 ms settlement period.watchedPath. Chokidar registration is mocked for repeatable event delivery; this measures the production callback, not native filesystem throughput or whole-Gateway memory. End-process RSS was 495.63 versus 480.28 MiB, including imports and the test harness; this does not establish a retained-memory improvement.node scripts/run-vitest.mjs src/skills/runtime/refresh.test.ts src/skills/runtime/refresh.windows.test.ts src/skills/runtime/refresh.capacity.test.ts src/skills/runtime/refresh.missing-root.integration.test.ts. These include real Chokidar missing-root integration, positive skill changes, unrelated-file filtering, polling, missing filenames, containment, and watcher shutdown. Full command wall time was 35.45 versus 33.44 seconds; max RSS was 2625.57 versus 2560.39 MiB. These suite timings are descriptive.oxfmt, type-awareoxlint, andgit diff --checkpassed. No new test duplicates the existing behavior contracts.7249a939db2c8d644a554ca286034df9a4b30c20completed scoped-clean through P2 with no findings.Combined live follow-up
A fixed 1,000-session workload on an isolated Linux Testbox exercised both changes together against main
7249a939db2c8d644a554ca286034df9a4b30c20. Both variants completed eight real OpenAI responses, two read-tool flows, and the same control-plane, UI, history, subscription, and session activity. Independent SQLite reads verified the eight final responses exactly once before cleanup and after shutdown. Tool flows were verified through RPC history and streaming evidence.Sampled allocations were 6.612 → 6.449 GB (−2.47%), peak RSS 2,121 → 2,037 MiB (−3.96%), and post-GC load heap 354.011 → 353.517 MB (essentially flat). Wall time was 48.75 → 50.92 seconds (+4.46%). These are one-pair descriptive observations for the combined changes, not per-PR causal or retained-memory claims.
The baseline required SIGKILL after the canonical two-second graceful teardown budget; the candidate exited cleanly. Captured logs do not establish the baseline shutdown phase or root cause, and baseline final provider counters were unavailable. Consequently ordinary paired validation did not pass, despite both functional workloads passing. The baseline was not replayed; the candidate ran once. Both owned Gateway groups and the Testbox lease are stopped, and all 30 downloaded evidence files match remote hashes. Raw credentialed heap snapshots remained remote. Testbox run.
The combined local
node scripts/check-changed.mjs -- src/skills/runtime/refresh.ts src/config/sessions/session-accessor.sqlite-participant-projection.tsgate passed, including core and all 18 test type graphs, dead-export scans, targeted lint, formatting, and source guards. Both independent canonical reviews and subsequent ClawSweeper reviews found no actionable issues. Initial hosted CI failed on an unrelated stale QA scenario selector introduced on main by #146207. The independently reviewed repair #146323 is now merged on main; this branch includes that correction, and its landing prerequisite is satisfied. The optimization patch and source hash are unchanged, verified by range-diff; the local and live measurements above apply to the original pinned baseline, not the refreshed full main tree.