After implementing the recommended fix (320 bytes/20ms) and generating actual comparison audio, the test results show the fix performs WORSE than the current code.
✅ Total flushes: 26
After implementing the recommended fix (320 bytes/20ms) and generating actual comparison audio, the test results show the fix performs WORSE than the current code.
✅ Total flushes: 26
| #!/bin/bash | |
| # Simple Branch Comparison - Test main vs PR #1981 | |
| # | |
| # Uses only Test 2 (Reasoning Token Exhaustion) - the confirmed working test | |
| # | |
| # Usage: | |
| # export GEMINI_API_KEY="your-key" | |
| # bash /tmp/compare_fix.sh | |
| set -e |
| """ | |
| Test concurrent access to AdvancedSQLiteSession to verify lock protection. | |
| This test verifies the fix for Codex's P1 review comment: | |
| - _get_current_turn_number(), _get_next_turn_number(), _get_next_branch_turn_number() | |
| and list_branches() now properly acquire self._lock when accessing shared connection. | |
| Without proper locking, concurrent operations would cause: | |
| - sqlite3.ProgrammingError: Recursive use of cursors not allowed | |
| - Data inconsistency |
| """ | |
| Comprehensive stress test for SQLiteSession with file descriptor monitoring. | |
| This test demonstrates the fix for two critical bugs: | |
| 1. threading.Lock() being created anew on every operation (no thread safety) | |
| 2. File descriptor leak from thread-local connections in ThreadPoolExecutor | |
| Test setup: | |
| - 30 concurrent writers + 10 concurrent readers | |
| - 60 seconds duration |
| """ | |
| Medium stress test - 15 workers, 30 seconds | |
| """ | |
| import asyncio | |
| import threading | |
| import time | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).parent / "src")) |
| #!/usr/bin/env python3 | |
| """ | |
| Test SQLite file-based database threading behavior. | |
| Verifies that thread-local connections + nullcontext() is safe for concurrent access. | |
| """ | |
| import asyncio | |
| import sqlite3 | |
| import tempfile | |
| import threading | |
| from contextlib import nullcontext |