local stratified cohort planning from materialized traces - #480
Open
Anirudh2627 wants to merge 1 commit into
Open
local stratified cohort planning from materialized traces#480Anirudh2627 wants to merge 1 commit into
Anirudh2627 wants to merge 1 commit into
Conversation
Adds `understudy evals stratify`, a local, metadata-only cohort planner that derives configurable strata from completed-execution behavior in the trace-foundry artifacts (`execution-index.jsonl` + `tasks.jsonl`) and selects a deterministic, stratified cohort toward decision-sized per-stratum targets. Strata axes (in greedy priority order): `outcome`, `mode`, `turns`, `confidence`, `tag`. `mode` (write vs read-only vs no-tools) reuses the foundry's own `isMutatingTool` classifier so selection and replay agree on what is a write. `tag` strata are human-supplied only (`--tags` file) — never auto-inferred. Guarantees Deterministic. Same seed + same inputs ⇒ byte-identical plan (SHA-ordered selection). Covered by test. Pilot sizes are minimums, never caps. Rare strata (≤ `--rare-threshold`) and human-tagged high-consequence strata are saturated, so every available rare or high-consequence case is included. Incremental expansion without mutating frozen splits. `--expand-from` preserves every prior selection and reports whether the new batch shifted stratum prevalence within `--tolerance` (`stable` / `unstable`, machine-readable). Readiness is machine-readable. Underfilled rare/high-consequence strata populate `blocking[]` and set `ready: false`, so later gates can block a whole-workload-ready status. Privacy-hard. The plan carries execution ids, labels, and counts only — never prompts, completions, or task payloads. The module deliberately does not read payload-derived fields (e.g. task `title`), and a test asserts no payload text can leak into the artifact. New artifact `understudy.eval-cohort-strata-plan.v1` (`schemas/understudy.eval-cohort-strata-plan.v1.schema.json`), validated by a zod contract in `src/evals/cohort-strata.ts` and a schema-drift case in `tests/artifact-contracts.test.mjs`. Scope CLI + local contract only. No server API changes, no payload handling, no upload — in line with the issue's "server catalogs stay metadata-only; payload-derived classification runs locally" guidance. Testing `tests/cohort-strata.test.mjs` — 8 tests: derivation, byte-determinism, minimums-not-caps, payload redaction, frozen-expansion stability, unstable prevalence detection, blocking readiness, and an end-to-end CLI run. Full existing suite run; the only failures reproduce on clean `main` in this sandbox (GEPA/uv, gateway-fallback, and `$HOME` path tests) and are unrelated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
understudy evals stratify, a local, metadata-only cohort planner that derives configurable strata from completed-execution behavior in the trace-foundry artifacts (execution-index.jsonl+tasks.jsonl) and selects a deterministic, stratified cohort toward decision-sized per-stratum targets.Strata axes (in greedy priority order):
outcome,mode,turns,confidence,tag.mode(write vs read-only vs no-tools) reuses the foundry's ownisMutatingToolclassifier so selection and replay agree on what is a write.tagstrata are human-supplied only (--tagsfile) — never auto-inferred.Guarantees
Deterministic. Same seed + same inputs ⇒ byte-identical plan (SHA-ordered selection). Covered by test.
Pilot sizes are minimums, never caps. Rare strata (≤
--rare-threshold) and human-tagged high-consequence strata are saturated, so every available rare or high-consequence case is included.Incremental expansion without mutating frozen splits.
--expand-frompreserves every prior selection and reports whether the new batch shifted stratum prevalence within--tolerance(stable/unstable, machine-readable). Readiness is machine-readable. Underfilled rare/high-consequence strata populateblocking[]and setready: false, so later gates can block a whole-workload-ready status.Privacy-hard. The plan carries execution ids, labels, and counts only — never prompts, completions, or task payloads. The module deliberately does not read payload-derived fields (e.g. task
title), and a test asserts no payload text can leak into the artifact.New artifact
understudy.eval-cohort-strata-plan.v1(schemas/understudy.eval-cohort-strata-plan.v1.schema.json), validated by a zod contract insrc/evals/cohort-strata.tsand a schema-drift case intests/artifact-contracts.test.mjs.Scope
CLI + local contract only. No server API changes, no payload handling, no upload — in line with the issue's "server catalogs stay metadata-only; payload-derived classification runs locally" guidance.
Testing
tests/cohort-strata.test.mjs— 8 tests: derivation, byte-determinism, minimums-not-caps, payload redaction, frozen-expansion stability, unstable prevalence detection, blocking readiness, and an end-to-end CLI run. Full existing suite run; the only failures reproduce on cleanmainin this sandbox (GEPA/uv, gateway-fallback, and$HOMEpath tests) and are unrelated.