simparse 0.3.3__tar.gz → 0.3.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of simparse might be problematic. Click here for more details.

Files changed (34) hide show
  1. {simparse-0.3.3 → simparse-0.3.5}/Cargo.lock +6 -4
  2. {simparse-0.3.3 → simparse-0.3.5}/Cargo.toml +1 -1
  3. {simparse-0.3.3 → simparse-0.3.5}/PKG-INFO +19 -1
  4. {simparse-0.3.3 → simparse-0.3.5}/README.md +18 -0
  5. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-core/Cargo.toml +2 -0
  6. simparse-0.3.5/crates/simparse-core/examples/ir_asset_probe.rs +444 -0
  7. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-core/src/dispatch.rs +26 -3
  8. simparse-0.3.5/crates/simparse-core/src/ir.rs +270 -0
  9. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-core/src/lib.rs +5 -0
  10. simparse-0.3.5/crates/simparse-core/src/parsers/matfile.rs +499 -0
  11. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-core/src/parsers/mod.rs +3 -0
  12. simparse-0.3.5/crates/simparse-core/src/parsers/simulink.rs +1029 -0
  13. simparse-0.3.5/crates/simparse-core/src/parsers/step.rs +302 -0
  14. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-core/src/schema.rs +22 -0
  15. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-core/src/summary.rs +133 -1
  16. simparse-0.3.5/crates/simparse-core/tests/matfile.rs +296 -0
  17. simparse-0.3.5/crates/simparse-core/tests/simulink.rs +419 -0
  18. simparse-0.3.5/crates/simparse-core/tests/step_ir.rs +209 -0
  19. {simparse-0.3.3 → simparse-0.3.5}/pyproject.toml +1 -1
  20. {simparse-0.3.3 → simparse-0.3.5}/LICENSE +0 -0
  21. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-core/src/error.rs +0 -0
  22. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-core/src/parsers/abaqus.rs +0 -0
  23. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-core/src/parsers/comsol.rs +0 -0
  24. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-core/src/parsers/flotherm.rs +0 -0
  25. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-core/src/parsers/hfss.rs +0 -0
  26. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-core/src/parsers/icepak.rs +0 -0
  27. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-core/tests/synthetic.rs +0 -0
  28. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-hdf5/Cargo.toml +0 -0
  29. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-hdf5/src/lib.rs +0 -0
  30. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-py/Cargo.toml +0 -0
  31. {simparse-0.3.3 → simparse-0.3.5}/crates/simparse-py/src/lib.rs +0 -0
  32. {simparse-0.3.3 → simparse-0.3.5}/python/simparse/__init__.py +0 -0
  33. {simparse-0.3.3 → simparse-0.3.5}/python/simparse/__init__.pyi +0 -0
  34. {simparse-0.3.3 → simparse-0.3.5}/python/simparse/py.typed +0 -0
@@ -826,7 +826,7 @@ checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214"
826
826
 
827
827
  [[package]]
828
828
  name = "simparse-cli"
829
- version = "0.3.3"
829
+ version = "0.3.5"
830
830
  dependencies = [
831
831
  "anyhow",
832
832
  "clap",
@@ -837,13 +837,15 @@ dependencies = [
837
837
 
838
838
  [[package]]
839
839
  name = "simparse-core"
840
- version = "0.3.3"
840
+ version = "0.3.5"
841
841
  dependencies = [
842
842
  "flate2",
843
+ "hdf5-pure",
843
844
  "quick-xml",
844
845
  "schemars",
845
846
  "serde",
846
847
  "serde_json",
848
+ "sha2",
847
849
  "simparse-hdf5",
848
850
  "tar",
849
851
  "tempfile",
@@ -854,7 +856,7 @@ dependencies = [
854
856
 
855
857
  [[package]]
856
858
  name = "simparse-hdf5"
857
- version = "0.3.3"
859
+ version = "0.3.5"
858
860
  dependencies = [
859
861
  "flate2",
860
862
  "hdf5-pure",
@@ -867,7 +869,7 @@ dependencies = [
867
869
 
868
870
  [[package]]
869
871
  name = "simparse-py"
870
- version = "0.3.3"
872
+ version = "0.3.5"
871
873
  dependencies = [
872
874
  "pyo3",
873
875
  "serde",
@@ -3,7 +3,7 @@ members = ["crates/simparse-core", "crates/simparse-hdf5", "crates/simparse-py"]
3
3
  resolver = "2"
4
4
 
5
5
  [workspace.package]
6
- version = "0.3.3"
6
+ version = "0.3.5"
7
7
  edition = "2024"
8
8
  license = "Apache-2.0"
9
9
  repository = "https://github.com/svd-ai-lab/simparse"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simparse
3
- Version: 0.3.3
3
+ Version: 0.3.5
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: License :: OSI Approved :: Apache Software License
6
6
  Classifier: Programming Language :: Python :: 3
@@ -22,6 +22,7 @@ case metadata.
22
22
 
23
23
  | Format | Files |
24
24
  |---|---|
25
+ | STEP Part 21 declarations | `.step`, `.stp` |
25
26
  | COMSOL | `.mph` |
26
27
  | Abaqus | `.inp`, `.inc` |
27
28
  | Fluent | `.cas.h5`, `.msh.h5` |
@@ -29,6 +30,8 @@ case metadata.
29
30
  | Ansys Mechanical | `.mechdb`, `.mechdat` |
30
31
  | Icepak Classic | `.tzr` |
31
32
  | Simcenter FloTHERM | `.pack`, `.xml`, `.floxml` |
33
+ | Simulink | `.slx`, `.mdl` |
34
+ | MATLAB data | `.mat` |
32
35
 
33
36
  ## Design
34
37
 
@@ -37,10 +40,18 @@ It focuses on lightweight agent workflows: metadata, inventory, quick directory
37
40
  scans, and deciding when a heavier vendor or Python tool should be called next.
38
41
  See [tool design principles](docs/design-principles.md).
39
42
 
43
+ The [draft AI Infra System IR](docs/ir.md) defines compact inspection manifests
44
+ for cooling, advanced packaging and 3D IC, with CAD/CAE dialects and software
45
+ extensions. Geometry, meshes and result data stay in referenced artifacts.
46
+ JSON inspection results include an additive `ir` field alongside the existing
47
+ format-specific summary. STEP uses the CAD dialect; supported simulation formats
48
+ use the CAE dialect. The draft describes observed metadata, not executable models.
49
+
40
50
  ## CLI
41
51
 
42
52
  ```powershell
43
53
  cargo run -p simparse-cli -- inspect /path/to/model.mph --json
54
+ cargo run -p simparse-cli -- inspect /path/to/assembly.step --json --summary
44
55
  cargo run -p simparse-cli -- inspect /path/to/thermal-model.xml --json --summary
45
56
  cargo run -p simparse-cli -- inspect /path/to/model.mph --json --summary
46
57
  cargo run -p simparse-cli -- scan /path/to/history --jsonl
@@ -50,6 +61,13 @@ Use `--summary` for a deterministic, bounded preflight view. It reports total
50
61
  counts with capped samples and explicit parser limitations. Omit it when the
51
62
  full shallow inventory is needed.
52
63
 
64
+ STEP inspection streams source declarations with bounded metadata retention. It
65
+ reports schema names, entity-type counts, selected product names and length-unit
66
+ declarations. Counts are source records, not assembly occurrence counts or proof
67
+ of valid geometry. Units remain scoped declarations; no global scale is guessed.
68
+ Incomplete input or skipped records set `truncated`. For STEP, `--max-text-bytes`
69
+ limits each retained record, capped at 64 KiB, rather than the entire file read.
70
+
53
71
  FloXML files commonly use the generic `.xml` suffix. `simparse` checks their
54
72
  root element, so directory scans include `<xml_case>` and `<sm_xml_case>` files
55
73
  while skipping unrelated XML.
@@ -7,6 +7,7 @@ case metadata.
7
7
 
8
8
  | Format | Files |
9
9
  |---|---|
10
+ | STEP Part 21 declarations | `.step`, `.stp` |
10
11
  | COMSOL | `.mph` |
11
12
  | Abaqus | `.inp`, `.inc` |
12
13
  | Fluent | `.cas.h5`, `.msh.h5` |
@@ -14,6 +15,8 @@ case metadata.
14
15
  | Ansys Mechanical | `.mechdb`, `.mechdat` |
15
16
  | Icepak Classic | `.tzr` |
16
17
  | Simcenter FloTHERM | `.pack`, `.xml`, `.floxml` |
18
+ | Simulink | `.slx`, `.mdl` |
19
+ | MATLAB data | `.mat` |
17
20
 
18
21
  ## Design
19
22
 
@@ -22,10 +25,18 @@ It focuses on lightweight agent workflows: metadata, inventory, quick directory
22
25
  scans, and deciding when a heavier vendor or Python tool should be called next.
23
26
  See [tool design principles](docs/design-principles.md).
24
27
 
28
+ The [draft AI Infra System IR](docs/ir.md) defines compact inspection manifests
29
+ for cooling, advanced packaging and 3D IC, with CAD/CAE dialects and software
30
+ extensions. Geometry, meshes and result data stay in referenced artifacts.
31
+ JSON inspection results include an additive `ir` field alongside the existing
32
+ format-specific summary. STEP uses the CAD dialect; supported simulation formats
33
+ use the CAE dialect. The draft describes observed metadata, not executable models.
34
+
25
35
  ## CLI
26
36
 
27
37
  ```powershell
28
38
  cargo run -p simparse-cli -- inspect /path/to/model.mph --json
39
+ cargo run -p simparse-cli -- inspect /path/to/assembly.step --json --summary
29
40
  cargo run -p simparse-cli -- inspect /path/to/thermal-model.xml --json --summary
30
41
  cargo run -p simparse-cli -- inspect /path/to/model.mph --json --summary
31
42
  cargo run -p simparse-cli -- scan /path/to/history --jsonl
@@ -35,6 +46,13 @@ Use `--summary` for a deterministic, bounded preflight view. It reports total
35
46
  counts with capped samples and explicit parser limitations. Omit it when the
36
47
  full shallow inventory is needed.
37
48
 
49
+ STEP inspection streams source declarations with bounded metadata retention. It
50
+ reports schema names, entity-type counts, selected product names and length-unit
51
+ declarations. Counts are source records, not assembly occurrence counts or proof
52
+ of valid geometry. Units remain scoped declarations; no global scale is guessed.
53
+ Incomplete input or skipped records set `truncated`. For STEP, `--max-text-bytes`
54
+ limits each retained record, capped at 64 KiB, rather than the entire file read.
55
+
38
56
  FloXML files commonly use the generic `.xml` suffix. `simparse` checks their
39
57
  root element, so directory scans include `<xml_case>` and `<sm_xml_case>` files
40
58
  while skipping unrelated XML.
@@ -8,6 +8,7 @@ rust-version.workspace = true
8
8
 
9
9
  [dependencies]
10
10
  flate2.workspace = true
11
+ hdf5-pure.workspace = true
11
12
  quick-xml.workspace = true
12
13
  schemars.workspace = true
13
14
  serde.workspace = true
@@ -19,4 +20,5 @@ walkdir.workspace = true
19
20
  zip.workspace = true
20
21
 
21
22
  [dev-dependencies]
23
+ sha2 = "0.10"
22
24
  tempfile.workspace = true
@@ -0,0 +1,444 @@
1
+ //! Test-only, Rust-native projections for the draft AI Infra System IR.
2
+ //! Usage: cargo run -p simparse-core --example ir_asset_probe -- assets.json output-dir
3
+ //! Sources are read-only. The output contains full native inspection sidecars and
4
+ //! compact trial manifests. This is not a production IR exporter or solver adapter.
5
+
6
+ use quick_xml::Reader;
7
+ use quick_xml::events::Event;
8
+ use serde_json::{Value, json};
9
+ use sha2::{Digest, Sha256};
10
+ use simparse_core::{InspectOptions, inspect_path};
11
+ use std::collections::{BTreeMap, BTreeSet};
12
+ use std::error::Error;
13
+ use std::fs::{self, File};
14
+ use std::io::{BufReader, Read};
15
+ use std::path::Path;
16
+
17
+ type Result<T> = std::result::Result<T, Box<dyn Error>>;
18
+ const INLINE_SAMPLE: usize = 24;
19
+
20
+ fn sha256(path: &Path) -> Result<String> {
21
+ let mut reader = BufReader::new(File::open(path)?);
22
+ let mut digest = Sha256::new();
23
+ let mut buffer = [0_u8; 65536];
24
+ loop {
25
+ let count = reader.read(&mut buffer)?;
26
+ if count == 0 {
27
+ break;
28
+ }
29
+ digest.update(&buffer[..count]);
30
+ }
31
+ Ok(format!("{:x}", digest.finalize()))
32
+ }
33
+
34
+ fn reference(path: &Path, format: &str) -> Result<Value> {
35
+ let absolute = fs::canonicalize(path)?;
36
+ let path = absolute.to_string_lossy().replace('\\', "/");
37
+ if path.starts_with("//?/UNC/") || (path.starts_with("//") && !path.starts_with("//?/")) {
38
+ return Err("UNC paths are not supported by this offline probe".into());
39
+ }
40
+ let path = path.strip_prefix("//?/").unwrap_or(&path);
41
+ let mut encoded = String::new();
42
+ for byte in path.trim_start_matches('/').bytes() {
43
+ if byte.is_ascii_alphanumeric() || b"/-._~:".contains(&byte) {
44
+ encoded.push(char::from(byte));
45
+ } else {
46
+ encoded.push_str(&format!("%{byte:02X}"));
47
+ }
48
+ }
49
+ Ok(json!({"uri": format!("file:///{encoded}"), "format": format, "sha256": sha256(&absolute)?}))
50
+ }
51
+
52
+ fn step_observations(path: &Path) -> Result<Value> {
53
+ if fs::metadata(path)?.len() > 32 * 1024 * 1024 {
54
+ return Err("STEP file exceeds probe read limit".into());
55
+ }
56
+ let text = fs::read_to_string(path)?;
57
+ if !text.contains("ISO-10303-21;") {
58
+ return Err("not a STEP physical file".into());
59
+ }
60
+ let mut entities = Vec::new();
61
+ let mut counts = BTreeMap::<String, usize>::new();
62
+ for record in text.split(';') {
63
+ let Some((left, right)) = record.trim().split_once('=') else {
64
+ continue;
65
+ };
66
+ let Some(number) = left.trim().strip_prefix('#') else {
67
+ continue;
68
+ };
69
+ if number.parse::<u64>().is_err() {
70
+ continue;
71
+ }
72
+ let native_type = right.split('(').next().unwrap_or("").trim();
73
+ let kind = match native_type {
74
+ "MANIFOLD_SOLID_BREP" | "BREP_WITH_VOIDS" => "body",
75
+ "ADVANCED_FACE" => "face",
76
+ "EDGE_CURVE" => "edge",
77
+ "VERTEX_POINT" => "vertex",
78
+ _ => continue,
79
+ };
80
+ *counts.entry(native_type.into()).or_default() += 1;
81
+ entities.push(json!({"id": format!("step-{number}"), "kind": kind, "native_ref": format!("#{number}")}));
82
+ }
83
+ let compact: String = text.chars().filter(|c| !c.is_whitespace()).collect();
84
+ let units: BTreeSet<_> = compact
85
+ .split("SI_UNIT(")
86
+ .skip(1)
87
+ .filter_map(|tail| tail.split_once(')').map(|(unit, _)| unit))
88
+ .filter_map(|unit| unit.strip_suffix(",.METRE."))
89
+ .collect();
90
+ let mut observations = json!({"entities": entities, "observed_types": counts});
91
+ if units.len() == 1 && !text.contains("CONVERSION_BASED_UNIT") {
92
+ let unit = match units.first().copied() {
93
+ Some("$") => Some("m"),
94
+ Some(".MILLI.") => Some("mm"),
95
+ Some(".MICRO.") => Some("um"),
96
+ _ => None,
97
+ };
98
+ if let Some(unit) = unit {
99
+ observations["length_unit"] = json!(unit);
100
+ }
101
+ }
102
+ Ok(observations)
103
+ }
104
+
105
+ fn freecad_observations(path: &Path) -> Result<Value> {
106
+ let mut archive = zip::ZipArchive::new(File::open(path)?)?;
107
+ let mut entry = archive.by_name("Document.xml")?;
108
+ if entry.size() > 4 * 1024 * 1024 {
109
+ return Err("FreeCAD metadata exceeds probe read limit".into());
110
+ }
111
+ let mut xml = String::new();
112
+ entry.read_to_string(&mut xml)?;
113
+ let mut reader = Reader::from_str(&xml);
114
+ let mut in_objects = false;
115
+ let mut entities = Vec::new();
116
+ loop {
117
+ match reader.read_event()? {
118
+ Event::Start(ref element) if element.name().as_ref() == b"Objects" => in_objects = true,
119
+ Event::End(ref element) if element.name().as_ref() == b"Objects" => in_objects = false,
120
+ Event::Empty(ref element) | Event::Start(ref element)
121
+ if in_objects && element.name().as_ref() == b"Object" =>
122
+ {
123
+ let mut name = None;
124
+ let mut native_type = None;
125
+ for attribute in element.attributes() {
126
+ let attribute = attribute?;
127
+ let value = attribute
128
+ .decode_and_unescape_value(reader.decoder())?
129
+ .into_owned();
130
+ match attribute.key.as_ref() {
131
+ b"name" => name = Some(value),
132
+ b"type" => native_type = Some(value),
133
+ _ => {}
134
+ }
135
+ }
136
+ if let Some(name) = name {
137
+ let mut entity = json!({"id": name, "kind": "unknown", "native_ref": name});
138
+ if let Some(native_type) = native_type {
139
+ entity["extensions"] = json!({"freecad": {"version": "0", "attributes": {"object_type": native_type}}});
140
+ }
141
+ entities.push(entity);
142
+ }
143
+ }
144
+ Event::Eof => break,
145
+ _ => {}
146
+ }
147
+ }
148
+ Ok(json!({"entities": entities}))
149
+ }
150
+
151
+ fn cae_projection(raw: &Value, source: Value, setup: Value) -> Value {
152
+ let data = &raw["summary"]["data"];
153
+ let format = raw["format"].as_str().unwrap_or("unknown");
154
+ let namespace = match format {
155
+ "comsol-mph" => "comsol",
156
+ "hfss-aedt" => "ansys.aedt",
157
+ "ansys-mechanical" => "ansys.mechanical",
158
+ "fluent-hdf5" => "ansys.fluent",
159
+ "abaqus-inp" => "abaqus",
160
+ "flotherm-floxml" => "flotherm",
161
+ _ => "source",
162
+ };
163
+ let mut features = Vec::new();
164
+ // Preserve AEDT design identity separately from flattened setup inventories.
165
+ if let Some(designs) = data["designs"].as_array() {
166
+ for (index, design) in designs.iter().enumerate() {
167
+ let mut feature = json!({"id": format!("design-{index}"), "kind": "analysis"});
168
+ for (source_key, target_key) in [("name", "name"), ("design_type", "native_type")] {
169
+ if let Some(value) = design[source_key].as_str().filter(|v| !v.is_empty()) {
170
+ feature[target_key] = json!(value);
171
+ }
172
+ }
173
+ let mut attrs = serde_json::Map::new();
174
+ for key in ["solution_type", "is_solved"] {
175
+ if !design[key].is_null() {
176
+ attrs.insert(key.into(), design[key].clone());
177
+ }
178
+ }
179
+ if !attrs.is_empty() {
180
+ feature["extensions"] = json!({namespace: {"version": "0", "attributes": attrs}});
181
+ }
182
+ features.push(feature);
183
+ }
184
+ }
185
+ for (key, kind) in [
186
+ ("material_tags", "material"),
187
+ ("materials", "material"),
188
+ ("physics_tags", "physics"),
189
+ ("study_tags", "study"),
190
+ ("steps", "study"),
191
+ ("setups", "study"),
192
+ ("boundaries", "condition"),
193
+ ("ports", "condition"),
194
+ ("loads_and_conditions", "condition"),
195
+ ("analyses", "analysis"),
196
+ ("contacts", "interface"),
197
+ ("mesh_operations", "mesh"),
198
+ ] {
199
+ if let Some(names) = data[key].as_array() {
200
+ for (index, name) in names.iter().enumerate() {
201
+ if let Some(name) = name.as_str().filter(|v| !v.is_empty()) {
202
+ features
203
+ .push(json!({"id": format!("{key}-{index}"), "kind": kind, "name": name}));
204
+ }
205
+ }
206
+ }
207
+ }
208
+ let mut attrs = json!({"observed_feature_count": features.len()});
209
+ for key in [
210
+ "node_count",
211
+ "element_count",
212
+ "version_hint",
213
+ "comsol_version",
214
+ "mechanical_version",
215
+ "product",
216
+ ] {
217
+ if data[key].is_number() || data[key].as_str().is_some_and(|value| !value.is_empty()) {
218
+ attrs[key] = data[key].clone();
219
+ }
220
+ }
221
+ for (key, label) in [
222
+ ("parameters", "unscoped_value_count"),
223
+ ("datasets", "dataset_count"),
224
+ ("results", "result_object_count"),
225
+ ] {
226
+ if let Some(values) = data[key].as_array() {
227
+ attrs[label] = json!(values.len());
228
+ }
229
+ }
230
+ // Serialized COMSOL node properties remain in the native setup sidecar.
231
+ // No enabled flags, parameter scopes, units or selections are guessed.
232
+ features.truncate(INLINE_SAMPLE);
233
+ let mut dialect = json!({"version": 0, "source": source, "features": features,
234
+ "setup": setup, "extensions": {namespace: {"version": "0", "attributes": attrs}},
235
+ "warnings": ["Test projection of shallow inventories; scopes and effective activation are not established."]});
236
+ if matches!(format, "abaqus-inp" | "fluent-hdf5") {
237
+ dialect["mesh"] = dialect["source"].clone();
238
+ }
239
+ dialect
240
+ }
241
+
242
+ fn probe(path: &Path, case_dir: &Path) -> Result<Value> {
243
+ fs::create_dir_all(case_dir)?;
244
+ let extension = path
245
+ .extension()
246
+ .unwrap_or_default()
247
+ .to_string_lossy()
248
+ .to_ascii_lowercase();
249
+ let observations_path = case_dir.join("observations.json");
250
+ let (document, format, count) = if matches!(extension.as_str(), "step" | "stp" | "fcstd") {
251
+ let (raw, format) = if extension == "fcstd" {
252
+ (freecad_observations(path)?, "freecad")
253
+ } else {
254
+ (step_observations(path)?, "step")
255
+ };
256
+ fs::write(&observations_path, serde_json::to_vec(&raw)?)?;
257
+ let entities = raw["entities"]
258
+ .as_array()
259
+ .ok_or("entity inventory missing")?;
260
+ let mut dialect = json!({"version": 0, "source": reference(path, format)?,
261
+ "entities": entities.iter().take(INLINE_SAMPLE).collect::<Vec<_>>(),
262
+ "inventory": reference(&observations_path, "json")?,
263
+ "warnings": ["Test probe reads a shallow object inventory; topology and assembly transforms are not validated."]});
264
+ if let Some(unit) = raw["length_unit"].as_str() {
265
+ dialect["length_unit"] = json!(unit);
266
+ }
267
+ (
268
+ json!({"schema": "ai-infra-system/v0", "dialects": {"cad": dialect}}),
269
+ format.to_owned(),
270
+ entities.len(),
271
+ )
272
+ } else {
273
+ let result = inspect_path(path, InspectOptions::default())?;
274
+ let format = result.format.to_string();
275
+ let raw = serde_json::to_value(result)?;
276
+ fs::write(&observations_path, serde_json::to_vec(&raw)?)?;
277
+ let dialect = cae_projection(
278
+ &raw,
279
+ reference(path, &format)?,
280
+ reference(&observations_path, "simparse-inspect-json")?,
281
+ );
282
+ let count = dialect["extensions"]
283
+ .as_object()
284
+ .and_then(|v| v.values().next())
285
+ .and_then(|v| v["attributes"]["observed_feature_count"].as_u64())
286
+ .unwrap_or(0) as usize;
287
+ (
288
+ json!({"schema": "ai-infra-system/v0", "dialects": {"cae": dialect}}),
289
+ format,
290
+ count,
291
+ )
292
+ };
293
+ let bytes = serde_json::to_vec(&document)?;
294
+ fs::write(case_dir.join("system.json"), &bytes)?;
295
+ Ok(
296
+ json!({"format": format, "source_bytes": fs::metadata(path)?.len(),
297
+ "source_sha256": sha256(path)?, "manifest_bytes": bytes.len(), "observed_records": count}),
298
+ )
299
+ }
300
+
301
+ fn main() -> Result<()> {
302
+ let args: Vec<_> = std::env::args().collect();
303
+ if args.len() != 3 {
304
+ return Err("usage: ir_asset_probe assets.json output-dir".into());
305
+ }
306
+ let input = fs::read_to_string(&args[1])?;
307
+ let paths: Vec<String> = serde_json::from_str(input.trim_start_matches('\u{feff}'))?;
308
+ let output = Path::new(&args[2]);
309
+ fs::create_dir_all(output)?;
310
+ let mut results = Vec::new();
311
+ let mut failed = false;
312
+ for (index, path) in paths.iter().enumerate() {
313
+ let mut result = match probe(Path::new(path), &output.join(format!("case-{index:03}"))) {
314
+ Ok(mut value) => {
315
+ value["ok"] = json!(true);
316
+ value
317
+ }
318
+ Err(error) => {
319
+ failed = true;
320
+ json!({"ok": false, "error": error.to_string()})
321
+ }
322
+ };
323
+ result["case"] = json!(index);
324
+ println!("{}", serde_json::to_string(&result)?);
325
+ result["path"] = json!(path);
326
+ results.push(result);
327
+ }
328
+ fs::write(
329
+ output.join("report.json"),
330
+ serde_json::to_vec_pretty(&results)?,
331
+ )?;
332
+ if failed {
333
+ return Err("one or more asset probes failed; inspect report.json".into());
334
+ }
335
+ Ok(())
336
+ }
337
+
338
+ #[cfg(test)]
339
+ mod tests {
340
+ use super::*;
341
+
342
+ fn project(format: &str, data: Value) -> Value {
343
+ cae_projection(
344
+ &json!({"format": format, "summary": {"data": data}}),
345
+ json!({"uri": "source.bin"}),
346
+ json!({"uri": "native-inventory.json"}),
347
+ )
348
+ }
349
+
350
+ #[test]
351
+ fn comsol_serialized_properties_do_not_become_global_parameters() {
352
+ let result = project(
353
+ "comsol-mph",
354
+ json!({"parameters": [
355
+ {"name": "T", "value": "1|1,'300[K]'"}, {"name": "T", "value": "1|1,'400[K]'"}],
356
+ "physics_tags": ["ht"], "is_runnable": false}),
357
+ );
358
+ assert!(result.get("parameters").is_none());
359
+ assert!(result["features"][0].get("enabled").is_none());
360
+ assert_eq!(
361
+ result["extensions"]["comsol"]["attributes"]["unscoped_value_count"],
362
+ 2
363
+ );
364
+ assert_eq!(result["setup"]["uri"], "native-inventory.json");
365
+ }
366
+
367
+ #[test]
368
+ fn aedt_designs_keep_solution_state_separate_from_activation() {
369
+ let result = project(
370
+ "hfss-aedt",
371
+ json!({"designs": [
372
+ {"name": "Design", "design_type": "HFSS", "solution_type": "DrivenModal", "is_solved": false},
373
+ {"name": "Design", "design_type": "Icepak", "solution_type": "SteadyState", "is_solved": true}]}),
374
+ );
375
+ let features = result["features"].as_array().unwrap();
376
+ assert_ne!(features[0]["id"], features[1]["id"]);
377
+ assert_eq!(features[0]["native_type"], "HFSS");
378
+ assert_eq!(features[1]["native_type"], "Icepak");
379
+ assert!(
380
+ features
381
+ .iter()
382
+ .all(|feature| feature.get("enabled").is_none())
383
+ );
384
+ assert_eq!(
385
+ features[0]["extensions"]["ansys.aedt"]["attributes"]["is_solved"],
386
+ false
387
+ );
388
+ }
389
+
390
+ #[test]
391
+ fn mechanical_contacts_and_result_objects_are_not_solve_evidence() {
392
+ let result = project(
393
+ "ansys-mechanical",
394
+ json!({"analyses": ["Thermal"],
395
+ "contacts": ["Die interface"], "loads_and_conditions": ["Temperature"],
396
+ "results": ["Equivalent stress"], "mechanical_version": "test-version"}),
397
+ );
398
+ let kinds: Vec<_> = result["features"]
399
+ .as_array()
400
+ .unwrap()
401
+ .iter()
402
+ .map(|v| v["kind"].as_str().unwrap())
403
+ .collect();
404
+ assert!(
405
+ kinds.contains(&"analysis")
406
+ && kinds.contains(&"interface")
407
+ && kinds.contains(&"condition")
408
+ );
409
+ assert!(result.get("results").is_none());
410
+ assert_eq!(
411
+ result["extensions"]["ansys.mechanical"]["attributes"]["result_object_count"],
412
+ 1
413
+ );
414
+ }
415
+
416
+ #[test]
417
+ fn large_feature_inventories_keep_the_full_sidecar() {
418
+ let names: Vec<_> = (0..100).map(|i| format!("material-{i}")).collect();
419
+ let result = project("comsol-mph", json!({"material_tags": names}));
420
+ assert_eq!(result["features"].as_array().unwrap().len(), INLINE_SAMPLE);
421
+ assert_eq!(
422
+ result["extensions"]["comsol"]["attributes"]["observed_feature_count"],
423
+ 100
424
+ );
425
+ assert_eq!(result["setup"]["uri"], "native-inventory.json");
426
+ }
427
+
428
+ #[test]
429
+ fn conflicting_step_units_remain_unknown() -> Result<()> {
430
+ let directory = tempfile::tempdir()?;
431
+ let path = directory.path().join("mixed.step");
432
+ fs::write(
433
+ &path,
434
+ "ISO-10303-21;DATA;#1=SI_UNIT(.MILLI.,.METRE.);#2=SI_UNIT(.CENTI.,.METRE.);ENDSEC;",
435
+ )?;
436
+ assert!(step_observations(&path)?.get("length_unit").is_none());
437
+ fs::write(
438
+ &path,
439
+ "ISO-10303-21;DATA;#1=SI_UNIT(.MILLI.,.METRE.);ENDSEC;",
440
+ )?;
441
+ assert_eq!(step_observations(&path)?["length_unit"], "mm");
442
+ Ok(())
443
+ }
444
+ }