Skip to content

Add expr.MaxNodes() option #799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 3, 2025
Merged

Add expr.MaxNodes() option #799

merged 3 commits into from
Jun 3, 2025

Conversation

antonmedv
Copy link
Member

Fixes #798

@antonmedv antonmedv requested a review from Copilot June 3, 2025 15:13
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new expr.MaxNodes option to cap AST node count and adjusts default budget logic and related tests. Key changes include:

  • Added MaxNodes compiler option and wired it into config.
  • Removed MemoryBudget defaults from config struct and centralized default in VM.Run.
  • Updated tests to cover node- and memory-budget behaviors.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
vm/vm.go Trimmed whitespace only
parser/parser_test.go Adjusted error message text for node-budget-disabled test
expr_test.go Imported vm, added TestMaxNodes, and refactored memory-budget tests
expr.go Added MaxNodes option with documentation
conf/config.go Switched default budgets to var, removed MemoryBudget from Config and initializer
Comments suppressed due to low confidence (3)

parser/parser_test.go:1243

  • The test error message refers to DefaultMaxNodes, but the API option is MaxNodes. Update this to "Node budget check should be disabled when MaxNodes is 0" for clarity and consistency.
t.Error("Node budget check should be disabled when DefaultMaxNodes is 0")

expr_test.go:2716

  • Add a test case passing expr.MaxNodes(0) to verify that setting the limit to zero indeed disables the node-count check.
func TestMaxNodes(t *testing.T) {

conf/config.go:13

  • [nitpick] Consider using const for DefaultMemoryBudget and DefaultMaxNodes instead of var, since these values are intended as compile-time constants and shouldn't be modified at runtime.
var (

@antonmedv antonmedv merged commit eeb1b8b into master Jun 3, 2025
18 checks passed
@antonmedv antonmedv deleted the feat/add-max-nodes-option branch June 3, 2025 15:31
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.

Support custom MaxNodes property of expr Config
1 participant