Skip to content

Add a golden scenario (regression-test-first)

When a bad recommendation is found in the wild, the fix starts with a failing scenario — never with a rule edit. Format reference: golden-scenarios.

1. Reproduce as a scenario

Capture the buyer's situation from the report (track + answers). Translate the answers to factor-option ids (/admin/factors, or the option ids in data/selection-model/authored-model.json), and write what SHOULD have happened:

jsonc
{
  "id": "wild-2026-08-slider-on-budget",       // dated, descriptive
  "title": "Reported: budget slider buyer was shown only premium systems",
  "track": "residential-homeowner",
  "optionIds": ["…the reported answers…"],
  "expect": { "mustInclude": ["…the system that should have appeared…"] }
}

Append it to data/selection-model/golden-scenarios.json and confirm it fails:

bash
npm run model:validate      # the new scenario must FAIL against the current model

A scenario that passes immediately reproduces nothing — tighten it until it captures the report.

2. Fix the model

Edit the authored deltas in scripts/build-authored-model.ts (rules, priorities, education), rebuild and re-validate until green:

bash
npm run model:build-authored && npm run model:validate
npm run model:import -- data/selection-model/authored-model.json --apply   # local

3. Re-approve and promote

A scenario addition or model change resets human review: set approval.status back to "pending", get the change reviewed (Paul), flip to "approved" (with by/on), then:

bash
npm run model:promote -- --apply

The promote gate re-runs the whole suite and refuses on any failure or unapproved suite. Commit the scenario + model change together — the scenario IS the regression test.