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
@@ -0,0 +1,365 @@
1
+ import type { EvidenceCoverageLevelV2 } from "./ledger-records";
2
+ import type {
3
+ ARCHITECTURE_DOCS_RENDERER_VERSION,
4
+ ARCHITECTURE_PROOF_P1_STATUSES,
5
+ ARCHITECTURE_PROOF_P2_STATUSES,
6
+ ARCHITECTURE_REFRESH_SIGNAL_SCHEMA_VERSION,
7
+ PROJECTION_APPLY_IDENTITY_SCHEMA_VERSION,
8
+ PROJECTION_REQUEST_SCHEMA_VERSION,
9
+ PROJECTION_SLICE_SCHEMA_VERSION,
10
+ ArchitectureMajorChangeReasonCode,
11
+ ArchitectureRefreshTarget,
12
+ ArchitectureSemanticFacet,
13
+ ProjectionArchitectureDebtCoverageReasonCode,
14
+ ProjectionArchitectureDebtReasonCode,
15
+ ProjectionCoverageReasonCode,
16
+ ProjectionFilePreviewFormat,
17
+ ProjectionFreshnessReasonCode,
18
+ ProjectionHumanActionReasonCode,
19
+ ProjectionMode,
20
+ ProjectionPriorCommittedApplyOperation,
21
+ ProjectionTarget,
22
+ ProjectionTargetChangeClassification,
23
+ ProjectionTargetChangePlannedAction,
24
+ ProjectionTargetChangeReasonCode,
25
+ Sha256Digest
26
+ } from "./projection-constants";
27
+
28
+ /** One capability's P1/P2 proof status, as its semantic state records it. */
29
+ export interface ArchitectureCapabilityProofStatusV1 {
30
+ p1: (typeof ARCHITECTURE_PROOF_P1_STATUSES)[number];
31
+ p2: (typeof ARCHITECTURE_PROOF_P2_STATUSES)[number];
32
+ }
33
+
34
+ /**
35
+ * Why one capability is part of a major change: the reason codes and semantic facets that moved for
36
+ * it between the committed semantic baseline and this run. `proofStatusBefore` is null when the
37
+ * baseline has no such capability (or no baseline exists); `proofStatusAfter` is null when the
38
+ * capability was removed. A capability present on one side only lists no changed facets. A
39
+ * capability listed only because its current proof is unprovable, while another capability carries
40
+ * the observed change, lists no reason codes.
41
+ */
42
+ export interface ArchitectureCapabilityChangeV1 {
43
+ capabilityId: string;
44
+ reasonCodes: ArchitectureMajorChangeReasonCode[];
45
+ changedFacets: ArchitectureSemanticFacet[];
46
+ proofStatusBefore: ArchitectureCapabilityProofStatusV1 | null;
47
+ proofStatusAfter: ArchitectureCapabilityProofStatusV1 | null;
48
+ }
49
+
50
+ /**
51
+ * What a `plan` would write to one file, returned in the response only and never persisted: the
52
+ * rendered body of a `create`, or a unified diff (current bytes to rendered bytes) of an `update` or
53
+ * `delete`. `content` is cut at a line boundary to at most PROJECTION_FILE_PREVIEW_MAX_BYTES UTF-8
54
+ * bytes, and to whatever remains of PROJECTION_PREVIEW_TOTAL_MAX_BYTES across the result, in path
55
+ * order; `byteLength` is the UTF-8 length of the complete content and `truncated` says whether
56
+ * `content` is shorter.
57
+ */
58
+ export interface ProjectionSliceEntrypointV1 {
59
+ nodeId: string;
60
+ entrypointId: string;
61
+ path: string;
62
+ symbol: string;
63
+ }
64
+
65
+ export interface ProjectionSliceCapabilityV1 {
66
+ capabilityId: string;
67
+ modulePath: string;
68
+ /** Unfenced Mermaid. Null when the capability was removed or P1 cannot be rendered. */
69
+ diagramMermaid: string | null;
70
+ entrypoints: ProjectionSliceEntrypointV1[];
71
+ markdown: string;
72
+ }
73
+
74
+ export interface ProjectionSliceV1 {
75
+ schemaVersion: typeof PROJECTION_SLICE_SCHEMA_VERSION;
76
+ base: string;
77
+ baseSha: string;
78
+ mergeBase: string;
79
+ headSha: string;
80
+ changedPaths: string[];
81
+ changed: boolean;
82
+ affectedCapabilities: ProjectionSliceCapabilityV1[];
83
+ markdown: string;
84
+ }
85
+
86
+ export interface ProjectionFilePreviewV1 {
87
+ format: ProjectionFilePreviewFormat;
88
+ content: string;
89
+ byteLength: number;
90
+ truncated: boolean;
91
+ }
92
+
93
+ export interface ProjectionExpectedSnapshotV1 {
94
+ repositoryId: string;
95
+ workspaceId: string;
96
+ headSha: string;
97
+ worktreeDigest: Sha256Digest;
98
+ }
99
+
100
+ export interface ProjectionRequestV1 {
101
+ schemaVersion: typeof PROJECTION_REQUEST_SCHEMA_VERSION;
102
+ requestId: string;
103
+ profile: "repo-harness/v1";
104
+ mode: ProjectionMode;
105
+ targets: ProjectionTarget[];
106
+ changedPaths: string[];
107
+ expected: ProjectionExpectedSnapshotV1;
108
+ adoptionPlanId?: string;
109
+ acceptedChange?: AcceptedArchitectureChangeReferenceV1;
110
+ /**
111
+ * `apply` and `adopt` only, never together with `acceptedChange`: accept the major change this
112
+ * run observes at `expected`. The provider classifies, derives the accepted change and applies
113
+ * it against the same expected snapshot, which the daemon re-checks under its writer lock before
114
+ * writing. The apply receipt records the observed change with provider-generated `changeSetId`
115
+ * and `eventId`. Absent, a major change still stops at `human-action-required` (#261).
116
+ */
117
+ acceptObservedMajorChange?: true;
118
+ }
119
+
120
+ export interface ProjectionSnapshotV1 extends ProjectionExpectedSnapshotV1 {
121
+ baseHeadSha: string;
122
+ sourceTreeDigest: Sha256Digest;
123
+ modelDigest: Sha256Digest;
124
+ codeGraphDigest: Sha256Digest;
125
+ indexedWorktreeDigest: Sha256Digest | null;
126
+ projectionInputDigest: Sha256Digest;
127
+ rendererVersion: typeof ARCHITECTURE_DOCS_RENDERER_VERSION;
128
+ layoutVersion: "archcontext.docs-layout/v1";
129
+ generatedFrom: {
130
+ codeGraphPackage: "@colbymchenry/codegraph";
131
+ codeGraphVersion: "1.6.4";
132
+ codeGraphStatus: "ready" | "unavailable";
133
+ };
134
+ }
135
+
136
+ export interface ProjectionFileResultV1 {
137
+ path: string;
138
+ action: "create" | "delete" | "unchanged" | "update";
139
+ preimageDigest: Sha256Digest | null;
140
+ outputDigest: Sha256Digest | null;
141
+ /**
142
+ * `plan` results only (#264): what this entry would write. Absent on every other mode, on a
143
+ * committed receipt, and on an entry whose path the projection rejected for adoption or ownership
144
+ * repair, because no apply writes that rendered body. Consumers gate on `projection-preview-v1`.
145
+ */
146
+ preview?: ProjectionFilePreviewV1;
147
+ }
148
+
149
+ export interface ProjectionHumanActionV1 {
150
+ reasonCode: ProjectionHumanActionReasonCode;
151
+ affectedNodeIds: string[];
152
+ /**
153
+ * Present exactly on `orphaned-document-review`: the managed document whose target the model no
154
+ * longer renders and which may hold human text. `apply` never deletes it; a human must review,
155
+ * move or remove it. A generated-only orphan is a `files[]` delete instead.
156
+ */
157
+ path?: string;
158
+ requestPayloadDigest: Sha256Digest;
159
+ }
160
+
161
+ export interface ProjectionApplyIdentityV1 {
162
+ schemaVersion: typeof PROJECTION_APPLY_IDENTITY_SCHEMA_VERSION;
163
+ applyId: Sha256Digest;
164
+ lookupKey: Sha256Digest;
165
+ repositoryId: string;
166
+ workspaceId: string;
167
+ acceptedChange: AcceptedArchitectureChangeReferenceV1;
168
+ semanticCommit: {
169
+ changeSetId: string;
170
+ idempotencyKey: string;
171
+ };
172
+ ownedFilesDigest: Sha256Digest;
173
+ refreshSignalsDigest: Sha256Digest;
174
+ }
175
+
176
+ /**
177
+ * The global digests of a projection. The base digests come from the committed manifest, which
178
+ * records no source state, so the set carries no source tree digest (ADR-0056 §4).
179
+ */
180
+ export interface ArchitectureDigestSetV2 {
181
+ modelDigest: Sha256Digest;
182
+ flowProofDigest: Sha256Digest;
183
+ projectionDigest: Sha256Digest;
184
+ }
185
+
186
+ export interface AcceptedArchitectureChangeReferenceV1 {
187
+ changeSetId: string;
188
+ eventId: string;
189
+ reasonCodes: ArchitectureMajorChangeReasonCode[];
190
+ affectedNodeIds: string[];
191
+ }
192
+
193
+ export interface ArchitectureRefreshSignalV2 {
194
+ schemaVersion: typeof ARCHITECTURE_REFRESH_SIGNAL_SCHEMA_VERSION;
195
+ signalId: Sha256Digest;
196
+ idempotencyKey: Sha256Digest;
197
+ mode: "human-action-required" | "refresh-required";
198
+ repository: { repositoryId: string };
199
+ worktree: { workspaceId: string; headSha: string; worktreeDigest: Sha256Digest };
200
+ cause: "accepted-semantic-delta" | "unresolved-major-candidate" | "verified-flow-proof-delta";
201
+ acceptedChange?: AcceptedArchitectureChangeReferenceV1;
202
+ reasonCodes: ArchitectureMajorChangeReasonCode[];
203
+ affectedNodeIds: string[];
204
+ /**
205
+ * The observed per-capability breakdown of the semantic delta this signal classifies, sorted by
206
+ * capabilityId (#264). Every signal this provider produces carries it; it is part of the signal
207
+ * identity; signals committed before it existed lack it. Consumers gate on
208
+ * `architecture-change-capabilities-v1`, not on field presence.
209
+ */
210
+ capabilities?: ArchitectureCapabilityChangeV1[];
211
+ refreshTargets: ArchitectureRefreshTarget[];
212
+ baseDigests: ArchitectureDigestSetV2;
213
+ resultingDigests: ArchitectureDigestSetV2;
214
+ projectionReceiptDigest: Sha256Digest;
215
+ }
216
+
217
+ export interface ProjectionPriorCommittedApplyFileV1 {
218
+ path: string;
219
+ operation: ProjectionPriorCommittedApplyOperation;
220
+ /** `digestJson({ body })` of the body this ChangeSet wrote, or `"missing"` for a delete. */
221
+ hash: string;
222
+ }
223
+
224
+ /**
225
+ * A ChangeSet already committed under this request's requestId by an earlier attempt of the same
226
+ * request. The CLI is a short-lived RPC client while the daemon owns the write, so a caller whose
227
+ * process was killed after the commit sees only `status: noop` on retry; this array is the only
228
+ * surface that names what that lost attempt actually wrote.
229
+ */
230
+ export interface ProjectionPriorCommittedApplyV1 {
231
+ /**
232
+ * Present together with `lookupKey` only when the committed ChangeSet also carried a projection
233
+ * apply receipt, which happens only for an accepted-semantic-change apply. A plain drift-repair
234
+ * apply commits without one, and both fields are then absent rather than invented.
235
+ */
236
+ applyId?: Sha256Digest;
237
+ lookupKey?: Sha256Digest;
238
+ requestId: string;
239
+ changeSetId: string;
240
+ committedAt: string;
241
+ files: ProjectionPriorCommittedApplyFileV1[];
242
+ }
243
+
244
+ /** One target whose rendered output differs from its committed manifest row. */
245
+ export interface ProjectionFreshnessStaleTargetV2 {
246
+ targetId: string;
247
+ path: string;
248
+ /** The committed row's `outputDigest`; `null` for a target the committed manifest does not record. */
249
+ committedOutputDigest: Sha256Digest | null;
250
+ /** The current render's `outputDigest`; `null` for a committed row the current layout no longer renders. */
251
+ renderedOutputDigest: Sha256Digest | null;
252
+ }
253
+
254
+ /**
255
+ * Render-equivalent freshness of the committed projection (ADR-0056 §1): a target is fresh when the
256
+ * output the current render produces equals its committed row's `outputDigest`, and the projection
257
+ * is fresh when every target is, the two target sets are equal, and the manifest the render would
258
+ * write equals the committed bytes.
259
+ */
260
+ export interface ProjectionFreshnessV2 {
261
+ ok: boolean;
262
+ reasonCodes: ProjectionFreshnessReasonCode[];
263
+ /** Sorted and unique by targetId. Non-empty exactly when `projection-output-changed` is reported. */
264
+ staleTargets: ProjectionFreshnessStaleTargetV2[];
265
+ }
266
+
267
+ /**
268
+ * One capability pair whose imports no model relation declares, under the rule of
269
+ * CAPABILITY_DEPENDENCY_DECLARING_RELATION_KINDS. It is the same pair, with the same edge count,
270
+ * that `archctx deps` reports as a cross-capability cell with `declared: false`, measured over
271
+ * the files this run measured instead of the `HEAD` tree.
272
+ */
273
+ export interface ProjectionUndeclaredDependencyV1 {
274
+ reasonCode: "undeclared-dependency";
275
+ fromCapabilityId: string;
276
+ toCapabilityId: string;
277
+ /** Distinct file-to-file import edges from `fromCapabilityId` into `toCapabilityId`; at least 1. */
278
+ importEdgeCount: number;
279
+ }
280
+
281
+ /**
282
+ * Architecture debt that this `check` or `plan` run found. It reuses the import facts the run
283
+ * already read, never blocks a mode and changes no rendered output. It covers every capability
284
+ * pair in the repository, not only pairs that touch the request's `changedPaths`.
285
+ */
286
+ export interface ProjectionArchitectureDebtV1 {
287
+ /**
288
+ * `unknown` when the run had no code facts (`code-facts-unavailable`): `items` is then empty and
289
+ * says nothing about the repository. `partial` when the import read is a prefix of the index or
290
+ * a workspace specifier could not be resolved: `items` then holds what was observed.
291
+ */
292
+ coverage: EvidenceCoverageLevelV2;
293
+ /** Sorted and unique; empty exactly when `coverage` is `complete`. */
294
+ coverageReasonCodes: ProjectionArchitectureDebtCoverageReasonCode[];
295
+ /** Sorted by `fromCapabilityId`, then `toCapabilityId`. */
296
+ items: ProjectionUndeclaredDependencyV1[];
297
+ }
298
+
299
+ /** One target a partial result carries forward instead of applying. */
300
+ export interface ProjectionCoverageBlockedTargetV1 {
301
+ targetId: string;
302
+ path: string;
303
+ /** The blocked capabilities this target depends on, sorted. Never empty. */
304
+ capabilityIds: string[];
305
+ /** Why those capabilities block it, sorted. Never empty. */
306
+ reasonCodes: ProjectionCoverageReasonCode[];
307
+ }
308
+
309
+ /**
310
+ * Which part of the projection a `planned-partial` or `applied-partial` result covers (#327,
311
+ * Phase 1 capability isolation). The blocked capabilities are those whose proof is unprovable or
312
+ * whose flow proof moved without an accepted change, while their semantic fingerprint held. Every
313
+ * target that depends on one of them is carried forward unchanged: its document, its manifest row
314
+ * and the capability's baseline entry keep their committed bytes. `appliedTargetIds` are all the
315
+ * other targets, which the result renders from the current model and sources.
316
+ *
317
+ * `complete` is always `false`: a result that covers every target omits `coverage` instead. A
318
+ * partial result is never an acceptance. It carries no apply receipt and no refresh signal, and a
319
+ * complete check or the `complete` gate still reports the blocked capabilities until they are
320
+ * fixed or accepted.
321
+ */
322
+ export interface ProjectionCoverageV1 {
323
+ complete: false;
324
+ /** Sorted and unique. Never empty. */
325
+ blockedCapabilityIds: string[];
326
+ /** Sorted and unique by targetId. Never empty. */
327
+ blockedTargets: ProjectionCoverageBlockedTargetV1[];
328
+ /** Sorted and unique; disjoint from the blocked targets. */
329
+ appliedTargetIds: string[];
330
+ }
331
+
332
+ /**
333
+ * One target of a `check` or `plan` result (#327 finding 2): how it changes since the committed
334
+ * projection, and what this run's write does to its file. The entries cover the union of the
335
+ * current layout's targets and the committed manifest's rows (plus orphans the manifest does not
336
+ * record), one per target. Only agent-context targets share a path (ADR-0056 §9). The projection
337
+ * manifest is not a target; its write is the `files[]` entry no change names.
338
+ *
339
+ * Each comparison is against the committed v4 manifest: `outputChanged` the row's `outputDigest`, or any byte the write changes;
340
+ * `semanticChanged` the `semanticFingerprint` of a capability the target documents (every
341
+ * capability for a target that is not an entity summary, which also compares the manifest's
342
+ * `semanticBaseline.modelDigest`, because it renders the whole model); `proofChanged` the `flowProofFingerprint`
343
+ * or `selectorEvidenceDigest` of a capability an entity summary documents. `null` is an unknown
344
+ * comparison, never `false`.
345
+ *
346
+ * `plannedAction` is the result's own write decision (`files[]`) for that path. When `status` is
347
+ * `planned` or `planned-partial`, the targets whose action is not `none` are exactly the documents
348
+ * an apply of this run writes or deletes; under `adoption-required` or `human-action-required`
349
+ * apply writes nothing, and `plannedAction` reports only what the render would write. A
350
+ * path rejected for adoption or ownership repair is `blocked` and `none`, because only an
351
+ * approved adoption writes it. `classification` never changes `status`, the write set or a gate.
352
+ */
353
+ export interface ProjectionTargetChangeV2 {
354
+ targetId: string;
355
+ path: string;
356
+ /** Sorted and unique: the documented capabilities whose change affects this target. Empty when unchanged. */
357
+ affectedCapabilityIds: string[];
358
+ outputChanged: boolean;
359
+ semanticChanged: boolean | null;
360
+ proofChanged: boolean | null;
361
+ plannedAction: ProjectionTargetChangePlannedAction;
362
+ classification: ProjectionTargetChangeClassification;
363
+ /** Sorted and unique. Empty exactly when `classification` is `unchanged`. */
364
+ reasonCodes: ProjectionTargetChangeReasonCode[];
365
+ }
@@ -0,0 +1,15 @@
1
+ export const SHA256_DIGEST = /^sha256:[a-f0-9]{64}$/;
2
+ export const ISO_INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/;
3
+
4
+ const UTF8 = new TextEncoder();
5
+
6
+ export function utf8ByteLength(value: string): number {
7
+ return UTF8.encode(value).length;
8
+ }
9
+
10
+ export function sortedUniqueIssues(label: string, values: readonly string[]): string[] {
11
+ const expected = [...new Set(values)].sort();
12
+ return expected.length === values.length && expected.every((value, index) => value === values[index])
13
+ ? []
14
+ : [`${label} must be sorted and unique`];
15
+ }