Skip to content

feat!: Bump the bindings to openjd-expr 0.18.1, openjd-model 0.18.0 and openjd-sessions 0.12.1 - #397

Open
leongdl wants to merge 11 commits into
OpenJobDescription:mainlinefrom
leongdl:bump/openjd-rs-0.18
Open

leongdl wants to merge 11 commits into
OpenJobDescription:mainlinefrom
leongdl:bump/openjd-rs-0.18

Conversation

@leongdl

@leongdl leongdl commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Bumps the bindings to the openjd-rs release in OpenJobDescription/openjd-rs#645: openjd-expr 0.15.0 → 0.18.1, openjd-model 0.16.0 → 0.18.0 and openjd-sessions 0.10.0 → 0.12.1. It also binds the new public API, ENV_PARAMS included, and pins every upstream change a Python caller can see.

What changed

Binding changes the new crates needed

  • ExprType constructors, nullable() and substitute() raise ExpressionError for a type deeper than 64 levels (openjd-rs#578). openjd.expr.MAX_TYPE_DEPTH is exported.
  • TaskParameter::Int lost its unused chunks field (openjd-rs#612).
  • Environment, StepDependency and CallerLimits gained fields (openjd-rs#641).

New public API

  • ENV_PARAMS, as public API. These new fields and types follow the camelCase alias convention, and they pickle:

    • TemplateEnvironment: env_parameter_definitions, activation, effective_activation, host_requirements, enable_if, exclusive_group.
    • TemplateStepDependency: step, environment, required, enable_if, parameters, step_name(), environment_name(), is_required(). depends_on is now optional, and the class compares by value.
    • New types EnvironmentActivation, ExprField, EnvironmentParameterDefinition, and ModelExtension.ENV_PARAMS.
    • CallerLimits(max_step_environment_entries=..., accept_unreleased_env_params=...).

    openjd-model marks ENV_PARAMS unstable. Decoding accepts it only with accept_unreleased_env_params=True, and job creation doesn't read the fields yet. The model spec has an "ENV_PARAMS (unstable)" section that says so.

  • EnvironmentTemplate.profile, TaskParameterType.expr_type() and raw_expr_type() (openjd-rs#638).

  • create_environment(env_template, *, job_parameter_values=None). With values, the Environment gets the filtered table that create_job gives a Job Environment. An Environment Template whose wrap hooks read its own Param.* needs it when it wraps a Job Environment from create_job.

Fixes found in review

  • Job.parameters keeps openjd-model's order again: definition order, then environment-template entries by name (openjd-rs#639). The getter used to collect into a HashMap.
  • The pure-Python model checks a TEMPLATE-scope EXPR expression without a host context, as openjd-model does. After openjd-rs#611 it had stopped refusing name: "{{ int(path('a/b').name) }}", and create_job failed later. It also refuses apply_path_mapping in a step let.
  • CallerLimits has a Python repr, and ExprField and StepDependency parameter values are read the way decoding reads them.

Pinned upstream changes. Each has a test, and a spec sentence that cites the PR and crate version. The commit messages list them in full. The main ones:

  • Clearer validation errors with field paths (openjd-rs#634).
  • Format-string fields refuse numbers and booleans, and templates without EXPR refuse complex expressions in every field (openjd-rs#633).
  • round(x, n<=0) returns an int (openjd-rs#567).
  • The regex cache counts toward the memory budget (openjd-rs#368).
  • re_sub control characters and surrogate escapes (openjd-rs#570).
  • Subscript receiver checks (openjd-rs#626).
  • In sessions: the enter-time table on exit (openjd-rs#632), CHUNK[INT] values bound as range expressions (openjd-rs#638), and PATH values that aren't paths fail the action (openjd-rs#639).

Breaking changes

These are listed in the BREAKING CHANGE: footers:

  • ExprType: constructors raise past 64 levels of nesting.
  • Template types: TemplateStepDependency.depends_on is optional and the class is unhashable.
  • v1 decoding:
    • It refuses numbers and booleans in format-string fields, complex expressions without EXPR, and empty descriptions.
    • An ENV_PARAMS key in a template without ENV_PARAMS raises ModelValidationError where it used to raise DecodeValidationError.
    • Two CHUNK[INT] parameters in one space are refused.
    • minLength and maxLength of STRING and PATH count characters rather than bytes.
  • openjd.expr: round() changes type, and the regex limits and re_sub rules are stricter.
  • Sessions:
    • CHUNK[INT] and PATH values must be range expressions and paths.
    • exit_environment with no table reuses the enter-time table.
    • Task.RawParam of a PATH task parameter is a string.
    • A CHUNK[INT] value given as TaskParameterValue, as the worker agent passes it, is bound in canonical range form: 1,3,5 is 1-5:2. The pure-Python openjd.sessions.Session still binds the text unchanged.
  • v0: it refuses a TEMPLATE-scope literal-path expression that can't resolve, and a host function in a step let.

Commits

The commits follow the 0.15/0.16/0.10 bump (713af01 through 156bf03): the bump, the licenses, then one commit per review round.

  1. feat!: the bump and new API.
  2. chore: THIRD-PARTY-LICENSES.txt.
  3. fix!: round-1 review fixes and pins.
  4. fix!: round-2 review fixes and test tightening.
  5. ci: pins pip-licenses to 5.5.5 and regenerates THIRD-PARTY-LICENSES.txt. pip-licenses 6.0.0, released 2026-12-02, writes UNKNOWN for every license text, which failed the license check on this PR. The regenerated file changes only the pydantic, pydantic_core and PyYAML versions.
  6. fix: review round A, part 1. A PanicException when a caller's parameters dict changes during conversion, an ExprField NaN through an int subclass, a duplicate v0 error, and six spec sentences the review found false.
  7. fix: review round A, part 2. A wrap hook in an Environment Template lost its own Param.* when it wrapped a Job Environment from create_job. That broke the conformance test WRAP_ACTIONS/jobs/wrap-env-template-parameters-in-hooks (openjd-rs#632). create_environment gains job_parameter_values= to give the Environment the table openjd run gives it.
  8. fix: review round A, part 3. create_environment(job_parameter_values=...) converts values to their types as a Session does. The bindings that can run user code while reading a caller's dict read a snapshot of it. The CHUNK[INT] TaskParameterValue form the worker agent uses is pinned.

Review and testing

Each round used sub-agents that compared the new build against a build of 4e8ce06 through the Python API:

  • Round 1 had four reviewers: binding code, expr, model and sessions. Round 1 found the two regressions above and about 40 unpinned changes.
  • Round 2 had three reviewers: fix verification with a v0/v1 parity matrix of about 830 cases, a test audit that ran the new tests on the old build and did read-only mutation checks, and an upstream spec diff with a 9,000-case differential fuzz. All the fuzz differences fall into pinned clusters.
  • Round 3 was a final ship review: no blockers.

Local results on Linux aarch64, Python 3.12:

  • hatch run test equivalent: 6742 passed, 26 skipped, 13 xfailed (all strict), coverage 94.35%.
  • ruff, black --check, mypy src test, cargo clippy --all-targets and cargo fmt --check are clean.
  • The regenerated stub matches the committed one.

Not run: Windows, macOS, cross-user sessions and benchmarks. The tests that assumed POSIX paths now use paths that render the same on Windows, and CI will be their first Windows run.

Follow-ups (not in this PR)

  • openjd-sessions-for-python:
    • Its pyproject.toml pins openjd-model >= 0.14, < 0.15. Raise the pin when this ships.
    • The comment at src/openjd/sessions/_v1/_session.py:258-265 says no resolved_symtab means an empty table. openjd-rs#632 made that wrong.
    • Line 247 maps timedelta(0) to None, so "terminate now" becomes "use the declared grace". This bug predates the bump.
  • Known gaps:
    • preprocess_job_parameters returns a dict in an unspecified order. This predates the bump and is now documented.
    • TemplateEnvironment compares by identity.
    • v1 doesn't check a STRING range written as one expression at decode. A strict xfail records it, and it should be reported upstream.
    • An ExprType deeper than 11 levels doesn't unpickle. A strict xfail records it.

…nd openjd-sessions 0.12.1

Move rust-bindings from openjd-expr 0.15.0, openjd-model 0.16.0 and
openjd-sessions 0.10.0 to 0.18.1, 0.18.0 and 0.12.1 (openjd-rs#645).
Cargo.lock moves the ruff_python_* crates from 0.0.21 to 0.0.22 and nix
from 0.31.3 to 0.32.0, and adds serde_path_to_error 0.1.20.

The new crates needed these binding changes:

- ExprType's constructors and substitute() are fallible
  (openjd-rs#578). ExprType(code, params), ExprType("list", params),
  ExprType.list, ExprType.union, nullable() and substitute() raise
  ExpressionError for a type deeper than MAX_TYPE_DEPTH (64), which
  openjd.expr now exports.
- job::TaskParameter::Int has no chunks field (openjd-rs#612). The
  binding never exposed it.
- template::Environment and template::StepDependency gained the
  ENV_PARAMS fields (openjd-rs#641), and StepDependency.depends_on is
  optional. CallerLimits gained max_step_environment_entries and
  accept_unreleased_env_params.

New public API:

- ENV_PARAMS, in full. TemplateEnvironment gains
  env_parameter_definitions, activation, effective_activation,
  host_requirements, enable_if and exclusive_group, as getters with
  camelCase aliases and as constructor keywords. TemplateStepDependency
  gains step, environment, required, enable_if and parameters, plus
  step_name(), environment_name() and is_required(); every constructor
  keyword is optional, as in decoding. New template types
  EnvironmentActivation, ExprField and EnvironmentParameterDefinition,
  and ModelExtension.ENV_PARAMS. CallerLimits takes
  max_step_environment_entries and accept_unreleased_env_params, and
  both take part in ==, repr and pickle. openjd-model marks ENV_PARAMS
  unstable: decoding accepts it only with
  CallerLimits(accept_unreleased_env_params=True), job creation does not
  read the fields, and ModelExtension.from_str does not parse it. The
  model spec says so.
- EnvironmentTemplate.profile, as JobTemplate.profile.
- TaskParameterType.expr_type() and raw_expr_type() (openjd-rs#638).
- TemplateEnvironment(description=...) is checked as decoding checks a
  <Description> (Template Schemas §7.2), and raises
  DecodeValidationError otherwise.

Tests changed for intended upstream changes:

- Template validation now prefixes an error with the path of the field
  that failed (openjd-rs#634): "steps[0] -> script -> actions -> onRun
  -> args[0]: Failed to parse ...". This changes the parser work-bound
  cases and one SimpleAction test.
- A subscript's receiver is checked by its type (openjd-rs#626), so an
  unresolved string index into a list reports "Cannot subscript type
  list[int] with index of type string" rather than "Index must be an
  integer".
- Compiling a regex charges one operation per pattern byte on a cache
  miss (openjd-rs#368), so re_search('a' * 500, r'b') counts 7
  operations, not 6.
- The ModelExtension drift guard lists ENV_PARAMS, and the map of
  pyclass modules lists the three new template types.

New tests pin the new API in test/openjd/model_v1/test_env_params.py,
the type depth limit, the regex compile charge and cache hit, and
EnvironmentTemplate.profile and decode-time Description checks. The
type stub is regenerated, which also picks up earlier drift: the
WRAP_ACTIONS getters on EnvironmentActions and EmbeddedFile.filename
as str. No strict xfail XPASSes.

BREAKING CHANGE: ExprType constructors, nullable() and substitute()
raise ExpressionError for a type deeper than 64 levels.
TemplateStepDependency.depends_on is Optional[str], and its constructor
keyword is optional. TemplateEnvironment(description=...) rejects a
description that decoding rejects. Template validation messages start
with the path of the field that failed, and some invalid templates report fewer or
different errors (openjd-rs#634). Validation rejects a subscript of an
unresolved path, int, float or bool, and the message for a
non-subscriptable receiver is "Cannot subscript type <type>"
(openjd-rs#626). Regex compilation counts toward the operation budget
and the regex cache toward the memory budget (openjd-rs#368).

Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
…8/0.12 bump

Regenerated the Rust section with scripts/check_third_party_licenses.sh
--update. The openjd crates' versions change, the ruff_python_* crates
and ruff_unicode_names2 move to 0.0.22, nix moves to 0.32.0, and
serde_path_to_error 0.1.20 is added. The Python section is kept as it
was: this machine's pip-licenses wrote UNKNOWN for every license text.

Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
…iew found

A first review of the bump to openjd-expr 0.18.1, openjd-model 0.18.0
and openjd-sessions 0.12.1 compared the old and new builds through the
Python API. It found two regressions, gaps in the new ENV_PARAMS
binding, and many upstream changes with no test or spec sentence.

Fixes:

- Job.parameters is a dict in openjd-model's order again: the job
  parameters of the job template in definition order, then any other entry in
  byte-wise name order (openjd-rs#639). The getter collected them into
  a HashMap, so the order changed from run to run.
- The pure-Python model checks a TEMPLATE-scope EXPR expression with no
  host context, as openjd-model does. Since openjd-expr 0.18.0
  (openjd-rs#611) the unresolved host context leaves path(...) and
  with_number unresolved, so v0 decoded
  name: "{{ int(path('a/b').name) }}" and create_job then failed. It is
  rejected at decode again, in a name, timeout, range element or step
  let, and still decodes in args.
- ENV_PARAMS binding: a FormatString parameter value without "{{" is the
  literal string, as decoding reads it. ExprField reads an int outside
  the i64 and u64 ranges as a float, as decoding does; its == returns
  NotImplemented for another type, and its repr evaluates back.
  TemplateStepDependency compares by value and is unhashable.
  EnvironmentParameterDefinition takes a FormatString default. An
  Environment with an empty env_parameter_definitions pickles.
  EnvironmentActivation members no longer equal ints.
- CallerLimits' repr writes None and numbers, not Rust's Some(..).
- Stale comments on the Int task parameter's chunks and on
  enter_environment with no resolved_symtab.

New tests pin these changes in openjd.expr:

- HostContext.unresolved() makes path(...) and with_number return
  unresolved[T] (openjd-rs#611).
- round(x, n) on a float returns an int for n <= 0, so
  string(round(2.5, 0)) is "2" (openjd-rs#567).
- A cached regex counts 1 MiB plus its length toward the memory budget,
  for at most 32 patterns (openjd-rs#368).
- re_sub refuses a control character in a replacement, and a surrogate
  escape is a syntax error (openjd-rs#570).
- A subscript of an int, float, bool or unresolved path raises "Cannot
  subscript type <type>" (openjd-rs#626).
- path([]) is path('.') (openjd-rs#576).
- -2^63 is a valid range value, and has_complex_expressions() counts a
  parenthesized name, a comment or a line continuation (openjd-rs#633).
- An ExprType 12 to 64 levels deep pickles but does not unpickle, since
  pickle goes through its type string. A strict xfail records it.

In openjd.model:

- A number or boolean in a format-string field raises
  DecodeValidationError, and without EXPR every interpolation in every
  field must be a bare name (openjd-rs#633).
- v1 reads YAML 1.2 Core, so 1e3 and 0o17 are refused where v0 reads
  strings.
- Decoding refuses an empty description, a relative working directory
  keeps a ".." it cannot cancel, -2^63 is accepted in INT and RANGE_EXPR
  values, and chunk order and sizes match v0 (openjd-rs#633).
- minLength and maxLength of STRING and PATH count characters
  (openjd-rs#615).
- A space with two CHUNK[INT] parameters is refused (openjd-rs#612).
- A command has no 1024-character cap (openjd-rs#561).
- Decode errors read "'<version>' failed checks: <path>: <message>", one
  mistake gives one error, and the WRAP_ACTIONS error is reported at the
  Step (openjd-rs#634).

In openjd.sessions:

- exit_environment with no resolved_symtab resolves onExit against the
  table the environment was entered with, and an Environment from
  create_job resolves against its own table, so Job.Name works
  (openjd-rs#632).
- A CHUNK[INT] task value is bound as a range expression, and an int,
  list or non-range string fails the task (openjd-rs#638).
- A PATH value given for a task parameter binds Task.RawParam as a
  string. One given for a job parameter still binds a path, which a
  strict xfail records (openjd-rs#638).
- A PATH or LIST[PATH] value that is not a string or path fails the
  action (openjd-rs#639).
- Same-user cancel_action is unchanged, and a new test pins it: a
  TERMINATE action is killed at once and a NOTIFY_THEN_TERMINATE grace
  is capped at time_limit. The spec also notes what changed for
  cross-user sessions, the grace in whole seconds (openjd-rs#563, #575)
  and the group check (openjd-rs#603), which these tests do not run.

The expr, model and sessions specs describe each change with its crate
version. The type stub is regenerated, and scripts/generate_stubs.sh
restores Job.parameters' value type, which pyo3-stub-gen writes as a bare
dict for a getter that builds a PyDict.

BREAKING CHANGE: v1 refuses a number or boolean in a format-string
field, and a complex expression in any field of a template without
EXPR. A CHUNK[INT] session task value must be a range expression or a
string in that form, and a PATH value must be a string or a path.
round(x, n) returns an int for n <= 0. A regex counts toward the memory
budget. re_sub refuses control characters in its replacement.
exit_environment with no resolved_symtab no longer rebuilds the table
from the job parameter values. v0 rejects at decode a TEMPLATE-scope
literal path expression that fails without a host context.
TemplateStepDependency instances are unhashable.

Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
… tests

A second review of the openjd-rs 0.18 bump checked the first round's
fixes and tests against the old build, and diffed the upstream specs and
a fuzzed template corpus.

Fixes:

- v0 refuses apply_path_mapping in a TEMPLATE-scope let binding, such as
  a step let, as it does in a TEMPLATE-scope field and as v1 does. The
  previous commit skipped the check without a host context for such an
  expression on the grounds that the caller reports the function, but
  only the field check did. A script let is host scope and still
  decodes. The set of host-context functions is defined once. v0 checks
  the function by name, so a call in a branch that a literal condition
  rules out is refused where v1 decodes it; a strict xfail records it,
  as a job name already differed this way.

New tests and spec sentences:

- In a template without ENV_PARAMS, an ENV_PARAMS key on a dependency or
  an Environment raises ModelValidationError at the key, where it raised
  DecodeValidationError as an unknown field (openjd-rs#641). Exact
  messages for each form, in job and environment templates.
- A template whose steps list is empty gets only the no-step error, not
  the WRAP_ACTIONS one as well (openjd-rs#634).
- openjd-model does not check, at decode, a STRING range written as one
  expression, where v0 does. A strict xfail records it.
- preprocess_job_parameters returns a dict whose order is unspecified.
- v0 accepts {{ True }}, {{ False }} and {{ None }} in a template that
  does not list EXPR when the caller allows EXPR, and v1 refuses them.

Test fixes: two tests no longer assume POSIX paths. The round() rows
check the result's type. Pickle tests cover StepDependency(step=...)
and every TemplateEnvironment field, a script included. ExprField refuses infinity and the
messages are checked in full. The regex memory control proves the
pattern would be charged without a limit.

BREAKING CHANGE: v0 refuses a host-context function such as
apply_path_mapping in a TEMPLATE-scope let binding. In a template that
does not list ENV_PARAMS, an ENV_PARAMS key raises ModelValidationError
rather than DecodeValidationError. Earlier commits on this branch also
change these, which their footers do not list: v1 refuses an empty
description at decode, and a step parameter space with two CHUNK[INT]
parameters (openjd-rs#633, #612); STRING and PATH minLength and
maxLength count characters rather than bytes (openjd-rs#615); a PATH
task value in a session binds Task.RawParam as a string (openjd-rs#638).

Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
match &self.inner {
ExprField::Bool(b) => (0u8, *b).hash(&mut h),
ExprField::Int(i) => (1u8, *i).hash(&mut h),
ExprField::Float(f) => (2u8, f.to_bits()).hash(&mut h),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: __hash__ hashes a float by f.to_bits(), but __eq__ compares with ExprField's PartialEq, and on f64 that treats 0.0 == -0.0 as true. Equal objects can then have different hashes.

For example, ExprField(0.0) == ExprField(-0.0) is True, yet {ExprField(0.0), ExprField(-0.0)} keeps both, and a dict lookup with one misses the other.

Fix: normalize the zero before hashing.

ExprField::Float(f) => (2u8, if *f == 0.0 { 0u64 } else { f.to_bits() }).hash(&mut h),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing this. __eq__ uses openjd-model's PartialEq for ExprField, which compares floats by to_bits() (expr_field.rs:57), not with f64's ==. ExprField(0.0) == ExprField(-0.0) is False, and the hash agrees with it. test_env_params.py:388 asserts that, and the spec says so at the ExprField section. Normalizing the zero in the hash would still be correct but isn't needed.

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Claude review · advisory

Reviewed d358b21 (changes since 2d0c2ad): 0 new, 0 resolved.

Open: 0 blocking · 0 should-fix · 1 nit. ✅ Nothing blocking.

Fix or reply to each thread; the next revision's review re-checks open threads and resolves those it agrees are handled. Resolving a thread yourself also closes it. Later revisions review only what changed.

The THIRD-PARTY-LICENSES check failed on this PR. pip-licenses was
installed unpinned, and pip-licenses 6.0.0 (released 2026-12-02) writes
"UNKNOWN" for each LicenseText, so the regenerated Python section lost
every license text. The earlier commit in this PR blamed the local
machine for the same output; the tool version is the cause. Pin
pip-licenses to 5.5.5, the last release that fills in LicenseText.

With the pin, regenerating changes only three Python versions that PyPI
now resolves: pydantic 2.14.3 to 2.14.4, pydantic_core 2.50.4 to
2.50.5, and PyYAML 6.0.3 to 6.0.4. Their license texts are unchanged.
The pydantic and PyYAML drift is also why Dependabot PRs have failed
this check since 2026-11-23.

Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
@leongdl
leongdl marked this pull request as ready for review December 3, 2026 05:25
@leongdl
leongdl requested a review from a team as a code owner December 3, 2026 05:25
…v0 error, and spec sentences

A review of the branch found no high-severity defect. It found these,
each now with a test that fails without the fix:

- StepDependency(parameters=...) raised PanicException when converting a
  value changed the dict, and silently swapped keys when the size stayed
  the same. json.dumps calls a dict subclass's items(), which can run user
  code, and PyO3's live dict iterator panics on a size change. The
  binding reads a snapshot of the dict.
- ExprField read an int outside the i64 and u64 ranges with the value's
  own __float__, so an int subclass could build ExprField(nan), which
  then failed to unpickle. It uses int.__float__.
- v0 reported a failing TEMPLATE-scope expression in
  notifyPeriodInSeconds twice: the reference check visits a cancelation
  value once per union member, and the check without a host context that
  this PR added runs in that pass. Errors that repeat one at the same
  location are dropped. The old build and v1 report it once.

Spec sentences that the review found false, now corrected and pinned:

- ExprField reads an int as decoding reads a template number: only 2^63
  to 2^64 - 1 raises OverflowError, and a larger or smaller int is a float.
- Only a Job Environment from create_job has its own table. A Step
  Environment needs step.resolved_symtab for Job.Name.
- A single path is accepted for a LIST[PATH] job parameter and binds a
  scalar path (a strict xfail), a PATH task parameter given None fails
  with "Cannot coerce nulltype to string", and a Python value with no
  ExprValue form raises TypeError and starts nothing.
- A CHUNK[INT] RangeExpr value is written as str(RangeExpr), so
  RangeExpr("1-2") binds 1,2 while the string "1-2" is kept.
- A larger memory_limit can fail where a smaller one passes, because the
  regex cache decides at compile time (openjd-rs#368). A strict xfail
  records it for an upstream report.
- ENV_PARAMS decoding refuses a parameter value containing "{{" that does
  not parse.

Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
…rs again

A second review ran the conformance suite's 567 job tests through a
worker's full flow on the old and new builds. One test,
WRAP_ACTIONS/jobs/wrap-env-template-parameters-in-hooks, passed before
the bump and failed after it.

A wrap hook (RFC 0008) reads its own Param.* from the table of the wrap
Environment. Since openjd-sessions 0.12.0 (openjd-rs#632) a Job Environment
from create_job is entered with its own filtered table, so a wrap
Environment from create_environment, which has no table, no longer saw
the session's job parameter values through it. Entering the Job
Environment failed with "Undefined variable: 'Param.Prefix'". openjd run
gives an Environment Template the table convert_environment_with_symtab
builds, which Python could not reach.

create_environment takes an optional job_parameter_values. With it, the
Environment gets the same filtered table openjd run gives it. Without
it, behaviour is unchanged. A new test runs the same templates as the conformance test: it
fails without the keyword and passes with it.

The same review found three more dict loops that iterate a caller's dict
live while reading values with code that can run user code:
create_job's job_parameter_values, and Session's job and task parameter
values. A value whose type attribute changes the dict raised PyO3's
PanicException. They read a snapshot now, as StepDependency's
parameters do since the previous commit. A test pins create_job.

Also:

- ExprField(10**400) raises OverflowError, as the spec now says.
- The previous commit's de-duplication also reports an identical error
  at one location once in a template without EXPR, where v0 used to
  report {{Param.Y}} {{Param.Y}} twice. v1 reports it once. A test pins
  it; the previous commit's message described only the EXPR case.

Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
…d read every caller dict as a snapshot

A third review found that the previous commit's
create_environment(env_template, job_parameter_values=...) put each
value into the Environment's table as given. When a Session builds a
table from its job parameters, it converts each value to its declared type, but it
does not convert the values of a table an Environment brings with it.
So {"type": "INT", "value": "05"}, the string form the Deadline Cloud
worker agent builds from its service payload, reached an action as the
text 05, and with EXPR {{ Param.N + 1 }} failed with "Cannot use '+'
operator with string and int". A BOOL "false" failed "Condition must be
a boolean". create_environment now converts each value other than PATH
and LIST[PATH] the way the Session does, and raises ValueError ("Failed
to coerce parameter 'Param.N': ...") for one that does not convert.
PATH values are left to the Session, which maps them, as before.

The same review found four more bindings that iterate a caller's dict
live while running user code, which raises PyO3's PanicException when
that code changes the dict: build_symbol_table, SymbolTable(dict) and
FormatString.resolve(symtab=dict), StepParameterSpace(...), and
StepParameterSpaceIterator containment checks. They predate this PR;
they read a snapshot now, as the earlier fixes do. A new
test/openjd/test_dict_snapshots.py pins each one, and the Session
snapshot from the previous commit, which had no test.

A consumer audit found that the worker agent passes CHUNK[INT] values as
TaskParameterValue(type=CHUNK_INT, value=<service text>). Since
openjd-sessions 0.12.1 (openjd-rs#638) that form is also written in
canonical range form, so 1,3,5 is 1-5:2 and 01-05 is 1-5, while the
pure-Python openjd.sessions.Session binds the text unchanged. A test
pins the TaskParameterValue form, and the sessions spec says so and
corrects "a string <N>-<M> is kept" to "kept when it is already
canonical".

BREAKING CHANGE: a CHUNK[INT] task value given as a TaskParameterValue,
as the worker agent passes it, is bound in canonical range form
(openjd-rs#638); before, its text was kept.

Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
The test asserted PosixPath, so it failed on Windows CI, where the class
is WindowsPath.

Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
crowecawcaw
crowecawcaw previously approved these changes Dec 3, 2026
# openjd-model does for a TEMPLATE-scope field. An expression that
# calls a host-context function is reported for that by the caller.
no_host = template_scope and not (self.called_functions & HOST_CONTEXT_FUNCTIONS)
if no_host and not accessed:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check without a host context only runs when the expression has no free symbols (not accessed), or when every symbol is typed (the typed branch below). A let name is deliberately untyped, so an expression that reads one falls back to the name-only check and skips the TEMPLATE-scope check. v1 evaluates the let values into a typed table and refuses these at decode.

Repro (EXPR + FEATURE_BUNDLE_1), a step with let: ["n = 1"] and onRun timeout: "{{ int(path('a/b').name) + n }}":

  • v0 decode_job_template succeeds, and create_job succeeds with the timeout left as the unresolved string {{ int(path('a/b').name) + n }}, so it fails only on the worker.
  • v1 refuses it at decode: Cannot convert 'b' to int.

path(...).parts[5] and int(with_number('f_#',3)) behave the same way. This predates the PR, so it isn't a regression, but the description says v0 checks TEMPLATE-scope expressions "as openjd-model does". Could you either fix it (check without a host context and treat let names as unknown-typed) or record it as a strict xfail in test_expr_literal_paths.py and qualify that sentence?

)
environment = create_environment(env_template, job_parameter_values={"N": value})
session = Session(
session_id="s", job_parameter_values={"N": value}, session_root_directory=str(tmp_path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test would still pass if create_environment ignored job_parameter_values=. The Session also gets {"N": value} and converts its own job parameter values, so create_environment(env_template) with no values plus this Session writes 5|6 too.

With Session(job_parameter_values={}, ...), the form without values fails with Undefined variable: 'Param.N', and the form with values only passes if create_environment converts them. That makes this test pin the conversion it describes.

mwiebe
mwiebe previously approved these changes Dec 3, 2026
Comment thread specs/python-model-interface.md Outdated
least 1 character`. Before, it decoded.

An Environment pickles, except one with `env_parameter_definitions`, which
raises `TypeError` because `EnvironmentParameterDefinition` does not pickle.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth fixing these up to be picklable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I will fix this first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2d0c2ad. All twelve Job*ParameterDefinition classes and EnvironmentParameterDefinition now pickle, so an Environment with env_parameter_definitions pickles too.

openjd-model reads these definitions from their template form but cannot write them back, so the new rust-bindings/src/model/param_def_json.rs writes that form. Each class pickles it as JSON text. A number written as a string keeps its spelling: a FLOAT default of "1.50" comes back as "1.50".

test_parameter_definition_pickle.py decodes a definition of each type with every field set, and checks that its template form is the same after a pickle round trip. The spec now lists these types in the Pickle Support table.

as a Session does with the values of its job parameters, so `{"type": "INT", "value":
"05"}` is the int `5`. A value that does not convert raises `ValueError`
(`Failed to coerce parameter 'Param.N': ...`). PATH and LIST[PATH] values are
left out of the table's `Param.*`, as openjd-model does, and the Session maps

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a potential bug to investigate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On it!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a bug, fixed in 2d0c2ad. With job_parameter_values, the Environment's table replaces the Session's values for every parameter except PATH and LIST[PATH]. A declared parameter left out of the values was undefined at enter, even when the Session had a value or the template had a default, and the error only showed up at enter.

create_environment now raises ValueError at create time with Values missing for required job parameters: A, D, as preprocess_job_parameters does. Passing the dict that preprocess_job_parameters returns fills in defaults. Test: test_create_environment_refuses_a_declared_parameter_without_a_value.

For a PATH parameter, the Session supplies Param.* and the table supplies RawParam.*, so different values still give Param.P=/b with RawParam.P=/a. The bindings can't change where the Session reads PATH values from, so the spec and docstring now say to give the Session the same values.

…te_environment

Review comments on PR OpenJobDescription#397 asked for two changes.

Pickle. Pickling any Job*ParameterDefinition or an
EnvironmentParameterDefinition raised TypeError, and so did pickling an
Environment with env_parameter_definitions. openjd-model deserializes
these definitions from their template form but does not serialize them,
so a new param_def_json module writes the template form back: every
field that is set, under its template name, with a number written as a
string kept as that string (a FLOAT default of "1.50"). Each class
pickles that JSON text through _reconstruct_job_parameter_definition or
_reconstruct_environment_parameter_definition, and an Environment
pickles its env_parameter_definitions. A test decodes a definition of
each of the twelve types with every field set and checks that its
template form is the same after a pickle round trip.

create_environment(job_parameter_values=...). For every parameter other
than PATH and LIST[PATH], the Environment's table replaces the session's
values. A declared parameter left out of job_parameter_values was then
undefined in the Environment even when the Session had it, including one
with a default, and the error came only at enter. It now raises
ValueError ("Values missing for required job parameters: A, D"), as
preprocess_job_parameters does. The dict that function returns fills in
defaults.
The spec says to give the Session the same values, since for a PATH
parameter the Session supplies Param.* and the table supplies RawParam.*.

Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
@leongdl
leongdl dismissed stale reviews from mwiebe and crowecawcaw via 2d0c2ad December 3, 2026 19:10
…tighten a create_environment test

These address crowecawcaw's review comments on PR OpenJobDescription#397.

v0 checked a TEMPLATE-scope expression without a host context only when
it didn't read a symbol, or when every symbol had a known type. A step let
name has no declared type, so an expression that read one got the
name-only check. A timeout of {{ int(path('a/b').name) + n }} with
let: ["n = 1"] decoded, and create_job left it unresolved, so it failed
only on the worker. v1 refuses it at decode. This predates the PR. v0
now checks such an expression without a host context, with each
untyped symbol as an unresolved value of type any. An any value
assumes nothing, so only the rest of the expression can fail. Tests
cover three repros (int of a path name, a path parts index, int of
with_number) in v0 and v1, and five controls with an untyped name
that still decode.

test_create_environment_converts_values_to_their_types gave the Session
the same job parameter values, so it passed without the keyword,
because the Session converts its own values. The Session now has none.
The test fails without the keyword ("Undefined variable:
'Param.N'") and without the conversion.

Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants