Files
Claude 87ac907403 feat(api): save Test Runner scenarios
Migration 018 adds a test_scenarios table, and /wp/api/test/scenarios
gives it list/get/create/update/delete. A scenario stores its stack
(library modules and bundles referenced live by id), pinned $var
values, seed spec and output variable, plus two JSON blobs the Test
Runner writes: a baseline to compare against and the latest run
summary. Listing can filter to the scenarios that use a given module
or bundle, for the "used in N scenarios" hint.

Scenarios are local only. They are not part of Import/Export or the
community, and this is a row-level table, so no schema_version bump.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xwq95EvrKu6WgE9D5rahKy
2026-09-26 01:54:11 +00:00

36 lines
1.4 KiB
SQL

-- Test Runner scenarios — saved stacks the Test Runner re-runs on demand.
--
-- A scenario references library modules and bundles LIVE by id (the stack
-- JSON holds `{module: id}` / `{bundle: id}` items), so editing a module
-- changes the next run. That is the point: a stored baseline lets the
-- runner say which variables moved since. Local-only by design, never
-- exported or published.
--
-- Columns:
-- stack JSON list of stack items, run top to bottom
-- pins JSON object of pinned $var values (stand-ins for upstream)
-- seeds JSON seed spec (from+count, random+count, or list)
-- output_var the variable the runner treats as the prompt, or NULL
-- baseline JSON snapshot of a run to compare against, or NULL
-- last_run JSON summary of the most recent run, or NULL
--
-- NOTE: the migration runner splits on the semicolon char, so comments
-- must avoid it.
CREATE TABLE IF NOT EXISTS test_scenarios (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
description TEXT NOT NULL DEFAULT '',
is_pinned INTEGER NOT NULL DEFAULT 0,
stack TEXT NOT NULL DEFAULT '[]',
pins TEXT NOT NULL DEFAULT '{}',
seeds TEXT NOT NULL DEFAULT '{"from": 0, "count": 100}',
output_var TEXT,
baseline TEXT,
last_run TEXT,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_test_scenarios_updated_at ON test_scenarios(updated_at DESC);