mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
89034f6422
Closes #24091 Adds `TestDeleteChatDebugDataAfterMessageIDStepLevelFieldBoundariesAndNulls`, which complements the existing triggered-runs test for `DeleteChatDebugDataAfterMessageID` with boundary and NULL coverage for step-level message IDs. The existing `TestDeleteChatDebugDataAfterMessageIDIncludesTriggeredRuns` already exercises the `step.assistant_message_id > @message_id` deletion path. This test focuses on: - Strict greater-than behavior at the cutoff for assistant and history-tip step message IDs. - Step-level assistant and history-tip message ID combinations. - SQL NULL behavior for step-level message IDs. - A mixed-step run where one matching step deletes the whole run and cascades every step. | Scenario | assistant_message_id | history_tip_message_id | Expected | |----------|----------------------|------------------------|----------| | Assistant above cutoff, history tip NULL | cutoff + 5 | NULL | Deleted | | Assistant above cutoff, history tip below cutoff | cutoff + 20 | cutoff - 3 | Deleted | | Assistant below cutoff, history tip NULL | cutoff - 3 | NULL | Preserved | | Assistant at cutoff boundary, history tip NULL | cutoff | NULL | Preserved | | Assistant NULL, history tip above cutoff | NULL | cutoff + 2 | Deleted | | Assistant NULL, history tip at cutoff boundary | NULL | cutoff | Preserved | | Both step message IDs NULL | NULL | NULL | Preserved | > Generated by Coder Agents <details><summary>Review notes</summary> - Run-level message IDs are below the cutoff to isolate step-level selection. - The assistant-above-cutoff scenario includes a second nonmatching step to cover mixed-step deletion. - The test uses unique model and chat names for isolation. - `go test -v ./coderd/database -run TestDeleteChatDebugDataAfterMessageID -count=1` passes. </details>