feature: Metadata contract#262
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands the compiled-runtime metadata contract so DSL runtimes can expose richer model metadata consistently across JIT, AoT, and WASM backends.
Changes:
- Adds state, covariate interpolation, and route destination/feature metadata to
NativeModelInfo. - Builds and exposes
ValidatedModelMetadatafrom compiled native/runtime models. - Tightens WASM metadata loading to require the compiled metadata envelope and kernel availability agreement.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/parameter_order.rs |
Updates test metadata construction for the expanded NativeModelInfo shape. |
src/dsl/wasm.rs |
Requires compiled metadata envelopes and updates WASM loader/tests for richer metadata. |
src/dsl/runtime.rs |
Exposes runtime metadata accessors and propagates model-construction errors. |
src/dsl/native.rs |
Constructs validated runtime metadata and exposes it from compiled native models. |
src/dsl/model_info.rs |
Extends compiled model info with states, interpolation, and route metadata. |
src/dsl/mod.rs |
Re-exports the new runtime state metadata type. |
src/dsl/jit.rs |
Propagates metadata validation errors during JIT compilation. |
src/dsl/compiled_backend_abi.rs |
Updates ABI tests for the expanded metadata fields. |
src/dsl/aot.rs |
Propagates metadata validation errors while loading AoT artifacts. |
pharmsol-dsl/src/ir.rs |
Makes covariate interpolation serializable for metadata transport. |
Comments suppressed due to low confidence (2)
src/dsl/native.rs:401
- Defaulting legacy structured-block routes to
Bolusmakes the exposed validated metadata disagree with runtime behavior:RouteInputSemanticsstill treatskind == Noneroutes as supporting both bolus and infusion inputs, whilemetadata().route(...).kind()will report bolus-only. Downstream crates relying on the new metadata contract can incorrectly reject infusion use for those models.
// Structured-block DSL routes still lower without an explicit kind.
// Treat them as declaration-ordered bolus routes for the shared
// metadata surface while preserving the original runtime semantics
// from `info.routes` below.
let kind = route.kind.unwrap_or(RouteKind::Bolus);
src/dsl/model_info.rs:66
- The state metadata omits the declared state's length even though execution states can span multiple buffer slots (
ExecutionStatehaslen). Without preserving that length (or expanding one entry per slot), downstream metadata consumers cannot reconstruct vector/array state layouts or map offsets back to state elements correctly.
/// Metadata for one compiled state.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct NativeStateInfo {
/// Public state name.
pub name: String,
/// Dense runtime state offset.
pub offset: usize,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
| Branch | fix/missing_metadata |
| Testbed | mhovd-pgx |
🐰 View full continuous benchmarking report in Bencher
⚠️ WARNING: Truncated view!The full continuous benchmarking report exceeds the maximum length allowed on this platform.
To reduce use of OtherError
mhovd
approved these changes
May 14, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR aims to define the metadata contract between the different runtimes in pharmsol. The different runtimes now expose metadata directly so downstream crates can read it independently on the runtime used