clawft
Weftos

Config & Auth Services

ConfigService for namespaced configuration and in-memory secrets, and AuthService for credentials, scoped tokens and audit. Both are in-memory kernel services with governance gating.

Two kernel services provide runtime configuration and credential handling for agents and system components. Both keep their state in memory only: nothing in config_service.rs or auth_service.rs writes to disk, so values do not survive a kernel restart through these services.

Source: crates/clawft-kernel/src/config_service.rs, crates/clawft-kernel/src/auth_service.rs Phase: K5

Security status. Secrets and credential values held by both services are obfuscated with a keyed XOR (xor_encrypt in each file; the source comment says "production would use AEAD"). That is not encryption against an attacker who can read process memory or knows the key, and the page that used to say "encrypted at rest" overstated it. Do not treat these services as a secret store for production credentials.

ConfigService

Namespaced key-value configuration with change notification and a secret area. Mutating calls take the PID of the caller (changed_by), are gated by the governance gate when one is attached (actions config.set and the secret and delete equivalents), and with exochain append config events to the chain.

Values

pub enum ConfigValue {
    Text(String),
    Integer(i64),
    Float(f64),
    Boolean(bool),
    Json(serde_json::Value),
}

pub struct ConfigEntry {
    pub key: String,
    pub namespace: String,
    pub value: ConfigValue,
    pub updated_at: DateTime<Utc>,
}

API

let config = ConfigService::new(encryption_key);        // [u8; 32]
// or ConfigService::new_default()

// JSON values
config.set("mesh", "peers", json!(["node-a"]), caller_pid)?;
config.get("mesh", "peers") -> Option<Value>;
config.delete("mesh", "peers", caller_pid)?;
config.list_keys("mesh") -> Vec<String>;

// Typed values
config.set_typed(/* namespace, key, ConfigValue, changed_by */)?;
config.get_typed("mesh", "heartbeat_interval_ms") -> Option<ConfigEntry>;
config.list("mesh") -> Vec<ConfigEntry>;
config.delete_typed(/* namespace, key, changed_by */)?;

// Secrets, optionally scoped to PIDs
config.set_secret("api", "key", b"...", scoped_to_pids)?;
config.get_secret(/* namespace, key, requesting pid */)?;

// Change notification
let changes = config.subscribe("mesh");   // Arc<RwLock<Vec<ConfigChange>>>
config.change_log() -> Vec<ConfigChange>;

Change tracking

pub struct ConfigChange {
    pub namespace: String,
    pub key: String,
    pub old_value: Option<serde_json::Value>,
    pub new_value: Option<serde_json::Value>,
    pub changed_by: Pid,
    pub timestamp: DateTime<Utc>,
}

AuthService

Centralized credential management in the Plan 9 Factotum pattern (K5-G2, auth_service.rs header): agents do not hold raw secrets; they request scoped, time-limited tokens and every access is audited. There are two credential paths.

Path 1: stored credentials and issued tokens

pub struct CredentialRequest {
    pub credential_name: String,
    pub requester_pid: Pid,
    pub agent_id: String,
    pub scope: Vec<String>,
    pub ttl_secs: u64,
}

pub enum CredentialGrant { Granted(IssuedToken), Denied { reason: String } }

pub struct IssuedToken {
    pub token_id: String,
    pub credential_name: String,
    pub issued_to: Pid,
    pub issued_at: DateTime<Utc>,
    pub expires_at: DateTime<Utc>,
    pub scope: Vec<String>,
}

register_credential(name, credential_type, value, allowed_agents) stores a credential (value XOR-obfuscated) restricted to the listed agents; registration is a governed action (auth.credential.register). rotate_credential, request_token, validate_token and revoke_token complete the path. CredentialType is ApiKey, BearerToken, Certificate or Custom(String).

Path 2: hashed agent credentials

register_hashed_credential(agent_id, raw_credential, scopes) stores only the SHA-256 hash. authenticate(agent_id, raw_credential) compares hashes and returns an AuthToken with the registered scopes and a fixed one-hour expiry. validate_auth_token, revoke_auth_token and check_scope(token_id, scope) follow. A failed attempt is audited and, with exochain, appended as an auth chain event.

pub struct AuthToken {
    pub token_id: String,
    pub agent_id: String,
    pub scopes: Vec<String>,
    pub expires_at: DateTime<Utc>,
    pub created_at: DateTime<Utc>,
}

The hash is plain unsalted SHA-256 (sha256_hash); it is a credential-equality check, not a password-hashing scheme.

Audit

audit_log() returns AuditEntry records for registrations, token issues, authentication attempts and revocations.

On this page