Skip to content

Fix #2131: [Bug] memos-local-plugin : chunks table never created — causes viewer dashboard #2132

Open
Memtensor-AI wants to merge 2 commits into
MemTensor:dev-v2.0.25from
Memtensor-AI:bugfix/autodev-2131-20260720122936585
Open

Fix #2131: [Bug] memos-local-plugin : chunks table never created — causes viewer dashboard #2132
Memtensor-AI wants to merge 2 commits into
MemTensor:dev-v2.0.25from
Memtensor-AI:bugfix/autodev-2131-20260720122936585

Conversation

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

Description

Fixes the memos-local-plugin 2.0 viewer dashboard "data drift to zero" reported in #2131. Root-cause analysis disproved the issue's hypothesis (a missing chunks table): the only 2.0 code referencing chunks is the legacy 1.0-import reader in server/routes/migrate.ts, which reads the OLD 1.0 database; the live dashboard and retrieval pipeline query traces/episodes/sessions with vectors in BLOB columns, so no schema/migration change is needed. Neither of the issue's suggested options (A: create chunks; B: migrate code off chunks) applies.

The actual root cause: the core keeps a mutable shared activeNamespace (core/pipeline/memory-core.ts:542) that every turn/session entry point rewrites from caller context hints (openclaw bridge derives profileId = ctx.agentId). Viewer read paths — metrics().total via countTurns(visibilityWhere(activeNamespace)), plus listEpisodes/listSkills/listPolicies/listWorldModels/listTraces via visibleToCurrent — filtered through that variable. When the gateway opened its session (~10-20 s after boot) or a sub-agent turn arrived, the profile flipped and all historical rows failed the isVisibleTo clauses, collapsing every dashboard count to zero. This exactly matches the reported repro ("correct momentarily, zero on first message").

Fix: complete the codebase's own established viewer convention (includeAllNamespaces: true, already used by diag.ts/session.ts/memory.ts). Added the option to core.metrics() and core.listEpisodes() (the only viewer readers lacking it, plus agent-contract signatures) and passed it from the routes that missed it: overview.ts (all five aggregate reads), metrics.ts (metrics + listTraces), trace.ts (listTraces + countTraces), session.ts (listEpisodes, matching its own countEpisodes). Explicit ownerAgentKind/ownerProfileId query filters still narrow (applied independently of the flag), and turn-time auto-recall namespace isolation is intentionally unchanged (pinned by the existing multi-profile isolation test); relaxing recall isolation for single-user installs is flagged as a follow-up product decision, as are the reporter's independently-bisected ONNX-corruption/provider-fallback issues.

Verification (TDD): new regression test "keeps metrics + listEpisodes stable across a namespace flip" was red before the fix (total collapsed 1 -> 0) and is green after; it also pins scoped-read isolation. Full unit suite: 1153 passed with only 2 failures verified pre-existing on the clean base branch via git stash (storage/migrator #1787 case, startup-recovery). Integration suite: 4 passed. tsc --noEmit (the repo's lint script): clean. opsp artifacts (task.md, proposal, spec, design, verification-report) archived to memos-autodev-specs.

Related Issue (Required): Fixes #2131

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Not run; documentation-only change.

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have created related documentation issue/PR in MemOS-Docs (if applicable)
  • I have linked the issue to this PR (if applicable)
  • I have mentioned the person who will review this PR

@whipser030, @hijzy, @wustzdy please review this PR.

Reviewer Checklist

…r#2131)

The viewer's Overview/metrics/traces/session routes filtered reads
through the core's mutable activeNamespace, which every turn/session
rewrites from caller context hints (openclaw: profileId = ctx.agentId).
When the gateway session or a sub-agent turn flipped the profile, all
historical rows failed the visibility clauses and dashboard counts
collapsed to zero.

The reported root cause (missing chunks table) is a misdiagnosis: the
only 2.0 reference to chunks is the legacy 1.0-import reader in
server/routes/migrate.ts; the live pipeline queries traces/episodes/
sessions with vectors stored in BLOB columns, so no schema change is
needed.

Fix: complete the existing includeAllNamespaces viewer convention
(already used by diag.ts/session.ts/memory.ts) — add the option to
core.metrics() and core.listEpisodes(), and pass it from overview.ts,
metrics.ts, trace.ts and session.ts. Scoped reads and turn-time
retrieval isolation are unchanged; explicit owner filters still narrow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Memtensor-AI Memtensor-AI added ai:generated Generated or modified by AI | 由 AI 生成或修改 area:plugin OpenClaw & Hermes status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Jul 20, 2026
@Memtensor-AI
Memtensor-AI requested review from hijzy and whipser030 July 20, 2026 13:32
@Memtensor-AI

Memtensor-AI commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator Author

🤖 Open Code Review

Target: PR #2132
Task: d757c50e2e9ae11c
Base: dev-v2.0.25
Head: bugfix/autodev-2131-20260720122936585
Head SHA: 67a48630014fb07f6665ff3ccacc65c2c476269d

OpenCodeReview: No comments generated. Looks good to me.

Generated by cloud-assistant via Open Code Review.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

🔧 Open Code Review requested Agent fix

Open Code Review found 3 issue(s). I have resumed the development Agent to fix them.

  • Task: d757c50e2e9ae11c
  • Fix attempt: 1/2
  • Finding delta: 0 repeated / 3 new / 0 likely resolved

The Agent will push a new commit to this PR branch. OCR will recheck after the commit is pushed.

Follow-up to MemTensor#2131 (OCR round 1/2):

- listApiLogs: accept includeAllNamespaces in the contract and core
  facade (contract symmetry with listTraces/listSkills/listPolicies);
  metrics/tools now passes it explicitly so both feeds of the bump()
  aggregation are scoped identically
- metrics(): document that the traces fetch feeding sessions/
  writesToday/embeddings/dailyWrites is intentionally cross-namespace;
  only totalTurns respects includeAllNamespaces
- listEpisodes: apply limit/offset after the visibility filter on the
  namespace-scoped path so pages are not silently under-filled by
  other namespaces' rows

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Memtensor-AI Memtensor-AI added status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发 and removed status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:generated Generated or modified by AI | 由 AI 生成或修改 area:plugin OpenClaw & Hermes status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants