6.7 KiB
Runtime Versions Feature
Date: 2026-02-26 Scope: Data model, repositories, version matching, pack loader, API, core pack definitions
Summary
Added support for multiple versions of the same runtime (e.g., Python 3.11, 3.12, 3.13 or Node.js 18, 20, 22). Actions and sensors can now declare a semver version constraint (e.g., >=3.12, ~18.0, >=3.12,<4.0) to specify which runtime version they require. The system selects the best matching available version at execution time.
The design is fully data-driven — no hard-coded handling for any specific runtime. All version detection, constraint matching, and execution configuration is driven by database records and YAML definitions.
Changes
New Migration: 20260226000000_runtime_versions.sql
runtime_versiontable: Stores version-specific execution configurations per runtimeruntime(FK → runtime.id),runtime_ref,version(semver string)version_major,version_minor,version_patch(ints for efficient range queries)execution_configJSONB — complete standalone config (not a diff) replacing the parent runtime's config when this version is selecteddistributionsJSONB — version-specific verification commandsis_default(at most one per runtime),available,verified_atmetaJSONB for arbitrary metadata (EOL dates, LTS codenames, etc.)- Unique constraint on
(runtime, version)
action.runtime_version_constraint— new nullable TEXT column for semver constraintssensor.runtime_version_constraint— same as above
New Module: crates/common/src/version_matching.rs
parse_version()— lenient semver parsing ("3.12"→3.12.0,"v20.11"→20.11.0)parse_constraint()— constraint parsing with bare version support ("3.12"→~3.12)matches_constraint()— check if a version satisfies a constraintselect_best_version()— pick the highest available version matching a constraint, with default-version preference when no constraint is specifiedextract_version_components()— split version string into (major, minor, patch) for DB columns- 33 unit tests covering all constraint operators, edge cases, and selection logic
New Repository: crates/common/src/repositories/runtime_version.rs
- Full CRUD (FindById, List, Create, Update, Delete)
find_by_runtime()— all versions for a runtime, ordered newest-firstfind_by_runtime_ref()— same, by runtime ref stringfind_available_by_runtime()— only available versionsfind_default_by_runtime()— the default versionfind_by_runtime_and_version()— exact version lookupclear_default_for_runtime()— helper for changing defaultsset_availability()— mark available/unavailable with timestampdelete_by_runtime()— bulk delete
Model Changes
RuntimeVersionstruct inmodels::runtimemodule withparsed_execution_config()methodAction— addedruntime_version_constraint: Option<String>Sensor— addedruntime_version_constraint: Option<String>
Pack Loader Updates (crates/common/src/pack_registry/loader.rs)
load_runtimes()now callsload_runtime_versions()after creating each runtimeload_runtime_versions()parses theversionsarray from runtime YAML and createsruntime_versionrowsload_actions()readsruntime_versionfrom action YAML → stored asruntime_version_constraintload_sensors()readsruntime_versionfrom sensor YAML → same
Repository Updates
- Action repository: All SELECT/INSERT/UPDATE/RETURNING queries updated to include
runtime_version_constraint - Sensor repository: Same — all queries updated
- Input structs:
CreateActionInput,UpdateActionInput,CreateSensorInput,UpdateSensorInputall include the new field
API Updates
- Action DTOs:
CreateActionRequest,UpdateActionRequest,ActionResponse,ActionSummaryincluderuntime_version_constraint - Route handlers:
create_action,update_actionpass the field through - OpenAPI annotations added for the new field
Core Pack Runtime YAML Updates
packs/core/runtimes/python.yaml: Addedversionsarray with Python 3.11, 3.12 (default), 3.13 — each with version-specific interpreter binary (python3.11,python3.12,python3.13), venv commands, and verification patternspacks/core/runtimes/nodejs.yaml: Addedversionsarray with Node.js 18, 20 (default), 22 — each with version-specific binary, verification commands, and LTS metadata
Dependency Addition
semver1.0 (with serde feature) added to workspace andattune-commonCargo.toml
Test Fixes
- All callsites constructing
CreateActionInput,CreateSensorInput,UpdateActionInput,UpdateSensorInputacross the workspace updated withruntime_version_constraint: None(approximately 20 files touched)
Architecture Decisions
-
Full execution_config per version, not diffs: Each
runtime_versionrow stores a completeexecution_configrather than overrides. This avoids merge complexity and makes each version self-contained. -
Constraint stored as text, matched at runtime: The
runtime_version_constraintcolumn stores the raw semver string. Matching is done in Rust code using thesemvercrate rather than in SQL, because semver range logic is complex and better handled in application code. -
Bare version = tilde range: A constraint like
"3.12"is interpreted as~3.12(>=3.12.0, <3.13.0), which is the most common developer expectation for "compatible with 3.12". -
No hard-coded runtime handling: The entire version system is data-driven through the
runtime_versiontable and YAML definitions. Any runtime can define versions with arbitrary verification commands and execution configs.
What's Next
- Worker integration: The worker execution pipeline should query
runtime_versionrows when an action has aruntime_version_constraint, useselect_best_version()to pick the right version, and use that version'sexecution_configinstead of the parent runtime's. - Runtime version detection: The
RuntimeDetectorshould verify individual version availability by running each version's verification commands and updating theavailable/verified_atfields. - Environment isolation per version: The
runtime_envs_dirpath pattern may need to include the version (e.g.,{runtime_envs_dir}/{pack_ref}/{runtime_name}-{version}) to support multiple Python versions with separate virtualenvs. - API endpoints: CRUD endpoints for
runtime_versionmanagement (list versions for a runtime, register new versions, mark availability). - Web UI: Display version information in runtime/action views, version constraint field in action editor.