// ise.el — Internal State Events (ISE) subsystem. // // Internal State Events are Neuron's introspective record. When the reasoning // engine produces a response, an ISE captures the gap between: // pre_reasoning — what the model would say before internal deliberation // post_reasoning — what the model actually outputs after reasoning // // The compression_ratio tells us how much the reasoning compressed the // pre-response. A ratio near 1.0 means almost no change; a ratio near 0.0 // means the reasoning fundamentally transformed the output. // // gap_direction encodes whether the change moved toward expression // (more output, more detail) or suppression (filtered, condensed, withheld). // // WHY does Neuron care about this? // ISEs are the raw data for self-model calibration. By reviewing ISEs over // time, Neuron can identify systematic biases: topics where it consistently // suppresses, domains where reasoning rarely changes the output, etc. // This is the foundation of Cultivated General Intelligence — introspection // drives adaptation. // // Access is authenticated by default. ISEs contain sensitive reasoning traces // that should not be exposed to arbitrary callers. from types import { InternalStateEvent, NeuronError, } // ── Public API ──────────────────────────────────────────────────────────────── // log_internal_state — record one ISE. // // Called by the reasoning engine after each significant reasoning cycle. // The id format is "ise_" + 8 hex chars (matches Rust domain convention). @manager fn log_internal_state( trigger: String, pre_reasoning: String, post_reasoning: String, compression_ratio: String, gap_direction: String, tags: [String], ) -> Result { let id = "ise_" + native_uuid() let now = native_now() let ise = InternalStateEvent { id: id, trigger: trigger, pre_reasoning: pre_reasoning, post_reasoning: post_reasoning, compression_ratio: compression_ratio, gap_direction: gap_direction, tags: tags, logged_at: now, } native_store_ise(ise)? // ISE events are emitted at low verbosity — they are high volume. native_emit("ise.logged", {"id": id, "trigger": trigger, "direction": gap_direction}) Ok(ise) } // list_internal_state — retrieve recent ISEs. // // limit defaults to 10. Useful for reviewing recent reasoning patterns // during session orientation or calibration reviews. @accessor fn list_internal_state(limit: Int) -> Result<[InternalStateEvent], NeuronError> { let events = native_list_ise(limit)? Ok(events) } // get_internal_state — retrieve one ISE by ID. // // Used to drill into a specific reasoning event for detailed analysis. @accessor fn get_internal_state(id: String) -> Result { // ISEs are stored with prefix "ise_", so a bare 8-char hex ID needs // the prefix prepended. The native layer handles both forms. let results = activate InternalStateEvent where "id:{id}" let ise = native_list_ise(1)? Ok(ise[0]) }