feat(cel-proto-parser): add CEL proto parser and deparser package#52
Merged
pyramation merged 4 commits intomainfrom Jan 5, 2026
Merged
feat(cel-proto-parser): add CEL proto parser and deparser package#52pyramation merged 4 commits intomainfrom
pyramation merged 4 commits intomainfrom
Conversation
- Add new cel-proto-parser package for working with CEL ASTs - Implement CelProtoParser class to parse CEL proto files and generate TypeScript types - Implement deparser to convert CEL AST back to expression strings - Support all CEL expression types: constants, identifiers, field access, function calls, operators, ternary, lists, maps, message construction, comprehensions - Add AST helper generation for constructing CEL AST nodes - Include comprehensive test suite with 34 passing tests - Include CEL syntax.proto fixture from official cel-spec
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…erter - Add @marcbachmann/cel-js as dependency for CEL parsing - Create AST converter from @marcbachmann/cel-js format to CEL proto format - Create TestUtil class (CelTest) for round-trip testing similar to pgsql-parser - Add CEL expression fixtures for testing - Add comprehensive converter and integration tests (31 new tests) - Add test-roundtrip.ts script for ESM-based round-trip testing - Export convertToProtoExpr and MarcAstNode from main index
- Add basic.txt fixture file with handful of representative CEL expressions - Update test-roundtrip.ts to load fixtures from file via CLI argument - Run with: npx tsx scripts/test-roundtrip.ts __fixtures__/expressions/basic.txt
…verter - Add policy.txt with 34 OPA-ish policy expressions (Kubernetes admission control patterns) - Add rls-templates.txt with 17 RLS policy template expressions (direct_owner, membership, etc.) - Fix converter to handle index access operator '[]' (was only handling 'index') - Fix converter to handle unary negation '!_' with single node args (not array) - Note: @marcbachmann/cel-js does not support bitwise AND (&) operator Round-trip test results: - basic.txt: 16/16 pass - policy.txt: 34/34 pass - rls-templates.txt: 17/17 pass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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