Skip to content

fix(memory-core): exclude archived transcripts from Dreaming session corpus#90433

Closed
xiaobao-k8s wants to merge 6 commits into
openclaw:mainfrom
xiaobao-k8s:fix/dreaming-exclude-archives
Closed

fix(memory-core): exclude archived transcripts from Dreaming session corpus#90433
xiaobao-k8s wants to merge 6 commits into
openclaw:mainfrom
xiaobao-k8s:fix/dreaming-exclude-archives

Conversation

@xiaobao-k8s

@xiaobao-k8s xiaobao-k8s commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Archived session transcripts (.jsonl.reset.* and .jsonl.deleted.*) are
currently ingested into the Dreaming corpus, polluting analysis with
reset/deleted cron-spawned subagent noise. On a cron-heavy deployment,
this causes 67-91% of the daily corpus to be dominated by automation
noise, suppressing pattern discovery. This is particularly visible on
workspaces where cron jobs frequently spawn subagents whose transcripts get
reset/deleted but remain in the session directory as usage-counted archives.

Changes

  • Reuse the SDK-exported isSessionArchiveArtifactName classifier so Dreaming
    follows the canonical archive filename contract instead of carrying a local regex
  • Add archive-exclusion filter in collectSessionIngestionBatches so
    Dreaming corpus assembly skips archived transcripts
  • Preserve memory_search archive indexing path unchanged (only Dreaming
    ingestion is affected)
  • Add corpus-level regression coverage for fresh ordinary reset archives,
    including archive timestamps without milliseconds (...T18-10-00Z)

Real behavior proof

Behavior or issue addressed: Before the fix, Dreaming session-corpus assembly could ingest usage-counted reset/deleted archive transcripts and, after refreshing against current main, could also fail to preserve skipped-transcript checkpoint semantics for generated dreaming/isolated-cron transcripts. After the fix, Dreaming excludes session archive artifacts from the session corpus, keeps generated dreaming/cron run transcripts out of corpus output, preserves skipped checkpoints with zero ingested content lines, and keeps legacy JSON sessions.json classification compatible with the current SQLite session-store loader.
Real environment tested: Repository openclaw/openclaw, branch fix/dreaming-exclude-archives, commit 61fd2d6f9cc5, local Linux worktree /datad/github/openclaw-issue90313 refreshed against current origin/main, using real OpenClaw session storage under /root/.openclaw/agents for the patched Dreaming storage proof and a temp workspace/plugin-state store for output isolation.
Exact steps or command run after this patch:

git diff --check
pnpm exec oxlint extensions/memory-core/src/dreaming-phases.ts packages/memory-host-sdk/src/host/session-files.ts
OPENCLAW_TEST_FAST=1 node scripts/test-projects.mjs extensions/memory-core/src/dreaming-phases.test.ts packages/memory-host-sdk/src/host/session-files.test.ts
./node_modules/.bin/tsx /tmp/openclaw-90433-real-storage-proof.ts > /tmp/openclaw-90433-real-storage-proof-clean.json
jq '{realStateRoot,totalJsonl,archiveCount,liveCount,agentCount,corpusFileCount:(.corpusFiles|length),liveLineCount,archiveAbsence: [.archiveAbsence[] | {agent,file,absent}][0:5]}' /tmp/openclaw-90433-real-storage-proof-clean.json

Evidence after fix: Terminal output from the verification:

=== diff --check ===
=== oxlint changed files ===
Found 0 warnings and 0 errors.
Finished in 49ms on 2 files with 208 rules using 8 threads.
=== focused tests quick rerun ===
packages/memory-host-sdk/src/host/session-files.test.ts: 12 passed
extensions/memory-core/src/dreaming-phases.test.ts: 45 passed
[test] passed 2 Vitest shards in 112.86s

