feat(cel-proto-parser): add CEL proto parser and deparser package #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat(cel-proto-parser): add CEL proto parser and deparser package
Summary
Adds a new
cel-proto-parserpackage to the dev-utils monorepo for working with CEL (Common Expression Language) Abstract Syntax Trees. The package provides:{callExpr: {function: '_>_', args: [...]}}→"x > 5")CelTestclass and helper functions for fixture-based round-trip testing (similar to pgsql-parser's TestUtils and constructive-db's PrettyTest)The deparser supports all CEL expression types including constants, identifiers, field access, operators, ternary conditionals, lists, maps, message construction, and comprehensions.
Updates Since Last Revision
Added comprehensive policy-shaped fixtures and fixed converter bugs:
policy.txtwith 34 OPA-ish Kubernetes admission control expressionsrls-templates.txtwith 17 RLS policy template expressions (direct_owner, membership, etc.)[](was only handlingindex)!_with single node args (not array)basic.txt16/16,policy.txt34/34,rls-templates.txt17/17Run fixture tests with:
Known limitation: @marcbachmann/cel-js does not support bitwise AND (
&) operator, so permission bitmask expressions cannot be round-trip tested.Review & Testing Checklist for Human
src/converter/index.ts- this translates between two different AST formats. Verify the operator mappings (especially the[]and!_fixes) and special cases (likehas()macro handling) are correct.npx tsx scripts/test-roundtrip.ts __fixtures__/expressions/basic.txtto verify full round-trip parsing.CelProtoParserclass has no tests. Runpnpm generateto verify it works with the includedsyntax.protofixture.deparseComprehensionfunction falls back to outputting a comment for unrecognized patterns.Recommended Test Plan
pnpm testin the package directory - 65 tests should pass (34 deparser + 31 converter/integration)npx tsx scripts/test-roundtrip.ts __fixtures__/expressions/basic.txt(expect 16/16 pass)npx tsx scripts/test-roundtrip.ts __fixtures__/expressions/policy.txt(expect 34/34 pass)npx tsx scripts/test-roundtrip.ts __fixtures__/expressions/rls-templates.txt(expect 17/17 pass)pnpm generateto test the proto parser with the CEL syntax.proto fixtureNotes
pg-proto-parserfrom the pgsql-parser ecosystem as requestedCelTestclass follows patterns from constructive-db'sPrettyTestand pgsql-parser'sFixtureTestUtilssrc/utils/index.tsappear unused but may be needed for future featuresRequested by: Dan Lynch (@pyramation)
Devin session: https://app.devin.ai/sessions/0d3278ca3e0d43b5a267e42838295712