b77f537dc6
- neuron-runtime, neuron-store, neuron-migrate: fix path deps (products/engram/ → foundation/engram/engrams/, products/el/ → foundation/el/engrams/) - neuron-rs workspace: fix axon-events/axon-protocol paths (../../../platform/ → ../../platform/, paths were off by one level) - neuron-lang/compiler/ removed (el self-hosting compiler now lives in foundation/el/el-compiler/)
87 lines
3.0 KiB
EmacsLisp
87 lines
3.0 KiB
EmacsLisp
// config.el — Runtime configuration subsystem.
|
|
//
|
|
// Config entries are key/value pairs that control Neuron's runtime behavior:
|
|
// persona directives, feature flags, thresholds, integration URLs, etc.
|
|
//
|
|
// WHY sealed blocks?
|
|
// Config mutations affect every subsequent tool call in this session and
|
|
// all future sessions. A malformed config write could silently alter Neuron's
|
|
// behavior in ways that are hard to debug. Sealed blocks ensure that config
|
|
// mutations are cryptographically logged and tamper-evident.
|
|
//
|
|
// The live config is authoritative over CLAUDE.md. When get_instructions()
|
|
// is called, it reads from config, not from the filesystem.
|
|
//
|
|
// inspect_config is a @public read — config keys are not secrets themselves.
|
|
// tune_config is a @manager write inside a sealed block — mutations are
|
|
// protected and auditable.
|
|
|
|
from types import {
|
|
ConfigEntry,
|
|
NeuronError,
|
|
}
|
|
|
|
// ── Public API ────────────────────────────────────────────────────────────────
|
|
|
|
// inspect_config — read one or all config entries.
|
|
//
|
|
// When key is empty string, returns all config entries.
|
|
// When key is provided, returns just that entry.
|
|
// This is @public because config keys are informational — they tell callers
|
|
// how Neuron is configured without exposing secret values.
|
|
@public
|
|
fn inspect_config(key: String) -> Result<[ConfigEntry], NeuronError> {
|
|
if key == "" {
|
|
let entries = native_list_config()?
|
|
return Ok(entries)
|
|
}
|
|
let value = native_get_config(key)?
|
|
let entry = ConfigEntry {
|
|
key: key,
|
|
value: value,
|
|
updated_at: native_now(),
|
|
}
|
|
Ok([entry])
|
|
}
|
|
|
|
// tune_config — set a runtime configuration value.
|
|
//
|
|
// Sealed because config changes have global scope across all future tool calls.
|
|
// The sealed block creates a cryptographic audit record of what changed and when.
|
|
//
|
|
// Key naming convention: "neuron.<subsystem>.<setting>"
|
|
// Examples:
|
|
// neuron.persona.directives
|
|
// neuron.memory.importance_threshold
|
|
// neuron.session.max_active_contexts
|
|
@manager
|
|
fn tune_config(key: String, value: String) -> Result<ConfigEntry, NeuronError> {
|
|
sealed {
|
|
native_set_config(key, value)?
|
|
let now = native_now()
|
|
let entry = ConfigEntry {
|
|
key: key,
|
|
value: value,
|
|
updated_at: now,
|
|
}
|
|
native_emit("config.updated", {"key": key})
|
|
Ok(entry)
|
|
}
|
|
}
|
|
|
|
// get_instructions — load the authoritative behavioral directives.
|
|
//
|
|
// This is the canonical way to load Neuron's behavioral configuration.
|
|
// Always call this at session start — the live config takes precedence
|
|
// over any cached or filesystem-based instructions.
|
|
@public
|
|
fn get_instructions() -> Result<[ConfigEntry], NeuronError> {
|
|
let directive_value = native_get_config("neuron.persona.directives")?
|
|
let entry = ConfigEntry {
|
|
key: "neuron.persona.directives",
|
|
value: directive_value,
|
|
updated_at: native_now(),
|
|
}
|
|
Ok([entry])
|
|
}
|