Skip to content

models:switch

Terminal window
rai models:switch [OPTIONS] <NAME>

Switch the current model.

Validates that name is a provisioned model schema, then updates deployment.schema in raiconfig (preserving comments/layout). This is the schema rai models deploy and rai models branch use.

When the oplog is enabled, switch then folds in a pull of the new model (RAI-52899): this records the local branch baseline a fresh branch lacks — so the next deploy no longer errors demanding a manual pull — and syncs any changes waiting after a merge. The pull is best-effort: the pointer move has already committed, so a genuine sync conflict warns with its remedy rather than failing the switch.

Switching to the schema you are already on is recognized and reported rather than re-announced — but only after validation, so a pointer at a schema that no longer exists (the state teardown deliberately leaves) still fails, and a bare pointer is still normalized to the qualified form deploy needs (RAI-51703/RAI-51804). Re-running switch is the repair for a bare pointer, so it must not short-circuit. The no-op still syncs: the fold-in pull is what records a missing branch baseline, and skipping it would make re-running switch useless as that repair too.

Validation dispatches on the configured oplog backend, so switch is a first-class verb on every backend. With the oplog disabled it is a pure pointer move (nothing to sync), so it still works like teardown does in that mode:

  • jsonl: the model is provisioned iff its local oplog store has records (a parent carries Deploy/Create entries; a branch a leading BranchEntry). Validated purely from the oplog — no SQL connection.
  • snowflake: keep the is_model_schema gate (the RELATIONALAI_MODEL object tag set during real provisioning), unchanged.
  • oplog disabled: there is no oplog to consult, and a disabled-mode deploy is a plain schema install that sets no RELATIONALAI_MODEL tag — so is_model_schema would wrongly reject it. Fall back to schema_exists (existence-only, no tag), the least-surprising gate that still catches a typo’d target.

Options

OptionTypeDescription
--yes, -yBooleanSkip confirmation prompts (e.g. when modifying a raiconfig.yaml outside the current directory). Default: False.
--pathfilePath to the model file, used to verify code-owned remote changes are in sync while syncing the new model. Defaults to config.model.path.

See Also