feat: add extension function mechanism (Phase 1) #26

Open
claireb wants to merge 1 commit from feat/extension-interface into main
claireb commented 2026-03-04 04:55:43 +00:00 (Migrated from codeberg.org)

Introduce a principled mechanism for registering external pure functions
callable from bind expressions during grounding. This is the foundation
for aggregation and other extension use-cases.

  • Add FunctionRegistry, ExtensionFunction trait, EvalContext, and
    supporting types in new function_registry module
  • Add ArithExpr::Call variant and ArithError::{UnknownFunction,FunctionError}
  • Add eval_with_context() on ArithExpr and ArithConstraint, threading
    EvalContext through the grounding call chain
  • Update parser to emit Call nodes for unknown names in expression position
  • Add validation of Call nodes against registry (existence + arity)
  • Add function_registry field to PipelineContext and PrepareOptions
  • Zero existing behaviour changes: programs without extension functions
    behave identically (1827 existing tests pass unchanged)

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

fix: remove redundant Arity::describe(), fix pluralization, add test coverage

  • Remove Arity::describe() in favor of the identical Display impl
  • Fix "expects N arguments" → "expects N argument(s)" for grammatical correctness
  • Add integration tests: range arity, non-numeric return, nested calls,
    call in body predicate argument, and zero-arg function
  • Add unit tests for ArithExpr::Call evaluation paths
  • Apply cargo fmt to touched files

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

test: add extension function test coverage for non-integer returns, e2e reasoning, multi-function

  • Add end-to-end reasoning test through reason_with_options() with extension functions
  • Add Decimal return type test (HalfFunction)
  • Add Float return type test (SqrtFunction with FiniteFloat)
  • Add multiple extension functions in one theory test
  • Add TODO comment in query/mod.rs for function_registry threading

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

fix: struct initialisation

Introduce a principled mechanism for registering external pure functions callable from `bind` expressions during grounding. This is the foundation for aggregation and other extension use-cases. - Add FunctionRegistry, ExtensionFunction trait, EvalContext, and supporting types in new function_registry module - Add ArithExpr::Call variant and ArithError::{UnknownFunction,FunctionError} - Add eval_with_context() on ArithExpr and ArithConstraint, threading EvalContext through the grounding call chain - Update parser to emit Call nodes for unknown names in expression position - Add validation of Call nodes against registry (existence + arity) - Add function_registry field to PipelineContext and PrepareOptions - Zero existing behaviour changes: programs without extension functions behave identically (1827 existing tests pass unchanged) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> fix: remove redundant Arity::describe(), fix pluralization, add test coverage - Remove Arity::describe() in favor of the identical Display impl - Fix "expects N arguments" → "expects N argument(s)" for grammatical correctness - Add integration tests: range arity, non-numeric return, nested calls, call in body predicate argument, and zero-arg function - Add unit tests for ArithExpr::Call evaluation paths - Apply cargo fmt to touched files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> test: add extension function test coverage for non-integer returns, e2e reasoning, multi-function - Add end-to-end reasoning test through reason_with_options() with extension functions - Add Decimal return type test (HalfFunction) - Add Float return type test (SqrtFunction with FiniteFloat) - Add multiple extension functions in one theory test - Add TODO comment in query/mod.rs for function_registry threading Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> fix: struct initialisation
This pull request has changes conflicting with the target branch.
  • crates/spindle-core/src/query/mod.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/extension-interface:feat/extension-interface
git switch feat/extension-interface

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff feat/extension-interface
git switch feat/extension-interface
git rebase main
git switch main
git merge --ff-only feat/extension-interface
git switch feat/extension-interface
git rebase main
git switch main
git merge --no-ff feat/extension-interface
git switch main
git merge --squash feat/extension-interface
git switch main
git merge --ff-only feat/extension-interface
git switch main
git merge feat/extension-interface
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
anuna-research/spindle-rust!26
No description provided.