Expose the parsed expression tree from Program (for explain/trace tooling, linting and sub-expression evaluation)
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 45/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
調査の方向性
まず Python Program wrapper と cel::Program::expression() を調査し、次にその IdedExpr および Expr のバリアントを、提案されている JSON シリアライズ可能なツリーと比較します。Program.ast() がリテラル、識別子、select、呼び出し、リスト、マップ、struct、展開された comprehensions を公開し、cel-rust のバージョンに対応付けられた暫定ドキュメントが用意されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Motivation
Program.references() answers "which names does this expression use", but several things people ask for need the structure of the expression, not just its leaves:
- #30 wants to know which element or clause made an
exists/&&chain true or false. cel-rust has no evaluation hooks, so a wrapper-sideexplain()would have to walk the tree and re-evaluate sub-expressions. - Policy linting beyond name lists: "no
matches()on untrusted input", "no more than N nested comprehensions", "field access only underrequest.". - Pretty-printing / normalising expressions stored by users.
What upstream gives us
cel::Program::expression() returns the parsed Expression (IdedExpr: an id plus an Expr enum covering literals, identifiers, selects, calls, lists, maps, structs and the expanded comprehensions). No protobuf AST, but the shape is close to cel.expr.Expr and would be straightforward to mirror as nested dicts or small dataclasses.
Proposal
Program.ast() returning a plain, JSON-serialisable tree, e.g. {"kind": "call", "function": "_&&_", "args": [...]}, with comprehension macros shown in their expanded form (that is what cel-rust holds after parsing; the original macro call is not retained). Ship it as provisional, tied to the cel-rust version, and note that the node shapes may change when cel-rust changes its AST.
A Python-side cel.explain(program, context) built on it could then evaluate each boolean sub-expression and report the first failing clause, which covers the exists/all case in #30 without upstream changes, at the cost of re-evaluation (custom functions run again).
- 主要言語
- Python
- スター
- 43
- フォーク
- 4
- 平均マージ
- 12時間 37分
- マージ済み PR(30日)
- 11
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hardbyte/python-common-expression-language のほかの issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
hardbyte/python-common-expression-language の issue をすべて見る
似ている issue
-
bug confirmed issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
open-webui/open-webui#30750 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 90/100