MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / allocateNextMessageRef

Function allocateNextMessageRef

lib/message-ids.ts:155–172  ·  view source on GitHub ↗
(state: SessionState)

Source from the content-addressed store, hash-verified

153}
154
155function allocateNextMessageRef(state: SessionState): string {
156 let candidate = Number.isInteger(state.messageIds.nextRef)
157 ? Math.max(MESSAGE_REF_MIN_INDEX, state.messageIds.nextRef)
158 : MESSAGE_REF_MIN_INDEX
159
160 while (candidate <= MESSAGE_REF_MAX_INDEX) {
161 const ref = formatMessageRef(candidate)
162 if (!state.messageIds.byRef.has(ref)) {
163 state.messageIds.nextRef = candidate + 1
164 return ref
165 }
166 candidate++
167 }
168
169 throw new Error(
170 `Message ID alias capacity exceeded. Cannot allocate more than ${formatMessageRef(MESSAGE_REF_MAX_INDEX)} aliases in this session.`,
171 )
172}

Callers 1

assignMessageRefsFunction · 0.85

Calls 1

formatMessageRefFunction · 0.85

Tested by

no test coverage detected