personal memory agent
0

Configure Feed

Select the types of activity you want to include in your feed.

perf(test): speed up over-provisioned slow tests; fix freezegun durations artifact

C0: add _pytest/pytest to FREEZEGUN_IGNORE so --durations stops
reporting the bogus ~1.7e9s setup for test_api_baseline[convey];
the freeze itself is unchanged, baselines pass identically.
C1: test_cancel_commit_race_runs_at_most_once synchronises on a
threading.Event from commit() + a join on the real Timer handle
instead of a blind 0.15s sleep. Real Timer and 50 iterations
preserved, no fake clock; at-most-once/xor assertions kept and
strengthened (timer-dead + commit-not-fired now asserted).
7.63s -> 0.03s.
C2: callosum stop() now closes the listening socket via an
idempotent _close_server_socket() (lock-guarded read-and-null,
OSError-swallowing), shared with the accept-loop finally, so a
blocked accept() is interrupted on shutdown instead of waiting
the 1.0s accept timeout. No double-close, no stop()-originated
exception, behaviour otherwise equivalent. Drops the
test_cortex_client teardown cluster (~0.8-1.0s x ~8).
C3: test_readiness timeout/poll-interval trims (real-timeout
behaviour unchanged; assertions verbatim).
C4: test_importer_stall_timeout wait args trimmed; elapsed<2.0
assertions unchanged.

Real timeout-path tests (test_wait_for_agents_timeout_actual,
_missed_event_recovery) untouched. Counts unchanged (4923/11/8).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

+44 -10
+24 -2
solstone/think/callosum.py
··· 49 49 with self.lock: 50 50 return len(self.clients) 51 51 52 + def _close_server_socket(self) -> None: 53 + with self.lock: 54 + server_socket = self.server_socket 55 + self.server_socket = None 56 + 57 + if server_socket is None: 58 + return 59 + 60 + try: 61 + server_socket.shutdown(socket.SHUT_RDWR) 62 + except OSError: 63 + pass 64 + try: 65 + server_socket.close() 66 + except OSError: 67 + pass 68 + 52 69 def start(self) -> None: 53 70 """Start the broadcast server.""" 54 71 # Ensure health directory exists ··· 75 92 try: 76 93 while not self.stop_event.is_set(): 77 94 try: 78 - conn, _ = self.server_socket.accept() 95 + with self.lock: 96 + server_socket = self.server_socket 97 + if server_socket is None: 98 + break 99 + conn, _ = server_socket.accept() 79 100 # Handle client in background thread 80 101 threading.Thread( 81 102 target=self._handle_client, args=(conn,), daemon=True ··· 86 107 if not self.stop_event.is_set(): 87 108 logger.error(f"Accept error: {e}") 88 109 finally: 89 - self.server_socket.close() 110 + self._close_server_socket() 90 111 if self.socket_path.exists(): 91 112 self.socket_path.unlink() 92 113 ··· 218 239 def stop(self) -> None: 219 240 """Stop the server and writer thread.""" 220 241 self.stop_event.set() 242 + self._close_server_socket() 221 243 222 244 # Wait for writer thread to finish 223 245 if self.writer_thread and self.writer_thread.is_alive():
+2
tests/test_api_baselines.py
··· 26 26 ) 27 27 28 28 FREEZEGUN_IGNORE = [ 29 + "_pytest", 29 30 "librosa", 30 31 "numba", 31 32 "pandas", 32 33 "pyarrow", 34 + "pytest", 33 35 "scipy", 34 36 "sentencepiece", 35 37 "sklearn",
+1 -1
tests/test_cortex_client.py
··· 578 578 579 579 def wait_thread(): 580 580 result["completed"], result["timed_out"] = wait_for_uses( 581 - [completing_agent, timeout_agent], timeout=2 581 + [completing_agent, timeout_agent], timeout=1 582 582 ) 583 583 584 584 waiter = threading.Thread(target=wait_thread)
+10 -1
tests/test_deferred_deletes.py
··· 62 62 for _ in range(iterations): 63 63 commit_count = 0 64 64 commit_lock = threading.Lock() 65 + commit_event = threading.Event() 65 66 start = threading.Event() 66 67 cancel_results = [] 67 68 ··· 69 70 nonlocal commit_count 70 71 with commit_lock: 71 72 commit_count += 1 73 + commit_event.set() 72 74 73 75 deferred_id = deferred_deletes.schedule(commit, ttl_seconds=0.05) 76 + with deferred_deletes._LOCK: 77 + timer = deferred_deletes._TIMERS[deferred_id] 74 78 75 79 def attempt_cancel(): 76 80 start.wait() ··· 81 85 thread.start() 82 86 83 87 start.set() 84 - time.sleep(0.15) 85 88 for thread in threads: 86 89 thread.join() 87 90 88 91 true_cancels = sum(cancel_results) 92 + if true_cancels: 93 + timer.join(timeout=0.1) 94 + assert not timer.is_alive() 95 + assert not commit_event.is_set() 96 + else: 97 + assert commit_event.wait(0.1) 89 98 assert commit_count in (0, 1) 90 99 assert not (true_cancels and commit_count) 91 100 assert (true_cancels == 1 and commit_count == 0) or (
+4 -4
tests/test_importer_stall_timeout.py
··· 53 53 failed_segments, completed_count = _wait_for_segments( 54 54 message_queue, 55 55 pending, 56 - segment_timeout=1.0, 57 - poll_timeout=0.05, 56 + segment_timeout=0.15, 57 + poll_timeout=0.02, 58 58 ) 59 59 elapsed = time.monotonic() - started_at 60 60 ··· 79 79 failed_segments, completed_count = _wait_for_segments( 80 80 message_queue, 81 81 pending, 82 - segment_timeout=1.0, 83 - poll_timeout=0.05, 82 + segment_timeout=0.15, 83 + poll_timeout=0.02, 84 84 ) 85 85 elapsed = time.monotonic() - started_at 86 86
+3 -2
tests/test_readiness.py
··· 92 92 monkeypatch.setenv("SOLSTONE_JOURNAL", str(tmp_path)) 93 93 _write_identity(tmp_path) 94 94 95 - assert readiness.wait_ready(timeout=1.0) is None 95 + assert readiness.wait_ready(timeout=0.1) is None 96 96 97 97 98 98 def test_wait_ready_ignores_malformed_marker(tmp_path, monkeypatch, caplog): ··· 136 136 137 137 def test_wait_ready_observes_marker_written_mid_flight(tmp_path, monkeypatch): 138 138 monkeypatch.setenv("SOLSTONE_JOURNAL", str(tmp_path)) 139 + monkeypatch.setattr(readiness, "_POLL_INTERVAL_S", 0.02) 139 140 _write_identity(tmp_path) 140 141 timer = threading.Timer( 141 - 0.1, readiness.signal_ready, kwargs={"payload": {"stage": "ready"}} 142 + 0.02, readiness.signal_ready, kwargs={"payload": {"stage": "ready"}} 142 143 ) 143 144 144 145 try: