refactor(engine): generalize and simplify code schema definition#2126
refactor(engine): generalize and simplify code schema definition#2126asrcpq wants to merge 4 commits into
Conversation
db8408f to
25283ec
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2126 +/- ##
=====================================
Coverage 7.86% 7.86%
=====================================
Files 224 224
Lines 37600 37600
=====================================
Hits 2956 2956
Misses 34391 34391
Partials 253 253
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
25283ec to
0fbb1fd
Compare
There was a problem hiding this comment.
Pull request overview
Refactors the Code schema definition in the engine: replaces the per-action JSON Schema Code/CodeType definitions with an inline custom schema fragment ({"type": "code", "codeTypes": [...]}), and introduces a const-generic Code<MASK> Rust type so that fields can restrict accepted code types at compile-time (e.g. FeatureFilter's condition expression now only accepts flowExpr). Custom Serialize/Deserialize/JsonSchema impls back the new representation. Generated schemas (per-locale + mdbook docs) and i18n files are updated accordingly, and the workspace version is bumped to 0.0.377.
Changes:
- New const-generic
Code<MASK>with custom serde + non-referenceableJsonSchemaemittingtype: "code"and a filteredcodeTypeslist, plus deserialize-time validation against the mask. FeatureFilter.Condition.exprnow usesCode<{ CodeType::FlowExpr as u32 }>to restrict toflowExpronly.- Regenerated schema JSONs, mdbook docs, and i18n files to remove inline
Code/CodeTypedefinitions and inline the new representation.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| engine/runtime/types/src/expr.rs | Adds const-generic Code<MASK>, manual serde + custom JsonSchema, removes Expr::compile. |
| engine/runtime/action-processor/src/feature/filter.rs | Uses Code<{ CodeType::FlowExpr as u32 }> for condition expressions. |
| engine/schema/actions.json (and _en/_es/_fr/_ja/_zh) | Regenerated schemas with inline type: "code"/codeTypes and removed Code/CodeType definitions. |
| engine/schema/i18n/actions/*.json | Removed obsolete Code entries from definitionI18n. |
| engine/docs/mdbook/src/action.md | Regenerated mdbook docs to match new schemas. |
| engine/Cargo.toml, engine/Cargo.lock | Workspace version bump to 0.0.377. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1e7da19 to
49ac84c
Compare
Overview
Currently Code in schema is a fixed type, so all code fields must have identical allowed language list.
This PR adds const generics to define accepted code types optionally for some fields. For example, conditions in FeatureFilter should not take plain string literal types. This PR also updates schema to pass the accepted types to the frontend.
Example
Feature filter's condition. Before:
Code definition repeated every action, also impossible to express acceptable codeTypes.
This PR: