Skip to content

refactor(memory): move Forget planning reads off the caller thread - #162045

Merged
steipete merged 1 commit into
mainfrom
codex/memory-forget-planning
Sep 30, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/memory-forget-planning

Conversation

@steipete

@steipete steipete commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

memory forget still scans the index, counts derived rows, and loads the vector extension on the caller thread while preparing preview and apply.

User Impact

Preview selection, reported counts, deletion ordering, and stored data stay unchanged. The remaining index-planning SQL runs in the existing Memory retrieval worker. No configuration, schema, retention, or supported SDK contract changes.

Session policy reads and cold database/bootstrap work remain separate migration work.

Why This Change Was Made

The caller captures its database target and matching inputs before dispatch. The worker reuses the original scrub rules and noncreating read owner, keeps indexed memory text local, and returns only selected row identities and counts. Real vector inspection retains its own probe/read-only cleanup. Final live lineage checks and mutations remain with their existing transaction owner.

The request participates in the retrieval pool's existing byte and task admission; no input truncation, new queue, or resource-budget override is added.

Evidence

  • The actual Forget durability case fails on the original host cache-count read and passes with the worker path.
  • 150 owning tests passed on Node 24.21/macOS, including native vector/FTS counts, failure recovery, current source authority, optional tables, and captured-input/read-error controls. The existing replacement experiment was excluded; normal same-file retirement controls passed.
  • The original privacy case still observes exactly 68 native rows and less than 16 KiB across preview/apply, preserves unrelated session bodies, and requires zero calibrated host planner queries.
  • Full changed-file gate and fresh independent P0–P2 review passed.
  • Exact-commit pnpm build passed (20m 57s). Supported built CLI indexing and vector-enabled preview/apply/repeat passed in 44.11s: preview/apply each reported three selected vectors, repeat reported zero, surviving vector bytes and the original tombstone timestamp matched independent SQLite reads. All 15 child processes joined and the loopback endpoint closed.
  • The pre-import observer was calibrated against real SQLite methods and the native vector library. Covered host planner SELECTs, vector health/load calls, final lineage reads, and Forget mutations were zero. The unchanged cold in-memory schema construction is separately recorded; this is not a whole-host-SQL claim.

CI run 36759848676 stopped on two tooling assertions in desktop-resize-proof.test.ts and parallels-smoke-model.test.ts (762 sibling tests passed). The unchanged tooling fixture port-ownership defects are corrected on main by 662b776. Independent real-contender controls reproduced the defects and passed with the existing claim owner; the repaired original-order selection passed 765 cases. The original CI socket tuples were not logged, and the unchanged local 764-case replay is only a non-reproduction. The cancelled lanes remain incomplete coverage.

Local per-file wall times with the maintained test wrapper and --maxWorkers=1 (Node 24.21/macOS): memory-forget.test.ts 77.82s (15 passed), memory-forget-recovery.test.ts 40.91s (8 passed), and memory-forget.sources.test.ts 39.06s (11 passed). These include preparation, imports, hooks, and cleanup. The real worker/SQLite boundaries are necessary to observe host versus native SQL, live source refusal, and durable failure recovery; mock readers would not prove those contracts. The repeated measurements add no distinct cases to the 150-test total. Completed per-file CI timings are not available from the cancelled run.

The automatic data-model checklist is not applicable: the agent schema/version, origin row codec, write backend, and tombstone kernel are byte-identical to the PR base. The added types are private worker read messages; no persisted format or migration changes. Existing-store CLI and optional-table/error controls cover the moved read boundary.

Use the existing memory retrieval pool for noncreating index selection, counts, and vector inspection. Capture caller placement and matching facts before dispatch, share the existing scrub rules, and return only selected row identities and counts. Keep final lineage checks and write settlement with their existing transaction owner.

Validation: causal host count regression, 150 owning tests, native fetched-row and byte bounds, captured-input and read-error controls, full changed-file gate, and independent review.
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 30, 2026 18:36
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core scripts Repository scripts size: XL labels Sep 30, 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 30, 2026
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 30, 2026, 4:07 PM ET / 20:07 UTC (Revision 4).

ClawSweeper review

What this changes

Memory Core moves Forget index selection, row counts, and vector inspection into its existing retrieval worker and updates boundary tests and database documentation.

Merge readiness

⛔ Blocked before merge - 1 item remains

Current main still runs Forget index planning on the caller thread, so this PR remains useful. The previous upgrade-compatibility blocker does not apply: the patch changes private read messages and execution placement, without changing stored data.

Priority: P2
Reviewed head: bae5c96b464182756327a7a5cddbb9800bb6f573

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has a coherent owner cutover and detailed real-flow evidence, with no actionable defect found in this read-only review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body reports the changed Memory Core reader exercised through a built CLI indexing and vector-enabled Forget preview, apply, and repeat run on Node 24/macOS, with selected-vector counts and independent SQLite checks of surviving bytes and tombstone time; worker-boundary tests supplement that real-flow report. No stored-data contract changes, so migration compatibility is not applicable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body reports the changed Memory Core reader exercised through a built CLI indexing and vector-enabled Forget preview, apply, and repeat run on Node 24/macOS, with selected-vector counts and independent SQLite checks of surviving bytes and tombstone time; worker-boundary tests supplement that real-flow report. No stored-data contract changes, so migration compatibility is not applicable.
Evidence reviewed 9 items Current-main gap: The current-main planner runs its SQLite chunk query in the calling path through the synchronous read helper.
Introduced worker route: The caller captures the database path and selection inputs before dispatch; the existing retrieval pool runs the new task.
Read and write ownership: The worker opens an existing database read-only, performs selection and counts, and closes its vector probe; Forget retains the separate live-lineage and purge write path.
Findings None None.
Security None None.

How this fits together

Memory Forget takes session and source selectors, examines workspace artifacts and the agent’s SQLite index, then previews or purges matching memory. The retrieval worker prepares index facts; the existing write owner checks live lineage before deletion.

flowchart LR
A[Forget selectors] --> B[Workspace evidence]
B --> C[Retrieval worker]
C --> D[Index plan and counts]
D --> E{Preview or apply}
E --> F[Preview report]
E --> G[Live lineage check]
G --> H[Purge and report]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +110, Tests +222, Docs +4, Other +4. Total +340 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 8 399 289 +110
Tests 5 265 43 +222
Docs 1 7 3 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 2 4 0 +4
Total 16 675 335 +340

Review metrics

Metric Value Why it matters
Production versus proof growth production +110 net lines; tests and test tooling +226 net lines The production growth relocates the reader; the larger proof addition measures the host and native worker boundary.
Owning test wall time 77.82 s, 40.91 s, and 39.06 s The PR body explains these measured per-file costs and why the real worker and SQLite boundaries are needed.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/memory-core/src/memory-forget-content.ts, unknown-data-model-change: extensions/memory-core/src/memory-forget-index-read.ts, unknown-data-model-change: extensions/memory-core/src/memory-forget-index-sources.ts, unknown-data-model-change: extensions/memory-core/src/memory-forget.ts, vector/embedding metadata: extensions/memory-core/src/memory-forget-content.ts, vector/embedding metadata: extensions/memory-core/src/memory-forget-index-read.ts, and 4 more. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep index planning with Memory Core’s existing read worker while preserving noncreating preview, bounded returned facts, and write-time lineage revalidation.

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

Yes. Current main’s Forget planner visibly executes its SQLite query on the caller thread; this read-only review did not rerun the reported failing case.

Is this the best way to solve the issue?

Yes. The existing retrieval worker is the narrow read owner, and the patch leaves destructive writes and live lineage checks with their established owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7045908edbfc.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded Memory Core responsiveness and database-ownership improvement with limited user-facing blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body reports the changed Memory Core reader exercised through a built CLI indexing and vector-enabled Forget preview, apply, and repeat run on Node 24/macOS, with selected-vector counts and independent SQLite checks of surviving bytes and tombstone time; worker-boundary tests supplement that real-flow report. No stored-data contract changes, so migration compatibility is not applicable.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports the changed Memory Core reader exercised through a built CLI indexing and vector-enabled Forget preview, apply, and repeat run on Node 24/macOS, with selected-vector counts and independent SQLite checks of surviving bytes and tombstone time; worker-boundary tests supplement that real-flow report. No stored-data contract changes, so migration compatibility is not applicable.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 96d66fe adds extensions/memory-core/src/memory-forget.ts:481 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 96d66fed3edf; files: extensions/memory-core/src/memory-forget.ts)

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 (3 earlier review cycles)
  • reviewed 2026-09-30T18:44:14.098Z sha bae5c96 :: blocked before merge. :: none
  • reviewed 2026-09-30T18:55:41.913Z sha bae5c96 :: blocked before merge. :: none
  • reviewed 2026-09-30T19:08:27.142Z sha bae5c96 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 30, 2026
@steipete
steipete merged commit 441e664 into main Sep 30, 2026
210 of 289 checks passed
@steipete
steipete deleted the codex/memory-forget-planning branch September 30, 2026 20:11
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 1, 2026
…162045)

Use the existing memory retrieval pool for noncreating index selection, counts, and vector inspection. Capture caller placement and matching facts before dispatch, share the existing scrub rules, and return only selected row identities and counts. Keep final lineage checks and write settlement with their existing transaction owner.

Validation: causal host count regression, 150 owning tests, native fetched-row and byte bounds, captured-input and read-error controls, full changed-file gate, and independent review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: memory-core Extension: memory-core P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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