| 1 | package control |
| 2 | |
| 3 | import ( |
| 4 | "crypto/sha256" |
| 5 | "encoding/hex" |
| 6 | "encoding/json" |
| 7 | |
| 8 | "reasonix/internal/sessioninbox" |
| 9 | ) |
| 10 | |
| 11 | //nolint:unused // The reliability layer persists this stable attachment fingerprint. |
| 12 | func inboxAttachmentFingerprint(req InboxRequest, env sessioninbox.PromptEnvelope) string { |
| 13 | intent := req.Intent |
| 14 | if intent != sessioninbox.IntentSteer { |
| 15 | intent = sessioninbox.IntentFollowup |
| 16 | } |
| 17 | identity := canonicalSubmissionFingerprint(SubmissionRequest{ |
| 18 | Input: env.SubmitText, Display: env.DisplayText, Original: env.RawText, |
| 19 | Action: string(intent), Format: req.Format, Invocations: req.Invocations, Attachments: req.Attachments, |
| 20 | }) |
| 21 | stable := struct { |
| 22 | Request string |
| 23 | Source string |
| 24 | Extra map[string]string |
| 25 | ExplicitRefs []string |
| 26 | }{identity, env.Source, env.Extra, env.ExplicitRefs} |
| 27 | body, _ := json.Marshal(stable) |
| 28 | digest := sha256.Sum256(body) |
| 29 | return hex.EncodeToString(digest[:]) |
| 30 | } |
| 31 |