Where Are the Configuration Schemas for the Rust Core Located in OpenHuman?

The configuration schemas for the Rust core in OpenHuman are located in the src/openhuman/config/schema/ directory, which contains serde-derived structs that define typed interfaces for loading, validating, and accessing TOML/YAML configuration values at runtime.

The tinyhumansai/openhuman repository implements a strictly typed configuration system for its Rust core. These configuration schemas serve as the single source of truth for startup behavior, defining everything from voice provider endpoints to autonomy tiers. Understanding their location and structure is essential for extending core functionality or debugging initialization failures.

Schema Directory Structure and Architecture

According to the OpenHuman source code, the root package for all configuration schemas is src/openhuman/config/schema/. This directory follows a modular architecture where each distinct functional area receives its own schema definition.

The Central Entry Point

The mod.rs file at src/openhuman/config/schema/mod.rs acts as the central re-export hub. It gathers all individual schema modules into a unified namespace, allowing the rest of the codebase to import configurations via a single location:

use openhuman::config::schema::autonomy::AutonomyConfig;

Individual Schema Modules

Each configuration domain resides in its own file within the schema directory. As implemented in tinyhumansai/openhuman, key files include:

Every schema struct uses standard serde derives for serialization safety:

#[derive(Deserialize, Serialize, Default, Debug, Clone)]
pub struct AutonomyConfig {
    // fields with validation logic
}

Configuration Loading Flow

The path from raw configuration file to typed Rust struct involves two distinct layers: the low-level loader and the high-level operations API.

The Loader Implementation

The loader logic resides in src/openhuman/config/schema/load/ (specifically mod.rs within that directory). This module handles:

  1. Reading raw TOML or YAML from disk.
  2. Merging environment variable overrides.
  3. Deserializing the merged result into the schema structs defined in src/openhuman/config/schema/.

Runtime Access via the Ops API

Core subsystems do not interact with the loader directly. Instead, they query the loaded configuration through the openhuman::config::ops API. The high-level entry point is implemented in src/openhuman/config/ops/loader.rs, which exposes functions like load_config() that return fully populated schema objects.

Practical Implementation Examples

Accessing Configuration at Runtime

To retrieve configuration values within the Rust core, import the loader and specific schema types:

use openhuman::config::ops::load::load_config;
use openhuman::config::schema::autonomy::AutonomyConfig;

async fn print_autonomy() -> Result<(), Box<dyn std::error::Error>> {
    // Load the full configuration (including environment overlays)
    let cfg = load_config().await?;
    
    // Grab the specific autonomy part
    let autonomy: &AutonomyConfig = cfg.autonomy();
    println!("Autonomy level: {:?}", autonomy.tier);
    
    Ok(())
}

Source: src/openhuman/config/ops/loader.rs

Extending the Schema with Custom Fields

When adding new functionality, you must extend the configuration schemas to accept new parameters:

// src/openhuman/config/schema/my_feature.rs
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct MyFeatureConfig {
    /// Enables the experimental mode.
    pub experimental: bool,
    /// Optional endpoint URL.
    pub endpoint: Option<String>,
}

Then expose the module in src/openhuman/config/schema/mod.rs:

pub mod my_feature;

The loader in src/openhuman/config/schema/load/ will automatically include your new schema when deserializing the overall configuration structure.

Summary

  • Location: All Rust core configuration schemas reside in src/openhuman/config/schema/.
  • Entry Point: src/openhuman/config/schema/mod.rs re-exports all schema modules for unified imports.
  • Key Files: autonomy.rs, voice_server.rs, and proxy.rs define domain-specific configuration structs.
  • Loading Path: Raw configs are read by src/openhuman/config/schema/load/, then exposed via src/openhuman/config/ops/loader.rs.
  • Implementation: Schemas use serde derives (Deserialize, Serialize) for type-safe configuration parsing.

Frequently Asked Questions

What configuration file formats does OpenHuman support?

The Rust core primarily expects TOML or YAML files at startup. The loader in src/openhuman/config/schema/load/ parses these formats and deserializes them into the strongly typed structs defined in the schema directory.

How do I add a new configuration option to the OpenHuman Rust core?

Create a new Rust module in src/openhuman/config/schema/ containing a struct with serde derives (Deserialize, Serialize, Default, Debug, Clone). Add pub mod your_module; to src/openhuman/config/schema/mod.rs. The configuration loader will automatically recognize the new fields during the deserialization phase.

Where does the runtime loading logic reside?

The runtime loading logic is split between two locations. The low-level deserialization and environment override merging happens in src/openhuman/config/schema/load/, while the high-level API exposed to other core subsystems is located in src/openhuman/config/ops/loader.rs.

Can configuration values be overridden via environment variables?

Yes. According to the source implementation, the loader reads the raw configuration file first, then merges environment variable overrides before final deserialization into the schema structs. This allows containerized deployments to inject sensitive values without modifying on-disk configuration files.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →