MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / _Budget

Class _Budget

scripts/test-impact/profile_map_v2.py:181–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179
180
181class _Budget:
182 __slots__ = (
183 "limits", "input_bytes", "rows", "records", "counter_values",
184 "name_bytes", "id_references", "output_bytes",
185 )
186
187 def __init__(self, limits, enumeration_text):
188 self.limits = limits
189 self.input_bytes = _bounded_add(
190 32, len(enumeration_text), limits.max_input_bytes, "input byte limit"
191 )
192 self.rows = 0
193 self.records = 0
194 self.counter_values = 0
195 self.name_bytes = 0
196 self.id_references = 0
197 self.output_bytes = 0
198
199 def name(self, value):
200 self.input_bytes = _bounded_add(
201 self.input_bytes, len(value), self.limits.max_input_bytes,
202 "input byte limit",
203 )
204 self.name_bytes = _bounded_add(
205 self.name_bytes, len(value), self.limits.max_name_bytes,
206 "name byte limit",
207 )
208
209 def text(self, value):
210 self.input_bytes = _bounded_add(
211 self.input_bytes, len(value), self.limits.max_input_bytes,
212 "input byte limit",
213 )
214
215 def add_rows(self, count):
216 self.rows = _bounded_add(
217 self.rows, count, min(self.limits.max_rows, _INT_MAX), "row limit"
218 )
219
220 def parsed(self, records, gate):
221 self.records = _bounded_add(
222 self.records, len(records), self.limits.max_records, "record limit"
223 )
224 for record in records:
225 gate.step()
226 self.counter_values = _bounded_add(
227 self.counter_values, len(record.counters),
228 self.limits.max_counter_values, "counter value limit",
229 )
230 self.name_bytes = _bounded_add(
231 self.name_bytes, len(record.raw_name),
232 self.limits.max_name_bytes, "name byte limit",
233 )
234
235 def reference(self):
236 self.id_references = _bounded_add(
237 self.id_references, 1, self.limits.max_id_references,
238 "ID reference limit",

Callers 1

build_profile_map_v2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected