-
-
Notifications
You must be signed in to change notification settings - Fork 398
Prevent stale native runtime reuse across branch builds #1305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,8 @@ pub struct NativeRuntimePlatform { | |
| pub struct NativeRuntimeArtifact { | ||
| pub id: String, | ||
| #[serde(default, skip_serializing_if = "Option::is_none")] | ||
| pub build_id: Option<String>, | ||
| #[serde(default, skip_serializing_if = "Option::is_none")] | ||
| pub mesh_version: Option<String>, | ||
| pub skippy_abi: String, | ||
| pub platform: NativeRuntimePlatform, | ||
|
|
@@ -163,6 +165,14 @@ fn validate_artifact(artifact: &NativeRuntimeArtifact) -> Result<()> { | |
| if artifact.id.trim().is_empty() { | ||
| bail!("native runtime artifact id is empty"); | ||
| } | ||
| if let Some(build_id) = &artifact.build_id { | ||
| validate_build_id(build_id).with_context(|| { | ||
| format!( | ||
| "native runtime artifact {} has invalid build_id", | ||
| artifact.id | ||
| ) | ||
| })?; | ||
| } | ||
| if artifact.skippy_abi.trim().is_empty() { | ||
| bail!( | ||
| "native runtime artifact {} skippy_abi is empty", | ||
|
|
@@ -242,6 +252,20 @@ fn validate_runtime_path(relative: &str) -> Result<()> { | |
| Ok(()) | ||
| } | ||
|
|
||
| fn validate_build_id(value: &str) -> Result<()> { | ||
| let Some(digest) = value.strip_prefix("sha256:") else { | ||
| bail!("expected sha256:<64 lowercase hex>"); | ||
| }; | ||
| if digest.len() != 64 | ||
| || !digest | ||
| .bytes() | ||
| .all(|byte| byte.is_ascii_digit() || (b'a'..=b'f').contains(&byte)) | ||
| { | ||
| bail!("expected sha256:<64 lowercase hex>"); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn normalize_sha256(value: &str) -> Result<String> { | ||
| let value = value | ||
| .trim() | ||
|
|
@@ -292,6 +316,7 @@ mod tests { | |
| r#"{ | ||
| "runtime": { | ||
| "id": "meshllm-runtime-linux-x86_64-cuda12", | ||
| "build_id": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ???? what is this? |
||
| "mesh_version": "0.68.0", | ||
| "skippy_abi": "0.1.25", | ||
| "platform": { | ||
|
|
@@ -319,6 +344,10 @@ mod tests { | |
| let manifest = NativeRuntimeManifest::read_from_dir(temp.path()).unwrap(); | ||
|
|
||
| assert_eq!(manifest.runtime.id, "meshllm-runtime-linux-x86_64-cuda12"); | ||
| assert_eq!( | ||
| manifest.runtime.build_id.as_deref(), | ||
| Some("sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") | ||
| ); | ||
| assert_eq!(manifest.runtime.skippy_abi, "0.1.25"); | ||
| assert_eq!(manifest.runtime.backend.kind.as_str(), "cuda"); | ||
| } | ||
|
|
@@ -345,9 +374,39 @@ mod tests { | |
| .unwrap(); | ||
|
|
||
| assert_eq!(manifest.artifacts.len(), 1); | ||
| assert_eq!(manifest.artifacts[0].build_id, None); | ||
| assert_eq!(manifest.artifacts[0].backend, NativeRuntimeBackend::cpu()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn rejects_invalid_runtime_build_ids() { | ||
| for build_id in [ | ||
| "", | ||
| &"a".repeat(64), | ||
| &format!("sha256:{}", "a".repeat(63)), | ||
| &format!("sha256:{}", "A".repeat(64)), | ||
| &format!("sha256:{}g", "a".repeat(63)), | ||
| ] { | ||
| let json = format!( | ||
| r#"{{ | ||
| "mesh_version": "0.68.0", | ||
| "skippy_abi": "0.1.25", | ||
| "artifacts": [{{ | ||
| "id": "runtime", | ||
| "build_id": "{build_id}", | ||
| "skippy_abi": "0.1.25", | ||
| "platform": {{"os": "linux", "arch": "x86_64"}}, | ||
| "backend": {{"kind": "cpu"}}, | ||
| "libraries": ["lib/runtime.so"] | ||
| }}] | ||
| }}"# | ||
| ); | ||
|
|
||
| let error = NativeRuntimeReleaseManifest::from_json_str(&json).unwrap_err(); | ||
| assert!(error.to_string().contains("invalid build_id"), "{build_id}"); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn rejects_tampered_runtime_file() { | ||
| let temp = tempfile::tempdir().unwrap(); | ||
|
|
@@ -357,6 +416,7 @@ mod tests { | |
| let manifest = NativeRuntimeManifest { | ||
| runtime: NativeRuntimeArtifact { | ||
| id: "meshllm-runtime-linux-x86_64-cpu".to_string(), | ||
| build_id: None, | ||
| mesh_version: Some("0.68.0".to_string()), | ||
| skippy_abi: "0.1.25".to_string(), | ||
| platform: NativeRuntimePlatform { | ||
|
|
@@ -395,6 +455,7 @@ mod tests { | |
| let manifest = NativeRuntimeManifest { | ||
| runtime: NativeRuntimeArtifact { | ||
| id: "meshllm-runtime-linux-x86_64-cuda12".to_string(), | ||
| build_id: None, | ||
| mesh_version: Some("0.68.0".to_string()), | ||
| skippy_abi: "0.1.25".to_string(), | ||
| platform: NativeRuntimePlatform { | ||
|
|
@@ -478,6 +539,7 @@ mod tests { | |
| fn rejects_runtime_checksum_path_traversal() { | ||
| let artifact = NativeRuntimeArtifact { | ||
| id: "meshllm-runtime-linux-x86_64-cpu".to_string(), | ||
| build_id: None, | ||
| mesh_version: Some("0.68.0".to_string()), | ||
| skippy_abi: "0.1.25".to_string(), | ||
| platform: NativeRuntimePlatform { | ||
|
|
||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Preserve build-ID matching on the startup cache-hit path.
Line 458 and Line 732 keep these tests on the legacy path, but the startup cache-hit path still bypasses
artifact_identity_matches.resolve_installed_native_runtime_planselects from installed manifests, andload_plan_from_candidatefinds an entry by version and runtime ID only. A stale runtime from another branch or release build can therefore load when both builds share those values.Pass a selected artifact with its expected
build_idinto this path, or route this lookup through the resolver. Add a test where cached and selected artifacts have equal version and ID but different build IDs, and assert that startup does not load the cached runtime.Also applies to: 732-732
🤖 Prompt for AI Agents