@kgdiff/core 0.1.0 → 0.3.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,566 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://cdn.jsdelivr.net/npm/@kgdiff/core/schema/diff.v1.json",
4
+ "title": "kgdiff diff, version 1",
5
+ "description": "A complete diff, as `kgdiff --json` and diffToJSON write it: the union of both graphs with what changed, the review hunks, the matches and the delta. diffFromJSON rebuilds both graphs from it. See https://github.com/iiwish/kgdiff/blob/main/docs/architecture.md",
6
+ "type": "object",
7
+ "properties": {
8
+ "format": { "const": "kgdiff.diff" },
9
+ "version": {
10
+ "const": 1,
11
+ "description": "Readers reject versions they do not support."
12
+ },
13
+ "meta": {
14
+ "type": "object",
15
+ "properties": {
16
+ "before": { "$ref": "graph.v1.json#/$defs/meta" },
17
+ "after": { "$ref": "graph.v1.json#/$defs/meta" }
18
+ },
19
+ "required": ["before", "after"],
20
+ "additionalProperties": false
21
+ },
22
+ "options": { "$ref": "#/$defs/options" },
23
+ "nodes": {
24
+ "type": "array",
25
+ "items": { "$ref": "#/$defs/unionNode" },
26
+ "description": "Every node of either version, sorted by id."
27
+ },
28
+ "edges": {
29
+ "type": "array",
30
+ "items": { "$ref": "#/$defs/unionEdge" },
31
+ "description": "Every edge of either version, sorted by id."
32
+ },
33
+ "hunks": {
34
+ "type": "array",
35
+ "items": { "$ref": "#/$defs/hunk" },
36
+ "description": "The review units, sorted by order."
37
+ },
38
+ "matches": {
39
+ "type": "array",
40
+ "items": { "$ref": "#/$defs/match" },
41
+ "description": "Node pairs found by replacement hints or by similarity, sorted by after. Pairs with equal ids are implied."
42
+ },
43
+ "suggestions": {
44
+ "type": "array",
45
+ "items": { "$ref": "#/$defs/suggestion" },
46
+ "description": "Plausible pairs that were not applied."
47
+ },
48
+ "delta": { "$ref": "delta.v1.json" },
49
+ "stats": { "$ref": "#/$defs/stats" }
50
+ },
51
+ "required": [
52
+ "format",
53
+ "version",
54
+ "meta",
55
+ "options",
56
+ "nodes",
57
+ "edges",
58
+ "hunks",
59
+ "matches",
60
+ "suggestions",
61
+ "delta",
62
+ "stats"
63
+ ],
64
+ "additionalProperties": false,
65
+ "$defs": {
66
+ "unionId": {
67
+ "type": "string",
68
+ "description": "Id of an element of the union: the after-version id, or the before-version id for a removed node."
69
+ },
70
+ "unionIds": {
71
+ "type": "array",
72
+ "items": { "$ref": "#/$defs/unionId" }
73
+ },
74
+ "strings": {
75
+ "type": "array",
76
+ "items": { "type": "string" }
77
+ },
78
+ "unit": {
79
+ "type": "number",
80
+ "minimum": 0,
81
+ "maximum": 1
82
+ },
83
+ "count": {
84
+ "type": "integer",
85
+ "minimum": 0
86
+ },
87
+ "status": {
88
+ "enum": ["unchanged", "added", "removed", "modified"]
89
+ },
90
+ "setChange": {
91
+ "type": "object",
92
+ "properties": {
93
+ "added": { "$ref": "#/$defs/strings" },
94
+ "removed": { "$ref": "#/$defs/strings" }
95
+ },
96
+ "required": ["added", "removed"],
97
+ "additionalProperties": false
98
+ },
99
+ "attrChange": {
100
+ "type": "object",
101
+ "properties": {
102
+ "key": { "type": "string" },
103
+ "before": { "description": "The value before; absent when the attribute was added." },
104
+ "after": { "description": "The value after; absent when the attribute was removed." }
105
+ },
106
+ "required": ["key"],
107
+ "additionalProperties": false
108
+ },
109
+ "attrsFacet": {
110
+ "type": "object",
111
+ "properties": {
112
+ "kind": { "const": "attrs" },
113
+ "changes": {
114
+ "type": "array",
115
+ "items": { "$ref": "#/$defs/attrChange" }
116
+ }
117
+ },
118
+ "required": ["kind", "changes"],
119
+ "additionalProperties": false
120
+ },
121
+ "nodeFacet": {
122
+ "oneOf": [
123
+ {
124
+ "type": "object",
125
+ "properties": {
126
+ "kind": { "const": "rename" },
127
+ "from": { "type": "string" },
128
+ "to": { "type": "string" }
129
+ },
130
+ "required": ["kind", "from", "to"],
131
+ "additionalProperties": false
132
+ },
133
+ {
134
+ "type": "object",
135
+ "properties": {
136
+ "kind": { "const": "rekey" },
137
+ "from": { "type": "string" },
138
+ "to": { "type": "string" },
139
+ "score": { "$ref": "#/$defs/unit" }
140
+ },
141
+ "required": ["kind", "from", "to", "score"],
142
+ "additionalProperties": false
143
+ },
144
+ {
145
+ "type": "object",
146
+ "properties": {
147
+ "kind": { "enum": ["types", "aliases"] },
148
+ "added": { "$ref": "#/$defs/strings" },
149
+ "removed": { "$ref": "#/$defs/strings" }
150
+ },
151
+ "required": ["kind", "added", "removed"],
152
+ "additionalProperties": false
153
+ },
154
+ { "$ref": "#/$defs/attrsFacet" },
155
+ {
156
+ "type": "object",
157
+ "properties": {
158
+ "kind": { "const": "move" },
159
+ "predicate": { "type": "string" },
160
+ "from": {
161
+ "$ref": "#/$defs/unionIds",
162
+ "description": "Parents removed."
163
+ },
164
+ "to": {
165
+ "$ref": "#/$defs/unionIds",
166
+ "description": "Parents added."
167
+ }
168
+ },
169
+ "required": ["kind", "predicate", "from", "to"],
170
+ "additionalProperties": false
171
+ },
172
+ {
173
+ "type": "object",
174
+ "properties": {
175
+ "kind": { "const": "deprecate" },
176
+ "deprecated": {
177
+ "type": "boolean",
178
+ "description": "True when the node became deprecated, false when it was un-deprecated."
179
+ }
180
+ },
181
+ "required": ["kind", "deprecated"],
182
+ "additionalProperties": false
183
+ },
184
+ {
185
+ "type": "object",
186
+ "properties": {
187
+ "kind": { "const": "replacement" },
188
+ "replaces": { "$ref": "#/$defs/setChange" },
189
+ "replacedBy": { "$ref": "#/$defs/setChange" }
190
+ },
191
+ "required": ["kind", "replaces", "replacedBy"],
192
+ "additionalProperties": false
193
+ },
194
+ {
195
+ "type": "object",
196
+ "properties": {
197
+ "kind": { "const": "mergedInto" },
198
+ "target": { "$ref": "#/$defs/unionId" },
199
+ "confidence": { "$ref": "#/$defs/unit" },
200
+ "via": { "enum": ["hint", "heuristic"] }
201
+ },
202
+ "required": ["kind", "target", "confidence", "via"],
203
+ "additionalProperties": false
204
+ },
205
+ {
206
+ "type": "object",
207
+ "properties": {
208
+ "kind": { "const": "mergeTarget" },
209
+ "sources": { "$ref": "#/$defs/unionIds" }
210
+ },
211
+ "required": ["kind", "sources"],
212
+ "additionalProperties": false
213
+ },
214
+ {
215
+ "type": "object",
216
+ "properties": {
217
+ "kind": { "const": "splitFrom" },
218
+ "source": { "$ref": "#/$defs/unionId" },
219
+ "confidence": { "$ref": "#/$defs/unit" },
220
+ "via": { "enum": ["hint", "heuristic"] }
221
+ },
222
+ "required": ["kind", "source", "confidence", "via"],
223
+ "additionalProperties": false
224
+ },
225
+ {
226
+ "type": "object",
227
+ "properties": {
228
+ "kind": { "const": "splitInto" },
229
+ "targets": { "$ref": "#/$defs/unionIds" }
230
+ },
231
+ "required": ["kind", "targets"],
232
+ "additionalProperties": false
233
+ }
234
+ ]
235
+ },
236
+ "edgeFacet": {
237
+ "oneOf": [
238
+ {
239
+ "type": "object",
240
+ "properties": {
241
+ "kind": { "const": "retarget" },
242
+ "end": { "enum": ["source", "target"] },
243
+ "from": { "$ref": "#/$defs/unionId" },
244
+ "to": { "$ref": "#/$defs/unionId" },
245
+ "cause": { "enum": ["edit", "merge", "split", "move"] }
246
+ },
247
+ "required": ["kind", "end", "from", "to", "cause"],
248
+ "additionalProperties": false
249
+ },
250
+ {
251
+ "type": "object",
252
+ "properties": {
253
+ "kind": { "enum": ["predicate", "label"] },
254
+ "from": { "type": "string" },
255
+ "to": { "type": "string" }
256
+ },
257
+ "required": ["kind", "from", "to"],
258
+ "additionalProperties": false
259
+ },
260
+ { "$ref": "#/$defs/attrsFacet" },
261
+ {
262
+ "type": "object",
263
+ "properties": {
264
+ "kind": { "const": "collapsed" },
265
+ "into": {
266
+ "$ref": "#/$defs/unionId",
267
+ "description": "The union edge this one would duplicate after a merge."
268
+ }
269
+ },
270
+ "required": ["kind", "into"],
271
+ "additionalProperties": false
272
+ }
273
+ ]
274
+ },
275
+ "facetKind": {
276
+ "enum": [
277
+ "rename",
278
+ "rekey",
279
+ "types",
280
+ "aliases",
281
+ "attrs",
282
+ "move",
283
+ "deprecate",
284
+ "replacement",
285
+ "mergedInto",
286
+ "mergeTarget",
287
+ "splitFrom",
288
+ "splitInto",
289
+ "retarget",
290
+ "predicate",
291
+ "label",
292
+ "collapsed"
293
+ ]
294
+ },
295
+ "hunkKind": {
296
+ "enum": ["add", "remove", "merge", "split", "modify", "relations"]
297
+ },
298
+ "unionNode": {
299
+ "type": "object",
300
+ "properties": {
301
+ "id": { "$ref": "#/$defs/unionId" },
302
+ "beforeId": { "$ref": "graph.v1.json#/$defs/id" },
303
+ "afterId": { "$ref": "graph.v1.json#/$defs/id" },
304
+ "before": {
305
+ "$ref": "graph.v1.json#/$defs/node",
306
+ "description": "The node before, stored only when it differs from after."
307
+ },
308
+ "after": { "$ref": "graph.v1.json#/$defs/node" },
309
+ "status": { "$ref": "#/$defs/status" },
310
+ "facets": {
311
+ "type": "array",
312
+ "items": { "$ref": "#/$defs/nodeFacet" },
313
+ "description": "What changed, in canonical order."
314
+ },
315
+ "hunk": {
316
+ "type": "string",
317
+ "description": "Id of the hunk this change belongs to."
318
+ }
319
+ },
320
+ "required": ["id", "status"],
321
+ "additionalProperties": false
322
+ },
323
+ "unionEdge": {
324
+ "type": "object",
325
+ "properties": {
326
+ "id": { "$ref": "#/$defs/unionId" },
327
+ "source": { "$ref": "#/$defs/unionId" },
328
+ "target": { "$ref": "#/$defs/unionId" },
329
+ "sourceBefore": {
330
+ "$ref": "#/$defs/unionId",
331
+ "description": "Present only when the source changed."
332
+ },
333
+ "targetBefore": {
334
+ "$ref": "#/$defs/unionId",
335
+ "description": "Present only when the target changed."
336
+ },
337
+ "predicateBefore": {
338
+ "type": "string",
339
+ "description": "Present only when the predicate changed."
340
+ },
341
+ "before": {
342
+ "$ref": "graph.v1.json#/$defs/edge",
343
+ "description": "The edge before, stored only when it differs from after."
344
+ },
345
+ "after": { "$ref": "graph.v1.json#/$defs/edge" },
346
+ "status": { "$ref": "#/$defs/status" },
347
+ "facets": {
348
+ "type": "array",
349
+ "items": { "$ref": "#/$defs/edgeFacet" }
350
+ },
351
+ "hunk": { "type": "string" }
352
+ },
353
+ "required": ["id", "source", "target", "status"],
354
+ "additionalProperties": false
355
+ },
356
+ "countTriplet": {
357
+ "type": "object",
358
+ "properties": {
359
+ "added": { "$ref": "#/$defs/count" },
360
+ "removed": { "$ref": "#/$defs/count" },
361
+ "modified": { "$ref": "#/$defs/count" }
362
+ },
363
+ "required": ["added", "removed", "modified"],
364
+ "additionalProperties": false
365
+ },
366
+ "countDelta": {
367
+ "type": "object",
368
+ "properties": {
369
+ "added": { "$ref": "#/$defs/count" },
370
+ "removed": { "$ref": "#/$defs/count" },
371
+ "modified": { "$ref": "#/$defs/count" },
372
+ "unchanged": { "$ref": "#/$defs/count" }
373
+ },
374
+ "required": ["added", "removed", "modified", "unchanged"],
375
+ "additionalProperties": false
376
+ },
377
+ "hunk": {
378
+ "type": "object",
379
+ "properties": {
380
+ "id": { "type": "string" },
381
+ "kind": { "$ref": "#/$defs/hunkKind" },
382
+ "phase": {
383
+ "enum": ["remove", "restructure", "modify", "add"],
384
+ "description": "Replay phase: clean up, restructure, refine, grow."
385
+ },
386
+ "anchor": {
387
+ "$ref": "#/$defs/unionId",
388
+ "description": "The node the hunk is about."
389
+ },
390
+ "nodes": {
391
+ "$ref": "#/$defs/unionIds",
392
+ "description": "Changed nodes owned by the hunk, anchor first."
393
+ },
394
+ "edges": {
395
+ "$ref": "#/$defs/unionIds",
396
+ "description": "Changed edges owned by the hunk."
397
+ },
398
+ "context": {
399
+ "$ref": "#/$defs/unionIds",
400
+ "description": "Nodes needed to read the hunk that it does not own."
401
+ },
402
+ "ops": {
403
+ "type": "array",
404
+ "items": { "type": "integer", "minimum": 0 },
405
+ "description": "Indices into delta.ops that implement the hunk, ascending."
406
+ },
407
+ "requires": {
408
+ "$ref": "#/$defs/strings",
409
+ "description": "Ids of the hunks that must be applied before this one."
410
+ },
411
+ "summary": {
412
+ "type": "object",
413
+ "properties": {
414
+ "nodes": { "$ref": "#/$defs/countTriplet" },
415
+ "edges": { "$ref": "#/$defs/countTriplet" },
416
+ "facets": {
417
+ "type": "array",
418
+ "items": { "$ref": "#/$defs/facetKind" }
419
+ }
420
+ },
421
+ "required": ["nodes", "edges", "facets"],
422
+ "additionalProperties": false
423
+ },
424
+ "order": {
425
+ "$ref": "#/$defs/count",
426
+ "description": "Default review order, 0-based."
427
+ }
428
+ },
429
+ "required": [
430
+ "id",
431
+ "kind",
432
+ "phase",
433
+ "anchor",
434
+ "nodes",
435
+ "edges",
436
+ "context",
437
+ "ops",
438
+ "requires",
439
+ "summary",
440
+ "order"
441
+ ],
442
+ "additionalProperties": false
443
+ },
444
+ "options": {
445
+ "type": "object",
446
+ "description": "The options the diff was made with, defaults filled in.",
447
+ "properties": {
448
+ "match": {
449
+ "type": "object",
450
+ "properties": {
451
+ "strategy": { "enum": ["id", "auto", "similarity"] },
452
+ "threshold": { "$ref": "#/$defs/unit" },
453
+ "suggestThreshold": { "$ref": "#/$defs/unit" },
454
+ "maxCandidates": { "type": "integer", "minimum": 1 }
455
+ },
456
+ "required": ["strategy", "threshold", "suggestThreshold", "maxCandidates"],
457
+ "additionalProperties": false
458
+ },
459
+ "edgeIdentity": { "enum": ["structure", "id"] },
460
+ "hierarchyPredicates": { "$ref": "#/$defs/strings" },
461
+ "detectMerges": { "type": "boolean" },
462
+ "detectSplits": { "type": "boolean" },
463
+ "ignoreAttrs": { "$ref": "#/$defs/strings" }
464
+ },
465
+ "required": [
466
+ "match",
467
+ "edgeIdentity",
468
+ "hierarchyPredicates",
469
+ "detectMerges",
470
+ "detectSplits",
471
+ "ignoreAttrs"
472
+ ],
473
+ "additionalProperties": false
474
+ },
475
+ "evidence": {
476
+ "type": "object",
477
+ "description": "Similarity per signal.",
478
+ "properties": {
479
+ "label": { "$ref": "#/$defs/unit" },
480
+ "neighbors": { "$ref": "#/$defs/unit" },
481
+ "types": { "$ref": "#/$defs/unit" },
482
+ "attrs": { "$ref": "#/$defs/unit" }
483
+ },
484
+ "required": ["label", "neighbors", "types", "attrs"],
485
+ "additionalProperties": false
486
+ },
487
+ "match": {
488
+ "type": "object",
489
+ "properties": {
490
+ "before": { "$ref": "graph.v1.json#/$defs/id" },
491
+ "after": { "$ref": "graph.v1.json#/$defs/id" },
492
+ "method": { "enum": ["id", "hint", "similarity"] },
493
+ "score": {
494
+ "$ref": "#/$defs/unit",
495
+ "description": "1 for id and hint matches."
496
+ },
497
+ "evidence": { "$ref": "#/$defs/evidence" }
498
+ },
499
+ "required": ["before", "after", "method", "score"],
500
+ "additionalProperties": false
501
+ },
502
+ "suggestion": {
503
+ "type": "object",
504
+ "properties": {
505
+ "before": { "$ref": "graph.v1.json#/$defs/id" },
506
+ "after": { "$ref": "graph.v1.json#/$defs/id" },
507
+ "score": { "$ref": "#/$defs/unit" },
508
+ "evidence": { "$ref": "#/$defs/evidence" },
509
+ "reason": { "enum": ["below-threshold", "ambiguous"] }
510
+ },
511
+ "required": ["before", "after", "score", "evidence", "reason"],
512
+ "additionalProperties": false
513
+ },
514
+ "size": {
515
+ "type": "object",
516
+ "properties": {
517
+ "nodes": { "$ref": "#/$defs/count" },
518
+ "edges": { "$ref": "#/$defs/count" }
519
+ },
520
+ "required": ["nodes", "edges"],
521
+ "additionalProperties": false
522
+ },
523
+ "stats": {
524
+ "type": "object",
525
+ "properties": {
526
+ "nodes": { "$ref": "#/$defs/countDelta" },
527
+ "edges": { "$ref": "#/$defs/countDelta" },
528
+ "before": { "$ref": "#/$defs/size" },
529
+ "after": { "$ref": "#/$defs/size" },
530
+ "facets": {
531
+ "type": "object",
532
+ "propertyNames": { "$ref": "#/$defs/facetKind" },
533
+ "additionalProperties": { "$ref": "#/$defs/count" },
534
+ "description": "Number of union elements carrying each facet kind."
535
+ },
536
+ "hunks": {
537
+ "type": "object",
538
+ "propertyNames": { "$ref": "#/$defs/hunkKind" },
539
+ "additionalProperties": { "$ref": "#/$defs/count" },
540
+ "description": "Number of hunks of each kind."
541
+ },
542
+ "byType": {
543
+ "type": "array",
544
+ "items": {
545
+ "type": "object",
546
+ "properties": {
547
+ "type": {
548
+ "type": "string",
549
+ "description": "A node type; untyped nodes count under the empty string."
550
+ },
551
+ "added": { "$ref": "#/$defs/count" },
552
+ "removed": { "$ref": "#/$defs/count" },
553
+ "modified": { "$ref": "#/$defs/count" },
554
+ "unchanged": { "$ref": "#/$defs/count" }
555
+ },
556
+ "required": ["type", "added", "removed", "modified", "unchanged"],
557
+ "additionalProperties": false
558
+ }
559
+ },
560
+ "identical": { "type": "boolean" }
561
+ },
562
+ "required": ["nodes", "edges", "before", "after", "facets", "hunks", "byType", "identical"],
563
+ "additionalProperties": false
564
+ }
565
+ }
566
+ }