You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MemoryService.getStates (post-B1 read-path fix in #218 / v5.9.7) calls adapter.getState for every state in the workspace to surface state.metadata.isArchived. This is O(N) JSONL reads per UI/LLM listStates call.
Fine for small workspaces (<50 states).
Will degrade for power-user workspaces hitting 100–500+ states.
The "tagged-state shortcut" that previously caused archive-visibility bugs (#218) existed precisely because the original author tried to skip these reads — but the shortcut traded correctness for perf. Denormalizing isArchived into SQLite metadata restores the perf win without sacrificing correctness.
Scope sketch (~80–120 LoC)
v12→v13 schema migration: add is_archived INTEGER DEFAULT 0 column to the states metadata table.
WorkspaceEventApplier.applyStateSaved: write isArchived from content.state.metadata.isArchived (default 0/false).
WorkspaceEventApplier.applyStateUpdated: handle isArchived field updates (parse from data.stateJson when present).
IStorageAdapter.getStates: expose isArchived in StateMetadata result rows.
MemoryService.getStates: restore the conditional await adapter.getState — now safe to skip when metadata is complete. New shortcut shape:
Motivation
MemoryService.getStates(post-B1 read-path fix in #218 / v5.9.7) callsadapter.getStatefor every state in the workspace to surfacestate.metadata.isArchived. This is O(N) JSONL reads per UI/LLMlistStatescall.The "tagged-state shortcut" that previously caused archive-visibility bugs (#218) existed precisely because the original author tried to skip these reads — but the shortcut traded correctness for perf. Denormalizing
isArchivedinto SQLite metadata restores the perf win without sacrificing correctness.Scope sketch (~80–120 LoC)
is_archived INTEGER DEFAULT 0column to the states metadata table.WorkspaceEventApplier.applyStateSaved: writeisArchivedfromcontent.state.metadata.isArchived(default 0/false).WorkspaceEventApplier.applyStateUpdated: handleisArchivedfield updates (parse fromdata.stateJsonwhen present).IStorageAdapter.getStates: exposeisArchivedinStateMetadataresult rows.MemoryService.getStates: restore the conditionalawait adapter.getState— now safe to skip when metadata is complete. New shortcut shape:isArchivedthroughstateMetadataToWorkspaceStatedirectly whenfullStateis null.MemoryServiceGetStates.test.ts(from fix(memoryManager): surface isArchived from getStates for tagged states #218) should be updated to verify the SQLite path returnsisArchivedwithout callingadapter.getState.References