Skip to content

Fix GoldenPath CI and add arithmetic and boolean agg functions#30

Open
trevornelson wants to merge 9 commits into
amuta:mainfrom
retirable:add-arithmetic-functions
Open

Fix GoldenPath CI and add arithmetic and boolean agg functions#30
trevornelson wants to merge 9 commits into
amuta:mainfrom
retirable:add-arithmetic-functions

Conversation

@trevornelson
Copy link
Copy Markdown

Summary

  • Fix Zeitwerk autoloader error that was failing CI by moving AUTOLOADER into the Kumi namespace and explicitly ignoring golden_schema_modules.rb
  • Add new function definitions: round, floor, ceil, between?, and none? with Ruby and JavaScript kernels
  • Add kernel finalize support to allow reducers whose final result differs from their accumulator (used by none? which accumulates with OR then inverts)
  • Add fold_inline to boolean aggregate kernels (any, all, none) to fix "Can't fold - no template defined" error when these reducers are applied to collection types

Autoloader fix

The top-level AUTOLOADER constant caused Zeitwerk namespace errors in CI. I moved it inside the Kumi namespace and added an explicit ignore for golden_schema_modules.rb, which is now loaded via require_relative only when golden tests are invoked.

New functions

Function Kind Description
round(value, precision) elementwise Round to N decimal places
floor(value) elementwise Round down to integer
ceil(value) elementwise Round up to integer
log(value) elementwise Calculate the normal log
between?(value, lo, hi) elementwise Inclusive range check, returns boolean
none?(source_value) reduce True when no element is truthy

Kernel finalize step

The none? reducer accumulates the same way as any? (boolean OR), then inverts the result. To support this, a finalize attribute was added to the kernel schema. During codegen, emit_loadaccumulator in both Ruby and JS emitters now checks for a finalize template and applies it to the accumulator before assigning the output.

Boolean aggregate fold_inline

When a reduce function is called on a collection type (tuple), the compiler generates a Fold LIR instruction. emit_fold requires a fold_inline template on the kernel. The numeric aggregates (sum, min, max, count) already had this, but the boolean aggregates did not, causing a runtime error. Added fold_inline for all three boolean aggregates.

fold_inline: "= $0.none?"
identity:
boolean: false
finalize: "= !$0" No newline at end of file
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finalize was needed so that none? could be calculated correctly when the function is used as an accumulator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant