March 5, 2026
Refining Timeouts and Schema Handling
Significant stability and reliability improvements were introduced today, focusing heavily on thread management and data integrity
Significant stability and reliability improvements were introduced today, focusing heavily on thread management and data integrity.
The dependency on signal.alarm has been replaced with thread-based timeouts across the application. Specifically, threading.Thread.join(timeout=) is now used for both the 120-second worker timeout and the 60-second LLM synthesis timeout, as signal.alarm() only functions correctly within the main thread environment.
Database schema initialization logic in run.py has been hardened. The initialize_schema() function is now always executed upon startup. By utilizing the IF NOT EXISTS clause, this process is made idempotent, guaranteeing that new database tables are created without requiring manual migrations if they are absent.
In routing_decision_service, an issue where specific JSON fields were being returned as raw strings has been addressed. A new _parse_json_field() helper function now deserializes these fields, including scores, signal_snapshot, and feedback, upon reading them.
Authentication handling in websocket.py was corrected to ensure proper connection lifecycle management. The code now calls ws.close() before returning during an authentication failure. This prevents Flask-Sock from mistakenly writing an HTTP 200 status into the established, upgraded TCP connection.
Finally, frontend behavior in app.js was adjusted. After a successful login, the page now reloads entirely instead of attempting to re-call _init() with a partial state. Additionally, the polling wait time for document synthesis has been capped at 30 seconds before a card is displayed to the user.
-
Replaced
signal.alarmwiththreading.Thread.join(timeout=)for worker and LLM timeouts. -
Ensured
initialize_schema()runs on startup inrun.pyusingIF NOT EXISTSfor idempotency. -
Implemented
_parse_json_field()inrouting_decision_serviceto deserialize raw JSON fields. -
Fixed WebSocket authentication failure flow by calling
ws.close()pre-return inwebsocket.py. -
Modified
app.jsto reload the page post-login instead of partial state initialization. -
Capped document synthesis poll wait time in
app.jsat 30 seconds.