---
name: "experiment-harness"
description: "Build an experiment harness for outreach and lifecycle programs: write a plan with one hypothesis, one primary metric, a minimum effect and a stop rule before the test starts, size the sample, assign people to A/B cohorts and a holdout with a deterministic salted hash, run to the planned end, check the split for sample ratio mismatch, then analyse with rates, confidence intervals and p-values and record a ship, iterate or stop decision. Use whenever a change to messaging, sequence, timing or targeting needs evidence."
---

# Experiment harness

## Goal
Make decisions on evidence you could defend to a skeptical colleague: a fair split, enough people, a rule written in advance and honest uncertainty. Part of GTM engineering. Fed by: multi-channel-orchestrator, attribution-ledger, reply-classifier, deliverability-monitor. Feeds: every other workflow (weights, thresholds, messages, timing).

## When to use
- You change a subject line, an offer, a sequence or a targeting rule.
- You want to know what the whole outbound program adds.
- A result will drive budget or headcount.

## Inputs
- A population with a stable id (person or account).
- One change to test.
- One primary metric with a clear time window.
- Current rate for that metric.
- The smallest effect that would change a decision.

## Data model
`plan.md`: hypothesis, metric, baseline, minimum effect, sample size, split, run length, decision rule
`assignments`: `id, experiment, group, assigned_at`
`results`: `id, group, converted (1 or 0), observed_at`
`decisions`: `experiment, date, call (ship, iterate, stop), rationale`

## Step 1. Write the plan first
One hypothesis, one change. One primary metric (for example replies per delivered first email within 7 days, or meetings booked per account within 30 days). The smallest effect worth acting on. The decision rule, written before any data arrives. Everything else you measure is exploratory.

## Step 2. Size the test
Run `scripts/experiment.py size --baseline 0.05 --mde 0.02`. It returns the people needed per arm for a two-sided test at 5 percent with 80 percent power (both adjustable). If you do not have enough people, either test a larger change, widen the population, lengthen the run, or accept that this test cannot answer the question. Say so in the plan.

## Step 3. Assign
Run `scripts/experiment.py assign ids.csv --experiment <name> --variants control,b --holdout-pct 10`.
- Assignment is a salted hash of the id and experiment name, so it is repeatable and nobody can pick favourites.
- The holdout receives no outreach. It answers "what does the program add?" while the variants answer "which version is better?".
- Assign at the level where contamination matters. For account-based outreach, assign accounts, not people, so two contacts at one company are never in different arms.
- Use a new experiment name each time so groups are independent across tests.

## Step 4. Run
Keep everything else the same. Do not change the message, the targeting or the timing mid-test. Do not peek and stop early because an arm looks ahead. Run to the planned end plus the metric window.

## Step 5. Check the split
Run `scripts/experiment.py analyze results.csv --expect control=45,b=45,holdout=10`. The first thing it prints is a sample ratio check: whether the counts per group match the plan. If it fails, do not read the results. Find the cause first: filters, send failures, tracking gaps or an assignment bug.

## Step 6. Analyse and decide
The readout gives, for each variant against control: rates, absolute difference, a 95 percent confidence interval and a p-value, and the treated-versus-holdout comparison. Apply the decision rule written in step 1.
- Ship: the interval for the difference sits above zero and the effect meets the minimum.
- Iterate: the effect is promising but the interval is wide. Run a larger or longer test.
- Stop: no meaningful effect, or the interval rules out the minimum.
A p-value is not the probability the variant is better. Say what the interval says in plain words.

## Step 7. Log
Write the decision, the date, the numbers and one learning in the decision log. Include failures and inconclusive tests.

## Tool options
Your sending tool or CRM for cohort columns. A warehouse or a script for assignment and readouts. An experimentation platform if you already have one. Statistics here use a normal approximation and suit rates with at least tens of conversions per arm. For very small counts, use an exact test or a statistician.

## Output
`assignments.csv` and `readout.txt`, plus the decision log entry.

## Success metrics
- Share of tests with a written plan before launch.
- Share of tests that pass the split check.
- Share of tests that ran to their planned end.
- Decisions changed by evidence, and what they were worth when measured later.

## Guardrails
- Test messages and timing, not people's rights. Everyone still gets opt-outs, unsubscribes and honest messages.
- Holdouts must not be harmed by being held out. Do not hold out people who asked for contact or who have an open request.
- Do not run many overlapping tests on the same people without accounting for it.
- Report uncertainty. Do not hide inconclusive results.
- Do not use experiment results to target or exclude people based on protected traits.
