Now boarding Flagsmith “Toggle Wars” hackathon build · Simulated traffic is always labelled · MIT licensed

Experiment decisions for Flagsmith

Flagsmith starts the experiment. ExPilot decides it.

Starting an A/B test is easy; deciding it honestly is where teams slip. ExPilot locks the Experiment Plan by sha256, runs the statistics in code, and stops at two typed Approval Gates: one to launch, one to close.

See the loop

Runs offline in ~20s against a bundled mock Flagsmith (simulated traffic). Node 22+.

Decisions · live Simulated traffic
Status

Collecting traffic. No decision before the minimum sample.

CONTROL VARIANT
n per arm C/V
P(V beats C)
Lift 95% CrI
SRM p
Refunds P(harm)

01 The half nobody automates

Most “AI + feature flags” demos stop at describe a flag, get a flag. The trouble starts after creation. Four failure modes, four fixes.

Fail 01Peeking

Teams check daily and ship the first green. In an A/A simulation, a fixed 0.95 bar checked every few minutes ships a false winner about 14% of the time.

ExPilot requires 0.995 before the maximum sample. False ships drop to about 5%.

Fail 02Lopsided split

Nobody checks that traffic really split 50/50. A sample ratio mismatch silently invalidates everything downstream.

ExPilot runs a chi-square test on exposed identities at every readout. Below p = 0.001 the result is INVALID and shipping is blocked.

Fail 03Glanced-at guardrails

Refunds get a look, not a rule. A “winner” that quietly raises refunds still ships.

ExPilot forces ROLL_BACK once P(harm beyond tolerance) ≥ 0.95, even before the minimum sample.

Fail 04Flags that never die

The losing branch stays in the code forever, one more dead branch nobody dares delete.

ExPilot writes a cleanup patch, proves it applies and typechecks, and hands it over without applying it.

02 Six steps, two gates

Six commands from Experiment Plan to Audit Record. At each Approval Gate, ExPilot stops until a human types the exact confirmation into a real terminal or the approval console. Output is verbatim from expilot demo, trimmed for width.

expilot plan

            

03 Rules, written before launch

Deterministic code runs these rules in order; first match wins. Each arm gets an independent Beta-Binomial posterior from Flagsmith’s raw counts. Code, never the model, sets the sample size with a two-proportion z calculation (α 0.05, power 0.8, 20% baseline, 25% minimum detectable effect): 1094 identities per arm, capped at 2188.

  1. 1SRM p < 0.001, from 100 identitiesBlock shipping, list likely causes
  2. 2Any Guardrail P(harm beyond tolerance) ≥ 0.95Force ROLL_BACK, even before the minimum sample
  3. 3Below 1094 per arm, too short, or stale dataKeep collecting, with a peeking warning
  4. 4P(win) ≥ 0.995 before max, ≥ 0.95 at 2188SHIP the Variant, if no Guardrail harm
  5. 5Max sample reached, no winnerKeep Control, report expected loss
False ships in an A/A simulation. Nothing differs, so every SHIP is wrong. Checked every few minutes. Source: scripts/peek-calibration.ts
Fixed 0.95 bar≈14%
ExPilot bar≈5%

What Flagsmith computes, and what ExPilot recomputes. Read from the Flagsmith 2.295.2 source and confirmed against a live self-hosted instance.

FlagsmithExPilot
ModelNormal approximation, each variant vs controlIndependent Beta-Binomial posteriors from raw counts
Win probabilitychance_to_win, pairwise vs controlP(beats control) per variant, plus P(best of all arms)
Expected lossnot providedcomputed
SRMsrm_p_value, null on the API rollout pathchi-square on exposed identities, every readout
Guardrailsno concepttolerance and P(harm) per guardrail, enforced
Floorshidden below 50 identities per armmirrors the same floors, so harm cannot hide

04 The model never holds a key

The model only gets read and propose tools. Only a human can mint an Approval, and it is verified at runtime on every mutating Flagsmith Admin API call. Against live Flagsmith there is no bypass flag; a non-TTY stdin exits with code 2.

Model

Reads & proposes

Greps for real trackEvent names, drafts the Experiment Plan, narrates the memo.

create start complete update

Human

Mints an Approval

A CLI prompt on a real TTY, or the console with session cookie, CSRF token and typed text.

› checkout_cta_copy

Admin client

Checks, then calls

Signature, single-use nonce, action, target, plan sha256, TTL. Only then the Flagsmith Admin API.

→ Flagsmith Admin API

Audit Record

Self-hosted and free-plan Flagsmith return zero audit rows, so ExPilot keeps its own Audit Record: every Experiment Plan lock, approval, amendment and API call (keys redacted) is appended to audit.jsonl as a sha256 hash chain, with an HMAC-keyed head anchor so truncation is detected.

audit chain OK: 55 events, each hashed to the previous

    G2 Your turn at Gate 2

    Approval Gate 2 is not a rubber stamp. Type the winning Variant key from the close dossier below to roll it out, or type control first and watch ExPilot refuse it without a logged --override reason.

    EXPILOT Close dossier · Gate 2 Simulated traffic
    Experimentcheckout_cta_copy
    Gate2
    DecisionSHIP · PRIMARY_WIN
    P(beats control)100.0%99.5% required
    Lift, 95% CrI+40.9%+23.4% to +61.1%
    Guardrail · SRMwithin · p 0.827
    Plan sha256a481068376d64ca9… · no amendments

    Audit tail

    1. …waiting for Gate 2

    05 Quickstart

    Reproduces offline against a bundled mock Flagsmith matching the source-verified API contract (41 endpoints), with the real @flagsmith/nodejs SDK sending simulated traffic. Only expilot demo auto-answers both Approval Gates, and it prints each as [demo] human typed: ….

    [demo] human typed: checkout_cta_copy
    DECISION: SHIP complete_secure_checkout   rule PRIMARY_WIN
    [demo] human typed: complete_secure_checkout
    Closed: rolled out complete_secure_checkout (decision SHIP).
    audit chain OK: 55 events, each hashed to the previous
    Run it against a real Flagsmith

    The live path ran end to end (plan, preflight, launch, simulate, readout, close, audit verify) against a self-hosted Flagsmith 2.295.2 brought up from infra/. Flagsmith Cloud has not been tried.

    docker compose -f infra/docker-compose.yml up -d
    npx tsx infra/bootstrap.ts
    infra/ex.sh plan "<hypothesis>" --repo demo/checkout-app
    infra/ex.sh launch checkout_cta_copy   # Gate 1 needs a real terminal

    That is the point.

    ExPilot finishes what Flagsmith Experimentation starts. It calls the start/, results/refresh/ and complete/ endpoints that agents otherwise cannot reach, enforces the statistics teams skip, and keeps a human’s fingers on the only two keys that change production.

    Try the gate