Skip to content

improve(memory): reduce forget planning payloads - #147315

Merged
steipete merged 1 commit into
mainfrom
codex/sqlite-round10-memory-landing
Sep 13, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/sqlite-round10-memory-landing

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Related: #146197

What Problem This Solves

Memory deletion previews and forget operations fetch large session bodies that their index planner never uses.

User Impact

Forgetting memory from session-heavy indexes requires much less payload materialization. Preview results, retained content, deletion selection and retry behavior stay unchanged. No migration or configuration change is needed. Small and all-memory workloads may be neutral or slower.

Why This Change Was Made

Keep the existing single index read and all selection metadata, while asking SQLite to return an empty body for session-source chunks. Full memory and unusual-source bodies remain available to the existing selection logic. The planner also stops fetching unused hashes.

Evidence

  • 37 owner tests passed across forget, phase signals and consolidation, including failure/retry coverage. The new actual preview/deletion regression passes all behavior assertions on the original code, then fails its payload budget at 7,345,132 bytes; the candidate passes the 16 KiB bound.
  • Six file-backed fixtures × preview/actual forget passed full report, schema and typed table-state parity, unchanged preview state and reopened follow-up behavior. Native statement and returned-row counts are unchanged.
  • Existing-data compatibility: each immutable seed database is initialized through the original forget owner before either version runs. The candidate opens copies of that database, preserves sqlite_schema and typed table-state parity, and passes a subsequent preview after reopening. This is a read projection change with no schema, stored encoding, version, migration, or writer change; no data conversion is required.
  • The 1,000-row large-session fixture reduces chunk string payload from 65,615,877 to 61,873 bytes. A separate idle confirmation on final reviewed bytes, with five alternating measured pairs after one warmup, showed preview 186.522→12.914 ms and forget 147.426→17.694 ms. Full outputs/state, reopened behavior, native counts and source hashes matched. The initial mixed 200-memory/800-session fixture showed 243.017→40.598 ms and 150.610→58.678 ms respectively.
  • These are warm synthetic Node 26.8.2 Linux owner timings. Other lanes' tests overlapped part of the initial six-fixture run; its original results remain retained and the headline large-session timings now come from the separate idle run. The all-memory actual-forget control slowed 49.329→52.278 ms and the empty control 6.658→7.159 ms; no universal latency claim is made.
  • 53 native source-text cases cover UTF8/UTF16LE/BE, NUL, surrogate normalization and malformed bytes. Fresh independent review with full changed-owner context found no P0-P2 issues, complemented by direct owner/caller inspection by the lead. Selected production/test types, dead-export checks, lint and remaining storage/import guards passed across the original run and exact recovery after two test lint fixes. The initial failed lint record is retained; final recovery.exit is0.

@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 marked this pull request as ready for review September 13, 2026 19:20
@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: blocked before merge. Reviewed September 13, 2026, 3:30 PM ET / 19:30 UTC.

ClawSweeper review

What this changes

Memory deletion planning skips fetching session bodies and unused hashes while preserving selection metadata, with regression coverage for preview results, deletion, and retained content.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful, bounded optimization: current main and the latest release still materialize the unused session bodies. No blocking correctness or security defect was found.

Priority: P2
Reviewed head: cf28771569995e5bb10f5fe7978755dba407e303

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with a clear selection invariant, meaningful regression coverage, and appropriately qualified measurements.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies this as maintainer-authored, so the external-contributor gate does not apply. The body reports production forget-owner runs against file-backed SQLite with preview/deletion parity and reduced returned payload; those measurements were not independently rerun.
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 maintainer-authored, so the external-contributor gate does not apply. The body reports production forget-owner runs against file-backed SQLite with preview/deletion parity and reduced returned payload; those measurements were not independently rerun.
Evidence reviewed 8 items Introduced change and selection invariant: The pinned merge-base-to-head diff changes only the planner projection and its regression test. Session selection uses paths and provenance; body matching runs only for memory-source chunks. Downstream deletion consumes chunk IDs, so removing hashes and substituting empty session bodies preserves its inputs.
Current main still fetches full bodies: The fetched main planner still selects both hash and text for every indexed chunk; this optimization is not already present.
Latest release comparison: The v2026.9.4 source likewise selects full session text and hashes. Release source was inspected through GitHub after local historical blob retrieval failed.
Findings None None.
Security None None.

How this fits together

Memory Core turns session selectors into a preview or deletion of derived memory artifacts. Its index planner reads the agent’s SQLite database to identify affected chunks and report deletion counts.

flowchart TD
  A[Memory forget command] --> B[Resolve selected sessions]
  B --> C[Read index metadata]
  D[Agent SQLite database] --> C
  C --> E[Match paths and memory content]
  E --> F[Preview report]
  E --> G[Delete selected derived artifacts]
Loading

Before merge

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

Security

None.

PR surface

Source +7, Tests +78. Total +85 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 11 4 +7
Tests 1 78 0 +78
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 89 4 +85

Review metrics

Metric Value Why it matters
Reported session payload 65,615,877 → 61,873 bytes The 1,000-row file-backed fixture demonstrates the intended allocation reduction without claiming universal latency gains.

Stored data model

Persistent data-model change detected: vector/embedding metadata: extensions/memory-core/src/memory-forget.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep the existing single-read planner and deletion owner while omitting payload that session selection never consumes.

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

Yes, the unnecessary materialization is source-proven: current main eagerly returns session text that selection never reads. The supplied regression exercises this path, but this review did not execute it.

Is this the best way to solve the issue?

Yes, the projection change removes unused payload at its existing owner without introducing another query, selection policy, or persistent representation.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded performance improvement for memory deletion on session-heavy indexes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add 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 maintainer-authored, so the external-contributor gate does not apply. The body reports production forget-owner runs against file-backed SQLite with preview/deletion parity and reduced returned payload; those measurements were not independently rerun.

Label justifications:

  • P2: This is a bounded performance improvement for memory deletion on session-heavy indexes.
  • 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 maintainer-authored, so the external-contributor gate does not apply. The body reports production forget-owner runs against file-backed SQLite with preview/deletion parity and reduced returned payload; those measurements were not independently rerun.

Evidence

What I checked:

  • Introduced change and selection invariant: The pinned merge-base-to-head diff changes only the planner projection and its regression test. Session selection uses paths and provenance; body matching runs only for memory-source chunks. Downstream deletion consumes chunk IDs, so removing hashes and substituting empty session bodies preserves its inputs. (extensions/memory-core/src/memory-forget.ts:202, cf2877156999)
  • Current main still fetches full bodies: The fetched main planner still selects both hash and text for every indexed chunk; this optimization is not already present. (extensions/memory-core/src/memory-forget.ts:206, cf45ff4d6a9c)
  • Latest release comparison: The v2026.9.4 source likewise selects full session text and hashes. Release source was inspected through GitHub after local historical blob retrieval failed. (extensions/memory-core/src/memory-forget.ts:206, 3a9d69db306c)
  • Regression checks actual database results: The added test invokes the production forget owner for preview and deletion against SQLite, checks selected and surviving rows, preserves an unrelated body containing NUL and Unicode, and measures returned string bytes. The existing tests also cover failed deletion retries and archive selection. Tests were inspected, not executed during this read-only review. (extensions/memory-core/src/memory-forget.test.ts:49, cf2877156999)
  • Documented command contract: The documented command previews without modifying state and retains source transcripts. The CLI forwards selectors and dry-run directly to the reviewed owner; the patch does not change that contract, persistent schemas, or configuration. Public docs: docs/cli/memory.md. (docs/cli/memory.md:195, cf2877156999)
  • Reported measurements and compatibility checks: The captured PR body reports six file-backed fixtures with full report/schema/table-state parity, unchanged preview state, and reopened follow-up behavior. Its 1,000-row session fixture reduced returned chunk strings from 65,615,877 to 61,873 bytes. These are reported synthetic Node 26.8.2 Linux measurements; overlapping workloads and slightly slower small controls limit latency conclusions. (cf2877156999)

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.

@steipete

Copy link
Copy Markdown
Contributor Author

The compatibility proof is now explicit in the PR body. Each synthetic database is initialized through the original forget owner, then copied for original/candidate preview and deletion. All six fixtures preserve schema and typed table-state parity, and subsequent previews pass after reopening. The final idle run confirms the same behavior.

No schema, stored encoding, database version, migration, or writer changes are introduced, so no data conversion is required. This addresses the data-model compatibility checklist item; the final idle measurements are also recorded in the body.

@steipete
steipete merged commit 7c50663 into main Sep 13, 2026
163 checks passed
@steipete
steipete deleted the codex/sqlite-round10-memory-landing branch September 13, 2026 19:44
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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