kumi 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -1
- data/.ruby-version +1 -0
- data/CHANGELOG.md +25 -0
- data/CLAUDE.md +26 -139
- data/README.md +143 -372
- data/data/functions/agg/boolean.yaml +14 -0
- data/data/functions/agg/numeric.yaml +80 -0
- data/data/functions/agg/string.yaml +8 -0
- data/data/functions/core/arithmetic.yaml +50 -0
- data/data/functions/core/boolean.yaml +18 -0
- data/data/functions/core/comparison.yaml +42 -0
- data/data/functions/core/constructor.yaml +32 -0
- data/data/functions/core/select.yaml +7 -0
- data/data/functions/core/stencil.yaml +21 -0
- data/data/functions/core/string.yaml +19 -0
- data/data/kernels/javascript/agg/boolean.yaml +12 -0
- data/data/kernels/javascript/agg/numeric.yaml +27 -0
- data/data/kernels/javascript/agg/string.yaml +5 -0
- data/data/kernels/javascript/core/arithmetic.yaml +32 -0
- data/data/kernels/javascript/core/boolean.yaml +12 -0
- data/data/kernels/javascript/core/comparison.yaml +24 -0
- data/data/kernels/javascript/core/constructor.yaml +15 -0
- data/data/kernels/javascript/core/select.yaml +7 -0
- data/data/kernels/javascript/core/string.yaml +12 -0
- data/data/kernels/ruby/agg/boolean.yaml +18 -0
- data/data/kernels/ruby/agg/numeric.yaml +29 -0
- data/data/kernels/ruby/agg/string.yaml +5 -0
- data/data/kernels/ruby/core/arithmetic.yaml +38 -0
- data/data/kernels/ruby/core/boolean.yaml +15 -0
- data/data/kernels/ruby/core/comparison.yaml +30 -0
- data/data/kernels/ruby/core/constructor.yaml +17 -0
- data/data/kernels/ruby/core/select.yaml +4 -0
- data/data/kernels/ruby/core/string.yaml +15 -0
- data/debug_ordering.rb +52 -0
- data/docs/FORM_SCHEMA.md +85 -0
- data/docs/OUTPUT_SCHEMA.md +69 -0
- data/docs/SYNTAX.md +626 -373
- data/golden/array_element/expected/ast.txt +21 -0
- data/golden/array_element/expected/input_plan.txt +5 -0
- data/golden/array_element/expected/lir_00_unoptimized.txt +13 -0
- data/golden/array_element/expected/lir_01_hoist_scalar_references.txt +13 -0
- data/golden/array_element/expected/lir_02_inlined.txt +13 -0
- data/golden/array_element/expected/lir_03_cse.txt +13 -0
- data/golden/array_element/expected/lir_04_1_loop_fusion.txt +13 -0
- data/golden/array_element/expected/lir_04_loop_invcm.txt +13 -0
- data/golden/array_element/expected/lir_06_const_prop.txt +13 -0
- data/golden/array_element/expected/nast.txt +7 -0
- data/golden/array_element/expected/schema_javascript.mjs +13 -0
- data/golden/array_element/expected/schema_ruby.rb +41 -0
- data/golden/array_element/expected/snast.txt +7 -0
- data/golden/array_element/expected.json +5 -0
- data/golden/array_element/input.json +9 -0
- data/golden/array_element/schema.kumi +11 -0
- data/golden/array_index/expected/ast.txt +59 -0
- data/golden/array_index/expected/input_plan.txt +5 -0
- data/golden/array_index/expected/lir_00_unoptimized.txt +41 -0
- data/golden/array_index/expected/lir_01_hoist_scalar_references.txt +41 -0
- data/golden/array_index/expected/lir_02_inlined.txt +42 -0
- data/golden/array_index/expected/lir_03_cse.txt +40 -0
- data/golden/array_index/expected/lir_04_1_loop_fusion.txt +40 -0
- data/golden/array_index/expected/lir_04_loop_invcm.txt +40 -0
- data/golden/array_index/expected/lir_06_const_prop.txt +40 -0
- data/golden/array_index/expected/nast.txt +33 -0
- data/golden/array_index/expected/schema_javascript.mjs +46 -0
- data/golden/array_index/expected/schema_ruby.rb +75 -0
- data/golden/array_index/expected/snast.txt +33 -0
- data/golden/array_index/expected.json +5 -0
- data/golden/array_index/input.json +1 -0
- data/golden/array_index/schema.kumi +19 -0
- data/golden/array_operations/expected/ast.txt +50 -0
- data/golden/array_operations/expected/input_plan.txt +10 -0
- data/golden/array_operations/expected/lir_00_unoptimized.txt +47 -0
- data/golden/array_operations/expected/lir_01_hoist_scalar_references.txt +47 -0
- data/golden/array_operations/expected/lir_02_inlined.txt +47 -0
- data/golden/array_operations/expected/lir_03_cse.txt +47 -0
- data/golden/array_operations/expected/lir_04_1_loop_fusion.txt +47 -0
- data/golden/array_operations/expected/lir_04_loop_invcm.txt +47 -0
- data/golden/array_operations/expected/lir_06_const_prop.txt +47 -0
- data/golden/array_operations/expected/nast.txt +32 -0
- data/golden/array_operations/expected/schema_javascript.mjs +60 -0
- data/golden/array_operations/expected/schema_ruby.rb +91 -0
- data/golden/array_operations/expected/snast.txt +32 -0
- data/golden/array_operations/expected.json +27 -0
- data/golden/array_operations/input.json +8 -0
- data/golden/array_operations/schema.kumi +12 -10
- data/golden/cascade_logic/expected/ast.txt +37 -0
- data/golden/cascade_logic/expected/input_plan.txt +2 -0
- data/golden/cascade_logic/expected/lir_00_unoptimized.txt +29 -0
- data/golden/cascade_logic/expected/lir_01_hoist_scalar_references.txt +29 -0
- data/golden/cascade_logic/expected/lir_02_inlined.txt +37 -0
- data/golden/cascade_logic/expected/lir_03_cse.txt +30 -0
- data/golden/cascade_logic/expected/lir_04_1_loop_fusion.txt +30 -0
- data/golden/cascade_logic/expected/lir_04_loop_invcm.txt +30 -0
- data/golden/cascade_logic/expected/lir_06_const_prop.txt +30 -0
- data/golden/cascade_logic/expected/nast.txt +32 -0
- data/golden/cascade_logic/expected/schema_javascript.mjs +31 -0
- data/golden/cascade_logic/expected/schema_ruby.rb +57 -0
- data/golden/cascade_logic/expected/snast.txt +32 -0
- data/golden/cascade_logic/expected.json +5 -0
- data/golden/cascade_logic/input.json +4 -0
- data/golden/cascade_logic/schema.kumi +1 -3
- data/golden/chained_fusion/expected/ast.txt +57 -0
- data/golden/chained_fusion/expected/input_plan.txt +13 -0
- data/golden/chained_fusion/expected/lir_00_unoptimized.txt +76 -0
- data/golden/chained_fusion/expected/lir_01_hoist_scalar_references.txt +76 -0
- data/golden/chained_fusion/expected/lir_02_inlined.txt +114 -0
- data/golden/chained_fusion/expected/lir_03_cse.txt +97 -0
- data/golden/chained_fusion/expected/lir_04_1_loop_fusion.txt +99 -0
- data/golden/chained_fusion/expected/lir_04_loop_invcm.txt +97 -0
- data/golden/chained_fusion/expected/lir_06_const_prop.txt +97 -0
- data/golden/chained_fusion/expected/nast.txt +55 -0
- data/golden/chained_fusion/expected/schema_javascript.mjs +116 -0
- data/golden/chained_fusion/expected/schema_ruby.rb +149 -0
- data/golden/chained_fusion/expected/snast.txt +55 -0
- data/golden/chained_fusion/expected.json +45 -0
- data/golden/chained_fusion/input.json +51 -0
- data/golden/chained_fusion/schema.kumi +52 -0
- data/golden/element_arrays/expected/ast.txt +55 -0
- data/golden/element_arrays/expected/input_plan.txt +7 -0
- data/golden/element_arrays/expected/lir_00_unoptimized.txt +81 -0
- data/golden/element_arrays/expected/lir_01_hoist_scalar_references.txt +81 -0
- data/golden/element_arrays/expected/lir_02_inlined.txt +85 -0
- data/golden/element_arrays/expected/lir_03_cse.txt +83 -0
- data/golden/element_arrays/expected/lir_04_1_loop_fusion.txt +83 -0
- data/golden/element_arrays/expected/lir_04_loop_invcm.txt +83 -0
- data/golden/element_arrays/expected/lir_06_const_prop.txt +83 -0
- data/golden/element_arrays/expected/nast.txt +42 -0
- data/golden/element_arrays/expected/schema_javascript.mjs +106 -0
- data/golden/element_arrays/expected/schema_ruby.rb +141 -0
- data/golden/element_arrays/expected/snast.txt +42 -0
- data/golden/element_arrays/expected.json +55 -0
- data/golden/element_arrays/input.json +12 -0
- data/golden/element_arrays/schema.kumi +21 -0
- data/golden/empty_and_null_inputs/expected/ast.txt +42 -0
- data/golden/empty_and_null_inputs/expected/input_plan.txt +12 -0
- data/golden/empty_and_null_inputs/expected/lir_00_unoptimized.txt +31 -0
- data/golden/empty_and_null_inputs/expected/lir_01_hoist_scalar_references.txt +31 -0
- data/golden/empty_and_null_inputs/expected/lir_02_inlined.txt +51 -0
- data/golden/empty_and_null_inputs/expected/lir_03_cse.txt +49 -0
- data/golden/empty_and_null_inputs/expected/lir_04_1_loop_fusion.txt +49 -0
- data/golden/empty_and_null_inputs/expected/lir_04_loop_invcm.txt +49 -0
- data/golden/empty_and_null_inputs/expected/lir_06_const_prop.txt +49 -0
- data/golden/empty_and_null_inputs/expected/nast.txt +18 -0
- data/golden/empty_and_null_inputs/expected/schema_javascript.mjs +47 -0
- data/golden/empty_and_null_inputs/expected/schema_ruby.rb +79 -0
- data/golden/empty_and_null_inputs/expected/snast.txt +18 -0
- data/golden/empty_and_null_inputs/expected.json +8 -0
- data/golden/empty_and_null_inputs/input.json +16 -0
- data/golden/empty_and_null_inputs/schema.kumi +30 -0
- data/golden/game_of_life/expected/ast.txt +118 -0
- data/golden/game_of_life/expected/input_plan.txt +5 -0
- data/golden/game_of_life/expected/lir_00_unoptimized.txt +343 -0
- data/golden/game_of_life/expected/lir_01_hoist_scalar_references.txt +343 -0
- data/golden/game_of_life/expected/lir_02_inlined.txt +1918 -0
- data/golden/game_of_life/expected/lir_03_cse.txt +766 -0
- data/golden/game_of_life/expected/lir_04_1_loop_fusion.txt +766 -0
- data/golden/game_of_life/expected/lir_04_loop_invcm.txt +766 -0
- data/golden/game_of_life/expected/lir_06_const_prop.txt +766 -0
- data/golden/game_of_life/expected/nast.txt +104 -0
- data/golden/game_of_life/expected/schema_javascript.mjs +98 -0
- data/golden/game_of_life/expected/schema_ruby.rb +125 -0
- data/golden/game_of_life/expected/snast.txt +104 -0
- data/golden/game_of_life/expected.json +3 -0
- data/golden/game_of_life/input.json +8 -0
- data/golden/game_of_life/schema.kumi +33 -0
- data/golden/hash_keys/expected/ast.txt +29 -0
- data/golden/hash_keys/expected/input_plan.txt +2 -0
- data/golden/hash_keys/expected/lir_00_unoptimized.txt +18 -0
- data/golden/hash_keys/expected/lir_01_hoist_scalar_references.txt +18 -0
- data/golden/hash_keys/expected/lir_02_inlined.txt +18 -0
- data/golden/hash_keys/expected/lir_03_cse.txt +18 -0
- data/golden/hash_keys/expected/lir_04_1_loop_fusion.txt +18 -0
- data/golden/hash_keys/expected/lir_04_loop_invcm.txt +18 -0
- data/golden/hash_keys/expected/lir_06_const_prop.txt +18 -0
- data/golden/hash_keys/expected/nast.txt +46 -0
- data/golden/hash_keys/expected/schema_javascript.mjs +34 -0
- data/golden/hash_keys/expected/schema_ruby.rb +61 -0
- data/golden/hash_keys/expected/snast.txt +46 -0
- data/golden/hash_keys/expected.json +20 -0
- data/golden/hash_keys/input.json +4 -0
- data/golden/hash_keys/schema.kumi +14 -0
- data/golden/hash_value/expected/ast.txt +37 -0
- data/golden/hash_value/expected/input_plan.txt +7 -0
- data/golden/hash_value/expected/lir_00_unoptimized.txt +30 -0
- data/golden/hash_value/expected/lir_01_hoist_scalar_references.txt +30 -0
- data/golden/hash_value/expected/lir_02_inlined.txt +36 -0
- data/golden/hash_value/expected/lir_03_cse.txt +33 -0
- data/golden/hash_value/expected/lir_04_1_loop_fusion.txt +33 -0
- data/golden/hash_value/expected/lir_04_loop_invcm.txt +33 -0
- data/golden/hash_value/expected/lir_06_const_prop.txt +33 -0
- data/golden/hash_value/expected/nast.txt +25 -0
- data/golden/hash_value/expected/schema_javascript.mjs +46 -0
- data/golden/hash_value/expected/schema_ruby.rb +75 -0
- data/golden/hash_value/expected/snast.txt +25 -0
- data/golden/hash_value/expected.json +19 -0
- data/golden/hash_value/input.json +12 -0
- data/golden/hash_value/schema.kumi +19 -0
- data/golden/hierarchical_complex/expected/ast.txt +85 -0
- data/golden/hierarchical_complex/expected/input_plan.txt +23 -0
- data/golden/hierarchical_complex/expected/lir_00_unoptimized.txt +87 -0
- data/golden/hierarchical_complex/expected/lir_01_hoist_scalar_references.txt +87 -0
- data/golden/hierarchical_complex/expected/lir_02_inlined.txt +115 -0
- data/golden/hierarchical_complex/expected/lir_03_cse.txt +89 -0
- data/golden/hierarchical_complex/expected/lir_04_1_loop_fusion.txt +89 -0
- data/golden/hierarchical_complex/expected/lir_04_loop_invcm.txt +89 -0
- data/golden/hierarchical_complex/expected/lir_06_const_prop.txt +89 -0
- data/golden/hierarchical_complex/expected/nast.txt +49 -0
- data/golden/hierarchical_complex/expected/schema_javascript.mjs +121 -0
- data/golden/hierarchical_complex/expected/schema_ruby.rb +151 -0
- data/golden/hierarchical_complex/expected/snast.txt +49 -0
- data/golden/hierarchical_complex/expected.json +34 -0
- data/golden/hierarchical_complex/input.json +26 -0
- data/golden/hierarchical_complex/schema.kumi +38 -0
- data/golden/input_reference/expected/ast.txt +46 -0
- data/golden/input_reference/expected/input_plan.txt +15 -0
- data/golden/input_reference/expected/lir_00_unoptimized.txt +39 -0
- data/golden/input_reference/expected/lir_01_hoist_scalar_references.txt +39 -0
- data/golden/input_reference/expected/lir_02_inlined.txt +39 -0
- data/golden/input_reference/expected/lir_03_cse.txt +39 -0
- data/golden/input_reference/expected/lir_04_1_loop_fusion.txt +39 -0
- data/golden/input_reference/expected/lir_04_loop_invcm.txt +39 -0
- data/golden/input_reference/expected/lir_06_const_prop.txt +39 -0
- data/golden/input_reference/expected/nast.txt +21 -0
- data/golden/input_reference/expected/schema_javascript.mjs +45 -0
- data/golden/input_reference/expected/schema_ruby.rb +74 -0
- data/golden/input_reference/expected/snast.txt +21 -0
- data/golden/input_reference/expected.json +7 -0
- data/golden/input_reference/input.json +11 -0
- data/golden/input_reference/schema.kumi +22 -0
- data/golden/interleaved_fusion/expected/ast.txt +51 -0
- data/golden/interleaved_fusion/expected/input_plan.txt +13 -0
- data/golden/interleaved_fusion/expected/lir_00_unoptimized.txt +53 -0
- data/golden/interleaved_fusion/expected/lir_01_hoist_scalar_references.txt +53 -0
- data/golden/interleaved_fusion/expected/lir_02_inlined.txt +89 -0
- data/golden/interleaved_fusion/expected/lir_03_cse.txt +77 -0
- data/golden/interleaved_fusion/expected/lir_04_1_loop_fusion.txt +77 -0
- data/golden/interleaved_fusion/expected/lir_04_loop_invcm.txt +77 -0
- data/golden/interleaved_fusion/expected/lir_06_const_prop.txt +77 -0
- data/golden/interleaved_fusion/expected/nast.txt +41 -0
- data/golden/interleaved_fusion/expected/schema_javascript.mjs +86 -0
- data/golden/interleaved_fusion/expected/schema_ruby.rb +122 -0
- data/golden/interleaved_fusion/expected/snast.txt +41 -0
- data/golden/interleaved_fusion/expected.json +37 -0
- data/golden/interleaved_fusion/input.json +26 -0
- data/golden/interleaved_fusion/schema.kumi +57 -0
- data/golden/let_inline/expected/ast.txt +33 -0
- data/golden/let_inline/expected/input_plan.txt +2 -0
- data/golden/let_inline/expected/lir_00_unoptimized.txt +26 -0
- data/golden/let_inline/expected/lir_01_hoist_scalar_references.txt +26 -0
- data/golden/let_inline/expected/lir_02_inlined.txt +36 -0
- data/golden/let_inline/expected/lir_03_cse.txt +30 -0
- data/golden/let_inline/expected/lir_04_1_loop_fusion.txt +30 -0
- data/golden/let_inline/expected/lir_04_loop_invcm.txt +30 -0
- data/golden/let_inline/expected/lir_06_const_prop.txt +30 -0
- data/golden/let_inline/expected/nast.txt +26 -0
- data/golden/let_inline/expected/schema_javascript.mjs +11 -0
- data/golden/let_inline/expected/schema_ruby.rb +37 -0
- data/golden/let_inline/expected/snast.txt +26 -0
- data/golden/let_inline/expected.json +1 -0
- data/golden/let_inline/input.json +1 -0
- data/golden/let_inline/schema.kumi +11 -0
- data/golden/loop_fusion/expected/ast.txt +44 -0
- data/golden/loop_fusion/expected/input_plan.txt +13 -0
- data/golden/loop_fusion/expected/lir_00_unoptimized.txt +43 -0
- data/golden/loop_fusion/expected/lir_01_hoist_scalar_references.txt +43 -0
- data/golden/loop_fusion/expected/lir_02_inlined.txt +62 -0
- data/golden/loop_fusion/expected/lir_03_cse.txt +57 -0
- data/golden/loop_fusion/expected/lir_04_1_loop_fusion.txt +57 -0
- data/golden/loop_fusion/expected/lir_04_loop_invcm.txt +57 -0
- data/golden/loop_fusion/expected/lir_06_const_prop.txt +57 -0
- data/golden/loop_fusion/expected/nast.txt +32 -0
- data/golden/loop_fusion/expected/schema_javascript.mjs +64 -0
- data/golden/loop_fusion/expected/schema_ruby.rb +97 -0
- data/golden/loop_fusion/expected/snast.txt +32 -0
- data/golden/loop_fusion/expected.json +30 -0
- data/golden/loop_fusion/input.json +28 -0
- data/golden/loop_fusion/schema.kumi +32 -0
- data/golden/min_reduce_scope/expected/ast.txt +49 -0
- data/golden/min_reduce_scope/expected/input_plan.txt +9 -0
- data/golden/min_reduce_scope/expected/lir_00_unoptimized.txt +59 -0
- data/golden/min_reduce_scope/expected/lir_01_hoist_scalar_references.txt +59 -0
- data/golden/min_reduce_scope/expected/lir_02_inlined.txt +63 -0
- data/golden/min_reduce_scope/expected/lir_03_cse.txt +60 -0
- data/golden/min_reduce_scope/expected/lir_04_1_loop_fusion.txt +60 -0
- data/golden/min_reduce_scope/expected/lir_04_loop_invcm.txt +60 -0
- data/golden/min_reduce_scope/expected/lir_06_const_prop.txt +60 -0
- data/golden/min_reduce_scope/expected/nast.txt +29 -0
- data/golden/min_reduce_scope/expected/schema_javascript.mjs +66 -0
- data/golden/min_reduce_scope/expected/schema_ruby.rb +99 -0
- data/golden/min_reduce_scope/expected/snast.txt +29 -0
- data/golden/min_reduce_scope/expected.json +9 -0
- data/golden/min_reduce_scope/input.json +18 -0
- data/golden/min_reduce_scope/schema.kumi +25 -0
- data/golden/mixed_dimensions/expected/ast.txt +54 -0
- data/golden/mixed_dimensions/expected/input_plan.txt +15 -0
- data/golden/mixed_dimensions/expected/lir_00_unoptimized.txt +42 -0
- data/golden/mixed_dimensions/expected/lir_01_hoist_scalar_references.txt +42 -0
- data/golden/mixed_dimensions/expected/lir_02_inlined.txt +48 -0
- data/golden/mixed_dimensions/expected/lir_03_cse.txt +48 -0
- data/golden/mixed_dimensions/expected/lir_04_1_loop_fusion.txt +48 -0
- data/golden/mixed_dimensions/expected/lir_04_loop_invcm.txt +48 -0
- data/golden/mixed_dimensions/expected/lir_06_const_prop.txt +48 -0
- data/golden/mixed_dimensions/expected/nast.txt +22 -0
- data/golden/mixed_dimensions/expected/schema_javascript.mjs +53 -0
- data/golden/mixed_dimensions/expected/schema_ruby.rb +84 -0
- data/golden/mixed_dimensions/expected/snast.txt +22 -0
- data/golden/mixed_dimensions/expected.json +6 -0
- data/golden/mixed_dimensions/input.json +22 -0
- data/golden/mixed_dimensions/schema.kumi +35 -0
- data/golden/multirank_hoisting/expected/ast.txt +72 -0
- data/golden/multirank_hoisting/expected/input_plan.txt +18 -0
- data/golden/multirank_hoisting/expected/lir_00_unoptimized.txt +75 -0
- data/golden/multirank_hoisting/expected/lir_01_hoist_scalar_references.txt +75 -0
- data/golden/multirank_hoisting/expected/lir_02_inlined.txt +126 -0
- data/golden/multirank_hoisting/expected/lir_03_cse.txt +109 -0
- data/golden/multirank_hoisting/expected/lir_04_1_loop_fusion.txt +109 -0
- data/golden/multirank_hoisting/expected/lir_04_loop_invcm.txt +109 -0
- data/golden/multirank_hoisting/expected/lir_06_const_prop.txt +109 -0
- data/golden/multirank_hoisting/expected/nast.txt +39 -0
- data/golden/multirank_hoisting/expected/schema_javascript.mjs +128 -0
- data/golden/multirank_hoisting/expected/schema_ruby.rb +162 -0
- data/golden/multirank_hoisting/expected/snast.txt +39 -0
- data/golden/multirank_hoisting/expected.json +15 -0
- data/golden/multirank_hoisting/input.json +19 -0
- data/golden/multirank_hoisting/schema.kumi +38 -0
- data/golden/nested_hash/expected/ast.txt +22 -0
- data/golden/nested_hash/expected/input_plan.txt +5 -0
- data/golden/nested_hash/expected/lir_00_unoptimized.txt +10 -0
- data/golden/nested_hash/expected/lir_01_hoist_scalar_references.txt +10 -0
- data/golden/nested_hash/expected/lir_02_inlined.txt +10 -0
- data/golden/nested_hash/expected/lir_03_cse.txt +10 -0
- data/golden/nested_hash/expected/lir_04_1_loop_fusion.txt +10 -0
- data/golden/nested_hash/expected/lir_04_loop_invcm.txt +10 -0
- data/golden/nested_hash/expected/lir_06_const_prop.txt +10 -0
- data/golden/nested_hash/expected/nast.txt +8 -0
- data/golden/nested_hash/expected/schema_javascript.mjs +9 -0
- data/golden/nested_hash/expected/schema_ruby.rb +35 -0
- data/golden/nested_hash/expected/snast.txt +8 -0
- data/golden/nested_hash/expected.json +3 -0
- data/golden/nested_hash/input.json +7 -0
- data/golden/nested_hash/schema.kumi +11 -0
- data/golden/reduction_broadcast/expected/ast.txt +49 -0
- data/golden/reduction_broadcast/expected/input_plan.txt +13 -0
- data/golden/reduction_broadcast/expected/lir_00_unoptimized.txt +49 -0
- data/golden/reduction_broadcast/expected/lir_01_hoist_scalar_references.txt +49 -0
- data/golden/reduction_broadcast/expected/lir_02_inlined.txt +80 -0
- data/golden/reduction_broadcast/expected/lir_03_cse.txt +68 -0
- data/golden/reduction_broadcast/expected/lir_04_1_loop_fusion.txt +68 -0
- data/golden/reduction_broadcast/expected/lir_04_loop_invcm.txt +68 -0
- data/golden/reduction_broadcast/expected/lir_06_const_prop.txt +68 -0
- data/golden/reduction_broadcast/expected/nast.txt +24 -0
- data/golden/reduction_broadcast/expected/schema_javascript.mjs +74 -0
- data/golden/reduction_broadcast/expected/schema_ruby.rb +110 -0
- data/golden/reduction_broadcast/expected/snast.txt +24 -0
- data/golden/reduction_broadcast/expected.json +25 -0
- data/golden/reduction_broadcast/input.json +19 -0
- data/golden/reduction_broadcast/schema.kumi +34 -0
- data/golden/roll/expected/ast.txt +36 -0
- data/golden/roll/expected/input_plan.txt +3 -0
- data/golden/roll/expected/lir_00_unoptimized.txt +56 -0
- data/golden/roll/expected/lir_01_hoist_scalar_references.txt +56 -0
- data/golden/roll/expected/lir_02_inlined.txt +56 -0
- data/golden/roll/expected/lir_03_cse.txt +55 -0
- data/golden/roll/expected/lir_04_1_loop_fusion.txt +55 -0
- data/golden/roll/expected/lir_04_loop_invcm.txt +55 -0
- data/golden/roll/expected/lir_06_const_prop.txt +55 -0
- data/golden/roll/expected/nast.txt +26 -0
- data/golden/roll/expected/schema_javascript.mjs +65 -0
- data/golden/roll/expected/schema_ruby.rb +95 -0
- data/golden/roll/expected/snast.txt +26 -0
- data/golden/roll/expected.json +6 -0
- data/golden/roll/input.json +1 -0
- data/golden/roll/schema.kumi +13 -0
- data/golden/shift/expected/ast.txt +48 -0
- data/golden/shift/expected/input_plan.txt +3 -0
- data/golden/shift/expected/lir_00_unoptimized.txt +96 -0
- data/golden/shift/expected/lir_01_hoist_scalar_references.txt +96 -0
- data/golden/shift/expected/lir_02_inlined.txt +96 -0
- data/golden/shift/expected/lir_03_cse.txt +90 -0
- data/golden/shift/expected/lir_04_1_loop_fusion.txt +90 -0
- data/golden/shift/expected/lir_04_loop_invcm.txt +90 -0
- data/golden/shift/expected/lir_06_const_prop.txt +90 -0
- data/golden/shift/expected/nast.txt +38 -0
- data/golden/shift/expected/schema_javascript.mjs +106 -0
- data/golden/shift/expected/schema_ruby.rb +138 -0
- data/golden/shift/expected/snast.txt +38 -0
- data/golden/shift/expected.json +8 -0
- data/golden/shift/input.json +1 -0
- data/golden/shift/schema.kumi +15 -0
- data/golden/shift_2d/expected/ast.txt +88 -0
- data/golden/shift_2d/expected/input_plan.txt +5 -0
- data/golden/shift_2d/expected/lir_00_unoptimized.txt +274 -0
- data/golden/shift_2d/expected/lir_01_hoist_scalar_references.txt +274 -0
- data/golden/shift_2d/expected/lir_02_inlined.txt +274 -0
- data/golden/shift_2d/expected/lir_03_cse.txt +262 -0
- data/golden/shift_2d/expected/lir_04_1_loop_fusion.txt +262 -0
- data/golden/shift_2d/expected/lir_04_loop_invcm.txt +262 -0
- data/golden/shift_2d/expected/lir_06_const_prop.txt +262 -0
- data/golden/shift_2d/expected/nast.txt +74 -0
- data/golden/shift_2d/expected/schema_javascript.mjs +320 -0
- data/golden/shift_2d/expected/schema_ruby.rb +358 -0
- data/golden/shift_2d/expected/snast.txt +74 -0
- data/golden/shift_2d/expected.json +15 -0
- data/golden/shift_2d/input.json +14 -0
- data/golden/shift_2d/schema.kumi +25 -0
- data/golden/simple_math/expected/ast.txt +40 -0
- data/golden/simple_math/expected/input_plan.txt +2 -0
- data/golden/simple_math/expected/lir_00_unoptimized.txt +31 -0
- data/golden/simple_math/expected/lir_01_hoist_scalar_references.txt +31 -0
- data/golden/simple_math/expected/lir_02_inlined.txt +31 -0
- data/golden/simple_math/expected/lir_03_cse.txt +31 -0
- data/golden/simple_math/expected/lir_04_1_loop_fusion.txt +31 -0
- data/golden/simple_math/expected/lir_04_loop_invcm.txt +31 -0
- data/golden/simple_math/expected/lir_06_const_prop.txt +31 -0
- data/golden/simple_math/expected/nast.txt +33 -0
- data/golden/simple_math/expected/schema_javascript.mjs +33 -0
- data/golden/simple_math/expected/schema_ruby.rb +59 -0
- data/golden/simple_math/expected/snast.txt +33 -0
- data/golden/simple_math/expected.json +1 -0
- data/golden/simple_math/input.json +4 -0
- data/golden/simple_math/schema.kumi +2 -1
- data/golden/streaming_basics/expected/ast.txt +64 -0
- data/golden/streaming_basics/expected/input_plan.txt +8 -0
- data/golden/streaming_basics/expected/lir_00_unoptimized.txt +73 -0
- data/golden/streaming_basics/expected/lir_01_hoist_scalar_references.txt +73 -0
- data/golden/streaming_basics/expected/lir_02_inlined.txt +100 -0
- data/golden/streaming_basics/expected/lir_03_cse.txt +84 -0
- data/golden/streaming_basics/expected/lir_04_1_loop_fusion.txt +84 -0
- data/golden/streaming_basics/expected/lir_04_loop_invcm.txt +84 -0
- data/golden/streaming_basics/expected/lir_06_const_prop.txt +84 -0
- data/golden/streaming_basics/expected/nast.txt +48 -0
- data/golden/streaming_basics/expected/schema_javascript.mjs +94 -0
- data/golden/streaming_basics/expected/schema_ruby.rb +127 -0
- data/golden/streaming_basics/expected/snast.txt +48 -0
- data/golden/streaming_basics/expected.json +10 -0
- data/golden/streaming_basics/input.json +8 -0
- data/golden/streaming_basics/schema.kumi +24 -0
- data/golden/tuples/expected/ast.txt +48 -0
- data/golden/tuples/expected/input_plan.txt +1 -0
- data/golden/tuples/expected/lir_00_unoptimized.txt +40 -0
- data/golden/tuples/expected/lir_01_hoist_scalar_references.txt +40 -0
- data/golden/tuples/expected/lir_02_inlined.txt +48 -0
- data/golden/tuples/expected/lir_03_cse.txt +48 -0
- data/golden/tuples/expected/lir_04_1_loop_fusion.txt +48 -0
- data/golden/tuples/expected/lir_04_loop_invcm.txt +48 -0
- data/golden/tuples/expected/lir_06_const_prop.txt +48 -0
- data/golden/tuples/expected/nast.txt +42 -0
- data/golden/tuples/expected/schema_javascript.mjs +51 -0
- data/golden/tuples/expected/schema_ruby.rb +77 -0
- data/golden/tuples/expected/snast.txt +42 -0
- data/golden/tuples/expected.json +7 -0
- data/golden/tuples/input.json +3 -0
- data/golden/tuples/schema.kumi +11 -0
- data/golden/tuples_and_arrays/expected/ast.txt +44 -0
- data/golden/tuples_and_arrays/expected/input_plan.txt +7 -0
- data/golden/tuples_and_arrays/expected/lir_00_unoptimized.txt +41 -0
- data/golden/tuples_and_arrays/expected/lir_01_hoist_scalar_references.txt +41 -0
- data/golden/tuples_and_arrays/expected/lir_02_inlined.txt +62 -0
- data/golden/tuples_and_arrays/expected/lir_03_cse.txt +51 -0
- data/golden/tuples_and_arrays/expected/lir_04_1_loop_fusion.txt +51 -0
- data/golden/tuples_and_arrays/expected/lir_04_loop_invcm.txt +51 -0
- data/golden/tuples_and_arrays/expected/lir_06_const_prop.txt +51 -0
- data/golden/tuples_and_arrays/expected/nast.txt +28 -0
- data/golden/tuples_and_arrays/expected/schema_javascript.mjs +58 -0
- data/golden/tuples_and_arrays/expected/schema_ruby.rb +88 -0
- data/golden/tuples_and_arrays/expected/snast.txt +28 -0
- data/golden/tuples_and_arrays/expected.json +18 -0
- data/golden/tuples_and_arrays/input.json +7 -0
- data/golden/tuples_and_arrays/schema.kumi +38 -0
- data/golden/with_constants/expected/ast.txt +28 -0
- data/golden/with_constants/expected/input_plan.txt +2 -0
- data/golden/with_constants/expected/lir_00_unoptimized.txt +17 -0
- data/golden/with_constants/expected/lir_01_hoist_scalar_references.txt +17 -0
- data/golden/with_constants/expected/lir_02_inlined.txt +17 -0
- data/golden/with_constants/expected/lir_03_cse.txt +17 -0
- data/golden/with_constants/expected/lir_04_1_loop_fusion.txt +17 -0
- data/golden/with_constants/expected/lir_04_loop_invcm.txt +17 -0
- data/golden/with_constants/expected/lir_06_const_prop.txt +17 -0
- data/golden/with_constants/expected/nast.txt +21 -0
- data/golden/with_constants/expected/schema_javascript.mjs +18 -0
- data/golden/with_constants/expected/schema_ruby.rb +44 -0
- data/golden/with_constants/expected/snast.txt +15 -0
- data/golden/with_constants/schema.kumi +10 -0
- data/lib/kumi/analyzer.rb +76 -24
- data/lib/kumi/configuration.rb +60 -0
- data/lib/kumi/core/analyzer/binder.rb +121 -0
- data/lib/kumi/core/analyzer/checkpoint.rb +15 -9
- data/lib/kumi/core/analyzer/constant_evaluator.rb +32 -37
- data/lib/kumi/core/analyzer/constant_folding_helpers.rb +55 -0
- data/lib/kumi/core/analyzer/debug.rb +14 -16
- data/lib/kumi/core/analyzer/fn_aliases.rb +46 -0
- data/lib/kumi/core/analyzer/folder.rb +94 -0
- data/lib/kumi/core/analyzer/macro_expander.rb +69 -0
- data/lib/kumi/core/analyzer/passes/assemble_irv2_pass.rb +130 -0
- data/lib/kumi/core/analyzer/passes/attach_anchors_pass.rb +71 -0
- data/lib/kumi/core/analyzer/passes/attach_terminal_info_pass.rb +181 -0
- data/lib/kumi/core/analyzer/passes/codegen/js/declaration_emitter.rb +317 -0
- data/lib/kumi/core/analyzer/passes/codegen/js/emitter.rb +75 -0
- data/lib/kumi/core/analyzer/passes/codegen/js/output_buffer.rb +103 -0
- data/lib/kumi/core/analyzer/passes/codegen/js_pass.rb +27 -0
- data/lib/kumi/core/analyzer/passes/codegen/ruby/declaration_emitter.rb +321 -0
- data/lib/kumi/core/analyzer/passes/codegen/ruby/emitter.rb +85 -0
- data/lib/kumi/core/analyzer/passes/codegen/ruby/output_buffer.rb +111 -0
- data/lib/kumi/core/analyzer/passes/codegen/ruby_pass.rb +32 -0
- data/lib/kumi/core/analyzer/passes/constant_folding_pass.rb +33 -0
- data/lib/kumi/core/analyzer/passes/contract_checker_pass.rb +220 -0
- data/lib/kumi/core/analyzer/passes/dependency_resolver.rb +5 -6
- data/lib/kumi/core/analyzer/passes/input_access_planner_pass.rb +7 -3
- data/lib/kumi/core/analyzer/passes/input_collector.rb +74 -122
- data/lib/kumi/core/analyzer/passes/input_form_schema_pass.rb +43 -0
- data/lib/kumi/core/analyzer/passes/ir_dependency_pass.rb +1 -1
- data/lib/kumi/core/analyzer/passes/ir_execution_schedule_pass.rb +1 -1
- data/lib/kumi/core/analyzer/passes/join_reduce_planning_pass.rb +21 -23
- data/lib/kumi/core/analyzer/passes/lir/constant_propagation_pass.rb +84 -0
- data/lib/kumi/core/analyzer/passes/lir/dead_code_elimination_pass.rb +93 -0
- data/lib/kumi/core/analyzer/passes/lir/hoist_scalar_references_pass.rb +115 -0
- data/lib/kumi/core/analyzer/passes/lir/inline_declarations_pass.rb +274 -0
- data/lib/kumi/core/analyzer/passes/lir/instruction_scheduling_pass.rb +198 -0
- data/lib/kumi/core/analyzer/passes/lir/kernel_binding_pass.rb +30 -0
- data/lib/kumi/core/analyzer/passes/lir/local_cse_pass.rb +121 -0
- data/lib/kumi/core/analyzer/passes/lir/loop_fusion_pass.rb +156 -0
- data/lib/kumi/core/analyzer/passes/lir/loop_invariant_code_motion_pass.rb +148 -0
- data/lib/kumi/core/analyzer/passes/lir/lower_pass.rb +407 -0
- data/lib/kumi/core/analyzer/passes/lir/stencil_emitter.rb +243 -0
- data/lib/kumi/core/analyzer/passes/lir/validation_pass.rb +83 -0
- data/lib/kumi/core/analyzer/passes/load_input_cse.rb +17 -16
- data/lib/kumi/core/analyzer/passes/lower_to_ir_pass.rb +4 -2
- data/lib/kumi/core/analyzer/passes/lower_to_irv2_pass.rb +197 -0
- data/lib/kumi/core/analyzer/passes/name_indexer.rb +4 -1
- data/lib/kumi/core/analyzer/passes/nast_dimensional_analyzer_pass.rb +237 -0
- data/lib/kumi/core/analyzer/passes/normalize_to_nast_pass.rb +156 -0
- data/lib/kumi/core/analyzer/passes/output_schema_pass.rb +38 -0
- data/lib/kumi/core/analyzer/passes/pass_base.rb +30 -4
- data/lib/kumi/core/analyzer/passes/precompute_access_paths_pass.rb +93 -0
- data/lib/kumi/core/analyzer/passes/scope_resolution_pass.rb +33 -30
- data/lib/kumi/core/analyzer/passes/semantic_constraint_validator.rb +5 -26
- data/lib/kumi/core/analyzer/passes/snast_pass.rb +229 -0
- data/lib/kumi/core/analyzer/passes/toposorter.rb +1 -0
- data/lib/kumi/core/analyzer/passes/type_checker.rb +13 -0
- data/lib/kumi/core/analyzer/passes/type_inferencer_pass.rb +14 -16
- data/lib/kumi/core/analyzer/passes/unsat_detector.rb +2 -1
- data/lib/kumi/core/analyzer/plans.rb +12 -0
- data/lib/kumi/core/analyzer/state_serde.rb +4 -4
- data/lib/kumi/core/analyzer/structs/access_plan.rb +2 -2
- data/lib/kumi/core/analyzer/unsat_constant_evaluator.rb +59 -0
- data/lib/kumi/core/compiler/access_codegen.rb +1 -1
- data/lib/kumi/core/compiler/access_emit/base.rb +9 -5
- data/lib/kumi/core/compiler/access_emit/each_indexed.rb +10 -3
- data/lib/kumi/core/compiler/access_emit/materialize.rb +12 -5
- data/lib/kumi/core/compiler/access_emit/ravel.rb +10 -3
- data/lib/kumi/core/compiler/access_emit/read.rb +4 -1
- data/lib/kumi/core/compiler/access_planner.rb +42 -4
- data/lib/kumi/core/compiler/access_planner_v2.rb +164 -0
- data/lib/kumi/core/explain.rb +18 -11
- data/lib/kumi/core/functions/loader.rb +47 -0
- data/lib/kumi/core/functions/model.rb +10 -0
- data/lib/kumi/core/functions/type_rules.rb +108 -0
- data/lib/kumi/core/ir/execution_engine/interpreter.rb +1 -1
- data/lib/kumi/core/ir/execution_engine/profiler.rb +107 -97
- data/lib/kumi/core/ir.rb +6 -2
- data/lib/kumi/core/irv2/builder.rb +48 -0
- data/lib/kumi/core/irv2/declaration.rb +28 -0
- data/lib/kumi/core/irv2/module.rb +108 -0
- data/lib/kumi/core/irv2/value.rb +28 -0
- data/lib/kumi/core/lir/analyze.rb +64 -0
- data/lib/kumi/core/lir/build.rb +363 -0
- data/lib/kumi/core/lir/emit.rb +62 -0
- data/lib/kumi/core/lir/structs/instruction.rb +44 -0
- data/lib/kumi/core/lir/structs/literal.rb +14 -0
- data/lib/kumi/core/lir/structs/stamp.rb +13 -0
- data/lib/kumi/core/lir/support/error.rb +9 -0
- data/lib/kumi/core/lir/support/ids.rb +34 -0
- data/lib/kumi/core/lir/validate.rb +74 -0
- data/lib/kumi/core/lir.rb +34 -0
- data/lib/kumi/core/nast.rb +216 -0
- data/lib/kumi/core/ruby_parser/dsl.rb +2 -2
- data/lib/kumi/core/ruby_parser/dsl_cascade_builder.rb +1 -1
- data/lib/kumi/core/ruby_parser/expression_converter.rb +10 -0
- data/lib/kumi/core/ruby_parser/input_builder.rb +16 -17
- data/lib/kumi/core/ruby_parser/schema_builder.rb +36 -10
- data/lib/kumi/core/ruby_parser/sugar.rb +64 -0
- data/lib/kumi/core/types/builder.rb +2 -2
- data/lib/kumi/core/types/normalizer.rb +2 -0
- data/lib/kumi/core/types/validator.rb +10 -3
- data/lib/kumi/core/types.rb +7 -0
- data/lib/kumi/dev/codegen.rb +194 -0
- data/lib/kumi/dev/golden/generator.rb +105 -0
- data/lib/kumi/dev/golden/reporter.rb +160 -0
- data/lib/kumi/dev/golden/representation.rb +45 -0
- data/lib/kumi/dev/golden/result.rb +98 -0
- data/lib/kumi/dev/golden/runtime_test.rb +93 -0
- data/lib/kumi/dev/golden/suite.rb +131 -0
- data/lib/kumi/dev/golden/verifier.rb +76 -0
- data/lib/kumi/dev/golden.rb +75 -0
- data/lib/kumi/dev/ir.rb +4 -4
- data/lib/kumi/dev/parse.rb +1 -1
- data/lib/kumi/dev/pretty_printer.rb +229 -0
- data/lib/kumi/dev/printer/irv2_formatter.rb +163 -0
- data/lib/kumi/dev/printer/width_aware_json.rb +44 -0
- data/lib/kumi/dev/profile_aggregator.rb +36 -38
- data/lib/kumi/dev/profile_runner.rb +19 -23
- data/lib/kumi/dev/runner.rb +12 -22
- data/lib/kumi/dev/support/kumi_runner.mjs +39 -0
- data/lib/kumi/dev.rb +3 -3
- data/lib/kumi/frontends/ruby.rb +12 -12
- data/lib/kumi/frontends/text.rb +26 -21
- data/lib/kumi/frontends.rb +6 -8
- data/lib/kumi/kernel_registry.rb +59 -0
- data/lib/kumi/pack/builder.rb +229 -0
- data/lib/kumi/pack.rb +15 -0
- data/lib/kumi/registry_v2/loader.rb +81 -0
- data/lib/kumi/registry_v2.rb +118 -0
- data/lib/kumi/schema.rb +83 -43
- data/lib/kumi/support/diff.rb +3 -2
- data/lib/kumi/support/ir_render.rb +1 -1
- data/lib/kumi/support/lir_printer.rb +143 -0
- data/lib/kumi/support/nast_printer.rb +93 -0
- data/lib/kumi/support/s_expression_printer.rb +5 -4
- data/lib/kumi/support/snast_printer.rb +111 -0
- data/lib/kumi/syntax/call_expression.rb +1 -1
- data/lib/kumi/syntax/input_declaration.rb +2 -2
- data/lib/kumi/syntax/node.rb +4 -12
- data/lib/kumi/syntax/root.rb +10 -0
- data/lib/kumi/syntax/trait_declaration.rb +1 -0
- data/lib/kumi/syntax/value_declaration.rb +1 -0
- data/lib/kumi/version.rb +1 -1
- data/lib/kumi.rb +47 -5
- metadata +571 -54
- data/docs/AST.md +0 -133
- data/docs/DSL.md +0 -154
- data/docs/FUNCTIONS.md +0 -176
- data/docs/VECTOR_SEMANTICS.md +0 -286
- data/docs/compiler_design_principles.md +0 -86
- data/docs/dev/analyzer-debug.md +0 -52
- data/docs/dev/parse-command.md +0 -64
- data/docs/dev/vm-profiling.md +0 -95
- data/docs/development/README.md +0 -120
- data/docs/development/error-reporting.md +0 -361
- data/docs/features/README.md +0 -58
- data/docs/features/analysis-type-inference.md +0 -42
- data/docs/features/analysis-unsat-detection.md +0 -71
- data/docs/features/hierarchical-broadcasting.md +0 -415
- data/docs/features/input-declaration-system.md +0 -58
- data/docs/features/performance.md +0 -14
- data/docs/features/s-expression-printer.md +0 -77
- data/docs/schema_metadata/broadcasts.md +0 -53
- data/docs/schema_metadata/cascades.md +0 -45
- data/docs/schema_metadata/declarations.md +0 -54
- data/docs/schema_metadata/dependencies.md +0 -57
- data/docs/schema_metadata/evaluation_order.md +0 -29
- data/docs/schema_metadata/examples.md +0 -95
- data/docs/schema_metadata/inferred_types.md +0 -46
- data/docs/schema_metadata/inputs.md +0 -86
- data/docs/schema_metadata.md +0 -108
- data/golden/mixed_nesting/schema.kumi +0 -42
- data/lib/kumi/core/function_registry/collection_functions.rb +0 -298
- data/lib/kumi/core/function_registry/comparison_functions.rb +0 -33
- data/lib/kumi/core/function_registry/conditional_functions.rb +0 -48
- data/lib/kumi/core/function_registry/function_builder.rb +0 -184
- data/lib/kumi/core/function_registry/logical_functions.rb +0 -214
- data/lib/kumi/core/function_registry/math_functions.rb +0 -74
- data/lib/kumi/core/function_registry/stat_functions.rb +0 -156
- data/lib/kumi/core/function_registry/string_functions.rb +0 -57
- data/lib/kumi/core/function_registry/type_functions.rb +0 -53
- data/lib/kumi/core/function_registry.rb +0 -176
- data/lib/kumi/registry.rb +0 -32
- data/lib/kumi/runtime/executable.rb +0 -135
- data/lib/kumi/runtime/run.rb +0 -105
- data/performance_results.txt +0 -63
- data/scripts/analyze_broadcast_methods.rb +0 -68
- data/scripts/analyze_cascade_methods.rb +0 -74
- data/scripts/check_broadcasting_coverage.rb +0 -51
- data/scripts/find_dead_code.rb +0 -114
- data/scripts/generate_function_docs.rb +0 -71
- data/scripts/test_mixed_nesting_performance.rb +0 -206
data/docs/VECTOR_SEMANTICS.md
DELETED
@@ -1,286 +0,0 @@
|
|
1
|
-
# Kumi Vector Semantics — Short Guide
|
2
|
-
|
3
|
-
This note documents how Kumi handles **vectorized traversal** over **arbitrary nested objects**, how **alignment/broadcasting** works, and how **reducers** and **structure functions** behave. It’s intentionally concise but hits all the sharp edges.
|
4
|
-
|
5
|
-
---
|
6
|
-
|
7
|
-
## Terminology
|
8
|
-
|
9
|
-
* **Path** – a dot-separated traversal, e.g. `input.regions.offices.employees.salary`.
|
10
|
-
* **Scope (axes)** – the list of array segments encountered along a path.
|
11
|
-
Example: for `regions.offices.employees.salary` the scope is `[:regions, :offices, :employees]`.
|
12
|
-
* **Rank** – number of axes = `scope.length`.
|
13
|
-
* **Index tuple** – lexicographic coordinates per axis, e.g. `[region_i, office_j, employee_k]`.
|
14
|
-
|
15
|
-
**Three Laws (think of them as invariants):**
|
16
|
-
|
17
|
-
1. **Enumeration**
|
18
|
-
`each_indexed(path).map(&:first) == ravel(path)`
|
19
|
-
|
20
|
-
2. **Reconstruction**
|
21
|
-
`lift(to_scope, each_indexed(path))` regroups by `to_scope` (must be a prefix of `scope(path)`).
|
22
|
-
|
23
|
-
3. **Counting**
|
24
|
-
`size(path) == ravel(path).length == each_indexed(path).count`
|
25
|
-
|
26
|
-
These laws are the mental model. Everything else is just mechanics.
|
27
|
-
|
28
|
-
---
|
29
|
-
|
30
|
-
## Access Modes
|
31
|
-
|
32
|
-
Kumi’s Access Planner emits low-level ops (`enter_hash`, `enter_array`) and supports three vector modes per path:
|
33
|
-
|
34
|
-
### 1) `:materialize`
|
35
|
-
|
36
|
-
Return the **original nested structure** down to that path (no enumeration).
|
37
|
-
Good for “give me the data shaped like the input.”
|
38
|
-
|
39
|
-
```ruby
|
40
|
-
# Input (object mode)
|
41
|
-
{
|
42
|
-
regions: [
|
43
|
-
{ name: "E", offices: [{ employees: [{salary: 100}, {salary: 120}] }] },
|
44
|
-
{ name: "D", offices: [{ employees: [{salary: 90}] }] }
|
45
|
-
]
|
46
|
-
}
|
47
|
-
|
48
|
-
materialize("regions.offices.employees.salary")
|
49
|
-
# => [[ [100,120] ], [ [90] ]]
|
50
|
-
```
|
51
|
-
|
52
|
-
### 2) `:ravel`
|
53
|
-
|
54
|
-
**Enumerate elements at the next array boundary** for that path, i.e., “collect the items at this depth.”
|
55
|
-
It is **not** NumPy’s “flatten everything.” It collects the next level.
|
56
|
-
|
57
|
-
```ruby
|
58
|
-
ravel("regions") # => [ {…E…}, {…D…} ] (enumerate regions)
|
59
|
-
ravel("regions.offices") # => [ {employees:[…]}, {employees:[…]} ] (each office)
|
60
|
-
ravel("regions.offices.employees.salary") # => [ [100,120], [90] ] (each employee group at that depth)
|
61
|
-
```
|
62
|
-
|
63
|
-
### 3) `:each_indexed`
|
64
|
-
|
65
|
-
Enumerate leaf values **with** their index tuple (authoritative for `lift` and alignment):
|
66
|
-
|
67
|
-
```ruby
|
68
|
-
each_indexed("regions.offices.employees.salary")
|
69
|
-
# => [
|
70
|
-
# [100, [0,0,0]], [120, [0,0,1]],
|
71
|
-
# [ 90, [1,0,0]]
|
72
|
-
# ]
|
73
|
-
```
|
74
|
-
|
75
|
-
---
|
76
|
-
|
77
|
-
## Lift (Regroup by prefix)
|
78
|
-
|
79
|
-
`lift(to_scope)` turns a vector-of-rows (from `each_indexed`) into a nested array grouped by `to_scope`.
|
80
|
-
|
81
|
-
```ruby
|
82
|
-
# Given values from each_indexed above:
|
83
|
-
lift([:regions], …) # => [ [100,120], [90] ]
|
84
|
-
lift([:regions,:offices], …) # => [ [[100,120]], [[90]] ]
|
85
|
-
lift([:regions,:offices,:employees], …) # => [ [[[100,120]]], [[[90]]] ]
|
86
|
-
```
|
87
|
-
|
88
|
-
* `to_scope` must be a **prefix** of the vector’s `scope`.
|
89
|
-
* Depth is derived mechanically from index arity; VM doesn’t guess.
|
90
|
-
|
91
|
-
---
|
92
|
-
|
93
|
-
## Alignment & Broadcasting
|
94
|
-
|
95
|
-
When mapping a function over multiple arguments, Kumi:
|
96
|
-
|
97
|
-
1. Picks a **carrier** vector (the one with the longest scope).
|
98
|
-
2. **Aligns** other vectors to the carrier if they are **prefix-compatible** (same axes prefix).
|
99
|
-
3. **Broadcasts** scalars across the carrier.
|
100
|
-
|
101
|
-
If scopes aren’t prefix-compatible, lowering raises:
|
102
|
-
`cross-scope map without join: [:a] vs [:b,:c]`
|
103
|
-
|
104
|
-
```ruby
|
105
|
-
# price, quantity both scope [:items]
|
106
|
-
final = price * quantity # zip by position (same scope)
|
107
|
-
|
108
|
-
# Broadcast scalar across [:items]
|
109
|
-
discounted = price * 0.9
|
110
|
-
|
111
|
-
# Align prefix [:regions] to carrier [:regions,:offices]
|
112
|
-
aligned_tax = align_to(offices_subtotals, regions_tax)
|
113
|
-
total = offices_subtotals * (1 - aligned_tax)
|
114
|
-
```
|
115
|
-
|
116
|
-
---
|
117
|
-
|
118
|
-
## Structure Functions vs Reducers
|
119
|
-
|
120
|
-
* **Reducers** collapse a vector to a **scalar** (e.g., `sum`, `min`, `avg`).
|
121
|
-
Lowering selects a vector argument and emits a `Reduce`.
|
122
|
-
|
123
|
-
* **Structure functions** observe or reshape **structure** (e.g., `size`, `flatten`, `count_across`).
|
124
|
-
Lowering usually uses a `:ravel` plan and a plain `Map` (no indices required).
|
125
|
-
|
126
|
-
### Laws for `size` and `flatten`
|
127
|
-
|
128
|
-
* `size(path) == ravel(path).length` (Counting Law)
|
129
|
-
* `flatten(path)` flattens nested arrays (by default all levels; use `flatten_one` for one level).
|
130
|
-
|
131
|
-
---
|
132
|
-
|
133
|
-
## End-to-End Mini Examples
|
134
|
-
|
135
|
-
### A. Simple vector math + reducers (object access)
|
136
|
-
|
137
|
-
```ruby
|
138
|
-
module Cart
|
139
|
-
extend Kumi::Schema
|
140
|
-
schema do
|
141
|
-
input do
|
142
|
-
array :items do
|
143
|
-
float :price
|
144
|
-
integer :qty
|
145
|
-
end
|
146
|
-
float :shipping_threshold
|
147
|
-
end
|
148
|
-
|
149
|
-
value :subtotals, input.items.price * input.items.qty
|
150
|
-
value :subtotal, fn(:sum, subtotals)
|
151
|
-
value :shipping, subtotal > input.shipping_threshold ? 0.0 : 9.99
|
152
|
-
value :total, subtotal + shipping
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
data = {
|
157
|
-
items: [{price: 100.0, qty: 2}, {price: 200.0, qty: 1}],
|
158
|
-
shipping_threshold: 50.0
|
159
|
-
}
|
160
|
-
|
161
|
-
r = Cart.from(data)
|
162
|
-
r[:subtotals] # => [200.0, 200.0] (vector map)
|
163
|
-
r[:subtotal] # => 400.0 (reducer)
|
164
|
-
r[:shipping] # => 0.0
|
165
|
-
r[:total] # => 400.0
|
166
|
-
```
|
167
|
-
|
168
|
-
**Internal truths**:
|
169
|
-
|
170
|
-
* `each_indexed(input.items.price)` → `[[100.0,[0]],[200.0,[1]]]`
|
171
|
-
* `size(input.items)` → `2` because `ravel(input.items)` has length 2.
|
172
|
-
|
173
|
-
### B. Mixed scopes + alignment
|
174
|
-
|
175
|
-
```ruby
|
176
|
-
module Regions
|
177
|
-
extend Kumi::Schema
|
178
|
-
schema do
|
179
|
-
input do
|
180
|
-
array :regions do
|
181
|
-
float :tax
|
182
|
-
array :offices do
|
183
|
-
array :employees do
|
184
|
-
float :salary
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
value :office_payrolls, fn(:sum, input.regions.offices.employees.salary) # vector reduce per office
|
191
|
-
value :taxed, office_payrolls * (1 - input.regions.tax) # tax (align regions.tax to [:regions,:offices])
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
# Alignment rule: regions.tax (scope [:regions]) aligns to office_payrolls (scope [:regions,:offices])
|
196
|
-
```
|
197
|
-
|
198
|
-
### C. Element access (pure arrays) + structure functions
|
199
|
-
|
200
|
-
```ruby
|
201
|
-
module Cube
|
202
|
-
extend Kumi::Schema
|
203
|
-
schema do
|
204
|
-
input do
|
205
|
-
array :cube do
|
206
|
-
element :array, :layer do
|
207
|
-
element :array, :row do
|
208
|
-
element :float, :cell
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
value :layers, fn(:size, input.cube) # == ravel(input.cube).length
|
215
|
-
value :matrices, fn(:size, input.cube.layer) # enumerate at next depth
|
216
|
-
value :rows, fn(:size, input.cube.layer.row)
|
217
|
-
value :all_values, fn(:flatten, input.cube.layer.row.cell)
|
218
|
-
value :total, fn(:sum, all_values)
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
data = { cube: [ [[1,2],[3]], [[4]] ] }
|
223
|
-
|
224
|
-
# ravel views (intuition)
|
225
|
-
# ravel(cube) => [ [[1,2],[3]], [[4]] ]
|
226
|
-
# ravel(cube.layer) => [ [1,2], [3], [4] ]
|
227
|
-
# ravel(cube.layer.row) => [ 1, 2, 3, 4 ]
|
228
|
-
# ravel(cube.layer.row.cell) => [ 1, 2, 3, 4 ] (same leaf)
|
229
|
-
|
230
|
-
c = Cube.from(data)
|
231
|
-
c[:layers] # => 2
|
232
|
-
c[:matrices] # => 3
|
233
|
-
c[:rows] # => 4
|
234
|
-
c[:all_values] # => [1,2,3,4]
|
235
|
-
c[:total] # => 10
|
236
|
-
```
|
237
|
-
|
238
|
-
---
|
239
|
-
|
240
|
-
## Planner & VM: Who does what?
|
241
|
-
|
242
|
-
* **Planner**: Emits deterministic `enter_hash`/`enter_array` sequences per path and mode.
|
243
|
-
|
244
|
-
* For element edges (inline array aliases), it **does not** emit `enter_hash`.
|
245
|
-
* For `:each_indexed` / `:ravel`, it appends a terminal `enter_array` **only if** the final node is an array.
|
246
|
-
* **Lowerer**: Decides plans (`:ravel`, `:each_indexed`, `:materialize`), inserts `align_to`, emits `lift` at declaration boundary when a vector result should be exposed as a scalar nested array.
|
247
|
-
* **VM**: Purely mechanical:
|
248
|
-
|
249
|
-
* `broadcast_scalar` for scalar→vec expansion,
|
250
|
-
* `zip_same_scope` when scopes match,
|
251
|
-
* `align_to` for prefix alignment,
|
252
|
-
* `group_rows` inside `lift` to reconstruct prefixes.
|
253
|
-
|
254
|
-
No type sniffing or guesses: the IR is the source of truth.
|
255
|
-
|
256
|
-
---
|
257
|
-
|
258
|
-
## Jagged & Sparse Arrays
|
259
|
-
|
260
|
-
* Ordering is **lexicographic by index tuple** (stable).
|
261
|
-
* No padding is introduced; missing branches are just… missing.
|
262
|
-
* `align_to(..., on_missing: :error|:nil)` enforces policy.
|
263
|
-
|
264
|
-
---
|
265
|
-
|
266
|
-
## Error Policies
|
267
|
-
|
268
|
-
For missing keys/arrays, accessors obey policy:
|
269
|
-
|
270
|
-
* `:error` (default) – raise descriptive error with the path/mode.
|
271
|
-
* `:skip` – drop the missing branch (useful in ravels).
|
272
|
-
* `:yield_nil` – emit `nil` in place (preserves cardinality).
|
273
|
-
|
274
|
-
Document these on any user-facing accessor.
|
275
|
-
|
276
|
-
---
|
277
|
-
|
278
|
-
## Quick Cheatsheet
|
279
|
-
|
280
|
-
* Use **`ravel(path)`** to “list the things at this level.”
|
281
|
-
* Use **`each_indexed(path)`** when you need `(value, idx)` pairs for joins/regroup.
|
282
|
-
* Use **`lift(to_scope, each_indexed(path))`** to reconstruct nested structure.
|
283
|
-
* **Reducers** (e.g., `sum`, `avg`, `min`) consume the raveled view of their argument.
|
284
|
-
* **Structure functions** (e.g., `size`, `flatten`, `flatten_one`, `count_across`) operate on structure at that depth and usually compile via `:ravel`.
|
285
|
-
|
286
|
-
Keep the three laws in mind and Kumi’s behavior is predictable—even over deeply nested, heterogeneous data.
|
@@ -1,86 +0,0 @@
|
|
1
|
-
# Compiler Design Principles
|
2
|
-
|
3
|
-
## Core Principle: Smart Analyzer, Dumb Compiler
|
4
|
-
|
5
|
-
The Kumi compiler follows a strict separation of concerns:
|
6
|
-
|
7
|
-
### Analyzer Phase (Smart)
|
8
|
-
- **Makes all decisions** about how operations should be executed
|
9
|
-
- **Analyzes semantic context** to determine operation modes
|
10
|
-
- **Pre-computes execution strategies** and stores in metadata
|
11
|
-
- **Resolves complex logic** like nested array broadcasting, reduction flattening, etc.
|
12
|
-
- **Produces complete instructions** for the compiler to follow
|
13
|
-
|
14
|
-
### Compiler Phase (Dumb)
|
15
|
-
- **Follows metadata instructions** without making decisions
|
16
|
-
- **No conditional logic** based on data types, function types, or structure analysis
|
17
|
-
- **Mechanically executes** the pre-computed strategy from analyzer
|
18
|
-
- **Pure translation** from AST + metadata → executable functions
|
19
|
-
|
20
|
-
## Examples
|
21
|
-
|
22
|
-
### ❌ BAD: Compiler Making Decisions
|
23
|
-
```ruby
|
24
|
-
def compile_call(expr)
|
25
|
-
if Kumi::Registry.reducer?(expr.fn_name)
|
26
|
-
if nested_array_detected?(values)
|
27
|
-
# Compiler deciding to flatten
|
28
|
-
flatten_and_call(expr.fn_name, values)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
```
|
33
|
-
|
34
|
-
### ✅ GOOD: Compiler Following Metadata
|
35
|
-
```ruby
|
36
|
-
def compile_call(expr)
|
37
|
-
# Just read the pre-computed strategy
|
38
|
-
strategy = @analysis.metadata[:call_strategies][expr]
|
39
|
-
execute_strategy(strategy, expr)
|
40
|
-
end
|
41
|
-
```
|
42
|
-
|
43
|
-
### ❌ BAD: Runtime Structure Analysis
|
44
|
-
```ruby
|
45
|
-
def vectorized_function_call(fn_name, values)
|
46
|
-
# Compiler analyzing structure at runtime
|
47
|
-
if values.any? { |v| deeply_nested?(v) }
|
48
|
-
apply_nested_broadcasting(fn, values)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
```
|
52
|
-
|
53
|
-
### ✅ GOOD: Pre-computed Broadcasting Plan
|
54
|
-
```ruby
|
55
|
-
def compile_element_field_reference(expr)
|
56
|
-
# Analyzer already determined the strategy
|
57
|
-
metadata = @analysis.state[:broadcasts][:nested_paths][expr.path]
|
58
|
-
traverse_nested_path(ctx, expr.path, metadata[:operation_mode])
|
59
|
-
end
|
60
|
-
```
|
61
|
-
|
62
|
-
## Benefits
|
63
|
-
|
64
|
-
1. **Predictable Performance**: No runtime analysis or decision-making
|
65
|
-
2. **Easier Testing**: Compiler behavior determined entirely by metadata
|
66
|
-
3. **Maintainable**: Complex logic isolated in analyzer passes
|
67
|
-
4. **Extensible**: New features added by extending analyzer, not compiler
|
68
|
-
5. **Debuggable**: All decisions visible in analyzer metadata
|
69
|
-
|
70
|
-
## Implementation Pattern
|
71
|
-
|
72
|
-
For any new compiler feature:
|
73
|
-
|
74
|
-
1. **Analyzer Pass**: Analyze the requirement and store strategy in metadata
|
75
|
-
2. **Metadata Schema**: Define clear data structure for the strategy
|
76
|
-
3. **Compiler Method**: Read metadata and execute strategy mechanically
|
77
|
-
4. **No Conditionals**: Avoid `if` statements based on runtime data in compiler
|
78
|
-
|
79
|
-
## Metadata-Driven Architecture
|
80
|
-
|
81
|
-
The compiler should be a pure **metadata interpreter**:
|
82
|
-
- Input: AST + Analyzer Metadata
|
83
|
-
- Output: Executable Functions
|
84
|
-
- Process: Mechanical translation following metadata instructions
|
85
|
-
|
86
|
-
This ensures the compiler remains simple, fast, and maintainable as the system grows in complexity.
|
data/docs/dev/analyzer-debug.md
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# Analyzer Debug System
|
2
|
-
|
3
|
-
## Debug Module
|
4
|
-
|
5
|
-
**File**: `lib/kumi/core/analyzer/debug.rb`
|
6
|
-
|
7
|
-
**Enable**: `KUMI_DEBUG_STATE=1`
|
8
|
-
|
9
|
-
**Output**: JSONL to stdout with state diffs and timing per pass
|
10
|
-
|
11
|
-
**Configuration**:
|
12
|
-
- `KUMI_DEBUG_REQUIRE_FROZEN=1` - Enforce state immutability checks
|
13
|
-
|
14
|
-
## Checkpoint System
|
15
|
-
|
16
|
-
**Files**:
|
17
|
-
- `lib/kumi/core/analyzer/checkpoint.rb`
|
18
|
-
- `lib/kumi/core/analyzer/state_serde.rb`
|
19
|
-
|
20
|
-
**Enable**: `KUMI_CHECKPOINT=1`
|
21
|
-
|
22
|
-
**Configuration**:
|
23
|
-
- `KUMI_CHECKPOINT_DIR=path` - Output directory (default: `/tmp/kumi_checkpoints`)
|
24
|
-
- `KUMI_CHECKPOINT_FORMAT=marshal|json|both` - File format (default: `marshal`)
|
25
|
-
- `KUMI_CHECKPOINT_PHASE=before|after|both` - When to save (default: `both`)
|
26
|
-
|
27
|
-
**Resume/Stop**:
|
28
|
-
- `KUMI_RESUME_FROM=file.msh` - Resume from checkpoint file
|
29
|
-
- `KUMI_RESUME_AT=PassName` - Skip to specific pass
|
30
|
-
- `KUMI_STOP_AFTER=PassName` - Stop after specific pass
|
31
|
-
|
32
|
-
## Object Printers
|
33
|
-
|
34
|
-
**File**: `spec/support/debug_printers.rb`
|
35
|
-
|
36
|
-
Handles clean output for debug logs. Add new object types here when they appear as `#<Object:0x...>` in debug output.
|
37
|
-
|
38
|
-
## Usage
|
39
|
-
|
40
|
-
```bash
|
41
|
-
# Basic debug
|
42
|
-
KUMI_DEBUG_STATE=1 bundle exec ruby script.rb
|
43
|
-
|
44
|
-
# Debug with checkpoints
|
45
|
-
KUMI_DEBUG_STATE=1 KUMI_CHECKPOINT=1 bundle exec ruby script.rb
|
46
|
-
|
47
|
-
# Resume from checkpoint
|
48
|
-
KUMI_RESUME_FROM=/tmp/kumi_checkpoints/005_TypeChecker_after.msh bundle exec ruby script.rb
|
49
|
-
|
50
|
-
# Stop at specific pass for debugging
|
51
|
-
KUMI_STOP_AFTER=BroadcastDetector bundle exec ruby script.rb
|
52
|
-
```
|
data/docs/dev/parse-command.md
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# Parse Command
|
2
|
-
|
3
|
-
One-command developer loop for text schemas: parse → analyze → render IR → diff.
|
4
|
-
|
5
|
-
## Usage
|
6
|
-
|
7
|
-
```bash
|
8
|
-
# Default: show diff vs golden file (or print if no golden)
|
9
|
-
kumi parse golden/simple_math/schema.kumi
|
10
|
-
|
11
|
-
# Write/overwrite golden file
|
12
|
-
kumi parse golden/simple_math/schema.kumi --write
|
13
|
-
|
14
|
-
# Update golden only if different
|
15
|
-
kumi parse golden/simple_math/schema.kumi --update
|
16
|
-
|
17
|
-
# JSON format instead of text
|
18
|
-
kumi parse golden/simple_math/schema.kumi --json --write
|
19
|
-
|
20
|
-
# Enable state tracing
|
21
|
-
kumi parse golden/simple_math/schema.kumi --trace
|
22
|
-
|
23
|
-
# Snapshot analysis passes
|
24
|
-
kumi parse golden/simple_math/schema.kumi --snap after --snap-dir debug/
|
25
|
-
```
|
26
|
-
|
27
|
-
## Exit Codes
|
28
|
-
|
29
|
-
- `0` - No changes or successful write
|
30
|
-
- `1` - Diff mismatch or analysis error
|
31
|
-
|
32
|
-
## Output
|
33
|
-
|
34
|
-
**No changes:**
|
35
|
-
```
|
36
|
-
No changes (golden/simple_math/expected/ir.txt)
|
37
|
-
```
|
38
|
-
|
39
|
-
**Diff mismatch:**
|
40
|
-
```
|
41
|
-
--- expected
|
42
|
-
+++ actual
|
43
|
-
@@ -6,7 +6,7 @@
|
44
|
-
2: map argc=2 fn=:add [0, 1]
|
45
|
-
+ 2: map argc=2 fn=:power [0, 1]
|
46
|
-
```
|
47
|
-
|
48
|
-
**Write mode:**
|
49
|
-
```
|
50
|
-
Wrote: golden/simple_math/expected/ir.txt
|
51
|
-
```
|
52
|
-
|
53
|
-
## IR Format
|
54
|
-
|
55
|
-
Deterministic text representation:
|
56
|
-
```
|
57
|
-
IR Module
|
58
|
-
decls: 3
|
59
|
-
decl[0] value:sum shape=scalar ops=4
|
60
|
-
0: load_input has_idx=false is_scalar=true plan_id=x:read scope=[] []
|
61
|
-
1: load_input has_idx=false is_scalar=true plan_id=y:read scope=[] []
|
62
|
-
2: map argc=2 fn=:add [0, 1]
|
63
|
-
3: store name=:sum [2]
|
64
|
-
```
|
data/docs/dev/vm-profiling.md
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
# VM Profiling with Schema Differentiation
|
2
|
-
|
3
|
-
## Overview
|
4
|
-
|
5
|
-
Profiles VM operation execution with schema-level differentiation. Tracks operations by schema type for multi-schema performance analysis.
|
6
|
-
|
7
|
-
## Core Components
|
8
|
-
|
9
|
-
**Profiler**: `lib/kumi/core/ir/execution_engine/profiler.rb`
|
10
|
-
- Streams VM operation events with schema identification
|
11
|
-
- Supports persistent mode for cross-run analysis
|
12
|
-
- JSONL event format with operation metadata
|
13
|
-
|
14
|
-
**Profile Aggregator**: `lib/kumi/dev/profile_aggregator.rb`
|
15
|
-
- Analyzes profiling data by schema type
|
16
|
-
- Generates summary and detailed performance reports
|
17
|
-
- Schema breakdown showing operations and timing per schema
|
18
|
-
|
19
|
-
**CLI Integration**: `bin/kumi profile`
|
20
|
-
- Processes JSONL profiling data files
|
21
|
-
- Multiple output formats: summary, detailed, raw
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
### Basic Profiling
|
26
|
-
|
27
|
-
```bash
|
28
|
-
# Single schema with operations
|
29
|
-
KUMI_PROFILE=1 KUMI_PROFILE_OPS=1 KUMI_PROFILE_FILE=profile.jsonl ruby script.rb
|
30
|
-
|
31
|
-
# Persistent mode across multiple runs
|
32
|
-
KUMI_PROFILE=1 KUMI_PROFILE_PERSISTENT=1 KUMI_PROFILE_OPS=1 KUMI_PROFILE_FILE=profile.jsonl ruby script.rb
|
33
|
-
|
34
|
-
# Streaming mode for real-time analysis
|
35
|
-
KUMI_PROFILE=1 KUMI_PROFILE_STREAM=1 KUMI_PROFILE_OPS=1 KUMI_PROFILE_FILE=profile.jsonl ruby script.rb
|
36
|
-
```
|
37
|
-
|
38
|
-
### CLI Analysis
|
39
|
-
|
40
|
-
```bash
|
41
|
-
# Summary report with schema breakdown
|
42
|
-
kumi profile profile.jsonl --summary
|
43
|
-
|
44
|
-
# Detailed per-operation analysis
|
45
|
-
kumi profile profile.jsonl --detailed
|
46
|
-
|
47
|
-
# Raw event stream
|
48
|
-
kumi profile profile.jsonl --raw
|
49
|
-
```
|
50
|
-
|
51
|
-
## Environment Variables
|
52
|
-
|
53
|
-
**Core**:
|
54
|
-
- `KUMI_PROFILE=1` - Enable profiling
|
55
|
-
- `KUMI_PROFILE_FILE=path` - Output file (required)
|
56
|
-
- `KUMI_PROFILE_OPS=1` - Enable VM operation profiling
|
57
|
-
|
58
|
-
**Modes**:
|
59
|
-
- `KUMI_PROFILE_PERSISTENT=1` - Append to existing files across runs
|
60
|
-
- `KUMI_PROFILE_STREAM=1` - Stream individual events vs batch
|
61
|
-
- `KUMI_PROFILE_TRUNCATE=1` - Truncate existing files
|
62
|
-
|
63
|
-
## Event Format
|
64
|
-
|
65
|
-
JSONL with operation metadata:
|
66
|
-
|
67
|
-
```json
|
68
|
-
{"event":"vm_operation","schema":"TestSchema","operation":"LoadInput","duration_ms":0.001,"timestamp":"2025-01-20T10:30:45.123Z"}
|
69
|
-
{"event":"vm_operation","schema":"TestSchema","operation":"Map","duration_ms":0.002,"timestamp":"2025-01-20T10:30:45.125Z"}
|
70
|
-
```
|
71
|
-
|
72
|
-
## Schema Differentiation
|
73
|
-
|
74
|
-
Tracks operations by schema class name for multi-schema analysis:
|
75
|
-
|
76
|
-
**Implementation**:
|
77
|
-
- Schema name propagated through compilation pipeline
|
78
|
-
- Profiler tags each VM operation with schema identifier
|
79
|
-
- Aggregator groups operations by schema type
|
80
|
-
|
81
|
-
**Output Example**:
|
82
|
-
```
|
83
|
-
Total operations: 24 (0.8746ms)
|
84
|
-
Schemas analyzed: SchemaA, SchemaB
|
85
|
-
SchemaA: 12 operations, 0.3242ms
|
86
|
-
SchemaB: 12 operations, 0.0504ms
|
87
|
-
```
|
88
|
-
|
89
|
-
## Performance Analysis
|
90
|
-
|
91
|
-
**Reference Operations**: Typically dominate execution time in complex schemas
|
92
|
-
**Map Operations**: Element-wise computations on arrays
|
93
|
-
**LoadInput Operations**: Data access operations
|
94
|
-
|
95
|
-
Use schema breakdown to identify performance differences between schema types.
|
data/docs/development/README.md
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
# Development Guides
|
2
|
-
|
3
|
-
This directory contains detailed guides for developing and maintaining Kumi. These guides complement the high-level information in the main `CLAUDE.md` file.
|
4
|
-
|
5
|
-
## Guide Index
|
6
|
-
|
7
|
-
### Architecture & Design
|
8
|
-
- [Error Reporting Standards](error-reporting.md) - Comprehensive guide to unified error reporting
|
9
|
-
- [Analyzer Pass Development](analyzer-passes.md) - How to create new analyzer passes
|
10
|
-
- [Type System Integration](type-system.md) - Working with Kumi's type inference and checking
|
11
|
-
|
12
|
-
### Code Quality & Standards
|
13
|
-
- [Testing Standards](testing-standards.md) - Testing patterns and requirements
|
14
|
-
- [Code Organization](code-organization.md) - File structure and class design patterns
|
15
|
-
- [RuboCop Guidelines](rubocop-guidelines.md) - Code style and quality requirements
|
16
|
-
|
17
|
-
### Common Tasks
|
18
|
-
- [Adding New Functions](adding-functions.md) - Extending the FunctionRegistry
|
19
|
-
- [DSL Extension Patterns](dsl-extensions.md) - Adding new DSL constructs
|
20
|
-
- [Performance Considerations](performance.md) - Guidelines for maintaining performance
|
21
|
-
|
22
|
-
### Integration & Compatibility
|
23
|
-
- [Backward Compatibility](backward-compatibility.md) - Maintaining compatibility during changes
|
24
|
-
- [Migration Patterns](migration-patterns.md) - Safe patterns for evolving APIs
|
25
|
-
- [Zeitwerk Integration](zeitwerk.md) - Autoloading patterns and requirements
|
26
|
-
|
27
|
-
## Quick Reference
|
28
|
-
|
29
|
-
### Key Principles
|
30
|
-
1. **Unified Error Reporting**: All errors must provide clear location information
|
31
|
-
2. **Multi-pass Analysis**: Each analyzer pass has single responsibility
|
32
|
-
3. **Backward Compatibility**: Changes maintain existing API compatibility
|
33
|
-
4. **Type Safety**: Optional but comprehensive type checking
|
34
|
-
5. **Ruby Integration**: Leverage Ruby idioms while maintaining structure
|
35
|
-
|
36
|
-
### Common Commands
|
37
|
-
```bash
|
38
|
-
# Run all tests
|
39
|
-
bundle exec rspec
|
40
|
-
|
41
|
-
# Run specific test categories
|
42
|
-
bundle exec rspec spec/integration/
|
43
|
-
bundle exec rspec spec/kumi/analyzer/
|
44
|
-
|
45
|
-
# Check code quality
|
46
|
-
bundle exec rubocop
|
47
|
-
bundle exec rubocop -a
|
48
|
-
|
49
|
-
# Validate error reporting
|
50
|
-
bundle exec ruby test_location_improvements.rb
|
51
|
-
```
|
52
|
-
|
53
|
-
### File Templates
|
54
|
-
|
55
|
-
**New Analyzer Pass**:
|
56
|
-
```ruby
|
57
|
-
# frozen_string_literal: true
|
58
|
-
|
59
|
-
module Kumi
|
60
|
-
module Analyzer
|
61
|
-
module Passes
|
62
|
-
class MyNewPass < PassBase
|
63
|
-
def run(errors)
|
64
|
-
# Implementation with proper error reporting
|
65
|
-
report_error(errors, "message", location: node.loc, type: :semantic)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
```
|
72
|
-
|
73
|
-
**New Integration Test**:
|
74
|
-
```ruby
|
75
|
-
# frozen_string_literal: true
|
76
|
-
|
77
|
-
RSpec.describe "My Feature Integration" do
|
78
|
-
it "validates the feature works correctly" do
|
79
|
-
schema = build_schema do
|
80
|
-
input { integer :field }
|
81
|
-
value :result, input.field * 2
|
82
|
-
end
|
83
|
-
|
84
|
-
expect(schema.from(field: 5).fetch(:result)).to eq(10)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
```
|
88
|
-
|
89
|
-
## Contributing Guidelines
|
90
|
-
|
91
|
-
### Before Making Changes
|
92
|
-
1. Check relevant development guide in this directory
|
93
|
-
2. Review `CLAUDE.md` for high-level architecture understanding
|
94
|
-
3. Run existing tests to ensure baseline functionality
|
95
|
-
4. Consider backward compatibility implications
|
96
|
-
|
97
|
-
### After Making Changes
|
98
|
-
1. Update relevant development guides if patterns change
|
99
|
-
2. Add or update tests for new functionality
|
100
|
-
3. Run full test suite: `bundle exec rspec`
|
101
|
-
4. Check code quality: `bundle exec rubocop`
|
102
|
-
5. Verify error reporting quality with integration tests
|
103
|
-
|
104
|
-
### Adding New Guides
|
105
|
-
When adding new development guides:
|
106
|
-
1. Create focused, actionable guides for specific development tasks
|
107
|
-
2. Include code examples and common patterns
|
108
|
-
3. Reference related files and tests
|
109
|
-
4. Update this README index
|
110
|
-
5. Cross-reference from main `CLAUDE.md` if needed
|
111
|
-
|
112
|
-
## Guide Maintenance
|
113
|
-
|
114
|
-
These guides should be kept up-to-date as the codebase evolves:
|
115
|
-
- **Review quarterly** for accuracy and completeness
|
116
|
-
- **Update immediately** when patterns or APIs change significantly
|
117
|
-
- **Expand based on common questions** during development
|
118
|
-
- **Consolidate** overlapping or redundant information
|
119
|
-
|
120
|
-
The goal is to make Kumi development efficient and consistent while maintaining high code quality.
|