Commit b660e59
csv_parse + selective imports + heal context awareness + NSL-KDD validation
+ transitive-import aliasing bug fix
Four roadmap items cleared in one batch, plus a real bug found via
real-data validation.
== csv_parse(text, sep, skip_header) ==
Native CSV parser builtin. 2.8x faster than per-line str_split on
10k MovieLens rows: 5ms vs 14ms. The full 10k load was originally
9.9s before Rc-shared collections, then 28ms after, now 5ms.
PAIN_POINTS HIGH-2 closed.
Defaults to comma separator. Pass sep="\t" for TSV, skip_header=1
to drop the first line.
== Selective imports: `from "path" import name1, name2;` ==
Pulls only listed names into the global namespace, unprefixed.
Mutually exclusive with the `as alias` form. Helper functions
the module relies on internally must be in the list too.
from "examples/lib/np.omc" import _np, array, mean, median;
If a name isn't found in the module, gives a clear error pointing
at the missing helper. PAIN_POINTS MED-4 closed.
== Heal pass context awareness ==
Two changes that fix PAIN_POINTS MED-3 (heal was unsafe-by-default
for any program with domain semantics on small ints):
1. @no_heal pragma opts a whole fn out of healing. Also added the
short-form @name pragma syntax (previously only @pragma[name]
worked) — matches Rust attribute style.
2. Literal harmonic rewriting is now OPT-IN, fires ONLY when a
numeric literal appears in an array-index position
(`xs[7]` → `xs[8]`). Outside index position — function args,
return values, comparison operands, variable bindings — literal
values are PRESERVED. Domain values like rating=4 no longer get
silently rewritten to 3.
Other heal classes (typo correction via Levenshtein,
divide-by-zero → safe_divide, arity auto-pad/truncate) all
still fire unchanged.
Existing heal demos (heal_pass_demo, self_healing_h2..h5) all still
work — they were already using array-index patterns or relied on
the other heal classes that didn't change.
== Real-data anomaly validation: NSL-KDD ==
22,544-row labeled network intrusion dataset from UNB. Sampled to
5000 rows: 2147 normal, 2853 attacks across multiple classes
(neptune DoS, guess_passwd, mscan, smurf, satan, etc.). Real
captured packets, not synthesis.
Results — IsolationForest wins on this dataset:
K=10: IF 9/10 vs harmonic 7/10
K=50: IF 45/50 vs harmonic 42/50
K=100: IF 92/100 vs harmonic 76/100
K=500: IF 351/500 vs harmonic 348/500
Honest interpretation in the file: NSL-KDD attacks are dominated by
volumetric DoS (smurf, neptune) with massive byte counts. IF picks
these magnitude outliers first — exactly its strength. Harmonic
spreads picks across diverse attack TYPES (mscan, warezmaster, back,
smurf) but lower per-pick precision.
This is the OPPOSITE of the synthesized credential-stuffing result
(10/10 vs 7/10) because credential stuffing is structural (rare
combinations of normal values) while NSL-KDD attacks are mostly
magnitude outliers. Right tool for the right threat model:
- Harmonic for structural / multi-vector / "looks normal per dim"
- IF for volumetric / magnitude-outlier
== Critical bug fix: transitive-import aliasing ==
Found via NSL-KDD validation. When `ha` (harmonic_anomaly) imports
`np` internally and the user file ALSO imports `ha as ha`, the
aliasing pass was renaming np's already-prefixed functions
(np.argsort, np.median, ...) to ha.np.argsort, ha.np.median, ...
Symptom: `np.argsort([3, 1, 2])` after `import "harmonic_anomaly"
as ha;` failed with "Undefined function: argsort".
Fix in interpreter.rs import_module_with_alias: skip names that
already contain a dot. Those came from a transitively-imported
child module and belong to that child, not the outer alias.
Found because real validation imports BOTH ha (which depends on np)
AND np directly. Synthetic tests never hit this because demo files
only imported np directly.
43/43 functional examples produce identical output under tree-walk
and VM. 18/18 OMC tests pass via --test mode. 92/92 unit tests pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 4f15dae commit b660e59
6 files changed
Lines changed: 5539 additions & 53 deletions
File tree
- examples/datascience
- nsl_kdd_data
- omnimcode-core/src
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
81 | 88 | | |
82 | 89 | | |
83 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
170 | 179 | | |
171 | | - | |
172 | 180 | | |
173 | 181 | | |
174 | 182 | | |
| |||
0 commit comments