Real storage proof summary:
{
  "realStateRoot": "/root/.openclaw/agents",
  "totalJsonl": 627,
  "archiveCount": 73,
  "liveCount": 554,
  "agentCount": 7,
  "corpusFileCount": 17,
  "liveLineCount": 240,
  "archiveAbsence": [
    { "agent": "hr-agent", "file": "30d9dd9e-8281-48eb-bf65-c2d4086d7163.jsonl.reset.2026-05-31T02-45-36.108Z", "absent": true },
    { "agent": "hr-agent", "file": "37325983-4da0-49cc-8747-1bdcf4b0342a.jsonl.reset.2026-06-03T08-50-31.129Z", "absent": true },
    { "agent": "hr-agent", "file": "3b72e1cc-a0c0-4378-92fa-473dfe21551a.jsonl.reset.2026-05-23T13-55-57.715Z", "absent": true },
    { "agent": "hr-agent", "file": "43fb8e14-c895-46c0-a5eb-4eae0014cbbd.jsonl.reset.2026-05-29T23-16-37.488Z", "absent": true },
    { "agent": "hr-agent", "file": "53c23768-32e0-4772-9f8a-0944bde75f52.jsonl.reset.2026-05-29T00-41-25.765Z", "absent": true }
  ]
}

Observed result after fix: The refreshed branch builds a Dreaming session corpus from live real session storage while sampled .jsonl.reset.* archive transcripts remain absent from the corpus; generated dreaming and isolated cron transcript checkpoints are retained as zero ingested content lines; focused regression suites pass on the refreshed main branch.
What was not tested: Full repository test suite and full production gateway run were not executed; validation was limited to changed-file lint, focused memory-core/SDK regressions, and a patched Dreaming run over real local session storage with redacted/archive-only file identifiers.

Test Plan

  1. git diff --check
  2. pnpm exec oxlint extensions/memory-core/src/dreaming-phases.ts extensions/memory-core/src/dreaming-phases.test.ts — 0 warnings, 0 errors
  3. OPENCLAW_TEST_FAST=1 node scripts/test-projects.mjs extensions/memory-core/src/dreaming-phases.test.ts — 45 tests, all passing
  4. OPENCLAW_TEST_FAST=1 node scripts/test-projects.mjs packages/memory-host-sdk/src/host/session-files.test.ts — 12 tests, all passing

Risk

  • Low risk: the change is a purely additive filter in the Dreaming ingestion
    loop. Archive files are still indexed for memory_search through the
    unchanged listSessionFilesForAgentbuildSessionEntry path used by
    manager-sync-ops.ts and qmd-manager.ts.
  • No change to the memory_search contract for reset/deleted archive
    indexing.

Related Issue

Refs #90313 (archive transcript Dreaming corpus pollution).
Note: the broader cron-descended subagent classification issue mentioned in
the linked report is outside this patch's scope and remains tracked separately.

Follow-up after ClawSweeper review

  • Removed the runtime legacy sessions.json fallback from packages/memory-host-sdk/src/host/session-files.ts; SQLite session metadata remains the canonical runtime source.
  • Kept the Dreaming archive transcript exclusion and checkpoint-alignment changes unchanged.
  • Re-ran focused validation after the fallback removal:
    • git diff --check — passed
    • pnpm exec oxlint extensions/memory-core/src/dreaming-phases.ts extensions/memory-core/src/dreaming-phases.test.ts — 0 warnings, 0 errors
    • OPENCLAW_TEST_FAST=1 node scripts/test-projects.mjs extensions/memory-core/src/dreaming-phases.test.ts — 45/45 passed
    • OPENCLAW_TEST_FAST=1 node scripts/test-projects.mjs packages/memory-host-sdk/src/host/session-files.test.ts — 12/12 passed

…corpus

Archived session transcripts (.jsonl.reset.* and .jsonl.deleted.*) are
currently ingested into the Dreaming corpus, polluting analysis with
reset/deleted cron-spawned subagent noise. On a cron-heavy deployment,
this causes 67-91% of the daily corpus to be dominated by automation
noise, suppressing pattern discovery.

