bdc984e5ff
The REST/Web-UI HTTPServer shares one long-lived PG connection across all requests. Any statement that raised mid-request (e.g. a UniqueViolation from a desynced SERIAL sequence) aborted the transaction; the global handler returned 500 without rolling back, so every subsequent request failed with InFailedSqlTransaction until restart — surfacing as "duplicate keys cause 500s" and "500 immediately after login". - server.py: global handler now always rolls back the shared connection on error and maps constraint violations to 409 (was 500/400). This is the one funnel that guarantees the connection is never left aborted. - db.py: add is_integrity_error() — dual-backend (psycopg + sqlite3) constraint-violation classifier; replaces the fragile `"UNIQUE" in msg` string match that never matched Postgres' error text. - Remove make_write_mcp_server: a never-run duplicate of the MCP write tools that had bit-rotted (wrong file_update arg order + FK-violating hardcoded actor). Live writes go through oauth_mcp_app, which is correct. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>