codebase: cleaning cruft part 1

This commit is contained in:
ed
2026-07-05 13:46:35 -04:00
parent deae250019
commit 27f2c25f1c
22 changed files with 64 additions and 371 deletions
+5 -20
View File
@@ -8,10 +8,7 @@ from src.result_types import Result, ErrorInfo, ErrorKind
def get_file_hash(content: str) -> str:
"""
Returns SHA256 hash of the content.
[C: tests/test_summary_cache.py:test_get_file_hash, tests/test_summary_cache.py:test_summary_cache]
"""
"""Returns SHA256 hash of the content."""
return hashlib.sha256(content.encode("utf-8")).hexdigest()
class SummaryCache:
@@ -30,10 +27,7 @@ class SummaryCache:
self.load()
def load(self) -> Result[bool]:
"""
Loads cache from disk.
[C: src/tool_presets.py:ToolPresetManager._read_raw, src/workspace_manager.py:WorkspaceManager._load_file, tests/test_gui_phase3.py:test_create_track, tests/test_history_management.py:test_save_separation, tests/test_session_logging.py:test_open_session_creates_subdir_and_registry]
"""
"""Loads cache from disk."""
if not self.cache_file.exists():
return Result(data=False)
try:
@@ -55,10 +49,7 @@ class SummaryCache:
return Result(data=False, errors=[ErrorInfo(kind=ErrorKind.INTERNAL, message=str(e), source="summary_cache.save", original=e)])
def get_summary(self, file_path: str, content_hash: str) -> str:
"""
Returns cached summary if hash matches, otherwise "".
[C: tests/test_summary_cache.py:test_summary_cache, tests/test_summary_cache.py:test_summary_cache_lru]
"""
"""Returns cached summary if hash matches, otherwise ""."""
entry = self.cache.get(file_path)
if entry and entry.get("hash") == content_hash:
# LRU: move to end
@@ -68,10 +59,7 @@ class SummaryCache:
return ""
def set_summary(self, file_path: str, content_hash: str, summary: str) -> None:
"""
Stores summary in cache and saves to disk.
[C: tests/test_summary_cache.py:test_summary_cache, tests/test_summary_cache.py:test_summary_cache_lru]
"""
"""Stores summary in cache and saves to disk."""
if file_path in self.cache:
self.cache.pop(file_path)
self.cache[file_path] = {
@@ -86,10 +74,7 @@ class SummaryCache:
self.save()
def clear(self) -> Result[bool]:
"""
Clears the cache both in-memory and on disk.
[C: tests/conftest.py:reset_ai_client]
"""
"""Clears the cache both in-memory and on disk."""
self.cache.clear()
if not self.cache_file.exists():
return Result(data=True)