The CTE atomically locks the parent run via UPDATE, bumps its updated_at (eliminating a separate TouchChatDebugRunUpdatedAt call), and enforces the finalization guard: if the run is already finished, the UPDATE returns zero rows, the INSERT gets no source rows, and sql.ErrNoRows is returned. The UPD
(ctx context.Context, arg InsertChatDebugStepParams)
| 944 | // rows, and sql.ErrNoRows is returned. The UPDATE also serializes |
| 945 | // with concurrent FinalizeStale under READ COMMITTED isolation. |
| 946 | InsertChatDebugStep(ctx context.Context, arg InsertChatDebugStepParams) (ChatDebugStep, error) |
| 947 | InsertChatFile(ctx context.Context, arg InsertChatFileParams) (InsertChatFileRow, error) |
| 948 | InsertChatMessages(ctx context.Context, arg InsertChatMessagesParams) ([]ChatMessage, error) |
| 949 | InsertChatModelConfig(ctx context.Context, arg InsertChatModelConfigParams) (ChatModelConfig, error) |
no outgoing calls