feat(neuron-api): add identity/values write protection

Block evolve_knowledge, evolve_memory, forget, and link_entities (to_id
direction) from modifying the 15 hardcoded identity and values node IDs.
Returns HTTP 403 with a hint to use the cultivation path instead.

Add POST /api/neuron/cultivate — the bypass endpoint for intentional
cultivation sessions. Accepts { "operation": "...", ...args } and performs
the same operations without the protection check.

Add handle_api_forget and handle_api_evolve_memory as new protected-by-
default handlers, routed at /api/neuron/memory/forget and
/api/neuron/memory/evolve respectively.

Tested: 10 verification cases — 403 on all blocked targets, 200 on
non-protected nodes and FROM-direction links, cultivate bypass confirmed.
This commit is contained in:
2026-05-13 11:47:54 -05:00
parent cc07648ae1
commit 6a27fd231e
7 changed files with 346 additions and 0 deletions
+30
View File
@@ -17,6 +17,10 @@ el_val_t mem_load(el_val_t path);
el_val_t mem_boot_count_get(void);
el_val_t mem_boot_count_inc(void);
el_val_t mem_emit_state_event(el_val_t trigger, el_val_t kind, el_val_t content);
el_val_t idle_count(void);
el_val_t idle_inc(void);
el_val_t idle_reset(void);
el_val_t emit_heartbeat(void);
el_val_t pulse_count(void);
el_val_t pulse_inc(void);
el_val_t make_action(el_val_t kind, el_val_t payload);
@@ -26,7 +30,18 @@ el_val_t respond(el_val_t action_json);
el_val_t record(el_val_t outcome_json);
el_val_t one_cycle(void);
el_val_t awareness_run(void);
el_val_t security_research_authorized(void);
el_val_t threat_score_command(el_val_t cmd);
el_val_t threat_score_path(el_val_t path);
el_val_t threat_score_history(el_val_t history);
el_val_t threat_trajectory_check(el_val_t tool_name, el_val_t tool_input);
el_val_t threat_history_append(el_val_t text);
el_val_t chat_default_model(void);
el_val_t gemini_api_key(void);
el_val_t xai_api_key(void);
el_val_t llm_call_grok(el_val_t model, el_val_t system, el_val_t message);
el_val_t llm_call_gemini(el_val_t model, el_val_t system, el_val_t message);
el_val_t build_identity_from_graph(void);
el_val_t engram_compile(el_val_t intent);
el_val_t json_safe(el_val_t s);
el_val_t build_system_prompt(el_val_t ctx);
@@ -39,6 +54,7 @@ el_val_t handle_chat(el_val_t body);
el_val_t handle_see(el_val_t body);
el_val_t studio_tools_json(void);
el_val_t agentic_api_key(void);
el_val_t call_neuron_mcp(el_val_t tool_name, el_val_t args_json);
el_val_t agentic_tools_literal(void);
el_val_t dispatch_tool(el_val_t tool_name, el_val_t tool_input);
el_val_t handle_chat_agentic(el_val_t body);
@@ -62,6 +78,8 @@ el_val_t elp_extract_topic(el_val_t msg);
el_val_t elp_detect_predicate(el_val_t msg);
el_val_t elp_parse(el_val_t msg);
el_val_t handle_elp_chat(el_val_t body);
el_val_t is_protected_node(el_val_t id);
el_val_t api_err_protected(el_val_t id);
el_val_t api_json_escape(el_val_t s);
el_val_t api_query_param(el_val_t path, el_val_t key);
el_val_t api_query_int(el_val_t path, el_val_t key, el_val_t default_val);
@@ -86,6 +104,9 @@ el_val_t handle_api_inspect_config(el_val_t path, el_val_t body);
el_val_t handle_api_tune_config(el_val_t body);
el_val_t handle_api_inspect_graph(el_val_t method, el_val_t path, el_val_t body);
el_val_t handle_api_link_entities(el_val_t body);
el_val_t handle_api_forget(el_val_t body);
el_val_t handle_api_evolve_memory(el_val_t body);
el_val_t handle_api_cultivate(el_val_t body);
el_val_t handle_api_list_typed(el_val_t node_type, el_val_t path, el_val_t body);
el_val_t handle_api_consolidate(el_val_t body);
el_val_t strip_query(el_val_t path);
@@ -448,12 +469,21 @@ el_val_t handle_request(el_val_t method, el_val_t path, el_val_t body) {
if (str_eq(clean, EL_STR("/api/neuron/memory"))) {
return handle_api_remember(body);
}
if (str_eq(clean, EL_STR("/api/neuron/memory/evolve"))) {
return handle_api_evolve_memory(body);
}
if (str_eq(clean, EL_STR("/api/neuron/memory/forget"))) {
return handle_api_forget(body);
}
if (str_eq(clean, EL_STR("/api/neuron/recall"))) {
return handle_api_recall(method, path, body);
}
if (str_eq(clean, EL_STR("/api/neuron/consolidate"))) {
return handle_api_consolidate(body);
}
if (str_eq(clean, EL_STR("/api/neuron/cultivate"))) {
return handle_api_cultivate(body);
}
return err_404(clean);
}
return err_405(method, clean);