ML evaluation integration research¶
Research date: 2026-09-20. Recommendations for backlog refinement, not implemented contracts.
Repository constraints¶
Read CONTEXT.md, docs/performance-evaluation.md, specification chapters 02, 03 and 05,
and src/telemetry/performance/evaluation.py. Consumers own measurement meaning and datasets;
reports exclude case names, inputs, expected values, outputs and exception messages. The existing
evaluator is serial, bounded, dependency-free and report-v1 based. Missing evidence is unavailable.
Disabled runtime creation avoids OpenTelemetry imports and side effects. Runtime delivery failures
preserve application behavior; flush and shutdown share bounded deadlines.
The safety floor rejects attribute names containing the normalized credential term token, including
gen_ai.token.type. Do not weaken this floor to copy an external vocabulary. Run identity also cannot
become a metric dimension. These constraints govern all recommendations below.
Current primary-source findings¶
OpenTelemetry GenAI conventions now live in a separate repository and remain Development. Pin a specific reviewed convention revision in compatibility evidence; do not advertise stable blanket compliance. GenAI specification
The current metrics distinguish client first-chunk/per-output-chunk timing from server first-token/ per-output-token timing. Usage is recorded when efficiently available, with explicit optional offline counting otherwise. This means an SDK chunk is not necessarily one token, and unavailable usage must not silently become zero. GenAI metrics
MLflow supports evaluating previously collected traces and adding ground truth. This demonstrates a useful offline/production feedback loop, but its payload-rich trace model is not the platform's report contract. Trace evaluation MLflow provides span processors, scoped trace metadata, context-local destinations and explicit tracer provider bridging. Provider and context isolation require deliberate integration tests. Tracing API
Pytest discovers installed plugins through pytest11, and provides pytester for plugin tests.
Plugin authoring
Its exit codes distinguish failed tests, interruption, internal error, usage error and no collected tests.
Exit codes
Apache Beam's combination contract illustrates accumulator state separated from result values and associative/commutative merging for partitioned computation. Use the contract pattern without adding Beam as a dependency. Combine Python explicitly warns that unpickling untrusted data can execute arbitrary code; portable evaluation checkpoints should therefore use bounded validated data rather than arbitrary serialized objects. Pickle security
Recommended implementable tasks¶
Evaluation-to-production correlation¶
- Define an optional immutable linkage record carrying report digest, deployment/model revision and permitted trace correlation identifiers. Keep identity out of metric dimensions; consumers register allowed fields. Validate length, value safety and combined envelope limits before use.
- Implement an injected runtime adapter with explicit enablement, lazy dependencies, monotonic timing, bounded observation counts and fail-open emission. Verify disabled imports, concurrent context isolation, exporter failure, shutdown and no payload/exception-message capture.
- Document a consumer-owned delayed-label and evaluation-curation workflow. Use opaque references and bounded aggregates; never automatically turn production payloads into a library-owned dataset. Label timing, cohort identity and maturity belong in consumer policy.
Tracking export and local history¶
- Export only a validated immutable report and allowlisted metadata through an explicitly supplied tracker client/destination. Add an optional MLflow adapter without autologging or model/input/output logging. Credentials remain outside report/config fingerprints.
- Make export status separate from evaluation status. Bound timeout, retries and queued bytes; return structured safe errors. Retain the local report on failure. Use report digest plus destination to avoid duplicate retries where the backend permits it; do not promise universal exactly-once writes.
- Build local history from atomic JSON artifacts and a recoverable bounded index; define retention, duplicate identity and concurrent-writer behavior. No tracking server or remote sync in core.
Evidence: contract fixtures assert exact exported keys and absence of sensitive sentinels; fake tracker tests cover duplicate retry, destination isolation, timeout, partial upload and missing optional package.
Reports, CLI and pytest¶
- Build HTML/Markdown rendering from validated report/comparison/assessment objects, sharing the same formatter semantics. Show uncertainty method, counts, failures, slices, compatibility reasons and unavailable/inconclusive status. Escape labels and avoid scripts, remote assets and automatic links from arbitrary metadata. Test hostile labels, missing values and large bounded reports.
- Give CLI execution an explicit consumer entry point and local paths; loading an untrusted report never imports code. Specify a stable machine-readable result and exit mapping for pass, fail, inconclusive/unavailable and invalid input. Do not silently update baselines.
- Provide an optional pytest fixture/plugin with explicit evaluation opt-in and no import-time runtime
initialization. Preserve pytest's own exit meanings; incomplete required evidence cannot pass.
Use
pytestersubprocess fixtures for passing/failing/inconclusive assessments, no tests, disabled plugin, incompatible baseline, import isolation and separate worker artifact paths.
Streaming aggregation¶
- Add an explicit accumulator protocol with create/update/merge/finalize and versioned state semantics; built-in count/mean/variance paths have bounded state and documented numeric tolerance. Reject nonfinite observations and incompatible merges.
- Classify measurements as streamable or corpus-dependent before execution. Never silently approximate arbitrary corpus measurements, bootstrap intervals or exact percentiles. Optional sketches declare algorithm/version, configuration, bounds and approximation in identity and reports.
- Prove batch-versus-stream parity for exact measures, partition/merge equivalence within declared tolerance, memory bounds, empty/failed partitions and measurement-error isolation. Per-case evidence required for paired inference must have an explicit in-process bounded strategy.
Resumable evaluation¶
- Start with completed-trial checkpoints: bounded validated JSON stores manifest identity, execution position, completed safe summaries and schema/algorithm versions. Write atomically; no arbitrary object serialization, candidate state, inputs, outputs or raw RNG objects.
- Refuse identity mismatch before invoking a candidate. Restart an interrupted trial from its defined seed and setup contract; support only explicitly replayable candidate/dataset behavior. Document that externally stateful calls can be repeated and are not exactly-once.
- Verify crash-before/after-commit, truncated/oversize/malicious checkpoint, mismatched dataset/model/ measurement/plan, deterministic replay and no double-counted completed trial. Stateful mid-trial resume requires a separate consumer checkpoint contract and is not implicitly supported.
Optional LLM adapter¶
- Define sync/async streaming observation boundaries with monotonic first-chunk and inter-chunk timing, completion/cancellation/failure classification and bounded chunk processing. Only call measurements token-based when the adapter can establish true token boundaries. Never persist chunk content.
- Keep numeric token usage in payload-free reports. Any telemetry mapping uses approved consumer names
such as
usage.kindand explicitly documents the deviation from OTelgen_ai.token.type. Unknown, provider-reported and estimated usage are separate states; cost requires a consumer-supplied versioned rate schedule, currency and explicit estimates. - Give evaluators/judges versioned identity covering provider/model revision, prompt/rubric revision, sampling and retry policy. Bound requests, concurrency, total usage/cost and timeout; retain only safe numeric outcomes and classifications. Payload-bearing remote judging is explicitly configured by the consumer and is distinct from telemetry export. Never claim deterministic equivalence from seeds alone. Fake streaming/provider tests exercise empty chunks, missing usage, retries, cancellation and malicious responses without paid network calls.
Verification boundary¶
These are research recommendations derived from inspected repository contracts and current primary sources. No implementation, tests, hosted integration, performance or release evidence was produced.