YAML Advanced Blocks
This page documents the runner-only blocks that plan prior-sensitivity scenarios, configure the AI advisor and set the Stage 50 diagnostic gates. The structured pipeline consumes these blocks and strips them before the public MMM YAML builder validates the model specification. The YAML configuration overview lists all root keys, YAML model specification covers the modelling blocks, and YAML runner settings covers data loading, fitting, optimisation and validation.
prior_sensitivity
The Python API reference covers scenario expansion, evidence construction and approved-patch application.
Use the optional prior_sensitivity block when you want the runner to write a
pre-fit prior scenario plan. This stage does not fit every scenario. It creates
resolved scenario configs that can be reviewed, approved, and run deliberately.
Conservative generated plan:
prior_sensitivity:
enabled: true
scenario_policy: conservative_mmm
reference: reference
Manual plan:
prior_sensitivity:
enabled: true
scenario_policy: manual
reference: reference
scenarios:
reference:
description: Current approved prior specification.
tighter_media_effect:
description: Lower media-effect amplitude on the scaled target space.
overrides:
media.saturation.priors.beta:
distribution: HalfNormal
sigma: 0.5
dims: ["channel"]
Supported keys:
| Key | Meaning |
|---|---|
enabled | Set to true to write Stage 05 prior-sensitivity artifacts |
scenario_policy | manual for declared scenarios or conservative_mmm for generated relative scenarios |
reference | Scenario name for the unchanged reference config |
scenarios | Optional manual scenario declarations |
allow_model_structure_overrides | Required before scenarios can change transform structure such as media.adstock.l_max |
Scenario names are slugs such as reference, longer_memory, or
tighter_media_effect. Avoid names such as baseline; in MMM, baseline has a
model meaning and should not be overloaded as a scenario label.
Allowed override paths are intentionally narrow:
media.adstock.priors.*media.saturation.priors.*priors.*- selected transform-structure paths such as
media.adstock.l_max, only whenallow_model_structure_overrides: true
For half-life mode, prior-sensitivity scenarios may override
media.adstock.priors.halflife or the active root prior. Do not override
parametrization in a scenario. An inactive alpha prior fails validation;
AMMM3 does not generate automatic half-life-duration scenarios.
The stage writes both a human-readable manifest and an LLM-safe manifest. Use the LLM-safe file when passing scenario context to an external model because it aliases override paths and avoids free-text descriptions.
ai_advisor
See the diagnostics advisor guide for saved-run review, evidence requirements, identification limits and provider controls.
Use the optional ai_advisor block when you want privacy-safe, evidence-grounded
modelling guidance from deterministic rules and, optionally, OpenAI or
OpenRouter. The advisor proposes controlled tests. It does not approve a model,
establish causal identification, or apply a config patch to the run config.
ai_advisor:
enabled: true
provider: openrouter
mode: autopilot
privacy: anonymized_relative
approval: file_based
write_outputs: true
llm_enabled: true
diagnostics_review_enabled: true
openai_model: gpt-5-mini
openai_timeout_seconds: 60
openrouter_model: openai/gpt-5.6-terra
openrouter_timeout_seconds: 60
Supported keys:
| Key | Meaning |
|---|---|
enabled | Set to true to enable preparation checks and the final advisor |
provider | openai or openrouter |
mode | autopilot; the advisor prioritizes concise recommendations and approval-ready options |
privacy | anonymized_relative; raw channel names and raw business values are excluded from the LLM payload |
approval | file_based; proposed config changes are written as files for user approval |
write_outputs | Set to false to disable artifact writes even when the block is enabled |
llm_enabled | Defaults to true. Set to false to run deterministic privacy/rule checks without an LLM call |
diagnostics_review_enabled | Defaults to true; set to false to skip the post-fit 90_ai_advisor LLM review after interpretation |
openai_model | OpenAI model name used for the advisor call |
openai_timeout_seconds | Request timeout for the OpenAI call |
openrouter_model | OpenRouter model name used for the advisor call |
openrouter_timeout_seconds | Request timeout for the OpenRouter call |
The pipeline reads OPENAI_API_KEY or OPENROUTER_API_KEY from the process
environment based on provider. For local development, an untracked .env
file in the current working directory is also supported. Do not commit API keys.
The advisor stages complete even if an LLM call fails. In that case they write an error artifact and the rest of the pipeline can continue. Deterministic rules provide a minimum decision state: an LLM may make the state stricter, but cannot override a failed gate or weak-identification warning with a more favourable conclusion.
When the final advisor proposes a valid config patch, Stage 90 writes:
config_patch_proposal.yamlapproval_request.yaml
The proposal format is deliberately narrow:
overrides:
media.saturation.priors.beta:
distribution: HalfNormal
sigma: 0.5
dims: ["channel"]
To approve it, edit approval_request.yaml so status: approved, then run:
python -m abacus.pipeline.approval \
--approval-request results/<run>/90_ai_advisor/approval_request.yaml \
--approved-by "model owner"
The approval command writes approved_config.resolved.yaml and
approval_record.yaml beside the advisor artifacts. It does not mutate the
source YAML config.
By default, an enabled ai_advisor block also runs
90_ai_advisor after Stage 80 interpretation. That post-fit advisor
uses anonymized channel aliases, convergence counts, normalized predictive
metrics, coverage metrics, and scale-free design diagnostics. It intentionally
excludes raw target-scale fit errors from the LLM payload. Set
diagnostics_review_enabled: false to run only deterministic preparation checks.
diagnostics
Stage 50 resolves a complete, versioned decision-gate profile and writes it to
50_diagnostics/diagnostic_gates.resolved.yaml. The packaged default is
abacus/pipeline/diagnostic_gates.default.yaml. A documented copy is available
at examples/diagnostic_gates.team.yaml. Copy that file when your team needs a
governed profile with different thresholds; keep the source profile in version
control with the model configuration.
Use gates_file to select that profile. Relative paths are resolved from the
model YAML file. Optional inline thresholds take precedence over the selected
profile and are recorded in the resolved artifact.
diagnostics:
gates_file: diagnostic_gates.team_v1.yaml
thresholds:
design_max_vif:
warn: 10.0
fail: 20.0
mcmc_max_rhat:
warn: 1.02
fail: 1.08
Supported threshold keys:
design_max_vifdesign_condition_numbermcmc_divergence_countmcmc_max_rhatmcmc_min_ess_bulkmcmc_bfmi_minbayesian_pareto_k_maxpredictive_nrmseresidual_ljung_box_presidual_max_abs_acf
Validation rules:
- upper-bound checks require
warn <= fail - lower-bound checks require
warn >= fail - equality triggers the relevant warn or fail boundary; the zero-divergence gate is the explicit exception, where zero passes and any positive count fails
- a selected gate file must be schema version 1 and define every supported gate
- omit the block entirely to use the packaged default profile
These gates classify available diagnostic evidence. Passing them does not prove parameter identification, prior robustness, model validity, or causal identification. In particular, VIF and condition number are raw-design screens. A warning indicates weak-identification risk and should trigger controlled reparameterisation or prior-sensitivity runs. A clean screen only means that no material warning was detected by those checks.
This block affects only the structured runner. It is stripped before Stage 00 model preparation so the public MMM YAML schema remains unchanged.