archctx-contracts 0.17.1 → 0.18.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.
Files changed (112) hide show
  1. package/fixtures/valid/archctx-capabilities.json +2 -2
  2. package/fixtures/valid/product-version-manifest.json +4 -10
  3. package/package.json +4 -1
  4. package/schemas/repo/refactor-decision.schema.json +283 -37
  5. package/schemas/runtime/archctx-capabilities.schema.json +144 -20
  6. package/schemas/runtime/architecture-debt-delta.schema.json +58 -19
  7. package/schemas/runtime/architecture-debt.schema.json +42 -42
  8. package/schemas/runtime/architecture-event.schema.json +1 -1
  9. package/schemas/runtime/architecture-history.schema.json +354 -0
  10. package/schemas/runtime/capability-dependencies.schema.json +266 -59
  11. package/schemas/runtime/cli-check.schema.json +197 -0
  12. package/schemas/runtime/cli-help.schema.json +28 -0
  13. package/schemas/runtime/dependency-constraint-evaluation.schema.json +67 -68
  14. package/schemas/runtime/docs-anchors.schema.json +250 -67
  15. package/schemas/runtime/doctor-code-facts.schema.json +49 -0
  16. package/schemas/runtime/evidence-binding.schema.json +1 -1
  17. package/schemas/runtime/flow-selector-check.schema.json +179 -46
  18. package/schemas/runtime/hook-debt-checkpoint.schema.json +12 -12
  19. package/schemas/runtime/index-seed.schema.json +56 -0
  20. package/schemas/runtime/path-context.schema.json +108 -0
  21. package/schemas/runtime/product-version-manifest.schema.json +142 -54
  22. package/schemas/runtime/projection-slice.schema.json +34 -34
  23. package/schemas/runtime/recommendation-v3.schema.json +372 -1
  24. package/schemas/runtime/ref-impact-batch-request.schema.json +20 -7
  25. package/schemas/runtime/ref-impact-batch.schema.json +83 -13
  26. package/schemas/runtime/ref-impact.schema.json +68 -61
  27. package/schemas/runtime/refactor-scan-v2.schema.json +434 -0
  28. package/schemas/runtime/refactor-simulate.schema.json +505 -0
  29. package/schemas/runtime/refactor-verify-v2.schema.json +172 -0
  30. package/schemas/runtime/resolve-path.schema.json +69 -0
  31. package/schemas/runtime/runtime-recommendation-show.schema.json +531 -2
  32. package/schemas/runtime/runtime-refactor-scan.schema.json +498 -2
  33. package/schemas/runtime/runtime-verify.schema.json +274 -56
  34. package/schemas/runtime/state-machine-check.schema.json +357 -89
  35. package/schemas/runtime/structural-observation-payload.schema.json +372 -1
  36. package/schemas/runtime/sync-check.schema.json +65 -0
  37. package/src/architecture-debt.ts +125 -38
  38. package/src/architecture-history.ts +168 -42
  39. package/src/architecture.ts +100 -0
  40. package/src/cli-read.ts +228 -0
  41. package/src/docs-anchors.ts +105 -50
  42. package/src/explorer-occurrence-ports.ts +175 -0
  43. package/src/explorer-query-ports.ts +270 -0
  44. package/src/failure.ts +3 -0
  45. package/src/index-seed.ts +42 -0
  46. package/src/index.ts +5 -0
  47. package/src/ledger-records.ts +262 -0
  48. package/src/ledger.ts +27 -566
  49. package/src/ownership-dependencies.ts +115 -5
  50. package/src/ports.ts +6 -541
  51. package/src/product-version.ts +74 -55
  52. package/src/projection-apply-types.ts +216 -0
  53. package/src/projection-apply-validators.ts +355 -0
  54. package/src/projection-capabilities.ts +181 -0
  55. package/src/projection-constants.ts +317 -0
  56. package/src/projection-manifest-types.ts +298 -0
  57. package/src/projection-manifest.ts +12 -299
  58. package/src/projection-recovery-validators.ts +229 -0
  59. package/src/projection-request-validators.ts +326 -0
  60. package/src/projection-types.ts +365 -0
  61. package/src/projection-validation-helpers.ts +15 -0
  62. package/src/projection.ts +7 -1689
  63. package/src/ref-impact.ts +225 -33
  64. package/src/refactor-constants.ts +213 -0
  65. package/src/refactor-decision-validators.ts +350 -0
  66. package/src/refactor-evidence-types.ts +286 -0
  67. package/src/refactor-observation-validators.ts +359 -0
  68. package/src/refactor-resolution-validators.ts +229 -0
  69. package/src/refactor-snapshot-validators.ts +368 -0
  70. package/src/refactor-types.ts +270 -0
  71. package/src/refactor-v2.ts +389 -0
  72. package/src/refactor-validation-helpers.ts +195 -0
  73. package/src/refactor.ts +7 -1849
  74. package/src/review-guards.ts +3 -23
  75. package/src/runtime-verify.ts +87 -0
  76. package/src/schema-kit.ts +183 -0
  77. package/src/schema-registry.ts +73 -0
  78. package/src/schema.ts +0 -4
  79. package/src/state-machine-schemas.ts +192 -0
  80. package/src/state-machine-types.ts +188 -0
  81. package/src/state-machine.ts +9 -189
  82. package/fixtures/boundary/agent-job-expired.json +0 -33
  83. package/fixtures/invalid/adapter-fidelity-reverse-sync.json +0 -9
  84. package/fixtures/invalid/agent-job-direct-mutation.json +0 -32
  85. package/fixtures/invalid/cloud-egress-envelope-private-field.json +0 -12
  86. package/fixtures/invalid/investigation-report-direct-mutation.json +0 -38
  87. package/fixtures/invalid/investigation-report-missing-proposed-delta.json +0 -19
  88. package/fixtures/invalid/notification-event-code-field.json +0 -11
  89. package/fixtures/valid/adapter-fidelity.json +0 -9
  90. package/fixtures/valid/agent-job.json +0 -33
  91. package/fixtures/valid/architecture-candidate-delta-policy.json +0 -45
  92. package/fixtures/valid/architecture-candidate-delta.json +0 -188
  93. package/fixtures/valid/chatgpt-ga-tool.json +0 -9
  94. package/fixtures/valid/cloud-egress-envelope.json +0 -11
  95. package/fixtures/valid/entitlement.json +0 -12
  96. package/fixtures/valid/investigation-report.json +0 -38
  97. package/fixtures/valid/likec4-mapping.json +0 -14
  98. package/fixtures/valid/notification-event.json +0 -10
  99. package/fixtures/valid/notification-provider.json +0 -12
  100. package/fixtures/valid/structurizr-mapping.json +0 -15
  101. package/schemas/cloud/cloud-egress-envelope.schema.json +0 -19
  102. package/schemas/cloud/entitlement.schema.json +0 -24
  103. package/schemas/integrations/adapter-fidelity.schema.json +0 -21
  104. package/schemas/integrations/chatgpt-ga-tool.schema.json +0 -25
  105. package/schemas/integrations/likec4-mapping.schema.json +0 -32
  106. package/schemas/integrations/structurizr-mapping.schema.json +0 -33
  107. package/schemas/runtime/agent-job.schema.json +0 -63
  108. package/schemas/runtime/architecture-candidate-delta-policy.schema.json +0 -129
  109. package/schemas/runtime/architecture-candidate-delta.schema.json +0 -386
  110. package/schemas/runtime/investigation-report.schema.json +0 -119
  111. package/schemas/runtime/notification-event.schema.json +0 -18
  112. package/schemas/runtime/notification-provider.schema.json +0 -26
@@ -637,6 +637,164 @@
637
637
  "type": "boolean"
638
638
  }
639
639
  }
640
+ },
641
+ {
642
+ "type": "object",
643
+ "additionalProperties": false,
644
+ "required": [
645
+ "kind",
646
+ "files",
647
+ "totalCount",
648
+ "truncated"
649
+ ],
650
+ "properties": {
651
+ "kind": {
652
+ "const": "low-cohesion-god-file"
653
+ },
654
+ "files": {
655
+ "type": "array",
656
+ "maxItems": 20,
657
+ "items": {
658
+ "$ref": "#/$defs/evidenceLowCohesionFile"
659
+ }
660
+ },
661
+ "totalCount": {
662
+ "type": "integer",
663
+ "minimum": 0
664
+ },
665
+ "truncated": {
666
+ "type": "boolean"
667
+ }
668
+ }
669
+ },
670
+ {
671
+ "type": "object",
672
+ "additionalProperties": false,
673
+ "required": [
674
+ "kind",
675
+ "declaredEntrypointPaths",
676
+ "edges",
677
+ "totalCount",
678
+ "truncated"
679
+ ],
680
+ "properties": {
681
+ "kind": {
682
+ "const": "entrypoint-bypass"
683
+ },
684
+ "declaredEntrypointPaths": {
685
+ "type": "array",
686
+ "uniqueItems": true,
687
+ "items": {
688
+ "$ref": "#/$defs/repoRelativePath"
689
+ }
690
+ },
691
+ "edges": {
692
+ "type": "array",
693
+ "maxItems": 20,
694
+ "items": {
695
+ "$ref": "#/$defs/evidenceImportEdge"
696
+ }
697
+ },
698
+ "totalCount": {
699
+ "type": "integer",
700
+ "minimum": 0
701
+ },
702
+ "truncated": {
703
+ "type": "boolean"
704
+ }
705
+ }
706
+ },
707
+ {
708
+ "type": "object",
709
+ "additionalProperties": false,
710
+ "required": [
711
+ "kind",
712
+ "sourceFanIn",
713
+ "sourceInstability",
714
+ "targets",
715
+ "totalCount",
716
+ "truncated"
717
+ ],
718
+ "properties": {
719
+ "kind": {
720
+ "const": "unstable-dependency"
721
+ },
722
+ "sourceFanIn": {
723
+ "type": "integer",
724
+ "minimum": 0
725
+ },
726
+ "sourceInstability": {
727
+ "type": "number",
728
+ "minimum": 0,
729
+ "maximum": 1
730
+ },
731
+ "targets": {
732
+ "type": "array",
733
+ "maxItems": 20,
734
+ "items": {
735
+ "$ref": "#/$defs/evidenceUnstableTarget"
736
+ }
737
+ },
738
+ "totalCount": {
739
+ "type": "integer",
740
+ "minimum": 0
741
+ },
742
+ "truncated": {
743
+ "type": "boolean"
744
+ }
745
+ }
746
+ },
747
+ {
748
+ "type": "object",
749
+ "additionalProperties": false,
750
+ "required": [
751
+ "kind",
752
+ "memberNodeIds",
753
+ "coverageStatus",
754
+ "windowLimit",
755
+ "observedCommitCount",
756
+ "pairs",
757
+ "totalCount",
758
+ "truncated"
759
+ ],
760
+ "properties": {
761
+ "kind": {
762
+ "const": "co-change-coupling"
763
+ },
764
+ "memberNodeIds": {
765
+ "$ref": "#/$defs/evidenceIdList"
766
+ },
767
+ "coverageStatus": {
768
+ "enum": [
769
+ "complete",
770
+ "shallow",
771
+ "insufficient-history",
772
+ "unavailable"
773
+ ]
774
+ },
775
+ "windowLimit": {
776
+ "type": "integer",
777
+ "minimum": 1
778
+ },
779
+ "observedCommitCount": {
780
+ "type": "integer",
781
+ "minimum": 0
782
+ },
783
+ "pairs": {
784
+ "type": "array",
785
+ "maxItems": 20,
786
+ "items": {
787
+ "$ref": "#/$defs/evidenceCoChangePair"
788
+ }
789
+ },
790
+ "totalCount": {
791
+ "type": "integer",
792
+ "minimum": 0
793
+ },
794
+ "truncated": {
795
+ "type": "boolean"
796
+ }
797
+ }
640
798
  }
641
799
  ]
642
800
  },
@@ -967,13 +1125,17 @@
967
1125
  },
968
1126
  "kind": {
969
1127
  "enum": [
1128
+ "co-change-coupling",
970
1129
  "cycle",
971
1130
  "direction-violation",
1131
+ "entrypoint-bypass",
972
1132
  "evidence-gap",
1133
+ "low-cohesion-god-file",
973
1134
  "ownership-ambiguous",
974
1135
  "residual-cycle",
975
1136
  "undeclared-footprint",
976
- "unowned-paths"
1137
+ "unowned-paths",
1138
+ "unstable-dependency"
977
1139
  ]
978
1140
  },
979
1141
  "affectedNodeIds": {
@@ -1006,6 +1168,26 @@
1006
1168
  }
1007
1169
  },
1008
1170
  "allOf": [
1171
+ {
1172
+ "if": {
1173
+ "properties": {
1174
+ "kind": {
1175
+ "const": "co-change-coupling"
1176
+ }
1177
+ }
1178
+ },
1179
+ "then": {
1180
+ "properties": {
1181
+ "evidence": {
1182
+ "properties": {
1183
+ "kind": {
1184
+ "const": "co-change-coupling"
1185
+ }
1186
+ }
1187
+ }
1188
+ }
1189
+ }
1190
+ },
1009
1191
  {
1010
1192
  "if": {
1011
1193
  "properties": {
@@ -1046,6 +1228,26 @@
1046
1228
  }
1047
1229
  }
1048
1230
  },
1231
+ {
1232
+ "if": {
1233
+ "properties": {
1234
+ "kind": {
1235
+ "const": "entrypoint-bypass"
1236
+ }
1237
+ }
1238
+ },
1239
+ "then": {
1240
+ "properties": {
1241
+ "evidence": {
1242
+ "properties": {
1243
+ "kind": {
1244
+ "const": "entrypoint-bypass"
1245
+ }
1246
+ }
1247
+ }
1248
+ }
1249
+ }
1250
+ },
1049
1251
  {
1050
1252
  "if": {
1051
1253
  "properties": {
@@ -1066,6 +1268,26 @@
1066
1268
  }
1067
1269
  }
1068
1270
  },
1271
+ {
1272
+ "if": {
1273
+ "properties": {
1274
+ "kind": {
1275
+ "const": "low-cohesion-god-file"
1276
+ }
1277
+ }
1278
+ },
1279
+ "then": {
1280
+ "properties": {
1281
+ "evidence": {
1282
+ "properties": {
1283
+ "kind": {
1284
+ "const": "low-cohesion-god-file"
1285
+ }
1286
+ }
1287
+ }
1288
+ }
1289
+ }
1290
+ },
1069
1291
  {
1070
1292
  "if": {
1071
1293
  "properties": {
@@ -1126,6 +1348,26 @@
1126
1348
  }
1127
1349
  }
1128
1350
  },
1351
+ {
1352
+ "if": {
1353
+ "properties": {
1354
+ "kind": {
1355
+ "const": "unstable-dependency"
1356
+ }
1357
+ }
1358
+ },
1359
+ "then": {
1360
+ "properties": {
1361
+ "evidence": {
1362
+ "properties": {
1363
+ "kind": {
1364
+ "const": "unstable-dependency"
1365
+ }
1366
+ }
1367
+ }
1368
+ }
1369
+ }
1370
+ },
1129
1371
  {
1130
1372
  "if": {
1131
1373
  "properties": {
@@ -1665,6 +1907,10 @@
1665
1907
  "items": {
1666
1908
  "type": "string"
1667
1909
  }
1910
+ },
1911
+ "entrypointBypassCount": {
1912
+ "type": "integer",
1913
+ "minimum": 0
1668
1914
  }
1669
1915
  }
1670
1916
  },
@@ -1732,6 +1978,10 @@
1732
1978
  "null"
1733
1979
  ],
1734
1980
  "minimum": 0
1981
+ },
1982
+ "unstableDependencyCount": {
1983
+ "type": "integer",
1984
+ "minimum": 0
1735
1985
  }
1736
1986
  }
1737
1987
  }
@@ -1810,6 +2060,24 @@
1810
2060
  "extensions": {
1811
2061
  "type": "object",
1812
2062
  "additionalProperties": true
2063
+ },
2064
+ "cohesion": {
2065
+ "type": "object",
2066
+ "additionalProperties": false,
2067
+ "required": [
2068
+ "lowCohesionFileCount",
2069
+ "measuredFileCount"
2070
+ ],
2071
+ "properties": {
2072
+ "lowCohesionFileCount": {
2073
+ "type": "integer",
2074
+ "minimum": 0
2075
+ },
2076
+ "measuredFileCount": {
2077
+ "type": "integer",
2078
+ "minimum": 0
2079
+ }
2080
+ }
1813
2081
  }
1814
2082
  },
1815
2083
  "if": {
@@ -1855,7 +2123,13 @@
1855
2123
  },
1856
2124
  "scope": {
1857
2125
  "$ref": "#/$defs/refactorScope",
1858
- "not": { "properties": { "kind": { "const": "repository" } } },
2126
+ "not": {
2127
+ "properties": {
2128
+ "kind": {
2129
+ "const": "repository"
2130
+ }
2131
+ }
2132
+ },
1859
2133
  "description": "Present for statistics measured over the requested files and their direct import neighbors."
1860
2134
  },
1861
2135
  "repository": {
@@ -2045,6 +2319,99 @@
2045
2319
  "extensions": {
2046
2320
  "type": "object",
2047
2321
  "additionalProperties": true
2322
+ },
2323
+ "coChangeDependencies": {
2324
+ "type": "array",
2325
+ "items": {
2326
+ "type": "object",
2327
+ "additionalProperties": false,
2328
+ "required": [
2329
+ "fromNodeId",
2330
+ "toNodeId",
2331
+ "pairCount",
2332
+ "maxCoChangeCount",
2333
+ "maxJaccard"
2334
+ ],
2335
+ "properties": {
2336
+ "fromNodeId": {
2337
+ "type": "string",
2338
+ "minLength": 1
2339
+ },
2340
+ "toNodeId": {
2341
+ "type": "string",
2342
+ "minLength": 1
2343
+ },
2344
+ "pairCount": {
2345
+ "type": "integer",
2346
+ "minimum": 1
2347
+ },
2348
+ "maxCoChangeCount": {
2349
+ "type": "integer",
2350
+ "minimum": 1
2351
+ },
2352
+ "maxJaccard": {
2353
+ "type": "number",
2354
+ "minimum": 0,
2355
+ "maximum": 1
2356
+ }
2357
+ }
2358
+ }
2359
+ },
2360
+ "gitHistory": {
2361
+ "type": "object",
2362
+ "additionalProperties": false,
2363
+ "required": [
2364
+ "anchorHeadSha",
2365
+ "windowLimit",
2366
+ "observedCommitCount",
2367
+ "eligibleCommitCount",
2368
+ "maxFilesPerCommit",
2369
+ "isShallow",
2370
+ "reachedHistoryRoot",
2371
+ "coverageStatus",
2372
+ "reasonCodes"
2373
+ ],
2374
+ "properties": {
2375
+ "anchorHeadSha": {
2376
+ "type": "string"
2377
+ },
2378
+ "windowLimit": {
2379
+ "type": "integer",
2380
+ "minimum": 1
2381
+ },
2382
+ "observedCommitCount": {
2383
+ "type": "integer",
2384
+ "minimum": 0
2385
+ },
2386
+ "eligibleCommitCount": {
2387
+ "type": "integer",
2388
+ "minimum": 0
2389
+ },
2390
+ "maxFilesPerCommit": {
2391
+ "type": "integer",
2392
+ "minimum": 1
2393
+ },
2394
+ "isShallow": {
2395
+ "type": "boolean"
2396
+ },
2397
+ "reachedHistoryRoot": {
2398
+ "type": "boolean"
2399
+ },
2400
+ "coverageStatus": {
2401
+ "enum": [
2402
+ "complete",
2403
+ "shallow",
2404
+ "insufficient-history",
2405
+ "unavailable"
2406
+ ]
2407
+ },
2408
+ "reasonCodes": {
2409
+ "type": "array",
2410
+ "items": {
2411
+ "type": "string"
2412
+ }
2413
+ }
2414
+ }
2048
2415
  }
2049
2416
  }
2050
2417
  },
@@ -2692,6 +3059,135 @@
2692
3059
  "const": false
2693
3060
  }
2694
3061
  }
3062
+ },
3063
+ "evidenceLowCohesionCluster": {
3064
+ "type": "object",
3065
+ "additionalProperties": false,
3066
+ "required": [
3067
+ "symbols",
3068
+ "startLine",
3069
+ "endLine",
3070
+ "intraClusterEdges",
3071
+ "crossClusterEdges"
3072
+ ],
3073
+ "properties": {
3074
+ "symbols": {
3075
+ "type": "array",
3076
+ "uniqueItems": true,
3077
+ "items": {
3078
+ "type": "string",
3079
+ "minLength": 1
3080
+ }
3081
+ },
3082
+ "startLine": {
3083
+ "type": "integer",
3084
+ "minimum": 1
3085
+ },
3086
+ "endLine": {
3087
+ "type": "integer",
3088
+ "minimum": 1
3089
+ },
3090
+ "intraClusterEdges": {
3091
+ "type": "integer",
3092
+ "minimum": 0
3093
+ },
3094
+ "crossClusterEdges": {
3095
+ "type": "integer",
3096
+ "minimum": 0
3097
+ }
3098
+ }
3099
+ },
3100
+ "evidenceLowCohesionFile": {
3101
+ "type": "object",
3102
+ "additionalProperties": false,
3103
+ "required": [
3104
+ "path",
3105
+ "lineCount",
3106
+ "topLevelSymbolCount",
3107
+ "clusterCount",
3108
+ "clusters"
3109
+ ],
3110
+ "properties": {
3111
+ "path": {
3112
+ "$ref": "#/$defs/repoRelativePath"
3113
+ },
3114
+ "lineCount": {
3115
+ "type": "integer",
3116
+ "minimum": 0
3117
+ },
3118
+ "topLevelSymbolCount": {
3119
+ "type": "integer",
3120
+ "minimum": 0
3121
+ },
3122
+ "clusterCount": {
3123
+ "type": "integer",
3124
+ "minimum": 0
3125
+ },
3126
+ "clusters": {
3127
+ "type": "array",
3128
+ "items": {
3129
+ "$ref": "#/$defs/evidenceLowCohesionCluster"
3130
+ }
3131
+ }
3132
+ }
3133
+ },
3134
+ "evidenceUnstableTarget": {
3135
+ "type": "object",
3136
+ "additionalProperties": false,
3137
+ "required": [
3138
+ "targetNodeId",
3139
+ "targetInstability",
3140
+ "delta",
3141
+ "edgeCount"
3142
+ ],
3143
+ "properties": {
3144
+ "targetNodeId": {
3145
+ "type": "string",
3146
+ "minLength": 1,
3147
+ "pattern": "\\S"
3148
+ },
3149
+ "targetInstability": {
3150
+ "type": "number",
3151
+ "minimum": 0,
3152
+ "maximum": 1
3153
+ },
3154
+ "delta": {
3155
+ "type": "number",
3156
+ "minimum": -1,
3157
+ "maximum": 1
3158
+ },
3159
+ "edgeCount": {
3160
+ "type": "integer",
3161
+ "minimum": 1
3162
+ }
3163
+ }
3164
+ },
3165
+ "evidenceCoChangePair": {
3166
+ "type": "object",
3167
+ "additionalProperties": false,
3168
+ "required": [
3169
+ "pathA",
3170
+ "pathB",
3171
+ "coChangeCount",
3172
+ "jaccard"
3173
+ ],
3174
+ "properties": {
3175
+ "pathA": {
3176
+ "$ref": "#/$defs/repoRelativePath"
3177
+ },
3178
+ "pathB": {
3179
+ "$ref": "#/$defs/repoRelativePath"
3180
+ },
3181
+ "coChangeCount": {
3182
+ "type": "integer",
3183
+ "minimum": 1
3184
+ },
3185
+ "jaccard": {
3186
+ "type": "number",
3187
+ "minimum": 0,
3188
+ "maximum": 1
3189
+ }
3190
+ }
2695
3191
  }
2696
3192
  }
2697
3193
  }