# RU V2 acceptance scenarios

The [schema-maintenance compile fixtures](schema-maintenance/) add the closed
TiPoC #230 Securities and Internet maintenance matrix without moving or
renaming the existing RU V2 pair below.

These scenarios implement the first securities RU acceptance pair for
[TiPoC #150](https://github.com/tidbcloud/TiPoC/issues/150).

| Scenario | Variant | discriminator anchor |
| --- | --- | --- |
| `securities-baseline.yaml` | baseline | `report_01` plus indexed `recent_trade_status_feature` |
| `securities-missing-index.yaml` | missing_index | the same reports with the feature index absent |

Both retain the canonical TPC-E foreground workload. All stable registered
foreground statements are rendered; the focus list is calculated after the
run as per-attempt mean RU Top 10, then the scenario anchor is added. Across
the pair this gives the default two anchors and remains below the hard limit of
four.

The checked-in files deliberately omit `reporting.query_cost.deployment_attestation`.
Before `init`, the operator must copy each file to an attempt-specific location
and add a target-bound verified attestation `path` and `sha256`. TiPoC fails
closed without it. Do not commit target addresses, credentials, attestation
documents, or generated run artifacts.

The collected evidence identity is
`required_provider_id: tidb_last_query_info_rru_wru/v1` and
`required_ru_model: resource_control_rru_plus_wru`. The scenario is the first
RU differentiation experiment, but the current TiDB value is the existing
Resource Control `RRU + WRU`; it must not be relabelled as RU v3 or as a future
provider. A later RU provider can reuse this scenario and report layer while
retaining its own model identity.

The pair executes the exact same unhinted `recent_trade_status_feature` SQL.
It never drops a customer or TPC-E-owned index. Prepare first verifies the
operation-owned `i_t_exec_st_dts` index is absent. For baseline only, create
and verify it after prepare and before run:

```sh
tipoc ops securities/tpce/recent_trade_status \
  --action add-feature-index --manifest <baseline-prepared-manifest> --wait
```

For missing-index, execute `add-feature-index` followed by
`drop-feature-index` before run. The second verified action receipt proves the
same feature SQL has returned to the omitted-index plan; the run begins only
after the index is absent. In each run, start the manual worker after foreground
readiness with:

```sh
tipoc ops securities/tpce/recent_trade_status \
  --action start --manifest <prepared-manifest> --wait
```

Cleanup drops the operation-owned index and verifies absence. Run baseline
first and complete cleanup before missing-index. A cleanup failure blocks the
next run. Cleanup publishes `actions/cleanup-restore-feature-index.json` plus
its probe/plan evidence; pairing requires that restoration receipt from both
runs. Big Query, foreground workload, dataset, SQL, parameters, concurrency
and windows are identical across the pair; only this index state changes. Both
specs bind the same generated-source object URI. Each run must start from a
fresh import/restore of that source snapshot; do not run the second case on the
mutated terminal database left by the first pressure run.
Pairing consumes the two
immutable `ru-acceptance` bundles; Statement Summary is optional reconciliation
evidence and does not supply per-attempt percentiles.

```sh
tipoc ru-acceptance pair \
  --baseline <baseline>/ru-acceptance/statement-aggregates.json \
  --missing-index <missing>/ru-acceptance/statement-aggregates.json \
  --baseline-action-receipt <baseline-add-action.json> \
  --missing-index-action-receipt <missing-index-drop-action.json> \
  --baseline-restore-receipt <baseline-cleanup-restore-action.json> \
  --missing-index-restore-receipt <missing-index-cleanup-restore-action.json> \
  --output <new-paired-output-directory>
```

The command extracts maximum `actRows` from verified `EXPLAIN ANALYZE` action
evidence when it is available; otherwise it retains the maximum `estRows` from
verified `EXPLAIN` evidence as explicitly labelled `plan_est_rows`. Prebuilt `--baseline-work` and `--missing-index-work` JSON
arrays of `{statement_id, variant_id, metric, value, source_ref}` are also accepted.
Without matching independent work evidence, the evaluator emits
`explanation_missing` and the Workload—RU chart omits that statement; it never
uses latency or statement order as a workload substitute.
