# Visual QA of a candidate version: `--package-version`

The visual check is advisory: moving a listed item to a new Package Version never waits on it (only a technical
failure, an unusable file reported with its reason, or content safety refuses a move). A plain `helix item visual-qa <id>`
renders the item's *current* pin, so on its own it cannot give notes for a version that is not pinned yet.
`--package-version` renders the candidate instead:

```
helix item visual-qa <item-id> --package-version 1.0.12 --vehicle-package vehicle-definition.json --local-critic
helix item visual-qa <item-id> --package-version 1.0.4 --submit          # an add-on, wearable or avatar
helix item visual-qa <item-id> --package-version 1.0.2 --submit          # a Prop or Device
```

| Category | Route to the candidate | Needs |
|---|---|---|
| vehicle | Try Now session with `trial.packageVersion` + `trial.vehiclePackage` | `--vehicle-package <file>` (the move's vehicle package JSON; a `{ "vehiclePackage": … }` wrapper is accepted) |
| avatar | Try Now session with `trial.packageVersion` | — |
| vehicle add-on, character add-on, wearable | customiser: `GET …/universal-items/<host>/add-ons?previewItemId=&previewPackageVersion=` and `GET …/universal-items/<add-on>?previewPackageVersion=` | — |
| Prop, Device | item viewer: `GET …/universal-items/<item>?previewPackageVersion=` under the CLI creator login | — |
| animation, scene | refused: their routes only show the pinned version | — |

Only the item's creator, an admin, or the hosted runner holding the job's lease can open a candidate; the CLI renders as
your `helix login` unless `--storage-state` says otherwise. A `--package-version` equal to the item's pin is the normal
run.

## Moving the item once it passed

`--submit` on a passing candidate prints the next command; run it to make the version the one owners resolve:

```
helix item set-version <item-id> --package-version 1.0.12 --reason "fixed the cuff seam"
```

The pin (`packageId`, `version`, `manifestCid`) comes from the public Package API, and the request is
`POST /api/v1/universal-items/<id>/versions`. If the gate still refuses (422) the server's message is printed first,
then its `remedy` and any hosted render it queued. `helix item visual-qa <id> --status` lists the item's
`pendingVersions` (sealed, not current) with each one's latest run. A `--package-version` the package does not have
fails with the sealed versions listed; a non-creator gets a first-line explanation that only the creator, an admin or
the hosted runner can render an unreleased version.

## How it stays honest

- **Identity is the candidate's.** The version is read from the item's own pinned package
  (`GET /api/v1/continuum/public/packages/<packageId>/versions/<v>`; it must be sealed), so the bundle's
  `packageVersion`, `manifestCid`, root document and model CID describe the candidate. An item with no pin is refused.
- **The server names what it served.** The Try Now response's `trial.candidate` (`packageId`, `packageVersion`,
  `packageVersionId`, `manifestCid`, `vehicleChecksum`, `modelCid`) must agree with the sealed version; it then fills the
  bundle's `packageVersionId` and, for a vehicle, `vehicleChecksum` — minted server-side after preparing the vehicle
  package, so it is unknown until then. The backend only accepts a non-current vehicle run whose
  `bundle.item.vehicleChecksum` is the checksum it minted in that trial.
- **The runtime must agree.** The vehicle route still checks that the runtime served exactly that checksum, and every
  route still requires the candidate model's CID among the fetched assets. A Prop or Device candidate also requires the
  item viewer's returned Package ID, Version and manifest CID to equal the sealed Version. The evidence records the
  definition/root and model CIDs; a Device must have a matching `helix.device/1` definition Version and web GLB.
- **It never falls back.** No `trial.candidate` (backend refused or not deployed), a session that was never requested,
  a customiser that never listed add-ons, a preview request that was refused, or a response built from another version
  is a harness error, so the run fails closed instead of judging the current version under the candidate's name.

`bundle.json` records what was seen under `facts.candidate` (`sessions`, `previews`, the sealed root/model CIDs and bound identity).

## Mechanics

Command code sets a module-level candidate config in `src/visualQa/browser.ts` (`setCandidate`) around the render
route; every browser the route opens installs Playwright routes that rewrite those requests and read their responses
before the page sees them. The routes themselves are unchanged. The pure parts (flag checks, body/URL rewrites,
response → identity) are in `src/visualQa/candidate.ts`.

## Hosted runs

A refused version move queues a hosted job whose claim carries `target.packageVersion` and, for vehicles,
`target.vehiclePackage`; the runner passes both to the same harness. `--hosted` itself still queues the current version,
so `--package-version` is not combined with it.
