Repository navigation
refactor: use fs-safe for file watching and preserve Doctor plugin captures - #159226
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: blocked before merge. Reviewed September 29, 2026, 3:46 AM ET / 07:46 UTC (Revision 38). ClawSweeper reviewWhat this changesThe branch moves Config, Skills, Memory, and development file watching to fs-safe, removes Chokidar, and preserves native plugin captures during read-only Doctor inspections. Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open: current main still uses the older watchers, so the central cutover remains useful. Earlier findings appear repaired, and real behavior evidence plus successful exact-head CI support ordinary landing review. Priority: P2 Review scores
Verification
How this fits togetherFile changes feed OpenClaw's reload, skill refresh, memory indexing, and development restart flows. Doctor separately inspects plugin code and must keep native capture files usable without turning its read-only inspection into a live state write. flowchart LR
A[File edits] --> B[fs-safe observation]
B --> C{Relevant and stable?}
C --> D[Config and Skills updates]
C --> E[Memory index update]
C --> F[Development restart]
G[Doctor inspection] --> H[Retained native captures]
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Use one fs-safe observation contract while preserving each consumer's reload or indexing policy, existing polling controls, and Doctor's native-capture custody during upgrades. Do we have a high-confidence way to reproduce the issue? Not applicable to the watcher refactor. The PR reports failing-before and passing-after evidence for branch regressions, but this read-only review did not execute a current-main bug reproduction. Is this the best way to solve the issue? Yes. Shared observation with consumer-owned policy and separate Doctor capture custody fits the existing ownership boundaries; current main's earlier Doctor repair does not replace the watcher cutover. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d2811224dc0d. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (37 earlier review cycles; latest 8 shown)
|
9caed07 to
bc747d4
Compare
Match the selected builder spelling after the Synology inbound route was inlined in #160639. Preserve the existing caller inventory assertion and production behavior.
Preserve read-only and writable admission partitioning, pinned publication authority, and complete capture placement across Doctor inspections. Remove the obsolete directory-only capture context and stale runtime API classifications.
Keep primary config observation active when an unused include root is inaccessible, retry that root when it becomes selected, and raise Memory scans to the released fs-safe limits. Preserve main test pruning and the separate CI retention-census owner. Focused runtime and routing proof passes; the newly isolated hybrid packing fragmentation is repaired in the following commit.
Reuse the existing bounded exchange optimizer for final hybrid consolidation. Preserve group ownership, child worker limits and admission budgets while reducing the fs-safe composition from 80 to 78 rows. Scope exchange by backend so valid Blacksmith layouts and cap-independent plan identity stay stable.
Integrate the released dependency and current Memory owner fields. Keep healthy observation available after indexing failures, and anchor root-level config directories at the stable volume root. Preserve joined observer/provider/database cleanup. Both regressions fail on the prior source and pass after repair; real macOS native observation and the complete corrected review pass.
Stop the original subagent registry before non-isolated file cleanup retires its SQLite owners. Join accepted sweeps and cleanup tails while preserving synchronous fixture resets, successor scheduling, and the actor path guard. Await the new reset contract in the concurrency benchmark too. Baseline controls demonstrate an old registry tick recreating a retired shared-state owner and premature settlement of three in-flight retirements. The receiving candidate passes 102 owning/sibling cases, including the 17-case nested fixture (16 passed, one expected skip). The benchmark with eight child sessions also passes. The owning run took 156.42 seconds. Types, lint, formatting, export scans, and repository guards were qualified. The exact historical hosted timer schedule remains unobserved.
Keep synthetic historical runner fixtures in their explicit no-dist mode so an inherited CI prebuilt flag cannot enter package preparation before the worker-owner boundary. Preserve all six fixture modes and their assertions.
|
Merged via squash.
|
Related: #159605 (merged). Supersedes #158182. Thanks @vincentkoc.
What Problem This Solves
Config reload, Skills refresh, Memory indexing and the development supervisor maintain separate filesystem watchers. Their consolidation also exposed a Doctor bug: temporary plugin capture paths could survive a read-only inspection even though its cleanup had deleted the files.
User Impact
File edits continue to trigger reloads, refreshes and indexing through released fs-safe 0.21.2, including Bun and Node installations without its native addon. Doctor keeps loaded native plugin files usable after inspection without changing the live admission store. This introduces no configuration or stored-data migration.
Existing
CHOKIDAR_*controls remain supported. Unset, false, zero and empty polling overrides prefer native observation with polling fallback; other nonempty values force polling. Explicit polling and fallback honorCHOKIDAR_INTERVAL(100 ms default, 20 ms minimum). Native observation retains 30-second reconciliation and each consumer keeps its recovery policy.Why This Change Was Made
fs-safe owns guarded scans, backend selection, generation fencing and subscription retirement. OpenClaw retains source selection, settling, reload/indexing policy and joins for application work. The change removes 908 net production implementation lines across 42 files, excluding tests, support, tooling, comments and blanks. Main's scheduler and planner work receives no reduction credit.
Memory obtains Root admission and observation from the host SDK so captured plugins use the same fs-safe module instance. Replacement Skills subscriptions re-admit their selected directory after joined retirement; healthy scope updates retain their Root. This fixes recovery after replacing an external skill collection.
Native capture storage is separate from database authority. Doctor stores captures outside disposable database snapshots; deferred receipt publication retains the original installed-index authority. Read-only inspections cannot become writers during later cache retirement. Entirely missing obsolete namespaces can be recaptured, while active or partially missing captures still fail validation.
Evidence
Current head:
6f6d3e3915074cd0ad37ed809a970630d02e1e7c(treeec3b29cfe4132f44e0c13a11f32eb5ddf028b165), based on main7972c35315d71727cc4a387f8e5f4a21d86bbf75and its released fs-safe 0.21.2 dependency, plus canonical main teardown repair1475b6f8. Since package source71bdd822, the only changes are that canonical repair and the canonical sparse-runner fixture fixbb4573cd. Watcher, capture, update, SDK and dependency source remains byte-identical to the tested package. Current normal CI passed on this exact head: 163 successful jobs, 17 skipped, zero failures or cancellations, including all five standard Windows rows and both formerly failing shards. Earlier failed/cancelled attempts are retained below. Corrected installed-package acceptance passed on the same immutable package; the narrow receiving deltas are qualified separately, without relabeling package source. Main's Memory accessor inlining and shared batch type are preserved alongside the cutover's joined cleanup, which still retires providers and database resources when observation closure fails.The two hosted watcher findings are fixed. Unused inaccessible include roots no longer block primary Config observation; selected or ambiguous roots still propagate errors, successful aliases remain pinned, and changed selection retries admission. Memory explicitly uses the released library's ceiling of one million directories and examined entries per subscription. Larger trees retain refresh-on-search fallback; this is a finite ceiling, not unlimited observation.
Both regressions failed on the earlier code for the intended reason: unused-root
EACCES, and an actual 4,097-directory tree exceeding the default scan budget. With 0.21.2, the new Config case passed in 51 ms and the large-tree edit case in 22.036 s. The receiving owner group passed 30 cases in 262.31 s (including worker preparation), the remote-subscription close case passed in 3.724 s (127.88 s wrapper including preparation), and the hybrid cap case passed in 10.681 s (21.20 s wrapper). Types, scoped lint, formatting and whitespace checks passed.The cutover exposed fragmentation in hybrid CI packing: clean captured main fit, but the candidate produced 80 jobs against the unchanged 79 cap. Final hybrid consolidation now uses its existing bounded group-exchange optimizer, yielding 78 rows with all 277 group descriptors retained. Worker, runner, family and admission rules remain intact; row placement and timeouts derived from existing whole-config rules can change. All six unchanged packing/cap/queue/worker/serial-ownership regressions passed (13.38 s wrapper), and the focused P0–P2 review was clean. No test expectations, numeric caps or deadlines were weakened.
The full corrected integration review completed all five passes with no actionable P0–P2 findings. Its preceding assessment identified two further edge cases, both fixed: an indexing callback rejection no longer declares healthy Memory observation unavailable, and root-level Config directories use the stable volume root as observation authority. Both new cases failed on the preceding source for the intended reason and then passed; their complete owner files passed 23 tests in 77.24 s including preparation (new cases: 1 ms and 10 ms). Affected types, lint and formatting pass. Current native Windows observation and normal enforced CI both passed. Corrected installed-package proof passed; neither earlier failed attempt is counted as passing.
f07aececcontains the identical fixture patch now on this branch; this is not relabeled as final-head execution.f3274f8apassed 44 tests across seven files in 97.482 s, after the canonical build took 445.003 s. Restoring stale Skills Root inheritance failed withpath-mismatch; restoring the unrelated capture probe failed withEACCES. All 19 original hashes were restored. The current admission-view integration has its own owner proof above; this older run remains attributed to its executed source.71bdd822package with toolingdefdf2d3. Session migration, Doctor, installed identity, Gateway startup/health/status, root/include writes and atomic replacements, Skills creation, and joined cleanup passed. One initialmemory_searchwas followed by read-only SQLite chunks and real FTS observations of warm-up (1.736 s), edit (1.735 s) and deletion (1.635 s, both stores empty), without another search/index/reconcile. This establishes automatic durable convergence, not event drainage or per-event causality. Observation took 51.336 s, candidate startup 86.882 s, stop 3.311 s, and the single lane attempt 1040 s, with no timeout. The sole 93-second startup advisory concerned the older baseline; candidate startup had none. The unchanged observer/source and verified package checksum retain the original source identity. The subsequent receiving changes affect sweeper test teardown and the sparse runner fixture; review, source comparison and receiving CI qualify those separately.0bf1b920with the complete application tree bound to current head6f6d3e39. The required fs-safe 0.21.2 native addon was verified loaded. Primary/include writes and both atomic replacements delivered in 318–355 ms, all within 3.58 s, below periodic reconciliation. No manual reconciliation, fake timers, warnings, errors or post-close callbacks; the child exited naturally and removed its owned fixture. The outer Windows Vitest launcher retained its separate temporary namespace because descendant-group completion was not attested; Actions teardown owns that cleanup. No broader launcher-cleanup claim is made.6f6d3e39with fs-safe 0.21.2: one passed, zero skipped, 24.567 s body / 120.97 s wrapper (79.9 s worker preparation). Its assertions verify both mapped native images and companions after normal and nested Doctor inspections, unchanged source database bytes, and capture deletion after child exit. Source, workflow, dependencies and artifact digest were verified. The test captures its child receipt rather than printing it on success; the non-skipped passing case is the boundary evidence. The outer Vitest namespace remains explicitly owned by Actions teardown. A real child is necessary to test mapped-image lifetime; these cases use the existing integration tier.ebf752Linux scenario passed five real turns, local CLI control, canonical/worktree selection, unchanged rescans and joined shutdown in 29.596 s, retaining its 90-second case and 20-second CLI limits. Startup-owner tests passed 14 cases in 26.19 s. This remains pre-integration evidence.Failure history, review decisions and evidence limits
CI on
b6b276f4ended with 100 successful, 61 cancelled, 17 skipped and two failed jobs including the gate. Two sparse-runner fixture cases inherited the outer job's prebuilt mode and attempted to import a package-preparation helper outside their synthetic closure. Setting the same flag locally reproduced exactly two failures; clearing it preserved all six original modes and assertions. The fixture now matches canonical main fixbb4573cdexactly. The repaired inherited-mode fixture plus real prebuilt-AI siblings passed 14 cases in 8.561 s (fixture 2.538 s); normal-mode fixture plus package-admission cases passed eight cases in 4.290 s. The final canonical spelling passed six cases in 1.096 s / 3.645 s wall, with clean P0–P2 review. The complete selected static gate passed in 265.831 s. No application code, assertions, deadlines or production dependency changed. A textual conflict between equivalent cleared values was resolved to the canonical main postimage without broad main integration.CI on
71bdd822ended with 125 successful, 37 cancelled, 17 skipped and two failed jobs including the gate.server.agent.rpc-contracts.test.tsfailed during startup withShared-state worker opening path changed, surfaced as unavailable required secrets; its Config watcher had not started. An independently reproduced test-teardown defect allows an old subagent sweeper to recreate a stale shared-state worker. Canonical main repair1475b6f8now retires and joins the original sweeper before SQLite teardown; this head includes its exact 11-file patch, including the awaited benchmark reset. The correction has a clean full-context P0–P2 review, 102 owning/sibling passing cases, two failing-before causal controls and receiving fixture/lifecycle proof. The original-row Blacksmith replay passed 1,435 tests across 112 files, using the original three plans, four Node/Bun invocations, literal include order, worker limits and deadlines. Node 24.19.0 and the exact CI-pinned Bun revision matched; the former failing Gateway group passed all 219 cases. Command execution took 448.191 s, cleanup joined and the lease stopped. Its first preparation attempt ran zero tests because Bun was absent; the corrected invocation used the existing pinned CI setup action. This replay does not establish the exact historical callback timing. No reduction credit is taken for this independently landed repair. Earlier-file lifecycle effects remain possible, so source equality and the startup location alone are not claimed as proof of independence.Package Acceptance 36525423001 built and verified the current package, passed npm installation and update/package identity, then failed before watcher preparation. Its frozen tooling read only the hot session row after schema 24 had moved prompt snapshot fields into
session_entry_snapshots. The corrected tooling uses the candidate's existing hydration logic; the old reader failed five of seven schema-24 cases, while the corrected reader and siblings passed 29 cases in 10.98 s. Corrected run 36531683986 passed using the same source71bdd822package (SHA-25617677865f4390bf1c8b0c2f04db83ce0f6f46df434adb184cb552ebdf823d241) with toolingdefdf2d3. The observer, published 2026.9.6 updater, scenario and no-push image policy are unchanged. The earlier failure did not exercise watchers or establish prompt preservation. The corrected run passed migration, all selected observation stages and cleanup, as detailed above.CI on
8bea42bafailed only the stale Synology inventory assertion before fail-fast: 16 jobs succeeded, 146 were cancelled, 17 were skipped and two failed including the gate. Both affected files matched receiving main. Focused proof changed from five passing/one failing case to six passing cases (29.69 s wall). The separate eight-file local replay emitted 95 passing assertions but was interrupted during its lifecycle and exited nonzero; it is not complete green proof. The repaired head needs its normal CI run.CI on
176edf10passed the channel repair and 94 jobs overall, then failed the context test's stale strict Root identity assertion. Recovery correctly admits a new Root; all context-isolation assertions passed. The run ended with 68 cancelled, 17 skipped and two failed jobs including the gate. This head checks renewed subscription identity and removes a recovery count assertion that was already satisfied by the earlier healthy scope update. No production behavior or timeout changed.CI on
172302d3timed out the Memory filesystem case at its unchanged 120-second limit; 48 other cases in that group passed. The exact receiving-merge composition then passed all 150 cases in 118.557 s; one observational replay passed in 107.337 s. The historical timeout did not reproduce and its precise cause remains unknown. The trace did establish native reconciliations overlapping the fixture's frozen settling clock. The corrected fixture uses real polling subscriptions and explicit reconciliation, matching the Skills fixture. Real Root admission, filesystem operations, SQLite publication assertions, deadlines and cleanup are preserved; production code is unchanged. Diagnostic and final Testboxes had 8 CPUs/32 GB versus CI's 2 CPUs/8 GB.The earlier Windows collection case used backslashes to look up forward-slash registry keys. It now uses existing
toWatchRoot; the corrected case passed in 187 ms before the previous run was cancelled by the Memory failure. The whole cancelled row is not counted as passing. The original Windows installer composition separately passed 540 cases/27 skips; its healthy and stalled scripts share one PowerShell process while retaining deadlines, failure and cleanup assertions.Historical config-generation and PowerShell timeouts, plus a report-owner SIGTERM, remain recorded without invented causes. Successful replays are not claimed as fixes. The managed config-journal fixture now isolates managed writes using its existing watcher option; dedicated watcher-echo coverage remains. Independent planner contracts were separated without removing calls/assertions or increasing deadlines. Main's canonical packing fix repairs the independently reproduced 82-versus-79 hourly overflow; the formerly failing case passed in 21.526 s. Incoming fixtures use the current watcher helper, and native fixture construction was extracted unchanged to respect the existing file-length limit.
Fresh review questioned the sticky Memory unavailable flag after recovery. Main already has the identical callback and search behavior, and its old watcher resumes after reconciliation failures without clearing that flag. The cost is real but no new regression was established; this change retains the conservative fallback. A later assessment correctly distinguished a newly introduced indexing-callback error path from that pre-existing observation fallback; the extra unavailable notification is now removed, with a failing-before/passing-after recovery regression. The earlier second finding proposed releasing the development watch lock when observer retirement rejects. The actual CLI reports that failure and exits; the next invocation reclaims the dead PID's lock. There is no production caller that catches the rejection and retries within the same process. Retaining the fence until process exit avoids overlapping observers when retirement is uncertain. The review's findings result is retained, not described as a clean verdict.
CI on
fa2e8015failed the runtime API classification test after main removed the diffs and lobster runtime entrypoints. This head removes precisely those two obsolete IDs, retaining complete discovery equality and all 15 guarded export inventories. All seven guardrail cases passed. The old run remains failed/cancelled: 23 jobs succeeded, 138 were cancelled, 17 skipped and two failed including the gate.The earlier f327 package run recorded startup warnings; the newer successful 176edf1 candidate started in 75.871 s without the 90-second advisory warning. Its successful artifact omits individual observation timings, the primed-agent list and a full first-hop exit snapshot; there is no independent same-PID receipt. Earlier invalid fixture reload mode and observer budget/priming errors were repaired in proof tooling, not represented as product fixes. Original failed runs remain failed. The final probe preserves strict readiness, the original five observation predicates, the 120-second total observer budget, 30-second RPC cap, restoration and joined cleanup.
No release, tag, npm publication or registry-image publication is part of this work.