Skip to content

perf(memory): move local file watching into a shared worker - #175157

Merged
steipete merged 3 commits into
mainfrom
dbasync/memwatch3
Oct 17, 2026
Merged

steipete merged 3 commits into
mainfrom
dbasync/memwatch3

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Initial Memory file-watcher setup traverses large workspaces synchronously on the Gateway main thread. Moving indexing work off-thread did not remove this separate source of event-loop stalls.

User Impact

Local Memory directory discovery, native observation, and change settling now run in one shared file worker. Agents keep independent subscriptions and share unchanged roots. Startup still waits for watcher readiness, health and capacity remain visible, and shutdown joins native cleanup and the final worker exit.

Why This Change Was Made

The existing Memory file worker entry and MemoryFileWatcher remain the owners. Source hosts retain their configured ESM TypeScript loader when tests select a compiled worker that still imports source plugins. A local message-port transport replaces direct main-thread watcher construction; the remote stream protocol and the SQL/indexing pool are unchanged. The Gateway still owns indexing and consumes pushed dirty, settled, and health facts. No schema, public SDK, or configuration change is needed.

Accepted scheduling edges: dirty notifications arrive on the earliest message delivery instead of the same JavaScript stack; the worker can settle newer filesystem events while host indexing is running. A newer dirty event clears pending settled readiness, so host indexing stays bounded without a callback-completion handshake. Shutdown errors stay visible; only after all native close attempts finish unsuccessfully does final retirement terminate and join the worker to release remaining handles.

Removed checks: none. The superseded direct local watcher construction path is removed; filesystem admission and existing watcher recovery remain with the same owner.

Evidence

Final test-only head: 32018e562524. Final Node tests, all ordinary static/security checks, and the macOS Bun polling integration passed. PostgreSQL conformance reached its configured 30-minute job deadline with no failed assertion; it is incomplete, not passing. Completed production and update evidence below uses c5c87c1ef894, with identical production code.

Three alternating pairs used unchanged sqlharness-v3 on base a2e6a6b0f9c437989aa8cdf80d495240381f7be8 and candidate 32018e5625241a1b65093694c6905cfc596e2519. The shared SQL harness used Node 24.22.0 / SQLite 3.54.0; exact build snapshots and runtime identities were checked for every arm. Each side has 30 warmed turns. All six arms completed without SQL errors, missing causal coverage, or remaining fixture processes. The request and statement ledgers reconcile to the recorded totals.

Values below are median [min–max]: pooled individual turns for warmed values, three run totals per side for whole-workload and phase values. Causal values follow each turn across threads; raw values include background work overlapping its wall-clock window.

Measurement Base Candidate
Causal warmed statements 62 [62–63] 62 [62–63]
Causal warmed requests 18 [18–19] 18 [18–19]
Causal warmed main 0 [0–0] 0 [0–0]
Raw warmed statements 62.5 [62–96] 62 [62–96]
Raw warmed requests 18 [18–23] 18 [18–24]
Raw warmed main 0 [0–13] 0 [0–13]
Whole workload statements 3580 [3568–3580] 3589 [3559–3596]
Whole workload requests 923 [916–929] 926 [921–928]
Whole workload main 149 [149–150] 149 [149–151]

Watcher SQL / requests / T1: 0 / 0 / 0 → 0 / 0 / 0. Global T1: 182 → 182. This moves filesystem work off MAIN; it does not claim SQL savings.

Native watcher scale

All six scale probes used Node 26.12.0 on both sides, independently of the Node 24 shared SQL harness. The outer Node 24 hash receipt does not attest the child Node 26 libraries. Each probe completed all nine lifecycle phases with ready native observation, matching directory counts, root-replacement notifications, and zero owners after shutdown. The sizes below count ordinary files in the primary root; each setup also includes a secondary root with N/10 ordinary files. Both roots additionally include 24 deep files, three sparse files, and symlinks.

