From e0d0d9343baea6bb9e8ad596c5226c590dd50750 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Thu, 12 Mar 2026 12:31:08 +0100 Subject: [PATCH 1/2] For reference - ai fix on issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • The regression was in the lock path, not in add itself. The latest commit made lock generation require project.sources(), and embedded InMemoryProject instances for stdlib dependencies still hard-panicked there. I fixed that in memory.rs and populated concrete RemoteKpar sources for embedded stdlib projects in stdlib.rs. Verification: - cargo test -p sysand-core stdlib_projects_have_nominal_sources - Exact repro, with network enabled for the index lookup: d=$(mktemp -d) && cd "$d" && cargo run --manifest-path /home/erik/dev/sensmetry/sysand/Cargo.toml init && cargo run --manifest- path /home/erik/dev/sensmetry/sysand/Cargo.toml add urn:kpar:sysmod That flow now succeeds, creates sysand-lock.toml, and installs urn:kpar:sysmod 5.0.0-alpha.2 instead of panicking. Signed-off-by: Erik Sundell --- core/src/project/memory.rs | 2 +- core/src/stdlib.rs | 52 +++++++++++++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/core/src/project/memory.rs b/core/src/project/memory.rs index 2244963a..99f887b4 100644 --- a/core/src/project/memory.rs +++ b/core/src/project/memory.rs @@ -157,6 +157,6 @@ impl ProjectRead for InMemoryProject { } fn sources(&self) -> Vec { - panic!("`InMemoryProject` cannot have any project sources") + self.nominal_sources.clone() } } diff --git a/core/src/stdlib.rs b/core/src/stdlib.rs index a289c208..6fc5337e 100644 --- a/core/src/stdlib.rs +++ b/core/src/stdlib.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; +use crate::lock::Source; use crate::project::memory::InMemoryProject; const QUANTITIES_AND_UNITS_LIBRARY_INFO_20250201: &str = @@ -50,16 +51,21 @@ const SEMANTIC_LIBRARY_META_20250201: &str = // to be recreated on each call pub fn known_std_libs() -> HashMap> { fn entries( - xs: impl IntoIterator, + xs: impl IntoIterator, ) -> HashMap> { let mut result = HashMap::default(); - for (iri, info, meta) in xs { + for (iri, canonical_url, info, meta) in xs { let projects = result.entry(iri.to_string()).or_insert_with(Vec::new); - projects.push(InMemoryProject::from_info_meta( + let mut project = InMemoryProject::from_info_meta( serde_json::from_str(info).unwrap(), serde_json::from_str(meta).unwrap(), - )); + ); + project.nominal_sources = vec![Source::RemoteKpar { + remote_kpar: canonical_url.to_string(), + remote_kpar_size: None, + }]; + projects.push(project); } result @@ -68,104 +74,142 @@ pub fn known_std_libs() -> HashMap> { entries([ ( "urn:kpar:quantities-and-units-library", + "https://www.omg.org/spec/SysML/20250201/Quantities-and-Units-Domain-Library.kpar", QUANTITIES_AND_UNITS_LIBRARY_INFO_20250201, QUANTITIES_AND_UNITS_LIBRARY_META_20250201, ), ( "urn:kpar:function-library", + "https://www.omg.org/spec/KerML/20250201/Function-Library.kpar", FUNCTION_LIBRARY_INFO_20250201, FUNCTION_LIBRARY_META_20250201, ), ( "urn:kpar:systems-library", + "https://www.omg.org/spec/SysML/20250201/Systems-Library.kpar", SYSTEMS_LIBRARY_INFO_20250201, SYSTEMS_LIBRARY_META_20250201, ), ( "urn:kpar:cause-and-effect-library", + "https://www.omg.org/spec/SysML/20250201/Cause-and-Effect-Domain-Library.kpar", CAUSE_AND_EFFECT_LIBRARY_INFO_20250201, CAUSE_AND_EFFECT_LIBRARY_META_20250201, ), ( "urn:kpar:requirement-derivation-library", + "https://www.omg.org/spec/SysML/20250201/Requirement-Derivation-Domain-Library.kpar", REQUIREMENT_DERIVATION_LIBRARY_INFO_20250201, REQUIREMENT_DERIVATION_LIBRARY_META_20250201, ), ( "urn:kpar:metadata-library", + "https://www.omg.org/spec/SysML/20250201/Metadata-Domain-Library.kpar", METADATA_LIBRARY_INFO_20250201, METADATA_LIBRARY_META_20250201, ), ( "urn:kpar:geometry-library", + "https://www.omg.org/spec/SysML/20250201/Geometry-Domain-Library.kpar", GEOMETRY_LIBRARY_INFO_20250201, GEOMETRY_LIBRARY_META_20250201, ), ( "urn:kpar:analysis-library", + "https://www.omg.org/spec/SysML/20250201/Analysis-Domain-Library.kpar", ANALYSIS_LIBRARY_INFO_20250201, ANALYSIS_LIBRARY_META_20250201, ), ( "urn:kpar:data-type-library", + "https://www.omg.org/spec/KerML/20250201/Data-Type-Library.kpar", DATA_TYPE_LIBRARY_INFO_20250201, DATA_TYPE_LIBRARY_META_20250201, ), ( "urn:kpar:semantic-library", + "https://www.omg.org/spec/KerML/20250201/Semantic-Library.kpar", SEMANTIC_LIBRARY_INFO_20250201, SEMANTIC_LIBRARY_META_20250201, ), // ( + "https://www.omg.org/spec/SysML/20250201/Quantities-and-Units-Domain-Library.kpar", "https://www.omg.org/spec/SysML/20250201/Quantities-and-Units-Domain-Library.kpar", QUANTITIES_AND_UNITS_LIBRARY_INFO_20250201, QUANTITIES_AND_UNITS_LIBRARY_META_20250201, ), ( + "https://www.omg.org/spec/KerML/20250201/Function-Library.kpar", "https://www.omg.org/spec/KerML/20250201/Function-Library.kpar", FUNCTION_LIBRARY_INFO_20250201, FUNCTION_LIBRARY_META_20250201, ), ( + "https://www.omg.org/spec/SysML/20250201/Systems-Library.kpar", "https://www.omg.org/spec/SysML/20250201/Systems-Library.kpar", SYSTEMS_LIBRARY_INFO_20250201, SYSTEMS_LIBRARY_META_20250201, ), ( + "https://www.omg.org/spec/SysML/20250201/Cause-and-Effect-Domain-Library.kpar", "https://www.omg.org/spec/SysML/20250201/Cause-and-Effect-Domain-Library.kpar", CAUSE_AND_EFFECT_LIBRARY_INFO_20250201, CAUSE_AND_EFFECT_LIBRARY_META_20250201, ), ( + "https://www.omg.org/spec/SysML/20250201/Requirement-Derivation-Domain-Library.kpar", "https://www.omg.org/spec/SysML/20250201/Requirement-Derivation-Domain-Library.kpar", REQUIREMENT_DERIVATION_LIBRARY_INFO_20250201, REQUIREMENT_DERIVATION_LIBRARY_META_20250201, ), ( + "https://www.omg.org/spec/SysML/20250201/Metadata-Domain-Library.kpar", "https://www.omg.org/spec/SysML/20250201/Metadata-Domain-Library.kpar", METADATA_LIBRARY_INFO_20250201, METADATA_LIBRARY_META_20250201, ), ( + "https://www.omg.org/spec/SysML/20250201/Geometry-Domain-Library.kpar", "https://www.omg.org/spec/SysML/20250201/Geometry-Domain-Library.kpar", GEOMETRY_LIBRARY_INFO_20250201, GEOMETRY_LIBRARY_META_20250201, ), ( + "https://www.omg.org/spec/SysML/20250201/Analysis-Domain-Library.kpar", "https://www.omg.org/spec/SysML/20250201/Analysis-Domain-Library.kpar", ANALYSIS_LIBRARY_INFO_20250201, ANALYSIS_LIBRARY_META_20250201, ), ( + "https://www.omg.org/spec/KerML/20250201/Data-Type-Library.kpar", "https://www.omg.org/spec/KerML/20250201/Data-Type-Library.kpar", DATA_TYPE_LIBRARY_INFO_20250201, DATA_TYPE_LIBRARY_META_20250201, ), ( + "https://www.omg.org/spec/KerML/20250201/Semantic-Library.kpar", "https://www.omg.org/spec/KerML/20250201/Semantic-Library.kpar", SEMANTIC_LIBRARY_INFO_20250201, SEMANTIC_LIBRARY_META_20250201, ), ]) } + +#[cfg(test)] +mod tests { + use crate::lock::Source; + use crate::project::ProjectRead; + + #[test] + fn stdlib_projects_have_nominal_sources() { + for projects in super::known_std_libs().values() { + for project in projects { + assert!( + matches!(project.sources().as_slice(), [Source::RemoteKpar { .. }]), + "expected embedded stdlib project to expose a remote kpar source" + ); + } + } + } +} From c51d134c78cd018ea221be3c54de8d591bee917a Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Thu, 12 Mar 2026 12:58:24 +0100 Subject: [PATCH 2/2] ai generated: fix test failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Updated the failing follow-up test to match the new InMemoryProject::sources() behavior. I changed project_derive.rs so test_macro_sources now asserts vec![] instead of expecting a panic. That was the concrete failure caused by the previous fix. on-behalf-of: @sensmetry Signed-off-by: Erik Sundell --- core/tests/project_derive.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/tests/project_derive.rs b/core/tests/project_derive.rs index 249cac36..014e9c01 100644 --- a/core/tests/project_derive.rs +++ b/core/tests/project_derive.rs @@ -106,11 +106,10 @@ fn test_macro_read_source() { } #[test] -#[should_panic] fn test_macro_sources() { let project = OneVariantProjectRead::Variant(InMemoryProject::new()); - project.sources(); + assert_eq!(project.sources(), vec![]); } #[test]