Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Expose the parsed expression tree from Program (for explain/trace tooling, linting and sub-expression evaluation)

Offen
#48 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
45/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
python, rust

Rechercherichtung

Beginne mit der Untersuchung des Python Program-Wrappers und von cel::Program::expression(), und vergleiche dann dessen IdedExpr- und Expr-Varianten mit dem vorgeschlagenen JSON-serialisierbaren Baum. Als erledigt gilt die Aufgabe, wenn Program.ast() Literale, Bezeichner, Selects, Aufrufe, Listen, Maps, Structs und expandierte Comprehensions offenlegt, mit einer vorläufigen Dokumentation, die an die cel-rust-Version gebunden ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

enhancement

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-side explain() 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 under request.".
  • 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).

Vorherrschende Sprache
Python
Sterne
43
Forks
4
Ø Merge
12 Std. 37 Min.
Gemergte PRs (30 T.)
11

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus hardbyte/python-common-expression-language

Alle Issues in hardbyte/python-common-expression-language

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.