Primary-root ordinary files Initial MAIN sync-fs calls M → C MAIN event-loop p99 ms M → C MAIN event-loop max ms M → C Readiness seconds M → C
1,000 38,930 → 3 27.738 → 12.124 36.602 → 15.286 1.303 → 15.716
10,000 316,058 → 3 15.163 → 16.646 35.029 → 36.504 5.172 → 26.327
50,000 1,548,096 → 4 23.708 → 15.991 159.908 → 104.858 29.152 → 48.856

Candidate MAIN native watcher calls and SQL were zero throughout. Profiles used --cpu-prof; the historical 113-second MAIN stall was not reproduced. Timing is descriptive on a busy host: this is evidence of filesystem work moving off MAIN, not faster readiness or reduced total filesystem work.

Per-run, phase, shared-read-family, and lifecycle measurements

Background MAIN lease reads and memory corpus-inventory requests are recorded separately below. Lease reads can move between the first-turn and warmed windows without adding work. Corpus-inventory request counts distinguish transport calls from the number of calls that actually execute snapshot SELECTs.

Arm Whole MAIN lease SELECTs Warm-window MAIN lease SELECTs Memory corpus-inventory requests
pr1-M1 13 13 4
pr1-C1 13 13 4
pr1-M2 13 0 4
pr1-C2 13 13 4
pr1-M3 13 13 4
pr1-C3 13 13 4

Per-run warmed results

Arm Causal SQL Causal requests Raw SQL Raw requests Raw MAIN
pr1-M1 62 [62–63] 18 [18–19] 63 [62–96] 18 [18–23] 0 [0–13]
pr1-C1 62 [62–63] 18 [18–19] 62.5 [62–82] 18 [18–24] 0 [0–9]
pr1-M2 62 [62–63] 18 [18–19] 62.5 [62–66] 18 [18–21] 0 [0–0]
pr1-C2 62 [62–63] 18 [18–19] 62 [62–80] 18 [18–22] 0 [0–9]
pr1-M3 62 [62–63] 18 [18–19] 62 [62–83] 18 [18–23] 0 [0–9]
pr1-C3 62 [62–63] 18 [18–19] 62 [62–96] 18 [18–23] 0 [0–13]

Shared read-family attribution

Counts identify executed SELECT/WITH statements by owner stack, including callbacks in pinned source ranges when deep stacks truncate the outer name. Requests count unique causal request IDs containing those reads; nested families may overlap. Zero means no executed read, not that the in-memory owner function was never called. All five families also have zero causal and raw warmed requests on both sides.

Family Causal warm SQL M → C Raw warm SQL M → C Whole SQL M → C Whole requests M → C
exact-entry facts 0 [0–0] → 0 [0–0] 0 [0–0] → 0 [0–0] 23 [23–23] → 23 [23–24] 23 [23–23] → 23 [23–24]
actor hydration 0 [0–0] → 0 [0–0] 0 [0–0] → 0 [0–0] 10 [10–10] → 10 [10–10] 5 [5–5] → 5 [5–5]
entry-cache snapshot loads 0 [0–0] → 0 [0–0] 0 [0–0] → 0 [0–0] 20 [19–20] → 21 [20–22] 12 [11–12] → 12 [12–13]
row facts 0 [0–0] → 0 [0–0] 0 [0–0] → 0 [0–0] 12 [12–12] → 12 [12–12] 5 [5–5] → 5 [5–5]
watermark reads 0 [0–0] → 0 [0–0] 0 [0–0] → 0 [0–0] 4 [4–4] → 4 [4–4] 3 [3–3] → 3 [3–3]

C2 executed two snapshot SELECTs in its existing shadow-rebuild corpus request (66211:0:642); that request executed zero SQL in M1, C1, and M2. This is a cache miss/invalidity reload on an already-used worker, not a new transport request. The relevant cache/indexing source is identical. A sibling row-transcript write overlaps the earlier read, but retained ledgers do not record receipt values or completion ordering. The exact invalidating write and any indirect watcher-scheduling contribution cannot be established. The cold difference is disclosed rather than classified as generic noise.

C3 likewise executes two snapshot SELECTs in the existing compaction shadow-rebuild request (56562:0:636, worker 17), versus zero in M3. C3 also has one extra exact-entry SELECT in background request 56562:0:132 during the first-turn window (worker 16): session-transcript.worker.ts:345 calls readExactSessionEntriesWithLifecycle. Its retained origin stack contains queued worker-pool dispatch rather than the higher-level caller. The ordinary turn-scoped retained-facts read exists on both sides. These are cold differences with unresolved higher-level scheduling attribution; the measurements do not establish zero cold SQL cost or exclude an indirect watcher effect.

Raw phase attribution

Warm windows are summed per run here. Compaction and settle are combined because memory first-use work can cross that boundary.

Phase SQL base → candidate Requests base → candidate MAIN base → candidate
01.boot 333 [333–336] → 334 [333–351] 89 [89–90] → 89 [89–94] 63 [63–64] → 63 [63–64]
01.connect 94 [90–240] → 50 [43–242] 25 [21–26] → 20 [18–21] 0 [0–0] → 0 [0–0]
02.first-turn 474 [348–506] → 509 [337–523] 104 [94–111] → 107 [99–109] 0 [0–13] → 0 [0–0]
03.warmed windows (sum) 661 [629–662] → 659 [657–662] 186 [184–188] → 186 [185–188] 13 [0–13] → 13 [13–13]
04.second-session 507 [506–508] → 508 [506–512] 134 [134–134] → 134 [134–135] 0 [0–0] → 0 [0–0]
05.control-plane 7 [7–7] → 7 [7–9] 1 [1–1] → 1 [1–1] 0 [0–0] → 0 [0–0]
06.cron 277 [277–277] → 276 [275–279] 73 [73–73] → 73 [73–74] 0 [0–0] → 0 [0–0]
07.compaction + settle 393 [391–404] → 397 [394–397] 58 [55–61] → 58 [58–58] 0 [0–0] → 0 [0–0]
07.idle-connected 142 [131–143] → 141 [141–141] 49 [46–50] → 49 [49–50] 0 [0–0] → 0 [0–0]
08.shutdown 26 [26–26] → 26 [26–26] 6 [6–6] → 6 [6–6] 7 [7–7] → 7 [7–7]
09.restart-boot 342 [342–343] → 345 [343–351] 103 [103–103] → 102 [100–105] 59 [59–59] → 59 [59–60]
09.restart-connect 57 [48–58] → 58 [46–67] 21 [20–24] → 25 [22–26] 0 [0–0] → 0 [0–0]
10.restart-first-turn 238 [217–240] → 229 [220–231] 70 [66–71] → 69 [65–70] 0 [0–0] → 0 [0–0]
11.restart-shutdown 26 [26–30] → 30 [26–30] 6 [6–7] → 7 [6–7] 7 [7–7] → 7 [7–7]

50k per-operation MAIN filesystem calls

Operation Base Candidate
01.setup-two-roots 1,548,096 4
02.setup-shared-root 200 2
03.retire-shared-member 0 0
03a.expand-shared-root-selection 1,404,582 2
03b.contract-shared-root-selection 1,403,905 0
04.retire-last-members 1 0
05.recreate-and-switch-agent-workspace 1,548,061 2
06.workspace-replacement 520 0
07.shutdown 0 0

Candidate MAIN native-watcher calls and SQL statements are zero in every scale phase. Remaining initial MAIN filesystem calls are two realpathSync calls and one or two writeSync calls. Worker diagnostics confirm native observation moved to the worker. CPU profiles were collected with --cpu-prof, summarized, and deleted with the synthetic fixtures.

These event-loop observations are descriptive on a busy host. No wall-time speedup or reduced total filesystem-work claim is made: source-launch readiness was slower with cold worker loading. The historical 113-second MAIN stall was not reproduced.

