Commit 8eae8ae
authored
feat: Implement WRAP_ACTIONS with EXPR binding to RS (#285)
* feat: Implement WRAP_ACTIONS with EXPR binding to RS
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
* feat: Pass conformance test
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
* feat: add build_symbol_table binding for typed EXPR symbol tables
Add a build_symbol_table #[pyfunction] that constructs a typed
openjd-expr SymbolTable from a flat dotted-key value map plus an
optional per-key EXPR type-spec map. String values are coerced to
their declared type via ExprValue::from_str_coerce and dotted keys
are nested into subtables.
This moves the typed symbol-table construction next to the engine
(previously a string-coercion + nesting dance in the Python
_expr_support bridge), keeping value typing consistent with
evaluation and giving correct native-aggregate inference. The
OpenJD-type -> EXPR-type-spec mapping stays on the Python side and is
passed in as resolved spec strings.
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
* feat: expr and wrap_actions pr comments
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
* feat: v0 parity for RFC 0007 typed params and RFC 0008 wrap-action rules
Close the remaining pure-Python v0 vs Rust gaps for the EXPR / WRAP_ACTIONS
extensions in the default model path:
- RFC 0007: v0 create_job can now instantiate jobs that declare BOOL,
RANGE_EXPR, and LIST[*] parameters. Their values are carried natively
(lists/bools) through preprocessing into the JobParameter, and the typed
EXPR symbol table (build_symbol_table) coerces them, rather than the
string-only handling used by the original scalar types. ParameterValueType,
ParameterValue.value, and JobParameter.value are extended accordingly, and
the parameter merge skips the legacy scalar-only constraint merging (and the
EXPR-gated re-parse) for the new types.
- RFC 0008 single-wrap-layer: JobTemplate now rejects more than one
wrap-defining environment reachable in any session stack (jobEnvironments
plus one step's stepEnvironments), mirroring openjd-rs wrap_actions.rs.
- RFC 0008 wrapped-variable scoping: EnvironmentActions now rejects
WrappedAction.* outside the wrap hooks, WrappedEnv.* outside the env
enter/exit hooks, and WrappedStep.* outside the task-run hook.
Runtime action-wrapping (RFC 0008 execution) lives in
openjd-sessions-for-python and is tracked as a separate change.
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
* feat: reuse Rust via bindings to simplify the EXPR model glue
Replace hand-maintained Python logic in the v0 model's EXPR glue with thin
calls into the Rust bindings, so the behaviour is single-sourced in the
openjd crates:
- job_parameter_type_expr_spec: maps an OpenJD job-parameter type name
(case-insensitive) to its EXPR type spec by reusing the crate's
JobParameterType::from_spec_str + expr_type(). Removes the hand-maintained
_OPENJD_TYPE_TO_EXPR_TYPE table and the recursive LIST[...] unwrap from
_expr_support.py; the OpenJD-type -> EXPR-type contract (incl. nested
LIST[LIST[INT]]) now lives only in the openjd-model crate. RANGE_EXPR now
maps to the engine's range_expr type.
- ParsedExpression.typecheck: type-checks an expression against typed
(unresolved) symbol placeholders without extracting a result. Lets
validate_typed_expression drop its brittle error-message sniffing
("unresolved" / "Cannot extract value") — a well-typed but runtime-dependent
expression now simply type-checks Ok in Rust instead of surfacing a
boundary error the Python had to recognise by string.
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
* feat: scope-check timeout format strings and cover RANGE_EXPR typed validation
RFC 0008 wrapped-variable scoping: _action_referenced_namespaces now also
inspects an Action's timeout field, which is a FormatString under the
FEATURE_BUNDLE_1 extension. Previously only command/args were scanned, so a
WrappedAction.*/WrappedEnv.*/WrappedStep.* reference smuggled into a timeout
expression bypassed the per-hook scope rule. Non-FormatString timeouts (plain
ints) are skipped by the existing isinstance guard.
RFC 0007 RANGE_EXPR: add tests pinning the typed-validation behaviour now that
the OpenJD-type -> EXPR-type mapping resolves RANGE_EXPR to the engine's
range_expr type (previously None, which fell back to name-only validation).
Valid range_expr ops (subscript, len, list) type-check; genuine type errors
(arithmetic, invalid methods) are now caught at decode time. Covered at the
ExprNode seam and end-to-end through decode_job_template.
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
* feat: harden EXPR/WRAP_ACTIONS v0 model — spec string coercion, value constraints, lazy import
Address six review findings on the EXPR (RFC 0005-0007) / WRAP_ACTIONS (RFC
0008) support in the pure-Python (v0) model:
- EXPR results interpolated into format strings now use the engine's
RFC 0005 string coercion (true/false, double-quoted list items, preserved
Decimal trailing zeros; null -> empty string) instead of Python str() of the
native value, which emitted Python reprs (True/None/['a', 'b']). Adds
evaluate_to_str() to the node/expression seam; evaluate() still returns the
native value.
- create_job/preprocess now enforce item/length/range constraints on
user-supplied LIST[*] and RANGE_EXPR values (previously only the template
default was validated at decode time).
- Merged EXPR defaults are re-validated against the surviving definition's
constraints before model_copy (which skips validators), so a default carried
over from another source can no longer bypass them.
- SymbolTable.expr_types is now a first-class field copied by __init__ and
union(), instead of a dynamic attribute that derived/unioned tables dropped.
- The EXPR_EXTENSION gate constant moved to _parser so importing the parser no
longer eagerly loads the Rust expr surface on the non-EXPR path.
- Collapsed the eight near-identical JobList*/RangeExpr definitions onto a
shared base, and single-sourced the triplicated task-parameter range gate.
Adds 27 regression unit tests covering each fix.
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
* test: cover create_job instantiation of WRAP_ACTIONS templates
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
---------
Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>1 parent 8f1f9f1 commit 8eae8ae
30 files changed
Lines changed: 3206 additions & 94 deletions
File tree
- rust-bindings/src
- expr
- model
- src/openjd
- model
- _format_strings
- _internal
- v2023_09
- test/openjd/model_v0
- format_strings
- v2023_09
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
95 | 126 | | |
96 | 127 | | |
97 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| |||
324 | 328 | | |
325 | 329 | | |
326 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| |||
231 | 232 | | |
232 | 233 | | |
233 | 234 | | |
| 235 | + | |
234 | 236 | | |
235 | 237 | | |
236 | 238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
307 | 323 | | |
308 | 324 | | |
309 | 325 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1780 | 1780 | | |
1781 | 1781 | | |
1782 | 1782 | | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
1783 | 1789 | | |
1784 | 1790 | | |
1785 | 1791 | | |
| |||
3567 | 3573 | | |
3568 | 3574 | | |
3569 | 3575 | | |
| 3576 | + | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
3570 | 3585 | | |
3571 | 3586 | | |
3572 | 3587 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| |||
70 | 76 | | |
71 | 77 | | |
72 | 78 | | |
| 79 | + | |
73 | 80 | | |
74 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
75 | 91 | | |
76 | 92 | | |
77 | 93 | | |
| |||
104 | 120 | | |
105 | 121 | | |
106 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
107 | 129 | | |
108 | 130 | | |
109 | 131 | | |
| |||
123 | 145 | | |
124 | 146 | | |
125 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
126 | 156 | | |
127 | | - | |
| 157 | + | |
128 | 158 | | |
129 | 159 | | |
130 | 160 | | |
| |||
312 | 342 | | |
313 | 343 | | |
314 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
315 | 350 | | |
| 351 | + | |
| 352 | + | |
316 | 353 | | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
323 | 360 | | |
324 | 361 | | |
325 | 362 | | |
| |||
0 commit comments