Fix #2131: [Bug] memos-local-plugin : chunks table never created — causes viewer dashboard #2132
Open
Memtensor-AI wants to merge 2 commits into
Open
Conversation
…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>
5 tasks
Collaborator
Author
🤖 Open Code ReviewTarget: PR #2132 ✅ OpenCodeReview: No comments generated. Looks good to me. Generated by cloud-assistant via Open Code Review. |
Collaborator
Author
🔧 Open Code Review requested Agent fixOpen Code Review found 3 issue(s). I have resumed the development Agent to fix them.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
chunkstable): the only 2.0 code referencingchunksis the legacy 1.0-import reader inserver/routes/migrate.ts, which reads the OLD 1.0 database; the live dashboard and retrieval pipeline querytraces/episodes/sessionswith vectors in BLOB columns, so no schema/migration change is needed. Neither of the issue's suggested options (A: createchunks; B: migrate code offchunks) 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 derivesprofileId = ctx.agentId). Viewer read paths —metrics().totalviacountTurns(visibilityWhere(activeNamespace)), pluslistEpisodes/listSkills/listPolicies/listWorldModels/listTracesviavisibleToCurrent— 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 theisVisibleToclauses, 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 tocore.metrics()andcore.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.
How Has This Been Tested?
Not run; documentation-only change.
Checklist
@whipser030, @hijzy, @wustzdy please review this PR.
Reviewer Checklist