Skip to content

fix(memory): keep embedding pause budgets on the monotonic clock - #169360

Merged
obviyus merged 3 commits into
openclaw:mainfrom
Bartok9:bartok9/embedding-pause-deadline-monotonic-20261011
Oct 26, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
Bartok9:bartok9/embedding-pause-deadline-monotonic-20261011

Conversation

@Bartok9

@Bartok9 Bartok9 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Embedding deadline timers use elapsed time, but their pause accounting and post-provider-result expiry check used wall-clock time. A clock correction could discard a healthy result or accept an already-overdue one. Use the same monotonic clock for both embedding and corpus deadlines.

Adapt the existing overdue-success retry regression to advance monotonic elapsed time without servicing its timer. It still requires three attempts, aborts every obsolete attempt, preserves the timeout reason, and leaves no timers behind. Reuse the existing balanced deadline-control owner in the new pause regression instead of duplicating its subscribe/report implementation.

Evidence

Observed built-CLI capture.

Built main (92233fdddef26465e8701531620b69ff48c3124d) and the candidate in isolated Node 24.22.1 containers. Ran the shipped memory index --force --verbose CLI against a temporary Markdown corpus and a local HTTP embeddings server. A fixture plugin, installed through plugins install --force --accept-capabilities, delegates to the shipped OpenAI-compatible embedding adapter and sets its supported runtime budget to 300 ms. It records actual HTTP requests and provider aborts. For the overdue-result cases, a 600 ms synchronous provider completion stall prevents the timer callback from running first. Only the index process's Date.now() is shifted; timers, performance.now(), and system time remain unchanged.

  • Backward five-second step, main twice: the overdue result incorrectly succeeds, indexing one file with one request and no abort.
  • Same backward step, candidate twice: the overdue result is rejected; three real HTTP attempts are aborted, then indexing reports the embedding timeout instead of committing the late result.
  • No-step overdue controls on both refs: three attempts, three aborts, timeout. Healthy no-step controls on both refs: one request, one file indexed, no abort.
  • Forward five-second control: main unnecessarily aborts/retries a healthy result; the candidate indexes it with one request and no abort.
  • Both committed clock-step regressions fail against main. The candidate's paused-deadline and embedding-retry suites pass: 25 tests in two files, including readiness pause/resume and overdue-result cleanup. Formatting and lint pass for all three changed files.

The shipped CLI campaign exercises post-provider expiry and persisted index outcomes; readiness pause/resume is covered by the focused regression tests, not claimed as live managed-service proof.

Compatibility and Merge Danger

No configuration, storage format, provider contract, or public API changes. Reverting fully restores prior deadline arithmetic: a two-way door. The blast radius is memory embedding timeout accounting during clock corrections; corpus deadlines already used monotonic time.

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Oct 11, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR uses monotonic elapsed time for embedding expiry checks and readiness-pause accounting.

Example: A 300 ms embedding operation finishes after 600 ms while Date.now moves backward five seconds.

  • Before: The overdue result can succeed and publish an indexed file.
  • After: All three overdue attempts are aborted and indexing reports a timeout without publishing the file.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A minimal owner-level repair with supplied shipped-CLI fault evidence, meaningful regression coverage, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied isolated Node 24 built-CLI campaign exercises memory index through the shipped OpenAI-compatible adapter and a real HTTP fixture, recording clock-step results, request aborts, exit status, and persisted index outcomes before and after the fix; focused regressions separately cover readiness pause/resume.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A system clock correction can make memory indexing or search reject healthy embedding results or accept results beyond their elapsed-time budget.
Reason: This restores established elapsed-time budgets without changing configuration, provider contracts, or product direction.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current deadline-accounting bug with a focused change. The previous finding is resolved, supplied CLI evidence supports the fix, and no new actionable defects were found; current-head CI is still running.

Priority: P2
Reviewed head: 0faaf0e9d5a23ae01088add5d7d83b15d3c292b8

Before merge

None.

Findings

None.

Agent review details

How this fits together

Memory Core wraps embedding provider operations in a shared pause-aware deadline owner, which accepts timeout budgets and readiness events and returns results or aborts overdue operations.

flowchart TD
  A[Memory CLI or search] --> B[Embedding operation]
  B --> C[Pause-aware deadline]
  D[Readiness control] --> C
  C --> E[Embedding provider]
  E --> F[Result expiry check]
  F --> G[Return result or timeout]
Loading

Technical review

Best possible solution:

Use the existing shared deadline owner with monotonic accounting while preserving readiness pauses, cancellation, retries, and cleanup.

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

Current-main source exposes the clock mismatch, and the supplied built-CLI capture demonstrates both backward-step late acceptance and forward-step unnecessary retries; this review did not execute the reproduction.

Is this the best way to solve the issue?

The patch repairs the clock at its existing owner, preserves the established timing contract, and updates the affected regression without adding a competing path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Pause-aware deadline clock changes intended behavior with a stated reason (51de49c: The consolidation preserved the existing embedding wall-clock arithmetic and corpus monotonic arithmetic while sharing deadline lifecycle code.)
  • Overdue embedding result rejection keeps the original intent (e71fc94: Reject provider successes that arrive after the operation budget even when an event-loop stall delays the watchdog callback.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +1, Tests +59. Total +60 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 2 61 2 +59
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 63 3 +60

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Clock corrections can cause unnecessary embedding retries or acceptance of overdue results, with impact limited to memory deadline accounting.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-11T20:58:47.384Z sha ca424059b17927c480397948db942ba78f37fae7 :: needs real behavior proof before merge. :: [P2] Advance monotonic time in the existing overdue-provider regression

Reviewed October 26, 2026, 3:15 AM ET / 07:15 UTC (Revision 2).

Embedding pause accounting used Date.now() while setTimeout runs on the
monotonic clock. A wall-clock jump could expire a live budget or discard
remaining time when a readiness pause resumed.
@Bartok9
Bartok9 force-pushed the bartok9/embedding-pause-deadline-monotonic-20261011 branch from c35dada to 449f901 Compare October 25, 2026 15:49
@obviyus

obviyus commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Built memory-index evidence

Local HTTP embeddings fixture, installed provider fixture delegating to the shipped OpenAI-compatible adapter; 300 ms supported runtime budget. The overdue completion stalls the index process for 600 ms after a real HTTP response, so post-result expiry—not an already-fired timer—must reject it. Date.now steps affect only that process.

case                     HTTP requests  aborts  exit  persisted files/chunks
main backward -5s #1     1              0       0     1/1 (incorrect late acceptance)
main backward -5s #2     1              0       0     1/1 (incorrect late acceptance)
candidate backward #1   3              3       1     0/0 (timeout)
candidate backward #2   3              3       1     0/0 (timeout)
main no-step overdue    3              3       1     0/0
candidate no-step late  3              3       1     0/0
main healthy no-step    1              0       0     1/1
candidate healthy       1              0       0     1/1
main forward +5s        2              1       0     1/1 (unnecessary retry)
candidate forward +5s   1              0       0     1/1

Overdue candidate output: Memory index failed (main): memory embeddings batch timed out after 0s (300 ms rounded for display). Successful output: Memory index updated (main): 1 file indexed.

Focused suites: 25 passed. Both clock-step regressions fail with unchanged main production. The repaired overdue retry fixture still requires three aborted attempts and zero leftover timers. Readiness pause/resume coverage is focused-test evidence, not a live managed-service claim.

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 26, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 26, 2026
@obviyus
obviyus merged commit 80ed717 into openclaw:main Oct 26, 2026
119 of 121 checks passed
@obviyus

obviyus commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Landed in 80ed717. Thanks @Bartok9. Embedding deadlines now ignore wall-clock jumps.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…nclaw#169360)

fix(memory): use monotonic time for embedding deadlines

Embedding deadline pause and resume, and the expiry check after a provider result, used the wall clock while the timers ran on monotonic time. After a backward clock step an overdue embedding could still be accepted and published. Those checks now use monotonic time.

Evidence: built `memory index` runs through a local embedding fixture using the shipped HTTP adapter, with the wall clock stepped back 5 seconds inside the process under test only and an overdue completion. On main one file was wrongly published (twice); with this change all three attempts aborted and nothing was published (twice). No-step and forward-step controls behave correctly on both refs. Details: openclaw#169360 (comment). Production +2/-1.

Thanks @Bartok9.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 28, 2026
…9360)

fix(memory): use monotonic time for embedding deadlines

Embedding deadline pause and resume, and the expiry check after a provider result, used the wall clock while the timers ran on monotonic time. After a backward clock step an overdue embedding could still be accepted and published. Those checks now use monotonic time.

Evidence: built `memory index` runs through a local embedding fixture using the shipped HTTP adapter, with the wall clock stepped back 5 seconds inside the process under test only and an overdue completion. On main one file was wrongly published (twice); with this change all three attempts aborted and nothing was published (twice). No-step and forward-step controls behave correctly on both refs. Details: #169360 (comment). Production +2/-1.

Thanks @Bartok9.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 80ed717)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-core Extension: memory-core P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants