MCPcopy Create free account
hub / github.com/betta-tech/byo-coding-agent / Pair

Function Pair

internal/debug/debug.go:151–181  ·  view source on GitHub ↗

Pair returns the event linked to id, in either direction. If the given event has a CorrelatedID, that's the request it's paired with. Otherwise Pair walks the ring looking for an event whose CorrelatedID equals id — that would be its response. Returns (zero, false) when no link exists or the paired

(id uint64)

Source from the content-addressed store, hash-verified

149// that would be its response. Returns (zero, false) when no link exists or
150// the paired event has aged out of the ring.
151func Pair(id uint64) (Event, bool) {
152 mu.Lock()
153 defer mu.Unlock()
154 var target Event
155 var have bool
156 for _, e := range events {
157 if e.ID == id {
158 target, have = e, true
159 break
160 }
161 }
162 if !have {
163 return Event{}, false
164 }
165 if target.CorrelatedID != 0 {
166 // Response → walk back to the request.
167 for _, e := range events {
168 if e.ID == target.CorrelatedID {
169 return e, true
170 }
171 }
172 return Event{}, false
173 }
174 // Request → walk forward to find a response that points back.
175 for _, e := range events {
176 if e.CorrelatedID == target.ID {
177 return e, true
178 }
179 }
180 return Event{}, false
181}
182
183// FindByID returns the event with the given monotonic ID, if it's still in
184// the ring. Used by /debug show to look up a specific event.

Callers 4

updateDebugFocusMethod · 0.92
viewDebugModalMethod · 0.92

Calls

no outgoing calls

Tested by 2