Repository navigation
fix(anthropic): measure session catalog TTLs against monotonic time - #192122
wangmiao0668000666 wants to merge 3 commits into
Conversation
The Anthropic session catalog keys its hard-scan, desktop-overlay, and CLI-scan deadlines with Date.now(), so a wall-clock correction (NTP step or manual change) can stretch or shorten the five-minute tree backstop, letting stale sessions linger or forcing needless rescans. Use performance.now() for all elapsed-time TTLs, matching the established clock-sweep shape (openclaw#191606) already applied to sibling extensions. Co-Authored-By: nebulacoder-v8.0 <[email protected]>
|
🦞👀 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 real behavior proof before merge. What this changesThis PR measures Anthropic session-catalog cache deadlines with monotonic time so wall-clock corrections do not alter their duration. Example: The wall clock rolls back one hour while 300,001 milliseconds elapse after caching ttl-session.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this PR fixes a source-verifiable cache-expiry defect still present on current main, with no identified correctness defect in the patch. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe Anthropic plugin scans local Claude transcripts and Desktop metadata, caches their catalog records, and returns session pages through the Gateway catalog RPC. flowchart LR
A[Gateway catalog RPC] --> B[Anthropic catalog provider]
B --> C[Project tree snapshot]
C --> D[CLI record cache]
B --> E[Desktop overlay cache]
D --> F[Merged session page]
E --> F
Technical reviewBest possible solution: Keep the focused monotonic-clock substitutions in the existing cache owners while preserving watcher invalidation, refresh intervals, and persisted timestamps. Do we have a high-confidence way to reproduce the issue? The current-main deadline comparisons establish the rollback failure, and the contributor reports the committed ghost-entry regression failing on the base and passing on the head; this review executed no target code. Is this the best way to solve the issue? The invariant is that elapsed cache budgets use one monotonic clock for every write and comparison; replacing the seven reads is the smallest complete fix and needs no new helper or state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a29b8d3b84df. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource 0, Tests +29. Total +29 across 5 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label 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 HistoryReviewed November 3, 2026, 7:32 PM ET / November 4, 2026, 00:32 UTC (Revision 3). |
Co-Authored-By: nebulacoder-v8.0 <[email protected]>
readDesktopOverlay now keys its sixty-second refresh backstop on performance.now(), so the Desktop overlay test's clock mock must follow; the Date.now() mock no longer advances the deadline. Co-Authored-By: nebulacoder-v8.0 <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Added a running-Gateway @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…192469) fix: measure three more cache and retry deadlines with the monotonic clock Three more deadlines used the wall clock: the Claude catalog filesystem scan cache, a browser extension cache with a 5-minute expiry, and Feishu streaming fallback retry. After the clock moved, they expired early or too late. They now use the monotonic clock. Behavior without a clock change is unchanged. This sweep includes #192122, #192422 and #192308, with the contributors' commits kept for credit. Evidence: built shipped entry points, stepping only the process wall clock (no system clock change). Each member was wrong on main twice and right with this change twice, with no-step controls: real Claude catalog filesystem scans; real Chromium with an unpacked extension and a 301-second real expiry; and a signed Feishu webhook with real agent dispatch and a natural streaming HTTP 400 fallback with a 61-second real retry. Details: #192469 (comment). Thanks @wangmiao0668000666. Co-authored-by: wangmiao0668000666 <wangmiao0668000666> Co-authored-by: nebulacoder-v8.0 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#192469) fix: measure three more cache and retry deadlines with the monotonic clock Three more deadlines used the wall clock: the Claude catalog filesystem scan cache, a browser extension cache with a 5-minute expiry, and Feishu streaming fallback retry. After the clock moved, they expired early or too late. They now use the monotonic clock. Behavior without a clock change is unchanged. This sweep includes openclaw#192122, openclaw#192422 and openclaw#192308, with the contributors' commits kept for credit. Evidence: built shipped entry points, stepping only the process wall clock (no system clock change). Each member was wrong on main twice and right with this change twice, with no-step controls: real Claude catalog filesystem scans; real Chromium with an unpacked extension and a 301-second real expiry; and a signed Feishu webhook with real agent dispatch and a natural streaming HTTP 400 fallback with a 61-second real retry. Details: openclaw#192469 (comment). Thanks @wangmiao0668000666. Co-authored-by: wangmiao0668000666 <wangmiao0668000666> Co-authored-by: nebulacoder-v8.0 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
The Anthropic session catalog keys its hard-scan tree backstop, its Desktop overlay refresh TTL, and its CLI-scan cache deadline with
Date.now(). A wall-clock correction (NTP step or manual change) can stretch or shorten those elapsed-time TTLs: rolling the clock back keeps a stale tree snapshot "fresh" past its five-minute deadline, so deleted sessions linger as ghost entries until the next forced refresh; rolling it forward forces needless full rescans.Precedent: #191606 (same elapsed-TTL-vs-wall-clock shape; this PR is the same shape at the remaining Anthropic extension sites).
Why This Change Was Made
The catalog's owners (
readProjectsTreeSnapshotinsession-catalog-scan.ts,readDesktopOverlayinsession-catalog-desktop.ts,readCliScaninsession-catalog-discovery.ts) each write and compare an in-memory TTL deadline withDate.now(). All three are elapsed-time budgets and are 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
+7/-7, net 0.Classification:
behavior-completingUser Impact
Wall-clock corrections no longer disturb the catalog's five-minute rescan backstop, Desktop overlay refresh, or CLI-scan cache deadline. Sessions removed from disk are cleaned up on schedule regardless of NTP/manual clock changes; nothing else changes.
Evidence
Exact-head proof receipt
14b10161fff79d7ffc82d8e748e30c50fc611b7e0bb438485084d55ff7c760b4f5ad3f79b16346e2listClaudeSessions->readProjectsTreeSnapshot(extensions/anthropic/session-catalog-scan.ts)readProjectsTreeSnapshothard-expiry check inextensions/anthropic/session-catalog-scan.ts:292current.hardExpiresAt <= <now>(tree backstop TTL)sessionslist reflects whether the tree was rescannedre-scans on TTL expiry by elapsed time even when the wall clock rolls backFAILS (ghost session survives a wall-clock rollback), 40/41retries transient index I/O without a metadata change,retries transient transcript I/O without a metadata change) still pass with forward-only clock stepsHOMEviacreateHome(); no production Gateway/session/token/config touchedInspectable RED -> GREEN terminal trace
The test drives both clocks independently:
performance.now()(elapsed, advanced past the 5-minute hard TTL) andDate.now()(wall clock, rolled back an hour), then deletes a transcript while the watch is armed so only a full rescan can evict the ghost entry.Real catalog entry trace
The real production entry
listClaudeSessions(the function behindsessions.catalog.list) runs against a real temporary Claude store: first read discovers the session, a second read within the 5-minute hard TTL is served from cache, deleting the transcript and rollingDate.now()back an hour whileperformance.now()advances past the hard TTL forces a real rescan that evicts the ghost.Running-Gateway
sessions.catalog.listtrace (shipped entry)A real Gateway is started from the built tree (
node openclaw.mjs gateway run) withHOMEpointed at a temporary Claude store holding one session (ttl-session),auth.mode = none, and a process-localDate.now()preload that can step the wall clock without touchingperformance.now(). The Gateway loads the bundledanthropicextension (log:plugins.gateway-load.plugin.anthropic ... loadFailedCount=0) and servessessions.catalog.listwith the claude catalog provider; no Anthropic API credential is involved (the catalog scans the local Claude store only).The elapsed-time expiry side (the rescan that evicts a ghost when the TTL lapses) is covered by the discriminating mock-clock test above (RED on current main 40/41, GREEN on this head 41/41) and by the real
listClaudeSessionsprobe; the running-Gateway trace above proves the shippedsessions.catalog.listpath reaches the changed TTL comparisons and that a wall-clock correction is inert for them.Verification
node scripts/run-vitest.mjs run extensions/anthropic/session-catalog.test.ts(Node 24.18, docker) — 41/41 passed on headgit diff --check upstream/main...HEADlistClaudeSessionsentry against a real temporary Claude store, and a real Gateway (node openclaw.mjs gateway runfrom the built tree) servessessions.catalog.listwith the claude catalog and a process-local wall-clock rollback. No Anthropic credential is required (the catalog scans the local Claude store); the discriminating mock-clock test covers the expiry side.Scope and risk
+7/-7+31/-5performance.now()elapsed-time pattern from fix(cache): keep private cache TTLs on elapsed time #191606; no new helper, validator, or API surfaceVerification
node scripts/run-vitest.mjs run extensions/anthropic/session-catalog.test.ts(Node 24.18, docker) — 41/41 passed on headgit diff --check upstream/main...HEADlistClaudeSessionsentry against a real temporary Claude store. A fullsessions.catalog.listvia a running Gateway needs an Anthropic provider credential and a live Claude store, which this environment lacks; the real-entry trace plus the discriminating mock-clock test cover the changed TTL comparisons.Scope and risk
+7/-7+31/-5performance.now()elapsed-time pattern from fix(cache): keep private cache TTLs on elapsed time #191606; no new helper, validator, or API surface