| 1 | package event |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | // These values are the persisted event contract before ToolStarted was added |
| 6 | // (origin/main-v2). New events must not reinterpret existing lifecycle records. |
| 7 | func TestToolStartedPreservesPersistedKindValues(t *testing.T) { |
| 8 | legacy := []struct { |
| 9 | name string |
| 10 | kind Kind |
| 11 | value int |
| 12 | }{ |
| 13 | {"TurnStarted", TurnStarted, 0}, |
| 14 | {"Reasoning", Reasoning, 1}, |
| 15 | {"Text", Text, 2}, |
| 16 | {"Message", Message, 3}, |
| 17 | {"ToolDispatch", ToolDispatch, 4}, |
| 18 | {"ToolResult", ToolResult, 5}, |
| 19 | {"Usage", Usage, 6}, |
| 20 | {"Notice", Notice, 7}, |
| 21 | {"Phase", Phase, 8}, |
| 22 | {"ApprovalRequest", ApprovalRequest, 9}, |
| 23 | {"AskRequest", AskRequest, 10}, |
| 24 | {"TurnDone", TurnDone, 11}, |
| 25 | {"CompactionStarted", CompactionStarted, 12}, |
| 26 | {"CompactionDone", CompactionDone, 13}, |
| 27 | {"ToolProgress", ToolProgress, 14}, |
| 28 | {"MCPSurfaceReady", MCPSurfaceReady, 15}, |
| 29 | {"Retrying", Retrying, 16}, |
| 30 | {"Steer", Steer, 17}, |
| 31 | {"GuardianAssessment", GuardianAssessment, 18}, |
| 32 | {"ExtensionSurface", ExtensionSurface, 19}, |
| 33 | {"ExtensionStatus", ExtensionStatus, 20}, |
| 34 | {"StreamAttempt", StreamAttempt, 21}, |
| 35 | {"ContextMaintenanceEvent", ContextMaintenanceEvent, 22}, |
| 36 | {"WorkspaceChanged", WorkspaceChanged, 23}, |
| 37 | {"TurnPhase", TurnPhase, 24}, |
| 38 | {"CompletionSummary", CompletionSummary, 25}, |
| 39 | {"ToolResultPreview", ToolResultPreview, 26}, |
| 40 | {"TurnStatusChanged", TurnStatusChanged, 27}, |
| 41 | {"PromptAnswered", PromptAnswered, 28}, |
| 42 | {"MCPInteractionRequest", MCPInteractionRequest, 29}, |
| 43 | {"SessionChanged", SessionChanged, 30}, |
| 44 | {"ReadStatus", ReadStatus, 31}, |
| 45 | } |
| 46 | for _, tc := range legacy { |
| 47 | if int(tc.kind) != tc.value { |
| 48 | t.Errorf("persisted %s kind = %d, want %d", tc.name, tc.kind, tc.value) |
| 49 | } |
| 50 | if ToolStarted == tc.kind { |
| 51 | t.Errorf("ToolStarted aliases legacy %s", tc.name) |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 |