@@ -18,6 +18,26 @@ use binoc_sdk::*;
1818
1919use binoc_stdlib:: renderers:: markdown as md_renderer;
2020
21+ fn restore_transform_transient_fields (
22+ result : & mut TransformResult ,
23+ source_items : & Option < ItemPair > ,
24+ artifacts : & [ ArtifactDescriptor ] ,
25+ ) {
26+ match result {
27+ TransformResult :: Replace ( ref mut node) => {
28+ node. source_items = source_items. clone ( ) ;
29+ node. artifacts = artifacts. to_vec ( ) ;
30+ }
31+ TransformResult :: ReplaceMany ( ref mut nodes) => {
32+ for node in nodes. iter_mut ( ) {
33+ node. source_items = source_items. clone ( ) ;
34+ node. artifacts = artifacts. to_vec ( ) ;
35+ }
36+ }
37+ _ => { }
38+ }
39+ }
40+
2141// ═══════════════════════════════════════════════════════════════════════════
2242// Native plugin loader — loads Rust plugins via C ABI (libloading)
2343// ═══════════════════════════════════════════════════════════════════════════
@@ -160,7 +180,18 @@ impl Comparator for NativeComparator {
160180 let response: CompareResponse = serde_json:: from_str ( & json)
161181 . map_err ( |e| BinocError :: Other ( format ! ( "deserialize CompareResponse: {e}" ) ) ) ?;
162182 match response {
163- CompareResponse :: Ok { result } => Ok ( * result) ,
183+ CompareResponse :: Ok {
184+ mut result,
185+ artifacts,
186+ } => {
187+ match result. as_mut ( ) {
188+ CompareResult :: Leaf ( n) | CompareResult :: Expand ( n, _) => {
189+ n. artifacts = artifacts;
190+ }
191+ _ => { }
192+ }
193+ Ok ( * result)
194+ }
164195 CompareResponse :: Error { message } => Err ( BinocError :: Comparator {
165196 comparator : self . desc . name . clone ( ) ,
166197 message,
@@ -212,6 +243,7 @@ impl Comparator for NativeComparator {
212243 aspect : aspect. to_string ( ) ,
213244 data_root : data_root. to_string_lossy ( ) . to_string ( ) ,
214245 source_items : node. source_items . clone ( ) ,
246+ artifacts : node. artifacts . clone ( ) ,
215247 } ;
216248 let request_json = serde_json:: to_string ( & request) . ok ( ) ?;
217249 let json = self
@@ -249,10 +281,12 @@ impl Transformer for NativeTransformer {
249281 Err ( _) => return TransformResult :: Unchanged ,
250282 } ;
251283 let source_items = node. source_items . clone ( ) ;
284+ let artifacts = node. artifacts . clone ( ) ;
252285 let request = TransformRequest {
253286 node,
254287 data_root : data_root. to_string_lossy ( ) . to_string ( ) ,
255- source_items,
288+ source_items : source_items. clone ( ) ,
289+ artifacts : artifacts. clone ( ) ,
256290 } ;
257291 let request_json = match serde_json:: to_string ( & request) {
258292 Ok ( j) => j,
@@ -269,10 +303,12 @@ impl Transformer for NativeTransformer {
269303 Ok ( r) => r,
270304 Err ( _) => return TransformResult :: Unchanged ,
271305 } ;
272- match response. into_result ( ) {
306+ let mut result = match response. into_result ( ) {
273307 Ok ( r) => r,
274308 Err ( _) => TransformResult :: Unchanged ,
275- }
309+ } ;
310+ restore_transform_transient_fields ( & mut result, & source_items, & artifacts) ;
311+ result
276312 }
277313
278314 fn extract (
@@ -288,6 +324,7 @@ impl Transformer for NativeTransformer {
288324 aspect : aspect. to_string ( ) ,
289325 data_root : data_root. to_string_lossy ( ) . to_string ( ) ,
290326 source_items : node. source_items . clone ( ) ,
327+ artifacts : node. artifacts . clone ( ) ,
291328 } ;
292329 let request_json = serde_json:: to_string ( & request) . ok ( ) ?;
293330 let json = self
@@ -1236,10 +1273,21 @@ fn create_transformer_bridge(
12361273 . getattr ( "match_actions" )
12371274 . and_then ( |v| v. extract ( ) )
12381275 . unwrap_or_default ( ) ;
1276+ let node_shape: NodeShapeFilter = obj
1277+ . getattr ( "node_shape" )
1278+ . and_then ( |v| v. extract :: < String > ( ) )
1279+ . ok ( )
1280+ . and_then ( |s| match s. as_str ( ) {
1281+ "container" => Some ( NodeShapeFilter :: Container ) ,
1282+ "leaf" => Some ( NodeShapeFilter :: Leaf ) ,
1283+ _ => None ,
1284+ } )
1285+ . unwrap_or_default ( ) ;
12391286 let desc = TransformerDescriptor :: new ( name)
12401287 . with_match_types ( match_types)
12411288 . with_match_tags ( match_tags)
1242- . with_match_actions ( match_actions) ;
1289+ . with_match_actions ( match_actions)
1290+ . with_node_shape ( node_shape) ;
12431291 Ok ( PyTransformerBridge {
12441292 py_obj : obj. clone ( ) . unbind ( ) ,
12451293 desc,
0 commit comments