Add a Dreaming-specific archive-exclusion boundary: a new
isSessionArchiveTranscriptPath helper detects .jsonl.reset.* and
.jsonl.deleted.* archives, and collectSessionIngestionBatches skips them
during corpus assembly. This preserves memory_search archive indexing
via the existing listSessionFilesForAgent path, which is unchanged for
non-Dreaming callers.

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

clawsweeper Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close: this PR is now superseded by the merged session-corpus metadata implementation, which covers the archive exclusion and the broader cron-lineage defect on current main.

Root-cause cluster
Relationship: superseded
Canonical: #96517
Summary: This PR is superseded by the merged maintainer-owned replacement that closed the canonical Dreaming corpus pollution issue and moved the fix to the session transcript corpus seam.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Keep the merged #96517 implementation as the canonical path and close this conflicting archive-only branch.

So I’m closing this here and keeping the remaining discussion on #96517.

Review details

Best possible solution:

Keep the merged #96517 implementation as the canonical path and close this conflicting archive-only branch.

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

No for current main: source inspection shows Dreaming now skips archive-artifact corpus entries and classifies cron-descended session lineage before ingestion. The original pre-fix failure path is documented in the PR diff and linked issue, but it is superseded on current main.

Is this the best way to solve the issue?

No for this branch now. It was a plausible archive-only fix, but the best current solution is the merged session-transcript-corpus metadata seam from #96517 because it also handles cron lineage and avoids a duplicate Dreaming-local source of truth.

Security review:

Security review cleared: The PR changes memory-core TypeScript ingestion logic and tests only; no workflow, dependency, lockfile, script, credential, or third-party execution surface is changed.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

Codex review notes: model internal, reasoning high; reviewed against 6cb82eaab865; fix evidence: commit da50a450d271, main fix timestamp 2026-06-24T11:29:26-07:00.

@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 4, 2026
…VE_TIMESTAMP_RE

Make the milliseconds portion of the archive timestamp optional
((?:\.\d{3})?Z), matching the canonical contract in
src/config/sessions/artifacts.ts. Previously the local regex required
exactly three millisecond digits (\.\d{3}Z), which could miss valid
usage-counted archive transcripts without the optional millisecond
portion.

The plugin SDK boundary prevents direct import of the host's
isSessionArchiveArtifactName; this change aligns the local regex to the
same contract.
@xiaobao-k8s

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 5, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Jun 5, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Jun 7, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 7, 2026
@xiaobao-k8s

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@xiaobao-k8s

Copy link
Copy Markdown
Contributor Author

Updated after the latest review and refreshed the branch against current origin/main.

Changes since the previous proof attempt:

  • Merged current main into fix/dreaming-exclude-archives.
  • Kept the archive exclusion behavior and added the refresh-required compatibility fix for skipped dreaming / isolated-cron transcript checkpoints.
  • Added legacy JSON sessions.json classification fallback for the memory-host SDK path now that the session store loader is SQLite-first.
  • Replaced the PR body proof with a patched Dreaming run over real local session storage (/root/.openclaw/agents) and redacted archive-absence evidence.

Local verification on head 61fd2d6f9cc5:

  • git diff --check
  • pnpm exec oxlint extensions/memory-core/src/dreaming-phases.ts packages/memory-host-sdk/src/host/session-files.ts → 0 errors
  • OPENCLAW_TEST_FAST=1 node scripts/test-projects.mjs extensions/memory-core/src/dreaming-phases.test.ts packages/memory-host-sdk/src/host/session-files.test.ts → 57 tests passed
  • Real storage proof: 627 jsonl files scanned, 73 archive files detected/excluded, 240 live corpus lines produced, sampled archive transcripts absent: true.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 8, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 8, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed size: S proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Jun 9, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 9, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 Jun 30, 2026
@xiaobao-k8s

Copy link
Copy Markdown
Contributor Author

Closing per ClawSweeper review: this PR has been superseded by #96517 (session-corpus metadata implementation). Thanks for the contribution!

@xiaobao-k8s xiaobao-k8s closed this Jul 7, 2026
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 merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant