SwapAI

Errors

Stable failures for configuration, storage, providers, verification, promotion and cleanup.

import { SwapAIError } from "@swapai/core";

try {
  await relevance.requestTraining();
} catch (error) {
  if (error instanceof SwapAIError) {
    logger.error({ code: error.code, cause: error.cause }, error.message);
  }
}

Failure classes

FailureMeaning
Invalid configuration or resultThe declared task or a value violates its contract.
Not trainedClassification was requested without an available reference or promoted model.
Storage or migrationSQLite, a transaction or a supported schema migration failed.
Dataset not readyTraining was not started; the returned deficits explain what is missing.
Provider or reconciliationInfrastructure failed, timed out or cannot yet be reconciled.
Runner verificationA manifest, input hash, output hash or runner format did not match.
Candidate rejectedProtected evaluation did not meet the release policy.
Promotion refusedThe named run is not a valid candidate for the current generation.
Cleanup or erasureExternal resources or managed data could not be proved absent.

Background failures

Collection uses a queue so request latency does not include every SQLite write. Report queued failures through onBackgroundError, and call flush() where durability must be acknowledged.

Training, reconciliation, promotion and erasure are operator actions. They reject directly and must be observed by the command, job or API that invoked them.

Never treat an unknown cleanup state as success. Keep the run visible and call reconcileTraining() again after the provider is reachable.