LeveredDocs
Manual Setup

6. Test before launch

Check the user id, try the variants and the holdout with test users, confirm that test events reach the warehouse, and keep test users out of the results.

An optimization starts as a draft. A draft does not serve real users, so the setup can be checked end to end before launch. The steps below apply to your own warehouse and to the Managed Warehouse.

1. Check the user id

Most setup problems come from the id. The id in the exposure table and in the reward metric must be the id that the app passes to the SDK. If the app calls the SDK with a user id and the id column of the table contains a device id, no error is raised, but rewards match no exposures and the holdout comparison is wrong.

Run levered verify:

Terminal
levered verify <optimization-id>

The command reads the last 14 days of the exposures table (change the period with --days) and reports two shares:

CheckWhat it meansLooks wrong when
Exposure ids in the reward metricThe share of ids in the exposures table that also appear as ids in the reward metric of the optimizationThe share is close to 0%. In that case the two id columns contain different ids.
is_holdout rows in the holdout hashThe share of rows logged with is_holdout = true that belong to the holdout according to Levered's hash of the idThe share is far below 100%. In that case the id column does not contain the id that the SDK was called with.

The second check runs only if the exposures table has an is_holdout column. Both checks need some exposures in the table, from another optimization or from the test events in step 3.

If representative non-test data is present, resolve a low share or a query error before launch.

If there are no representative non-test exposures yet, record the aggregate identity check as pending. This includes the case where the only exposures belong to QA users whose rewards the reward metric excludes intentionally. Then do the following:

  • Verify the arrival of the raw exposure and reward for each test user in the steps below.
  • Repeat the aggregate check when representative data arrives.

A pending aggregate check does not mean that the overall verification passed. It is also not a reason to change a valid id mapping. Query errors and failed holdout checks must still be fixed, including for QA users.

If a share is low with representative data, fix the column and run levered verify again. Use your own column names describes how to set which columns of the exposures table contain the id, the time and the variant.

2. Find out what a test user gets

Use new test user ids for each run, so that earlier events cannot satisfy the arrival check. A draft does not serve real traffic. A dry run performs the holdout assignment and the variant selection of a real serve. Levered logs no exposure for a dry run and does not train on it. A dry run counts as the SDK check that going live requires (see step 6):

Terminal
levered serve <optimization-id> --anonymous-id <test-user-id> --dry-run --json

The same works over HTTP with "dry_run": true on /serve. The response contains the variant and is_holdout.

Testing the holdout. If the holdout is 0%, which includes --control none, use one ordinary test user and continue with step 3. With a holdout above 0%, the id of a user determines whether the user is in the holdout, so a test user cannot be placed there. Run the dry run for the ids of your test accounts and keep the ids that return is_holdout: true. With a 10% holdout, about one id in ten does. The result is the same on every request for the same id and optimization, so a holdout test user stays in the holdout.

3. Send test events

In a dry run, Levered logs no exposure. The tracking of the app still logs events as usual, and this tracking is what the test checks:

  1. Render the variant from the dry-run response, or the holdout experience if is_holdout is true.
  2. Log the exposure in the way the app does for real users, with the same test user id, the factor values and is_holdout.
  3. Trigger the conversion, so that the pipeline logs the reward with the same id.

With your own warehouse, these rows arrive in your tables. On the Managed Warehouse, send the events to the ingestion API and mark the test reward with "properties": {"test": true}.

4. Check that the events arrived

Managed Warehouse:

Terminal
levered verify <optimization-id> --anonymous-id <test-user-id> --json

Require exposure: true and reward: true for event arrival. The command also runs the aggregate identity check. identity contains its result. The top-level ok combines event arrival with identity.ok. Inspect the warnings and errors even if both events arrived.

A false top-level ok or exit status 1 may be recorded as identity pending only if its sole cause is one of the two cases described in step 1: the lack of representative non-test data, or the reward overlap of intentionally excluded QA traffic. Missing events, query or authentication errors, a failed holdout check, or identity failures with representative data still block launch. A pending result is not an overall pass.

For an arrival-only read, call authenticated GET /api/v2/warehouse/verify with the same optimization_id and anonymous_id. It returns the two booleans and does not run the identity check. It does not clear a pending or failed identity check.

Your own warehouse: Derive the arrival checks from the configured sources of the optimization:

  1. Read levered optimizations show <optimization-id> --json for the linked assignment and reward metric IDs. Fetch the saved SQL and the column mapping of each metric with authenticated GET /api/v2/warehouse/metrics/<metric-id>.
  2. Use levered warehouse query '<SQL>' --json for two read-only checks against those actual tables and mapped visitor/timestamp columns. Scope the exposure to this optimization, the reward to the chosen goal, and both to the same test visitor and test run. Preserve the configured organization and optimization filters, use the provider's SQL syntax, and resolve time parameters from the run.
  3. Read raw test rows even if training excludes them. For these targeted checks, relax only the deliberate QA exclusion. Confirm that the id and is_holdout match the dry run, that the timestamps belong to this run, and that the factors match the rendered variant. External holdout rows may have empty factors. Confirm that the chosen reward arrived for the same visitor and run.

Repeat levered verify <optimization-id> when representative non-test data is available. Intentionally excluded test rewards cannot establish aggregate id overlap.

5. Keep test users out of the results

Test users who keep using the app after launch are counted like all other users. For a handful of users, this does not matter. To exclude them completely, filter their ids, or a test marker that the pipeline already sets, in both of these places:

  • The reward metric, for example ... AND USER_ID NOT IN ('qa-1', 'qa-2').
  • The exposure source of the optimization (its assignment source), with the same filter.

Change either one with PUT /api/v2/warehouse/metrics/:id. On the Managed Warehouse, metrics that leave out properties.test already exclude test rewards.

6. Go live

Levered refuses to set an optimization live until at least one /serve call, live or dry run, has been made for it. The dry run in step 2 meets this condition. Go live when raw event delivery passes and every runnable identity check passes. Record any aggregate check that is still pending representative data. Then set the optimization live:

Terminal
levered optimizations update <optimization-id> --status live

Then deploy the version of the app that serves the optimization.

6. Test before launch