Skip to content

fix(memory): align session file counter denominator with indexer filter (fixes #77338)#93064

Closed
liuhao1024 wants to merge 1 commit into
openclaw:mainfrom
liuhao1024:fix/memory-session-counter-overflow
Closed

fix(memory): align session file counter denominator with indexer filter (fixes #77338)#93064
liuhao1024 wants to merge 1 commit into
openclaw:mainfrom
liuhao1024:fix/memory-session-counter-overflow

Conversation

@liuhao1024

@liuhao1024 liuhao1024 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

What

openclaw memory status reports sessions · N/M where N > M (numerator exceeds denominator) when .jsonl.reset.* or .jsonl.deleted.* archive files exist in the sessions directory.

Root cause: scanSessionFiles (denominator) uses .endsWith(".jsonl") which only counts primary transcript files. The indexer listSessionFilesForAgent (numerator) uses isUsageCountedSessionTranscriptFileName which also includes reset/deleted archive files. This filter divergence causes the overflow.

Fix: Replace .endsWith(".jsonl") with isUsageCountedSessionTranscriptFileName in scanSessionFiles to align the denominator with the indexer.

Fixes #77338

Real behavior proof

  • Behavior addressed: Session file counter in openclaw memory status showing N > M when archive artifacts exist
  • Environment tested: macOS 26.4.1, Node.js, openclaw/openclaw main branch
  • Steps run after the patch:
    1. Verified scanSessionFiles uses isUsageCountedSessionTranscriptFileName via grep
    2. Built the project with pnpm build — compiled successfully
    3. Verified the built output contains the updated filter
    4. Ran src/config/sessions/artifacts.test.ts — 9 verification passes
  • Evidence after fix:
$ grep -n 'isUsageCountedSessionTranscriptFileName' extensions/memory-core/src/cli.runtime.ts
12:import { isUsageCountedSessionTranscriptFileName } from "openclaw/plugin-sdk/memory-core-host-engine-qmd";
530:      (entry) => entry.isFile() && isUsageCountedSessionTranscriptFileName(entry.name),

$ grep -n 'isUsageCountedSessionTranscriptFileName\|scanSessionFiles' dist/cli.runtime-*.js
12:import { b as isUsageCountedSessionTranscriptFileName, l as resolveSessionTranscriptsDirForAgent } from "./paths-NEwU8m3X.js";
284:async function scanSessionFiles(agentId) {
290:			totalFiles: (await fs$1.readdir(sessionsDir, { withFileTypes: true })).filter((entry) => entry.isFile() && isUsageCountedSessionTranscriptFileName(entry.name)).length,
390:		if (source === "sessions") scans.push(await scanSessionFiles(params.agentId));

$ pnpm build
✓ built in 485ms
  • Observed result after fix: Denominator filter now matches indexer filter — both use isUsageCountedSessionTranscriptFileName which includes primary .jsonl files plus .jsonl.reset.* and .jsonl.deleted.* archives
  • What was not tested: Live openclaw memory status command on a container with archive files (requires agent setup with session history)

scanSessionFiles used .endsWith('.jsonl') for the denominator, but the
indexer (listSessionFilesForAgent) uses isUsageCountedSessionTranscriptFileName
which also includes .jsonl.reset.* and .jsonl.deleted.* archive artifacts.
This filter divergence caused the sessions counter to show N > M (numerator
exceeds denominator) when archive files exist.

Switch the denominator filter to isUsageCountedSessionTranscriptFileName
to match the indexer's enumeration.

Fixes openclaw#77338
@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core proof: supplied External PR includes structured after-fix real behavior proof. size: XS labels Jun 14, 2026
@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 15, 2026, 4:25 PM ET / 20:25 UTC.

Summary
The PR changes extensions/memory-core/src/cli.runtime.ts so the memory status session-file denominator uses the shared usage-counted session transcript predicate instead of a strict .jsonl suffix check.

PR surface: Source +1. Total +1 across 1 file.

Reproducibility: yes. Source inspection gives a high-confidence reproduction path: create usage-counted reset/deleted archive files under the agent sessions directory, then current memory status counts only strict .jsonl files while the indexer counts the helper-selected archive set.

Review metrics: none identified.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted openclaw memory status output from a real setup containing .jsonl.reset.* or .jsonl.deleted.* files.
  • After adding proof, update the PR body so ClawSweeper re-reviews automatically; if it does not, ask a maintainer to comment @clawsweeper re-review.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body provides source/build/test evidence, but no after-fix real openclaw memory status output from a setup with reset/deleted archive files; the contributor should add redacted terminal output, a terminal screenshot, copied live output, or logs and then update the PR body to trigger re-review.

Risk before merge

  • [P1] The submitted proof does not show the actual openclaw memory status command after the patch on a sessions directory containing .jsonl.reset.* or .jsonl.deleted.* files.

Maintainer options:

  1. Decide the mitigation before merge
    Merge the focused predicate alignment after the contributor adds redacted real CLI output showing the session counter no longer overflows with reset/deleted archives present.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] The remaining blocker is contributor-supplied real behavior proof plus ordinary maintainer review, not an automatable code repair.

Security
Cleared: The diff only changes a TypeScript import and filename predicate in memory-core status scanning; it does not touch secrets, workflows, package metadata, dependencies, or code-execution surfaces.

Review details

Best possible solution:

Merge the focused predicate alignment after the contributor adds redacted real CLI output showing the session counter no longer overflows with reset/deleted archives present.

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

Yes. Source inspection gives a high-confidence reproduction path: create usage-counted reset/deleted archive files under the agent sessions directory, then current memory status counts only strict .jsonl files while the indexer counts the helper-selected archive set.

Is this the best way to solve the issue?

Yes. This PR is the best narrow fix for the counter mismatch because reset/deleted archive recall is an intentional current contract; excluding those archives from indexing would regress protected memory-search behavior.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a bounded memory status correctness fix for a misleading session index counter with limited blast radius.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides source/build/test evidence, but no after-fix real openclaw memory status output from a setup with reset/deleted archive files; the contributor should add redacted terminal output, a terminal screenshot, copied live output, or logs and then update the PR body to trigger re-review.
Evidence reviewed

PR surface:

Source +1. Total +1 across 1 file.

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

What I checked:

Likely related people:

  • steipete: Authored the commit that introduced the memory-core extension CLI runtime surface containing scanSessionFiles. (role: feature-history owner; confidence: medium; commits: 3d0050c306ac; files: extensions/memory-core/src/cli.runtime.ts, extensions/memory-core/src/cli.test.ts)
  • rcrick: Authored the merged change that introduced reset/deleted archives as usage-counted transcript files. (role: session artifact contract contributor; confidence: high; commits: 2fe1ff8ea8ab; files: src/config/sessions/artifacts.ts, src/config/sessions/artifacts.test.ts, src/infra/session-cost-usage.ts)
  • frankekn: Merged the usage-counted archive PR that established the predicate contract this PR now reuses. (role: merger; confidence: medium; commits: 2fe1ff8ea8ab; files: src/config/sessions/artifacts.ts, src/infra/session-cost-usage.ts)
  • vincentkoc: Authored and merged the QMD session export fix that moved listSessionFilesForAgent to the usage-counted predicate used by the indexer path. (role: recent area contributor; confidence: high; commits: b7d59f783152; files: packages/memory-host-sdk/src/host/session-files.ts, packages/memory-host-sdk/src/host/session-files.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jun 14, 2026
@liuhao1024

Copy link
Copy Markdown
Contributor Author

Auto-cleanup: freeing PR slots for higher-quality contributions. Feel free to reopen if still relevant.

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: supplied External PR includes structured after-fix real behavior proof. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[memory] sessions source counter overflow: tombstones and reset snapshots indexed as live files

1 participant