65d5e9de83
nextGlobalSequence()/nextSessionSequence() computed MAX+1 with two extra SELECT round-trips, guarded only by an in-process mutex — two processes on the same correx.db (CLI + server) could read the same MAX and collide on the unique index. Compute both the global sequence and session_sequence as MAX+1 subqueries inside the INSERT and RETURNING the assigned values. SQLite serializes writers, so the subqueries are atomic across processes; the unique index is the backstop. Also removes the two pre-SELECTs per append.