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
manual async verification of StatsAggregator.get_memory_stats() for both profile classification and VikingFS fallback scenarios
pytest tests/unit/stats/test_stats_aggregator.py tests/unit/stats/test_stats_api.py -q is still blocked by the repo's known pytest-asyncio collection bug: AttributeError: 'Package' object has no attribute 'obj'
The filesystem fallback is only used when records_by_uri is completely empty. If VikingDB returns some but not all memory records, the missing ones won't be supplemented from the filesystem.
The filesystem scan should always run to supplement VikingDB records, not only when there are zero DB records. This ensures stats include all memories even if some are not yet indexed.
-if not records_by_uri:- for record in await self._scan_memory_filesystem(ctx):- uri = record.get("uri", "")- if isinstance(uri, str) and uri and uri not in records_by_uri:- records_by_uri[uri] = record+for record in await self._scan_memory_filesystem(ctx):+ uri = record.get("uri", "")+ if isinstance(uri, str) and uri and uri not in records_by_uri:+ records_by_uri[uri] = record
Suggestion importance[1-10]: 9
__
Why: The original code only supplements with filesystem records when there are zero DB records, which contradicts the PR's stated goal of supplementing indexed records. This fix ensures all unindexed memories are included, addressing a critical logical bug.
Updated based on the review suggestions. The stats fallback now supplements partial VikingDB results instead of only the empty-index case, and I added regression coverage for that path plus some debug logging around fallback reads.
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
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
viking://.../memories/profile.md/api/v1/stats/memories, but fall back to scanning the memory filesystem when no memory records are indexedVerification
python -m compileall openviking/storage/stats_aggregator.py tests/unit/stats/test_stats_aggregator.py tests/unit/stats/test_stats_api.pyStatsAggregator.get_memory_stats()for both profile classification and VikingFS fallback scenariospytest tests/unit/stats/test_stats_aggregator.py tests/unit/stats/test_stats_api.py -qis still blocked by the repo's knownpytest-asynciocollection bug:AttributeError: 'Package' object has no attribute 'obj'Closes #1255