Skip to content

Support filter includes without side effects#104

Open
dloss wants to merge 1 commit intomainfrom
codex/explore-compatibility-of-include-with-filter
Open

Support filter includes without side effects#104
dloss wants to merge 1 commit intomainfrom
codex/explore-compatibility-of-include-with-filter

Conversation

@dloss
Copy link
Owner

@dloss dloss commented Jan 1, 2026

Motivation

  • Allow --include to be used with --filter so shared helper functions can be reused in filter expressions while preserving filter purity.
  • Avoid introducing side effects into filter stages by preventing include files from contributing statements that could mutate state or perform I/O.
  • Carry include metadata through the CLI/pipeline plumbing so filters can access included helper definitions.

Description

  • Change ScriptStageType::Filter to carry { script: String, includes: Vec<IncludeFile> } and add IncludeFile { path, content } in src/config.rs.
  • Add load_include_files in src/cli.rs and attach loaded includes to filter stages instead of inlining their contents into the expression.
  • Add RhaiEngine::compile_filter_with_includes in src/engine.rs which compiles the filter as an expression, compiles each include as a script, rejects includes that contain statements, extracts only functions via clone_functions_only, and merges them into the filter AST.
  • Update pipeline builders and FilterStage::new signature to accept includes, and add unit tests to validate that includes provide helper functions and that includes with statements are rejected.

Testing

  • Ran cargo fmt --all and formatting completed successfully.
  • Ran cargo clippy --all-targets --all-features -- -D warnings with no warnings treated as errors.
  • Ran cargo test and the full test suite completed with all tests passing (automated unit and integration tests passed).

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant