⚠ SPEED CAVEAT: Cloud model (run via opencode, not LM Studio) — tok_sec/tokens/TTFT are N/A (not measured for cloud). Included as a quality baseline against the local models. NOTE: it took 3 attempts to produce any output and ~12 minutes of thinking before succeeding — so it is a QUALITY benchmark, not a speed/usability one.
runtimeCLOUD — not measured
▮ PILLAR BREAKDOWN
Complexity (O(1))
18/20
Concurrency / Races
18/20
Tx Isolation
19/20
Memory & Edges
18/20
Test Integrity
18/20
✓ WENT RIGHT
Tx Isolation (19/20)
Complexity (O(1)) (18/20)
Concurrency / Races (18/20)
Memory & Edges (18/20)
Test Integrity (18/20)
✗ WENT WRONG
No pillar fell below 14 — solid across the board.
▮ CRITICAL BUGS
Two min(self._freq_to_list) linear scans in _evict_one's defensive recovery path (lines 415, 429) — only triggered when min_freq desyncs, not per-operation, but still a non-O(1) path. Could be replaced with incremental tracking.
Single coarse lock held across the whole commit-apply loop — not the fine-grained locking the prompt asked for.
__slots__ present on _Node and _DLL but not extended to Transaction / LFUCache.
No explicit lost-update/conflict abort on commit (delta-based freq is applied unconditionally).
Tests pass 20/20 but don't include a mid-commit read-isolation probe or adversarial eviction-under-contention stress.
▮ RECOMMENDED USE
Reference-quality baseline (91/100) — the bar the local models are measured against. Only submission with __slots__ + time.monotonic() + delta-based transactional frequency accounting. Sets the ceiling for correctness, though its unreliability (3 attempts, 12-min think time) makes it a poor *local* daily-driver.
▮ REFACTORED PATCH
# These are minor refinements on an already production-ready file.
# FIX 1: eliminate the recovery min() scans by keeping min_freq
# strictly in sync on every insert/bump/remove (it already does on
# the hot path), so the _evict_one recovery branch is unreachable and
# can assert instead of scanning:
assert self._min_freq in self._freq_to_list or not self._freq_to_list
# FIX 2: extend __slots__ to Transaction and LFUCache.
class LFUCache(Generic[KT, VT]):
__slots__ = ('_capacity','_key_to_node','_freq_to_list','_min_freq',
'_lock','_ttl_index','_evictor_task','_closed')
# FIX 3 (optional): on commit, if a key's global node changed since the
# tx snapshot, raise LFUCacheError('lost update') instead of overwriting.