Add latency-tuner example loop and measurement infrastructure#1
Merged
Conversation
A plausible-but-wrong gain fools judgment; it cannot fool an exact sign test deflated by a search budget the tool refuses to run without. verdict.py ships the METHODOLOGY rules as executable modes (screen, reproduce, confirm, compare, floor, self-test), the gate agents treat its REJECT as binding, and the tournament's trap and final claim are now certified mechanically in tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011t5gmHpHh68Jcigy5uPPEx
The loop is only as good as its prove command, and a broken metric silently certifies bad changes. Step 0 of instantiation is now a runnable contract — numeric, deterministic, and able to score a planted-bad control worse than a known-good — re-run at triage whenever measurement is in doubt. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011t5gmHpHh68Jcigy5uPPEx
A wedged or over-eager unattended iteration needs a mechanical budget floor exactly like the safety floor: ITER_MAX_TURNS caps agent turns per tick (default 50, raise deliberately), alongside the existing wall-clock time-box. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011t5gmHpHh68Jcigy5uPPEx
The docs have always said the deny-list is a tripwire and the real boundary is an OS sandbox — now the sandbox ships ready to adapt: a container image + locked-down runner, a hardened systemd unit/timer pair, and a macOS Seatbelt profile, each keeping the floor files read-only even inside the writable area. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011t5gmHpHh68Jcigy5uPPEx
…xample The latency tuner exercises everything the tournament cannot: a time-based out-of-time holdout with a regime shift, a hard error-rate floor, continuous-metric certification via the paired bootstrap, and the cheap-error reward-hack encoded into the metric itself. Its planted trap tops the train leaderboard and runs 4x the error budget on the holdout window — the gate must kill the best-looking config on the board, and the tests prove it does. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011t5gmHpHh68Jcigy5uPPEx
Both examples now run in a CI matrix; the runners, verdict tool, and metric contract are diffed against the template so instantiated copies cannot silently drift, and the verdict self-test (the known-nothing control) runs on every push. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011t5gmHpHh68Jcigy5uPPEx
Lead with a two-minute path into a working example, show the loop as a diagram, turn the failure-mode reasoning into a countermeasure table, give each example a real description with its trap, walk build-your-own step by step, and answer the questions a first-time user actually has (cost, API keys, no-holdout domains, why verdict.py fails closed) in an FAQ. Adds the ASCII masthead and a contributing section geared toward community example loops. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011t5gmHpHh68Jcigy5uPPEx
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.
Summary
This PR adds a complete second example of a self-improving loop — the latency tuner — alongside the existing prompt-technique-tournament example. The latency tuner optimizes a running service's retry policy (timeout, retries, backoff) against replayed production traffic, demonstrating the "optimize-a-running-system" flavor of the framework with time-based holdout validation and operational safety floors.
Key Changes
New latency-tuner example (
examples/latency-tuner/):sim/run_eval.py): Deterministic replay of retry policies against fixed traffic traces, scoring effective latency (per-request elapsed time including errors as penalties)traces/train.jsonl,traces/holdout.jsonl): 600 holdout requests and ~1000 training requests with pre-drawn upstream latencies and failure modes; checksummed to prevent mid-campaign regenerationsim/test_run_eval.py,sim/test_guardrail.py): Proves trace integrity, replay determinism, and the planted reward-hacking trap (timeout-fast-fail-cheap) that the metric must resist/iteratecommand orchestrating the full cycleGOAL.md,METHODOLOGY.md,PERSONA.md): Defines the optimization target, window discipline (train/holdout split), and the skeptical reliability engineer personaShared tooling (copied to all three locations: template, prompt-technique-tournament, latency-tuner):
verdict.py: Mechanical gate for statistical certification — implements screen, reproduce, confirm, compare, floor, and self-test modes; fails closed on undeclared search sizemetric-contract.sh: Pre-loop validation that the metric is numeric, deterministic, and able to distinguish good from badmetric-contract.env: Configuration for metric contract validationTemplate and CI updates:
README.mdwith ASCII art, clearer positioning, and quick-start instructionstemplate/INSTANTIATE.mdwith Step 0 (prove your metric) and clarified gate methodologytemplate/sandbox/): Dockerfile, macOS Seatbelt profile, systemd service/timer, and run-sandboxed.sh wrapper for OS-level jailing.github/workflows/ci.ymlto run tests for both examples in parallelNotable Implementation Details
The latency tuner runs fully offline and deterministic — no API key, no network — making it ideal for testing the framework's measurement and gating machinery before deploying to a live domain.
https://claude.ai/code/session_011t5gmHpHh68Jcigy5uPPEx