Skip to content

Commit fafa302

Browse files
demo: end-to-end LLM workflow exercising the full discoverability stack
Single demo that walks an LLM through every primitive added across this session: surface size queries, builtin lookup (signature / category / unique / example), substring search, typo recovery via did_you_mean, code memory (omc_id, remember, recall_matches), structural diff (omc_change_report), bulk metrics (omc_code_metrics), program summary (omc_code_summary), substrate properties (is_attractor, attractor_distance, arr_resonance_vec), substrate scoring, token compression measurement, and error explanation. This is the canonical "LLM driving OMC via MCP" workflow, exercisable standalone via `omc examples/demos/llm_full_workflow.omc`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent fe6179f commit fafa302

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# End-to-end LLM workflow demo. Exercises every major LLM-facing
2+
# primitive added in this work session. Run this as a sanity check of
3+
# the overall surface.
4+
5+
fn show(label, v) { print(concat_many(label, " = ", to_string(v))); }
6+
fn section(name) { print(""); print(concat_many("=== ", name, " ===")); }
7+
8+
fn main() {
9+
print("OMC LLM workflow demo — exercises the full discoverability stack.");
10+
11+
section("Surface size");
12+
show("documented builtins", omc_builtin_count());
13+
show("OMC-unique builtins", omc_unique_count());
14+
show("categories ", omc_categories_count());
15+
show("error patterns ", omc_error_count());
16+
show("token vocab ", omc_token_vocab_size());
17+
18+
section("Look up a specific builtin");
19+
show("signature ", omc_help_signature("arr_softmax"));
20+
show("category ", omc_help_category("arr_softmax"));
21+
show("unique? ", omc_is_unique("arr_softmax"));
22+
show("example ", omc_help_example("arr_softmax"));
23+
24+
section("Find what we don't know the name of");
25+
h hits = omc_search_builtins("substrate");
26+
show("substrate hits", arr_len(hits));
27+
28+
section("Typo recovery");
29+
h sug = omc_did_you_mean("arr_softmx");
30+
show("did you mean", sug);
31+
32+
section("Code memory across edits");
33+
omc_memory_clear();
34+
h v1 = "fn loss(p, t) { return (p - t) * (p - t); }";
35+
h id_v1 = omc_id(v1);
36+
show("v1 omc_id", id_v1);
37+
omc_remember("loss", v1);
38+
h v2 = "fn loss(pred, target) { return (pred - target) * (pred - target); }";
39+
show("v2 matches v1?", omc_recall_matches("loss", v2)); # 1 (alpha-eq)
40+
h v3 = "fn loss(p, t) { return (p - t) * (p - t) + 0.01; }";
41+
show("v3 matches v1?", omc_recall_matches("loss", v3)); # 0 (changed)
42+
43+
section("Structural diff");
44+
h r = omc_change_report(v1, v3);
45+
show("modified ", dict_get(r, "modified"));
46+
show("suggestion", dict_get(r, "suggested_action"));
47+
48+
section("Code metrics");
49+
h m = omc_code_metrics(v3);
50+
show("complexity ", dict_get(m, "complexity"));
51+
show("ast_size ", dict_get(m, "ast_size"));
52+
show("ast_depth ", dict_get(m, "ast_depth"));
53+
show("compression_ratio", dict_get(m, "compression_ratio"));
54+
55+
section("Code summary");
56+
h s = omc_code_summary(v3);
57+
show("functions", dict_get(s, "functions"));
58+
59+
section("Substrate properties");
60+
show("is_attractor(8) ", is_attractor(8));
61+
show("attractor_distance(7)", attractor_distance(7));
62+
show("resonance_vec [1..5]", arr_resonance_vec([1, 2, 3, 4, 5]));
63+
64+
section("Substrate scoring");
65+
show("substrate_score(v3)", omc_substrate_score(v3));
66+
67+
section("Token compression");
68+
h saved = omc_token_byte_savings(v3);
69+
h pct = omc_token_compress_pct(v3);
70+
show("bytes saved", saved);
71+
show("pct saved", pct);
72+
73+
section("Catch + explain an error");
74+
h em = "";
75+
try { h _ = arr_softmx([1.0]); } catch e { em = e; }
76+
h ex = omc_explain_error(em);
77+
show("category", dict_get(ex, "category"));
78+
show("fix ", dict_get(ex, "fix"));
79+
80+
print("");
81+
print("End: this is the canonical 'LLM driving OMC via MCP' workflow.");
82+
}
83+
84+
main();

0 commit comments

Comments
 (0)