Repository navigation
fix(memory-lancedb): keep the cold-start embed deadline on the monotonic clock - #186037
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 changesThis PR makes the embedding adapter’s cold-start timeout budget independent of wall-clock changes. Example: The wall clock advances 30 seconds during provider initialization for a recall with a 15-second budget.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current cold-start deadline bug with a focused patch, adequate behavior proof, passing affected checks, and no actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherExplicit and automatic memory recall pass a timeout budget through the embedding adapter, which initializes a shared provider and returns a vector for LanceDB search. flowchart TD
A[Memory recall or prompt hook] --> B[Recall deadline]
B --> C[Embedding adapter]
C --> D[Shared provider initialization]
D --> E[Bounded embedding request]
E --> F[LanceDB search]
Technical reviewBest possible solution: Use the existing adapter’s monotonic deadline calculation while preserving shared provider initialization and timeout enforcement. Do we have a high-confidence way to reproduce the issue? Current-main source shows the two wall-clock reads around awaited initialization, and the contributor supplies a failing CLI trace plus a successful no-step control; no target code was executed during this review. Is this the best way to solve the issue? This is the smallest complete production repair: change the existing deadline’s clock source and retain its expiration check, abort timer, and provider lifecycle. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 32679f5ac9f9. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +2, Tests +71. Total +73 across 2 files. Added test files: 0. View PR surface stats
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 (1 earlier review cycle)
Reviewed October 27, 2026, 12:38 PM ET / 16:38 UTC (Revision 2). |
|
🦞👀 Re-review progress:
|
Independent bundled-memory cold-start proofCompared main Each run executes the shipped An in-process preload observes the real lazy embedding-provider SDK import using Node's loader-resolution hook and applies +30 seconds to Date.now only during that cold-start await. Module resolution and provider implementations are returned unchanged; nothing is held or replaced. The recorded real/shifted clock values confirm exactly +30000ms in every stepped main and candidate run. Real timers, performance.now and the HTTP observer remain unchanged; no system clock change.
Main falsely exhausts the healthy cold-start budget before dispatching any embedding request. The candidate dispatches and completes recall normally, like the controls. These are fresh empty LanceDB stores, not raw database seeding or mocked adapters. No real provider credentials or plugin installation were used. This independent run proves the forward-step cold-start defect and normal recall controls. It does not independently claim rollback-overrun or delayed-endpoint timeout coverage; the contributor's separate regression/proof remains attributable to them. No source changes or pushes were needed. |
|
Landed in bde8a4e. Thanks @SunnyShu0925. The first LanceDB recall no longer times out after a clock jump. |
|
@obviyus Thanks! |
…nic clock (openclaw#186037) fix(memory-lancedb): keep the cold-start embed deadline on the monotonic clock The memory-lancedb embed deadline was measured with the wall clock during cold initialization, so a forward clock step while the provider loaded made the first recall time out before any embedding request was sent. The deadline now uses monotonic time. Evidence: the bundled memory-lancedb enabled with shipped `plugins enable` on a built Gateway, real memory_recall, a local embedding fixture, and Date.now stepped forward 30 seconds inside the process during the lazy provider import. On main the recall timed out with 0 embedding requests (twice); with this change it sent 1 request and completed (twice), like the no-step runs on both refs. Details: openclaw#186037 (comment). Production 6 lines. Thanks @SunnyShu0925. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Ayaan Zaidi <[email protected]>
…nic clock (#186037) fix(memory-lancedb): keep the cold-start embed deadline on the monotonic clock The memory-lancedb embed deadline was measured with the wall clock during cold initialization, so a forward clock step while the provider loaded made the first recall time out before any embedding request was sent. The deadline now uses monotonic time. Evidence: the bundled memory-lancedb enabled with shipped `plugins enable` on a built Gateway, real memory_recall, a local embedding fixture, and Date.now stepped forward 30 seconds inside the process during the lazy provider import. On main the recall timed out with 0 embedding requests (twice); with this change it sent 1 request and completed (twice), like the no-step runs on both refs. Details: #186037 (comment). Production 6 lines. Thanks @SunnyShu0925. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Ayaan Zaidi <[email protected]> Beta.5 baseline adaptation: Measure provider cold-start budget monotonically and floor remaining timeout; preserve prior outer recall budget. (cherry picked from commit bde8a4e) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit c3a8914eb7a6e532c0668765a17d8258307f7dd7)
…nic clock (#186037) fix(memory-lancedb): keep the cold-start embed deadline on the monotonic clock The memory-lancedb embed deadline was measured with the wall clock during cold initialization, so a forward clock step while the provider loaded made the first recall time out before any embedding request was sent. The deadline now uses monotonic time. Evidence: the bundled memory-lancedb enabled with shipped `plugins enable` on a built Gateway, real memory_recall, a local embedding fixture, and Date.now stepped forward 30 seconds inside the process during the lazy provider import. On main the recall timed out with 0 embedding requests (twice); with this change it sent 1 request and completed (twice), like the no-step runs on both refs. Details: #186037 (comment). Production 6 lines. Thanks @SunnyShu0925. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit bde8a4e) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 632d0be1325d682b0b82f05bdc78c603c617f1b7)
…o the fork's 5 s budget beta.5 added "includes %ims of cold provider initialization in the auto-recall deadline" (openclaw#182340, openclaw#186037) with cases 10_000 and 16_000 around upstream's 15_000 ms auto-recall budget. The fork keeps auto-recall at 5_000 ms (auto-recall.ts AUTO_RECALL_TIMEOUT_MS), so the 10_000 case expected a request the fork never makes: it failed 3 of 3 alone on the carry and passed 3 of 3 on bare beta.5. The cases now straddle 5_000 (3_000 inside, 6_000 past), and the remaining-budget advance uses 5_000. The test still checks that cold initialization counts against the deadline: the 3_000 case expects the request aborted at 5 s total, not 5 s after the provider is ready. Control: with AUTO_RECALL_TIMEOUT_MS set back to 15_000, both adapted cases fail.
What Problem This Solves
A healthy
memory_recall(or automatic prompt recall) can be rejected as a timeout — or an expired embedding request can be dispatched past its budget — when the host wall clock steps during a provider cold start. Inextensions/memory-lancedb/embeddings.ts,ProviderAdapterEmbeddings.embed()seeds its absolute embed deadline withDate.now()and, after awaiting the shared provider's cold-start initialization, recomputes the remaining abort budget withDate.now()again: a forward step shrinks (or negates) the budget so a healthy query is fenced asmemory-lancedb embedding timed out, while a rollback inflates it so an already-expired query is dispatched — exactly the "never dispatch that expired query" case the guard exists to stop.Why This Change Was Made
The embed deadline is process-local — never persisted, never compared against a wall-clock epoch by another process — so the monotonic clock is the only correct source, matching the repo's wall-clock-to-monotonic pattern (merged #177155, #183104, #184711 for the sibling recall-deadline path in the same file).
performance.now()instead ofDate.now().Math.floor(deadlineAtMs - performance.now()), keeping the integer contractsetTimeoutrequires.User Impact
A healthy recall whose provider is still cold-starting is no longer rejected because the clock stepped forward mid-initialization, and an expired query can no longer be dispatched past its budget after a rollback. Timeout text, result ordering, and error reporting are unchanged.
Evidence
Shipped entry point: real recall across a clock step
A real
openclaw agent --localturn (real plugin load, realRecallService, real provider adapter, real HTTP embedding dispatch to a local OpenAI-compatible endpoint that logs every request). A--importshim stepsDate.nowby +30 s between the adapter's deadline seed and its remaining-budget read — the window a host clock correction lands in. It matches the direct caller frame, so the seed keeps the real clock and only the read is stepped. Every run starts from a fresh state dir, so the provider is always cold-started.Pre-fix (
Date.nowseed + read): healthy recall fenced, no embedding request ever sent.Post-fix (
performance.nowseed + read): same shim, same step, recall dispatches.Control (pre-fix source, shim loaded, offset 0): same path without the step dispatches normally, so the failure above is the clock step, not the harness.
The step is injected rather than host-NTP; the measured seed→read window here was 41 ms (1793116945400 → 1793116945441), which is exactly the window an instantaneous clock correction lands in.
Timeout still enforced after the fix
A 16 s embedding response against the 15 s recall budget is still abandoned at the budget:
Regression test RED / GREEN
keeps the cold-start embed deadline on the monotonic clock across a wall-clock step(auto-recall.deadline.test.ts) uses a synthetic cold provider (pendingready.promise) andvi.setSystemTimeto stepDate.now()by +30 s between seed and read.Full memory-lancedb shard
node scripts/run-vitest.mjs extensions/memory-lancedb --run→ 18 passed | 1 failed files, 115 passed | 1 failed tests. The single failure isarrow-null-predicates.test.ts, which fails identically on cleanmain(EvalError: Code generation from strings disallowed— apache-arrow'snew Functionpredicate compilation blocked in this Node context); pre-existing, unrelated, and recorded as such.Merge risk
Two-way door: reverting restores the previous process-local deadline calculation; no state migration or published contract changes. Blast radius is memory-lancedb cold-start embed deadline handling.
Independent bundled-enable Gateway Evidence
#186037 (comment)
Enabled the bundled memory-lancedb with the shipped CLI (no plugin install). Fresh built Gateway cold starts, +30s process-only Date.now correction: main twice times out without dispatching embeddings; candidate twice sends one embedding request and completes recall. Both no-step controls complete recall. The same actual clock correction is recorded on both refs. No source edits or pushes were required.