Skip to content

Commit a2b63c1

Browse files
authored
feat!: Bump openjd-* Rust crates to the 0.10.0 release (#373)
* chore(deps): Bump openjd-* Rust crates to the 0.10.0 release openjd-rs released on 2026-09-28: openjd-expr 0.10.0, openjd-model 0.10.0, openjd-sessions 0.7.1 (OpenJobDescription/openjd-rs#408). This package pinned 0.9.0 / 0.9.0 / 0.7.0. openjd-sessions 0.7.1 is a transitive re-pin with no source change. Two breaking changes, both features: - #409 makes template::AmountRequirement::name and template::AttributeRequirement::name a FormatString instead of a String, so a capability name may contain expressions (openjd-specifications#189). The §3.3.1.1 / §3.3.2.1 constraints now apply to the resolved name. - #407 requires create_job's context to cover the template's declared extensions. With mismatch impossible, the job-creation resolved-value checks report every evaluation error instead of silently skipping it. Only #409 broke compilation, in four places: the two template-type constructors and the two name getters. The Python-facing `name` stays a `str` holding the raw template text. v0 models these as AmountCapabilityName / AttributeCapabilityName, both subclasses of v0's FormatString, which subclasses str -- so exposing an openjd.expr .FormatString here would make v0 and v1 diverge where they agree, and .raw() is what #409 prescribes for reading these fields. One behaviour change falls out of the adaptation rather than upstream: the constructor parses, so a malformed format string now raises ExpressionError. create_job needed no code change. The binding derives its context from job_template.default_validation_context() when the caller passes none, which covers the template's extensions by construction; a caller-supplied mismatched context is what #407 now rejects, and the binding surfaces it. #407 is a squash of five commits whose message documents three behaviour changes the release changelog and the PR body do not name: - eval_boolop no longer suppresses budget errors in operands after an unresolved one, the same bypass eval_ifexp had. - A list comprehension over a *concrete* iterable whose filter evaluates unresolved concludes unresolved[list[T]] instead of hard-erroring. This was a defect that predated the release, masked by the lenient policy #407 deleted, and reachable only at job creation -- the one stage where the iterable is concrete and the filter is not. - Template validation and create_job's re-checks evaluate under PathFormat::Posix, so validation outcomes no longer depend on the host OS. Windows-only in effect; unverified locally. Verified: 6243 passed / 24 skipped / 3 xfailed, coverage 94.22%. The three xfails are the pre-existing openjd.expr known gaps; none flipped. ruff, black, mypy, cargo fmt and clippy clean. Every behaviour change above was measured through this package's public API against both 0.9.0 and 0.10.0, and the openjd.expr expectations are taken from the upstream assertions in test_unresolved_eval.rs and test_memory.rs. Four mutants, each rebuilt and each caught: reverting the three pins kills 53 of the new cases, the two __repr__ sites kill 2, the two name getters kill 11, and swallowing the name parse error kills 2. Each was restored byte-for-byte with the bytecode cache cleared between runs. THIRD-PARTY-LICENSES.txt moves only the three version lines; the release pulled in no new transitive crates. Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com> * fix: Expose the capability name as a FormatString, not a str Review feedback on #373: consistency with the other v1 fields beats consistency with v0 here. openjd-rs#409 made template::AmountRequirement::name and template::AttributeRequirement::name a FormatString. The first pass kept the Python-facing `name` a `str` and parsed on the way in, on the grounds that v0 models these as AmountCapabilityName / AttributeCapabilityName, both subclasses of v0's FormatString, which subclasses str. That argument looks at the wrong neighbour: every other FormatString-typed field on the v1 template types -- `min`, `max`, `anyOf`, `allOf`, `Action.command` -- is an openjd.expr.FormatString and refuses a bare str. `name` now matches them. This deletes more than it adds. parse_capability_name and its doc comment go away, because the FormatString arrives already parsed, and both constructors go back to being infallible. Validation moves to where it belongs: a malformed name is rejected by FormatString's own constructor rather than by a str-typed field that parses behind the caller's back. __repr__ keeps .raw(), matching Action's treatment of its command. This is a breaking change to the v1 Python API, and two pre-existing tests prove it: TestPickle::test_amount_requirement and test_attribute_requirement both passed `name=` a str, and TestStepTemplate::test_host_requirements compared `.name` to one. All three are updated, so this is a behaviour change and not a refactor. Also from review: the spec edit that changed the documented ModelProfile repr to `revision=v2023_09` was wrong -- PyModelProfile::__repr__ still emits the uppercase-V form (rust-bindings/src/model/profile.rs:397), measured as `ModelProfile(revision=V2023_09, extensions=[EXPR])`. Reverted. The two `SpecificationRevision.v2023_09` corrections in the same block stand: that repr is lowercase (profile.rs:63) and `V2023_09` is not an attribute at all. The divergence between the two reprs is pre-existing and left alone here. Verified: 6245 passed / 24 skipped / 3 xfailed, coverage 94.32%. ruff, black, mypy, cargo fmt and clippy clean. Four mutants, each rebuilt and each caught: reverting the pins to 0.9.0 kills 68 cases, formatting the FormatString in both __repr__ sites kills 2, both getters returning a constant kills 12, and both constructors discarding the supplied name kills 10. Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com> --------- Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
1 parent ff0c08c commit a2b63c1

11 files changed

Lines changed: 1096 additions & 44 deletions

File tree

‎Cargo.lock‎

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎THIRD-PARTY-LICENSES.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,9 +2741,9 @@ limitations under the License.
27412741
** itoa; version 1.0.18 -- https://crates.io/crates/itoa
27422742
** libc; version 0.2.189 -- https://crates.io/crates/libc
27432743
** manyhow-macros; version 0.11.4 -- https://crates.io/crates/manyhow-macros
2744-
** openjd-expr; version 0.9.0 -- https://crates.io/crates/openjd-expr
2745-
** openjd-model; version 0.9.0 -- https://crates.io/crates/openjd-model
2746-
** openjd-sessions; version 0.7.0 -- https://crates.io/crates/openjd-sessions
2744+
** openjd-expr; version 0.10.0 -- https://crates.io/crates/openjd-expr
2745+
** openjd-model; version 0.10.0 -- https://crates.io/crates/openjd-model
2746+
** openjd-sessions; version 0.7.1 -- https://crates.io/crates/openjd-sessions
27472747
** pin-project-lite; version 0.2.17 -- https://crates.io/crates/pin-project-lite
27482748
** portable-atomic; version 1.15.0 -- https://crates.io/crates/portable-atomic
27492749
** proc-macro2; version 1.0.107 -- https://crates.io/crates/proc-macro2

‎rust-bindings/Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ name = "_openjd_rs"
1212
crate-type = ["cdylib", "rlib"]
1313

1414
[dependencies]
15-
openjd-expr = "0.9.0"
16-
openjd-model = "0.9.0"
17-
openjd-sessions = "0.7.0"
15+
openjd-expr = "0.10.0"
16+
openjd-model = "0.10.0"
17+
openjd-sessions = "0.7.1"
1818
tokio = { version = "1", features = ["rt-multi-thread"] }
1919
uuid = { version = "1", features = ["v4"] }
2020
serde_json = "1"

‎rust-bindings/src/model/template_types.rs‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -979,19 +979,25 @@ pub(crate) struct PyAmountRequirement {
979979
impl PyAmountRequirement {
980980
#[new]
981981
#[pyo3(signature = (*, name, min=None, max=None))]
982-
fn new(name: String, min: Option<PyFormatString>, max: Option<PyFormatString>) -> Self {
982+
fn new(name: PyFormatString, min: Option<PyFormatString>, max: Option<PyFormatString>) -> Self {
983983
PyAmountRequirement {
984984
inner: AmountRequirement {
985-
name,
985+
name: name.inner,
986986
min: min.map(|fs| fs.inner),
987987
max: max.map(|fs| fs.inner),
988988
},
989989
}
990990
}
991991

992+
/// `@fmtstring` as of openjd-rs#409: a name may carry expressions, and its
993+
/// §3.3.1.1 constraints are checked on the resolved value. Use `.raw()` for
994+
/// the template text. The job-side `AmountRequirement.name` is the resolved
995+
/// `str`.
992996
#[getter]
993-
fn name(&self) -> &str {
994-
&self.inner.name
997+
fn name(&self) -> PyFormatString {
998+
PyFormatString {
999+
inner: self.inner.name.clone(),
1000+
}
9951001
}
9961002

9971003
#[getter]
@@ -1011,7 +1017,7 @@ impl PyAmountRequirement {
10111017
}
10121018

10131019
fn __repr__(&self) -> String {
1014-
format!("AmountRequirement(name={:?})", self.inner.name)
1020+
format!("AmountRequirement(name={:?})", self.inner.name.raw())
10151021
}
10161022

10171023
#[allow(clippy::type_complexity)]
@@ -1054,22 +1060,28 @@ impl PyAttributeRequirement {
10541060
#[new]
10551061
#[pyo3(signature = (*, name, any_of=None, all_of=None))]
10561062
fn new(
1057-
name: String,
1063+
name: PyFormatString,
10581064
any_of: Option<Vec<PyFormatString>>,
10591065
all_of: Option<Vec<PyFormatString>>,
10601066
) -> Self {
10611067
PyAttributeRequirement {
10621068
inner: AttributeRequirement {
1063-
name,
1069+
name: name.inner,
10641070
any_of: any_of.map(|v| v.into_iter().map(|fs| fs.inner).collect()),
10651071
all_of: all_of.map(|v| v.into_iter().map(|fs| fs.inner).collect()),
10661072
},
10671073
}
10681074
}
10691075

1076+
/// `@fmtstring` as of openjd-rs#409: a name may carry expressions, and its
1077+
/// §3.3.2.1 constraints are checked on the resolved value. Use `.raw()` for
1078+
/// the template text. The job-side `AttributeRequirement.name` is the
1079+
/// resolved `str`.
10701080
#[getter]
1071-
fn name(&self) -> &str {
1072-
&self.inner.name
1081+
fn name(&self) -> PyFormatString {
1082+
PyFormatString {
1083+
inner: self.inner.name.clone(),
1084+
}
10731085
}
10741086

10751087
#[getter]
@@ -1103,7 +1115,7 @@ impl PyAttributeRequirement {
11031115
}
11041116

11051117
fn __repr__(&self) -> String {
1106-
format!("AttributeRequirement(name={:?})", self.inner.name)
1118+
format!("AttributeRequirement(name={:?})", self.inner.name.raw())
11071119
}
11081120

11091121
#[allow(clippy::type_complexity)]

‎specs/python-expr-interface.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,27 @@ never raises (Python convention). This makes unresolved values
255255
safe to inspect in debuggers and tracebacks while still failing
256256
loudly anywhere a real value is expected.
257257

258+
**How an unresolved operand propagates.** Three rules are worth stating,
259+
because each decides whether an expression errors or concludes unresolved,
260+
and all three changed in openjd-expr 0.10.0 (openjd-rs#407):
261+
262+
* A conditional whose test is unresolved evaluates both branches. A *value*
263+
error in one branch is absorbed — run time may select the healthy one — but
264+
a memory or operation *budget* exceedance propagates, because the budget was
265+
spent in this evaluation whichever branch run time takes.
266+
* `and` / `or` behave the same way for operands after the first unresolved
267+
one: value errors are suppressed for the same short-circuit reason, budget
268+
exceedances are not.
269+
* A list comprehension whose filter evaluates unresolved concludes
270+
`unresolved[list[T]]` rather than erroring, whether the iterable is
271+
unresolved or concrete. Per-element inclusion is undecidable, so the
272+
elements accumulated so far are abandoned. `T` is the body's type derived
273+
under an *unresolved* loop variable, so evaluating the body on an element the
274+
run-time filter may exclude cannot raise a spurious value error:
275+
`[10 // x for x in [0, 2] if x > N]` with `N` unresolved is
276+
`unresolved[list[int]]`, not a division-by-zero. A filter whose type can
277+
never be a boolean is still an error.
278+
258279
### `SymbolTable`
259280

260281
Hierarchical key-value store providing variable bindings for expression

‎specs/python-model-interface.md‎

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,10 @@ cancel.notify_period_in_seconds # Optional[int]
795795
Job-time host requirements. Distinct from the template-time
796796
``HostRequirements`` / ``AmountRequirement`` / ``AttributeRequirement``
797797
(see `openjd.model._v1.template`): the template-time variants carry
798-
unresolved ``FormatString`` values for ``min`` / ``max`` / ``anyOf`` /
799-
``allOf``, while these job-time variants carry the post-``create_job``
800-
resolved ``f64`` (amounts) and ``str`` (attributes) values.
798+
unresolved ``FormatString`` values for ``name``, ``min`` / ``max`` / ``anyOf``
799+
/ ``allOf``, while these job-time variants carry the post-``create_job``
800+
resolved ``str`` name and the resolved ``f64`` (amounts) and ``str``
801+
(attributes) values.
801802

802803
```python
803804
hr = step.host_requirements # alias: step.hostRequirements
@@ -955,16 +956,38 @@ hr.amounts # Optional[list[AmountRequirement]]
955956
hr.attributes # Optional[list[AttributeRequirement]]
956957

957958
amt = hr.amounts[0]
958-
amt.name # str
959+
amt.name # FormatString — raw, may hold expressions
959960
amt.min # Optional[FormatString]
960961
amt.max # Optional[FormatString]
961962

962963
attr = hr.attributes[0]
963-
attr.name # str
964+
attr.name # FormatString — raw, may hold expressions
964965
attr.any_of # Optional[list[FormatString]] (alias: anyOf)
965966
attr.all_of # Optional[list[FormatString]] (alias: allOf)
966967
```
967968

969+
`name` is `@fmtstring` (§3.3.1, §3.3.2): `"{{Param.FleetAttribute}}"` is a
970+
valid template-time name, and the §3.3.1.1 / §3.3.2.1 capability-name
971+
constraints apply to the *resolved* name. Which stage applies them depends on
972+
when the name's value becomes known:
973+
974+
| Name | Checked at | Applied |
975+
|---|---|---|
976+
| literal | decode | pattern, length, reserved scopes, uniqueness, standard-capability values |
977+
| fully static — `{{ 'attr.custom.x' }}`, or built only from `let` bindings with literal values | decode | the same set, against the resolved text |
978+
| partly static — `"amount.custom.<95 chars>{{Param.X}}"` | decode | the length *lower bound*: `resolves to at least 109 characters, exceeding the maximum of 100.` |
979+
| parameter-dependent | `create_job` | pattern, length, reserved scopes, case-insensitive uniqueness within `amounts` and within `attributes`, and the standard-capability value rules the resolved name selects |
980+
981+
A name is resolved at job creation, so only symbols available there are in
982+
scope for it: `Task.Param.*` in a name is rejected at decode as an undefined
983+
variable even where the same symbol is valid elsewhere in the step.
984+
985+
`name` is an `openjd.expr.FormatString`, like every other FormatString-typed
986+
field on the template types, so reading the template text needs `.raw()` and
987+
constructing one needs `FormatString(...)` rather than a bare `str`. On 0.9.0
988+
it was a `str` in both directions. The job-side `AmountRequirement.name` /
989+
`AttributeRequirement.name` are still `str`: they hold the resolved name.
990+
968991
### `StepDependency`
969992

970993
```python
@@ -1372,25 +1395,49 @@ template = decode_job_template(template={...}, supported_extensions=["EXPR"])
13721395

13731396
# 2. Read the template's declared profile back out.
13741397
profile = template.profile # ModelProfile(revision=V2023_09, extensions=[EXPR])
1375-
profile.revision # SpecificationRevision.V2023_09
1398+
profile.revision # SpecificationRevision.v2023_09
13761399
profile.extensions # [ModelExtension.EXPR]
13771400
profile.has_extension(ModelExtension.EXPR) # True
13781401

1379-
# 3. Build it manually if needed (e.g. when validating against a different
1380-
# policy than the template declared).
1402+
# 3. Build it manually if needed (e.g. to enable an extension the template
1403+
# does not declare, or to carry caller limits).
13811404
manual = ModelProfile(extensions=[ModelExtension.EXPR, ModelExtension.TASK_CHUNKING])
1382-
ModelProfile.from_strings(SpecificationRevision.V2023_09, ["EXPR"])
1405+
ModelProfile.from_strings(SpecificationRevision.v2023_09, ["EXPR"])
13831406

1384-
# 4. Pass to create_job through a ValidationContext if you want to
1385-
# override the template's default validation context.
1407+
# 4. Pass to create_job through a ValidationContext, usually to attach
1408+
# caller limits. The context must COVER the template: same revision, and
1409+
# every extension the template declares (enabling more is fine).
13861410
limits = CallerLimits(max_step_count=100, max_task_count=10_000)
1387-
ctx = ValidationContext(profile, caller_limits=limits)
1411+
ctx = ValidationContext(template.profile, caller_limits=limits)
13881412
job = create_job(
13891413
job_template=template,
13901414
job_parameter_values={...},
13911415
validation_context=ctx, # optional; defaults to template.default_validation_context()
13921416
)
1417+
```
13931418

1419+
A context that strips an extension the template declares raises
1420+
`ModelValidationError`:
1421+
`create_job requires a context enabling every extension the template declares:
1422+
missing EXPR.` An application that does not support an extension rejects the
1423+
template at decode, via `supported_extensions`, rather than at job creation.
1424+
Deriving the context from `template.profile` — or omitting it — satisfies the
1425+
contract by construction.
1426+
1427+
Because the context contract makes every evaluation error at job creation a
1428+
real defect, `create_job` reports them all. A value-dependent failure —
1429+
`args: ["{{ 10 // Param.N }}"]` with `N = 0` — fails `create_job` rather than
1430+
every session that runs the task. Lowered `max_eval_memory_bytes` /
1431+
`max_eval_operations` are enforced inside a conditional whose test only a
1432+
worker can resolve, which is the idiomatic construction for one.
1433+
1434+
Validation outcomes do not depend on the host operating system. Every stage
1435+
that evaluates outside host context — template validation and every resolution
1436+
`create_job` performs, including its resolved-value re-checks — evaluates
1437+
under the POSIX path format, so a PATH value flowing through a `let` binding
1438+
into an argument validates identically on Windows and POSIX.
1439+
1440+
```python
13941441
# 5. Bridge to the expression engine.
13951442
from openjd.expr import HostContext
13961443
expr_profile = profile.to_expr_profile(HostContext.unresolved())

‎src/openjd/_openjd_rs.pyi‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2772,15 +2772,22 @@ class TemplateAction:
27722772
@typing.final
27732773
class TemplateAmountRequirement:
27742774
@property
2775-
def name(self) -> builtins.str: ...
2775+
def name(self) -> FormatString:
2776+
r"""
2777+
`@fmtstring` as of openjd-rs#409: a name may carry expressions, and its
2778+
§3.3.1.1 constraints are checked on the resolved value. Use `.raw()` for
2779+
the template text. The job-side `AmountRequirement.name` is the resolved
2780+
`str`.
2781+
"""
2782+
27762783
@property
27772784
def min(self) -> typing.Optional[FormatString]: ...
27782785
@property
27792786
def max(self) -> typing.Optional[FormatString]: ...
27802787
def __new__(
27812788
cls,
27822789
*,
2783-
name: builtins.str,
2790+
name: FormatString,
27842791
min: typing.Optional[FormatString] = None,
27852792
max: typing.Optional[FormatString] = None,
27862793
) -> TemplateAmountRequirement: ...
@@ -2790,7 +2797,14 @@ class TemplateAmountRequirement:
27902797
@typing.final
27912798
class TemplateAttributeRequirement:
27922799
@property
2793-
def name(self) -> builtins.str: ...
2800+
def name(self) -> FormatString:
2801+
r"""
2802+
`@fmtstring` as of openjd-rs#409: a name may carry expressions, and its
2803+
§3.3.2.1 constraints are checked on the resolved value. Use `.raw()` for
2804+
the template text. The job-side `AttributeRequirement.name` is the
2805+
resolved `str`.
2806+
"""
2807+
27942808
@property
27952809
def any_of(self) -> typing.Optional[builtins.list[FormatString]]: ...
27962810
@property
@@ -2802,7 +2816,7 @@ class TemplateAttributeRequirement:
28022816
def __new__(
28032817
cls,
28042818
*,
2805-
name: builtins.str,
2819+
name: FormatString,
28062820
any_of: typing.Optional[typing.Sequence[FormatString]] = None,
28072821
all_of: typing.Optional[typing.Sequence[FormatString]] = None,
28082822
) -> TemplateAttributeRequirement: ...

0 commit comments

Comments
 (0)