Repository navigation
fix(anthropic): retry unavailable catalog watch on elapsed time - #192144
wangmiao0668000666 wants to merge 5 commits into
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 maintainer review before merge. What this changesMeasures Anthropic catalog watcher retry deadlines with monotonic elapsed time instead of wall-clock time. Example: An unavailable catalog watcher encounters a one-hour clock rollback.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current-main retry defect with a focused change; no actionable correctness or security findings remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherClaude CLI and Desktop catalog readers consume dirty-directory information from a shared watcher owner, which manages fs-safe subscriptions and requests full scans while coverage is unavailable. flowchart LR
A[CLI catalog reader] --> C[Dirty directory watcher]
B[Desktop catalog reader] --> C
C --> D[Elapsed retry deadline]
C --> E[fs-safe subscription]
E --> F[Filesystem changes]
C --> G[Dirty names or full scan]
Technical reviewBest possible solution: Keep the existing watcher owner and use performance.now consistently for its process-local retry deadline. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the wall-clock-sensitive retry path, and the contributor supplies discriminating base-failure/candidate-success output; no target code was executed during this review. Is this the best way to solve the issue? This is the smallest complete repair: both deadline producers and their comparison use the same monotonic clock, with one distinct rollback regression and no new production machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c230ae5c3c46. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource 0, Tests +39, Other +2. Total +41 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed November 5, 2026, 8:21 AM ET / 13:21 UTC (Revision 4). |
deef784 to
a613557
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
a613557 to
48709a1
Compare
|
@clawsweeper re-review Rebased onto |
|
🦞👀 Re-review progress:
|
48709a1 to
2371ffd
Compare
|
@clawsweeper re-review Updated the branch via GitHub update-branch to merge the latest main (head |
|
🦞👀 Re-review progress:
|
The catalog tree watch arms its restart backoff with Date.now(), so a wall-clock correction can postpone or accelerate the retry: rolling the clock back keeps an unavailable watch un-retried (every read degrades to a full rescan), while a forward step retries early. Measure the 5s retry deadline with performance.now(), matching the elapsed-time sweep shape (openclaw#191606).
The main-line fs-safe WatchSubscription requires setScopes and Symbol.asyncDispose, and WatchHealth requires mode and directories. Fill the mock so check-test-types passes.
15bccea to
6b4e6e8
Compare
|
Closing to free PR queue capacity (author has >20 active PRs per barnacle policy). This fix remains valid; can be reopened/resubmitted once queue is under the limit. |
What Problem This Solves
The Anthropic catalog's
createDirtyDirectoryWatcharms its restart backoff withDate.now(). When a watch becomes unavailable (health callback or start failure), it recordsretryAt = Date.now() + 5_000and only restarts onceDate.now() >= retryAt. A wall-clock correction can distort that elapsed-time budget: rolling the clock back keeps an unavailable watch un-retried indefinitely (every catalog read degrades to a full rescan), while a forward step retries early and churns subscriptions.Precedent: #191606 (same elapsed-TTL-vs-wall-clock shape; this PR is the same shape at the remaining Anthropic tree-watch site).
Why This Change Was Made
The tree-watch owner (
createDirtyDirectoryWatchinsession-catalog-tree-watch.ts) writes and compares a single in-memory retry deadline withDate.now()in three spots (health-callback, start-catch, and thetakeDirtyre-check). The deadline is an elapsed-time budget and is switched toperformance.now(), matching the clock-sweep already merged for sibling extensions in #191606. No validator, option, config, or persistence policy is added or changed.Production LOC is
+2/-2, net 0.Classification:
behavior-completingUser Impact
A wall-clock correction no longer postpones or accelerates watch restart after an unavailable/failed filesystem watch. The five-second retry backoff fires on schedule regardless of NTP/manual clock changes; recovered coverage is re-established as before.
Evidence
Exact-head proof receipt
a6135571c9927fabe906cfd1c334a3b346f8be510bb438485084d55ff7c760b4f5ad3f79b16346e2createDirtyDirectoryWatch(extensions/anthropic/session-catalog-tree-watch.ts)takeDirtyretry check insession-catalog-tree-watch.ts:75performance.now() >= retryAt(watch restart backoff)observation.watchcall count (retry re-attaches the subscription)retries an unavailable watch on elapsed time even when the wall clock rolls backFAILS (rollback keeps the watch un-retried), 2/3invalidates catalog reads at depth 2/3 and recovers lost coveragetests still pass with forward-only clock stepsuseAutoCleanupTempDirTracker; no production Gateway/session/token/config touchedInspectable RED -> GREEN terminal trace
The test drives both clocks independently:
performance.now()(elapsed, advanced past the 5s retry window) andDate.now()(wall clock, rolled back an hour), with a watch that reportsunavailable, and asserts the retry re-attaches the subscription only when the elapsed deadline has passed.Real-subscription recovery trace
A real filesystem subscription drives the same unavailable->recover path (no mock):
createDirtyDirectoryWatchwatches a real directory, removing the root makes the real fs-safe watch reportunavailable, a one-hour backwardDate.now()step does not postpone the elapsed retry, and the rebuilt root re-attaches coverage.takeDirty()returning an emptySet(instead of the blanket"all") proves the subscription recovered coverage after the elapsed retry deadline — a real watcher, real file system, real invalidation, no mock.Verification
node scripts/run-vitest.mjs run extensions/anthropic/session-catalog-tree-watch.test.ts(Node 24.18, docker) — 3/3 passed on headgit diff --check upstream/main...HEADunavailablehealth, rebuild re-attaches coverage after the elapsed deadline). The wall-clock rollback is applied only in-process toDate.now(); the host/system clock is untouched.Scope and risk
+2/-2+39/-2performance.now()elapsed-time pattern from fix(cache): keep private cache TTLs on elapsed time #191606; no new helper, validator, or API surface