Skip to content

feat: add Bool type support across Rust and Lua APIs#344

Draft
chobits wants to merge 4 commits intomainfrom
feat/bool-type-support
Draft

feat: add Bool type support across Rust and Lua APIs#344
chobits wants to merge 4 commits intomainfrom
feat/bool-type-support

Conversation

@chobits
Copy link
Contributor

@chobits chobits commented Mar 20, 2026

Use case: I'm adding field to context called plugins.xxx.is_access_executed() == true/false to indicate whether the some plugins in kong was executed. This is related to plugin conditional expression feature in kong.

@chobits chobits marked this pull request as draft March 20, 2026 06:27
@github-actions
Copy link

github-actions bot commented Mar 20, 2026

Luacheck Report

3 tests   3 ✅  0s ⏱️
1 suites  0 💤
1 files    0 ❌

Results for commit 2ba1185.

♻️ This comment has been updated with latest results.

Copy link

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

Adds first-class boolean literal/type support to the ATC DSL and wires it through the Rust core plus the Lua FFI wrappers, so matchers can compare schema fields against true/false.

Changes:

  • Extend DSL grammar/parser/AST/semantics to support Bool values and true/false literals.
  • Add interpreter and Rust unit/integration tests for boolean comparisons.
  • Update Lua schema/context bindings and generated FFI cdefs to pass boolean values into the Rust engine.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
t/08-equals.t Adds an OpenResty integration test for == / != with Bool fields.
src/semantics.rs Allows Bool LHS for equality ops and adds validation tests.
src/schema.rs Extends schema test coverage to include Type::Bool.
src/parser.rs Parses bool_literal into Value::Bool.
src/interpreter.rs Adds predicate execution test cases for Bool equality/inequality.
src/ffi/router.rs Removes deprecated constant usage in tests (inlines buffer size).
src/ffi/mod.rs Extends CValue and conversion to include Bool.
src/ffi/expression.rs Removes deprecated constant usage in tests (inlines buffer size).
src/atc_grammar.pest Adds bool_literal and includes it in rhs.
src/ast.rs Adds Value::Bool, Type::Bool, formatting, and parse/display tests.
lib/resty/router/schema.lua Maps "Bool" to the correct C enum type.
lib/resty/router/context.lua Supports adding Bool values and fixes nil-check so false is not dropped.
lib/resty/router/cdefs.lua Updates FFI definitions for Type::Bool and CValue_Bool.
README.md Documents Bool type and shows usage in the Lua example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

chobits and others added 2 commits March 20, 2026 14:38
Previously, add_value would silently fall through without updating
CACHED_VALUE when called with an unsupported field type (e.g. IpCidr,
Regex), causing stale data to be passed into the FFI call. Now returns
an explicit error instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The comment was missing rawstr_literal after it was added to the
grammar. Now mirrors the grammar definition exactly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment on lines +221 to +222

const ERR_BUF_MAX_LEN: usize = 4096;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is not a good way to fix this issue,
and also i foudn that our Ci workflow does not include "cargo test"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chobits
Copy link
Contributor Author

chobits commented Mar 20, 2026

based on this #328, i re-implement boolean support

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.

2 participants