方寸 Portal

AI Engineer Portal

Your personal operating system for career transition.

Private mode

Exercise

Build an eval result storage and comparison layer

Build an Eval Result Storage and Comparison Layer

Eval results are only useful if you can compare them across runs. This exercise builds the persistence and comparison layer that makes prompt iteration data-driven.

What to build

Implement EvalStore:

  1. save(run_id: str, report: dict) -> None — Persists the report under run_id. Raises ValueError if run_id already exists.

  2. load(run_id: str) -> dict — Returns the stored report. Raises KeyError if not found.

  3. list_runs() -> list[str] — Returns all run_ids in insertion order.

  4. compare(run_id_a: str, run_id_b: str) -> dict — Returns {"run_a", "run_b", "pass_rate_delta", "avg_score_delta", "regression_count_delta", "improved": bool}. improved = True if avg_score_delta > 0 and regression_count_delta <= 0.

  5. best_run(metric: str = "avg_score") -> str | None — Returns the run_id with the highest value for the given metric key. Returns None if empty.

Constraints

  • Standard library only. In-memory store is fine (no file I/O required).

Evaluation / medium / Step 30 of 36

Practice stage

Evaluation and review loops

Hint

Separate the scoring logic from the interpretation logic. Your goal is not just a number; it is a useful next action.

Success criteria
  • - Produces a useful signal, not decorative output
  • - Makes regression review easier
  • - Would support a benchmark or observability loop
Review checklist
  • - Would this output help decide what to fix next?
  • - Are important failure modes visible?
  • - Does the score hide any ambiguity I should record?

Practice

Generate a variation

Generate a new exercise variation to deepen understanding or practice a related concept.

Attempt history

Recent submissions

Before you submit, decide what a strong answer should make obvious to the reviewer.

No attempts yet.