@kanonak-protocol/expression 1.0.0 → 1.1.0

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.
@@ -0,0 +1,942 @@
1
+ {
2
+ "expressionRuntimeVersion": "2",
3
+ "description": "Alignment vectors (runtime#26): explain() returns verdicts, not labels, and the trace does not mirror the expression node-for-node — its shape follows the operator's dispatch group. `align(expr, trace)` walks both under that contract and yields, per node: `type` (expr and trace agree), `operand` (the key on the parent expression through which the node was reached; absent at the root), `index` (the position within a list operand, or the element index of an iterating body), `element` ({loopVar, value} for an iterating body: element k of the source value coerced to a list), `value` (the trace verdict) and `children`. It pairs, never renders. A trace that does not fit is an error (`expectError`: the trace of `expr` aligned against `alignExpr`). Values, env, graph, refEnv and closures follow expression-vectors-2.json.",
4
+ "vectors": [
5
+ {
6
+ "id": "align-filter-list-source-with-rejected-element",
7
+ "description": "IteratingExpression: children[0] pairs with `source`; body trace k pairs with the body operand under element k (loopVar + value), every element including the rejected one. The caller leaf (PropertyRead) pairs as a LEAF — its readSource is the caller's computation and is not traced",
8
+ "expr": {
9
+ "type": "kanonak.org/transformations/Count",
10
+ "source": {
11
+ "type": "kanonak.org/transformations/Filter",
12
+ "source": {
13
+ "type": "kanonak.org/transformations/VarRef",
14
+ "varName": "items"
15
+ },
16
+ "loopVar": "it",
17
+ "predicate": {
18
+ "type": "kanonak.org/transformations/Equals",
19
+ "compareLeft": {
20
+ "type": "kanonak.org/transformations/PropertyRead",
21
+ "readSource": {
22
+ "type": "kanonak.org/transformations/VarRef",
23
+ "varName": "it"
24
+ },
25
+ "readProp": "size"
26
+ },
27
+ "compareRight": {
28
+ "type": "kanonak.org/transformations/IntegerLiteral",
29
+ "integerLiteral": 20
30
+ }
31
+ }
32
+ }
33
+ },
34
+ "env": {
35
+ "items": [
36
+ {
37
+ "ref": "example.org/inv/item-1"
38
+ },
39
+ {
40
+ "ref": "example.org/inv/item-2"
41
+ }
42
+ ]
43
+ },
44
+ "graph": {
45
+ "example.org/inv/item-1": {
46
+ "size": 10,
47
+ "tags": [
48
+ "a",
49
+ "b"
50
+ ]
51
+ },
52
+ "example.org/inv/item-2": {
53
+ "size": 20,
54
+ "tags": "c",
55
+ "owner": {
56
+ "ref": "example.org/inv/ann"
57
+ }
58
+ }
59
+ },
60
+ "expected": {
61
+ "type": "kanonak.org/transformations/Count",
62
+ "value": 1,
63
+ "children": [
64
+ {
65
+ "type": "kanonak.org/transformations/Filter",
66
+ "operand": "source",
67
+ "value": [
68
+ {
69
+ "ref": "example.org/inv/item-2"
70
+ }
71
+ ],
72
+ "children": [
73
+ {
74
+ "type": "kanonak.org/transformations/VarRef",
75
+ "operand": "source",
76
+ "value": [
77
+ {
78
+ "ref": "example.org/inv/item-1"
79
+ },
80
+ {
81
+ "ref": "example.org/inv/item-2"
82
+ }
83
+ ],
84
+ "children": []
85
+ },
86
+ {
87
+ "type": "kanonak.org/transformations/Equals",
88
+ "operand": "predicate",
89
+ "index": 0,
90
+ "element": {
91
+ "loopVar": "it",
92
+ "value": {
93
+ "ref": "example.org/inv/item-1"
94
+ }
95
+ },
96
+ "value": 0,
97
+ "children": [
98
+ {
99
+ "type": "kanonak.org/transformations/PropertyRead",
100
+ "operand": "compareLeft",
101
+ "value": 10,
102
+ "children": []
103
+ },
104
+ {
105
+ "type": "kanonak.org/transformations/IntegerLiteral",
106
+ "operand": "compareRight",
107
+ "value": 20,
108
+ "children": []
109
+ }
110
+ ]
111
+ },
112
+ {
113
+ "type": "kanonak.org/transformations/Equals",
114
+ "operand": "predicate",
115
+ "index": 1,
116
+ "element": {
117
+ "loopVar": "it",
118
+ "value": {
119
+ "ref": "example.org/inv/item-2"
120
+ }
121
+ },
122
+ "value": 1,
123
+ "children": [
124
+ {
125
+ "type": "kanonak.org/transformations/PropertyRead",
126
+ "operand": "compareLeft",
127
+ "value": 20,
128
+ "children": []
129
+ },
130
+ {
131
+ "type": "kanonak.org/transformations/IntegerLiteral",
132
+ "operand": "compareRight",
133
+ "value": 20,
134
+ "children": []
135
+ }
136
+ ]
137
+ }
138
+ ]
139
+ }
140
+ ]
141
+ }
142
+ },
143
+ {
144
+ "id": "align-filter-scalar-source-coerced",
145
+ "description": "The coercion hole: a one-valued source iterates as a one-element list while its source trace carries the scalar; align reports element 0 = that scalar",
146
+ "expr": {
147
+ "type": "kanonak.org/transformations/Filter",
148
+ "source": {
149
+ "type": "kanonak.org/transformations/PropertyRead",
150
+ "readSource": {
151
+ "type": "kanonak.org/transformations/VarRef",
152
+ "varName": "x"
153
+ },
154
+ "readProp": "tags"
155
+ },
156
+ "loopVar": "t",
157
+ "predicate": {
158
+ "type": "kanonak.org/transformations/Equals",
159
+ "compareLeft": {
160
+ "type": "kanonak.org/transformations/VarRef",
161
+ "varName": "t"
162
+ },
163
+ "compareRight": {
164
+ "type": "kanonak.org/transformations/StringLiteral",
165
+ "stringLiteral": "c"
166
+ }
167
+ }
168
+ },
169
+ "env": {
170
+ "x": {
171
+ "ref": "example.org/inv/item-2"
172
+ }
173
+ },
174
+ "graph": {
175
+ "example.org/inv/item-1": {
176
+ "size": 10,
177
+ "tags": [
178
+ "a",
179
+ "b"
180
+ ]
181
+ },
182
+ "example.org/inv/item-2": {
183
+ "size": 20,
184
+ "tags": "c",
185
+ "owner": {
186
+ "ref": "example.org/inv/ann"
187
+ }
188
+ }
189
+ },
190
+ "expected": {
191
+ "type": "kanonak.org/transformations/Filter",
192
+ "value": [
193
+ "c"
194
+ ],
195
+ "children": [
196
+ {
197
+ "type": "kanonak.org/transformations/PropertyRead",
198
+ "operand": "source",
199
+ "value": "c",
200
+ "children": []
201
+ },
202
+ {
203
+ "type": "kanonak.org/transformations/Equals",
204
+ "operand": "predicate",
205
+ "index": 0,
206
+ "element": {
207
+ "loopVar": "t",
208
+ "value": "c"
209
+ },
210
+ "value": 1,
211
+ "children": [
212
+ {
213
+ "type": "kanonak.org/transformations/VarRef",
214
+ "operand": "compareLeft",
215
+ "value": "c",
216
+ "children": []
217
+ },
218
+ {
219
+ "type": "kanonak.org/transformations/StringLiteral",
220
+ "operand": "compareRight",
221
+ "value": "c",
222
+ "children": []
223
+ }
224
+ ]
225
+ }
226
+ ]
227
+ }
228
+ },
229
+ {
230
+ "id": "align-and-short-circuit-prefix",
231
+ "description": "BooleanLogic: the trace is a PREFIX of `operands`; the second operand (an unbound VarRef that would error) was never evaluated and has no aligned node — absence means \"did not run\"",
232
+ "expr": {
233
+ "type": "kanonak.org/transformations/And",
234
+ "operands": [
235
+ {
236
+ "type": "kanonak.org/transformations/GreaterThan",
237
+ "compareLeft": {
238
+ "type": "kanonak.org/transformations/IntegerLiteral",
239
+ "integerLiteral": 1
240
+ },
241
+ "compareRight": {
242
+ "type": "kanonak.org/transformations/IntegerLiteral",
243
+ "integerLiteral": 2
244
+ }
245
+ },
246
+ {
247
+ "type": "kanonak.org/transformations/VarRef",
248
+ "varName": "never"
249
+ }
250
+ ]
251
+ },
252
+ "env": {},
253
+ "expected": {
254
+ "type": "kanonak.org/transformations/And",
255
+ "value": 0,
256
+ "children": [
257
+ {
258
+ "type": "kanonak.org/transformations/GreaterThan",
259
+ "operand": "operands",
260
+ "index": 0,
261
+ "value": 0,
262
+ "children": [
263
+ {
264
+ "type": "kanonak.org/transformations/IntegerLiteral",
265
+ "operand": "compareLeft",
266
+ "value": 1,
267
+ "children": []
268
+ },
269
+ {
270
+ "type": "kanonak.org/transformations/IntegerLiteral",
271
+ "operand": "compareRight",
272
+ "value": 2,
273
+ "children": []
274
+ }
275
+ ]
276
+ }
277
+ ]
278
+ }
279
+ },
280
+ {
281
+ "id": "align-ordered-comparison-has-no-children",
282
+ "description": "OrderedComparison: nothing to pair — the verdict and the resolved identities are on the trace node itself (leftRef/rightRef); the operands are not visited",
283
+ "expr": {
284
+ "type": "kanonak.org/transformations/And",
285
+ "operands": [
286
+ {
287
+ "type": "kanonak.org/transformations/IsAtLeast",
288
+ "viaProperty": "example.org/severity/dominates",
289
+ "compareLeft": {
290
+ "type": "kanonak.org/transformations/VarRef",
291
+ "varName": "observed"
292
+ },
293
+ "compareRight": {
294
+ "type": "kanonak.org/transformations/UriLiteral",
295
+ "refTo": "example.org/severity/warn"
296
+ }
297
+ },
298
+ {
299
+ "type": "kanonak.org/transformations/Equals",
300
+ "compareLeft": {
301
+ "type": "kanonak.org/transformations/IntegerLiteral",
302
+ "integerLiteral": 1
303
+ },
304
+ "compareRight": {
305
+ "type": "kanonak.org/transformations/IntegerLiteral",
306
+ "integerLiteral": 2
307
+ }
308
+ }
309
+ ]
310
+ },
311
+ "refEnv": {
312
+ "observed": "example.org/severity/error"
313
+ },
314
+ "closures": {
315
+ "example.org/severity/dominates": {
316
+ "example.org/severity/error": [
317
+ "example.org/severity/warn"
318
+ ]
319
+ }
320
+ },
321
+ "expected": {
322
+ "type": "kanonak.org/transformations/And",
323
+ "value": 0,
324
+ "children": [
325
+ {
326
+ "type": "kanonak.org/transformations/IsAtLeast",
327
+ "operand": "operands",
328
+ "index": 0,
329
+ "value": 1,
330
+ "children": []
331
+ },
332
+ {
333
+ "type": "kanonak.org/transformations/Equals",
334
+ "operand": "operands",
335
+ "index": 1,
336
+ "value": 0,
337
+ "children": [
338
+ {
339
+ "type": "kanonak.org/transformations/IntegerLiteral",
340
+ "operand": "compareLeft",
341
+ "value": 1,
342
+ "children": []
343
+ },
344
+ {
345
+ "type": "kanonak.org/transformations/IntegerLiteral",
346
+ "operand": "compareRight",
347
+ "value": 2,
348
+ "children": []
349
+ }
350
+ ]
351
+ }
352
+ ]
353
+ }
354
+ },
355
+ {
356
+ "id": "align-nested-iterators-shadowing",
357
+ "description": "Nested binders with the same loopVar: each body carries ITS binder's element, so the inner element is visible per inner iteration and the outer per outer",
358
+ "expr": {
359
+ "type": "kanonak.org/transformations/ListMap",
360
+ "source": {
361
+ "type": "kanonak.org/transformations/VarRef",
362
+ "varName": "items"
363
+ },
364
+ "loopVar": "it",
365
+ "mapBody": {
366
+ "type": "kanonak.org/transformations/Count",
367
+ "source": {
368
+ "type": "kanonak.org/transformations/Filter",
369
+ "source": {
370
+ "type": "kanonak.org/transformations/VarRef",
371
+ "varName": "items"
372
+ },
373
+ "loopVar": "it",
374
+ "predicate": {
375
+ "type": "kanonak.org/transformations/Equals",
376
+ "compareLeft": {
377
+ "type": "kanonak.org/transformations/PropertyRead",
378
+ "readSource": {
379
+ "type": "kanonak.org/transformations/VarRef",
380
+ "varName": "it"
381
+ },
382
+ "readProp": "size"
383
+ },
384
+ "compareRight": {
385
+ "type": "kanonak.org/transformations/IntegerLiteral",
386
+ "integerLiteral": 20
387
+ }
388
+ }
389
+ }
390
+ }
391
+ },
392
+ "env": {
393
+ "items": [
394
+ {
395
+ "ref": "example.org/inv/item-1"
396
+ },
397
+ {
398
+ "ref": "example.org/inv/item-2"
399
+ }
400
+ ]
401
+ },
402
+ "graph": {
403
+ "example.org/inv/item-1": {
404
+ "size": 10,
405
+ "tags": [
406
+ "a",
407
+ "b"
408
+ ]
409
+ },
410
+ "example.org/inv/item-2": {
411
+ "size": 20,
412
+ "tags": "c",
413
+ "owner": {
414
+ "ref": "example.org/inv/ann"
415
+ }
416
+ }
417
+ },
418
+ "expected": {
419
+ "type": "kanonak.org/transformations/ListMap",
420
+ "value": [
421
+ 1,
422
+ 1
423
+ ],
424
+ "children": [
425
+ {
426
+ "type": "kanonak.org/transformations/VarRef",
427
+ "operand": "source",
428
+ "value": [
429
+ {
430
+ "ref": "example.org/inv/item-1"
431
+ },
432
+ {
433
+ "ref": "example.org/inv/item-2"
434
+ }
435
+ ],
436
+ "children": []
437
+ },
438
+ {
439
+ "type": "kanonak.org/transformations/Count",
440
+ "operand": "mapBody",
441
+ "index": 0,
442
+ "element": {
443
+ "loopVar": "it",
444
+ "value": {
445
+ "ref": "example.org/inv/item-1"
446
+ }
447
+ },
448
+ "value": 1,
449
+ "children": [
450
+ {
451
+ "type": "kanonak.org/transformations/Filter",
452
+ "operand": "source",
453
+ "value": [
454
+ {
455
+ "ref": "example.org/inv/item-2"
456
+ }
457
+ ],
458
+ "children": [
459
+ {
460
+ "type": "kanonak.org/transformations/VarRef",
461
+ "operand": "source",
462
+ "value": [
463
+ {
464
+ "ref": "example.org/inv/item-1"
465
+ },
466
+ {
467
+ "ref": "example.org/inv/item-2"
468
+ }
469
+ ],
470
+ "children": []
471
+ },
472
+ {
473
+ "type": "kanonak.org/transformations/Equals",
474
+ "operand": "predicate",
475
+ "index": 0,
476
+ "element": {
477
+ "loopVar": "it",
478
+ "value": {
479
+ "ref": "example.org/inv/item-1"
480
+ }
481
+ },
482
+ "value": 0,
483
+ "children": [
484
+ {
485
+ "type": "kanonak.org/transformations/PropertyRead",
486
+ "operand": "compareLeft",
487
+ "value": 10,
488
+ "children": []
489
+ },
490
+ {
491
+ "type": "kanonak.org/transformations/IntegerLiteral",
492
+ "operand": "compareRight",
493
+ "value": 20,
494
+ "children": []
495
+ }
496
+ ]
497
+ },
498
+ {
499
+ "type": "kanonak.org/transformations/Equals",
500
+ "operand": "predicate",
501
+ "index": 1,
502
+ "element": {
503
+ "loopVar": "it",
504
+ "value": {
505
+ "ref": "example.org/inv/item-2"
506
+ }
507
+ },
508
+ "value": 1,
509
+ "children": [
510
+ {
511
+ "type": "kanonak.org/transformations/PropertyRead",
512
+ "operand": "compareLeft",
513
+ "value": 20,
514
+ "children": []
515
+ },
516
+ {
517
+ "type": "kanonak.org/transformations/IntegerLiteral",
518
+ "operand": "compareRight",
519
+ "value": 20,
520
+ "children": []
521
+ }
522
+ ]
523
+ }
524
+ ]
525
+ }
526
+ ]
527
+ },
528
+ {
529
+ "type": "kanonak.org/transformations/Count",
530
+ "operand": "mapBody",
531
+ "index": 1,
532
+ "element": {
533
+ "loopVar": "it",
534
+ "value": {
535
+ "ref": "example.org/inv/item-2"
536
+ }
537
+ },
538
+ "value": 1,
539
+ "children": [
540
+ {
541
+ "type": "kanonak.org/transformations/Filter",
542
+ "operand": "source",
543
+ "value": [
544
+ {
545
+ "ref": "example.org/inv/item-2"
546
+ }
547
+ ],
548
+ "children": [
549
+ {
550
+ "type": "kanonak.org/transformations/VarRef",
551
+ "operand": "source",
552
+ "value": [
553
+ {
554
+ "ref": "example.org/inv/item-1"
555
+ },
556
+ {
557
+ "ref": "example.org/inv/item-2"
558
+ }
559
+ ],
560
+ "children": []
561
+ },
562
+ {
563
+ "type": "kanonak.org/transformations/Equals",
564
+ "operand": "predicate",
565
+ "index": 0,
566
+ "element": {
567
+ "loopVar": "it",
568
+ "value": {
569
+ "ref": "example.org/inv/item-1"
570
+ }
571
+ },
572
+ "value": 0,
573
+ "children": [
574
+ {
575
+ "type": "kanonak.org/transformations/PropertyRead",
576
+ "operand": "compareLeft",
577
+ "value": 10,
578
+ "children": []
579
+ },
580
+ {
581
+ "type": "kanonak.org/transformations/IntegerLiteral",
582
+ "operand": "compareRight",
583
+ "value": 20,
584
+ "children": []
585
+ }
586
+ ]
587
+ },
588
+ {
589
+ "type": "kanonak.org/transformations/Equals",
590
+ "operand": "predicate",
591
+ "index": 1,
592
+ "element": {
593
+ "loopVar": "it",
594
+ "value": {
595
+ "ref": "example.org/inv/item-2"
596
+ }
597
+ },
598
+ "value": 1,
599
+ "children": [
600
+ {
601
+ "type": "kanonak.org/transformations/PropertyRead",
602
+ "operand": "compareLeft",
603
+ "value": 20,
604
+ "children": []
605
+ },
606
+ {
607
+ "type": "kanonak.org/transformations/IntegerLiteral",
608
+ "operand": "compareRight",
609
+ "value": 20,
610
+ "children": []
611
+ }
612
+ ]
613
+ }
614
+ ]
615
+ }
616
+ ]
617
+ }
618
+ ]
619
+ }
620
+ },
621
+ {
622
+ "id": "align-ternary-and-arithmetic-positional",
623
+ "description": "Positional groups: Clip pairs clipValue/clipLower/clipUpper in that order; Add pairs arithLeft/arithRight",
624
+ "expr": {
625
+ "type": "kanonak.org/math/Clip",
626
+ "clipValue": {
627
+ "type": "kanonak.org/transformations/Add",
628
+ "arithLeft": {
629
+ "type": "kanonak.org/transformations/IntegerLiteral",
630
+ "integerLiteral": 2
631
+ },
632
+ "arithRight": {
633
+ "type": "kanonak.org/transformations/IntegerLiteral",
634
+ "integerLiteral": 3
635
+ }
636
+ },
637
+ "clipLower": {
638
+ "type": "kanonak.org/transformations/IntegerLiteral",
639
+ "integerLiteral": 0
640
+ },
641
+ "clipUpper": {
642
+ "type": "kanonak.org/transformations/IntegerLiteral",
643
+ "integerLiteral": 4
644
+ }
645
+ },
646
+ "expected": {
647
+ "type": "kanonak.org/math/Clip",
648
+ "value": 4,
649
+ "children": [
650
+ {
651
+ "type": "kanonak.org/transformations/Add",
652
+ "operand": "clipValue",
653
+ "value": 5,
654
+ "children": [
655
+ {
656
+ "type": "kanonak.org/transformations/IntegerLiteral",
657
+ "operand": "arithLeft",
658
+ "value": 2,
659
+ "children": []
660
+ },
661
+ {
662
+ "type": "kanonak.org/transformations/IntegerLiteral",
663
+ "operand": "arithRight",
664
+ "value": 3,
665
+ "children": []
666
+ }
667
+ ]
668
+ },
669
+ {
670
+ "type": "kanonak.org/transformations/IntegerLiteral",
671
+ "operand": "clipLower",
672
+ "value": 0,
673
+ "children": []
674
+ },
675
+ {
676
+ "type": "kanonak.org/transformations/IntegerLiteral",
677
+ "operand": "clipUpper",
678
+ "value": 4,
679
+ "children": []
680
+ }
681
+ ]
682
+ }
683
+ },
684
+ {
685
+ "id": "align-direct-operators-not-isset-listitemat",
686
+ "description": "Direct operators: Not→operand, IsSet→checkExpr, ListItemAt→source,itemIndex",
687
+ "expr": {
688
+ "type": "kanonak.org/transformations/Not",
689
+ "operand": {
690
+ "type": "kanonak.org/transformations/IsSet",
691
+ "checkExpr": {
692
+ "type": "kanonak.org/transformations/ListItemAt",
693
+ "source": {
694
+ "type": "kanonak.org/transformations/VarRef",
695
+ "varName": "xs"
696
+ },
697
+ "itemIndex": {
698
+ "type": "kanonak.org/transformations/IntegerLiteral",
699
+ "integerLiteral": 5
700
+ }
701
+ }
702
+ }
703
+ },
704
+ "env": {
705
+ "xs": [
706
+ "a",
707
+ "b"
708
+ ]
709
+ },
710
+ "expected": {
711
+ "type": "kanonak.org/transformations/Not",
712
+ "value": 1,
713
+ "children": [
714
+ {
715
+ "type": "kanonak.org/transformations/IsSet",
716
+ "operand": "operand",
717
+ "value": 0,
718
+ "children": [
719
+ {
720
+ "type": "kanonak.org/transformations/ListItemAt",
721
+ "operand": "checkExpr",
722
+ "value": [],
723
+ "children": [
724
+ {
725
+ "type": "kanonak.org/transformations/VarRef",
726
+ "operand": "source",
727
+ "value": [
728
+ "a",
729
+ "b"
730
+ ],
731
+ "children": []
732
+ },
733
+ {
734
+ "type": "kanonak.org/transformations/IntegerLiteral",
735
+ "operand": "itemIndex",
736
+ "value": 5,
737
+ "children": []
738
+ }
739
+ ]
740
+ }
741
+ ]
742
+ }
743
+ ]
744
+ }
745
+ },
746
+ {
747
+ "id": "align-direct-operators-contains-matches-join",
748
+ "description": "Direct operators: Contains→haystack,needle; Matches→matchSource (pattern is data); Join→source",
749
+ "expr": {
750
+ "type": "kanonak.org/transformations/And",
751
+ "operands": [
752
+ {
753
+ "type": "kanonak.org/transformations/Contains",
754
+ "haystack": {
755
+ "type": "kanonak.org/transformations/VarRef",
756
+ "varName": "xs"
757
+ },
758
+ "needle": {
759
+ "type": "kanonak.org/transformations/StringLiteral",
760
+ "stringLiteral": "b"
761
+ }
762
+ },
763
+ {
764
+ "type": "kanonak.org/transformations/Matches",
765
+ "matchSource": {
766
+ "type": "kanonak.org/transformations/Join",
767
+ "source": {
768
+ "type": "kanonak.org/transformations/VarRef",
769
+ "varName": "xs"
770
+ },
771
+ "separator": "-"
772
+ },
773
+ "pattern": "a-b"
774
+ }
775
+ ]
776
+ },
777
+ "env": {
778
+ "xs": [
779
+ "a",
780
+ "b"
781
+ ]
782
+ },
783
+ "expected": {
784
+ "type": "kanonak.org/transformations/And",
785
+ "value": 1,
786
+ "children": [
787
+ {
788
+ "type": "kanonak.org/transformations/Contains",
789
+ "operand": "operands",
790
+ "index": 0,
791
+ "value": 1,
792
+ "children": [
793
+ {
794
+ "type": "kanonak.org/transformations/VarRef",
795
+ "operand": "haystack",
796
+ "value": [
797
+ "a",
798
+ "b"
799
+ ],
800
+ "children": []
801
+ },
802
+ {
803
+ "type": "kanonak.org/transformations/StringLiteral",
804
+ "operand": "needle",
805
+ "value": "b",
806
+ "children": []
807
+ }
808
+ ]
809
+ },
810
+ {
811
+ "type": "kanonak.org/transformations/Matches",
812
+ "operand": "operands",
813
+ "index": 1,
814
+ "value": 1,
815
+ "children": [
816
+ {
817
+ "type": "kanonak.org/transformations/Join",
818
+ "operand": "matchSource",
819
+ "value": "a-b",
820
+ "children": [
821
+ {
822
+ "type": "kanonak.org/transformations/VarRef",
823
+ "operand": "source",
824
+ "value": [
825
+ "a",
826
+ "b"
827
+ ],
828
+ "children": []
829
+ }
830
+ ]
831
+ }
832
+ ]
833
+ }
834
+ ]
835
+ }
836
+ },
837
+ {
838
+ "id": "align-kind-predicate-and-unary-chain",
839
+ "description": "KindPredicate→kindCheck; UnaryNumericOp→value, nested",
840
+ "expr": {
841
+ "type": "kanonak.org/transformations/IsNumber",
842
+ "kindCheck": {
843
+ "type": "kanonak.org/transformations/Abs",
844
+ "value": {
845
+ "type": "kanonak.org/transformations/Negate",
846
+ "value": {
847
+ "type": "kanonak.org/transformations/IntegerLiteral",
848
+ "integerLiteral": 3
849
+ }
850
+ }
851
+ }
852
+ },
853
+ "expected": {
854
+ "type": "kanonak.org/transformations/IsNumber",
855
+ "value": 1,
856
+ "children": [
857
+ {
858
+ "type": "kanonak.org/transformations/Abs",
859
+ "operand": "kindCheck",
860
+ "value": 3,
861
+ "children": [
862
+ {
863
+ "type": "kanonak.org/transformations/Negate",
864
+ "operand": "value",
865
+ "value": -3,
866
+ "children": [
867
+ {
868
+ "type": "kanonak.org/transformations/IntegerLiteral",
869
+ "operand": "value",
870
+ "value": 3,
871
+ "children": []
872
+ }
873
+ ]
874
+ }
875
+ ]
876
+ }
877
+ ]
878
+ }
879
+ },
880
+ {
881
+ "id": "align-rejects-a-trace-from-another-expression",
882
+ "description": "A trace that does not fit the expression is an ERROR, never a best-effort pairing: here the trace of Add(1,2) is aligned against Subtract(1,2)",
883
+ "expr": {
884
+ "type": "kanonak.org/transformations/Add",
885
+ "arithLeft": {
886
+ "type": "kanonak.org/transformations/IntegerLiteral",
887
+ "integerLiteral": 1
888
+ },
889
+ "arithRight": {
890
+ "type": "kanonak.org/transformations/IntegerLiteral",
891
+ "integerLiteral": 2
892
+ }
893
+ },
894
+ "alignExpr": {
895
+ "type": "kanonak.org/transformations/Subtract",
896
+ "arithLeft": {
897
+ "type": "kanonak.org/transformations/IntegerLiteral",
898
+ "integerLiteral": 1
899
+ },
900
+ "arithRight": {
901
+ "type": "kanonak.org/transformations/IntegerLiteral",
902
+ "integerLiteral": 2
903
+ }
904
+ },
905
+ "expectError": true
906
+ },
907
+ {
908
+ "id": "align-rejects-a-trace-with-the-wrong-arity",
909
+ "description": "Same root type, different tree: the trace of Add(1,2) against Add(1, Add(2,3)) fails at the child whose type does not match",
910
+ "expr": {
911
+ "type": "kanonak.org/transformations/Add",
912
+ "arithLeft": {
913
+ "type": "kanonak.org/transformations/IntegerLiteral",
914
+ "integerLiteral": 1
915
+ },
916
+ "arithRight": {
917
+ "type": "kanonak.org/transformations/IntegerLiteral",
918
+ "integerLiteral": 2
919
+ }
920
+ },
921
+ "alignExpr": {
922
+ "type": "kanonak.org/transformations/Add",
923
+ "arithLeft": {
924
+ "type": "kanonak.org/transformations/IntegerLiteral",
925
+ "integerLiteral": 1
926
+ },
927
+ "arithRight": {
928
+ "type": "kanonak.org/transformations/Add",
929
+ "arithLeft": {
930
+ "type": "kanonak.org/transformations/IntegerLiteral",
931
+ "integerLiteral": 2
932
+ },
933
+ "arithRight": {
934
+ "type": "kanonak.org/transformations/IntegerLiteral",
935
+ "integerLiteral": 3
936
+ }
937
+ }
938
+ },
939
+ "expectError": true
940
+ }
941
+ ]
942
+ }