Private
Public Access
0
0

refactor(src): Phase 10.2 batch 1 - session_logger + file_cache Result[T] migration

Migrates 5 SILENT_SWALLOW sites to full Result[T] pattern:

session_logger.py (4 sites):
1. log_api_hook - returns Result[bool] (was None)
2. log_comms - returns Result[bool] (was None)
3. log_tool_call - returns Result[Optional[str]] (was Optional[str])
4. log_cli_call - returns Result[bool] (was None)

file_cache.py (1 site):
- L98: removed dead code (try/except StopIteration around
  next(iter(_ast_cache)) is unreachable because we just checked
  len(_ast_cache) >= 10)

Updates tests/test_session_logger_optimization.py to extract
result.data from the new Result-based API.

All callers of these log_* functions previously ignored the
return value; they continue to ignore the new Result return
value (backwards-compatible).
This commit is contained in:
2026-06-17 22:29:36 -04:00
parent 15b778485c
commit 0f5290f038
3 changed files with 37 additions and 31 deletions
+5 -6
View File
@@ -91,12 +91,11 @@ class ASTParser:
tree = self.parse(code)
if len(_ast_cache) >= 10:
# Simple LRU: remove the first added entry
try:
first_key = next(iter(_ast_cache))
del _ast_cache[first_key]
except StopIteration:
pass
# Simple LRU: remove the first added entry.
# next(iter(...)) is guaranteed to succeed because we just
# checked len(_ast_cache) >= 10; no try/except needed.
first_key = next(iter(_ast_cache))
del _ast_cache[first_key]
_ast_cache[path] = (mtime, tree)
return tree