Skip to content

improve(skills): reduce watcher work during unrelated file activity - #146309

Merged
steipete merged 2 commits into
mainfrom
codex/memory-next-runtime
Sep 12, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/memory-next-runtime

Conversation

@steipete

@steipete steipete commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

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.md filename 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

  • On Node 24.19.0/Linux, the actual callback registered by ensureSkillsWatcher handled 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.
  • The fixture asserts the actual watched parent and uses it as the raw event's 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.
  • Both original and candidate passed 63 tests across four files, with one native Windows-only case skipped on Linux: 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.
  • Targeted oxfmt, type-aware oxlint, and git diff --check passed. No new test duplicates the existing behavior contracts.
  • Canonical independent review against 7249a939db2c8d644a554ca286034df9a4b30c20 completed 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.ts gate 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.

@clawsweeper

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

@steipete
steipete marked this pull request as ready for review September 12, 2026 18:38
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Sep 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority 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. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed September 12, 2026, 3:01 PM ET / 19:01 UTC (Revision 2).

ClawSweeper review

What this changes

The 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
Reviewed head: 21edefa43ce998d8725e5480f9a01ed093c469b4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving optimization with relevant existing coverage and appropriately bounded performance claims.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. The callback benchmark directly addresses the optimization; existing native-watcher tests support behavior preservation, while the combined live workload does not isolate watcher performance.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. The callback benchmark directly addresses the optimization; existing native-watcher tests support behavior preservation, while the combined live workload does not isolate watcher performance.
Evidence reviewed 8 items Introduced change preserves filtering semantics: The complete watcher owner retains path resolution, non-stateful ignore expressions, containment, polling, debounce, and shutdown behavior. The introduced runtime hunks only reorder short-circuit predicates.
Optimization remains absent from inspected main: The comparison against fetched main shows both proposed changes remain distinct. The related closed performance issue covers model-default resolution, recipient expiry, and coordinator paths, not this watcher optimization.
Latest-release comparison: The v2026.9.4 contents API returns watcher blob 008380103d511d637b41beaca9da0d91dd8674bd, matching the pre-optimization blob in the pinned introduced diff.
Findings None None.
Security None None.

How this fits together

OpenClaw 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]
Loading

Before merge

Agent review details

Security

None.

PR surface

Source 0, Other 0. Total 0 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 6 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 2 7 7 0

Review metrics

None.

Technical review

Best 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.

Labels

Label justifications:

  • P2: This is a bounded Gateway performance improvement for busy workspaces, with unchanged user-facing refresh behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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 external-contributor proof gate does not apply to this MEMBER-authored PR. The callback benchmark directly addresses the optimization; existing native-watcher tests support behavior preservation, while the combined live workload does not isolate watcher performance.

Evidence

What I checked:

  • Introduced change preserves filtering semantics: The complete watcher owner retains path resolution, non-stateful ignore expressions, containment, polling, debounce, and shutdown behavior. The introduced runtime hunks only reorder short-circuit predicates. (src/skills/runtime/refresh.ts:391, 21edefa43ce9)
  • Optimization remains absent from inspected main: The comparison against fetched main shows both proposed changes remain distinct. The related closed performance issue covers model-default resolution, recipient expiry, and coordinator paths, not this watcher optimization. (src/skills/runtime/refresh.ts:391, e14b3ddac2e5)
  • Latest-release comparison: The v2026.9.4 contents API returns watcher blob 008380103d511d637b41beaca9da0d91dd8674bd, matching the pre-optimization blob in the pinned introduced diff. (src/skills/runtime/refresh.ts, 3a9d69db306c)
  • Re-review continuity: The previous reviewed head and current head contain the identical watcher blob, 7b641ce4a7ba3c0bcccd069fe418da976e984ef9. REST inspection established this after the local earlier-revision comparison could not retrieve its objects. The supplied previous review contains no findings or published rank-up moves. (src/skills/runtime/refresh.ts, 90bbd66564f5)
  • QA selector and landing prerequisite: The new selector exactly matches the executable test at ui/src/e2e/debug-diagnostics.e2e.test.ts:24. The PR body requests landing fix(qa): select the renamed diagnostics browser test #146323 first; a live REST read confirms that prerequisite remains open and unmerged. (qa/scenarios/ui/control-ui-health-status-models.yaml:28, 21edefa43ce9)
  • Existing observable refresh contract: Documentation promises refresh after SKILL.md changes, including initially absent roots. Inspected tests cover positive raw events, unrelated activity, missing filenames, polling, shared-root containment, shutdown, and real Chokidar missing-root creation. Tests were not executed during this read-only review. Public docs: docs/tools/skills.md. (docs/tools/skills.md:703, 21edefa43ce9)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • 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 (1 earlier review cycle)
  • reviewed 2026-09-12T18:44:29.414Z sha 90bbd66564f5409886a994a62f370807d5a2bf0b :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/memory-next-runtime branch from 90bbd66 to 21edefa Compare September 12, 2026 18:56
@steipete
steipete merged commit 6b92ac8 into main Sep 12, 2026
196 of 198 checks passed
@steipete
steipete deleted the codex/memory-next-runtime branch September 12, 2026 19:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
…penclaw#146309)

* fix(qa): select the renamed diagnostics browser test

* improve(skills): reduce watcher work during unrelated file activity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: qa-lab maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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