@granular-software/fractory 0.0.0-stage → 0.1.25
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/LICENSE +4 -0
- package/README.md +28 -2
- package/dist/activity-volume.d.ts +18 -0
- package/dist/activity-volume.js +94 -0
- package/dist/annotations.d.ts +122 -0
- package/dist/annotations.js +304 -0
- package/dist/benchmark-cli.d.ts +1 -0
- package/dist/benchmark-cli.js +95 -0
- package/dist/benchmark-worker.d.ts +2 -0
- package/dist/benchmark-worker.js +22 -0
- package/dist/benchmarks.d.ts +19 -0
- package/dist/benchmarks.js +414 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +63 -0
- package/dist/block-cli.d.ts +1 -0
- package/dist/block-cli.js +88 -0
- package/dist/block-documents.d.ts +35 -0
- package/dist/block-documents.js +84 -0
- package/dist/change-impact.d.ts +55 -0
- package/dist/change-impact.js +223 -0
- package/dist/check-source.d.ts +2 -0
- package/dist/check-source.js +66 -0
- package/dist/checks-model.d.ts +64 -0
- package/dist/checks-model.js +36 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +359 -0
- package/dist/code-model.d.ts +38 -0
- package/dist/code-model.js +94 -0
- package/dist/code-store.d.ts +9 -0
- package/dist/code-store.js +79 -0
- package/dist/compare-artifact.d.ts +6 -0
- package/dist/compare-artifact.js +277 -0
- package/dist/compare.d.ts +81 -0
- package/dist/compare.js +291 -0
- package/dist/compiler.d.ts +10 -0
- package/dist/compiler.js +1240 -0
- package/dist/compose.d.ts +9 -0
- package/dist/compose.js +72 -0
- package/dist/core.d.ts +87 -0
- package/dist/core.js +207 -0
- package/dist/coverage-cli.d.ts +1 -0
- package/dist/coverage-cli.js +42 -0
- package/dist/declaration-sources.d.ts +3 -0
- package/dist/declaration-sources.js +51 -0
- package/dist/declared-graph.d.ts +3 -0
- package/dist/declared-graph.js +67 -0
- package/dist/display-name.d.ts +2 -0
- package/dist/display-name.js +8 -0
- package/dist/error-heat.d.ts +58 -0
- package/dist/error-heat.js +96 -0
- package/dist/evidence.d.ts +3 -0
- package/dist/evidence.js +68 -0
- package/dist/factory-graph.d.ts +7 -0
- package/dist/factory-graph.js +389 -0
- package/dist/factory-model.d.ts +111 -0
- package/dist/factory-model.js +1 -0
- package/dist/git-code.d.ts +47 -0
- package/dist/git-code.js +352 -0
- package/dist/git-refs.d.ts +4 -0
- package/dist/git-refs.js +37 -0
- package/dist/history-activity.d.ts +4 -0
- package/dist/history-activity.js +129 -0
- package/dist/history-churn.d.ts +36 -0
- package/dist/history-churn.js +302 -0
- package/dist/history-git.d.ts +21 -0
- package/dist/history-git.js +125 -0
- package/dist/history-ledger.d.ts +43 -0
- package/dist/history-ledger.js +450 -0
- package/dist/history-ownership.d.ts +10 -0
- package/dist/history-ownership.js +75 -0
- package/dist/history-source.d.ts +13 -0
- package/dist/history-source.js +100 -0
- package/dist/integrations-cli.d.ts +2 -0
- package/dist/integrations-cli.js +159 -0
- package/dist/interface-map.d.ts +15 -0
- package/dist/interface-map.js +125 -0
- package/dist/issue-cache.d.ts +9 -0
- package/dist/issue-cache.js +68 -0
- package/dist/issue-cli.d.ts +1 -0
- package/dist/issue-cli.js +89 -0
- package/dist/issue-links.d.ts +15 -0
- package/dist/issue-links.js +125 -0
- package/dist/linear-issues.d.ts +19 -0
- package/dist/linear-issues.js +124 -0
- package/dist/local-runtime.d.ts +8 -0
- package/dist/local-runtime.js +59 -0
- package/dist/map-activity.d.ts +73 -0
- package/dist/map-activity.js +234 -0
- package/dist/map-model.d.ts +5 -0
- package/dist/map-model.js +166 -0
- package/dist/map-quality.d.ts +20 -0
- package/dist/map-quality.js +61 -0
- package/dist/mapping-coverage.d.ts +87 -0
- package/dist/mapping-coverage.js +404 -0
- package/dist/model.d.ts +186 -0
- package/dist/model.js +66 -0
- package/dist/operation-benchmark-worker.d.ts +2 -0
- package/dist/operation-benchmark-worker.js +60 -0
- package/dist/operation-benchmark.d.ts +29 -0
- package/dist/operation-benchmark.js +1 -0
- package/dist/otel-metrics.d.ts +21 -0
- package/dist/otel-metrics.js +146 -0
- package/dist/performance-model.d.ts +185 -0
- package/dist/performance-model.js +396 -0
- package/dist/product-map.d.ts +71 -0
- package/dist/product-map.js +197 -0
- package/dist/provider-access.cjs +207 -0
- package/dist/provider-access.d.cts +14 -0
- package/dist/public-boundaries.d.ts +13 -0
- package/dist/public-boundaries.js +115 -0
- package/dist/reports-cli.d.ts +1 -0
- package/dist/reports-cli.js +111 -0
- package/dist/reports-model.d.ts +27 -0
- package/dist/reports-model.js +39 -0
- package/dist/reports.d.ts +23 -0
- package/dist/reports.js +223 -0
- package/dist/repository-map.d.ts +22 -0
- package/dist/repository-map.js +153 -0
- package/dist/resource-cache.d.ts +17 -0
- package/dist/resource-cache.js +65 -0
- package/dist/review-cli.d.ts +19 -0
- package/dist/review-cli.js +224 -0
- package/dist/review.d.ts +48 -0
- package/dist/review.js +289 -0
- package/dist/runtime-metrics.d.ts +26 -0
- package/dist/runtime-metrics.js +290 -0
- package/dist/scope.d.ts +14 -0
- package/dist/scope.js +168 -0
- package/dist/sentry-activity.d.ts +39 -0
- package/dist/sentry-activity.js +174 -0
- package/dist/sentry.d.ts +130 -0
- package/dist/sentry.js +369 -0
- package/dist/service-release.d.ts +16 -0
- package/dist/service-release.js +14 -0
- package/dist/setup-cli.d.ts +2 -0
- package/dist/setup-cli.js +52 -0
- package/dist/setup-kit.cjs +163 -0
- package/dist/setup-kit.d.cts +32 -0
- package/dist/source-index.d.ts +37 -0
- package/dist/source-index.js +170 -0
- package/dist/source-review-git.d.ts +7 -0
- package/dist/source-review-git.js +105 -0
- package/dist/source-review.d.ts +18 -0
- package/dist/source-review.js +573 -0
- package/dist/telemetry.d.ts +17 -0
- package/dist/telemetry.js +51 -0
- package/dist/time-window.d.ts +9 -0
- package/dist/time-window.js +35 -0
- package/dist/trace-evidence.d.ts +23 -0
- package/dist/trace-evidence.js +55 -0
- package/dist/trace-model.d.ts +26 -0
- package/dist/trace-model.js +1 -0
- package/dist/tracing.d.ts +44 -0
- package/dist/tracing.js +123 -0
- package/dist/work-check.d.ts +18 -0
- package/dist/work-check.js +115 -0
- package/dist/work-cli.d.ts +1 -0
- package/dist/work-cli.js +176 -0
- package/dist/work-context.d.ts +59 -0
- package/dist/work-context.js +594 -0
- package/dist/work-intents.d.ts +6 -0
- package/dist/work-intents.js +140 -0
- package/dist/work-items.d.ts +58 -0
- package/dist/work-items.js +86 -0
- package/dist/work-lock-check.d.ts +12 -0
- package/dist/work-lock-check.js +339 -0
- package/dist/work-locks.d.ts +10 -0
- package/dist/work-locks.js +98 -0
- package/dist/work-model.d.ts +119 -0
- package/dist/work-model.js +310 -0
- package/dist/work-review-git.d.ts +8 -0
- package/dist/work-review-git.js +111 -0
- package/dist/work-review.d.ts +26 -0
- package/dist/work-review.js +426 -0
- package/dist/work-switcher-model.d.ts +43 -0
- package/dist/work-switcher-model.js +79 -0
- package/dist/work-switcher.d.ts +6 -0
- package/dist/work-switcher.js +171 -0
- package/dist/working-cli.d.ts +1 -0
- package/dist/working-cli.js +33 -0
- package/dist/working-code.d.ts +74 -0
- package/dist/working-code.js +421 -0
- package/dist/workspace-notes.d.ts +71 -0
- package/dist/workspace-notes.js +177 -0
- package/dist/workspace-tests.d.ts +21 -0
- package/dist/workspace-tests.js +573 -0
- package/package.json +547 -4
- package/src/activity-volume.ts +149 -0
- package/src/annotations.ts +485 -0
- package/src/benchmark-cli.ts +118 -0
- package/src/benchmark-worker.ts +22 -0
- package/src/benchmarks.ts +493 -0
- package/src/bin.ts +54 -0
- package/src/block-cli.ts +106 -0
- package/src/block-documents.ts +117 -0
- package/src/change-impact.ts +280 -0
- package/src/check-source.ts +82 -0
- package/src/checks-model.ts +108 -0
- package/src/cli.ts +440 -0
- package/src/code-model.ts +159 -0
- package/src/code-store.ts +98 -0
- package/src/compare-artifact.ts +314 -0
- package/src/compare.ts +440 -0
- package/src/compiler.ts +1512 -0
- package/src/compose.ts +94 -0
- package/src/core.ts +361 -0
- package/src/coverage-cli.ts +52 -0
- package/src/declaration-sources.ts +69 -0
- package/src/declared-graph.ts +75 -0
- package/src/display-name.ts +8 -0
- package/src/error-heat.ts +161 -0
- package/src/evidence.ts +94 -0
- package/src/factory-graph.ts +462 -0
- package/src/factory-model.ts +82 -0
- package/src/git-code.ts +461 -0
- package/src/git-refs.ts +43 -0
- package/src/history-activity.ts +146 -0
- package/src/history-churn.ts +416 -0
- package/src/history-git.ts +163 -0
- package/src/history-ledger.ts +636 -0
- package/src/history-ownership.ts +116 -0
- package/src/history-source.ts +117 -0
- package/src/integrations-cli.ts +187 -0
- package/src/interface-map.ts +166 -0
- package/src/issue-cache.ts +96 -0
- package/src/issue-cli.ts +137 -0
- package/src/issue-links.ts +153 -0
- package/src/linear-issues.ts +154 -0
- package/src/local-runtime.ts +70 -0
- package/src/map-activity.ts +309 -0
- package/src/map-model.ts +213 -0
- package/src/map-quality.ts +66 -0
- package/src/mapping-coverage.ts +570 -0
- package/src/model.ts +228 -0
- package/src/operation-benchmark-worker.ts +60 -0
- package/src/operation-benchmark.ts +28 -0
- package/src/otel-metrics.ts +176 -0
- package/src/performance-model.ts +575 -0
- package/src/product-map.ts +271 -0
- package/src/provider-access.cjs +207 -0
- package/src/provider-access.d.cts +14 -0
- package/src/public-boundaries.ts +143 -0
- package/src/reports-cli.ts +125 -0
- package/src/reports-model.ts +73 -0
- package/src/reports.ts +276 -0
- package/src/repository-map.ts +191 -0
- package/src/resource-cache.ts +76 -0
- package/src/review-cli.ts +256 -0
- package/src/review.ts +376 -0
- package/src/runtime-metrics.ts +386 -0
- package/src/scope.ts +192 -0
- package/src/sentry-activity.ts +234 -0
- package/src/sentry.ts +545 -0
- package/src/service-release.ts +18 -0
- package/src/setup-cli.ts +58 -0
- package/src/setup-kit.cjs +163 -0
- package/src/setup-kit.d.cts +32 -0
- package/src/source-index.ts +208 -0
- package/src/source-review-git.ts +131 -0
- package/src/source-review.ts +736 -0
- package/src/telemetry.ts +68 -0
- package/src/time-window.ts +51 -0
- package/src/trace-evidence.ts +80 -0
- package/src/trace-model.ts +26 -0
- package/src/tracing.ts +165 -0
- package/src/work-check.ts +149 -0
- package/src/work-cli.ts +229 -0
- package/src/work-context.ts +753 -0
- package/src/work-intents.ts +196 -0
- package/src/work-items.ts +151 -0
- package/src/work-lock-check.ts +549 -0
- package/src/work-locks.ts +108 -0
- package/src/work-model.ts +466 -0
- package/src/work-review-git.ts +130 -0
- package/src/work-review.ts +573 -0
- package/src/work-switcher-model.ts +121 -0
- package/src/work-switcher.ts +191 -0
- package/src/working-cli.ts +38 -0
- package/src/working-code.ts +582 -0
- package/src/workspace-notes.ts +203 -0
- package/src/workspace-tests.ts +654 -0
- package/toolkit/GUIDE.md +354 -0
- package/toolkit/SKILL.md +142 -0
- package/toolkit/bin/fractory +2 -0
- package/toolkit/build.json +1 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { FactoryComparison } from "./compare";
|
|
3
|
+
import type { FactoryFootprint } from "./review";
|
|
4
|
+
const sha = z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/);
|
|
5
|
+
const id = z
|
|
6
|
+
.string()
|
|
7
|
+
.min(1)
|
|
8
|
+
.max(1000)
|
|
9
|
+
.refine(
|
|
10
|
+
(value) => !["__proto__", "constructor", "prototype"].includes(value),
|
|
11
|
+
);
|
|
12
|
+
const source = z.object({
|
|
13
|
+
file: z.string(),
|
|
14
|
+
line: z.number().int().positive(),
|
|
15
|
+
digest: z.string(),
|
|
16
|
+
symbol: z.string().optional(),
|
|
17
|
+
scope: z.literal("file").optional(),
|
|
18
|
+
});
|
|
19
|
+
const artifact = z.object({
|
|
20
|
+
id,
|
|
21
|
+
label: z.string(),
|
|
22
|
+
description: z.string().optional(),
|
|
23
|
+
source: source.optional(),
|
|
24
|
+
sources: z.array(source).optional(),
|
|
25
|
+
});
|
|
26
|
+
const element = z.object({
|
|
27
|
+
id,
|
|
28
|
+
label: z.string(),
|
|
29
|
+
kind: z.enum(["block", "interface", "method", "process"]),
|
|
30
|
+
parent: id.optional(),
|
|
31
|
+
provenance: z.enum(["declared", "source", "inferred", "observed"]),
|
|
32
|
+
description: z.string().optional(),
|
|
33
|
+
signature: z.string().optional(),
|
|
34
|
+
source: source.optional(),
|
|
35
|
+
sources: z.array(source).optional(),
|
|
36
|
+
hosting: z.string().optional(),
|
|
37
|
+
implementationBlock: id.optional(),
|
|
38
|
+
contract: z
|
|
39
|
+
.object({
|
|
40
|
+
id: z.string(),
|
|
41
|
+
input: z.unknown().optional(),
|
|
42
|
+
output: z.unknown().optional(),
|
|
43
|
+
})
|
|
44
|
+
.optional(),
|
|
45
|
+
attachments: z
|
|
46
|
+
.object({
|
|
47
|
+
docs: z.array(z.string()),
|
|
48
|
+
tests: z.array(z.string()),
|
|
49
|
+
benchmarks: z.array(z.string()).optional(),
|
|
50
|
+
description: z.string().optional(),
|
|
51
|
+
auth: z.object({ symbol: z.string(), source }).optional(),
|
|
52
|
+
})
|
|
53
|
+
.optional(),
|
|
54
|
+
resources: z.array(artifact).optional(),
|
|
55
|
+
outputs: z.array(artifact).optional(),
|
|
56
|
+
});
|
|
57
|
+
const edge = z.object({
|
|
58
|
+
id,
|
|
59
|
+
source: id,
|
|
60
|
+
target: id,
|
|
61
|
+
relation: z.enum([
|
|
62
|
+
"exposes",
|
|
63
|
+
"flows",
|
|
64
|
+
"calls",
|
|
65
|
+
"renders",
|
|
66
|
+
"callbacks",
|
|
67
|
+
"delegates",
|
|
68
|
+
"resumes",
|
|
69
|
+
"requires",
|
|
70
|
+
"reads",
|
|
71
|
+
"writes",
|
|
72
|
+
"produces",
|
|
73
|
+
"loads",
|
|
74
|
+
]),
|
|
75
|
+
label: z.string(),
|
|
76
|
+
displayLabel: z.string().optional(),
|
|
77
|
+
provenance: z.enum(["declared", "source", "inferred", "observed"]),
|
|
78
|
+
sourceRef: source.optional(),
|
|
79
|
+
sources: z.array(source).optional(),
|
|
80
|
+
transport: z.string().optional(),
|
|
81
|
+
bidirectional: z.boolean().optional(),
|
|
82
|
+
condition: z.string().optional(),
|
|
83
|
+
overview: z.boolean().optional(),
|
|
84
|
+
artifacts: z.array(artifact).optional(),
|
|
85
|
+
exchange: z
|
|
86
|
+
.object({
|
|
87
|
+
inputs: z.array(z.object({ name: z.string(), type: z.string() })),
|
|
88
|
+
output: z.string().optional(),
|
|
89
|
+
})
|
|
90
|
+
.optional(),
|
|
91
|
+
});
|
|
92
|
+
const kind = z.enum(["added", "removed", "modified"]);
|
|
93
|
+
const schema = z.object({
|
|
94
|
+
schema: z.literal("fractal.comparison.v1"),
|
|
95
|
+
context: z
|
|
96
|
+
.object({
|
|
97
|
+
title: z.string().max(500),
|
|
98
|
+
url: z
|
|
99
|
+
.string()
|
|
100
|
+
.url()
|
|
101
|
+
.refine((url) => url.startsWith("https://"))
|
|
102
|
+
.optional(),
|
|
103
|
+
})
|
|
104
|
+
.optional(),
|
|
105
|
+
before: z.object({ commit: sha, id: z.string(), at: z.string() }),
|
|
106
|
+
after: z.object({ commit: sha, id: z.string(), at: z.string() }),
|
|
107
|
+
graph: z.object({
|
|
108
|
+
schema: z.literal("fractal.definition.v1"),
|
|
109
|
+
id,
|
|
110
|
+
revision: z.string(),
|
|
111
|
+
codeRevision: sha.optional(),
|
|
112
|
+
generatedAt: z.string(),
|
|
113
|
+
scope: z.string(),
|
|
114
|
+
basis: z.literal("repository-review").optional(),
|
|
115
|
+
elements: z.array(element).max(20000),
|
|
116
|
+
connections: z.array(edge).max(100000),
|
|
117
|
+
tests: z
|
|
118
|
+
.array(
|
|
119
|
+
z.object({
|
|
120
|
+
id,
|
|
121
|
+
name: z.string(),
|
|
122
|
+
source,
|
|
123
|
+
targets: z.array(id),
|
|
124
|
+
association: z.enum(["imports", "contract-reference", "attachment"]),
|
|
125
|
+
status: z.literal("not_run"),
|
|
126
|
+
}),
|
|
127
|
+
)
|
|
128
|
+
.max(20000),
|
|
129
|
+
failures: z.array(z.unknown()).transform(() => []),
|
|
130
|
+
gaps: z.array(z.unknown()).transform(() => []),
|
|
131
|
+
}),
|
|
132
|
+
elements: z.record(
|
|
133
|
+
id,
|
|
134
|
+
z.object({
|
|
135
|
+
kind,
|
|
136
|
+
fields: z.array(z.string()),
|
|
137
|
+
before: element.optional(),
|
|
138
|
+
after: element.optional(),
|
|
139
|
+
source: z.array(
|
|
140
|
+
z.object({
|
|
141
|
+
side: z.enum(["before", "after"]),
|
|
142
|
+
file: z.string(),
|
|
143
|
+
start: z.number().int().nonnegative(),
|
|
144
|
+
count: z.number().int().nonnegative(),
|
|
145
|
+
digest: z.string().max(128).optional(),
|
|
146
|
+
matches: z.array(
|
|
147
|
+
z.object({ status: z.string(), elementIds: z.array(id) }),
|
|
148
|
+
),
|
|
149
|
+
}),
|
|
150
|
+
),
|
|
151
|
+
}),
|
|
152
|
+
),
|
|
153
|
+
connections: z.record(
|
|
154
|
+
id,
|
|
155
|
+
z.object({ kind, before: edge.optional(), after: edge.optional() }),
|
|
156
|
+
),
|
|
157
|
+
marks: z.record(
|
|
158
|
+
id,
|
|
159
|
+
z.object({
|
|
160
|
+
kind,
|
|
161
|
+
added: z.number().nonnegative(),
|
|
162
|
+
removed: z.number().nonnegative(),
|
|
163
|
+
modified: z.number().nonnegative(),
|
|
164
|
+
own: z.boolean(),
|
|
165
|
+
connections: z.number().nonnegative().optional(),
|
|
166
|
+
}),
|
|
167
|
+
),
|
|
168
|
+
summary: z.object({
|
|
169
|
+
added: z.number(),
|
|
170
|
+
removed: z.number(),
|
|
171
|
+
modified: z.number(),
|
|
172
|
+
interfaces: z.number(),
|
|
173
|
+
connections: z.number(),
|
|
174
|
+
}),
|
|
175
|
+
evidence: z.object({
|
|
176
|
+
source: z.enum(["git-hunks", "unavailable"]),
|
|
177
|
+
ambiguous: z.number(),
|
|
178
|
+
unmapped: z.number(),
|
|
179
|
+
snapshotGaps: z.number(),
|
|
180
|
+
}),
|
|
181
|
+
range: z
|
|
182
|
+
.object({
|
|
183
|
+
base: sha,
|
|
184
|
+
head: sha,
|
|
185
|
+
mode: z.enum(["commits", "pr"]),
|
|
186
|
+
mergeBase: sha.optional(),
|
|
187
|
+
})
|
|
188
|
+
.optional(),
|
|
189
|
+
});
|
|
190
|
+
/** CI reports contain data only. Strip unknown fields and never execute imported code. */
|
|
191
|
+
export function readComparisonReport(value: unknown): FactoryComparison {
|
|
192
|
+
const result = schema.parse(value);
|
|
193
|
+
const ids = new Set(result.graph.elements.map((node) => node.id));
|
|
194
|
+
if (ids.size !== result.graph.elements.length || !ids.has(result.graph.id))
|
|
195
|
+
throw Error("Invalid factory identities in comparison report");
|
|
196
|
+
const byId = new Map(result.graph.elements.map((node) => [node.id, node]));
|
|
197
|
+
for (const node of byId.values()) {
|
|
198
|
+
let current: typeof node | undefined = node;
|
|
199
|
+
const seen = new Set<string>();
|
|
200
|
+
while (current) {
|
|
201
|
+
if (seen.has(current.id)) throw Error("Cyclic block nesting in report");
|
|
202
|
+
seen.add(current.id);
|
|
203
|
+
if (seen.size > 128)
|
|
204
|
+
throw Error("Block nesting exceeds the report depth limit");
|
|
205
|
+
if (current.parent && !ids.has(current.parent))
|
|
206
|
+
throw Error("Missing parent in report");
|
|
207
|
+
current = byId.get(current.parent || "");
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (
|
|
211
|
+
result.graph.connections.some(
|
|
212
|
+
(connection) =>
|
|
213
|
+
!ids.has(connection.source) || !ids.has(connection.target),
|
|
214
|
+
)
|
|
215
|
+
)
|
|
216
|
+
throw Error("Missing connection endpoint in report");
|
|
217
|
+
if (
|
|
218
|
+
Object.keys(result.elements).some((key) => !ids.has(key)) ||
|
|
219
|
+
Object.keys(result.marks).some((key) => !ids.has(key))
|
|
220
|
+
)
|
|
221
|
+
throw Error("Unknown changed block in report");
|
|
222
|
+
return result as FactoryComparison;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** File-only reports never pretend to contain a historical factory. Reuse the graph safety checks. */
|
|
226
|
+
export function readFootprintReport(value: unknown): FactoryFootprint {
|
|
227
|
+
const result = z
|
|
228
|
+
.object({
|
|
229
|
+
schema: z.literal("fractal.footprint.v1"),
|
|
230
|
+
mappingRevision: sha.optional(),
|
|
231
|
+
concepts: z
|
|
232
|
+
.object({
|
|
233
|
+
basis: z.literal("saved-code"),
|
|
234
|
+
historicalOwnership: z.boolean(),
|
|
235
|
+
unassigned: z.array(z.string().max(4000)).max(20000),
|
|
236
|
+
changes: z
|
|
237
|
+
.array(
|
|
238
|
+
z.object({
|
|
239
|
+
kind: z.enum([
|
|
240
|
+
"implementation",
|
|
241
|
+
"interface",
|
|
242
|
+
"connection",
|
|
243
|
+
"mapping",
|
|
244
|
+
"support",
|
|
245
|
+
]),
|
|
246
|
+
block: z.string().max(1000),
|
|
247
|
+
file: z.string().max(4000),
|
|
248
|
+
label: z.string().max(500),
|
|
249
|
+
before: z.string().max(1800).optional(),
|
|
250
|
+
after: z.string().max(1800).optional(),
|
|
251
|
+
connection:
|
|
252
|
+
schema.shape.graph.shape.connections.element.optional(),
|
|
253
|
+
change: z.enum(["added", "removed", "modified"]).optional(),
|
|
254
|
+
}),
|
|
255
|
+
)
|
|
256
|
+
.max(100000),
|
|
257
|
+
})
|
|
258
|
+
.optional(),
|
|
259
|
+
graph: schema.shape.graph,
|
|
260
|
+
base: sha,
|
|
261
|
+
head: sha,
|
|
262
|
+
title: z.string().max(500).optional(),
|
|
263
|
+
url: z
|
|
264
|
+
.string()
|
|
265
|
+
.url()
|
|
266
|
+
.refine((url) => url.startsWith("https://"))
|
|
267
|
+
.optional(),
|
|
268
|
+
files: z
|
|
269
|
+
.array(
|
|
270
|
+
z.object({
|
|
271
|
+
path: z.string().min(1).max(4000),
|
|
272
|
+
status: z.enum(["added", "removed", "modified"]),
|
|
273
|
+
digest: z.string().max(150).optional(),
|
|
274
|
+
}),
|
|
275
|
+
)
|
|
276
|
+
.max(20000),
|
|
277
|
+
})
|
|
278
|
+
.parse(value);
|
|
279
|
+
readComparisonReport({
|
|
280
|
+
schema: "fractal.comparison.v1",
|
|
281
|
+
before: { commit: result.base, id: "validation", at: "" },
|
|
282
|
+
after: { commit: result.head, id: "validation", at: "" },
|
|
283
|
+
graph: result.graph,
|
|
284
|
+
elements: {},
|
|
285
|
+
connections: {},
|
|
286
|
+
marks: {},
|
|
287
|
+
summary: {
|
|
288
|
+
added: 0,
|
|
289
|
+
removed: 0,
|
|
290
|
+
modified: 0,
|
|
291
|
+
interfaces: 0,
|
|
292
|
+
connections: 0,
|
|
293
|
+
},
|
|
294
|
+
evidence: {
|
|
295
|
+
source: "unavailable",
|
|
296
|
+
ambiguous: 0,
|
|
297
|
+
unmapped: 0,
|
|
298
|
+
snapshotGaps: 0,
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
if (
|
|
302
|
+
result.mappingRevision &&
|
|
303
|
+
(result.mappingRevision !== result.head ||
|
|
304
|
+
result.graph.codeRevision !== result.head)
|
|
305
|
+
)
|
|
306
|
+
throw Error(
|
|
307
|
+
"Source review must identify the same head revision as its source graph",
|
|
308
|
+
);
|
|
309
|
+
if (
|
|
310
|
+
new Set(result.files.map((file) => file.path)).size !== result.files.length
|
|
311
|
+
)
|
|
312
|
+
throw Error("Duplicate footprint paths");
|
|
313
|
+
return result as FactoryFootprint;
|
|
314
|
+
}
|