Focused proof covers client ordering, readiness, callback context, shared subscriptions, worker failure, joined cleanup, and native file edits. At c5c87c1ef894, all 22 cases across the six changed test files passed in Linux CI, including the real Node Worker integration. That integration also passed on macOS Node 24. All 22 local reload tests passed: five live Memory reload cases and 17 service lifecycle cases. The existing 41-case watcher coverage also passed in CI, along with the remote worker and watcher configuration tests. Knip completed: all eight production and six full-tree findings match exact file/export tuples on recent main bbb775bd (run 39006528379/job 117320109233), with identical source/config/lock/scanner inputs. The script scan has zero findings; no new unused export was introduced.

The worker migration exposed a fixture boundary: the shared indexing fixture mocked filesystem observation only inside Vitest, while real Workers bypassed that mock. The fixture now retains in-process observation; separate integration tests exercise the real transport. All four failing indexing scenarios pass locally with unchanged assertions, including both captured-session vector variants. Bun integration explicitly selects supported polling; the installed filesystem dependency does not support Bun native event callbacks. Node retains required native-event coverage. The macOS Bun polling integration passed with the same shared-worker, edit-observation, and joined-exit assertions.

Both Codex autoreview rounds completed: round 1 scoped-clean through P2 and round 2 scoped-clean through P1. Follow-up changes repaired type/format/mock-export findings, preserved the configured source-host ESM loader in compiled workers importing source plugins, and corrected controlled test fixtures. No additional review rounds were run.

Final-head CI run 39010620192 passed all selected Node tests, type-aware lint, production/test types, source contracts, docs, Madge (zero cycles), T1 (182 → 182), compatibility inventory (10 → 10), every dialect class (0 → 0), and security checks. PostgreSQL conformance job 117332467074 passed its 49-file/296-case infrastructure group and preceding groups (70, 6, and 1 cases), then reached the configured 30-minute job deadline during Doctor command testing without a failing assertion. The four failures from the earlier candidate all passed on this run; the test-only change is not claimed to have fixed their root causes. Recent main job 117320108759 also reached that deadline. Landing uses the authorized relaxed-v4 deadline exception; PostgreSQL conformance and the aggregate gate remain incomplete/cancelled and failed respectively, not green.

The published-driver update cell passed against c5c87c1ef894, whose production code is identical to the final head. Earlier unrelated remote-exec missing-worker failures also occurred on recent main and do not recur in final CI. The separate npm 12 package-acceptance job installed successfully but exceeded the existing file-count budget; main run 38874597379/job 116891947806 has the same failure class. This establishes inheritance of the failure, not an exact-base file-count delta.

Current diff: production +473/−21 (net +452), tests +799/−0, docs +7/−0. The added code provides the shared local transport and its lifecycle; it does not duplicate filesystem observation or move watchers into the SQL task pool.

Follow-up from the automatic GitHub review (P2): after an unexpected shared-worker failure, the transport currently retains its failure for the Gateway process lifetime, even after the final subscriber closes. Managers mark observation unavailable and memory dirty; a Gateway restart restores automatic observation. Allowing a fresh transport after the failed worker is joined and every subscription retires is deferred under the requested two-round review limit. Normal retirement and reload recreate the worker and are covered above.

Keep readiness, health, dirty delivery and joined retirement with the existing MemoryFileWatcher owner. Reuse the Memory worker entry with a local transport while indexing remains host-owned. Native scale, warm non-regression and CI proof are pending.
@clawsweeper

clawsweeper Bot commented Oct 17, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T06:41:53.296092Z 32018e5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core size: XL labels Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR moves local Memory filesystem discovery, observation, and settling into one shared worker while keeping indexing on the Gateway.

Example: Two agents watch the same memory directory containing 50,000 files.

  • Before: Filesystem observation runs on the Gateway thread, where directory traversal can delay other work.
  • After: A shared worker runs observation and sends each agent dirty notifications, settled changes, and health facts.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The direction is useful and ownership remains coherent, but two concrete repairs remain and successful execution evidence is pending.
Proof confidence 🦪 silver shellfish (2/6) The ordinary contributor proof gate is exempt for this maintainer-authored PR; its body still marks native scale measurements and execution pending, and CI annotations establish failures rather than a successful after-fix run.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Large Memory trees can stall unrelated Gateway work while filesystem observation traverses directories.
Reason: The maintainer-authored direction addresses measured residual work, reuses existing owners, and adds no user configuration or persisted format.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep open: moving filesystem observation off-thread addresses a documented Gateway stall source, but failed-transport recovery and the shared manager test fixture need repair.

