fix(memoryManager): surface isArchived from getStates for tagged states#218
Merged
Conversation
The SQLite-metadata fast-path in MemoryService.getStates skipped the JSONL content fetch when stateMeta.tags was cached. The resulting skeleton-branch return path never surfaced state.metadata.isArchived to consumers, so: - The states UI list (PR #216) showed archived tagged states as if active. - The AI-facing listStates tool (PR #216) returned archived tagged states to the LLM as if active — partially breaking the AI-archive-only read contract from #215. Dropping the shortcut so adapter.getState always runs. Line 556's tag extraction OR-short-circuits when stateMeta.tags is set, so behavior on the untagged path is unchanged. Tool filter at listStates.ts:106 inherits the fix automatically (reads from the same getStates items). Tech debt: proper long-term fix is denormalizing is_archived into SQLite metadata so the fast-path can return a complete view (~80-120 LoC, v13 migration). Tracked as follow-up. Tests: - MemoryServiceGetStates.test.ts (NEW, +107): tagged-archived surfacing, tags preservation, explicit no-shortcut assertion. - npm run build clean; 220/222 suites, 2792/2809 tests pass. Follow-up to #216 manual-test finding (issue #215). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 26, 2026
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.
Summary
Bug found while manually testing PR #216 (issue #215): clicking the archive icon on a state in the workspace-settings UI did not remove it from the list, and the refresh button had no effect.
Root cause is a SQLite-metadata fast-path in
MemoryService.getStatesat line 555 — whenstateMeta.tagswas cached, the JSONL content fetch was skipped, and the skeleton return path never surfacedstate.metadata.isArchivedto consumers. This affected both the UI list filter and the AI-facinglistStatestool filter atlistStates.ts:106, partially breaking the AI-archive-only read contract from #215.Fix is surgical (1 line): drop the
stateMeta.tags ? null :shortcut soadapter.getStatealways runs. Line 556's tag-extraction OR-short-circuits whenstateMeta.tagsis set, so behavior on the untagged path is unchanged. Tool filter inherits the fix automatically (readsstate.state?.metadata?.isArchivedfrom the same items).Manual-tested in Obsidian — archive icon now removes tagged states from the list immediately.
Test plan
MemoryServiceGetStates.test.ts— 3 regression tests (tagged-archived isArchived surfacing, tags preservation, no-shortcut assertion).npm run buildclean (lint + tsc + esbuild + connector regen).npm test— 220/222 suites, 2792/2809 tests pass (2 pre-existing flakes unrelated).Follow-up tech debt (not blocking)
Proper long-term fix is denormalizing
is_archivedinto SQLite states metadata so the fast-path can return a complete view (~80-120 LoC, v12→v13 migration). The shortcut existed for perf — denormalization restores it without correctness cost. Will file as a separate issue post-merge.Follow-up to #215 manual-test finding (do not auto-close — #215 has further verification still pending after this lands).
🤖 Generated with Claude Code