返回 DeepSeek-Reasonix
completion_uncertain_compat_test.go
根目录 / internal / eventwire / completion_uncertain_compat_test.go
1 package eventwire
2
3 import (
4 "encoding/json"
5 "errors"
6 "testing"
7
8 "reasonix/internal/event"
9 )
10
11 // An older client does not know completion_uncertain and ignores the additive
12 // outcome field. Keeping the bounded error text on TurnDone makes that client
13 // stop the run and show a generic recoverable error instead of treating the
14 // incomplete turn as success.
15 func TestCompletionUncertainSafelyDegradesForLegacyClient(t *testing.T) {
16 wire := ToWire(event.Event{
17 Kind: event.TurnDone,
18 Outcome: event.TurnOutcomeCompletionUncertain,
19 Err: errors.New("completion could not be confirmed; completed work was kept"),
20 })
21 raw, err := json.Marshal(wire)
22 if err != nil {
23 t.Fatal(err)
24 }
25 var legacy struct {
26 Kind string `json:"kind"`
27 Err string `json:"err,omitempty"`
28 }
29 if err := json.Unmarshal(raw, &legacy); err != nil {
30 t.Fatal(err)
31 }
32 if legacy.Kind != "turn_done" || legacy.Err == "" {
33 t.Fatalf("legacy TurnDone = %+v, want terminal event with non-empty error", legacy)
34 }
35 }
36
36 lines GO