archctx-contracts 0.17.0 → 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 (119) hide show
  1. package/fixtures/invalid/projection-result-applied-incomplete-coverage.json +3 -3
  2. package/fixtures/valid/archctx-capabilities.json +2 -2
  3. package/fixtures/valid/flow-selector-check.json +1 -1
  4. package/fixtures/valid/product-version-manifest.json +5 -11
  5. package/fixtures/valid/projection-manifest.json +1 -1
  6. package/fixtures/valid/projection-result.json +3 -3
  7. package/package.json +4 -1
  8. package/schemas/repo/refactor-decision.schema.json +283 -37
  9. package/schemas/runtime/archctx-capabilities.schema.json +144 -20
  10. package/schemas/runtime/architecture-debt-delta.schema.json +58 -19
  11. package/schemas/runtime/architecture-debt.schema.json +42 -42
  12. package/schemas/runtime/architecture-event.schema.json +1 -1
  13. package/schemas/runtime/architecture-history.schema.json +354 -0
  14. package/schemas/runtime/capability-dependencies.schema.json +266 -59
  15. package/schemas/runtime/cli-check.schema.json +197 -0
  16. package/schemas/runtime/cli-help.schema.json +28 -0
  17. package/schemas/runtime/dependency-constraint-evaluation.schema.json +67 -68
  18. package/schemas/runtime/docs-anchors.schema.json +250 -67
  19. package/schemas/runtime/doctor-code-facts.schema.json +49 -0
  20. package/schemas/runtime/evidence-binding.schema.json +1 -1
  21. package/schemas/runtime/flow-selector-check.schema.json +179 -46
  22. package/schemas/runtime/hook-debt-checkpoint.schema.json +12 -12
  23. package/schemas/runtime/index-seed.schema.json +56 -0
  24. package/schemas/runtime/path-context.schema.json +108 -0
  25. package/schemas/runtime/product-version-manifest.schema.json +142 -54
  26. package/schemas/runtime/projection-apply-readback.schema.json +2 -2
  27. package/schemas/runtime/projection-apply-recovery.schema.json +1 -1
  28. package/schemas/runtime/projection-result.schema.json +1 -1
  29. package/schemas/runtime/projection-slice.schema.json +34 -34
  30. package/schemas/runtime/recommendation-v3.schema.json +372 -1
  31. package/schemas/runtime/ref-impact-batch-request.schema.json +20 -7
  32. package/schemas/runtime/ref-impact-batch.schema.json +83 -13
  33. package/schemas/runtime/ref-impact.schema.json +68 -61
  34. package/schemas/runtime/refactor-scan-v2.schema.json +434 -0
  35. package/schemas/runtime/refactor-simulate.schema.json +505 -0
  36. package/schemas/runtime/refactor-verify-v2.schema.json +172 -0
  37. package/schemas/runtime/resolve-path.schema.json +69 -0
  38. package/schemas/runtime/runtime-recommendation-show.schema.json +531 -2
  39. package/schemas/runtime/runtime-refactor-scan.schema.json +498 -2
  40. package/schemas/runtime/runtime-verify.schema.json +274 -56
  41. package/schemas/runtime/state-machine-check.schema.json +357 -89
  42. package/schemas/runtime/structural-observation-payload.schema.json +372 -1
  43. package/schemas/runtime/sync-check.schema.json +65 -0
  44. package/src/architecture-debt.ts +125 -38
  45. package/src/architecture-history.ts +168 -42
  46. package/src/architecture.ts +100 -0
  47. package/src/cli-read.ts +228 -0
  48. package/src/docs-anchors.ts +105 -50
  49. package/src/explorer-occurrence-ports.ts +175 -0
  50. package/src/explorer-query-ports.ts +270 -0
  51. package/src/failure.ts +3 -0
  52. package/src/index-seed.ts +42 -0
  53. package/src/index.ts +5 -0
  54. package/src/ledger-records.ts +262 -0
  55. package/src/ledger.ts +27 -566
  56. package/src/ownership-dependencies.ts +115 -5
  57. package/src/ports.ts +12 -543
  58. package/src/product-version.ts +75 -56
  59. package/src/projection-apply-types.ts +216 -0
  60. package/src/projection-apply-validators.ts +355 -0
  61. package/src/projection-capabilities.ts +181 -0
  62. package/src/projection-constants.ts +317 -0
  63. package/src/projection-manifest-types.ts +298 -0
  64. package/src/projection-manifest.ts +12 -299
  65. package/src/projection-recovery-validators.ts +229 -0
  66. package/src/projection-request-validators.ts +326 -0
  67. package/src/projection-types.ts +365 -0
  68. package/src/projection-validation-helpers.ts +15 -0
  69. package/src/projection.ts +7 -1689
  70. package/src/ref-impact.ts +225 -33
  71. package/src/refactor-constants.ts +213 -0
  72. package/src/refactor-decision-validators.ts +350 -0
  73. package/src/refactor-evidence-types.ts +286 -0
  74. package/src/refactor-observation-validators.ts +359 -0
  75. package/src/refactor-resolution-validators.ts +229 -0
  76. package/src/refactor-snapshot-validators.ts +368 -0
  77. package/src/refactor-types.ts +270 -0
  78. package/src/refactor-v2.ts +389 -0
  79. package/src/refactor-validation-helpers.ts +195 -0
  80. package/src/refactor.ts +7 -1849
  81. package/src/review-guards.ts +3 -23
  82. package/src/runtime-verify.ts +87 -0
  83. package/src/schema-kit.ts +183 -0
  84. package/src/schema-registry.ts +73 -0
  85. package/src/schema.ts +0 -4
  86. package/src/state-machine-schemas.ts +192 -0
  87. package/src/state-machine-types.ts +188 -0
  88. package/src/state-machine.ts +9 -189
  89. package/fixtures/boundary/agent-job-expired.json +0 -33
  90. package/fixtures/invalid/adapter-fidelity-reverse-sync.json +0 -9
  91. package/fixtures/invalid/agent-job-direct-mutation.json +0 -32
  92. package/fixtures/invalid/cloud-egress-envelope-private-field.json +0 -12
  93. package/fixtures/invalid/investigation-report-direct-mutation.json +0 -38
  94. package/fixtures/invalid/investigation-report-missing-proposed-delta.json +0 -19
  95. package/fixtures/invalid/notification-event-code-field.json +0 -11
  96. package/fixtures/valid/adapter-fidelity.json +0 -9
  97. package/fixtures/valid/agent-job.json +0 -33
  98. package/fixtures/valid/architecture-candidate-delta-policy.json +0 -45
  99. package/fixtures/valid/architecture-candidate-delta.json +0 -188
  100. package/fixtures/valid/chatgpt-ga-tool.json +0 -9
  101. package/fixtures/valid/cloud-egress-envelope.json +0 -11
  102. package/fixtures/valid/entitlement.json +0 -12
  103. package/fixtures/valid/investigation-report.json +0 -38
  104. package/fixtures/valid/likec4-mapping.json +0 -14
  105. package/fixtures/valid/notification-event.json +0 -10
  106. package/fixtures/valid/notification-provider.json +0 -12
  107. package/fixtures/valid/structurizr-mapping.json +0 -15
  108. package/schemas/cloud/cloud-egress-envelope.schema.json +0 -19
  109. package/schemas/cloud/entitlement.schema.json +0 -24
  110. package/schemas/integrations/adapter-fidelity.schema.json +0 -21
  111. package/schemas/integrations/chatgpt-ga-tool.schema.json +0 -25
  112. package/schemas/integrations/likec4-mapping.schema.json +0 -32
  113. package/schemas/integrations/structurizr-mapping.schema.json +0 -33
  114. package/schemas/runtime/agent-job.schema.json +0 -63
  115. package/schemas/runtime/architecture-candidate-delta-policy.schema.json +0 -129
  116. package/schemas/runtime/architecture-candidate-delta.schema.json +0 -386
  117. package/schemas/runtime/investigation-report.schema.json +0 -119
  118. package/schemas/runtime/notification-event.schema.json +0 -18
  119. package/schemas/runtime/notification-provider.schema.json +0 -26
@@ -20,13 +20,17 @@
20
20
  },
21
21
  "kind": {
22
22
  "enum": [
23
+ "co-change-coupling",
23
24
  "cycle",
24
25
  "direction-violation",
26
+ "entrypoint-bypass",
25
27
  "evidence-gap",
28
+ "low-cohesion-god-file",
26
29
  "ownership-ambiguous",
27
30
  "residual-cycle",
28
31
  "undeclared-footprint",
29
- "unowned-paths"
32
+ "unowned-paths",
33
+ "unstable-dependency"
30
34
  ]
31
35
  },
32
36
  "affectedNodeIds": {
@@ -59,6 +63,26 @@
59
63
  }
60
64
  },
61
65
  "allOf": [
66
+ {
67
+ "if": {
68
+ "properties": {
69
+ "kind": {
70
+ "const": "co-change-coupling"
71
+ }
72
+ }
73
+ },
74
+ "then": {
75
+ "properties": {
76
+ "evidence": {
77
+ "properties": {
78
+ "kind": {
79
+ "const": "co-change-coupling"
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ },
62
86
  {
63
87
  "if": {
64
88
  "properties": {
@@ -99,6 +123,26 @@
99
123
  }
100
124
  }
101
125
  },
126
+ {
127
+ "if": {
128
+ "properties": {
129
+ "kind": {
130
+ "const": "entrypoint-bypass"
131
+ }
132
+ }
133
+ },
134
+ "then": {
135
+ "properties": {
136
+ "evidence": {
137
+ "properties": {
138
+ "kind": {
139
+ "const": "entrypoint-bypass"
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
145
+ },
102
146
  {
103
147
  "if": {
104
148
  "properties": {
@@ -119,6 +163,26 @@
119
163
  }
120
164
  }
121
165
  },
166
+ {
167
+ "if": {
168
+ "properties": {
169
+ "kind": {
170
+ "const": "low-cohesion-god-file"
171
+ }
172
+ }
173
+ },
174
+ "then": {
175
+ "properties": {
176
+ "evidence": {
177
+ "properties": {
178
+ "kind": {
179
+ "const": "low-cohesion-god-file"
180
+ }
181
+ }
182
+ }
183
+ }
184
+ }
185
+ },
122
186
  {
123
187
  "if": {
124
188
  "properties": {
@@ -179,6 +243,26 @@
179
243
  }
180
244
  }
181
245
  },
246
+ {
247
+ "if": {
248
+ "properties": {
249
+ "kind": {
250
+ "const": "unstable-dependency"
251
+ }
252
+ }
253
+ },
254
+ "then": {
255
+ "properties": {
256
+ "evidence": {
257
+ "properties": {
258
+ "kind": {
259
+ "const": "unstable-dependency"
260
+ }
261
+ }
262
+ }
263
+ }
264
+ }
265
+ },
182
266
  {
183
267
  "if": {
184
268
  "properties": {
@@ -594,6 +678,164 @@
594
678
  "type": "boolean"
595
679
  }
596
680
  }
681
+ },
682
+ {
683
+ "type": "object",
684
+ "additionalProperties": false,
685
+ "required": [
686
+ "kind",
687
+ "files",
688
+ "totalCount",
689
+ "truncated"
690
+ ],
691
+ "properties": {
692
+ "kind": {
693
+ "const": "low-cohesion-god-file"
694
+ },
695
+ "files": {
696
+ "type": "array",
697
+ "maxItems": 20,
698
+ "items": {
699
+ "$ref": "#/$defs/evidenceLowCohesionFile"
700
+ }
701
+ },
702
+ "totalCount": {
703
+ "type": "integer",
704
+ "minimum": 0
705
+ },
706
+ "truncated": {
707
+ "type": "boolean"
708
+ }
709
+ }
710
+ },
711
+ {
712
+ "type": "object",
713
+ "additionalProperties": false,
714
+ "required": [
715
+ "kind",
716
+ "declaredEntrypointPaths",
717
+ "edges",
718
+ "totalCount",
719
+ "truncated"
720
+ ],
721
+ "properties": {
722
+ "kind": {
723
+ "const": "entrypoint-bypass"
724
+ },
725
+ "declaredEntrypointPaths": {
726
+ "type": "array",
727
+ "uniqueItems": true,
728
+ "items": {
729
+ "$ref": "#/$defs/repoRelativePath"
730
+ }
731
+ },
732
+ "edges": {
733
+ "type": "array",
734
+ "maxItems": 20,
735
+ "items": {
736
+ "$ref": "#/$defs/evidenceImportEdge"
737
+ }
738
+ },
739
+ "totalCount": {
740
+ "type": "integer",
741
+ "minimum": 0
742
+ },
743
+ "truncated": {
744
+ "type": "boolean"
745
+ }
746
+ }
747
+ },
748
+ {
749
+ "type": "object",
750
+ "additionalProperties": false,
751
+ "required": [
752
+ "kind",
753
+ "sourceFanIn",
754
+ "sourceInstability",
755
+ "targets",
756
+ "totalCount",
757
+ "truncated"
758
+ ],
759
+ "properties": {
760
+ "kind": {
761
+ "const": "unstable-dependency"
762
+ },
763
+ "sourceFanIn": {
764
+ "type": "integer",
765
+ "minimum": 0
766
+ },
767
+ "sourceInstability": {
768
+ "type": "number",
769
+ "minimum": 0,
770
+ "maximum": 1
771
+ },
772
+ "targets": {
773
+ "type": "array",
774
+ "maxItems": 20,
775
+ "items": {
776
+ "$ref": "#/$defs/evidenceUnstableTarget"
777
+ }
778
+ },
779
+ "totalCount": {
780
+ "type": "integer",
781
+ "minimum": 0
782
+ },
783
+ "truncated": {
784
+ "type": "boolean"
785
+ }
786
+ }
787
+ },
788
+ {
789
+ "type": "object",
790
+ "additionalProperties": false,
791
+ "required": [
792
+ "kind",
793
+ "memberNodeIds",
794
+ "coverageStatus",
795
+ "windowLimit",
796
+ "observedCommitCount",
797
+ "pairs",
798
+ "totalCount",
799
+ "truncated"
800
+ ],
801
+ "properties": {
802
+ "kind": {
803
+ "const": "co-change-coupling"
804
+ },
805
+ "memberNodeIds": {
806
+ "$ref": "#/$defs/evidenceIdList"
807
+ },
808
+ "coverageStatus": {
809
+ "enum": [
810
+ "complete",
811
+ "shallow",
812
+ "insufficient-history",
813
+ "unavailable"
814
+ ]
815
+ },
816
+ "windowLimit": {
817
+ "type": "integer",
818
+ "minimum": 1
819
+ },
820
+ "observedCommitCount": {
821
+ "type": "integer",
822
+ "minimum": 0
823
+ },
824
+ "pairs": {
825
+ "type": "array",
826
+ "maxItems": 20,
827
+ "items": {
828
+ "$ref": "#/$defs/evidenceCoChangePair"
829
+ }
830
+ },
831
+ "totalCount": {
832
+ "type": "integer",
833
+ "minimum": 0
834
+ },
835
+ "truncated": {
836
+ "type": "boolean"
837
+ }
838
+ }
597
839
  }
598
840
  ]
599
841
  },
@@ -680,6 +922,135 @@
680
922
  }
681
923
  }
682
924
  }
925
+ },
926
+ "evidenceLowCohesionCluster": {
927
+ "type": "object",
928
+ "additionalProperties": false,
929
+ "required": [
930
+ "symbols",
931
+ "startLine",
932
+ "endLine",
933
+ "intraClusterEdges",
934
+ "crossClusterEdges"
935
+ ],
936
+ "properties": {
937
+ "symbols": {
938
+ "type": "array",
939
+ "uniqueItems": true,
940
+ "items": {
941
+ "type": "string",
942
+ "minLength": 1
943
+ }
944
+ },
945
+ "startLine": {
946
+ "type": "integer",
947
+ "minimum": 1
948
+ },
949
+ "endLine": {
950
+ "type": "integer",
951
+ "minimum": 1
952
+ },
953
+ "intraClusterEdges": {
954
+ "type": "integer",
955
+ "minimum": 0
956
+ },
957
+ "crossClusterEdges": {
958
+ "type": "integer",
959
+ "minimum": 0
960
+ }
961
+ }
962
+ },
963
+ "evidenceLowCohesionFile": {
964
+ "type": "object",
965
+ "additionalProperties": false,
966
+ "required": [
967
+ "path",
968
+ "lineCount",
969
+ "topLevelSymbolCount",
970
+ "clusterCount",
971
+ "clusters"
972
+ ],
973
+ "properties": {
974
+ "path": {
975
+ "$ref": "#/$defs/repoRelativePath"
976
+ },
977
+ "lineCount": {
978
+ "type": "integer",
979
+ "minimum": 0
980
+ },
981
+ "topLevelSymbolCount": {
982
+ "type": "integer",
983
+ "minimum": 0
984
+ },
985
+ "clusterCount": {
986
+ "type": "integer",
987
+ "minimum": 0
988
+ },
989
+ "clusters": {
990
+ "type": "array",
991
+ "items": {
992
+ "$ref": "#/$defs/evidenceLowCohesionCluster"
993
+ }
994
+ }
995
+ }
996
+ },
997
+ "evidenceUnstableTarget": {
998
+ "type": "object",
999
+ "additionalProperties": false,
1000
+ "required": [
1001
+ "targetNodeId",
1002
+ "targetInstability",
1003
+ "delta",
1004
+ "edgeCount"
1005
+ ],
1006
+ "properties": {
1007
+ "targetNodeId": {
1008
+ "type": "string",
1009
+ "minLength": 1,
1010
+ "pattern": "\\S"
1011
+ },
1012
+ "targetInstability": {
1013
+ "type": "number",
1014
+ "minimum": 0,
1015
+ "maximum": 1
1016
+ },
1017
+ "delta": {
1018
+ "type": "number",
1019
+ "minimum": -1,
1020
+ "maximum": 1
1021
+ },
1022
+ "edgeCount": {
1023
+ "type": "integer",
1024
+ "minimum": 1
1025
+ }
1026
+ }
1027
+ },
1028
+ "evidenceCoChangePair": {
1029
+ "type": "object",
1030
+ "additionalProperties": false,
1031
+ "required": [
1032
+ "pathA",
1033
+ "pathB",
1034
+ "coChangeCount",
1035
+ "jaccard"
1036
+ ],
1037
+ "properties": {
1038
+ "pathA": {
1039
+ "$ref": "#/$defs/repoRelativePath"
1040
+ },
1041
+ "pathB": {
1042
+ "$ref": "#/$defs/repoRelativePath"
1043
+ },
1044
+ "coChangeCount": {
1045
+ "type": "integer",
1046
+ "minimum": 1
1047
+ },
1048
+ "jaccard": {
1049
+ "type": "number",
1050
+ "minimum": 0,
1051
+ "maximum": 1
1052
+ }
1053
+ }
683
1054
  }
684
1055
  }
685
1056
  }
@@ -0,0 +1,65 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://archcontext.dev/schemas/runtime/sync-check.schema.json",
4
+ "title": "SyncCheckOutputV1",
5
+ "description": "Read-only projection freshness check returned by `archctx sync --check --json`.",
6
+ "additionalProperties": false,
7
+ "type": "object",
8
+ "required": [
9
+ "schemaVersion",
10
+ "check",
11
+ "fresh",
12
+ "profile",
13
+ "includeInstructions",
14
+ "modelDigest",
15
+ "pendingGeneratedPaths"
16
+ ],
17
+ "properties": {
18
+ "schemaVersion": {
19
+ "const": "archcontext.sync-check/v1"
20
+ },
21
+ "check": {
22
+ "const": true
23
+ },
24
+ "fresh": {
25
+ "type": "boolean"
26
+ },
27
+ "profile": {
28
+ "type": "string",
29
+ "enum": [
30
+ "default",
31
+ "repo-harness/v1"
32
+ ]
33
+ },
34
+ "includeInstructions": {
35
+ "type": "boolean"
36
+ },
37
+ "modelDigest": {
38
+ "pattern": "^sha256:[a-f0-9]{64}$",
39
+ "type": "string"
40
+ },
41
+ "pendingGeneratedPaths": {
42
+ "type": "array",
43
+ "items": {
44
+ "type": "string",
45
+ "minLength": 1,
46
+ "not": {
47
+ "anyOf": [
48
+ {
49
+ "pattern": "^/"
50
+ },
51
+ {
52
+ "pattern": "\\\\"
53
+ },
54
+ {
55
+ "pattern": "(^|/)\\.\\.(/|$)"
56
+ }
57
+ ]
58
+ }
59
+ }
60
+ },
61
+ "drift": {
62
+ "type": "object"
63
+ }
64
+ }
65
+ }
@@ -1,4 +1,19 @@
1
1
  import { digestJson, type ArchContextError, type Json } from "./schema";
2
+ import {
3
+ BoundedStringSchema,
4
+ Const,
5
+ GitOidSchema,
6
+ OneOf,
7
+ RawEnum,
8
+ Ref,
9
+ SchemaDocument,
10
+ Sha256DigestSchema,
11
+ StrictObject,
12
+ Type,
13
+ TypedUnsafe,
14
+ UniqueStringArray,
15
+ type Static
16
+ } from "./schema-kit";
2
17
 
3
18
  /** Measured architecture work, distinct from generated-file freshness and source byte stamps. */
4
19
  export const ARCHITECTURE_DEBT_SCHEMA_VERSION = "archcontext.architecture-debt/v1" as const;
@@ -7,56 +22,128 @@ export type ArchitectureDebtKind = typeof ARCHITECTURE_DEBT_KINDS[number];
7
22
  export const ARCHITECTURE_DEBT_CHECKS = ["ownership", "anchors", "dependencies", "flows", "state-machines", "practices"] as const;
8
23
  export type ArchitectureDebtCheck = typeof ARCHITECTURE_DEBT_CHECKS[number];
9
24
 
10
- export interface ArchitectureDebtItemV1 {
25
+ const DEBT_SCHEMA_ID = "https://archctx.repoharness.com/schemas/runtime/architecture-debt.schema.json";
26
+
27
+ const DebtCoverageSchema = RawEnum(["complete", "partial", "unknown"] as const);
28
+
29
+ const DebtDetailValueSchema = OneOf([
30
+ BoundedStringSchema,
31
+ Type.Integer(),
32
+ UniqueStringArray(BoundedStringSchema)
33
+ ]);
34
+
35
+ export const ArchitectureDebtItemSchema = StrictObject({
11
36
  /** Content identity, independent of absolute root, branch, timestamps and source byte stamps. */
12
- id: string;
13
- kind: ArchitectureDebtKind;
37
+ id: Type.String({ pattern: "^debt\\.[a-f0-9]{64}$" }),
38
+ kind: RawEnum(ARCHITECTURE_DEBT_KINDS),
14
39
  /** Canonical producer identities. Empty for a source path with no owner. */
15
- nodeIds: string[];
16
- capabilityIds: string[];
17
- paths: string[];
18
- reasonCode: string;
19
- action: string;
40
+ nodeIds: UniqueStringArray(BoundedStringSchema),
41
+ capabilityIds: UniqueStringArray(BoundedStringSchema),
42
+ paths: UniqueStringArray(BoundedStringSchema),
43
+ reasonCode: BoundedStringSchema,
44
+ action: BoundedStringSchema,
20
45
  /** Bounded metadata only; never source bodies or arbitrary provider output. */
21
- details: Record<string, string | number | string[]>;
22
- }
46
+ details: TypedUnsafe<Record<string, string | number | string[]>>({
47
+ type: "object",
48
+ maxProperties: 12,
49
+ additionalProperties: DebtDetailValueSchema
50
+ })
51
+ });
23
52
 
24
- export interface ArchitectureDebtCheckV1 {
25
- check: ArchitectureDebtCheck;
26
- coverage: "complete" | "partial" | "unknown";
27
- reasonCodes: string[];
28
- }
53
+ export const ArchitectureDebtCheckSchema = StrictObject({
54
+ check: RawEnum(ARCHITECTURE_DEBT_CHECKS),
55
+ coverage: DebtCoverageSchema,
56
+ reasonCodes: UniqueStringArray(BoundedStringSchema)
57
+ });
29
58
 
30
- export interface ArchitectureDebtReportV1 {
31
- schemaVersion: typeof ARCHITECTURE_DEBT_SCHEMA_VERSION;
32
- scope: { kind: "repository" | "changed-paths"; changedPaths: string[]; capabilityIds: string[] };
59
+ export const ArchitectureDebtReportBodySchema = StrictObject({
60
+ schemaVersion: Const(ARCHITECTURE_DEBT_SCHEMA_VERSION),
61
+ scope: StrictObject({
62
+ kind: RawEnum(["repository", "changed-paths"] as const),
63
+ changedPaths: UniqueStringArray(BoundedStringSchema),
64
+ capabilityIds: UniqueStringArray(BoundedStringSchema)
65
+ }),
33
66
  /** A partial/unknown report with no items does not prove absence of debt. */
34
- coverage: "complete" | "partial" | "unknown";
35
- coverageReasonCodes: string[];
36
- checks: ArchitectureDebtCheckV1[];
37
- items: ArchitectureDebtItemV1[];
38
- actionsRequired: string[];
67
+ coverage: DebtCoverageSchema,
68
+ coverageReasonCodes: UniqueStringArray(BoundedStringSchema),
69
+ checks: Type.Array(ArchitectureDebtCheckSchema, { minItems: 6, maxItems: 6 }),
70
+ items: Type.Array(ArchitectureDebtItemSchema),
71
+ actionsRequired: UniqueStringArray(BoundedStringSchema),
39
72
  /** Binds the entire debt report. Checkpoint's existing resultDigest binds practice guidance only. */
40
- digest: string;
41
- }
73
+ digest: Sha256DigestSchema
74
+ });
75
+
76
+ export const ArchitectureDebtReportSchema = SchemaDocument({
77
+ $id: DEBT_SCHEMA_ID,
78
+ title: "ArchitectureDebtReportV1",
79
+ schema: ArchitectureDebtReportBodySchema
80
+ });
81
+
82
+ export type ArchitectureDebtItemV1 = Static<typeof ArchitectureDebtItemSchema>;
83
+ export type ArchitectureDebtCheckV1 = Static<typeof ArchitectureDebtCheckSchema>;
84
+ export type ArchitectureDebtReportV1 = Static<typeof ArchitectureDebtReportSchema>;
42
85
 
43
86
  export const ARCHITECTURE_DEBT_DELTA_SCHEMA_VERSION = "archcontext.architecture-debt-delta/v1" as const;
44
87
 
45
- export interface ArchitectureDebtDeltaReportV1 {
46
- schemaVersion: typeof ARCHITECTURE_DEBT_DELTA_SCHEMA_VERSION;
88
+ export const ArchitectureDebtDeltaReportBodySchema = StrictObject({
89
+ schemaVersion: Const(ARCHITECTURE_DEBT_DELTA_SCHEMA_VERSION),
47
90
  /** The current working tree, anchored to its checked-out commit. */
48
- head: { sha: string; debt: ArchitectureDebtReportV1 };
49
- base: {
50
- ref: string;
51
- sha: string;
52
- debtDigest: string;
53
- coverage: ArchitectureDebtReportV1["coverage"];
54
- coverageReasonCodes: string[];
55
- };
91
+ head: StrictObject({
92
+ sha: Ref<string>("#/$defs/commitSha"),
93
+ debt: Ref<ArchitectureDebtReportV1>("architecture-debt.schema.json")
94
+ }),
95
+ base: StrictObject({
96
+ ref: Type.String({ minLength: 1 }),
97
+ sha: Ref<string>("#/$defs/commitSha"),
98
+ debtDigest: Ref<string>("architecture-debt.schema.json#/properties/digest"),
99
+ coverage: Ref<ArchitectureDebtReportV1["coverage"]>("architecture-debt.schema.json#/properties/coverage"),
100
+ coverageReasonCodes: Ref<string[]>("architecture-debt.schema.json#/properties/coverageReasonCodes")
101
+ }),
56
102
  /** Ordered by item ID. An absence requires complete coverage from the opposing check. */
57
- introduced: ArchitectureDebtItemV1[];
58
- resolvedIds: string[];
59
- }
103
+ introduced: Type.Array(Ref<ArchitectureDebtItemV1>("architecture-debt.schema.json#/properties/items/items"), {
104
+ description: "Items ordered by item ID.",
105
+ uniqueItems: true
106
+ }),
107
+ resolvedIds: Type.Array(Ref<string>("architecture-debt.schema.json#/properties/items/items/properties/id"), {
108
+ description: "Resolved item IDs in ascending order.",
109
+ uniqueItems: true
110
+ })
111
+ });
112
+
113
+ export const ArchitectureDebtDeltaReportSchema = SchemaDocument({
114
+ $id: "https://archctx.repoharness.com/schemas/runtime/architecture-debt-delta.schema.json",
115
+ title: "ArchitectureDebtDeltaReportV1",
116
+ schema: ArchitectureDebtDeltaReportBodySchema,
117
+ $defs: {
118
+ commitSha: GitOidSchema
119
+ }
120
+ });
121
+
122
+ export type ArchitectureDebtDeltaReportV1 = Static<typeof ArchitectureDebtDeltaReportSchema>;
123
+
124
+ export const ArchitectureDebtHookLogSchema = StrictObject({
125
+ schemaVersion: Const("archcontext.hook-log/v1"),
126
+ event: Type.String({ minLength: 1 }),
127
+ elapsedMs: Type.Number({ minimum: 0 }),
128
+ pathCount: Type.Integer({ minimum: 0 }),
129
+ changedPathDigest: Type.String({ pattern: "^sha256:[0-9a-f]{64}$" }),
130
+ reasonCode: Type.String({ minLength: 1 }),
131
+ failOpen: Const(false),
132
+ egress: Const("none"),
133
+ network: Const("forbidden")
134
+ });
135
+
136
+ export const ArchitectureDebtHookCheckpointBodySchema = StrictObject({
137
+ schemaVersion: Const("archcontext.hook-debt-checkpoint/v1"),
138
+ debt: Ref<typeof ArchitectureDebtReportSchema>("architecture-debt.schema.json"),
139
+ hookLog: ArchitectureDebtHookLogSchema
140
+ });
141
+
142
+ export const ArchitectureDebtHookCheckpointSchema = SchemaDocument({
143
+ $id: "https://archctx.repoharness.com/schemas/runtime/hook-debt-checkpoint.schema.json",
144
+ title: "ArchitectureDebtHookCheckpointV1",
145
+ schema: ArchitectureDebtHookCheckpointBodySchema
146
+ });
60
147
 
61
148
  export interface ArchitectureDebtHookLogV1 {
62
149
  schemaVersion: "archcontext.hook-log/v1";