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
package/src/index.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  export * from "./architecture";
2
2
  export * from "./architecture-history";
3
3
  export * from "./architecture-debt";
4
+ export * from "./cli-read";
4
5
  export * from "./docs-anchors";
5
6
  export * from "./external-docs";
7
+ export * from "./index-seed";
6
8
  export * from "./review-guards";
7
9
  export * from "./ledger";
8
10
  export * from "./native-context";
9
11
  export * from "./ref-impact";
12
+ export * from "./refactor-v2";
10
13
  export * from "./runtime-verify";
11
14
  export * from "./changeset-receipt";
12
15
  export * from "./ownership-dependencies";
@@ -20,6 +23,8 @@ export * from "./product-version";
20
23
  export * from "./refactor";
21
24
  export * from "./runtime-topology";
22
25
  export * from "./schema";
26
+ export * from "./schema-kit";
27
+ export * from "./schema-registry";
23
28
  export * from "./state-machine";
24
29
  export * from "./failure";
25
30
  export * from "./validator";
@@ -0,0 +1,262 @@
1
+ import type { Json } from "./schema";
2
+
3
+ export const ARCHITECTURE_EVENT_SCHEMA_VERSION = "archcontext.architecture-event/v1" as const;
4
+ export const ARCHITECTURE_SNAPSHOT_SCHEMA_VERSION = "archcontext.architecture-snapshot/v2" as const;
5
+ export const EVIDENCE_ITEM_SCHEMA_VERSION = "archcontext.evidence-item/v2" as const;
6
+ export const EVIDENCE_BINDING_SCHEMA_VERSION = "archcontext.evidence-binding/v1" as const;
7
+ export const RECOMMENDATION_RUN_SCHEMA_VERSION = "archcontext.recommendation-run/v1" as const;
8
+ export const RECOMMENDATION_SCHEMA_VERSION = "archcontext.recommendation/v2" as const;
9
+ export const RECOMMENDATION_V3_SCHEMA_VERSION = "archcontext.recommendation/v3" as const;
10
+ export const RECOMMENDATION_FEEDBACK_SCHEMA_VERSION = "archcontext.recommendation-feedback/v1" as const;
11
+ export const AGENT_JOB_SCHEMA_VERSION = "archcontext.agent-job/v1" as const;
12
+ export const ARCHITECTURE_SUBJECT_SELECTOR_SCHEMA_VERSION = "archcontext.architecture-subject-selector/v1" as const;
13
+ export const PROJECTION_TARGET_SCHEMA_VERSION = "archcontext.projection-target/v1" as const;
14
+
15
+ export const RECOMMENDATION_CATEGORIES = ["practice", "refactor_proposal", "structural_observation"] as const;
16
+
17
+ export type ArchitectureFactAuthority = "declared" | "observed" | "verified" | "proposed" | "projected";
18
+ export type ArchitectureLedgerMode = "yaml" | "dual" | "dual-compare" | "ledger-shadow" | "ledger" | "ledger-authoritative";
19
+ export type ArchitectureActorKind = "developer" | "daemon" | "hook" | "cli" | "mcp" | "subagent" | "migration" | "system";
20
+ export type ArchitectureActorSource = "cli" | "mcp" | "manual" | "daemon" | "system" | "subagent";
21
+ export type RecommendationCategory = (typeof RECOMMENDATION_CATEGORIES)[number];
22
+ export const RECOMMENDATION_STATUSES = [
23
+ "open",
24
+ "acknowledged",
25
+ "accepted",
26
+ "rejected",
27
+ "deferred",
28
+ "waived",
29
+ "resolved",
30
+ "superseded",
31
+ "expired"
32
+ ] as const;
33
+ export type RecommendationStatus = (typeof RECOMMENDATION_STATUSES)[number];
34
+ export type ArchitectureEventSource =
35
+ | "prepare_task"
36
+ | "checkpoint"
37
+ | "plan_update"
38
+ | "apply_update"
39
+ | "complete_task"
40
+ | "git_hook"
41
+ | "yaml_import"
42
+ | "projection_reconcile"
43
+ | "migration"
44
+ | "manual"
45
+ | "agent_audit"
46
+ | "refactor_scan";
47
+
48
+ export type EvidenceStrengthV2 = "heuristic" | "declared" | "observed" | "verified";
49
+ export type EvidencePolarityV2 = "positive" | "absence" | "declaration";
50
+ export type EvidenceOriginV2 = "codegraph" | "model-store-yaml" | "checkpoint" | "runtime-daemon" | "user" | "subagent" | "external-doc";
51
+ export type EvidenceCoverageLevelV2 = "complete" | "partial" | "unknown";
52
+ export type EvidenceAuthorityEffect = "context-only" | "ranking" | "checkpoint-eligible" | "complete-eligible";
53
+ export type ArchitectureSubjectSelectorKind =
54
+ | "repository"
55
+ | "path"
56
+ | "symbol"
57
+ | "node"
58
+ | "relation"
59
+ | "api"
60
+ | "datastore"
61
+ | "external-contract";
62
+ export type ProjectionTargetType =
63
+ | "architecture-index"
64
+ | "entity-summary"
65
+ | "relation-summary"
66
+ | "decision-index"
67
+ | "diagram-mermaid"
68
+ | "diagram-structurizr"
69
+ | "diagram-likec4"
70
+ | "diagram-runtime-topology"
71
+ | "runtime-topology-summary"
72
+ | "architecture-history"
73
+ | "agent-context";
74
+ export type ProjectionTargetScopeKind = "repository" | "entity" | "relation" | "decision" | "diagram";
75
+ export type ProjectionTargetOwnership = "generated" | "mixed";
76
+ export type ProjectionTargetFormat = "markdown" | "mermaid" | "structurizr-json" | "likec4";
77
+
78
+ export interface ArchitectureRepositoryIdentityV1 {
79
+ repositoryId: string;
80
+ storageRepositoryId: string;
81
+ }
82
+
83
+ export interface ArchitectureWorktreeIdentityV1 {
84
+ workspaceId: string;
85
+ storageWorkspaceId: string;
86
+ branch: string;
87
+ headSha: string;
88
+ worktreeDigest: string;
89
+ }
90
+
91
+ export interface LedgerProvenanceV1 {
92
+ producer: string;
93
+ command: string;
94
+ inputDigest: string;
95
+ traceDigest?: string;
96
+ }
97
+
98
+ export interface RecommendationAuthorV1 {
99
+ kind: ArchitectureActorKind;
100
+ id: string;
101
+ source: ArchitectureActorSource;
102
+ }
103
+
104
+ export interface EvidenceItemV2 {
105
+ schemaVersion: typeof EVIDENCE_ITEM_SCHEMA_VERSION;
106
+ evidenceId: string;
107
+ kind: string;
108
+ strength: EvidenceStrengthV2;
109
+ polarity: EvidencePolarityV2;
110
+ origin: EvidenceOriginV2;
111
+ subject: string;
112
+ selector: {
113
+ kind: "repository" | "path" | "symbol" | "relation" | "constraint" | "practice" | "event" | "snapshot";
114
+ id: string;
115
+ path?: string;
116
+ symbolId?: string;
117
+ startLine?: number;
118
+ endLine?: number;
119
+ };
120
+ summary: string;
121
+ coverage: {
122
+ level: EvidenceCoverageLevelV2;
123
+ scope: string;
124
+ };
125
+ supports: ("recommendation" | "checkpoint" | "complete")[];
126
+ provenance: LedgerProvenanceV1;
127
+ createdAt: string;
128
+ digest: string;
129
+ extensions?: Record<string, Json>;
130
+ }
131
+
132
+ export interface EvidenceBindingV1 {
133
+ schemaVersion: typeof EVIDENCE_BINDING_SCHEMA_VERSION;
134
+ bindingId: string;
135
+ evidenceId: string;
136
+ target: {
137
+ kind: "entity" | "relation" | "constraint" | "recommendation" | "practice" | "event" | "snapshot" | "subject";
138
+ id: string;
139
+ };
140
+ bindingReason: "direct-selector" | "predicate-subject" | "change-cursor" | "human-attestation" | "deterministic-check" | "subagent-proposal";
141
+ authorityEffect: EvidenceAuthorityEffect;
142
+ createdAt: string;
143
+ provenance: LedgerProvenanceV1;
144
+ extensions?: Record<string, Json>;
145
+ }
146
+
147
+ export type EvidenceLifecycleTargetV1 = "item" | "binding";
148
+ export type EvidenceLifecycleActionV1 = "create" | "update" | "remove";
149
+
150
+ export type EvidenceLifecycleOperationV1 =
151
+ | {
152
+ target: "item";
153
+ action: "create";
154
+ evidenceId: string;
155
+ value: EvidenceItemV2;
156
+ }
157
+ | {
158
+ target: "item";
159
+ action: "update";
160
+ evidenceId: string;
161
+ previousDigest: string;
162
+ value: EvidenceItemV2;
163
+ }
164
+ | {
165
+ target: "item";
166
+ action: "remove";
167
+ evidenceId: string;
168
+ previousDigest: string;
169
+ reasonCode: string;
170
+ }
171
+ | {
172
+ target: "binding";
173
+ action: "create";
174
+ bindingId: string;
175
+ value: EvidenceBindingV1;
176
+ }
177
+ | {
178
+ target: "binding";
179
+ action: "update";
180
+ bindingId: string;
181
+ previousDigest: string;
182
+ value: EvidenceBindingV1;
183
+ }
184
+ | {
185
+ target: "binding";
186
+ action: "remove";
187
+ bindingId: string;
188
+ previousDigest: string;
189
+ reasonCode: string;
190
+ };
191
+
192
+ export interface EvidenceLifecycleTombstoneV1 {
193
+ target: EvidenceLifecycleTargetV1;
194
+ id: string;
195
+ previousDigest: string;
196
+ reasonCode: string;
197
+ removedByEventId: string;
198
+ }
199
+
200
+ export interface EvidenceStateAtCursorV1 {
201
+ schemaVersion: "archcontext.evidence-state-at-cursor/v1";
202
+ evidenceItems: EvidenceItemV2[];
203
+ evidenceBindings: EvidenceBindingV1[];
204
+ tombstones: EvidenceLifecycleTombstoneV1[];
205
+ stateDigest: string;
206
+ }
207
+
208
+ export interface ArchitectureSubjectSelectorV1 {
209
+ schemaVersion: typeof ARCHITECTURE_SUBJECT_SELECTOR_SCHEMA_VERSION;
210
+ selectorId: string;
211
+ kind: ArchitectureSubjectSelectorKind;
212
+ repositoryId: string;
213
+ stableKey: string;
214
+ path?: string;
215
+ symbolId?: string;
216
+ name?: string;
217
+ relation?: {
218
+ source: string;
219
+ target: string;
220
+ kind: string;
221
+ };
222
+ externalId?: string;
223
+ digest: string;
224
+ extensions?: Record<string, Json>;
225
+ }
226
+
227
+ export interface ProjectionTargetGeneratedRegionV1 {
228
+ startMarker: string;
229
+ endMarker: string;
230
+ }
231
+
232
+ export interface ProjectionTargetScopeV1 {
233
+ kind: ProjectionTargetScopeKind;
234
+ id?: string;
235
+ entityKind?: string;
236
+ }
237
+
238
+ interface ProjectionTargetBaseV1 {
239
+ schemaVersion: typeof PROJECTION_TARGET_SCHEMA_VERSION;
240
+ targetId: string;
241
+ type: ProjectionTargetType;
242
+ scope: ProjectionTargetScopeV1;
243
+ path: string;
244
+ rendererVersion: string;
245
+ format: ProjectionTargetFormat;
246
+ sourceDigest: string;
247
+ outputDigest: string;
248
+ extensions?: Record<string, Json>;
249
+ }
250
+
251
+ /**
252
+ * A `mixed` target owns one marked region inside a human-owned document, so it carries the region
253
+ * markers. A `generated` target owns its whole file and carries no marker: the projection manifest
254
+ * row's `outputDigest` is what proves the file is projection output.
255
+ */
256
+ export type ProjectionTargetV1 = ProjectionTargetBaseV1 & (
257
+ | { ownership: Extract<ProjectionTargetOwnership, "mixed">; generatedRegion: ProjectionTargetGeneratedRegionV1 }
258
+ | { ownership: Extract<ProjectionTargetOwnership, "generated">; generatedRegion?: never }
259
+ );
260
+
261
+ /** A target that owns one marked region inside a document. */
262
+ export type ProjectionMixedTargetV1 = Extract<ProjectionTargetV1, { ownership: "mixed" }>;