返回 DeepSeek-Reasonix
model_application_actions.go
根目录 / internal / serve / model_application_actions.go
1 package serve
2
3 import (
4 "encoding/json"
5 "net/http"
6 "reasonix/internal/control"
7 )
8
9 func (s *Server) cancelModelApplicationBlockers(w http.ResponseWriter, r *http.Request) {
10 var body struct {
11 Choice control.ModelApplicationChoice `json:"choice"`
12 IDs []string `json:"ids"`
13 }
14 if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
15 http.Error(w, "invalid recovery request", http.StatusBadRequest)
16 return
17 }
18 d := s.modelApplicationDetailsLocked(r.Context())
19 if d == nil || d.RuntimeIdentity != body.Choice.ExpectedRuntimeIdentity || d.AppliedRevision != body.Choice.ExpectedAppliedRevision || d.DesiredRevision != body.Choice.ExpectedDesiredRevision {
20 s.rejectModelApplication(w, r, control.ErrModelChoiceStale)
21 return
22 }
23 c, ok := s.ctl().(*control.Controller)
24 if !ok {
25 s.rejectModelApplication(w, r, control.ErrModelChoiceStale)
26 return
27 }
28 c.CancelModelApplicationBlockers(body.IDs)
29 s.deferModelApplicationLocked()
30 writeJSON(w, map[string]bool{"ok": true})
31 }
32
32 lines GO