# OpenLogi Configuration Schema Version: Current Constants and Validation

> Discover the current OpenLogi configuration schema version 7. Learn how SCHEMA_VERSION is defined and validated in TOML files for optimal setup. Get your OpenLogi project configured correctly.

- Repository: [Xuan Zhang/OpenLogi](https://github.com/AprilNEA/OpenLogi)
- Tags: api-reference
- Published: 2026-09-11

---

**The current OpenLogi configuration schema version is 7, defined as the public constant `SCHEMA_VERSION` in the core crate and required in all user TOML configuration files.**

The AprilNEA/OpenLogi repository employs a strict versioning system to maintain compatibility between the Rust-based engine and user-defined settings. Understanding the OpenLogi configuration schema version is essential for ensuring your deployments run without validation errors or migration issues.

## Current Schema Version Constant

As implemented in the master branch, the configuration schema version is hardcoded as a `u32` constant in the core library. In [`crates/openlogi-core/src/config.rs`](https://github.com/AprilNEA/OpenLogi/blob/main/crates/openlogi-core/src/config.rs) at line 94, the version is defined as:

```rust
pub const SCHEMA_VERSION: u32 = 7;

```

All configuration loading operations compare user-provided values against this constant to determine compatibility and trigger migration logic when necessary.

### Example Configuration File

The repository includes a reference implementation in [`docs/config.example.toml`](https://github.com/AprilNEA/OpenLogi/blob/main/docs/config.example.toml) that demonstrates the required TOML field:

```toml
schema_version = 7

```

User configurations must include this exact value to pass validation during the loading process.

## Validating the Schema Version Programmatically

The OpenLogi codebase provides explicit methods for verifying configuration compatibility at runtime. The loading logic in [`crates/openlogi-core/src/config/file.rs`](https://github.com/AprilNEA/OpenLogi/blob/main/crates/openlogi-core/src/config/file.rs) performs version checks against `SCHEMA_VERSION` during both load and save operations.

### Loading and Verifying Existing Configurations

To load a configuration from the default location and assert that its schema version matches the current constant:

```rust
use openlogi_core::config::{Config, ConfigFile};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Load configuration from the default location (or a custom path)
    let cfg: Config = ConfigFile::load_default()?;
    
    // Verify the schema version
    assert_eq!(cfg.schema_version, openlogi_core::config::SCHEMA_VERSION);
    println!("Config schema version: {}", cfg.schema_version);
    Ok(())
}

```

### Creating New Configurations

When generating new configuration instances programmatically, the `Default` trait implementation automatically sets the correct schema version:

```rust
use openlogi_core::config::{Config, ConfigFile};

fn new_config() -> Config {
    // `Config::default()` automatically sets `schema_version` to the current constant
    Config::default()
}

```

This ensures that newly created configurations always match the current OpenLogi configuration schema version without manual field assignment.

## Implementation Details and File Locations

The schema version system spans three critical files in the repository:

- **[`crates/openlogi-core/src/config.rs`](https://github.com/AprilNEA/OpenLogi/blob/main/crates/openlogi-core/src/config.rs)** — Defines the `pub const SCHEMA_VERSION: u32 = 7` constant and the core `Config` struct that deserializes the TOML representation.
- **[`docs/config.example.toml`](https://github.com/AprilNEA/OpenLogi/blob/main/docs/config.example.toml)** — Provides the canonical example showing `schema_version = 7` as the expected user-facing value.
- **[`crates/openlogi-core/src/config/file.rs`](https://github.com/AprilNEA/OpenLogi/blob/main/crates/openlogi-core/src/config/file.rs)** — Implements the I/O logic that reads configuration files from disk, validates the `schema_version` field against `SCHEMA_VERSION`, and handles migration paths for outdated configurations.

## Summary

- The current OpenLogi configuration schema version is **7**.
- The version is defined as a public constant `SCHEMA_VERSION: u32` in [`crates/openlogi-core/src/config.rs`](https://github.com/AprilNEA/OpenLogi/blob/main/crates/openlogi-core/src/config.rs).
- All user configuration files must specify `schema_version = 7` in their TOML headers.
- The `Config::default()` constructor automatically initializes new configurations with the correct version.
- Runtime validation occurs in [`file.rs`](https://github.com/AprilNEA/OpenLogi/blob/main/file.rs), which compares user configurations against the `SCHEMA_VERSION` constant.

## Frequently Asked Questions

### What is the current OpenLogi configuration schema version?

The current version is **7**. This integer value is defined as the constant `SCHEMA_VERSION` in [`crates/openlogi-core/src/config.rs`](https://github.com/AprilNEA/OpenLogi/blob/main/crates/openlogi-core/src/config.rs) and represents the latest supported configuration format for the master branch.

### Where does OpenLogi validate the configuration schema version?

Validation occurs in [`crates/openlogi-core/src/config/file.rs`](https://github.com/AprilNEA/OpenLogi/blob/main/crates/openlogi-core/src/config/file.rs), which handles all configuration I/O operations. This module compares the `schema_version` field from the user's TOML file against the `SCHEMA_VERSION` constant to determine if the configuration requires migration or is compatible with the current engine build.

### How do I ensure my configuration file uses the correct schema version?

Set `schema_version = 7` in the root of your TOML configuration file, following the example in [`docs/config.example.toml`](https://github.com/AprilNEA/OpenLogi/blob/main/docs/config.example.toml). When creating configurations programmatically, use `Config::default()` rather than manual struct initialization to automatically inherit the current `SCHEMA_VERSION` value.

### What happens if my configuration uses an outdated schema version?

The loader in [`file.rs`](https://github.com/AprilNEA/OpenLogi/blob/main/file.rs) uses the `SCHEMA_VERSION` constant to detect version mismatches and execute appropriate migration logic or validation checks. Configurations that do not match the expected version may trigger errors or automatic conversion procedures depending on the specific version difference and the implementation in the core crate.