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.
- package/fixtures/invalid/projection-result-applied-incomplete-coverage.json +3 -3
- package/fixtures/valid/archctx-capabilities.json +2 -2
- package/fixtures/valid/flow-selector-check.json +1 -1
- package/fixtures/valid/product-version-manifest.json +5 -11
- package/fixtures/valid/projection-manifest.json +1 -1
- package/fixtures/valid/projection-result.json +3 -3
- package/package.json +4 -1
- package/schemas/repo/refactor-decision.schema.json +283 -37
- package/schemas/runtime/archctx-capabilities.schema.json +144 -20
- package/schemas/runtime/architecture-debt-delta.schema.json +58 -19
- package/schemas/runtime/architecture-debt.schema.json +42 -42
- package/schemas/runtime/architecture-event.schema.json +1 -1
- package/schemas/runtime/architecture-history.schema.json +354 -0
- package/schemas/runtime/capability-dependencies.schema.json +266 -59
- package/schemas/runtime/cli-check.schema.json +197 -0
- package/schemas/runtime/cli-help.schema.json +28 -0
- package/schemas/runtime/dependency-constraint-evaluation.schema.json +67 -68
- package/schemas/runtime/docs-anchors.schema.json +250 -67
- package/schemas/runtime/doctor-code-facts.schema.json +49 -0
- package/schemas/runtime/evidence-binding.schema.json +1 -1
- package/schemas/runtime/flow-selector-check.schema.json +179 -46
- package/schemas/runtime/hook-debt-checkpoint.schema.json +12 -12
- package/schemas/runtime/index-seed.schema.json +56 -0
- package/schemas/runtime/path-context.schema.json +108 -0
- package/schemas/runtime/product-version-manifest.schema.json +142 -54
- package/schemas/runtime/projection-apply-readback.schema.json +2 -2
- package/schemas/runtime/projection-apply-recovery.schema.json +1 -1
- package/schemas/runtime/projection-result.schema.json +1 -1
- package/schemas/runtime/projection-slice.schema.json +34 -34
- package/schemas/runtime/recommendation-v3.schema.json +372 -1
- package/schemas/runtime/ref-impact-batch-request.schema.json +20 -7
- package/schemas/runtime/ref-impact-batch.schema.json +83 -13
- package/schemas/runtime/ref-impact.schema.json +68 -61
- package/schemas/runtime/refactor-scan-v2.schema.json +434 -0
- package/schemas/runtime/refactor-simulate.schema.json +505 -0
- package/schemas/runtime/refactor-verify-v2.schema.json +172 -0
- package/schemas/runtime/resolve-path.schema.json +69 -0
- package/schemas/runtime/runtime-recommendation-show.schema.json +531 -2
- package/schemas/runtime/runtime-refactor-scan.schema.json +498 -2
- package/schemas/runtime/runtime-verify.schema.json +274 -56
- package/schemas/runtime/state-machine-check.schema.json +357 -89
- package/schemas/runtime/structural-observation-payload.schema.json +372 -1
- package/schemas/runtime/sync-check.schema.json +65 -0
- package/src/architecture-debt.ts +125 -38
- package/src/architecture-history.ts +168 -42
- package/src/architecture.ts +100 -0
- package/src/cli-read.ts +228 -0
- package/src/docs-anchors.ts +105 -50
- package/src/explorer-occurrence-ports.ts +175 -0
- package/src/explorer-query-ports.ts +270 -0
- package/src/failure.ts +3 -0
- package/src/index-seed.ts +42 -0
- package/src/index.ts +5 -0
- package/src/ledger-records.ts +262 -0
- package/src/ledger.ts +27 -566
- package/src/ownership-dependencies.ts +115 -5
- package/src/ports.ts +12 -543
- package/src/product-version.ts +75 -56
- package/src/projection-apply-types.ts +216 -0
- package/src/projection-apply-validators.ts +355 -0
- package/src/projection-capabilities.ts +181 -0
- package/src/projection-constants.ts +317 -0
- package/src/projection-manifest-types.ts +298 -0
- package/src/projection-manifest.ts +12 -299
- package/src/projection-recovery-validators.ts +229 -0
- package/src/projection-request-validators.ts +326 -0
- package/src/projection-types.ts +365 -0
- package/src/projection-validation-helpers.ts +15 -0
- package/src/projection.ts +7 -1689
- package/src/ref-impact.ts +225 -33
- package/src/refactor-constants.ts +213 -0
- package/src/refactor-decision-validators.ts +350 -0
- package/src/refactor-evidence-types.ts +286 -0
- package/src/refactor-observation-validators.ts +359 -0
- package/src/refactor-resolution-validators.ts +229 -0
- package/src/refactor-snapshot-validators.ts +368 -0
- package/src/refactor-types.ts +270 -0
- package/src/refactor-v2.ts +389 -0
- package/src/refactor-validation-helpers.ts +195 -0
- package/src/refactor.ts +7 -1849
- package/src/review-guards.ts +3 -23
- package/src/runtime-verify.ts +87 -0
- package/src/schema-kit.ts +183 -0
- package/src/schema-registry.ts +73 -0
- package/src/schema.ts +0 -4
- package/src/state-machine-schemas.ts +192 -0
- package/src/state-machine-types.ts +188 -0
- package/src/state-machine.ts +9 -189
- package/fixtures/boundary/agent-job-expired.json +0 -33
- package/fixtures/invalid/adapter-fidelity-reverse-sync.json +0 -9
- package/fixtures/invalid/agent-job-direct-mutation.json +0 -32
- package/fixtures/invalid/cloud-egress-envelope-private-field.json +0 -12
- package/fixtures/invalid/investigation-report-direct-mutation.json +0 -38
- package/fixtures/invalid/investigation-report-missing-proposed-delta.json +0 -19
- package/fixtures/invalid/notification-event-code-field.json +0 -11
- package/fixtures/valid/adapter-fidelity.json +0 -9
- package/fixtures/valid/agent-job.json +0 -33
- package/fixtures/valid/architecture-candidate-delta-policy.json +0 -45
- package/fixtures/valid/architecture-candidate-delta.json +0 -188
- package/fixtures/valid/chatgpt-ga-tool.json +0 -9
- package/fixtures/valid/cloud-egress-envelope.json +0 -11
- package/fixtures/valid/entitlement.json +0 -12
- package/fixtures/valid/investigation-report.json +0 -38
- package/fixtures/valid/likec4-mapping.json +0 -14
- package/fixtures/valid/notification-event.json +0 -10
- package/fixtures/valid/notification-provider.json +0 -12
- package/fixtures/valid/structurizr-mapping.json +0 -15
- package/schemas/cloud/cloud-egress-envelope.schema.json +0 -19
- package/schemas/cloud/entitlement.schema.json +0 -24
- package/schemas/integrations/adapter-fidelity.schema.json +0 -21
- package/schemas/integrations/chatgpt-ga-tool.schema.json +0 -25
- package/schemas/integrations/likec4-mapping.schema.json +0 -32
- package/schemas/integrations/structurizr-mapping.schema.json +0 -33
- package/schemas/runtime/agent-job.schema.json +0 -63
- package/schemas/runtime/architecture-candidate-delta-policy.schema.json +0 -129
- package/schemas/runtime/architecture-candidate-delta.schema.json +0 -386
- package/schemas/runtime/investigation-report.schema.json +0 -119
- package/schemas/runtime/notification-event.schema.json +0 -18
- package/schemas/runtime/notification-provider.schema.json +0 -26
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
export const PROJECTION_REQUEST_SCHEMA_VERSION = "archcontext.projection-request/v1" as const;
|
|
2
|
+
export const PROJECTION_RESULT_SCHEMA_VERSION = "archcontext.projection-result/v3" as const;
|
|
3
|
+
export const PROJECTION_APPLY_IDENTITY_SCHEMA_VERSION = "archcontext.projection-apply-identity/v1" as const;
|
|
4
|
+
export const PROJECTION_APPLY_RECEIPT_SCHEMA_VERSION = "archcontext.projection-apply-receipt/v1" as const;
|
|
5
|
+
export const PROJECTION_APPLY_RECOVERY_BINDING_SCHEMA_VERSION = "archcontext.projection-apply-recovery-binding/v2" as const;
|
|
6
|
+
export const PROJECTION_APPLY_RECOVERY_INTENT_SCHEMA_VERSION = "archcontext.projection-apply-recovery-intent/v1" as const;
|
|
7
|
+
export const PROJECTION_APPLY_RECOVERY_PROOF_SCHEMA_VERSION = "archcontext.projection-apply-recovery-proof/v2" as const;
|
|
8
|
+
export const PROJECTION_APPLY_RECOVERY_RESULT_SCHEMA_VERSION = "archcontext.projection-apply-recovery-result/v2" as const;
|
|
9
|
+
export const PROJECTION_APPLY_READBACK_RESULT_SCHEMA_VERSION = "archcontext.projection-apply-readback-result/v2" as const;
|
|
10
|
+
export const ARCHITECTURE_REFRESH_SIGNAL_SCHEMA_VERSION = "archcontext.architecture-refresh-signal/v2" as const;
|
|
11
|
+
export const ARCHCTX_CAPABILITIES_SCHEMA_VERSION = "archcontext.capabilities/v1" as const;
|
|
12
|
+
export const ARCHITECTURE_DOCS_RENDERER_VERSION = "archcontext.docs-renderer/v6" as const;
|
|
13
|
+
/**
|
|
14
|
+
* The committed projection manifest's path. `projection-manifest.ts` owns its shape and byte layout;
|
|
15
|
+
* the path lives here because a projection result's `files[]` names the manifest write.
|
|
16
|
+
*/
|
|
17
|
+
export const ARCHITECTURE_DOCS_PROJECTION_MANIFEST_PATH = "docs/architecture/.projection-manifest.json" as const;
|
|
18
|
+
export const AGENT_CONTEXT_RENDERER_VERSION = "archcontext.agent-context-renderer/v2" as const;
|
|
19
|
+
|
|
20
|
+
export const PROJECTION_MODES = ["check", "plan", "apply", "adopt"] as const;
|
|
21
|
+
export const PROJECTION_PRIOR_COMMITTED_APPLY_OPERATIONS = ["delete", "write"] as const;
|
|
22
|
+
export const PROJECTION_TARGETS = ["agent-context", "architecture-docs", "architecture-history"] as const;
|
|
23
|
+
export const PROJECTION_RESULT_STATUSES = [
|
|
24
|
+
"adoption-required",
|
|
25
|
+
"applied",
|
|
26
|
+
"applied-partial",
|
|
27
|
+
"applied-reconcile-required",
|
|
28
|
+
"blocked",
|
|
29
|
+
"human-action-required",
|
|
30
|
+
"noop",
|
|
31
|
+
"permanent-failure",
|
|
32
|
+
"planned",
|
|
33
|
+
"planned-partial",
|
|
34
|
+
"retryable-failure"
|
|
35
|
+
] as const;
|
|
36
|
+
/**
|
|
37
|
+
* The two statuses of a projection that covers only part of its targets (#327, Phase 1 capability
|
|
38
|
+
* isolation): `planned-partial` from `check` and `plan`, `applied-partial` from `apply`. Exactly
|
|
39
|
+
* these results carry `coverage`, always with `complete: false`; a complete result omits it.
|
|
40
|
+
*/
|
|
41
|
+
export const PROJECTION_PARTIAL_RESULT_STATUSES = ["applied-partial", "planned-partial"] as const;
|
|
42
|
+
/**
|
|
43
|
+
* Why a target is carried forward instead of applied: a capability it depends on has an
|
|
44
|
+
* unprovable P1 or P2 proof (`unprovable-required-flow`), or its flow proof moved since the
|
|
45
|
+
* committed baseline while its semantic fingerprint held (`verified-flow-proof-changed`).
|
|
46
|
+
*/
|
|
47
|
+
export const PROJECTION_COVERAGE_REASON_CODES = ["unprovable-required-flow", "verified-flow-proof-changed"] as const;
|
|
48
|
+
export const PROJECTION_HUMAN_ACTION_REASON_CODES = [
|
|
49
|
+
"adoption-required",
|
|
50
|
+
"manual-region-conflict",
|
|
51
|
+
"orphaned-document-review",
|
|
52
|
+
"target-collision",
|
|
53
|
+
"unprovable-required-flow",
|
|
54
|
+
"unresolved-major-change"
|
|
55
|
+
] as const;
|
|
56
|
+
export const ARCHITECTURE_MAJOR_CHANGE_REASON_CODES = [
|
|
57
|
+
"constraint-changed",
|
|
58
|
+
"entrypoint-changed",
|
|
59
|
+
"interface-changed",
|
|
60
|
+
"lifecycle-changed",
|
|
61
|
+
"node-added",
|
|
62
|
+
"node-moved",
|
|
63
|
+
"node-removed",
|
|
64
|
+
"node-renamed",
|
|
65
|
+
"ownership-changed",
|
|
66
|
+
"relation-changed",
|
|
67
|
+
"responsibility-changed",
|
|
68
|
+
"risk-boundary-changed",
|
|
69
|
+
"verified-flow-proof-changed"
|
|
70
|
+
] as const;
|
|
71
|
+
export const ARCHITECTURE_REFRESH_TARGETS = [
|
|
72
|
+
"architecture-contract-context",
|
|
73
|
+
"architecture-readiness",
|
|
74
|
+
"architecture-request-index",
|
|
75
|
+
"capability-context",
|
|
76
|
+
"capability-index"
|
|
77
|
+
] as const;
|
|
78
|
+
export const ARCHCTX_FEATURES = [
|
|
79
|
+
"architecture-change-capabilities-v1",
|
|
80
|
+
"architecture-debt-v1",
|
|
81
|
+
"architecture-docs-renderer-v2",
|
|
82
|
+
"architecture-refresh-signal-v1",
|
|
83
|
+
"capability-dependencies-declared-v1",
|
|
84
|
+
"capability-dependencies-v1",
|
|
85
|
+
"changeset-entity-operations-v1",
|
|
86
|
+
"changeset-ownership-delta-v1",
|
|
87
|
+
"cli-check-v1",
|
|
88
|
+
"code-facts-unavailable-error-v1",
|
|
89
|
+
"deps-calls-matrix-v1",
|
|
90
|
+
"docs-anchors-v1",
|
|
91
|
+
"flow-selector-check-v1",
|
|
92
|
+
"host-ownership-isolation-v1",
|
|
93
|
+
"index-seed-v1",
|
|
94
|
+
"module-statistics-v1",
|
|
95
|
+
"native-context-export-v1",
|
|
96
|
+
"projection-apply-receipt-v1",
|
|
97
|
+
"projection-apply-replay-restore-v1",
|
|
98
|
+
"projection-apply-replay-v1",
|
|
99
|
+
"projection-architecture-debt-v1",
|
|
100
|
+
"projection-capability-isolation-v1",
|
|
101
|
+
"projection-change-classification-v2",
|
|
102
|
+
"projection-check-freshness-v2",
|
|
103
|
+
"projection-freshness-v2",
|
|
104
|
+
"projection-manifest-contract-v4",
|
|
105
|
+
"projection-observed-major-change-acceptance-v1",
|
|
106
|
+
"projection-orphan-review-v1",
|
|
107
|
+
"projection-preview-v1",
|
|
108
|
+
"projection-prior-committed-applies-v1",
|
|
109
|
+
"projection-protocol-v2",
|
|
110
|
+
"projection-publish-v1",
|
|
111
|
+
"projection-slice-v1",
|
|
112
|
+
"projection-snapshot-v1",
|
|
113
|
+
"projection-verify-pr-v1",
|
|
114
|
+
"recommendation-scan-decision-v1",
|
|
115
|
+
"recommendation-v3",
|
|
116
|
+
"refactor-assessment-v1",
|
|
117
|
+
"refactor-observation-evidence-v1",
|
|
118
|
+
"refactor-radar-v2",
|
|
119
|
+
"refactor-resolution-v1",
|
|
120
|
+
"refactor-scan-limits-v1",
|
|
121
|
+
"refactor-scan-untracked-count-v1",
|
|
122
|
+
"refactor-simulate-v1",
|
|
123
|
+
"refactor-symbol-kill-list-v1"
|
|
124
|
+
] as const;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The closed set of semantic facets a capability's semantic state digests. Each facet maps to the
|
|
128
|
+
* major-change reason code it raises when its digest moves.
|
|
129
|
+
*/
|
|
130
|
+
export const ARCHITECTURE_SEMANTIC_FACETS = [
|
|
131
|
+
"constraints",
|
|
132
|
+
"entrypoints",
|
|
133
|
+
"interfaces",
|
|
134
|
+
"lifecycle",
|
|
135
|
+
"names",
|
|
136
|
+
"ownership",
|
|
137
|
+
"placement",
|
|
138
|
+
"relations",
|
|
139
|
+
"responsibilities",
|
|
140
|
+
"riskBoundaries"
|
|
141
|
+
] as const;
|
|
142
|
+
export const ARCHITECTURE_PROOF_P1_STATUSES = ["proven", "unprovable"] as const;
|
|
143
|
+
export const ARCHITECTURE_PROOF_P2_STATUSES = ["not-applicable", "proven", "unprovable"] as const;
|
|
144
|
+
|
|
145
|
+
export const ARCHITECTURE_FLOW_SELECTOR_CHECK_SCHEMA_VERSION = "archcontext.flow-selector-check/v1" as const;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The proof status of one declared entrypoint→sink selector, as the P2 flow proof reads its
|
|
149
|
+
* evidence. Only `proven` can bind a flow step. `no-direct-call`: no `calls` edge from the source
|
|
150
|
+
* to the sink. `only-references`: no proving call, but the source references the sink by value.
|
|
151
|
+
* `false-builtin-call`: the only calls carry a runtime built-in name and the source file does not
|
|
152
|
+
* import the sink file. `ambiguous-symbol`: the source or the sink matches more than one indexed
|
|
153
|
+
* symbol. `evidence-missing`: no evidence was measured (for example, no CodeGraph index).
|
|
154
|
+
* `evidence-truncated`: the evidence producer could not enumerate every edge.
|
|
155
|
+
*/
|
|
156
|
+
export const ARCHITECTURE_FLOW_SELECTOR_PROOF_STATUSES = [
|
|
157
|
+
"ambiguous-symbol",
|
|
158
|
+
"evidence-missing",
|
|
159
|
+
"evidence-truncated",
|
|
160
|
+
"false-builtin-call",
|
|
161
|
+
"no-direct-call",
|
|
162
|
+
"only-references",
|
|
163
|
+
"proven"
|
|
164
|
+
] as const;
|
|
165
|
+
export type ArchitectureFlowSelectorProofStatus = typeof ARCHITECTURE_FLOW_SELECTOR_PROOF_STATUSES[number];
|
|
166
|
+
|
|
167
|
+
export interface ArchitectureFlowSelectorSiteV1 {
|
|
168
|
+
path: string;
|
|
169
|
+
line?: number;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface ArchitectureFlowSelectorCheckEntryV1 {
|
|
173
|
+
nodeId: string;
|
|
174
|
+
entrypointId: string;
|
|
175
|
+
sourcePath: string;
|
|
176
|
+
sourceSymbol: string;
|
|
177
|
+
sinkId: string;
|
|
178
|
+
sinkPath: string;
|
|
179
|
+
sinkSymbol: string;
|
|
180
|
+
status: ArchitectureFlowSelectorProofStatus;
|
|
181
|
+
callSites: ArchitectureFlowSelectorSiteV1[];
|
|
182
|
+
referenceSites: ArchitectureFlowSelectorSiteV1[];
|
|
183
|
+
rejectedBuiltinCallSites: ArchitectureFlowSelectorSiteV1[];
|
|
184
|
+
/** The required-flow steps that name this selector as evidence. Empty for an unused selector. */
|
|
185
|
+
flowSteps: Array<{ flowId: string; stepId: string }>;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface ArchitectureFlowSelectorCheckCapabilityV1 {
|
|
189
|
+
capabilityId: string;
|
|
190
|
+
/** The same P2 status a projection records for this capability. */
|
|
191
|
+
p2Status: typeof ARCHITECTURE_PROOF_P2_STATUSES[number];
|
|
192
|
+
diagnostics: Array<{ code: string; flowId?: string; stepId?: string; detail: string }>;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* `archctx flows check`: the P2 flow proof without rendering. Read-only. `ok` is true when no
|
|
197
|
+
* capability that declares a flow has an unprovable P2 proof.
|
|
198
|
+
*/
|
|
199
|
+
export interface ArchitectureFlowSelectorCheckV1 {
|
|
200
|
+
schemaVersion: typeof ARCHITECTURE_FLOW_SELECTOR_CHECK_SCHEMA_VERSION;
|
|
201
|
+
ok: boolean;
|
|
202
|
+
codeGraph: { availability: "ready" | "unavailable"; version: string };
|
|
203
|
+
summary: { selectors: number; proven: number; unproven: number; usedUnproven: number };
|
|
204
|
+
selectors: ArchitectureFlowSelectorCheckEntryV1[];
|
|
205
|
+
capabilities: ArchitectureFlowSelectorCheckCapabilityV1[];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** `files[].preview.format`: a `create` carries the rendered body, an `update` or `delete` a unified diff. */
|
|
209
|
+
export const PROJECTION_SLICE_SCHEMA_VERSION = "archcontext.projection-slice/v1" as const;
|
|
210
|
+
export const PROJECTION_FILE_PREVIEW_FORMATS = ["body", "unified-diff"] as const;
|
|
211
|
+
/** Upper bound, in UTF-8 bytes, on one `files[].preview.content`. */
|
|
212
|
+
export const PROJECTION_FILE_PREVIEW_MAX_BYTES = 65_536;
|
|
213
|
+
/** Upper bound, in UTF-8 bytes, on the sum of every `files[].preview.content` of one result. */
|
|
214
|
+
export const PROJECTION_PREVIEW_TOTAL_MAX_BYTES = 1_048_576;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Why a projection is not fresh (ADR-0056 §1). Shared by the engine's freshness evaluator and the
|
|
218
|
+
* `check` result's `freshness` field so the two can never disagree. `projection-output-changed`:
|
|
219
|
+
* a target renders an output other than its committed row's (`staleTargets`).
|
|
220
|
+
* `projection-manifest-changed`: every output equals its row, but the manifest the render would
|
|
221
|
+
* write differs from the committed bytes (the semantic baseline or a header line).
|
|
222
|
+
*/
|
|
223
|
+
export const PROJECTION_FRESHNESS_REASON_CODES = [
|
|
224
|
+
"projection-manifest-changed",
|
|
225
|
+
"projection-manifest-missing",
|
|
226
|
+
"projection-manifest-unreadable",
|
|
227
|
+
"projection-output-changed"
|
|
228
|
+
] as const;
|
|
229
|
+
|
|
230
|
+
/** The architecture debt a `check` or `plan` result reports. Debt is a finding, never a blocker. */
|
|
231
|
+
export const PROJECTION_ARCHITECTURE_DEBT_REASON_CODES = ["undeclared-dependency"] as const;
|
|
232
|
+
/**
|
|
233
|
+
* Why the debt read is not a complete observation. The `code-facts-*` codes mean what they mean on
|
|
234
|
+
* `archctx deps`; `workspace-resolution-failed` means the workspace package map was unreadable, so
|
|
235
|
+
* no bare workspace import specifier could be resolved.
|
|
236
|
+
*/
|
|
237
|
+
export const PROJECTION_ARCHITECTURE_DEBT_COVERAGE_REASON_CODES = [
|
|
238
|
+
"code-facts-import-limit",
|
|
239
|
+
"code-facts-truncated",
|
|
240
|
+
"code-facts-unavailable",
|
|
241
|
+
"workspace-resolution-failed"
|
|
242
|
+
] as const;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* How one target of a `check` or `plan` result changes (#327 finding 2), from the strongest reason
|
|
246
|
+
* down: `blocked` (a human must act before the target can be written: Phase 1 isolation, an orphan
|
|
247
|
+
* that needs review, an adoption or ownership rejection), `proof-change` (a known proof change,
|
|
248
|
+
* which a missing baseline never hides), `baseline-missing` (a comparison is unknown: no committed
|
|
249
|
+
* current-format manifest, or no committed row for the target), `semantic-change`, `output-change`
|
|
250
|
+
* and `unchanged`.
|
|
251
|
+
* `projectionTargetChangeClassification` is the one precedence rule.
|
|
252
|
+
*/
|
|
253
|
+
export const PROJECTION_TARGET_CHANGE_CLASSIFICATIONS = [
|
|
254
|
+
"baseline-missing",
|
|
255
|
+
"blocked",
|
|
256
|
+
"output-change",
|
|
257
|
+
"proof-change",
|
|
258
|
+
"semantic-change",
|
|
259
|
+
"unchanged"
|
|
260
|
+
] as const;
|
|
261
|
+
/** What the projection write does to the target's file: the result's own `files[]` decision for that path. */
|
|
262
|
+
export const PROJECTION_TARGET_CHANGE_PLANNED_ACTIONS = ["create", "delete", "none", "update"] as const;
|
|
263
|
+
/** The reason codes that block a target: no apply writes it until a human acts. */
|
|
264
|
+
export const PROJECTION_TARGET_CHANGE_BLOCKING_REASON_CODES = [
|
|
265
|
+
"adoption-required",
|
|
266
|
+
"ambiguous-ownership",
|
|
267
|
+
"orphan-review-required",
|
|
268
|
+
"unprovable-required-flow",
|
|
269
|
+
"verified-flow-proof-changed"
|
|
270
|
+
] as const;
|
|
271
|
+
/**
|
|
272
|
+
* Why a target is classified as it is. Each comparison flag has its codes: `semanticChanged` is `semantic-fingerprint-changed` or, for a target that
|
|
273
|
+
* describes the whole model, `model-digest-changed` (the committed `semanticBaseline.modelDigest`
|
|
274
|
+
* differs from the current model's); `proofChanged` is
|
|
275
|
+
* `flow-proof-changed` or `selector-evidence-changed`; `outputChanged` is `rendered-output-changed`
|
|
276
|
+
* (the rendered output differs from the committed row's `outputDigest`), `target-added`,
|
|
277
|
+
* `target-removed` or `file-bytes-changed` (the write changes the file although its rendered output
|
|
278
|
+
* is the committed one: a marker, a missing file, an edited region); an unknown comparison is
|
|
279
|
+
* `baseline-missing` or `target-row-missing`.
|
|
280
|
+
*/
|
|
281
|
+
export const PROJECTION_TARGET_CHANGE_REASON_CODES = [
|
|
282
|
+
"adoption-required",
|
|
283
|
+
"ambiguous-ownership",
|
|
284
|
+
"baseline-missing",
|
|
285
|
+
"file-bytes-changed",
|
|
286
|
+
"flow-proof-changed",
|
|
287
|
+
"model-digest-changed",
|
|
288
|
+
"orphan-review-required",
|
|
289
|
+
"rendered-output-changed",
|
|
290
|
+
"selector-evidence-changed",
|
|
291
|
+
"semantic-fingerprint-changed",
|
|
292
|
+
"target-added",
|
|
293
|
+
"target-removed",
|
|
294
|
+
"target-row-missing",
|
|
295
|
+
"unprovable-required-flow",
|
|
296
|
+
"verified-flow-proof-changed"
|
|
297
|
+
] as const;
|
|
298
|
+
|
|
299
|
+
export type ProjectionMode = (typeof PROJECTION_MODES)[number];
|
|
300
|
+
export type ProjectionTargetChangeClassification = (typeof PROJECTION_TARGET_CHANGE_CLASSIFICATIONS)[number];
|
|
301
|
+
export type ProjectionTargetChangePlannedAction = (typeof PROJECTION_TARGET_CHANGE_PLANNED_ACTIONS)[number];
|
|
302
|
+
export type ProjectionTargetChangeReasonCode = (typeof PROJECTION_TARGET_CHANGE_REASON_CODES)[number];
|
|
303
|
+
export type ProjectionFreshnessReasonCode = (typeof PROJECTION_FRESHNESS_REASON_CODES)[number];
|
|
304
|
+
export type ProjectionTarget = (typeof PROJECTION_TARGETS)[number];
|
|
305
|
+
export type ProjectionResultStatus = (typeof PROJECTION_RESULT_STATUSES)[number];
|
|
306
|
+
export type ProjectionPartialResultStatus = (typeof PROJECTION_PARTIAL_RESULT_STATUSES)[number];
|
|
307
|
+
export type ProjectionCoverageReasonCode = (typeof PROJECTION_COVERAGE_REASON_CODES)[number];
|
|
308
|
+
export type ProjectionHumanActionReasonCode = (typeof PROJECTION_HUMAN_ACTION_REASON_CODES)[number];
|
|
309
|
+
export type ProjectionPriorCommittedApplyOperation = (typeof PROJECTION_PRIOR_COMMITTED_APPLY_OPERATIONS)[number];
|
|
310
|
+
export type ArchitectureMajorChangeReasonCode = (typeof ARCHITECTURE_MAJOR_CHANGE_REASON_CODES)[number];
|
|
311
|
+
export type ArchitectureRefreshTarget = (typeof ARCHITECTURE_REFRESH_TARGETS)[number];
|
|
312
|
+
export type ArchctxFeature = (typeof ARCHCTX_FEATURES)[number];
|
|
313
|
+
export type ProjectionArchitectureDebtReasonCode = (typeof PROJECTION_ARCHITECTURE_DEBT_REASON_CODES)[number];
|
|
314
|
+
export type ProjectionArchitectureDebtCoverageReasonCode = (typeof PROJECTION_ARCHITECTURE_DEBT_COVERAGE_REASON_CODES)[number];
|
|
315
|
+
export type ArchitectureSemanticFacet = (typeof ARCHITECTURE_SEMANTIC_FACETS)[number];
|
|
316
|
+
export type ProjectionFilePreviewFormat = (typeof PROJECTION_FILE_PREVIEW_FORMATS)[number];
|
|
317
|
+
export type Sha256Digest = `sha256:${string}`;
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import type { ProjectionTargetFormat, ProjectionTargetOwnership, ProjectionTargetScopeKind, ProjectionTargetType } from "./ledger-records";
|
|
2
|
+
import type {
|
|
3
|
+
ARCHITECTURE_DOCS_RENDERER_VERSION,
|
|
4
|
+
ArchitectureSemanticFacet,
|
|
5
|
+
Sha256Digest
|
|
6
|
+
} from "./projection-constants";
|
|
7
|
+
import type {
|
|
8
|
+
ArchitectureCapabilityProofStatusV1,
|
|
9
|
+
ArchitectureDigestSetV2
|
|
10
|
+
} from "./projection-types";
|
|
11
|
+
import { digestJson, type Json } from "./schema";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The committed projection manifest, `docs/architecture/.projection-manifest.json` (#264). The
|
|
15
|
+
* projection engine writes it and reads its semantic baseline and per-target rows back; this module
|
|
16
|
+
* is the only definition of its shape, of its byte layout and of every value derived from it.
|
|
17
|
+
*
|
|
18
|
+
* `schemaVersion` is `v4` (ADR-0056). The file records no digest of raw source: a target row holds
|
|
19
|
+
* only what the render produced, so a source edit that changes no output, no proof evidence and no
|
|
20
|
+
* header line leaves the file byte-identical. Header lines change only on a protocol upgrade, the
|
|
21
|
+
* one Git-visible anchor is `semanticBaseline.modelDigest`, and every other line belongs to one
|
|
22
|
+
* capability or one target. Two pull requests that touch different capabilities therefore rewrite
|
|
23
|
+
* disjoint lines. The global digests a run still needs (flow proof, projection) are computed from
|
|
24
|
+
* the rows when the manifest is read (`architectureDocsProjectionManifestDigests`).
|
|
25
|
+
*
|
|
26
|
+
* A `v1`, `v2` or `v3` manifest is read only for its `schemaVersion` and refused with
|
|
27
|
+
* `projection-manifest-upgrade-required`; nothing else in it is read.
|
|
28
|
+
*/
|
|
29
|
+
export const ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSION = "archcontext.architecture-docs-projection-manifest/v4" as const;
|
|
30
|
+
/** Manifest versions earlier releases wrote. Only their `schemaVersion` is read, to refuse them. */
|
|
31
|
+
export const SUPERSEDED_ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSIONS = [
|
|
32
|
+
"archcontext.architecture-docs-projection-manifest/v1",
|
|
33
|
+
"archcontext.architecture-docs-projection-manifest/v2",
|
|
34
|
+
"archcontext.architecture-docs-projection-manifest/v3"
|
|
35
|
+
] as const;
|
|
36
|
+
/**
|
|
37
|
+
* The one-time re-baseline an operator runs after the migration preconditions in the runbook are
|
|
38
|
+
* met. The profile comes from the repository, not from a superseded manifest, so the command names
|
|
39
|
+
* both supported profiles instead of guessing.
|
|
40
|
+
*/
|
|
41
|
+
export const ARCHITECTURE_DOCS_PROJECTION_MANIFEST_UPGRADE_COMMAND = "archctx docs apply --approved --profile <default|repo-harness/v1>" as const;
|
|
42
|
+
/** The operator runbook that pairs a re-baseline with its prerequisites (model restoration, upgrade path, receipt drain). */
|
|
43
|
+
export const ARCHITECTURE_DOCS_PROJECTION_MANIFEST_MIGRATION_GUIDE = "docs/runbooks/architecture-documentation-projections.md" as const;
|
|
44
|
+
/** The reason code of a refused superseded manifest; the operator re-baselines once with `archctx docs apply --approved`. */
|
|
45
|
+
export const PROJECTION_MANIFEST_UPGRADE_REQUIRED = "projection-manifest-upgrade-required" as const;
|
|
46
|
+
/** The reason code of a current-format manifest that fails its contract; restore it from Git. */
|
|
47
|
+
export const PROJECTION_MANIFEST_INVALID = "projection-manifest-invalid" as const;
|
|
48
|
+
/** The reason code of a declared source footprint that no entity-summary or topology target documents. */
|
|
49
|
+
export const PROJECTION_FOOTPRINT_UNCOVERED = "projection-footprint-uncovered" as const;
|
|
50
|
+
export const ARCHITECTURE_DOCS_PROJECTION_PROVENANCE_SCHEMA_VERSION = "archcontext.architecture-docs-projection-provenance/v3" as const;
|
|
51
|
+
export const ARCHITECTURE_DOCS_LAYOUT_VERSION_V1 = "archcontext.docs-layout/v1" as const;
|
|
52
|
+
export const ARCHITECTURE_SEMANTIC_STATE_SCHEMA_VERSION = "archcontext.architecture-semantic-state/v1" as const;
|
|
53
|
+
export const ARCHITECTURE_DOCS_PROJECTION_PROFILES = ["default", "repo-harness/v1"] as const;
|
|
54
|
+
|
|
55
|
+
export type ArchitectureDocsProjectionProfile = (typeof ARCHITECTURE_DOCS_PROJECTION_PROFILES)[number];
|
|
56
|
+
|
|
57
|
+
export interface ArchitectureCapabilitySemanticStateV1 {
|
|
58
|
+
capabilityId: string;
|
|
59
|
+
memberNodeIds: string[];
|
|
60
|
+
semanticFingerprint: string;
|
|
61
|
+
flowProofFingerprint: string;
|
|
62
|
+
proofStatus: ArchitectureCapabilityProofStatusV1;
|
|
63
|
+
facets: Record<ArchitectureSemanticFacet, string>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface ArchitectureSemanticStateV1 {
|
|
67
|
+
schemaVersion: typeof ARCHITECTURE_SEMANTIC_STATE_SCHEMA_VERSION;
|
|
68
|
+
capabilities: ArchitectureCapabilitySemanticStateV1[];
|
|
69
|
+
semanticFingerprint: string;
|
|
70
|
+
flowProofFingerprint: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The inputs besides the model that the flow proofs of one projection were compiled from, per
|
|
75
|
+
* capability. Committed acceptance compares the manifest's value with a fresh measurement: a
|
|
76
|
+
* capability whose proof moved while its semantic fingerprint held is explained by the journaled
|
|
77
|
+
* model only when its selector-evidence digest and the renderer are unchanged (ADR-0056 §5).
|
|
78
|
+
*/
|
|
79
|
+
export interface ArchitectureProjectionProofEvidenceV2 {
|
|
80
|
+
rendererVersion: string;
|
|
81
|
+
/** Per capability: digest of the proof-relevant selector evidence its flows cite. */
|
|
82
|
+
selectorEvidenceDigests: Record<string, string>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Projection provenance of one run. Runtime only: receipts, recovery bindings and envelopes carry
|
|
87
|
+
* it, the committed manifest does not (#327). It records machine-independent values only: content
|
|
88
|
+
* digests of the model and the declared sources, plus renderer, layout and CodeGraph versions.
|
|
89
|
+
* HEAD, the full-worktree digest, the CodeGraph evidence digest, the indexed-worktree digest and
|
|
90
|
+
* the CodeGraph status are runtime snapshot facts (#277).
|
|
91
|
+
*/
|
|
92
|
+
export interface ArchitectureDocumentationProjectionProvenanceV3 {
|
|
93
|
+
schemaVersion: typeof ARCHITECTURE_DOCS_PROJECTION_PROVENANCE_SCHEMA_VERSION;
|
|
94
|
+
sourceTreeDigest: string;
|
|
95
|
+
modelDigest: string;
|
|
96
|
+
projectionInputDigest: string;
|
|
97
|
+
rendererVersion: typeof ARCHITECTURE_DOCS_RENDERER_VERSION;
|
|
98
|
+
layoutVersion: typeof ARCHITECTURE_DOCS_LAYOUT_VERSION_V1;
|
|
99
|
+
/** Reproducible CodeGraph identity only: package name and version (#266, #277). */
|
|
100
|
+
generatedFrom: ArchitectureDocsProjectionGeneratedFromV1;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export type ArchitectureDocsProjectionGeneratedFromV1 = {
|
|
104
|
+
codeGraphPackage: string;
|
|
105
|
+
codeGraphVersion: string;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* One target row of the committed manifest, keyed by `targetId`. The targetId and the renderer
|
|
110
|
+
* version are not repeated in the row: the key and the manifest header carry them. A row records
|
|
111
|
+
* no source state; its `outputDigest` is the target's freshness identity (ADR-0056 §1).
|
|
112
|
+
*/
|
|
113
|
+
export interface ArchitectureDocsProjectionManifestTargetV4 {
|
|
114
|
+
type: ProjectionTargetType;
|
|
115
|
+
scope: { kind: ProjectionTargetScopeKind; id?: string; entityKind?: string };
|
|
116
|
+
path: string;
|
|
117
|
+
ownership: ProjectionTargetOwnership;
|
|
118
|
+
format: ProjectionTargetFormat;
|
|
119
|
+
/** `digestJson({ targetId, body })` of the generated body: the region of a `mixed` target, the whole file of a `generated` one. */
|
|
120
|
+
outputDigest: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** One capability of the committed semantic baseline. */
|
|
124
|
+
export interface ArchitectureDocsProjectionManifestCapabilityV4 extends ArchitectureCapabilitySemanticStateV1 {
|
|
125
|
+
/** Digest of the proof-relevant selector evidence for the selectors this capability's flows cite. */
|
|
126
|
+
selectorEvidenceDigest: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface ArchitectureDocsProjectionManifestV4 {
|
|
130
|
+
schemaVersion: typeof ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSION;
|
|
131
|
+
/**
|
|
132
|
+
* The renderer that wrote this manifest. Any renderer is readable: a renderer bump re-renders
|
|
133
|
+
* the owned outputs (drift reports them stale) and the per-capability proof check compares it.
|
|
134
|
+
*/
|
|
135
|
+
rendererVersion: string;
|
|
136
|
+
/** Optional repository-declared engine floors; preserved by every render. */
|
|
137
|
+
minimumRendererVersion?: string;
|
|
138
|
+
minimumProtocolVersion?: string;
|
|
139
|
+
profile: ArchitectureDocsProjectionProfile;
|
|
140
|
+
layoutVersion: typeof ARCHITECTURE_DOCS_LAYOUT_VERSION_V1;
|
|
141
|
+
generatedFrom: ArchitectureDocsProjectionGeneratedFromV1;
|
|
142
|
+
semanticBaseline: {
|
|
143
|
+
/** The one Git-visible anchor: the digest of the model this baseline was compiled from. */
|
|
144
|
+
modelDigest: string;
|
|
145
|
+
/** Sorted and unique by capabilityId. */
|
|
146
|
+
capabilities: ArchitectureDocsProjectionManifestCapabilityV4[];
|
|
147
|
+
};
|
|
148
|
+
targets: Record<string, ArchitectureDocsProjectionManifestTargetV4>;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The whole-model targets that render the runtime topology (ADR-0049); they document its nodes' footprints. */
|
|
152
|
+
export const RUNTIME_TOPOLOGY_TARGET_TYPES = ["diagram-runtime-topology", "runtime-topology-summary"] as const satisfies readonly ProjectionTargetType[];
|
|
153
|
+
export function isRuntimeTopologyTargetType(type: unknown): type is (typeof RUNTIME_TOPOLOGY_TARGET_TYPES)[number] {
|
|
154
|
+
return typeof type === "string" && (RUNTIME_TOPOLOGY_TARGET_TYPES as readonly string[]).includes(type);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** True for a manifest version an earlier release wrote; such a manifest is refused, never read. */
|
|
158
|
+
export function isSupersededArchitectureDocsProjectionManifestSchemaVersion(schemaVersion: string | undefined): boolean {
|
|
159
|
+
return (SUPERSEDED_ARCHITECTURE_DOCS_PROJECTION_MANIFEST_SCHEMA_VERSIONS as readonly (string | undefined)[]).includes(schemaVersion);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The committed byte layout. JSON, with one rule beyond `JSON.stringify`: every value that one
|
|
164
|
+
* capability or one target owns sits on lines no other capability or target shares, and an
|
|
165
|
+
* unchanged line separates the lines of any two owners. Git merges two branches that touch
|
|
166
|
+
* different owners without a conflict, because a merge conflicts on adjacent changed lines too.
|
|
167
|
+
*/
|
|
168
|
+
export function serializeArchitectureDocsProjectionManifest(manifest: ArchitectureDocsProjectionManifestV4): string {
|
|
169
|
+
const capabilities = [...manifest.semanticBaseline.capabilities]
|
|
170
|
+
.sort((left, right) => compareStrings(left.capabilityId, right.capabilityId))
|
|
171
|
+
.map(canonicalCapability);
|
|
172
|
+
const capabilityBlock = JSON.stringify(capabilities, null, 2).split("\n").map((line, index) => index === 0 ? line : ` ${line}`).join("\n");
|
|
173
|
+
const targetIds = Object.keys(manifest.targets).sort(compareStrings);
|
|
174
|
+
const targetLines = targetIds.length === 0
|
|
175
|
+
? [" \"targets\": {}"]
|
|
176
|
+
: [
|
|
177
|
+
" \"targets\": {",
|
|
178
|
+
...targetIds.flatMap((targetId, index) => [
|
|
179
|
+
` ${JSON.stringify(targetId)}:`,
|
|
180
|
+
` ${JSON.stringify(canonicalTargetRow(manifest.targets[targetId]!))}${index === targetIds.length - 1 ? "" : ","}`
|
|
181
|
+
]),
|
|
182
|
+
" }"
|
|
183
|
+
];
|
|
184
|
+
return [
|
|
185
|
+
"{",
|
|
186
|
+
` "schemaVersion": ${JSON.stringify(manifest.schemaVersion)},`,
|
|
187
|
+
` "rendererVersion": ${JSON.stringify(manifest.rendererVersion)},`,
|
|
188
|
+
...(manifest.minimumRendererVersion === undefined ? [] : [` "minimumRendererVersion": ${JSON.stringify(manifest.minimumRendererVersion)},`]),
|
|
189
|
+
...(manifest.minimumProtocolVersion === undefined ? [] : [` "minimumProtocolVersion": ${JSON.stringify(manifest.minimumProtocolVersion)},`]),
|
|
190
|
+
` "profile": ${JSON.stringify(manifest.profile)},`,
|
|
191
|
+
` "layoutVersion": ${JSON.stringify(manifest.layoutVersion)},`,
|
|
192
|
+
` "generatedFrom": ${JSON.stringify({ codeGraphPackage: manifest.generatedFrom.codeGraphPackage, codeGraphVersion: manifest.generatedFrom.codeGraphVersion })},`,
|
|
193
|
+
" \"semanticBaseline\": {",
|
|
194
|
+
` "modelDigest": ${JSON.stringify(manifest.semanticBaseline.modelDigest)},`,
|
|
195
|
+
` "capabilities": ${capabilityBlock}`,
|
|
196
|
+
" },",
|
|
197
|
+
...targetLines,
|
|
198
|
+
"}",
|
|
199
|
+
""
|
|
200
|
+
].join("\n");
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** The runtime semantic state the baseline records: capability entries without their evidence, plus the two aggregates. */
|
|
204
|
+
export function architectureDocsProjectionManifestSemanticState(manifest: ArchitectureDocsProjectionManifestV4): ArchitectureSemanticStateV1 {
|
|
205
|
+
return architectureSemanticStateFromCapabilities(manifest.semanticBaseline.capabilities.map(({ selectorEvidenceDigest: _selectorEvidenceDigest, ...capability }) => capability));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Assembles a semantic state from its capability entries. The two aggregates are a function of
|
|
210
|
+
* the entries, so the committed manifest records only the entries and every reader recomputes them.
|
|
211
|
+
*/
|
|
212
|
+
export function architectureSemanticStateFromCapabilities(capabilities: readonly ArchitectureCapabilitySemanticStateV1[]): ArchitectureSemanticStateV1 {
|
|
213
|
+
const sorted = [...capabilities].sort((left, right) => compareStrings(left.capabilityId, right.capabilityId));
|
|
214
|
+
return {
|
|
215
|
+
schemaVersion: ARCHITECTURE_SEMANTIC_STATE_SCHEMA_VERSION,
|
|
216
|
+
capabilities: sorted,
|
|
217
|
+
semanticFingerprint: digestJson(sorted.map(({ capabilityId, semanticFingerprint }) => ({ capabilityId, semanticFingerprint })) as unknown as Json),
|
|
218
|
+
flowProofFingerprint: digestJson(sorted.map(({ capabilityId, flowProofFingerprint }) => ({ capabilityId, flowProofFingerprint })) as unknown as Json)
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** The proof evidence the baseline was compiled from, as `ArchitectureProjectionProofEvidenceV2`. */
|
|
223
|
+
export function architectureDocsProjectionManifestProofEvidence(manifest: ArchitectureDocsProjectionManifestV4): ArchitectureProjectionProofEvidenceV2 {
|
|
224
|
+
return {
|
|
225
|
+
rendererVersion: manifest.rendererVersion,
|
|
226
|
+
selectorEvidenceDigests: Object.fromEntries(manifest.semanticBaseline.capabilities.map((capability) => [capability.capabilityId, capability.selectorEvidenceDigest]))
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* The declared source tree digest of runtime provenance: the digest of every node's footprint
|
|
232
|
+
* digest, by node id. It binds the CodeGraph index and the expected snapshot to the measured tree
|
|
233
|
+
* and is never committed (ADR-0056 §4).
|
|
234
|
+
*/
|
|
235
|
+
export function architectureSourceTreeDigest(footprintDigests: Readonly<Record<string, string>>): Sha256Digest {
|
|
236
|
+
return digestJson({
|
|
237
|
+
schemaVersion: "archcontext.architecture-source-stamps/v1",
|
|
238
|
+
stamps: Object.keys(footprintDigests).sort(compareStrings).map((nodeId) => ({ nodeId, digest: footprintDigests[nodeId]! }))
|
|
239
|
+
} as unknown as Json) as Sha256Digest;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** The projection digest: renderer, profile and every target's output digest. */
|
|
243
|
+
export function architectureProjectionOutputsDigest(input: {
|
|
244
|
+
rendererVersion: string;
|
|
245
|
+
profile: string;
|
|
246
|
+
outputDigests: Readonly<Record<string, string>>;
|
|
247
|
+
}): Sha256Digest {
|
|
248
|
+
return digestJson({
|
|
249
|
+
schemaVersion: "archcontext.architecture-projection-outputs/v1",
|
|
250
|
+
rendererVersion: input.rendererVersion,
|
|
251
|
+
profile: input.profile,
|
|
252
|
+
outputs: Object.keys(input.outputDigests).sort(compareStrings).map((targetId) => ({ targetId, outputDigest: input.outputDigests[targetId]! }))
|
|
253
|
+
} as unknown as Json) as Sha256Digest;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** The global digests of a committed manifest, computed from its rows at read time. */
|
|
257
|
+
export function architectureDocsProjectionManifestDigests(manifest: ArchitectureDocsProjectionManifestV4): ArchitectureDigestSetV2 {
|
|
258
|
+
return {
|
|
259
|
+
modelDigest: manifest.semanticBaseline.modelDigest as Sha256Digest,
|
|
260
|
+
flowProofDigest: architectureDocsProjectionManifestSemanticState(manifest).flowProofFingerprint as Sha256Digest,
|
|
261
|
+
projectionDigest: architectureProjectionOutputsDigest({
|
|
262
|
+
rendererVersion: manifest.rendererVersion,
|
|
263
|
+
profile: manifest.profile,
|
|
264
|
+
outputDigests: Object.fromEntries(Object.entries(manifest.targets).map(([targetId, row]) => [targetId, row.outputDigest]))
|
|
265
|
+
})
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function canonicalCapability(capability: ArchitectureDocsProjectionManifestCapabilityV4): ArchitectureDocsProjectionManifestCapabilityV4 {
|
|
270
|
+
return {
|
|
271
|
+
capabilityId: capability.capabilityId,
|
|
272
|
+
memberNodeIds: [...capability.memberNodeIds],
|
|
273
|
+
semanticFingerprint: capability.semanticFingerprint,
|
|
274
|
+
flowProofFingerprint: capability.flowProofFingerprint,
|
|
275
|
+
proofStatus: { p1: capability.proofStatus.p1, p2: capability.proofStatus.p2 },
|
|
276
|
+
facets: Object.fromEntries(Object.keys(capability.facets).sort(compareStrings).map((facet) => [facet, capability.facets[facet as ArchitectureSemanticFacet]])) as Record<ArchitectureSemanticFacet, string>,
|
|
277
|
+
selectorEvidenceDigest: capability.selectorEvidenceDigest
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function canonicalTargetRow(row: ArchitectureDocsProjectionManifestTargetV4): ArchitectureDocsProjectionManifestTargetV4 {
|
|
282
|
+
return {
|
|
283
|
+
type: row.type,
|
|
284
|
+
scope: {
|
|
285
|
+
kind: row.scope.kind,
|
|
286
|
+
...(row.scope.id !== undefined ? { id: row.scope.id } : {}),
|
|
287
|
+
...(row.scope.entityKind !== undefined ? { entityKind: row.scope.entityKind } : {})
|
|
288
|
+
},
|
|
289
|
+
path: row.path,
|
|
290
|
+
ownership: row.ownership,
|
|
291
|
+
format: row.format,
|
|
292
|
+
outputDigest: row.outputDigest
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function compareStrings(left: string, right: string): number {
|
|
297
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
298
|
+
}
|