diff --git a/scripts/persistent_registry.py b/scripts/persistent_registry.py index 06b80159..cb3a8f01 100644 --- a/scripts/persistent_registry.py +++ b/scripts/persistent_registry.py @@ -572,10 +572,17 @@ def get_cached_result( return None conn = self._connect() + # Tiebreak on the autoincrement id (monotonic) in addition to + # timestamp: set_cached_result() does a plain INSERT (not an + # upsert), so two writes for the same (command, file_set_hash) in + # quick succession can land on the same time.time() value (limited + # clock resolution) — ORDER BY timestamp alone then returns + # whichever row SQLite picks arbitrarily on the tie, which can be + # the stale one. row = conn.execute( """SELECT result_json FROM analysis_cache WHERE command = ? AND file_set_hash = ? - ORDER BY timestamp DESC LIMIT 1 + ORDER BY timestamp DESC, id DESC LIMIT 1 """, (command, file_set_hash), ).fetchone() diff --git a/tests/test_node_types.py b/tests/test_node_types.py index ac611568..d2c6a3cd 100644 --- a/tests/test_node_types.py +++ b/tests/test_node_types.py @@ -162,10 +162,13 @@ def test_unknown_language_raises(self): class TestGetSupportedLanguages: - """``get_supported_languages()`` lists all 7 tree-sitter languages.""" + """``get_supported_languages()`` lists all 13 tree-sitter languages.""" + # Issue #198 added go/java/php/ruby/c/cpp (6 languages) alongside the + # original 7 (python/rust/javascript/typescript/tsx/css/html) -> 13 total. EXPECTED_LANGUAGES = { - "python", "rust", "javascript", "typescript", "tsx", "css", "html" + "python", "rust", "javascript", "typescript", "tsx", "css", "html", + "go", "java", "php", "ruby", "c", "cpp", } def test_all_expected_languages_present(self):