Skip to content

Evaluators: two evaluators on one case can't share a score field name — fail loud or auto-namespace #113

Description

@renaudcepre

Context

Each @evaluator returns a dataclass whose fields are tagged Verdict / Metric / Reason. If two evaluators attached to the same EvalCase expose a field with the same name (e.g. both declare ok: Annotated[bool, Verdict]), their scores collide. The current workaround is a bespoke dataclass per evaluator with globally-unique field names (count_ok/count_detail, alert_ok/alert_detail, shared_key_ok/shared_key_detail, …).

Impact

  • You discover the rule only by hitting a collision, not from the API.
  • It forces verbose, prefix-namespaced field names everywhere, which leaks the evaluator's identity into its result schema (every evaluator reinvents <name>_ok / <name>_detail).

Suggestion

Namespace scores by the evaluator's name automatically (e.g. count_matching.ok, alert_emitted.ok), so two evaluators can both use plain ok / detail. Failing that, raise an explicit error at registration/run time when two evaluators on the same case declare the same score name.

Note

If the constraint is intended, a loud error at collision time (instead of a silent overwrite) would already remove the papercut — the dangerous case is two evaluators silently clobbering each other's verdict.

Metadata

Metadata

Assignees

No one assigned

    Labels

    diDependency injection

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions