add runtime/engram.el, manifest.el; register seed builtins in codegen arity table

- runtime/engram.el: thin El wrappers over all __engram_* and __generate
  seed primitives (16 functions), matching the el_seed.c API exactly
- runtime/manifest.el: build manifest documenting module load order and
  the cat+compile+cc command for runtime builds
- el-compiler/src/codegen.el: add 77 __-prefix seed primitive entries to
  builtin_arity, covering str, fs, http, thread, exec, env, time, uuid,
  math, state, html, json, and engram seeds
This commit is contained in:
Will Anderson
2026-05-03 15:37:05 -05:00
parent 9d0e1f64d4
commit 33af4ed09e
3 changed files with 198 additions and 0 deletions
+78
View File
@@ -1997,6 +1997,84 @@ fn builtin_arity(name: String) -> Int {
if str_eq(name, "http_post_form_auth") { return 3 }
if str_eq(name, "http_serve") { return 2 }
if str_eq(name, "http_set_handler") { return 1 }
// Seed primitives (__-prefix) runtime/el_seed.c
if str_eq(name, "__str_len") { return 1 }
if str_eq(name, "__str_char_at") { return 2 }
if str_eq(name, "__str_alloc") { return 1 }
if str_eq(name, "__str_set_char") { return 3 }
if str_eq(name, "__str_cmp") { return 2 }
if str_eq(name, "__str_ncmp") { return 3 }
if str_eq(name, "__str_concat_raw") { return 2 }
if str_eq(name, "__str_slice_raw") { return 3 }
if str_eq(name, "__int_to_str") { return 1 }
if str_eq(name, "__str_to_int") { return 1 }
if str_eq(name, "__float_to_str") { return 1 }
if str_eq(name, "__str_to_float") { return 1 }
if str_eq(name, "__println") { return 1 }
if str_eq(name, "__print") { return 1 }
if str_eq(name, "__readline") { return 0 }
if str_eq(name, "__fs_read") { return 1 }
if str_eq(name, "__fs_write") { return 2 }
if str_eq(name, "__fs_exists") { return 1 }
if str_eq(name, "__fs_list_raw") { return 1 }
if str_eq(name, "__fs_mkdir") { return 1 }
if str_eq(name, "__fs_write_bytes") { return 3 }
if str_eq(name, "__http_do") { return 5 }
if str_eq(name, "__http_do_map") { return 5 }
if str_eq(name, "__http_do_to_file") { return 5 }
if str_eq(name, "__http_serve") { return 2 }
if str_eq(name, "__http_serve_v2") { return 2 }
if str_eq(name, "__http_response") { return 3 }
if str_eq(name, "__thread_create") { return 2 }
if str_eq(name, "__thread_join") { return 1 }
if str_eq(name, "__mutex_new") { return 0 }
if str_eq(name, "__mutex_lock") { return 1 }
if str_eq(name, "__mutex_unlock") { return 1 }
if str_eq(name, "__exec") { return 1 }
if str_eq(name, "__exec_bg") { return 1 }
if str_eq(name, "__env_get") { return 1 }
if str_eq(name, "__args_json") { return 0 }
if str_eq(name, "__exit_program") { return 1 }
if str_eq(name, "__time_now_ns") { return 0 }
if str_eq(name, "__sleep_ms") { return 1 }
if str_eq(name, "__uuid_v4") { return 0 }
if str_eq(name, "__sqrt_f") { return 1 }
if str_eq(name, "__log_f") { return 1 }
if str_eq(name, "__ln_f") { return 1 }
if str_eq(name, "__sin_f") { return 1 }
if str_eq(name, "__cos_f") { return 1 }
if str_eq(name, "__pi_f") { return 0 }
if str_eq(name, "__state_set") { return 2 }
if str_eq(name, "__state_get") { return 1 }
if str_eq(name, "__state_del") { return 1 }
if str_eq(name, "__state_keys") { return 0 }
if str_eq(name, "__html_sanitize") { return 2 }
if str_eq(name, "__url_encode") { return 1 }
if str_eq(name, "__url_decode") { return 1 }
if str_eq(name, "__json_get") { return 2 }
if str_eq(name, "__json_get_raw") { return 2 }
if str_eq(name, "__json_parse_map") { return 1 }
if str_eq(name, "__json_stringify_val") { return 1 }
if str_eq(name, "__json_array_len") { return 1 }
if str_eq(name, "__json_array_get") { return 2 }
if str_eq(name, "__json_array_get_string") { return 2 }
if str_eq(name, "__json_set") { return 3 }
if str_eq(name, "__engram_node") { return 3 }
if str_eq(name, "__engram_node_full") { return 8 }
if str_eq(name, "__engram_get_node") { return 1 }
if str_eq(name, "__engram_strengthen") { return 1 }
if str_eq(name, "__engram_forget") { return 1 }
if str_eq(name, "__engram_node_count") { return 0 }
if str_eq(name, "__engram_search") { return 2 }
if str_eq(name, "__engram_scan_nodes") { return 2 }
if str_eq(name, "__engram_connect") { return 4 }
if str_eq(name, "__engram_edge_between") { return 2 }
if str_eq(name, "__engram_neighbors") { return 1 }
if str_eq(name, "__engram_neighbors_filtered") { return 3 }
if str_eq(name, "__engram_activate") { return 2 }
if str_eq(name, "__engram_activate_json") { return 2 }
if str_eq(name, "__engram_scan_nodes_json") { return 2 }
if str_eq(name, "__generate") { return 1 }
// Filesystem
if str_eq(name, "fs_read") { return 1 }
if str_eq(name, "fs_write") { return 2 }
+86
View File
@@ -0,0 +1,86 @@
// runtime/engram.el El wrapper for the engram graph store
//
// Thin wrappers over the __engram_* seed primitives defined in el_seed.c.
// Each function delegates directly to the corresponding seed no logic here.
// The seed layer owns all storage, indexing, and graph traversal.
//
// Dependencies: runtime/string.el, runtime/json.el
// --- Node creation ---
fn engram_node(content: String, node_type: String, salience: Float) -> String {
return __engram_node(content, node_type, salience)
}
fn engram_node_full(content: String, nt: String, sal: Float, imp: Float,
source: String, lang: String, ts: Int, tags: String) -> String {
return __engram_node_full(content, nt, sal, imp, source, lang, ts, tags)
}
// --- Node retrieval ---
fn engram_get_node(id: String) -> String {
return __engram_get_node(id)
}
fn engram_node_count() -> Int {
return __engram_node_count()
}
// --- Node lifecycle ---
fn engram_strengthen(id: String) -> Bool {
return __engram_strengthen(id)
}
fn engram_forget(id: String) -> Bool {
return __engram_forget(id)
}
// --- Search and scan ---
fn engram_search(query: String, limit: Int) -> String {
return __engram_search(query, limit)
}
fn engram_scan_nodes(limit: Int, offset: Int) -> String {
return __engram_scan_nodes(limit, offset)
}
fn engram_scan_nodes_json(limit: Int, offset: Int) -> String {
return __engram_scan_nodes_json(limit, offset)
}
// --- Graph edges ---
fn engram_connect(from: String, to: String, rel: String, weight: Float) -> Bool {
return __engram_connect(from, to, rel, weight)
}
fn engram_edge_between(a: String, b: String) -> String {
return __engram_edge_between(a, b)
}
// --- Graph traversal ---
fn engram_neighbors(id: String) -> String {
return __engram_neighbors(id)
}
fn engram_neighbors_filtered(id: String, rel: String, min_w: Float) -> String {
return __engram_neighbors_filtered(id, rel, min_w)
}
fn engram_activate(query: String, depth: Int) -> String {
return __engram_activate(query, depth)
}
fn engram_activate_json(query: String, limit: Int) -> String {
return __engram_activate_json(query, limit)
}
// --- Generation ---
fn generate(form: String) -> String {
return __generate(form)
}
+34
View File
@@ -0,0 +1,34 @@
// runtime/manifest.el El runtime module manifest
//
// Load order for runtime compilation. Each module may depend on modules
// listed before it. The build system concatenates these in this order,
// then compiles the combined source.
//
// Modules:
// 1. runtime/string.el string operations (no dependencies)
// 2. runtime/math.el numeric/float operations (no dependencies)
// 3. runtime/state.el in-process key-value (no dependencies)
// 4. runtime/env.el environment, process, args, uuid
// 5. runtime/fs.el filesystem operations (depends: string)
// 6. runtime/exec.el subprocess execution (depends: string)
// 7. runtime/time.el time, date, calendar (depends: string, math)
// 8. runtime/json.el JSON operations (depends: string)
// 9. runtime/http.el HTTP client+server (depends: string, json)
// 10. runtime/engram.el graph store (depends: string, json)
// 11. runtime/thread.el threading, parallel_map (depends: all above)
// 12. runtime/collections.el list/map higher-level ops (depends: string)
//
// Build command (from el/ root):
// cat runtime/string.el runtime/math.el runtime/state.el runtime/env.el \
// runtime/fs.el runtime/exec.el runtime/time.el runtime/json.el \
// runtime/http.el runtime/engram.el runtime/thread.el \
// runtime/collections.el \
// <user-program.el> > combined.el
// ./dist/platform/elc combined.el > output.c
// cc -std=c11 -I el-compiler/runtime -lcurl -lpthread \
// -o output output.c el-compiler/runtime/el_seed.c
// This file itself is not compiled it is documentation only.
fn runtime_version() -> String {
return "2.0.0-el-native"
}