Priority: P2
Reviewed head: dac4cda68028b0056e8ab2a1e2497c0cfca64f2f

Before merge

  • [P2] Release the failed singleton after its worker exits (P2) - After a worker startup error or unexpected exit, remove() takes this branch and join() rejects without clearing owner.transport. Every later LocalMemoryFileWatcher therefore reuses the dead transport and add() throws the old error, including watchers for newly created agents or a subsequent in-process lifecycle. The new replacement test explicitly pins this permanent failure. Once physical exit is confirmed, release the global transport slot while preserving rejected close results on the affected instances; a future watcher should be able to create a fresh worker.
  • [P2] Migrate the shared manager fixture across the worker boundary (P2) - Switching every local manager to this proxy leaves the shared indexing fixture behind: test-runtime-mocks.ts still mocks file-access-runtime in the Vitest process to suppress physical observation, but that mock cannot reach the new worker. The patch adapts three watcher suites individually while manager-index.test-support.ts consumers still launch uncontrolled real workers. Exact-head CI reports worker exit failures during keyword retrieval, temporal ranking, shadow-write, and chunking-upgrade manager preparation. Update the shared explicit-sync fixture to retain its controlled observation contract, as the adapted watcher suites do, and keep actual worker execution in the dedicated integration test.

Findings

  • [P2] [P2] Release the failed singleton after its worker exits — extensions/memory-core/src/memory/local-file-watcher.ts:79-81
  • [P2] [P2] Migrate the shared manager fixture across the worker boundary — extensions/memory-core/src/memory/manager-watch-ops.ts:72

Tests

  • Missing end-to-end proof: The posted evidence contains no completed large-tree Gateway run demonstrating off-thread observation, edit-driven indexing, and joined shutdown at this head.
Agent review details

How this fits together

Memory managers send workspace paths and watcher settings through a local message port; the existing MemoryFileWatcher observes files and returns facts that drive Gateway-owned indexing.

flowchart LR
  A[Memory managers] --> B[Local watcher proxies]
  B --> C[Shared file worker]
  C --> D[MemoryFileWatcher]
  D --> E[Filesystem observation]
  C --> F[Dirty and health facts]
  F --> A
Loading

Technical review

Best possible solution:

Keep the shared-worker design, release exited transports for future watcher instances, and migrate the shared manager fixture to the new observation boundary.

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

Current main constructs observation on the Gateway thread, and prior measured evidence establishes remaining initial-scan work; the failed-transport path is source-reproducible and existing manager failures appear in exact-head CI annotations.

Is this the best way to solve the issue?

Reusing the existing watcher inside a shared file worker is a focused solution that preserves root sharing and host-owned indexing, provided failure retirement and test fixtures complete the cutover.

Full review comments:

  • [P2] [P2] Release the failed singleton after its worker exits — extensions/memory-core/src/memory/local-file-watcher.ts:79-81
    After a worker startup error or unexpected exit, remove() takes this branch and join() rejects without clearing owner.transport. Every later LocalMemoryFileWatcher therefore reuses the dead transport and add() throws the old error, including watchers for newly created agents or a subsequent in-process lifecycle. The new replacement test explicitly pins this permanent failure. Once physical exit is confirmed, release the global transport slot while preserving rejected close results on the affected instances; a future watcher should be able to create a fresh worker.
    Confidence: 0.99
  • [P2] [P2] Migrate the shared manager fixture across the worker boundary — extensions/memory-core/src/memory/manager-watch-ops.ts:72
    Switching every local manager to this proxy leaves the shared indexing fixture behind: test-runtime-mocks.ts still mocks file-access-runtime in the Vitest process to suppress physical observation, but that mock cannot reach the new worker. The patch adapts three watcher suites individually while manager-index.test-support.ts consumers still launch uncontrolled real workers. Exact-head CI reports worker exit failures during keyword retrieval, temporal ranking, shadow-write, and chunking-upgrade manager preparation. Update the shared explicit-sync fixture to retain its controlled observation contract, as the adapted watcher suites do, and keep actual worker execution in the dedicated integration test.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 82d97d2fada9.

Provenance checked

  • Standalone watcher and packaged Memory worker keeps the original intent (refactor(memory): let file watching run without an index #152631: Separate filesystem watching from indexing so local managers and workspace workers can reuse one implementation; the packaged worker followed in feat(memory): read and update files on remote workspaces #153124.)
  • Shared roots and unchanged-selection reuse keeps the original intent (68166d8: Avoid repeated scans of common roots while preserving individual selections, failure isolation, and joined final close; subsequent unchanged-selection reuse remains intact.)
  • Dirty delivery and indexing completion changes intended behavior with a stated reason (9b19fe8: Preserve edits arriving during indexing and join accepted work; this PR explains its asynchronous notification delivery and newer-dirty invalidation of queued settled readiness.)

Testing

Proof path: none.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test extensions/memory-core/src/memory/local-file-watcher.test.ts --maxWorkers=1
  • pnpm test extensions/memory-core/src/memory/local-file-watcher.integration.test.ts --maxWorkers=1
  • pnpm test extensions/memory-core/src/memory/manager-keyword-retrieval.test.ts extensions/memory-core/src/memory/manager-temporal-ranking.test.ts extensions/memory-core/src/memory/manager-shadow-write.test.ts extensions/memory-core/src/chunking-upgrade-real-transport.test.ts --maxWorkers=1
  • pnpm check:changed
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 1c09c1c adds extensions/memory-core/src/memory/file-watcher.ts:130 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1c09c1c3f064; files: extensions/memory-core/src/memory/file-watcher.ts)
  • Eric Cai: Raw commit 68166d8 adds extensions/memory-core/src/memory/file-watcher.ts:130 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 68166d8e61e9; files: extensions/memory-core/src/memory/file-watcher.ts)
  • Vincent Koc: Raw commit 9b19fe8 adds extensions/memory-core/src/memory/manager-watch-ops.ts:71 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9b19fe8e296f; files: extensions/memory-core/src/memory/manager-watch-ops.ts)

PR surface

Source +435, Tests +753, Docs +7. Total +1195 across 15 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 8 451 16 +435
Tests 6 753 0 +753
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 1211 16 +1195

Review metrics

Metric Value Why it matters
Production versus test LOC Production +451/-16; tests +753 Growth implements the local message transport and lifecycle while retaining one filesystem observation owner; the tests cover distinct client, server, and native-worker boundaries.

Labels

