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
package/src/ledger.ts CHANGED
@@ -1,181 +1,31 @@
1
- import type { ArchitectureMajorChangeReasonCode } from "./projection";
2
- import type {
3
- ArchitectureTargetDeltaV1,
4
- RefactorKillListEntryV1,
5
- RefactorObservationEvidenceV1,
6
- RefactorObservationKind,
7
- RefactorScale,
8
- RefactorTargetOutcomeV1
9
- } from "./refactor";
1
+ import type { ArchitectureMajorChangeReasonCode } from "./projection-constants";
2
+ import type { RefactorObservationKind, RefactorScale } from "./refactor-constants";
3
+ import type { ArchitectureTargetDeltaV1, RefactorKillListEntryV1, RefactorTargetOutcomeV1 } from "./refactor-types";
4
+ import type { RefactorObservationEvidenceV1 } from "./refactor-evidence-types";
10
5
  import { digestJson, type Json } from "./schema";
11
-
12
- export const ARCHITECTURE_EVENT_SCHEMA_VERSION = "archcontext.architecture-event/v1" as const;
13
- export const ARCHITECTURE_SNAPSHOT_SCHEMA_VERSION = "archcontext.architecture-snapshot/v2" as const;
14
- export const EVIDENCE_ITEM_SCHEMA_VERSION = "archcontext.evidence-item/v2" as const;
15
- export const EVIDENCE_BINDING_SCHEMA_VERSION = "archcontext.evidence-binding/v1" as const;
16
- export const RECOMMENDATION_RUN_SCHEMA_VERSION = "archcontext.recommendation-run/v1" as const;
17
- export const RECOMMENDATION_SCHEMA_VERSION = "archcontext.recommendation/v2" as const;
18
- export const RECOMMENDATION_V3_SCHEMA_VERSION = "archcontext.recommendation/v3" as const;
19
- export const RECOMMENDATION_FEEDBACK_SCHEMA_VERSION = "archcontext.recommendation-feedback/v1" as const;
20
- export const AGENT_JOB_SCHEMA_VERSION = "archcontext.agent-job/v1" as const;
21
- export const INVESTIGATION_REPORT_SCHEMA_VERSION = "archcontext.investigation-report/v1" as const;
22
- export const ARCHITECTURE_SUBJECT_SELECTOR_SCHEMA_VERSION = "archcontext.architecture-subject-selector/v1" as const;
23
- export const ARCHITECTURE_CANDIDATE_DELTA_SCHEMA_VERSION = "archcontext.architecture-candidate-delta/v1" as const;
24
- export const ARCHITECTURE_CANDIDATE_DELTA_POLICY_SCHEMA_VERSION = "archcontext.architecture-candidate-delta-policy/v1" as const;
25
- export const PROJECTION_TARGET_SCHEMA_VERSION = "archcontext.projection-target/v1" as const;
26
-
27
- export const RECOMMENDATION_CATEGORIES = ["practice", "refactor_proposal", "structural_observation"] as const;
28
-
29
- export type ArchitectureFactAuthority = "declared" | "observed" | "verified" | "proposed" | "projected";
30
- export type ArchitectureLedgerMode = "yaml" | "dual" | "dual-compare" | "ledger-shadow" | "ledger" | "ledger-authoritative";
31
- export type ArchitectureActorKind = "developer" | "daemon" | "hook" | "cli" | "mcp" | "subagent" | "migration" | "system";
32
- export type ArchitectureActorSource = "cli" | "mcp" | "manual" | "daemon" | "system" | "subagent";
33
- export type RecommendationCategory = (typeof RECOMMENDATION_CATEGORIES)[number];
34
- export const RECOMMENDATION_STATUSES = [
35
- "open",
36
- "acknowledged",
37
- "accepted",
38
- "rejected",
39
- "deferred",
40
- "waived",
41
- "resolved",
42
- "superseded",
43
- "expired"
44
- ] as const;
45
- export type RecommendationStatus = (typeof RECOMMENDATION_STATUSES)[number];
46
- export type ArchitectureEventSource =
47
- | "prepare_task"
48
- | "checkpoint"
49
- | "plan_update"
50
- | "apply_update"
51
- | "complete_task"
52
- | "git_hook"
53
- | "yaml_import"
54
- | "projection_reconcile"
55
- | "migration"
56
- | "manual"
57
- | "agent_audit"
58
- | "refactor_scan";
59
-
60
- export type EvidenceStrengthV2 = "heuristic" | "declared" | "observed" | "verified";
61
- export type EvidencePolarityV2 = "positive" | "absence" | "declaration";
62
- export type EvidenceOriginV2 = "codegraph" | "model-store-yaml" | "checkpoint" | "runtime-daemon" | "user" | "subagent" | "external-doc";
63
- export type EvidenceCoverageLevelV2 = "complete" | "partial" | "unknown";
64
- export type EvidenceAuthorityEffect = "context-only" | "ranking" | "checkpoint-eligible" | "complete-eligible";
65
- export type ArchitectureSubjectSelectorKind =
66
- | "repository"
67
- | "path"
68
- | "symbol"
69
- | "node"
70
- | "relation"
71
- | "api"
72
- | "datastore"
73
- | "external-contract";
74
- export type ArchitectureCodeChangeKind = "added" | "removed" | "moved" | "renamed" | "materially_changed";
75
- export type ArchitectureDeltaRawFactKind = "git-path-change" | "codegraph-symbol" | "codegraph-relation";
76
- export type ArchitectureDeltaInterpretationKind =
77
- | "code-subject-added"
78
- | "code-subject-removed"
79
- | "code-subject-moved"
80
- | "code-subject-renamed"
81
- | "code-subject-materially-changed";
82
- export type ArchitectureDeclaredTargetKind = "entity" | "relation" | "constraint";
83
- export type ArchitectureCandidateChangeTargetKind = "node" | "relation" | "constraint" | "owner" | "lifecycle" | "migration-state";
84
- export type ArchitectureCandidateStateDimension = "target-state" | "migration-state";
85
- export type ArchitectureDeltaMappingMatchReason =
86
- | "declared-path-exact"
87
- | "declared-path-prefix"
88
- | "declared-name-match"
89
- | "declared-relation-endpoints"
90
- | "declared-constraint-subject";
91
- export type ArchitectureDeltaMappingAmbiguityReason =
92
- | "declared-graph-unavailable"
93
- | "no-declared-target"
94
- | "multiple-declared-targets"
95
- | "relation-endpoint-unmapped";
96
- export type ArchitectureCandidateChangeKind =
97
- | "node-added"
98
- | "node-removed"
99
- | "node-moved"
100
- | "node-renamed"
101
- | "node-materially-changed"
102
- | "relation-added"
103
- | "relation-removed"
104
- | "relation-moved"
105
- | "relation-renamed"
106
- | "relation-materially-changed"
107
- | "constraint-added"
108
- | "constraint-removed"
109
- | "constraint-moved"
110
- | "constraint-renamed"
111
- | "constraint-materially-changed"
112
- | "owner-added"
113
- | "owner-removed"
114
- | "owner-moved"
115
- | "owner-renamed"
116
- | "owner-materially-changed"
117
- | "lifecycle-added"
118
- | "lifecycle-removed"
119
- | "lifecycle-moved"
120
- | "lifecycle-renamed"
121
- | "lifecycle-materially-changed"
122
- | "migration-state-added"
123
- | "migration-state-removed"
124
- | "migration-state-moved"
125
- | "migration-state-renamed"
126
- | "migration-state-materially-changed";
127
- export type ArchitectureCandidateDeltaPolicyAction =
128
- | "auto-accept"
129
- | "require-checkpoint"
130
- | "require-proof"
131
- | "require-human-approval";
132
- export type ArchitectureCandidateDeltaPolicyReasonCode =
133
- | "high-confidence-complete-evidence"
134
- | "medium-confidence"
135
- | "low-confidence"
136
- | "partial-evidence"
137
- | "missing-evidence"
138
- | "mapping-ambiguity"
139
- | "migration-state-progress"
140
- | "target-state-removal"
141
- | "relation-removal"
142
- | "constraint-relaxation"
143
- | "owner-authority-change";
144
- export type ProjectionTargetType =
145
- | "architecture-index"
146
- | "entity-summary"
147
- | "relation-summary"
148
- | "decision-index"
149
- | "diagram-mermaid"
150
- | "diagram-structurizr"
151
- | "diagram-likec4"
152
- | "diagram-runtime-topology"
153
- | "runtime-topology-summary"
154
- | "architecture-history"
155
- | "agent-context";
156
- export type ProjectionTargetScopeKind = "repository" | "entity" | "relation" | "decision" | "diagram";
157
- export type ProjectionTargetOwnership = "generated" | "mixed";
158
- export type ProjectionTargetFormat = "markdown" | "mermaid" | "structurizr-json" | "likec4";
159
-
160
- export interface ArchitectureRepositoryIdentityV1 {
161
- repositoryId: string;
162
- storageRepositoryId: string;
163
- }
164
-
165
- export interface ArchitectureWorktreeIdentityV1 {
166
- workspaceId: string;
167
- storageWorkspaceId: string;
168
- branch: string;
169
- headSha: string;
170
- worktreeDigest: string;
171
- }
172
-
173
- export interface LedgerProvenanceV1 {
174
- producer: string;
175
- command: string;
176
- inputDigest: string;
177
- traceDigest?: string;
178
- }
6
+ import {
7
+ AGENT_JOB_SCHEMA_VERSION,
8
+ ARCHITECTURE_EVENT_SCHEMA_VERSION,
9
+ ARCHITECTURE_SNAPSHOT_SCHEMA_VERSION,
10
+ RECOMMENDATION_FEEDBACK_SCHEMA_VERSION,
11
+ RECOMMENDATION_RUN_SCHEMA_VERSION,
12
+ RECOMMENDATION_SCHEMA_VERSION,
13
+ RECOMMENDATION_V3_SCHEMA_VERSION,
14
+ type ArchitectureActorKind,
15
+ type ArchitectureActorSource,
16
+ type ArchitectureEventSource,
17
+ type ArchitectureFactAuthority,
18
+ type ArchitectureLedgerMode,
19
+ type ArchitectureRepositoryIdentityV1,
20
+ type ArchitectureSubjectSelectorV1,
21
+ type ArchitectureWorktreeIdentityV1,
22
+ type EvidenceStateAtCursorV1,
23
+ type LedgerProvenanceV1,
24
+ type RecommendationAuthorV1,
25
+ type RecommendationStatus
26
+ } from "./ledger-records";
27
+
28
+ export * from "./ledger-records";
179
29
 
180
30
  export interface ArchitectureEventV1 {
181
31
  schemaVersion: typeof ARCHITECTURE_EVENT_SCHEMA_VERSION;
@@ -234,110 +84,6 @@ export interface ArchitectureSnapshotV2 {
234
84
  extensions?: Record<string, Json>;
235
85
  }
236
86
 
237
- export interface EvidenceItemV2 {
238
- schemaVersion: typeof EVIDENCE_ITEM_SCHEMA_VERSION;
239
- evidenceId: string;
240
- kind: string;
241
- strength: EvidenceStrengthV2;
242
- polarity: EvidencePolarityV2;
243
- origin: EvidenceOriginV2;
244
- subject: string;
245
- selector: {
246
- kind: "repository" | "path" | "symbol" | "relation" | "constraint" | "practice" | "event" | "snapshot";
247
- id: string;
248
- path?: string;
249
- symbolId?: string;
250
- startLine?: number;
251
- endLine?: number;
252
- };
253
- summary: string;
254
- coverage: {
255
- level: EvidenceCoverageLevelV2;
256
- scope: string;
257
- };
258
- supports: ("recommendation" | "checkpoint" | "complete")[];
259
- provenance: LedgerProvenanceV1;
260
- createdAt: string;
261
- digest: string;
262
- extensions?: Record<string, Json>;
263
- }
264
-
265
- export interface EvidenceBindingV1 {
266
- schemaVersion: typeof EVIDENCE_BINDING_SCHEMA_VERSION;
267
- bindingId: string;
268
- evidenceId: string;
269
- target: {
270
- kind: "entity" | "relation" | "constraint" | "recommendation" | "practice" | "event" | "snapshot" | "subject" | "candidate-delta";
271
- id: string;
272
- };
273
- bindingReason: "direct-selector" | "predicate-subject" | "change-cursor" | "human-attestation" | "deterministic-check" | "subagent-proposal";
274
- authorityEffect: EvidenceAuthorityEffect;
275
- createdAt: string;
276
- provenance: LedgerProvenanceV1;
277
- extensions?: Record<string, Json>;
278
- }
279
-
280
- export type EvidenceLifecycleTargetV1 = "item" | "binding";
281
- export type EvidenceLifecycleActionV1 = "create" | "update" | "remove";
282
-
283
- export type EvidenceLifecycleOperationV1 =
284
- | {
285
- target: "item";
286
- action: "create";
287
- evidenceId: string;
288
- value: EvidenceItemV2;
289
- }
290
- | {
291
- target: "item";
292
- action: "update";
293
- evidenceId: string;
294
- previousDigest: string;
295
- value: EvidenceItemV2;
296
- }
297
- | {
298
- target: "item";
299
- action: "remove";
300
- evidenceId: string;
301
- previousDigest: string;
302
- reasonCode: string;
303
- }
304
- | {
305
- target: "binding";
306
- action: "create";
307
- bindingId: string;
308
- value: EvidenceBindingV1;
309
- }
310
- | {
311
- target: "binding";
312
- action: "update";
313
- bindingId: string;
314
- previousDigest: string;
315
- value: EvidenceBindingV1;
316
- }
317
- | {
318
- target: "binding";
319
- action: "remove";
320
- bindingId: string;
321
- previousDigest: string;
322
- reasonCode: string;
323
- };
324
-
325
- export interface EvidenceLifecycleTombstoneV1 {
326
- target: EvidenceLifecycleTargetV1;
327
- id: string;
328
- previousDigest: string;
329
- reasonCode: string;
330
- removedByEventId: string;
331
- }
332
-
333
- export interface EvidenceStateAtCursorV1 {
334
- schemaVersion: "archcontext.evidence-state-at-cursor/v1";
335
- evidenceItems: EvidenceItemV2[];
336
- evidenceBindings: EvidenceBindingV1[];
337
- tombstones: EvidenceLifecycleTombstoneV1[];
338
- stateDigest: string;
339
- }
340
-
341
87
  export type ArchitectureAffectedSubjectAuthorityClassV1 = "architecture-fact" | "evidence";
342
88
  export type ArchitectureAffectedSubjectKindV1 =
343
89
  | "entity"
@@ -391,243 +137,6 @@ export interface ArchitectureEventBacklinkV1 {
391
137
  rationale?: string;
392
138
  }
393
139
 
394
- export interface ArchitectureSubjectSelectorV1 {
395
- schemaVersion: typeof ARCHITECTURE_SUBJECT_SELECTOR_SCHEMA_VERSION;
396
- selectorId: string;
397
- kind: ArchitectureSubjectSelectorKind;
398
- repositoryId: string;
399
- stableKey: string;
400
- path?: string;
401
- symbolId?: string;
402
- name?: string;
403
- relation?: {
404
- source: string;
405
- target: string;
406
- kind: string;
407
- };
408
- externalId?: string;
409
- digest: string;
410
- extensions?: Record<string, Json>;
411
- }
412
-
413
- export interface ArchitectureDeltaRawFactV1 {
414
- factId: string;
415
- kind: ArchitectureDeltaRawFactKind;
416
- subjectSelectorId: string;
417
- source: "git" | "codegraph";
418
- summary: string;
419
- evidenceIds: string[];
420
- digest: string;
421
- extensions?: Record<string, Json>;
422
- }
423
-
424
- export interface ArchitectureDeltaChangedSubjectV1 {
425
- subjectSelectorId: string;
426
- changeKind: ArchitectureCodeChangeKind;
427
- previousSelectorId?: string;
428
- rawFactIds: string[];
429
- evidenceIds: string[];
430
- digest: string;
431
- }
432
-
433
- export interface ArchitectureDeltaInterpretationV1 {
434
- interpretationId: string;
435
- kind: ArchitectureDeltaInterpretationKind;
436
- subjectSelectorId: string;
437
- evidenceIds: string[];
438
- confidence: "low" | "medium" | "high";
439
- coverage: EvidenceCoverageLevelV2;
440
- heuristic: true;
441
- summary: string;
442
- digest: string;
443
- extensions?: Record<string, Json>;
444
- }
445
-
446
- export interface ArchitectureDeltaDeclaredSubjectMappingV1 {
447
- mappingId: string;
448
- subjectSelectorId: string;
449
- target: {
450
- kind: ArchitectureDeclaredTargetKind;
451
- id: string;
452
- };
453
- matchReason: ArchitectureDeltaMappingMatchReason;
454
- confidence: "low" | "medium" | "high";
455
- evidenceIds: string[];
456
- digest: string;
457
- extensions?: Record<string, Json>;
458
- }
459
-
460
- export interface ArchitectureDeltaMappingCandidateV1 {
461
- target: {
462
- kind: ArchitectureDeclaredTargetKind;
463
- id: string;
464
- };
465
- matchReason: ArchitectureDeltaMappingMatchReason;
466
- confidence: "low" | "medium" | "high";
467
- }
468
-
469
- export interface ArchitectureDeltaMappingAmbiguityV1 {
470
- ambiguityId: string;
471
- subjectSelectorId: string;
472
- reasonCode: ArchitectureDeltaMappingAmbiguityReason;
473
- candidateTargets: ArchitectureDeltaMappingCandidateV1[];
474
- evidenceIds: string[];
475
- summary: string;
476
- digest: string;
477
- extensions?: Record<string, Json>;
478
- }
479
-
480
- export interface ArchitectureCandidateChangeV1 {
481
- candidateChangeId: string;
482
- kind: ArchitectureCandidateChangeKind;
483
- target: {
484
- kind: ArchitectureCandidateChangeTargetKind;
485
- id: string;
486
- parentId?: string;
487
- };
488
- stateDimension: ArchitectureCandidateStateDimension;
489
- changeKind: ArchitectureCodeChangeKind;
490
- subjectSelectorIds: string[];
491
- mappingIds: string[];
492
- ambiguityIds: string[];
493
- evidenceIds: string[];
494
- confidence: "low" | "medium" | "high";
495
- heuristic: true;
496
- summary: string;
497
- digest: string;
498
- extensions?: Record<string, Json>;
499
- }
500
-
501
- export interface ArchitectureCandidateDeltaV1 {
502
- schemaVersion: typeof ARCHITECTURE_CANDIDATE_DELTA_SCHEMA_VERSION;
503
- deltaId: string;
504
- repository: ArchitectureRepositoryIdentityV1;
505
- worktree: ArchitectureWorktreeIdentityV1;
506
- changeCursor: {
507
- source: "git";
508
- changeSource: "commit" | "staged" | "worktree";
509
- baseSha?: string;
510
- headSha: string;
511
- pathCount: number;
512
- metadataDigest: string;
513
- codeFactsDigest: string;
514
- };
515
- subjectSelectors: ArchitectureSubjectSelectorV1[];
516
- changedSubjects: ArchitectureDeltaChangedSubjectV1[];
517
- rawFacts: ArchitectureDeltaRawFactV1[];
518
- interpretations: ArchitectureDeltaInterpretationV1[];
519
- declaredSubjectMappings: ArchitectureDeltaDeclaredSubjectMappingV1[];
520
- mappingAmbiguities: ArchitectureDeltaMappingAmbiguityV1[];
521
- candidateChanges: ArchitectureCandidateChangeV1[];
522
- evidenceItems: EvidenceItemV2[];
523
- evidenceBindings: EvidenceBindingV1[];
524
- summary: {
525
- added: number;
526
- removed: number;
527
- moved: number;
528
- renamed: number;
529
- materiallyChanged: number;
530
- unresolved: number;
531
- mapped: number;
532
- ambiguous: number;
533
- candidateChanges: number;
534
- targetStateChanges: number;
535
- migrationStateProgress: number;
536
- mappingCoverage: {
537
- totalChangedSubjects: number;
538
- mappedSubjects: number;
539
- unresolvedSubjects: number;
540
- ambiguousSubjects: number;
541
- coveragePercent: number;
542
- };
543
- unresolvedSubjects: {
544
- total: number;
545
- byReason: Record<ArchitectureDeltaMappingAmbiguityReason, number>;
546
- subjectSelectorIds: string[];
547
- };
548
- evidenceStrengthDistribution: Record<EvidenceStrengthV2, number>;
549
- };
550
- deltaDigest: string;
551
- extensions?: Record<string, Json>;
552
- }
553
-
554
- export interface ArchitectureCandidateDeltaPolicyDecisionV1 {
555
- decisionId: string;
556
- candidateChangeId: string;
557
- target: {
558
- kind: ArchitectureCandidateChangeTargetKind;
559
- id: string;
560
- parentId?: string;
561
- };
562
- stateDimension: ArchitectureCandidateStateDimension;
563
- changeKind: ArchitectureCodeChangeKind;
564
- confidence: "low" | "medium" | "high";
565
- action: ArchitectureCandidateDeltaPolicyAction;
566
- reasonCodes: ArchitectureCandidateDeltaPolicyReasonCode[];
567
- evidenceIds: string[];
568
- digest: string;
569
- extensions?: Record<string, Json>;
570
- }
571
-
572
- export interface ArchitectureCandidateDeltaPolicyEvaluationV1 {
573
- schemaVersion: typeof ARCHITECTURE_CANDIDATE_DELTA_POLICY_SCHEMA_VERSION;
574
- evaluationId: string;
575
- deltaId: string;
576
- repository: ArchitectureRepositoryIdentityV1;
577
- worktree: ArchitectureWorktreeIdentityV1;
578
- deltaDigest: string;
579
- policyVersion: string;
580
- evaluatedAt: string;
581
- decisions: ArchitectureCandidateDeltaPolicyDecisionV1[];
582
- summary: {
583
- candidateChanges: number;
584
- autoAccept: number;
585
- requireCheckpoint: number;
586
- requireProof: number;
587
- requireHumanApproval: number;
588
- mappingAmbiguities: number;
589
- };
590
- evaluationDigest: string;
591
- extensions?: Record<string, Json>;
592
- }
593
-
594
- export interface ProjectionTargetGeneratedRegionV1 {
595
- startMarker: string;
596
- endMarker: string;
597
- }
598
-
599
- export interface ProjectionTargetScopeV1 {
600
- kind: ProjectionTargetScopeKind;
601
- id?: string;
602
- entityKind?: string;
603
- }
604
-
605
- interface ProjectionTargetBaseV1 {
606
- schemaVersion: typeof PROJECTION_TARGET_SCHEMA_VERSION;
607
- targetId: string;
608
- type: ProjectionTargetType;
609
- scope: ProjectionTargetScopeV1;
610
- path: string;
611
- rendererVersion: string;
612
- format: ProjectionTargetFormat;
613
- sourceDigest: string;
614
- outputDigest: string;
615
- extensions?: Record<string, Json>;
616
- }
617
-
618
- /**
619
- * A `mixed` target owns one marked region inside a human-owned document, so it carries the region
620
- * markers. A `generated` target owns its whole file and carries no marker: the projection manifest
621
- * row's `outputDigest` is what proves the file is projection output.
622
- */
623
- export type ProjectionTargetV1 = ProjectionTargetBaseV1 & (
624
- | { ownership: Extract<ProjectionTargetOwnership, "mixed">; generatedRegion: ProjectionTargetGeneratedRegionV1 }
625
- | { ownership: Extract<ProjectionTargetOwnership, "generated">; generatedRegion?: never }
626
- );
627
-
628
- /** A target that owns one marked region inside a document. */
629
- export type ProjectionMixedTargetV1 = Extract<ProjectionTargetV1, { ownership: "mixed" }>;
630
-
631
140
  export interface RecommendationRunV1 {
632
141
  schemaVersion: typeof RECOMMENDATION_RUN_SCHEMA_VERSION;
633
142
  runId: string;
@@ -695,12 +204,6 @@ export interface RecommendationFeedbackV1 {
695
204
  extensions?: Record<string, Json>;
696
205
  }
697
206
 
698
- export interface RecommendationAuthorV1 {
699
- kind: ArchitectureActorKind;
700
- id: string;
701
- source: ArchitectureActorSource;
702
- }
703
-
704
207
  export interface RecommendationRelationsV1 {
705
208
  supersedes?: string;
706
209
  regressesFrom?: string;
@@ -807,27 +310,6 @@ export interface AgentJobV1 {
807
310
  extensions?: Record<string, Json>;
808
311
  }
809
312
 
810
- export interface InvestigationReportV1 {
811
- schemaVersion: typeof INVESTIGATION_REPORT_SCHEMA_VERSION;
812
- reportId: string;
813
- jobId: string;
814
- status: "succeeded" | "failed" | "partial";
815
- findings: {
816
- findingId: string;
817
- hypothesis: string;
818
- evidenceBindingIds: string[];
819
- unknowns: string[];
820
- falsifier: string;
821
- proposedDelta: ArchitectureCandidateChangeV1;
822
- proposedDeltaDigest: string;
823
- confidence: "low" | "medium" | "high";
824
- }[];
825
- outputDigest: string;
826
- createdAt: string;
827
- directMutationAllowed: false;
828
- extensions?: Record<string, Json>;
829
- }
830
-
831
313
  export const LEDGER_AUTHORITY_MATRIX: Record<ArchitectureFactAuthority, {
832
314
  writer: string;
833
315
  canonicalIdRule: string;
@@ -874,24 +356,3 @@ export function architectureSubjectSelectorDigest(selector: ArchitectureSubjectS
874
356
  const { digest: _digest, extensions: _extensions, ...hashable } = selector;
875
357
  return digestJson(hashable as unknown as Json);
876
358
  }
877
-
878
- export function architectureCandidateDeltaDigest(delta: ArchitectureCandidateDeltaV1): string {
879
- const { deltaDigest: _deltaDigest, extensions: _extensions, ...hashable } = delta;
880
- return digestJson(hashable as unknown as Json);
881
- }
882
-
883
- export function architectureCandidateDeltaPolicyDecisionDigest(decision: ArchitectureCandidateDeltaPolicyDecisionV1): string {
884
- const { digest: _digest, extensions: _extensions, ...hashable } = decision;
885
- return digestJson(hashable as unknown as Json);
886
- }
887
-
888
- export function architectureCandidateDeltaPolicyEvaluationDigest(evaluation: ArchitectureCandidateDeltaPolicyEvaluationV1): string {
889
- const {
890
- evaluationId: _evaluationId,
891
- evaluatedAt: _evaluatedAt,
892
- evaluationDigest: _evaluationDigest,
893
- extensions: _extensions,
894
- ...hashable
895
- } = evaluation;
896
- return digestJson(hashable as unknown as Json);
897
- }