返回 DeepSeek-Reasonix
protocol_recovery.go
根目录 / internal / provider / protocol_recovery.go
1 package provider
2
3 import "encoding/json"
4
5 // ProtocolRecoveryRecord is stored only on a local sentinel. The Message field
6 // holds raw JSON so unknown versions/fields survive older readers unchanged.
7 type ProtocolRecoveryRecord struct {
8 Evidence string `json:"evidence,omitempty"`
9 Projected bool `json:"projected,omitempty"`
10 Version int `json:"version"`
11 ID string `json:"id"`
12 State string `json:"state"` // pending|consumed
13 Scope string `json:"scope"`
14 Fingerprint string `json:"fingerprint"`
15 Prefix int `json:"prefix"`
16 Count int `json:"count"`
17 Anchor string `json:"anchor"`
18 Run uint64 `json:"run"`
19 }
20
21 type ProtocolRecoveryAction struct {
22 ID string `json:"id"`
23 }
24
25 func DecodeProtocolRecovery(raw json.RawMessage) (ProtocolRecoveryRecord, bool) {
26 var r ProtocolRecoveryRecord
27 err := json.Unmarshal(raw, &r)
28 return r, err == nil && r.Version == 1 && r.ID != "" && r.Prefix > 0 && r.Fingerprint != "" && (r.State == "pending" || r.State == "consumed")
29 }
30
30 lines GO