Environment Variables

Overview

AspectDetails
PurposeEnvironment-level toggles for network access, evaluation, snapshots, and docs tooling.
AudienceCLI users and operators tuning runtime behavior.
ScopeCLI commands and programmatic runs; config values override env when both are set.
NetworkOffline by default; network must be explicitly enabled.
Source of truthdocs/reference/env-vars.md, src/invarlock/cli/commands/*, src/invarlock/cli/backend_runtime.py, src/invarlock/runtime_security.py, src/invarlock/core/runner.py.

Quick Start

# Allow model + dataset downloads for a single command
INVARLOCK_ALLOW_NETWORK=1 invarlock evaluate --baseline gpt2 --subject gpt2

# Force evaluation device for a one-off compare/evaluate run
INVARLOCK_EVAL_DEVICE=cpu INVARLOCK_ALLOW_NETWORK=1 \
  invarlock evaluate --baseline gpt2 --subject gpt2 --device cpu

Concepts

  • Offline-first: all network access is opt-in and must be explicitly enabled.
  • Precedence: when a setting exists in both env + config/CLI, the winner is setting-specific (see the matrix below).
  • Auditability: selected env flags are recorded in report.meta.env_flags for traceability.

Precedence (conflict cases)

  1. CLI/config values for assurance-critical policy (strictness, drift/acceptance bands, overhead skip, tiny relax).
  2. Env overrides only for explicitly env-scoped toggles (for example, downloads and calibration materialization).
  3. Packaged defaults when no explicit setting exists.

Key override matrix

SettingEnv varConfig/CLIWinner ruleHow to confirm
Calibration materializeINVARLOCK_ALLOW_CALIBRATION_MATERIALIZEcontext.eval.materialize_calibration / context.eval.allow_iterable_calibrationEnv wins.Config shows in report.context; env is not recorded.
Network downloadsINVARLOCK_ALLOW_NETWORKEnv-only toggle.Not recorded; rely on env.
Offline datasetsHF_DATASETS_OFFLINEEnv-only toggle.Not recorded; rely on env.

Conflict examples

ScenarioResultFix
context.run.skip_overhead_check: true in --profile releaseOverhead check is skipped and recorded in guard_overhead.source.Set context.run.skip_overhead_check: false for full overhead enforcement.
context.run.tiny_relax: trueTiny-relax gating is enabled from config and recorded in auto.tiny_relax.Remove or set to false for full policy strictness.

Reference

Network & data

VariableDefaultPurpose
INVARLOCK_ALLOW_NETWORKunsetEnable outbound downloads for models/datasets.
HF_DATASETS_OFFLINEunsetForce Hugging Face datasets to use local cache only.

Model loading

VariableDefaultPurpose
INVARLOCK_ALLOW_REMOTE_CODEunsetExplicitly allow remote model code execution.

INVARLOCK_ALLOW_REMOTE_CODE is the only environment gate for remote model code execution. Use INVARLOCK_ALLOW_REMOTE_CODE=1 or --allow-remote-code when remote code is required.

Evaluation & pairing

VariableDefaultPurpose
INVARLOCK_BOOTSTRAP_BCAunsetPrefer BCa bootstrap CIs when sample size allows.
INVARLOCK_TINY_RELAXunsetDoctor-only hint for tiny local demos (does not drive assurance gates).
INVARLOCK_EVAL_DEVICEunsetForce evaluation device (cpu, cuda, mps).
INVARLOCK_STORE_EVAL_WINDOWS1Store token windows in reports (set 0 to disable).
INVARLOCK_ALLOW_CALIBRATION_MATERIALIZEunsetAllow materializing iterables lacking __len__.

Dataset preparation

VariableDefaultPurpose
INVARLOCK_CAPACITY_FASTunsetApproximate capacity estimation for quick runs.
INVARLOCK_DEDUP_TEXTSunsetExact-text dedupe before tokenization.
INVARLOCK_HF_DATASETS_CACHEunsetOverride the writable fallback cache used when HF dataset loads hit a shared-cache lock/permission error.

Determinism & performance

VariableDefaultPurpose
INVARLOCK_OMP_THREADS1Thread caps for determinism preset.
INVARLOCK_DEBUG_TRACEunsetVerbose debug traces for data/eval paths.
INVARLOCK_LIGHT_IMPORTunsetAvoid heavy imports for docs/tests.

Checkpointing & snapshots

VariableDefaultPurpose
INVARLOCK_SNAPSHOT_MODEautoauto, bytes, or chunked snapshot strategy.
INVARLOCK_SNAPSHOT_AUTO_RAM_FRACTION0.4RAM fraction threshold for auto mode.
INVARLOCK_SNAPSHOT_THRESHOLD_MB768Size threshold for chunked snapshots.

Model export

VariableDefaultPurpose
INVARLOCK_EXPORT_MODELunsetEnable HF export during model-export capable CLI flows.
INVARLOCK_EXPORT_DIRunsetTarget directory for model export.

Guarding & evidence

VariableDefaultPurpose
INVARLOCK_ASSERT_GUARDSunsetEnable guard runtime assertions.
INVARLOCK_EVIDENCE_DEBUGunsetEmit guards_evidence.json for audit.

Primary-metric gate bounds are profile/config settings (primary_metric.acceptance_range and primary_metric.drift_band), not environment overrides. Strictness/tiny-relax/overhead-skip are also config/profile policy: context.eval.strict / context.eval.strict_errors, context.run.strict_guard_prepare, context.run.tiny_relax, context.run.skip_overhead_check.

Config loading

VariableDefaultPurpose
INVARLOCK_CONFIG_ROOTunsetOverride packaged runtime/ data.
INVARLOCK_ALLOW_CONFIG_INCLUDE_OUTSIDEunsetAllow YAML !include outside config dir.

Reporting & telemetry

VariableDefaultPurpose
INVARLOCK_TELEMETRYunsetEmit single-line telemetry summary.

Plugins

VariableDefaultPurpose
INVARLOCK_ALLOW_THIRD_PARTY_PLUGINSunsetEnable third-party plugin discovery.
INVARLOCK_MINIMALunsetShow minimal plugin list in invarlock advanced plugins.

Runtime enforcement

VariableDefaultPurpose
INVARLOCK_ALLOW_HOST_EXECUTIONunsetAdvanced/internal host-execution override. Prefer invarlock evaluate --execution-mode host for the public compare/evaluate path.
INVARLOCK_CONTAINER_EXECUTIONunsetInternal recursion guard marking runtime-container execution.
INVARLOCK_CONTAINER_ENGINEunsetForce the OCI engine used for default runtime-container execution (podman or docker).
INVARLOCK_RUNTIME_IMAGEunsetOverride the OCI image used for containerized model execution.
INVARLOCK_RUNTIME_IMAGE_DIGESTunsetSupply the immutable digest recorded into runtime.manifest.json.

Docs build

VariableDefaultPurpose
INVARLOCK_DOCS_MERMAIDunsetEnable Mermaid diagrams in MkDocs.
INVARLOCK_DOCS_EXTRA_JSunsetExtra JavaScript URLs for docs build.

Troubleshooting

  • Downloads blocked: set INVARLOCK_ALLOW_NETWORK=1 and retry.
  • Multiple container engines installed: set INVARLOCK_CONTAINER_ENGINE=podman or INVARLOCK_CONTAINER_ENGINE=docker.
  • HF dataset cache lock/permission errors on local reruns: set INVARLOCK_HF_DATASETS_CACHE=/path/to/writable/cache or let InvarLock retry under its own writable cache.
  • Calibration iterables fail: use INVARLOCK_ALLOW_CALIBRATION_MATERIALIZE=1.
  • Third-party plugins missing: set INVARLOCK_ALLOW_THIRD_PARTY_PLUGINS=1 or use --allow-third-party-plugins.

Observability

  • report.meta.env_flags records selected env toggles.
  • reports capture telemetry and policy digests derived from these flags.