Solve outcome curves to hit a pipeline's targets
solve_outcomeAdjust outcome-curve lever values until SQL-computed metrics over generated tables hit per-period targets. Use it when metrics derive from generated data, not declared fields.
Instructions
Find outcome-curve values that make SQL metrics over the data hit targets.
Use it when the number that matters is computed from the generated
tables rather than declared on them: net revenue after refunds, revenue
after a fee, a ratio of two tables. Each query runs in DuckDB over the
generated tables and returns two columns, the period and the value, one
row per period. Each target names a metric, the table.column outcome
curve that moves it (the lever, which must have exact per-period
values), and the value per period. Set direction: "inverse" when a
larger lever lowers the metric, as refunds lower net revenue.
Nothing is written. On success, replace each lever curve's
curve_points in your schema with levers[lever], then generate as
usual; attest_dataset will confirm the curves hold.
Args:
schema: The schema dict, with an outcome curve per lever.
queries: Metric name to DuckDB query, e.g. {"net": "SELECT date_trunc('month', ordered_at), SUM(amount) * 0.97 FROM orders GROUP BY 1"}.
targets: [{"metric", "lever", "values": {"2025-01": 70000}, "direction"?}].
tolerance: Relative tolerance per period, e.g. "0.5%".
max_iterations: Generate-and-query rounds allowed, at most 40.
seed: Seed used for every round.
Returns:
{"ok", "converged", "reason", "message", "iterations", "best_iteration", "levers", "steps"}. reason is one of
converged, max_iterations, max_seconds, diverging, unresponsive,
infeasible, pipeline_error; message says what to change when it
is not converged.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| seed | No | ||
| schema | Yes | ||
| queries | Yes | ||
| targets | Yes | ||
| tolerance | No | 1% | |
| max_iterations | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |