Commit 845b8cf
feat(#195): Python per-capability origin validation + native typing (cross-port parity)
Mirrors the committed TS reference (63943d0 validation, aff49ce typing) into the
Python port: the four #195 capabilities are now validated + typed identically.
- validation_passes.py: ports the closed expression grammar (validate_expr_node +
infer_expr_type, mirroring meta-attr-expression.ts) + the shared _validate_order_by_keys
helper, and the per-@agg branches — any/all (boolean non-array; @filter required; @Of
forbidden; @via required + to-many), collect (isArray; @Of required + element-type
preservation; @distinct/@orderby collect-only + mutually exclusive; @orderby resolves on
the @Of entity), the inverse rule (non-collect ⇒ isArray:false), origin.computed
(structural grammar → ERR_UNKNOWN_EXPR_NODE; inference vs base effective fields; type
mismatch → ERR_COMPUTED_TYPE_MISMATCH), origin.first (@Of required + type-preserving;
not @required; @via inference; @orderby resolution).
- errors.py: ERR_UNKNOWN_EXPR_NODE + ERR_COMPUTED_TYPE_MISMATCH.
- entity_model.py: origin_guaranteed_non_null — any/all/collect projection DTO fields
non-null; first Optional; computed conservative-nullable.
- origin_constants.py: AGG_ANY/AGG_ALL/AGG_COLLECT.
- test_validation_origin_195.py: 20 tests mirroring the TS suite.
Verified: conformance 336 + the 20 validation tests = 356 passed; error CODES identical to
TS (message text keeps Python phrasing — conformance compares codes). Tier-3: the expression
grammar lives in validation_passes.py (beside ops_for_subtype) to avoid an import cycle.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NGQ7oSuNcjhsMHWwZzhBwr1 parent aff49ce commit 845b8cf
5 files changed
Lines changed: 775 additions & 13 deletions
File tree
- server/python
- src/metaobjects
- codegen/generators
- loader
- meta/persistence/origin
- tests/unit
Lines changed: 33 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
18 | 25 | | |
19 | 26 | | |
20 | 27 | | |
| |||
221 | 228 | | |
222 | 229 | | |
223 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
224 | 247 | | |
225 | 248 | | |
226 | 249 | | |
| |||
243 | 266 | | |
244 | 267 | | |
245 | 268 | | |
246 | | - | |
247 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
248 | 276 | | |
249 | 277 | | |
250 | 278 | | |
251 | 279 | | |
252 | | - | |
| 280 | + | |
253 | 281 | | |
254 | | - | |
| 282 | + | |
255 | 283 | | |
256 | 284 | | |
257 | 285 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
| |||
0 commit comments