archctx 0.6.3 → 0.7.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,2489 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://archcontext.dev/schemas/runtime/runtime-refactor-scan.schema.json",
4
+ "title": "RuntimeRefactorScanV1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schemaVersion",
9
+ "repository",
10
+ "worktree",
11
+ "requestId",
12
+ "request",
13
+ "trackedFileCount",
14
+ "snapshot",
15
+ "assessment",
16
+ "proposedRecommendations",
17
+ "evidenceItems",
18
+ "evidenceBindings",
19
+ "suppressed",
20
+ "recording",
21
+ "limits",
22
+ "privacy"
23
+ ],
24
+ "properties": {
25
+ "schemaVersion": {
26
+ "const": "archcontext.runtime-refactor-scan/v1"
27
+ },
28
+ "repository": {
29
+ "$ref": "#/$defs/repositoryIdentity"
30
+ },
31
+ "worktree": {
32
+ "$ref": "#/$defs/worktreeIdentity"
33
+ },
34
+ "requestId": {
35
+ "type": "string",
36
+ "pattern": "^refactor_request\\.[a-f0-9]{16}$"
37
+ },
38
+ "request": {
39
+ "$ref": "#/$defs/refactorRequest"
40
+ },
41
+ "trackedFileCount": {
42
+ "type": "integer",
43
+ "minimum": 0
44
+ },
45
+ "snapshot": {
46
+ "$ref": "#/$defs/moduleStatisticsSnapshot"
47
+ },
48
+ "assessment": {
49
+ "$ref": "#/$defs/refactorAssessment"
50
+ },
51
+ "proposal": {
52
+ "$ref": "#/$defs/refactorProposal"
53
+ },
54
+ "proposedRecommendations": {
55
+ "type": "array",
56
+ "items": {
57
+ "$ref": "#/$defs/recommendationV3"
58
+ }
59
+ },
60
+ "evidenceItems": {
61
+ "type": "array",
62
+ "items": {
63
+ "$ref": "evidence-item.schema.json"
64
+ }
65
+ },
66
+ "evidenceBindings": {
67
+ "type": "array",
68
+ "items": {
69
+ "$ref": "evidence-binding.schema.json"
70
+ }
71
+ },
72
+ "suppressed": {
73
+ "type": "array",
74
+ "items": {
75
+ "type": "object",
76
+ "additionalProperties": false,
77
+ "required": [
78
+ "reasonCode",
79
+ "fingerprint",
80
+ "subject"
81
+ ],
82
+ "properties": {
83
+ "reasonCode": {
84
+ "enum": [
85
+ "cooldown-active",
86
+ "decided-fingerprint",
87
+ "duplicate-active-fingerprint"
88
+ ]
89
+ },
90
+ "fingerprint": {
91
+ "$ref": "#/$defs/sha256"
92
+ },
93
+ "subject": {
94
+ "type": "string"
95
+ },
96
+ "practiceId": {
97
+ "type": "string"
98
+ },
99
+ "previousRecommendationId": {
100
+ "type": "string"
101
+ },
102
+ "cooldownUntil": {
103
+ "type": "string"
104
+ }
105
+ }
106
+ }
107
+ },
108
+ "recording": {
109
+ "type": "object",
110
+ "additionalProperties": false,
111
+ "required": [
112
+ "recordable",
113
+ "reasonCode",
114
+ "measuredBytes",
115
+ "limitBytes"
116
+ ],
117
+ "properties": {
118
+ "recordable": {
119
+ "type": "boolean"
120
+ },
121
+ "reasonCode": {
122
+ "enum": [
123
+ null,
124
+ "refactor-run-exceeds-ledger-size-limit"
125
+ ]
126
+ },
127
+ "measuredBytes": {
128
+ "type": "integer",
129
+ "minimum": 0
130
+ },
131
+ "limitBytes": {
132
+ "type": "integer",
133
+ "minimum": 0
134
+ }
135
+ },
136
+ "if": {
137
+ "properties": {
138
+ "recordable": {
139
+ "const": true
140
+ }
141
+ }
142
+ },
143
+ "then": {
144
+ "properties": {
145
+ "reasonCode": {
146
+ "const": null
147
+ }
148
+ }
149
+ },
150
+ "else": {
151
+ "properties": {
152
+ "reasonCode": {
153
+ "const": "refactor-run-exceeds-ledger-size-limit"
154
+ }
155
+ }
156
+ }
157
+ },
158
+ "limits": {
159
+ "type": "object",
160
+ "additionalProperties": false,
161
+ "required": [
162
+ "evidenceSampleLimit",
163
+ "maxEvidenceSampleLimit",
164
+ "maxRecommendationsPerRun",
165
+ "candidateCount",
166
+ "omittedCandidateCount"
167
+ ],
168
+ "properties": {
169
+ "evidenceSampleLimit": {
170
+ "type": "integer",
171
+ "minimum": 0,
172
+ "maximum": 20
173
+ },
174
+ "maxEvidenceSampleLimit": {
175
+ "const": 20
176
+ },
177
+ "maxRecommendationsPerRun": {
178
+ "type": "integer",
179
+ "minimum": 0
180
+ },
181
+ "candidateCount": {
182
+ "type": "integer",
183
+ "minimum": 0
184
+ },
185
+ "omittedCandidateCount": {
186
+ "type": "integer",
187
+ "minimum": 0
188
+ }
189
+ }
190
+ },
191
+ "recordCommand": {
192
+ "type": "string",
193
+ "pattern": "^archctx refactor record --assessment-digest sha256:[a-f0-9]{64} --expected-worktree-digest sha256:[a-f0-9]{64}$"
194
+ },
195
+ "privacy": {
196
+ "$ref": "#/$defs/privacy"
197
+ }
198
+ },
199
+ "if": {
200
+ "properties": {
201
+ "recording": {
202
+ "properties": {
203
+ "recordable": {
204
+ "const": true
205
+ }
206
+ }
207
+ }
208
+ }
209
+ },
210
+ "then": {
211
+ "required": [
212
+ "recordCommand"
213
+ ]
214
+ },
215
+ "else": {
216
+ "not": {
217
+ "required": [
218
+ "recordCommand"
219
+ ]
220
+ }
221
+ },
222
+ "$defs": {
223
+ "sha256": {
224
+ "type": "string",
225
+ "pattern": "^sha256:[a-f0-9]{64}$"
226
+ },
227
+ "repoRelativePath": {
228
+ "type": "string",
229
+ "minLength": 1,
230
+ "pattern": "^(?!/)(?!.*\\\\)(?!(?:.*/)?\\.\\.(?:/|$)).+$"
231
+ },
232
+ "evidenceLine": {
233
+ "type": [
234
+ "integer",
235
+ "null"
236
+ ],
237
+ "minimum": 1
238
+ },
239
+ "evidenceSpecifier": {
240
+ "type": "string",
241
+ "minLength": 1,
242
+ "maxLength": 512,
243
+ "pattern": "^[^\\u0000-\\u001f\\u007f]+$"
244
+ },
245
+ "evidenceIdList": {
246
+ "type": "array",
247
+ "maxItems": 32,
248
+ "uniqueItems": true,
249
+ "items": {
250
+ "type": "string"
251
+ }
252
+ },
253
+ "observationMetrics": {
254
+ "type": "object",
255
+ "additionalProperties": {
256
+ "type": [
257
+ "number",
258
+ "null"
259
+ ]
260
+ }
261
+ },
262
+ "evidenceImportEdge": {
263
+ "type": "object",
264
+ "additionalProperties": false,
265
+ "required": [
266
+ "fromPath",
267
+ "fromLine",
268
+ "toPath",
269
+ "specifier",
270
+ "fromNodeId",
271
+ "toNodeId"
272
+ ],
273
+ "properties": {
274
+ "fromPath": {
275
+ "$ref": "#/$defs/repoRelativePath"
276
+ },
277
+ "fromLine": {
278
+ "$ref": "#/$defs/evidenceLine"
279
+ },
280
+ "toPath": {
281
+ "$ref": "#/$defs/repoRelativePath"
282
+ },
283
+ "specifier": {
284
+ "$ref": "#/$defs/evidenceSpecifier"
285
+ },
286
+ "fromNodeId": {
287
+ "type": "string",
288
+ "minLength": 1,
289
+ "pattern": "\\S"
290
+ },
291
+ "toNodeId": {
292
+ "type": "string",
293
+ "minLength": 1,
294
+ "pattern": "\\S"
295
+ }
296
+ }
297
+ },
298
+ "evidenceDirectionViolation": {
299
+ "type": "object",
300
+ "additionalProperties": false,
301
+ "required": [
302
+ "fromPath",
303
+ "fromLine",
304
+ "toPath",
305
+ "specifier",
306
+ "fromNodeId",
307
+ "toNodeId",
308
+ "constraintId"
309
+ ],
310
+ "properties": {
311
+ "fromPath": {
312
+ "$ref": "#/$defs/repoRelativePath"
313
+ },
314
+ "fromLine": {
315
+ "$ref": "#/$defs/evidenceLine"
316
+ },
317
+ "toPath": {
318
+ "$ref": "#/$defs/repoRelativePath"
319
+ },
320
+ "specifier": {
321
+ "$ref": "#/$defs/evidenceSpecifier"
322
+ },
323
+ "fromNodeId": {
324
+ "type": "string",
325
+ "minLength": 1,
326
+ "pattern": "\\S"
327
+ },
328
+ "toNodeId": {
329
+ "type": "string",
330
+ "minLength": 1,
331
+ "pattern": "\\S"
332
+ },
333
+ "constraintId": {
334
+ "type": "string"
335
+ }
336
+ }
337
+ },
338
+ "evidencePath": {
339
+ "type": "object",
340
+ "additionalProperties": false,
341
+ "required": [
342
+ "path",
343
+ "candidateOwnerNodeIds",
344
+ "candidateOwnerCount"
345
+ ],
346
+ "properties": {
347
+ "path": {
348
+ "$ref": "#/$defs/repoRelativePath"
349
+ },
350
+ "candidateOwnerNodeIds": {
351
+ "$ref": "#/$defs/evidenceIdList"
352
+ },
353
+ "candidateOwnerCount": {
354
+ "type": "integer",
355
+ "minimum": 0
356
+ }
357
+ }
358
+ },
359
+ "evidenceUnresolvedImport": {
360
+ "type": "object",
361
+ "additionalProperties": false,
362
+ "required": [
363
+ "fromPath",
364
+ "fromLine",
365
+ "specifier"
366
+ ],
367
+ "properties": {
368
+ "fromPath": {
369
+ "$ref": "#/$defs/repoRelativePath"
370
+ },
371
+ "fromLine": {
372
+ "$ref": "#/$defs/evidenceLine"
373
+ },
374
+ "specifier": {
375
+ "$ref": "#/$defs/evidenceSpecifier"
376
+ }
377
+ }
378
+ },
379
+ "observationEvidence": {
380
+ "oneOf": [
381
+ {
382
+ "type": "object",
383
+ "additionalProperties": false,
384
+ "required": [
385
+ "kind",
386
+ "memberNodeIds",
387
+ "edges",
388
+ "totalCount",
389
+ "truncated"
390
+ ],
391
+ "properties": {
392
+ "kind": {
393
+ "const": "cycle"
394
+ },
395
+ "memberNodeIds": {
396
+ "$ref": "#/$defs/evidenceIdList"
397
+ },
398
+ "edges": {
399
+ "type": "array",
400
+ "maxItems": 20,
401
+ "items": {
402
+ "$ref": "#/$defs/evidenceImportEdge"
403
+ }
404
+ },
405
+ "totalCount": {
406
+ "type": "integer",
407
+ "minimum": 0
408
+ },
409
+ "truncated": {
410
+ "type": "boolean"
411
+ }
412
+ }
413
+ },
414
+ {
415
+ "type": "object",
416
+ "additionalProperties": false,
417
+ "required": [
418
+ "kind",
419
+ "constraintIds",
420
+ "constraintCount",
421
+ "violations",
422
+ "totalCount",
423
+ "truncated"
424
+ ],
425
+ "properties": {
426
+ "kind": {
427
+ "const": "direction-violation"
428
+ },
429
+ "constraintIds": {
430
+ "$ref": "#/$defs/evidenceIdList"
431
+ },
432
+ "constraintCount": {
433
+ "type": "integer",
434
+ "minimum": 0
435
+ },
436
+ "violations": {
437
+ "type": "array",
438
+ "maxItems": 20,
439
+ "items": {
440
+ "$ref": "#/$defs/evidenceDirectionViolation"
441
+ }
442
+ },
443
+ "totalCount": {
444
+ "type": "integer",
445
+ "minimum": 0
446
+ },
447
+ "truncated": {
448
+ "type": "boolean"
449
+ }
450
+ }
451
+ },
452
+ {
453
+ "type": "object",
454
+ "additionalProperties": false,
455
+ "required": [
456
+ "kind",
457
+ "paths",
458
+ "totalCount",
459
+ "truncated"
460
+ ],
461
+ "properties": {
462
+ "kind": {
463
+ "enum": [
464
+ "ownership-ambiguous",
465
+ "undeclared-footprint",
466
+ "unowned-paths"
467
+ ]
468
+ },
469
+ "paths": {
470
+ "type": "array",
471
+ "maxItems": 20,
472
+ "items": {
473
+ "$ref": "#/$defs/evidencePath"
474
+ }
475
+ },
476
+ "totalCount": {
477
+ "type": "integer",
478
+ "minimum": 0
479
+ },
480
+ "truncated": {
481
+ "type": "boolean"
482
+ }
483
+ }
484
+ },
485
+ {
486
+ "type": "object",
487
+ "additionalProperties": false,
488
+ "required": [
489
+ "kind",
490
+ "coverage",
491
+ "reasonCodes",
492
+ "unresolvedImports",
493
+ "totalCount",
494
+ "truncated"
495
+ ],
496
+ "properties": {
497
+ "kind": {
498
+ "const": "evidence-gap"
499
+ },
500
+ "coverage": {
501
+ "enum": [
502
+ "complete",
503
+ "partial",
504
+ "unknown"
505
+ ]
506
+ },
507
+ "reasonCodes": {
508
+ "type": "array",
509
+ "uniqueItems": true,
510
+ "items": {
511
+ "enum": [
512
+ "caller-coverage-unknown",
513
+ "code-facts-missing",
514
+ "code-facts-truncated",
515
+ "major-change-detected",
516
+ "multi-node-scope",
517
+ "node-footprint-undeclared",
518
+ "ownership-ambiguous",
519
+ "single-node-scope",
520
+ "target-unresolved",
521
+ "unowned-paths"
522
+ ]
523
+ }
524
+ },
525
+ "unresolvedImports": {
526
+ "type": "array",
527
+ "maxItems": 20,
528
+ "items": {
529
+ "$ref": "#/$defs/evidenceUnresolvedImport"
530
+ }
531
+ },
532
+ "totalCount": {
533
+ "type": "integer",
534
+ "minimum": 0
535
+ },
536
+ "truncated": {
537
+ "type": "boolean"
538
+ }
539
+ }
540
+ }
541
+ ]
542
+ },
543
+ "targetOutcome": {
544
+ "type": "object",
545
+ "additionalProperties": false,
546
+ "required": [
547
+ "outcomeId",
548
+ "metric",
549
+ "subjectSelectorId",
550
+ "nodeId",
551
+ "operator",
552
+ "value",
553
+ "required"
554
+ ],
555
+ "properties": {
556
+ "outcomeId": {
557
+ "type": "string"
558
+ },
559
+ "metric": {
560
+ "type": "string",
561
+ "minLength": 1,
562
+ "pattern": "\\S"
563
+ },
564
+ "subjectSelectorId": {
565
+ "type": "string"
566
+ },
567
+ "nodeId": {
568
+ "type": [
569
+ "string",
570
+ "null"
571
+ ]
572
+ },
573
+ "operator": {
574
+ "enum": [
575
+ "absent",
576
+ "equals",
577
+ "greater_than",
578
+ "less_than",
579
+ "present"
580
+ ]
581
+ },
582
+ "value": {
583
+ "type": [
584
+ "number",
585
+ "null"
586
+ ]
587
+ },
588
+ "required": {
589
+ "type": "boolean"
590
+ }
591
+ },
592
+ "if": {
593
+ "properties": {
594
+ "operator": {
595
+ "enum": [
596
+ "absent",
597
+ "present"
598
+ ]
599
+ }
600
+ }
601
+ },
602
+ "then": {
603
+ "properties": {
604
+ "value": {
605
+ "type": "null"
606
+ }
607
+ }
608
+ },
609
+ "else": {
610
+ "properties": {
611
+ "value": {
612
+ "type": "number"
613
+ }
614
+ }
615
+ }
616
+ },
617
+ "killListEntry": {
618
+ "type": "object",
619
+ "additionalProperties": false,
620
+ "required": [
621
+ "kind",
622
+ "selectorId",
623
+ "required"
624
+ ],
625
+ "properties": {
626
+ "kind": {
627
+ "enum": [
628
+ "path",
629
+ "relation",
630
+ "symbol"
631
+ ]
632
+ },
633
+ "selectorId": {
634
+ "type": "string"
635
+ },
636
+ "required": {
637
+ "type": "boolean"
638
+ }
639
+ }
640
+ },
641
+ "architectureTargetDelta": {
642
+ "type": "object",
643
+ "additionalProperties": false,
644
+ "required": [
645
+ "interventionId",
646
+ "trigger",
647
+ "thesis",
648
+ "targetState",
649
+ "migrationState",
650
+ "completionCriteria",
651
+ "falsifiers",
652
+ "benefitLedger",
653
+ "unresolvedTargets"
654
+ ],
655
+ "properties": {
656
+ "interventionId": {
657
+ "type": "string"
658
+ },
659
+ "trigger": {
660
+ "type": "array",
661
+ "items": {
662
+ "type": "string"
663
+ },
664
+ "minItems": 1
665
+ },
666
+ "thesis": {
667
+ "type": "string",
668
+ "minLength": 1,
669
+ "pattern": "\\S"
670
+ },
671
+ "targetState": {
672
+ "type": "object",
673
+ "additionalProperties": false,
674
+ "required": [
675
+ "owners",
676
+ "requiredRelations",
677
+ "removedConcepts"
678
+ ],
679
+ "properties": {
680
+ "owners": {
681
+ "type": "object",
682
+ "additionalProperties": {
683
+ "type": "string"
684
+ }
685
+ },
686
+ "requiredRelations": {
687
+ "type": "array",
688
+ "items": {
689
+ "type": "string"
690
+ }
691
+ },
692
+ "removedConcepts": {
693
+ "type": "array",
694
+ "items": {
695
+ "type": "string"
696
+ }
697
+ }
698
+ }
699
+ },
700
+ "migrationState": {
701
+ "type": "object",
702
+ "additionalProperties": false,
703
+ "required": [
704
+ "active",
705
+ "compatibilityContracts",
706
+ "temporaryRelations"
707
+ ],
708
+ "properties": {
709
+ "active": {
710
+ "type": "boolean"
711
+ },
712
+ "compatibilityContracts": {
713
+ "type": "array",
714
+ "items": {
715
+ "type": "string"
716
+ }
717
+ },
718
+ "cleanupBy": {
719
+ "type": "string"
720
+ },
721
+ "temporaryRelations": {
722
+ "type": "array",
723
+ "items": {
724
+ "type": "string"
725
+ }
726
+ }
727
+ }
728
+ },
729
+ "completionCriteria": {
730
+ "type": "array",
731
+ "minItems": 1,
732
+ "items": {
733
+ "$ref": "#/$defs/targetOutcome"
734
+ }
735
+ },
736
+ "falsifiers": {
737
+ "type": "array",
738
+ "items": {
739
+ "type": "string"
740
+ },
741
+ "minItems": 1
742
+ },
743
+ "benefitLedger": {
744
+ "type": "object",
745
+ "additionalProperties": false,
746
+ "required": [
747
+ "benefits",
748
+ "costs",
749
+ "rollbackPoint"
750
+ ],
751
+ "properties": {
752
+ "benefits": {
753
+ "type": "array",
754
+ "items": {
755
+ "type": "string"
756
+ }
757
+ },
758
+ "costs": {
759
+ "type": "array",
760
+ "items": {
761
+ "type": "string"
762
+ }
763
+ },
764
+ "rollbackPoint": {
765
+ "type": "string",
766
+ "minLength": 1,
767
+ "pattern": "\\S"
768
+ }
769
+ }
770
+ },
771
+ "unresolvedTargets": {
772
+ "type": "array",
773
+ "uniqueItems": true,
774
+ "items": {
775
+ "type": "string"
776
+ }
777
+ },
778
+ "extensions": {
779
+ "type": "object",
780
+ "additionalProperties": true
781
+ }
782
+ }
783
+ },
784
+ "recommendationAuthor": {
785
+ "type": "object",
786
+ "additionalProperties": false,
787
+ "required": [
788
+ "kind",
789
+ "id",
790
+ "source"
791
+ ],
792
+ "properties": {
793
+ "kind": {
794
+ "enum": [
795
+ "developer",
796
+ "daemon",
797
+ "hook",
798
+ "cli",
799
+ "mcp",
800
+ "subagent",
801
+ "migration",
802
+ "system"
803
+ ]
804
+ },
805
+ "id": {
806
+ "type": "string",
807
+ "minLength": 1,
808
+ "pattern": "\\S"
809
+ },
810
+ "source": {
811
+ "enum": [
812
+ "cli",
813
+ "mcp",
814
+ "manual",
815
+ "daemon",
816
+ "system",
817
+ "subagent"
818
+ ]
819
+ }
820
+ }
821
+ },
822
+ "practiceRecommendationPayload": {
823
+ "type": "object",
824
+ "additionalProperties": false,
825
+ "required": [
826
+ "practiceId",
827
+ "baselineDigest"
828
+ ],
829
+ "properties": {
830
+ "practiceId": {
831
+ "type": "string"
832
+ },
833
+ "baselineDigest": {
834
+ "type": [
835
+ "string",
836
+ "null"
837
+ ]
838
+ }
839
+ }
840
+ },
841
+ "structuralObservationPayload": {
842
+ "type": "object",
843
+ "additionalProperties": false,
844
+ "required": [
845
+ "assessmentDigest",
846
+ "kind",
847
+ "affectedNodeIds",
848
+ "baselineSnapshotDigest",
849
+ "derivedOutcomes",
850
+ "metrics",
851
+ "signalIds",
852
+ "evidence"
853
+ ],
854
+ "properties": {
855
+ "assessmentDigest": {
856
+ "$ref": "#/$defs/sha256"
857
+ },
858
+ "kind": {
859
+ "enum": [
860
+ "cycle",
861
+ "direction-violation",
862
+ "evidence-gap",
863
+ "ownership-ambiguous",
864
+ "undeclared-footprint",
865
+ "unowned-paths"
866
+ ]
867
+ },
868
+ "affectedNodeIds": {
869
+ "type": "array",
870
+ "items": {
871
+ "type": "string"
872
+ }
873
+ },
874
+ "baselineSnapshotDigest": {
875
+ "$ref": "#/$defs/sha256"
876
+ },
877
+ "derivedOutcomes": {
878
+ "type": "array",
879
+ "items": {
880
+ "$ref": "#/$defs/targetOutcome"
881
+ }
882
+ },
883
+ "metrics": {
884
+ "$ref": "#/$defs/observationMetrics"
885
+ },
886
+ "signalIds": {
887
+ "type": "array",
888
+ "uniqueItems": true,
889
+ "items": {
890
+ "type": "string"
891
+ }
892
+ },
893
+ "evidence": {
894
+ "$ref": "#/$defs/observationEvidence"
895
+ }
896
+ },
897
+ "allOf": [
898
+ {
899
+ "if": {
900
+ "properties": {
901
+ "kind": {
902
+ "const": "cycle"
903
+ }
904
+ }
905
+ },
906
+ "then": {
907
+ "properties": {
908
+ "evidence": {
909
+ "properties": {
910
+ "kind": {
911
+ "const": "cycle"
912
+ }
913
+ }
914
+ }
915
+ }
916
+ }
917
+ },
918
+ {
919
+ "if": {
920
+ "properties": {
921
+ "kind": {
922
+ "const": "direction-violation"
923
+ }
924
+ }
925
+ },
926
+ "then": {
927
+ "properties": {
928
+ "evidence": {
929
+ "properties": {
930
+ "kind": {
931
+ "const": "direction-violation"
932
+ }
933
+ }
934
+ }
935
+ }
936
+ }
937
+ },
938
+ {
939
+ "if": {
940
+ "properties": {
941
+ "kind": {
942
+ "const": "evidence-gap"
943
+ }
944
+ }
945
+ },
946
+ "then": {
947
+ "properties": {
948
+ "evidence": {
949
+ "properties": {
950
+ "kind": {
951
+ "const": "evidence-gap"
952
+ }
953
+ }
954
+ }
955
+ }
956
+ }
957
+ },
958
+ {
959
+ "if": {
960
+ "properties": {
961
+ "kind": {
962
+ "const": "ownership-ambiguous"
963
+ }
964
+ }
965
+ },
966
+ "then": {
967
+ "properties": {
968
+ "evidence": {
969
+ "properties": {
970
+ "kind": {
971
+ "const": "ownership-ambiguous"
972
+ }
973
+ }
974
+ }
975
+ }
976
+ }
977
+ },
978
+ {
979
+ "if": {
980
+ "properties": {
981
+ "kind": {
982
+ "const": "undeclared-footprint"
983
+ }
984
+ }
985
+ },
986
+ "then": {
987
+ "properties": {
988
+ "evidence": {
989
+ "properties": {
990
+ "kind": {
991
+ "const": "undeclared-footprint"
992
+ }
993
+ }
994
+ }
995
+ }
996
+ }
997
+ },
998
+ {
999
+ "if": {
1000
+ "properties": {
1001
+ "kind": {
1002
+ "const": "unowned-paths"
1003
+ }
1004
+ }
1005
+ },
1006
+ "then": {
1007
+ "properties": {
1008
+ "evidence": {
1009
+ "properties": {
1010
+ "kind": {
1011
+ "const": "unowned-paths"
1012
+ }
1013
+ }
1014
+ }
1015
+ }
1016
+ }
1017
+ }
1018
+ ]
1019
+ },
1020
+ "refactorProposalPayload": {
1021
+ "type": "object",
1022
+ "additionalProperties": false,
1023
+ "required": [
1024
+ "assessmentDigest",
1025
+ "proposalDigest",
1026
+ "scale",
1027
+ "affectedNodeIds",
1028
+ "majorChangeReasons",
1029
+ "baselineSnapshotDigest",
1030
+ "targetOutcomes",
1031
+ "killList"
1032
+ ],
1033
+ "properties": {
1034
+ "assessmentDigest": {
1035
+ "$ref": "#/$defs/sha256"
1036
+ },
1037
+ "proposalDigest": {
1038
+ "$ref": "#/$defs/sha256"
1039
+ },
1040
+ "scale": {
1041
+ "enum": [
1042
+ "architecture",
1043
+ "cross_module",
1044
+ "insufficient_evidence",
1045
+ "model_adoption_required",
1046
+ "module"
1047
+ ]
1048
+ },
1049
+ "affectedNodeIds": {
1050
+ "type": "array",
1051
+ "uniqueItems": true,
1052
+ "items": {
1053
+ "type": "string"
1054
+ }
1055
+ },
1056
+ "majorChangeReasons": {
1057
+ "type": "array",
1058
+ "uniqueItems": true,
1059
+ "items": {
1060
+ "enum": [
1061
+ "constraint-changed",
1062
+ "entrypoint-changed",
1063
+ "interface-changed",
1064
+ "lifecycle-changed",
1065
+ "node-added",
1066
+ "node-moved",
1067
+ "node-removed",
1068
+ "node-renamed",
1069
+ "ownership-changed",
1070
+ "relation-changed",
1071
+ "responsibility-changed",
1072
+ "risk-boundary-changed",
1073
+ "verified-flow-proof-changed"
1074
+ ]
1075
+ }
1076
+ },
1077
+ "baselineSnapshotDigest": {
1078
+ "$ref": "#/$defs/sha256"
1079
+ },
1080
+ "targetDelta": {
1081
+ "$ref": "#/$defs/architectureTargetDelta"
1082
+ },
1083
+ "targetOutcomes": {
1084
+ "type": "array",
1085
+ "items": {
1086
+ "$ref": "#/$defs/targetOutcome"
1087
+ }
1088
+ },
1089
+ "killList": {
1090
+ "type": "array",
1091
+ "items": {
1092
+ "$ref": "#/$defs/killListEntry"
1093
+ }
1094
+ }
1095
+ }
1096
+ },
1097
+ "recommendationV3": {
1098
+ "type": "object",
1099
+ "additionalProperties": false,
1100
+ "required": [
1101
+ "schemaVersion",
1102
+ "recommendationId",
1103
+ "runId",
1104
+ "fingerprint",
1105
+ "subject",
1106
+ "status",
1107
+ "confidence",
1108
+ "enforcement",
1109
+ "risk",
1110
+ "uncertainty",
1111
+ "evidenceBindingIds",
1112
+ "explanation",
1113
+ "authoredBy",
1114
+ "subjectSelectorId",
1115
+ "relations",
1116
+ "createdAt",
1117
+ "updatedAt",
1118
+ "category",
1119
+ "payload"
1120
+ ],
1121
+ "properties": {
1122
+ "schemaVersion": {
1123
+ "const": "archcontext.recommendation/v3"
1124
+ },
1125
+ "recommendationId": {
1126
+ "type": "string",
1127
+ "minLength": 1,
1128
+ "pattern": "\\S"
1129
+ },
1130
+ "runId": {
1131
+ "type": "string",
1132
+ "minLength": 1,
1133
+ "pattern": "\\S"
1134
+ },
1135
+ "fingerprint": {
1136
+ "$ref": "#/$defs/sha256"
1137
+ },
1138
+ "subject": {
1139
+ "type": "string"
1140
+ },
1141
+ "practiceId": {
1142
+ "type": "string"
1143
+ },
1144
+ "status": {
1145
+ "enum": [
1146
+ "open",
1147
+ "acknowledged",
1148
+ "accepted",
1149
+ "rejected",
1150
+ "deferred",
1151
+ "waived",
1152
+ "resolved",
1153
+ "superseded",
1154
+ "expired"
1155
+ ]
1156
+ },
1157
+ "confidence": {
1158
+ "enum": [
1159
+ "low",
1160
+ "medium",
1161
+ "high"
1162
+ ]
1163
+ },
1164
+ "enforcement": {
1165
+ "enum": [
1166
+ "advisory",
1167
+ "checkpoint",
1168
+ "complete"
1169
+ ]
1170
+ },
1171
+ "risk": {
1172
+ "enum": [
1173
+ "low",
1174
+ "medium",
1175
+ "high"
1176
+ ]
1177
+ },
1178
+ "uncertainty": {
1179
+ "enum": [
1180
+ "low",
1181
+ "medium",
1182
+ "high"
1183
+ ]
1184
+ },
1185
+ "evidenceBindingIds": {
1186
+ "type": "array",
1187
+ "uniqueItems": true,
1188
+ "items": {
1189
+ "type": "string"
1190
+ }
1191
+ },
1192
+ "explanation": {
1193
+ "type": "array",
1194
+ "items": {
1195
+ "type": "string"
1196
+ }
1197
+ },
1198
+ "authoredBy": {
1199
+ "$ref": "#/$defs/recommendationAuthor"
1200
+ },
1201
+ "subjectSelectorId": {
1202
+ "type": "string",
1203
+ "minLength": 1,
1204
+ "pattern": "\\S"
1205
+ },
1206
+ "relations": {
1207
+ "type": "object",
1208
+ "additionalProperties": false,
1209
+ "required": [],
1210
+ "properties": {
1211
+ "supersedes": {
1212
+ "type": "string"
1213
+ },
1214
+ "regressesFrom": {
1215
+ "type": "string"
1216
+ }
1217
+ }
1218
+ },
1219
+ "createdAt": {
1220
+ "type": "string"
1221
+ },
1222
+ "updatedAt": {
1223
+ "type": "string"
1224
+ },
1225
+ "extensions": {
1226
+ "type": "object",
1227
+ "additionalProperties": true
1228
+ },
1229
+ "category": {
1230
+ "enum": [
1231
+ "practice",
1232
+ "refactor_proposal",
1233
+ "structural_observation"
1234
+ ]
1235
+ },
1236
+ "payload": {
1237
+ "type": "object"
1238
+ }
1239
+ },
1240
+ "allOf": [
1241
+ {
1242
+ "if": {
1243
+ "properties": {
1244
+ "category": {
1245
+ "const": "practice"
1246
+ }
1247
+ }
1248
+ },
1249
+ "then": {
1250
+ "required": [
1251
+ "practiceId"
1252
+ ],
1253
+ "properties": {
1254
+ "payload": {
1255
+ "$ref": "#/$defs/practiceRecommendationPayload"
1256
+ }
1257
+ }
1258
+ }
1259
+ },
1260
+ {
1261
+ "if": {
1262
+ "properties": {
1263
+ "category": {
1264
+ "const": "structural_observation"
1265
+ }
1266
+ }
1267
+ },
1268
+ "then": {
1269
+ "properties": {
1270
+ "payload": {
1271
+ "$ref": "#/$defs/structuralObservationPayload"
1272
+ },
1273
+ "enforcement": {
1274
+ "const": "advisory"
1275
+ },
1276
+ "authoredBy": {
1277
+ "properties": {
1278
+ "kind": {
1279
+ "const": "daemon"
1280
+ },
1281
+ "source": {
1282
+ "const": "daemon"
1283
+ }
1284
+ }
1285
+ }
1286
+ }
1287
+ }
1288
+ },
1289
+ {
1290
+ "if": {
1291
+ "properties": {
1292
+ "category": {
1293
+ "const": "refactor_proposal"
1294
+ }
1295
+ }
1296
+ },
1297
+ "then": {
1298
+ "properties": {
1299
+ "payload": {
1300
+ "$ref": "#/$defs/refactorProposalPayload"
1301
+ },
1302
+ "authoredBy": {
1303
+ "oneOf": [
1304
+ {
1305
+ "properties": {
1306
+ "kind": {
1307
+ "const": "cli"
1308
+ },
1309
+ "source": {
1310
+ "enum": [
1311
+ "cli"
1312
+ ]
1313
+ }
1314
+ }
1315
+ },
1316
+ {
1317
+ "properties": {
1318
+ "kind": {
1319
+ "const": "developer"
1320
+ },
1321
+ "source": {
1322
+ "enum": [
1323
+ "manual"
1324
+ ]
1325
+ }
1326
+ }
1327
+ },
1328
+ {
1329
+ "properties": {
1330
+ "kind": {
1331
+ "const": "mcp"
1332
+ },
1333
+ "source": {
1334
+ "enum": [
1335
+ "mcp"
1336
+ ]
1337
+ }
1338
+ }
1339
+ },
1340
+ {
1341
+ "properties": {
1342
+ "kind": {
1343
+ "const": "subagent"
1344
+ },
1345
+ "source": {
1346
+ "enum": [
1347
+ "subagent"
1348
+ ]
1349
+ }
1350
+ }
1351
+ }
1352
+ ]
1353
+ }
1354
+ },
1355
+ "if": {
1356
+ "properties": {
1357
+ "payload": {
1358
+ "properties": {
1359
+ "scale": {
1360
+ "const": "architecture"
1361
+ }
1362
+ }
1363
+ }
1364
+ }
1365
+ },
1366
+ "then": {
1367
+ "properties": {
1368
+ "enforcement": {
1369
+ "const": "complete"
1370
+ }
1371
+ }
1372
+ },
1373
+ "else": {
1374
+ "properties": {
1375
+ "enforcement": {
1376
+ "const": "checkpoint"
1377
+ }
1378
+ }
1379
+ }
1380
+ }
1381
+ }
1382
+ ]
1383
+ },
1384
+ "repositoryIdentity": {
1385
+ "type": "object",
1386
+ "additionalProperties": false,
1387
+ "required": [
1388
+ "repositoryId",
1389
+ "storageRepositoryId"
1390
+ ],
1391
+ "properties": {
1392
+ "repositoryId": {
1393
+ "type": "string"
1394
+ },
1395
+ "storageRepositoryId": {
1396
+ "type": "string"
1397
+ }
1398
+ }
1399
+ },
1400
+ "worktreeIdentity": {
1401
+ "type": "object",
1402
+ "additionalProperties": false,
1403
+ "required": [
1404
+ "workspaceId",
1405
+ "storageWorkspaceId",
1406
+ "branch",
1407
+ "headSha",
1408
+ "worktreeDigest"
1409
+ ],
1410
+ "properties": {
1411
+ "workspaceId": {
1412
+ "type": "string"
1413
+ },
1414
+ "storageWorkspaceId": {
1415
+ "type": "string"
1416
+ },
1417
+ "branch": {
1418
+ "type": "string"
1419
+ },
1420
+ "headSha": {
1421
+ "type": "string"
1422
+ },
1423
+ "worktreeDigest": {
1424
+ "$ref": "#/$defs/sha256"
1425
+ }
1426
+ }
1427
+ },
1428
+ "moduleStatistics": {
1429
+ "type": "object",
1430
+ "additionalProperties": false,
1431
+ "required": [
1432
+ "nodeId",
1433
+ "nodeDigest",
1434
+ "parentNodeId",
1435
+ "footprintDeclared",
1436
+ "footprint",
1437
+ "surfaces",
1438
+ "dependencyGraph",
1439
+ "tests",
1440
+ "uncertainty",
1441
+ "moduleDigest"
1442
+ ],
1443
+ "properties": {
1444
+ "nodeId": {
1445
+ "type": "string",
1446
+ "minLength": 1,
1447
+ "pattern": "\\S"
1448
+ },
1449
+ "nodeDigest": {
1450
+ "$ref": "#/$defs/sha256"
1451
+ },
1452
+ "parentNodeId": {
1453
+ "type": [
1454
+ "string",
1455
+ "null"
1456
+ ]
1457
+ },
1458
+ "footprintDeclared": {
1459
+ "type": "boolean"
1460
+ },
1461
+ "footprint": {
1462
+ "oneOf": [
1463
+ {
1464
+ "type": "null"
1465
+ },
1466
+ {
1467
+ "type": "object",
1468
+ "additionalProperties": false,
1469
+ "required": [
1470
+ "fileCount",
1471
+ "lineCount",
1472
+ "sourceFilesDigest",
1473
+ "includePatterns",
1474
+ "excludePatterns"
1475
+ ],
1476
+ "properties": {
1477
+ "fileCount": {
1478
+ "type": "integer",
1479
+ "minimum": 0
1480
+ },
1481
+ "lineCount": {
1482
+ "type": "integer",
1483
+ "minimum": 0
1484
+ },
1485
+ "sourceFilesDigest": {
1486
+ "$ref": "#/$defs/sha256"
1487
+ },
1488
+ "includePatterns": {
1489
+ "type": "array",
1490
+ "items": {
1491
+ "type": "string"
1492
+ }
1493
+ },
1494
+ "excludePatterns": {
1495
+ "type": "array",
1496
+ "items": {
1497
+ "type": "string"
1498
+ }
1499
+ }
1500
+ }
1501
+ }
1502
+ ]
1503
+ },
1504
+ "surfaces": {
1505
+ "type": "object",
1506
+ "additionalProperties": false,
1507
+ "required": [
1508
+ "declaredEntrypoints",
1509
+ "observedEntrypoints",
1510
+ "lifecycleOwners",
1511
+ "datastoreSubjects"
1512
+ ],
1513
+ "properties": {
1514
+ "declaredEntrypoints": {
1515
+ "type": "array",
1516
+ "items": {
1517
+ "type": "string"
1518
+ }
1519
+ },
1520
+ "observedEntrypoints": {
1521
+ "type": "array",
1522
+ "items": {
1523
+ "type": "string"
1524
+ }
1525
+ },
1526
+ "lifecycleOwners": {
1527
+ "type": "array",
1528
+ "items": {
1529
+ "type": "string"
1530
+ }
1531
+ },
1532
+ "datastoreSubjects": {
1533
+ "type": "array",
1534
+ "items": {
1535
+ "type": "string"
1536
+ }
1537
+ }
1538
+ }
1539
+ },
1540
+ "dependencyGraph": {
1541
+ "oneOf": [
1542
+ {
1543
+ "type": "null"
1544
+ },
1545
+ {
1546
+ "type": "object",
1547
+ "additionalProperties": false,
1548
+ "required": [
1549
+ "internalEdgeCount",
1550
+ "inboundModuleEdges",
1551
+ "outboundModuleEdges",
1552
+ "fanIn",
1553
+ "fanOut",
1554
+ "stronglyConnectedComponentId",
1555
+ "cycleCount",
1556
+ "instability",
1557
+ "directionViolationCount"
1558
+ ],
1559
+ "properties": {
1560
+ "internalEdgeCount": {
1561
+ "type": "integer",
1562
+ "minimum": 0
1563
+ },
1564
+ "inboundModuleEdges": {
1565
+ "type": "integer",
1566
+ "minimum": 0
1567
+ },
1568
+ "outboundModuleEdges": {
1569
+ "type": "integer",
1570
+ "minimum": 0
1571
+ },
1572
+ "fanIn": {
1573
+ "type": "integer",
1574
+ "minimum": 0
1575
+ },
1576
+ "fanOut": {
1577
+ "type": "integer",
1578
+ "minimum": 0
1579
+ },
1580
+ "stronglyConnectedComponentId": {
1581
+ "type": [
1582
+ "string",
1583
+ "null"
1584
+ ]
1585
+ },
1586
+ "cycleCount": {
1587
+ "type": "integer",
1588
+ "minimum": 0
1589
+ },
1590
+ "instability": {
1591
+ "type": [
1592
+ "number",
1593
+ "null"
1594
+ ],
1595
+ "minimum": 0,
1596
+ "maximum": 1
1597
+ },
1598
+ "directionViolationCount": {
1599
+ "type": [
1600
+ "integer",
1601
+ "null"
1602
+ ],
1603
+ "minimum": 0
1604
+ }
1605
+ }
1606
+ }
1607
+ ]
1608
+ },
1609
+ "tests": {
1610
+ "type": "object",
1611
+ "additionalProperties": false,
1612
+ "required": [
1613
+ "testFileCount",
1614
+ "observedTestEdges",
1615
+ "callerCoverage",
1616
+ "coverageStatus"
1617
+ ],
1618
+ "properties": {
1619
+ "testFileCount": {
1620
+ "type": [
1621
+ "integer",
1622
+ "null"
1623
+ ],
1624
+ "minimum": 0
1625
+ },
1626
+ "observedTestEdges": {
1627
+ "type": [
1628
+ "integer",
1629
+ "null"
1630
+ ],
1631
+ "minimum": 0
1632
+ },
1633
+ "callerCoverage": {
1634
+ "type": [
1635
+ "number",
1636
+ "null"
1637
+ ],
1638
+ "minimum": 0,
1639
+ "maximum": 1
1640
+ },
1641
+ "coverageStatus": {
1642
+ "enum": [
1643
+ "measured",
1644
+ "partial",
1645
+ "unknown"
1646
+ ]
1647
+ }
1648
+ }
1649
+ },
1650
+ "uncertainty": {
1651
+ "type": "object",
1652
+ "additionalProperties": false,
1653
+ "required": [
1654
+ "unresolvedImports",
1655
+ "dynamicInvocation",
1656
+ "ambiguousOwnership"
1657
+ ],
1658
+ "properties": {
1659
+ "unresolvedImports": {
1660
+ "type": "integer",
1661
+ "minimum": 0
1662
+ },
1663
+ "dynamicInvocation": {
1664
+ "enum": [
1665
+ "known",
1666
+ "none_observed",
1667
+ "possible",
1668
+ "unknown"
1669
+ ]
1670
+ },
1671
+ "ambiguousOwnership": {
1672
+ "type": "boolean"
1673
+ }
1674
+ }
1675
+ },
1676
+ "moduleDigest": {
1677
+ "$ref": "#/$defs/sha256"
1678
+ },
1679
+ "extensions": {
1680
+ "type": "object",
1681
+ "additionalProperties": true
1682
+ }
1683
+ },
1684
+ "if": {
1685
+ "properties": {
1686
+ "footprintDeclared": {
1687
+ "const": true
1688
+ }
1689
+ }
1690
+ },
1691
+ "then": {
1692
+ "properties": {
1693
+ "footprint": {
1694
+ "type": "object"
1695
+ }
1696
+ }
1697
+ },
1698
+ "else": {
1699
+ "properties": {
1700
+ "footprint": {
1701
+ "type": "null"
1702
+ }
1703
+ }
1704
+ }
1705
+ },
1706
+ "moduleStatisticsSnapshot": {
1707
+ "type": "object",
1708
+ "additionalProperties": false,
1709
+ "required": [
1710
+ "schemaVersion",
1711
+ "repository",
1712
+ "worktree",
1713
+ "modelDigest",
1714
+ "codeFacts",
1715
+ "modules",
1716
+ "repositorySummary",
1717
+ "createdAt",
1718
+ "snapshotDigest"
1719
+ ],
1720
+ "properties": {
1721
+ "schemaVersion": {
1722
+ "const": "archcontext.module-statistics/v1"
1723
+ },
1724
+ "repository": {
1725
+ "$ref": "#/$defs/repositoryIdentity"
1726
+ },
1727
+ "worktree": {
1728
+ "$ref": "#/$defs/worktreeIdentity"
1729
+ },
1730
+ "modelDigest": {
1731
+ "$ref": "#/$defs/sha256"
1732
+ },
1733
+ "codeFacts": {
1734
+ "type": "object",
1735
+ "additionalProperties": false,
1736
+ "required": [
1737
+ "provider",
1738
+ "version",
1739
+ "binaryDigest",
1740
+ "indexedWorktreeDigest",
1741
+ "coverage",
1742
+ "truncated",
1743
+ "edgeLimit",
1744
+ "reasonCodes"
1745
+ ],
1746
+ "properties": {
1747
+ "provider": {
1748
+ "const": "codegraph"
1749
+ },
1750
+ "version": {
1751
+ "type": "string"
1752
+ },
1753
+ "binaryDigest": {
1754
+ "type": "string"
1755
+ },
1756
+ "indexedWorktreeDigest": {
1757
+ "oneOf": [
1758
+ {
1759
+ "type": "null"
1760
+ },
1761
+ {
1762
+ "$ref": "#/$defs/sha256"
1763
+ }
1764
+ ]
1765
+ },
1766
+ "coverage": {
1767
+ "enum": [
1768
+ "complete",
1769
+ "partial",
1770
+ "unknown"
1771
+ ]
1772
+ },
1773
+ "truncated": {
1774
+ "type": "boolean"
1775
+ },
1776
+ "edgeLimit": {
1777
+ "type": [
1778
+ "integer",
1779
+ "null"
1780
+ ],
1781
+ "minimum": 0
1782
+ },
1783
+ "reasonCodes": {
1784
+ "type": "array",
1785
+ "uniqueItems": true,
1786
+ "items": {
1787
+ "enum": [
1788
+ "caller-coverage-unknown",
1789
+ "code-facts-missing",
1790
+ "code-facts-truncated",
1791
+ "major-change-detected",
1792
+ "multi-node-scope",
1793
+ "node-footprint-undeclared",
1794
+ "ownership-ambiguous",
1795
+ "single-node-scope",
1796
+ "target-unresolved",
1797
+ "unowned-paths"
1798
+ ]
1799
+ }
1800
+ }
1801
+ }
1802
+ },
1803
+ "modules": {
1804
+ "type": "array",
1805
+ "items": {
1806
+ "$ref": "#/$defs/moduleStatistics"
1807
+ }
1808
+ },
1809
+ "repositorySummary": {
1810
+ "type": "object",
1811
+ "additionalProperties": false,
1812
+ "required": [
1813
+ "moduleCount",
1814
+ "undeclaredFootprintNodeCount",
1815
+ "ownedFileCount",
1816
+ "unownedFileCount",
1817
+ "multiplyOwnedFileCount",
1818
+ "crossModuleEdgeCount",
1819
+ "crossModuleCycleCount",
1820
+ "stronglyConnectedComponentCount",
1821
+ "unresolvedImportCount",
1822
+ "dynamicInvocationRiskCount"
1823
+ ],
1824
+ "properties": {
1825
+ "moduleCount": {
1826
+ "type": "integer",
1827
+ "minimum": 0
1828
+ },
1829
+ "undeclaredFootprintNodeCount": {
1830
+ "type": "integer",
1831
+ "minimum": 0
1832
+ },
1833
+ "ownedFileCount": {
1834
+ "type": "integer",
1835
+ "minimum": 0
1836
+ },
1837
+ "unownedFileCount": {
1838
+ "type": "integer",
1839
+ "minimum": 0
1840
+ },
1841
+ "multiplyOwnedFileCount": {
1842
+ "type": "integer",
1843
+ "minimum": 0
1844
+ },
1845
+ "crossModuleEdgeCount": {
1846
+ "type": "integer",
1847
+ "minimum": 0
1848
+ },
1849
+ "crossModuleCycleCount": {
1850
+ "type": "integer",
1851
+ "minimum": 0
1852
+ },
1853
+ "stronglyConnectedComponentCount": {
1854
+ "type": "integer",
1855
+ "minimum": 0
1856
+ },
1857
+ "unresolvedImportCount": {
1858
+ "type": "integer",
1859
+ "minimum": 0
1860
+ },
1861
+ "dynamicInvocationRiskCount": {
1862
+ "type": "integer",
1863
+ "minimum": 0
1864
+ }
1865
+ }
1866
+ },
1867
+ "createdAt": {
1868
+ "type": "string"
1869
+ },
1870
+ "snapshotDigest": {
1871
+ "$ref": "#/$defs/sha256"
1872
+ },
1873
+ "extensions": {
1874
+ "type": "object",
1875
+ "additionalProperties": true
1876
+ }
1877
+ }
1878
+ },
1879
+ "refactorScope": {
1880
+ "oneOf": [
1881
+ {
1882
+ "type": "object",
1883
+ "additionalProperties": false,
1884
+ "required": [
1885
+ "kind"
1886
+ ],
1887
+ "properties": {
1888
+ "kind": {
1889
+ "const": "repository"
1890
+ }
1891
+ }
1892
+ },
1893
+ {
1894
+ "type": "object",
1895
+ "additionalProperties": false,
1896
+ "required": [
1897
+ "kind",
1898
+ "nodeId"
1899
+ ],
1900
+ "properties": {
1901
+ "kind": {
1902
+ "const": "node"
1903
+ },
1904
+ "nodeId": {
1905
+ "type": "string",
1906
+ "minLength": 1,
1907
+ "pattern": "\\S"
1908
+ }
1909
+ }
1910
+ },
1911
+ {
1912
+ "type": "object",
1913
+ "additionalProperties": false,
1914
+ "required": [
1915
+ "kind",
1916
+ "paths"
1917
+ ],
1918
+ "properties": {
1919
+ "kind": {
1920
+ "const": "paths"
1921
+ },
1922
+ "paths": {
1923
+ "type": "array",
1924
+ "minItems": 1,
1925
+ "uniqueItems": true,
1926
+ "items": {
1927
+ "$ref": "#/$defs/repoRelativePath"
1928
+ }
1929
+ }
1930
+ }
1931
+ }
1932
+ ]
1933
+ },
1934
+ "refactorProposal": {
1935
+ "type": "object",
1936
+ "additionalProperties": false,
1937
+ "required": [
1938
+ "schemaVersion",
1939
+ "authoredBy",
1940
+ "intent",
1941
+ "scopePaths",
1942
+ "targetOutcomes",
1943
+ "killList",
1944
+ "proposalDigest"
1945
+ ],
1946
+ "properties": {
1947
+ "schemaVersion": {
1948
+ "const": "archcontext.refactor-proposal/v1"
1949
+ },
1950
+ "authoredBy": {
1951
+ "allOf": [
1952
+ {
1953
+ "$ref": "#/$defs/recommendationAuthor"
1954
+ },
1955
+ {
1956
+ "oneOf": [
1957
+ {
1958
+ "properties": {
1959
+ "kind": {
1960
+ "const": "cli"
1961
+ },
1962
+ "source": {
1963
+ "enum": [
1964
+ "cli"
1965
+ ]
1966
+ }
1967
+ }
1968
+ },
1969
+ {
1970
+ "properties": {
1971
+ "kind": {
1972
+ "const": "developer"
1973
+ },
1974
+ "source": {
1975
+ "enum": [
1976
+ "manual"
1977
+ ]
1978
+ }
1979
+ }
1980
+ },
1981
+ {
1982
+ "properties": {
1983
+ "kind": {
1984
+ "const": "mcp"
1985
+ },
1986
+ "source": {
1987
+ "enum": [
1988
+ "mcp"
1989
+ ]
1990
+ }
1991
+ }
1992
+ },
1993
+ {
1994
+ "properties": {
1995
+ "kind": {
1996
+ "const": "subagent"
1997
+ },
1998
+ "source": {
1999
+ "enum": [
2000
+ "subagent"
2001
+ ]
2002
+ }
2003
+ }
2004
+ }
2005
+ ]
2006
+ }
2007
+ ]
2008
+ },
2009
+ "intent": {
2010
+ "type": "string",
2011
+ "minLength": 1,
2012
+ "pattern": "\\S"
2013
+ },
2014
+ "scopePaths": {
2015
+ "type": "array",
2016
+ "minItems": 1,
2017
+ "uniqueItems": true,
2018
+ "items": {
2019
+ "$ref": "#/$defs/repoRelativePath"
2020
+ }
2021
+ },
2022
+ "targetDelta": {
2023
+ "$ref": "#/$defs/architectureTargetDelta"
2024
+ },
2025
+ "targetOutcomes": {
2026
+ "type": "array",
2027
+ "items": {
2028
+ "$ref": "#/$defs/targetOutcome"
2029
+ }
2030
+ },
2031
+ "killList": {
2032
+ "type": "array",
2033
+ "items": {
2034
+ "$ref": "#/$defs/killListEntry"
2035
+ }
2036
+ },
2037
+ "proposalDigest": {
2038
+ "$ref": "#/$defs/sha256"
2039
+ },
2040
+ "extensions": {
2041
+ "type": "object",
2042
+ "additionalProperties": true
2043
+ }
2044
+ }
2045
+ },
2046
+ "refactorRequest": {
2047
+ "type": "object",
2048
+ "additionalProperties": false,
2049
+ "required": [
2050
+ "schemaVersion",
2051
+ "scope"
2052
+ ],
2053
+ "properties": {
2054
+ "schemaVersion": {
2055
+ "const": "archcontext.refactor-request/v1"
2056
+ },
2057
+ "scope": {
2058
+ "$ref": "#/$defs/refactorScope"
2059
+ },
2060
+ "proposal": {
2061
+ "$ref": "#/$defs/refactorProposal"
2062
+ },
2063
+ "expectedHeadSha": {
2064
+ "type": "string"
2065
+ },
2066
+ "expectedWorktreeDigest": {
2067
+ "type": "string"
2068
+ },
2069
+ "task": {
2070
+ "type": "string"
2071
+ }
2072
+ }
2073
+ },
2074
+ "refactorObservation": {
2075
+ "type": "object",
2076
+ "additionalProperties": false,
2077
+ "required": [
2078
+ "kind",
2079
+ "subjectSelectorId",
2080
+ "signalIds",
2081
+ "metrics",
2082
+ "evidence"
2083
+ ],
2084
+ "properties": {
2085
+ "kind": {
2086
+ "enum": [
2087
+ "cycle",
2088
+ "direction-violation",
2089
+ "evidence-gap",
2090
+ "ownership-ambiguous",
2091
+ "undeclared-footprint",
2092
+ "unowned-paths"
2093
+ ]
2094
+ },
2095
+ "subjectSelectorId": {
2096
+ "type": "string",
2097
+ "minLength": 1,
2098
+ "pattern": "\\S"
2099
+ },
2100
+ "signalIds": {
2101
+ "type": "array",
2102
+ "uniqueItems": true,
2103
+ "items": {
2104
+ "type": "string"
2105
+ }
2106
+ },
2107
+ "metrics": {
2108
+ "$ref": "#/$defs/observationMetrics"
2109
+ },
2110
+ "evidence": {
2111
+ "$ref": "#/$defs/observationEvidence"
2112
+ }
2113
+ },
2114
+ "allOf": [
2115
+ {
2116
+ "if": {
2117
+ "properties": {
2118
+ "kind": {
2119
+ "const": "cycle"
2120
+ }
2121
+ }
2122
+ },
2123
+ "then": {
2124
+ "properties": {
2125
+ "evidence": {
2126
+ "properties": {
2127
+ "kind": {
2128
+ "const": "cycle"
2129
+ }
2130
+ }
2131
+ }
2132
+ }
2133
+ }
2134
+ },
2135
+ {
2136
+ "if": {
2137
+ "properties": {
2138
+ "kind": {
2139
+ "const": "direction-violation"
2140
+ }
2141
+ }
2142
+ },
2143
+ "then": {
2144
+ "properties": {
2145
+ "evidence": {
2146
+ "properties": {
2147
+ "kind": {
2148
+ "const": "direction-violation"
2149
+ }
2150
+ }
2151
+ }
2152
+ }
2153
+ }
2154
+ },
2155
+ {
2156
+ "if": {
2157
+ "properties": {
2158
+ "kind": {
2159
+ "const": "evidence-gap"
2160
+ }
2161
+ }
2162
+ },
2163
+ "then": {
2164
+ "properties": {
2165
+ "evidence": {
2166
+ "properties": {
2167
+ "kind": {
2168
+ "const": "evidence-gap"
2169
+ }
2170
+ }
2171
+ }
2172
+ }
2173
+ }
2174
+ },
2175
+ {
2176
+ "if": {
2177
+ "properties": {
2178
+ "kind": {
2179
+ "const": "ownership-ambiguous"
2180
+ }
2181
+ }
2182
+ },
2183
+ "then": {
2184
+ "properties": {
2185
+ "evidence": {
2186
+ "properties": {
2187
+ "kind": {
2188
+ "const": "ownership-ambiguous"
2189
+ }
2190
+ }
2191
+ }
2192
+ }
2193
+ }
2194
+ },
2195
+ {
2196
+ "if": {
2197
+ "properties": {
2198
+ "kind": {
2199
+ "const": "undeclared-footprint"
2200
+ }
2201
+ }
2202
+ },
2203
+ "then": {
2204
+ "properties": {
2205
+ "evidence": {
2206
+ "properties": {
2207
+ "kind": {
2208
+ "const": "undeclared-footprint"
2209
+ }
2210
+ }
2211
+ }
2212
+ }
2213
+ }
2214
+ },
2215
+ {
2216
+ "if": {
2217
+ "properties": {
2218
+ "kind": {
2219
+ "const": "unowned-paths"
2220
+ }
2221
+ }
2222
+ },
2223
+ "then": {
2224
+ "properties": {
2225
+ "evidence": {
2226
+ "properties": {
2227
+ "kind": {
2228
+ "const": "unowned-paths"
2229
+ }
2230
+ }
2231
+ }
2232
+ }
2233
+ }
2234
+ }
2235
+ ]
2236
+ },
2237
+ "refactorAssessment": {
2238
+ "type": "object",
2239
+ "additionalProperties": false,
2240
+ "required": [
2241
+ "schemaVersion",
2242
+ "requestId",
2243
+ "statisticsSnapshotDigest",
2244
+ "modelDigest",
2245
+ "codeFactsDigest",
2246
+ "requestedScope",
2247
+ "proposalDigest",
2248
+ "observations",
2249
+ "scale",
2250
+ "scaleReasonCodes",
2251
+ "affectedNodeIds",
2252
+ "majorChangeReasons",
2253
+ "pressure",
2254
+ "confidence",
2255
+ "createdAt",
2256
+ "assessmentDigest"
2257
+ ],
2258
+ "properties": {
2259
+ "schemaVersion": {
2260
+ "const": "archcontext.refactor-assessment/v1"
2261
+ },
2262
+ "requestId": {
2263
+ "type": "string"
2264
+ },
2265
+ "statisticsSnapshotDigest": {
2266
+ "$ref": "#/$defs/sha256"
2267
+ },
2268
+ "modelDigest": {
2269
+ "$ref": "#/$defs/sha256"
2270
+ },
2271
+ "codeFactsDigest": {
2272
+ "$ref": "#/$defs/sha256"
2273
+ },
2274
+ "requestedScope": {
2275
+ "$ref": "#/$defs/refactorScope"
2276
+ },
2277
+ "proposalDigest": {
2278
+ "oneOf": [
2279
+ {
2280
+ "type": "null"
2281
+ },
2282
+ {
2283
+ "$ref": "#/$defs/sha256"
2284
+ }
2285
+ ]
2286
+ },
2287
+ "observations": {
2288
+ "type": "array",
2289
+ "items": {
2290
+ "$ref": "#/$defs/refactorObservation"
2291
+ }
2292
+ },
2293
+ "scale": {
2294
+ "oneOf": [
2295
+ {
2296
+ "type": "null"
2297
+ },
2298
+ {
2299
+ "enum": [
2300
+ "architecture",
2301
+ "cross_module",
2302
+ "insufficient_evidence",
2303
+ "model_adoption_required",
2304
+ "module"
2305
+ ]
2306
+ }
2307
+ ]
2308
+ },
2309
+ "scaleReasonCodes": {
2310
+ "type": "array",
2311
+ "uniqueItems": true,
2312
+ "items": {
2313
+ "enum": [
2314
+ "caller-coverage-unknown",
2315
+ "code-facts-missing",
2316
+ "code-facts-truncated",
2317
+ "major-change-detected",
2318
+ "multi-node-scope",
2319
+ "node-footprint-undeclared",
2320
+ "ownership-ambiguous",
2321
+ "single-node-scope",
2322
+ "target-unresolved",
2323
+ "unowned-paths"
2324
+ ]
2325
+ }
2326
+ },
2327
+ "affectedNodeIds": {
2328
+ "type": "array",
2329
+ "uniqueItems": true,
2330
+ "items": {
2331
+ "type": "string"
2332
+ }
2333
+ },
2334
+ "majorChangeReasons": {
2335
+ "type": "array",
2336
+ "uniqueItems": true,
2337
+ "items": {
2338
+ "enum": [
2339
+ "constraint-changed",
2340
+ "entrypoint-changed",
2341
+ "interface-changed",
2342
+ "lifecycle-changed",
2343
+ "node-added",
2344
+ "node-moved",
2345
+ "node-removed",
2346
+ "node-renamed",
2347
+ "ownership-changed",
2348
+ "relation-changed",
2349
+ "responsibility-changed",
2350
+ "risk-boundary-changed",
2351
+ "verified-flow-proof-changed"
2352
+ ]
2353
+ }
2354
+ },
2355
+ "pressure": {
2356
+ "type": "object",
2357
+ "additionalProperties": false,
2358
+ "required": [
2359
+ "level",
2360
+ "score",
2361
+ "signalIds"
2362
+ ],
2363
+ "properties": {
2364
+ "level": {
2365
+ "enum": [
2366
+ "low",
2367
+ "medium",
2368
+ "high"
2369
+ ]
2370
+ },
2371
+ "score": {
2372
+ "type": "integer",
2373
+ "minimum": 0,
2374
+ "maximum": 100
2375
+ },
2376
+ "signalIds": {
2377
+ "type": "array",
2378
+ "uniqueItems": true,
2379
+ "items": {
2380
+ "type": "string"
2381
+ }
2382
+ }
2383
+ }
2384
+ },
2385
+ "confidence": {
2386
+ "type": "object",
2387
+ "additionalProperties": false,
2388
+ "required": [
2389
+ "level",
2390
+ "callerCoverage",
2391
+ "testsObserved",
2392
+ "rollbackObserved",
2393
+ "unresolvedEvidence"
2394
+ ],
2395
+ "properties": {
2396
+ "level": {
2397
+ "enum": [
2398
+ "low",
2399
+ "medium",
2400
+ "high"
2401
+ ]
2402
+ },
2403
+ "callerCoverage": {
2404
+ "type": [
2405
+ "number",
2406
+ "null"
2407
+ ],
2408
+ "minimum": 0,
2409
+ "maximum": 1
2410
+ },
2411
+ "testsObserved": {
2412
+ "type": [
2413
+ "boolean",
2414
+ "null"
2415
+ ]
2416
+ },
2417
+ "rollbackObserved": {
2418
+ "type": [
2419
+ "boolean",
2420
+ "null"
2421
+ ]
2422
+ },
2423
+ "unresolvedEvidence": {
2424
+ "type": "array",
2425
+ "items": {
2426
+ "type": "string"
2427
+ }
2428
+ }
2429
+ }
2430
+ },
2431
+ "createdAt": {
2432
+ "type": "string"
2433
+ },
2434
+ "assessmentDigest": {
2435
+ "$ref": "#/$defs/sha256"
2436
+ },
2437
+ "extensions": {
2438
+ "type": "object",
2439
+ "additionalProperties": true
2440
+ }
2441
+ },
2442
+ "if": {
2443
+ "properties": {
2444
+ "proposalDigest": {
2445
+ "type": "null"
2446
+ }
2447
+ }
2448
+ },
2449
+ "then": {
2450
+ "properties": {
2451
+ "scale": {
2452
+ "type": "null"
2453
+ }
2454
+ }
2455
+ },
2456
+ "else": {
2457
+ "properties": {
2458
+ "scale": {
2459
+ "type": "string"
2460
+ }
2461
+ }
2462
+ }
2463
+ },
2464
+ "privacy": {
2465
+ "type": "object",
2466
+ "additionalProperties": false,
2467
+ "required": [
2468
+ "writes",
2469
+ "rawSourcePersisted",
2470
+ "rawDiffPersisted",
2471
+ "promptPersisted"
2472
+ ],
2473
+ "properties": {
2474
+ "writes": {
2475
+ "const": "none"
2476
+ },
2477
+ "rawSourcePersisted": {
2478
+ "const": false
2479
+ },
2480
+ "rawDiffPersisted": {
2481
+ "const": false
2482
+ },
2483
+ "promptPersisted": {
2484
+ "const": false
2485
+ }
2486
+ }
2487
+ }
2488
+ }
2489
+ }