You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two new builtins make registry-installed packages a first-class codec
library:
- omc_registry_codec_library() -> string[]
Scans omc_modules/ for *.omc files and returns every top-level
fn definition as a separate string entry. Empty array if
omc_modules/ doesn't exist (graceful no-op).
- omc_msg_recover_from_registry(msg: dict) -> string|null
Convenience for omc_msg_recover_compressed(msg,
omc_registry_codec_library()). Walks installed packages,
returns the matching canonical source or null.
Brace-aware fn extractor (extract_top_level_fns) tracks # line
comments + "..."/'...' string literals so braces inside literals
don't throw off depth counting.
Demos:
- examples/demos/llm_tandem_registry.omc: writes a synthetic
stats package to omc_modules/, signs an alpha-renamed copy of
pkg_mean, recovers the original via registry. Verified end-to-end
(3 fns extracted, canonical-hash match, returns library's
parameter name 'vs' not sender's 'xs').
- examples/tests/test_codec_registry.omc: 3 tests covering the
graceful-no-omc_modules path.
README + INDEX.md updated. 177 OMC tests total, all green.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
"fn pkg_mean(vs) { h n = arr_len(vs); h s = 0.0; h i = 0; while i < n { s = s + arr_get(vs, i); i = i + 1; } return s / n; }\n",
27
+
"fn pkg_sum(vs) { h n = arr_len(vs); h s = 0.0; h i = 0; while i < n { s = s + arr_get(vs, i); i = i + 1; } return s; }\n",
28
+
"fn pkg_max(vs) { h n = arr_len(vs); h m = arr_get(vs, 0); h i = 1; while i < n { if arr_get(vs, i) > m { m = arr_get(vs, i); } i = i + 1; } return m; }\n"
29
+
);
30
+
write_file("omc_modules/stats_pkg.omc", pkg);
31
+
print("[setup] Wrote synthetic package to omc_modules/stats_pkg.omc");
32
+
33
+
# 2. Inspect what the registry library now contains.
34
+
h lib = omc_registry_codec_library();
35
+
show("registry library size", arr_len(lib));
36
+
37
+
# 3. Sender writes a RENAMED variant of pkg_mean (xs instead of vs).
38
+
h sender_src = "fn pkg_mean(xs) { h n = arr_len(xs); h s = 0.0; h i = 0; while i < n { s = s + arr_get(xs, i); i = i + 1; } return s / n; }";
39
+
h msg = omc_msg_sign_compressed(sender_src, 18173, 1, 3);
description:"Scan omc_modules/ for installed registry packages and return every top-level fn definition as a separate string. Suitable as the library arg to omc_codec_decode_lookup / omc_msg_recover_compressed. Empty array if omc_modules/ doesn't exist.",
description:"Convenience for omc_msg_recover_compressed(msg, omc_registry_codec_library()). Returns the matching registry-package fn source, or null if no installed package contains it.",
1151
+
example:"omc_msg_recover_from_registry(msg) // recovered registry-fn source or null",
0 commit comments