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

Function _convert

scripts/test-impact/coverage_live_v2.py:447–475  ·  view source on GitHub ↗
(evidence, tool, path, label, environment, root, unavailable=False)

Source from the content-addressed store, hash-verified

445
446
447def _convert(evidence, tool, path, label, environment, root, unavailable=False):
448 try:
449 raw = _read(path, evidence.args.max_profile_bytes)
450 except OSError as error:
451 if unavailable and error.errno in (errno.EACCES, errno.EPERM, errno.ENOENT):
452 evidence.uncertainty.append({"path": path, "reason": "profile_unreadable"})
453 return None
454 raise
455 snapshot = evidence.write("evidence/" + label + ".profraw", raw)
456 raw_digest = hashlib.sha256(raw).hexdigest()
457 record, text = _run(evidence, label, [tool, "merge", "--instr", "--text", "--failure-mode=any",
458 "--num-threads=1", "--output=-", snapshot],
459 environment, evidence.args.conversion_timeout, root)
460 record["input"] = {"path": path, "snapshot": snapshot, "sha256": raw_digest,
461 "bytes": len(raw)}
462 _required(record)
463 if hashlib.sha256(_read(snapshot, evidence.args.max_profile_bytes)).hexdigest() != raw_digest:
464 _error("identity", "conversion input changed")
465 evidence.converted_bytes += len(text)
466 if evidence.converted_bytes > evidence.args.max_total_profile_bytes:
467 _error("resource_limit", "aggregate converted byte limit exceeded")
468 # Reject malformed transport, even though the pure producer can represent
469 # unavailable/malformed observations conservatively. Unknown identities and
470 # counter-shape incompatibilities are rejected by the producer's full join.
471 deadline = time.monotonic() + evidence.args.reduction_timeout
472 parse_profile_text(text, ParseLimits(evidence.args.max_output_bytes, RECORD_CAP,
473 COUNTER_CAP, NAME_CAP),
474 cancel=lambda _: time.monotonic() >= deadline)
475 return text
476
477
478def _scope(registry, requested, available):

Callers 2

_observationsFunction · 0.85
collectFunction · 0.85

Calls 7

parse_profile_textFunction · 0.90
ParseLimitsClass · 0.90
_readFunction · 0.85
_runFunction · 0.85
_requiredFunction · 0.85
_errorFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected