Skip to content

improve(memory): batch standing-intent rearming - #147180

Merged
steipete merged 2 commits into
mainfrom
codex/sqlite-round9-memory-landing
Sep 13, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/sqlite-round9-memory-landing

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Related: #146197

What Problem This Solves

Standing-intent maintenance repeats a database update for every reminder whose cooldown has elapsed, increasing work before prompt matching or listing a cooled cohort.

User Impact

Cooled cohorts require substantially fewer database calls; expiry, cooldown, fire budgets, matching, and durable results stay unchanged. Small cohorts have no statement savings and are not guaranteed to be faster.

Why This Change Was Made

Keep the complete native row read and existing JavaScript cooldown decision, then rearm eligible IDs in one update using the existing SQLite string-set helper. The same admitted connection and immediate transaction still own the operation. No schema, public API, or state-format change.

Evidence

  • Original plus regression: 12 passed; the new real-owner cohort test failed on 33 writes versus a ceiling of 2. Candidate: 28 direct/async owner tests passed, including registered hooks and concurrent fire-budget serialization.
  • Seven warm file-backed fixtures exercised actual sweep, list, and match, with two warmups and seven alternating measured pairs. Full outputs, schema/all-user-table typed state, and reopened subsequent matcher/list writes matched across all 21 fixture/flow combinations. Native reads, rows, and bytes remained identical.
  • 1000 ready intents: total native calls fell 1008→9 for sweep, 1009→10 for list, and 1012→13 for match; median times were 10.055→5.145 ms, 15.753→10.184 ms, and 20.976→15.097 ms. The 32-ready sweep fell 0.981→0.608 ms.
  • These are synthetic warm-host measurements. One-ready sweep increased 0.376→0.415 ms; the unchanged-work 1000-cooling list control increased 5.648→6.735 ms. No cold-admission or universal latency claim.
  • NUL, literal escape, emoji, combining Unicode, and native-bound lone-surrogate key fixtures preserved results and state. All six numeric/error differential cases passed, including complete rollback on a synthetic rearm failure after the expiry write and unchanged native unsafe-integer errors.
  • Fresh independent P0–P2 review and all selected formatting, types, lint and repository guards passed on the final source and test. Required exact-head CI passed.

Native prepare, merge and cleanup completed at 4f3b21518980c136f42732127e0adfb978d6a2db. The reviewed source and test hashes were verified on current main.

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: S maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 12:54 PM ET / 16:54 UTC (Revision 2).

ClawSweeper review

What this changes

Memory Core rearms reminders whose cooldown has elapsed with one database update and adds coverage for persisted results, bounded writes, and subsequent matching.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused optimization: current main still updates cooled reminders individually. No introduced correctness or security defect was found, and the protected maintainer PR should remain open.

Priority: P2
Reviewed head: e3b75c3dc5708812e22a2c34f5b0708f34c17fc3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with meaningful regression coverage, reported owner-boundary measurements, and no actionable defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies this as a maintainer PR, so the external-contributor proof gate does not apply. Its body reports actual file-backed sweep/list/match measurements and reopened-state parity for the changed lifecycle owner; this review inspected source and did not rerun those measurements.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies this as a maintainer PR, so the external-contributor proof gate does not apply. Its body reports actual file-backed sweep/list/match measurements and reopened-state parity for the changed lifecycle owner; this review inspected source and did not rerun those measurements.
Evidence reviewed 8 items Introduced lifecycle change: The complete production module preserves full-row reads, JavaScript cooldown arithmetic, expiry and fire-budget eligibility, and the fired-status guard. All lifecycle callers retain the existing synchronous immediate transaction.
Current main still needs the optimization: Fetched main retains the per-row rearming loop. The merged candidate-row optimization at #147099 changes matching reads, not this maintenance write loop.
Release comparison: The supplied latest release, v2026.9.4, also contains the individual rearming UPDATE loop. Its blob was unavailable locally, so the release source was inspected through the GitHub contents API.
Findings None None.
Security None None.

How this fits together

Memory Core stores event-triggered reminders in each agent’s SQLite database. Listing, prompt matching, and periodic maintenance refresh their lifecycle before returning reminders or injecting matching context into a reply.

flowchart TD
  A[Reminder listing] --> D[Lifecycle maintenance]
  B[Incoming user prompt] --> D
  C[Periodic reply hooks] --> D
  D --> E[Check expiry and cooldown]
  E --> F[Rearm eligible reminders in one update]
  F --> G[Persist agent database state]
  G --> H[Return list or matching reminder context]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -1, Tests +59. Total +58 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 5 -1
Tests 1 59 0 +59
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 63 5 +58

Review metrics

Metric Value Why it matters
Reported database-call reduction 1,000 ready reminders: sweep 1008→9, list 1009→10, match 1012→13 Warm file-backed measurements support the large-cohort benefit while the PR explicitly avoids claiming universal latency improvement.

Technical review

Best possible solution:

Keep lifecycle decisions in the existing transactional owner and use the shared bound-set helper to reduce writes without changing reminder semantics.

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

Yes, the overhead is source-reproducible: current main executes one rearming UPDATE for every eligible reminder. No failing runtime execution was performed in this read-only review.

Is this the best way to solve the issue?

Yes. Reusing the existing string-set helper preserves eligibility arithmetic and transaction ownership while removing repeated writes without introducing another API or stored representation.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded performance improvement to existing reminder maintenance, with no demonstrated urgent user-facing failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies this as a maintainer PR, so the external-contributor proof gate does not apply. Its body reports actual file-backed sweep/list/match measurements and reopened-state parity for the changed lifecycle owner; this review inspected source and did not rerun those measurements.

Evidence

What I checked:

  • Introduced lifecycle change: The complete production module preserves full-row reads, JavaScript cooldown arithmetic, expiry and fire-budget eligibility, and the fired-status guard. All lifecycle callers retain the existing synchronous immediate transaction. (extensions/memory-core/src/standing-intents.ts:230, e3b75c3dc570)
  • Current main still needs the optimization: Fetched main retains the per-row rearming loop. The merged candidate-row optimization at improve(memory): reuse standing-intent candidate rows #147099 changes matching reads, not this maintenance write loop. (extensions/memory-core/src/standing-intents.ts:249, b735b686361e)
  • Release comparison: The supplied latest release, v2026.9.4, also contains the individual rearming UPDATE loop. Its blob was unavailable locally, so the release source was inspected through the GitHub contents API. (extensions/memory-core/src/standing-intents.ts, 3a9d69db306c)
  • Existing SQLite membership contract: sqliteStringSet uses one bound JSON parameter, preserves native string normalization and embedded NUL handling, and avoids variable-count placeholders. Existing helper tests compare membership results across UTF-8 and UTF-16 databases, unusual strings, duplicates, and empty sets. No SDK API is added or changed. (src/infra/kysely-sync.ts:49, e3b75c3dc570)
  • Regression coverage and review continuity: The complete test exercises 32 reminders through creation, firing, reopening, cooldown-boundary listing, and subsequent matching while enforcing at most two writes. GitHub’s exact-head commit patch confirms the follow-up only simplifies expected values. The previous review retained no findings; tests were inspected but not executed during this read-only review. (extensions/memory-core/src/standing-intents.test.ts:355, e3b75c3dc570)
  • Reported owner-boundary measurements: The complete captured PR body reports seven warm file-backed fixtures across sweep, list, and match, equivalent outputs and reopened durable state, unusual-key cases, rollback checks, and 28 passing owner tests. For 1,000 ready reminders, reported native calls fall from 1008 to 9 for sweep. These are contributor-reported synthetic measurements, not independently rerun production latency evidence. (e3b75c3dc570)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-13T16:39:53.701Z sha 12b58a6 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 13, 2026 16:47
@clawsweeper

clawsweeper Bot commented Sep 13, 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.

@steipete
steipete merged commit 4f3b215 into main Sep 13, 2026
160 of 161 checks passed
@steipete
steipete deleted the codex/sqlite-round9-memory-landing branch September 13, 2026 17:04
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
* improve(memory): batch standing-intent rearming

* test(memory): simplify rearm cohort expectations

---------

Co-authored-by: Peter Steinberger <[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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

1 participant