返回 DeepSeek-Reasonix
draft_binding.go
根目录 / internal / attachment / draft_binding.go
1 package attachment
2
3 // RebindVerified renews an owner-transferred capability after the caller has
4 // validated its original. Possession of a digest is never sufficient. Previous
5 // credentials remain proofs for response-loss retries until explicit release.
6 func (d *DraftStore) RebindVerified(scope, id string) (DraftCredential, error) {
7 d.mu.Lock()
8 defer d.mu.Unlock()
9 item, ok := d.items[id]
10 if !ok || item.scope != scope {
11 return DraftCredential{}, Error{Code: CodeMissing, Message: "draft credential is not valid", Retry: true}
12 }
13 if !item.needsRebind {
14 return item.draft, nil
15 }
16 for _, bound := range d.items {
17 if bound.scope == scope && bound.family == item.family && !bound.needsRebind {
18 return bound.draft, nil
19 }
20 }
21 item.draft.ID = newID()
22 item.needsRebind = false
23 d.items[item.draft.ID] = item
24 return item.draft, nil
25 }
26
26 lines GO