Label changes:

  • add P2: This is a useful performance improvement with focused transport-recovery and test-fixture defects; search-triggered refresh remains available after watcher failure.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This is a useful performance improvement with focused transport-recovery and test-fixture defects; search-triggered refresh remains available after watcher failure.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 17, 2026, 1:48 AM ET / 05:48 UTC.

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Oct 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 32018e5625

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +85 to +88
async remove(id: number, retired: Promise<void>): Promise<void> {
if (this.failure) {
this.subscriptions.delete(id);
return this.waitForExit();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear the failed transport after its final subscriber exits

When the shared worker emits an error or exits unexpectedly, this early return deletes the subscription but never clears owner.transport. After the final watcher closes, every later LocalMemoryFileWatcher.start() reuses that failed singleton and add() immediately rethrows the old error, permanently disabling automatic local-memory observation for the rest of the Gateway process even though the worker has exited. Clear the owner after the failed worker is joined and the last subscription is removed so a later manager can start a replacement.

AGENTS.md reference: AGENTS.md:L7-L9

Useful? React with 👍 / 👎.

@steipete

Copy link
Copy Markdown
Contributor Author

Follow-up from the P2 automatic review: allow a replacement local watcher transport after an unexpectedly failed worker has exited and its final subscription retires. Current failure handling marks observation unavailable and memory dirty, retains the failed join, and requires a Gateway restart to restore automatic observation. Normal retirement/reload recreates the worker and passed the live lifecycle tests. This remains a follow-up under the requested two-round review limit; no third review or additional recovery mechanism is added in this PR.

@steipete
steipete merged commit 62ff6da into main Oct 17, 2026
138 of 142 checks passed
@steipete
steipete deleted the dbasync/memwatch3 branch October 17, 2026 07:21
steipete added a commit that referenced this pull request Oct 17, 2026
…175353)

The real Memory fixture imports its runtime directly into Vitest, while the
Gateway test environment disables bundled discovery. After #175157 moved
local file observation into the existing Memory worker, that worker could
not resolve memory-core/worker-api.js and agent deletion failed.

Prepare discovery at the shared fixture owner. Clear the disable override
and select the same validated source public-artifact tree as its runtime
import, so a prepared worker cannot borrow an unrelated older dist API.
The existing Vitest environment cleanup restores both scoped overrides.
Keep the real worker and every deletion, survivor-manager, custody and
shutdown assertion. Production discovery and disable policy are unchanged.

The unchanged current-main product proof reproduced the missing public
surface: one case passed and one failed (211.32s wrapper).

Final proof: all three shared-fixture consumer files pass 8/8 through the
native Gateway configs with --maxWorkers=1 (401.68s wrapper, 387.56s Vitest;
52% transformation). The formerly failing external-state deletion takes
15.137s. Source artifact resolution is exercised with older built artifacts
still present; no rebuild or deletion was used to make it pass.

Gateway-server and Gateway-methods test types (10.4s/10.2s), lint, boundary
lint, formatting, git diff --check, and P0-P2 autoreview pass. The mock-export
guard passes without changing its baseline. No retries, skips, timeouts,
production code, or CI dispatches/reruns were added.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
Move local directory discovery, native observation, and settling into one shared dedicated Memory file worker. Preserve independent subscriptions, same-root sharing, readiness, health/capacity reporting, dirty notifications, and joined shutdown. Indexing retains its existing owner.

Preserve the source-host ESM loader when compiled workers import source plugins. Keep controlled filesystem fixtures in-process and exercise native transport separately.

Validation: native macOS and Linux Node worker integration, macOS Bun polling integration, watcher owner coverage, 22 reload cases, final CI types/lint/contracts/ratchets, and published-driver update. PostgreSQL passed all observed assertions before its 30-minute job deadline; accepted under the authorized deadline exception. Knip findings exactly match recent main. Owner SQL, requests, and T1 remain zero; this change targets main-thread filesystem work.

Follow-up: an unexpected shared-worker failure remains sticky until Gateway restart; normal retirement/reload recreates the worker.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…penclaw#175353)

The real Memory fixture imports its runtime directly into Vitest, while the
Gateway test environment disables bundled discovery. After openclaw#175157 moved
local file observation into the existing Memory worker, that worker could
not resolve memory-core/worker-api.js and agent deletion failed.

Prepare discovery at the shared fixture owner. Clear the disable override
and select the same validated source public-artifact tree as its runtime
import, so a prepared worker cannot borrow an unrelated older dist API.
The existing Vitest environment cleanup restores both scoped overrides.
Keep the real worker and every deletion, survivor-manager, custody and
shutdown assertion. Production discovery and disable policy are unchanged.

The unchanged current-main product proof reproduced the missing public
surface: one case passed and one failed (211.32s wrapper).

Final proof: all three shared-fixture consumer files pass 8/8 through the
native Gateway configs with --maxWorkers=1 (401.68s wrapper, 387.56s Vitest;
52% transformation). The formerly failing external-state deletion takes
15.137s. Source artifact resolution is exercised with older built artifacts
still present; no rebuild or deletion was used to make it pass.

Gateway-server and Gateway-methods test types (10.4s/10.2s), lint, boundary
lint, formatting, git diff --check, and P0-P2 autoreview pass. The mock-export
guard passes without changing its baseline. No retries, skips, timeouts,
production code, or CI dispatches/reruns were added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: memory-core Extension: memory-core P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant