Repository navigation
fix(memory): expose storage usage and guide safe disk recovery - #137876
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 12:13 AM ET / 04:13 UTC. ClawSweeper reviewWhat this changesThe PR adds Memory Core storage diagnostics plus CLI and documentation guidance for safely reclaiming space from an agent’s shared SQLite database. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 5 items remain Keep this PR open: its new storage query makes Priority: P1 Review scores
Verification
How this fits togetherMemory Core indexes memory in each agent’s shared SQLite database, while the memory CLI presents diagnostic and recovery information to operators. This change carries database measurements through Memory Core status into JSON and terminal output, then points users to the existing Doctor compaction flow. flowchart LR
A[Agent SQLite database] --> B[Memory Core status]
B --> C[Storage diagnostics]
C --> D[Memory CLI and JSON]
D --> E[Operator recovery decision]
E --> F[Doctor compaction]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +65, Tests +61, Docs +37. Total +163 across 10 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep diagnostics read-only and report zero cache entries and bytes when the optional cache table is absent, with a regression covering cache-disabled Do we have a high-confidence way to reproduce the issue? Yes, from source: create or retain an indexed agent database with caching disabled before the cache table exists, then run Is this the best way to solve the issue? No. The storage diagnostics must respect the existing optional-cache schema contract; returning zero cache metrics when the table is absent is the narrow owner-boundary repair. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cd80cce329d4. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Final-head review and landing decision for Fresh independent Codex review found no actionable P0–P2 defects and independently confirmed that the missing-cache-table claim confuses temporary rebuild storage with the canonical agent database. The PR body now addresses both ClawSweeper rank-up moves with source links and a real cache-disabled CLI status/index/status proof. No code or database changes were needed for that disposition. The maintainer explicitly waived the npm audit outage for this landing. Exact-head CI is complete; only security-fast and its aggregate CI gate are failed. The sole failing security step is the production audit's repeated bulk-advisory timeout; the other security scanners passed. Local audit and independent minimal endpoint probes also timed out. This is a waiver, not audit clearance. The native review artifacts are retained. Because the native landing wrapper cannot express a single-check waiver, landing uses a maintainer squash pinned to the reviewed head. Check results, CI configuration, dependencies, and repository rules remain unchanged. |
|
Post-merge verification on The merged change has the same stable patch ID as the reviewed candidate. One DB per agent remains unchanged. The only waived CI result is the previously documented npm advisory endpoint outage. |
…law#137876) Expose database/WAL bytes, reusable allocation, and retained embedding-cache payloads in explicit memory diagnostics. Guide memory reset users through the existing offline Doctor compaction workflow before rebuilding. Keep one SQLite database per agent, with no schema, table, layout, retention, migration, or configuration changes. This completes the operator recovery flow after the cache-publication and safe-reset fixes in openclaw#135373 and openclaw#135653. Real Linux and macOS CLI/Gateway proof preserved 43 non-index tables and schema version 19, refused compaction while the Gateway was running, reclaimed 11,096,064 bytes after stopping it, and rebuilt searchable memory. Focused tests, builds, changed checks, and independent review passed. The maintainer explicitly waived npm advisory endpoint timeouts; other applicable CI checks passed or were skipped. Fixes openclaw#135347. Thanks @AlexisBallo2 for the report.
What Problem This Solves
Operators investigating a large agent database could see indexed chunk payloads but not retained embedding-cache bytes, WAL size, or reusable pages. After
memory reset, the file stays allocated, and the CLI sent operators straight back to rebuilding without explaining the supported disk-recovery step.Closes #135347. Follows the bounded cache-publication fix in #135373 and safe reset in #135653. Thanks @AlexisBallo2 for the original report.
Why This Change Was Made
Keep one SQLite database per agent and preserve its existing transaction, schema, reset, and compaction owners. Explicit memory diagnostics now report main-file bytes, WAL bytes, reusable pages, and retained cache payload/entry totals, including when caching is disabled. Normal serving status does not collect these facts.
Reset output and recovery docs point to the existing offline
doctor --session-sqlite compact --session-sqlite-agent <id>command. The documented disk-recovery order is verified backup, stopped writers, reset when needed, compaction, rebuild, and verification. The maintainer decision to retain the shared database is recorded at #135347 (comment).No database layout, table, schema-version, retention, embedding representation, configuration, environment variable, or dependency changes.
User Impact
Operators can distinguish retained cache payload, WAL growth, and reusable allocation before choosing recovery. The displayed sizes have explicit scope and are not presented as additive components or a complete attribution of the original reported 35 GB.
Existing sessions, transcripts, origins, tombstones, and deletion/rebuild coordination remain with their current owner. Byte inspection is limited to explicit diagnostics and uses the existing query/runtime abstractions.
Evidence
valreference; the final correction callseb.val(0), passes extension lint, and passed all 72 index/storage tests again.pnpm build: passed on Blacksmith Testboxtbx_01m1n6wajy307qjtdjyde2a49h(hydration run).0782a52cb3d). An isolated synthetic agent used keyword-only search with no external provider requests. Status reported 1,024 retained cache entries (9,438,208 payload bytes) despite caching being disabled, plus 11,272,352 WAL bytes. Compaction refused a running Gateway. After stopping it, reset preserved all 43 non-index tables, including transcript rows, origins, and tombstones; compaction reduced the database from 11,771,904 to 675,840 bytes, reclaiming 11,096,064 bytes. Schema SQL and version 19 stayed unchanged. Reindex produced searchable memory and a 679,936-byte database. Both remote commands exited 0.memory status --json→memory index→ seed synthetic canonical/cache/vector rows →memory status --json→ start Gateway → refuseddoctor --session-sqlite compact→ stop Gateway →memory reset --yes→doctor --session-sqlite compact→memory index→memory status --json→memory search.pnpm build: passed. The completed macOS build passed the same isolated real Gateway/CLI proof with identical reclaimed-byte, canonical-preservation, schema, and rebuilt-search results. An earlier local probe started before plugin packaging completed and correctly failed Gateway registry validation; the completed-build rerun passed. The corrected runtime build and final macOS live probe passed with the same reclaimed-byte, canonical-row, schema, and search results. The completenode scripts/check-changed.mjs --base c86d5b2d270eb2eb2a98cf5070f5efe19eb068c3suite passed after the lint correction. Exact-head CI is complete. All other applicable checks passed or were skipped; the only failed checks aresecurity-fastand its aggregateopenclaw/ci-gate. The sole failing security step is the production dependency audit: npm’s bulk advisory endpoint timed out after three attempts, and independent local audit/minimal POST probes also timed out. No audit clearance was obtained. The maintainer explicitly waived this external npm-audit timeout for landing; no dependency, workflow, check result, or repository rule is changed.Known limits: the original corpus/configuration is unavailable, so this does not attribute the full reported 35 GB or recover already deleted sessions. Broader representation/corpus work remains #131085 and #114612. A separate diagnostic follow-up is to include WAL bytes in Doctor's older database-bloat warning heuristic; this change exposes them directly in memory status.
Review disposition
The ClawSweeper review treats the cache table as optional in the published agent database. That premise confuses the temporary memory-only rebuild schema with the canonical agent schema:
Both rank-up moves were considered. The proposed absent-table guard is declined because it would add a fallback for a shape that the canonical agent store does not support. The requested live cache-disabled scenario was run through the real built CLI on the final head: with caching disabled from the start,
memory status --jsonsucceeded before indexing without creating a database file;memory indexthen created a valid schema-19 agent database, and another status succeeded with one indexed chunk, zero cache rows/bytes, and the cache table present. No table was manually added. An indexed canonical agent database without this table cannot be produced by the supported flow. The retained-cache case is also covered by the existing integration test and both full live recovery probes.The review's inferred data-model-change flag does not match the diff: there are no schema, storage representation, migration, or persistence-semantic changes. Full schema SQL/version and all 43 non-index tables remained identical through the live recovery proof. Production growth (+65 lines) provides read-only diagnostic facts and recovery guidance through existing owners.