semantic-atlas 0.1.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/.agents/skills/semantic-atlas/SKILL.md +172 -0
- package/.agents/skills/semantic-atlas/references/graph-patch.md +109 -0
- package/.agents/skills/semantic-atlas/references/result-routing.md +91 -0
- package/LICENSE +21 -0
- package/README.md +118 -0
- package/dist/business-flow/business-flow-derivation-service.d.ts +11 -0
- package/dist/business-flow/business-flow-derivation-service.d.ts.map +1 -0
- package/dist/business-flow/business-flow-derivation-service.js +151 -0
- package/dist/business-flow/business-flow-draft.d.ts +16 -0
- package/dist/business-flow/business-flow-draft.d.ts.map +1 -0
- package/dist/business-flow/business-flow-draft.js +150 -0
- package/dist/business-flow/framework-business-strategy.d.ts +7 -0
- package/dist/business-flow/framework-business-strategy.d.ts.map +1 -0
- package/dist/business-flow/framework-business-strategy.js +1 -0
- package/dist/business-flow/strategies/bullmq-business-strategy.d.ts +10 -0
- package/dist/business-flow/strategies/bullmq-business-strategy.d.ts.map +1 -0
- package/dist/business-flow/strategies/bullmq-business-strategy.js +79 -0
- package/dist/business-flow/strategies/called-operation-derivation.d.ts +13 -0
- package/dist/business-flow/strategies/called-operation-derivation.d.ts.map +1 -0
- package/dist/business-flow/strategies/called-operation-derivation.js +32 -0
- package/dist/business-flow/strategies/graphql-business-strategy.d.ts +8 -0
- package/dist/business-flow/strategies/graphql-business-strategy.d.ts.map +1 -0
- package/dist/business-flow/strategies/graphql-business-strategy.js +65 -0
- package/dist/business-flow/strategies/nestjs-business-strategy.d.ts +8 -0
- package/dist/business-flow/strategies/nestjs-business-strategy.d.ts.map +1 -0
- package/dist/business-flow/strategies/nestjs-business-strategy.js +72 -0
- package/dist/business-flow/strategies/strategy-helpers.d.ts +32 -0
- package/dist/business-flow/strategies/strategy-helpers.d.ts.map +1 -0
- package/dist/business-flow/strategies/strategy-helpers.js +49 -0
- package/dist/business-flow/strategies/typeorm-business-strategy.d.ts +10 -0
- package/dist/business-flow/strategies/typeorm-business-strategy.d.ts.map +1 -0
- package/dist/business-flow/strategies/typeorm-business-strategy.js +136 -0
- package/dist/business-flow/strategies/verified-invariant-strategy.d.ts +5 -0
- package/dist/business-flow/strategies/verified-invariant-strategy.d.ts.map +1 -0
- package/dist/business-flow/strategies/verified-invariant-strategy.js +38 -0
- package/dist/business-flow/strategies/verified-test-strategy.d.ts +5 -0
- package/dist/business-flow/strategies/verified-test-strategy.d.ts.map +1 -0
- package/dist/business-flow/strategies/verified-test-strategy.js +26 -0
- package/dist/business-flow/structural-flow-catalog.d.ts +21 -0
- package/dist/business-flow/structural-flow-catalog.d.ts.map +1 -0
- package/dist/business-flow/structural-flow-catalog.js +125 -0
- package/dist/business-flow/types.d.ts +51 -0
- package/dist/business-flow/types.d.ts.map +1 -0
- package/dist/business-flow/types.js +1 -0
- package/dist/cli/argument-parser.d.ts +3 -0
- package/dist/cli/argument-parser.d.ts.map +1 -0
- package/dist/cli/argument-parser.js +174 -0
- package/dist/cli/bin.d.ts +3 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +23 -0
- package/dist/cli/cli-application.d.ts +38 -0
- package/dist/cli/cli-application.d.ts.map +1 -0
- package/dist/cli/cli-application.js +515 -0
- package/dist/cli/cli-error.d.ts +12 -0
- package/dist/cli/cli-error.d.ts.map +1 -0
- package/dist/cli/cli-error.js +44 -0
- package/dist/cli/cli-presenter.d.ts +14 -0
- package/dist/cli/cli-presenter.d.ts.map +1 -0
- package/dist/cli/cli-presenter.js +36 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +45 -0
- package/dist/cli/types.d.ts +46 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +1 -0
- package/dist/contracts/cli.d.ts +2139 -0
- package/dist/contracts/cli.d.ts.map +1 -0
- package/dist/contracts/cli.js +232 -0
- package/dist/contracts/graph.d.ts +262 -0
- package/dist/contracts/graph.d.ts.map +1 -0
- package/dist/contracts/graph.js +182 -0
- package/dist/contracts/identifiers.d.ts +4 -0
- package/dist/contracts/identifiers.d.ts.map +1 -0
- package/dist/contracts/identifiers.js +7 -0
- package/dist/contracts/public-contracts.d.ts +4 -0
- package/dist/contracts/public-contracts.d.ts.map +1 -0
- package/dist/contracts/public-contracts.js +3 -0
- package/dist/evaluation/comparison.d.ts +30 -0
- package/dist/evaluation/comparison.d.ts.map +1 -0
- package/dist/evaluation/comparison.js +108 -0
- package/dist/evaluation/contracts.d.ts +204 -0
- package/dist/evaluation/contracts.d.ts.map +1 -0
- package/dist/evaluation/contracts.js +269 -0
- package/dist/graph/graph-store.d.ts +47 -0
- package/dist/graph/graph-store.d.ts.map +1 -0
- package/dist/graph/graph-store.js +719 -0
- package/dist/graph/types.d.ts +168 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/knowledge/business-knowledge-service.d.ts +24 -0
- package/dist/knowledge/business-knowledge-service.d.ts.map +1 -0
- package/dist/knowledge/business-knowledge-service.js +200 -0
- package/dist/knowledge/graph-patch-conflict-error.d.ts +8 -0
- package/dist/knowledge/graph-patch-conflict-error.d.ts.map +1 -0
- package/dist/knowledge/graph-patch-conflict-error.js +12 -0
- package/dist/knowledge/structural-target-binding.d.ts +14 -0
- package/dist/knowledge/structural-target-binding.d.ts.map +1 -0
- package/dist/knowledge/structural-target-binding.js +11 -0
- package/dist/repository/git-command.d.ts +3 -0
- package/dist/repository/git-command.d.ts.map +1 -0
- package/dist/repository/git-command.js +25 -0
- package/dist/repository/repository-inspector.d.ts +7 -0
- package/dist/repository/repository-inspector.d.ts.map +1 -0
- package/dist/repository/repository-inspector.js +84 -0
- package/dist/repository/repository-language-support.d.ts +14 -0
- package/dist/repository/repository-language-support.d.ts.map +1 -0
- package/dist/repository/repository-language-support.js +64 -0
- package/dist/repository/types.d.ts +9 -0
- package/dist/repository/types.d.ts.map +1 -0
- package/dist/repository/types.js +1 -0
- package/dist/snapshots/repository-snapshot.d.ts +4 -0
- package/dist/snapshots/repository-snapshot.d.ts.map +1 -0
- package/dist/snapshots/repository-snapshot.js +119 -0
- package/dist/snapshots/types.d.ts +30 -0
- package/dist/snapshots/types.d.ts.map +1 -0
- package/dist/snapshots/types.js +1 -0
- package/dist/storage/atlas-database.d.ts +14 -0
- package/dist/storage/atlas-database.d.ts.map +1 -0
- package/dist/storage/atlas-database.js +552 -0
- package/dist/storage/snapshot-store.d.ts +19 -0
- package/dist/storage/snapshot-store.d.ts.map +1 -0
- package/dist/storage/snapshot-store.js +77 -0
- package/dist/structural-backend/codegraph-backend.d.ts +54 -0
- package/dist/structural-backend/codegraph-backend.d.ts.map +1 -0
- package/dist/structural-backend/codegraph-backend.js +1224 -0
- package/dist/structural-backend/codegraph-worker-client.d.ts +5 -0
- package/dist/structural-backend/codegraph-worker-client.d.ts.map +1 -0
- package/dist/structural-backend/codegraph-worker-client.js +118 -0
- package/dist/structural-backend/codegraph-worker-protocol.d.ts +35 -0
- package/dist/structural-backend/codegraph-worker-protocol.d.ts.map +1 -0
- package/dist/structural-backend/codegraph-worker-protocol.js +1 -0
- package/dist/structural-backend/codegraph-worker.d.ts +2 -0
- package/dist/structural-backend/codegraph-worker.d.ts.map +1 -0
- package/dist/structural-backend/codegraph-worker.js +131 -0
- package/dist/structural-backend/process-instance.d.ts +18 -0
- package/dist/structural-backend/process-instance.d.ts.map +1 -0
- package/dist/structural-backend/process-instance.js +207 -0
- package/dist/structural-backend/structural-fact-changes.d.ts +7 -0
- package/dist/structural-backend/structural-fact-changes.d.ts.map +1 -0
- package/dist/structural-backend/structural-fact-changes.js +78 -0
- package/dist/structural-backend/structural-publication.d.ts +12 -0
- package/dist/structural-backend/structural-publication.d.ts.map +1 -0
- package/dist/structural-backend/structural-publication.js +252 -0
- package/dist/structural-backend/structural-write-lock.d.ts +8 -0
- package/dist/structural-backend/structural-write-lock.d.ts.map +1 -0
- package/dist/structural-backend/structural-write-lock.js +415 -0
- package/dist/structural-backend/types.d.ts +144 -0
- package/dist/structural-backend/types.d.ts.map +1 -0
- package/dist/structural-backend/types.js +11 -0
- package/dist/world/types.d.ts +77 -0
- package/dist/world/types.d.ts.map +1 -0
- package/dist/world/types.js +1 -0
- package/dist/world/world-graph-query.d.ts +31 -0
- package/dist/world/world-graph-query.d.ts.map +1 -0
- package/dist/world/world-graph-query.js +453 -0
- package/dist/world/world-model-service.d.ts +21 -0
- package/dist/world/world-model-service.d.ts.map +1 -0
- package/dist/world/world-model-service.js +211 -0
- package/dist/world/world-snapshot-store.d.ts +40 -0
- package/dist/world/world-snapshot-store.d.ts.map +1 -0
- package/dist/world/world-snapshot-store.js +555 -0
- package/docs/architecture/codegraph-backend.md +193 -0
- package/docs/contracts/cli-v1.md +119 -0
- package/docs/contracts/graph-model.md +102 -0
- package/docs/contracts/graph-patch-v1.md +98 -0
- package/docs/evaluation.md +128 -0
- package/docs/product-contract.md +148 -0
- package/package.json +78 -0
- package/schemas/cli-envelope-v1.schema.json +1359 -0
- package/schemas/evaluation-plan-v1.schema.json +211 -0
- package/schemas/evaluation-run-v1.schema.json +365 -0
- package/schemas/graph-patch-v1.schema.json +392 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/contracts/cli.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { assertionCertaintySchema, businessKeySchema, businessNodeKindSchema, businessRelationTypeSchema, evidenceSchema, knowledgeValiditySchema, relativeSourcePathSchema, sourceRangeSchema, structuralNodeKindSchema, structuralNodeIdSchema, structuralRelationTypeSchema, structuralSupportSchema, } from "./graph.js";
|
|
3
|
+
import { contentIdentifierSchema, gitObjectIdSchema, } from "./identifiers.js";
|
|
4
|
+
const repositoryDescriptorSchema = z.strictObject({
|
|
5
|
+
id: contentIdentifierSchema,
|
|
6
|
+
root: z.string().min(1),
|
|
7
|
+
headCommit: gitObjectIdSchema,
|
|
8
|
+
});
|
|
9
|
+
const snapshotDescriptorSchema = z.strictObject({
|
|
10
|
+
id: contentIdentifierSchema,
|
|
11
|
+
gitHead: gitObjectIdSchema,
|
|
12
|
+
createdAt: z.iso.datetime(),
|
|
13
|
+
freshness: z.enum(["current", "stale"]),
|
|
14
|
+
});
|
|
15
|
+
const warningSchema = z.strictObject({
|
|
16
|
+
code: z.string().regex(/^[A-Z][A-Z0-9_]*$/),
|
|
17
|
+
message: z.string().min(1),
|
|
18
|
+
details: z.json().optional(),
|
|
19
|
+
});
|
|
20
|
+
const sourceLocationSchema = z.looseObject({
|
|
21
|
+
file: relativeSourcePathSchema,
|
|
22
|
+
range: sourceRangeSchema,
|
|
23
|
+
});
|
|
24
|
+
const structuralMapNodeSchema = z.looseObject({
|
|
25
|
+
domain: z.literal("structural"),
|
|
26
|
+
id: structuralNodeIdSchema,
|
|
27
|
+
kind: structuralNodeKindSchema.exclude(["UnknownBoundary"]),
|
|
28
|
+
label: z.string().min(1),
|
|
29
|
+
validity: knowledgeValiditySchema,
|
|
30
|
+
locations: z.array(sourceLocationSchema),
|
|
31
|
+
support: structuralSupportSchema,
|
|
32
|
+
});
|
|
33
|
+
export const businessMapNodeSchema = z.looseObject({
|
|
34
|
+
domain: z.literal("business"),
|
|
35
|
+
key: businessKeySchema,
|
|
36
|
+
kind: businessNodeKindSchema,
|
|
37
|
+
label: z.string().min(1),
|
|
38
|
+
summary: z.string().min(1),
|
|
39
|
+
aliases: z.array(z.string().min(1)),
|
|
40
|
+
certainty: assertionCertaintySchema,
|
|
41
|
+
validity: knowledgeValiditySchema,
|
|
42
|
+
evidence: z.array(evidenceSchema).min(1),
|
|
43
|
+
});
|
|
44
|
+
const unknownBoundarySchema = z.looseObject({
|
|
45
|
+
domain: z.literal("structural"),
|
|
46
|
+
id: structuralNodeIdSchema,
|
|
47
|
+
kind: z.literal("UnknownBoundary"),
|
|
48
|
+
label: z.string().min(1),
|
|
49
|
+
validity: z.literal("unknown"),
|
|
50
|
+
owner: z.strictObject({
|
|
51
|
+
domain: z.literal("structural"),
|
|
52
|
+
id: structuralNodeIdSchema,
|
|
53
|
+
}),
|
|
54
|
+
operation: z.string().min(1),
|
|
55
|
+
reason: z.string().min(1),
|
|
56
|
+
location: sourceLocationSchema,
|
|
57
|
+
candidates: z.array(z.string().min(1)),
|
|
58
|
+
support: structuralSupportSchema,
|
|
59
|
+
});
|
|
60
|
+
export const mapNodeSchema = z.union([
|
|
61
|
+
structuralMapNodeSchema,
|
|
62
|
+
businessMapNodeSchema,
|
|
63
|
+
unknownBoundarySchema,
|
|
64
|
+
]);
|
|
65
|
+
const mapRootNodeSchema = z.union([
|
|
66
|
+
structuralMapNodeSchema.safeExtend({ kind: z.literal("Module") }),
|
|
67
|
+
businessMapNodeSchema.safeExtend({ kind: z.literal("Capability") }),
|
|
68
|
+
]);
|
|
69
|
+
const invariantMapNodeSchema = businessMapNodeSchema.safeExtend({
|
|
70
|
+
kind: z.literal("Invariant"),
|
|
71
|
+
});
|
|
72
|
+
const testMapNodeSchema = structuralMapNodeSchema.safeExtend({
|
|
73
|
+
kind: z.enum(["Symbol", "Test"]),
|
|
74
|
+
});
|
|
75
|
+
const commandNameSchema = z.enum([
|
|
76
|
+
"status",
|
|
77
|
+
"index",
|
|
78
|
+
"map.roots",
|
|
79
|
+
"map.children",
|
|
80
|
+
"map.search",
|
|
81
|
+
"map.show",
|
|
82
|
+
"learn",
|
|
83
|
+
"changes",
|
|
84
|
+
]);
|
|
85
|
+
const countSchema = z.number().int().nonnegative();
|
|
86
|
+
const sourceChangeCountsSchema = z.looseObject({
|
|
87
|
+
staged: countSchema,
|
|
88
|
+
unstaged: countSchema,
|
|
89
|
+
untracked: countSchema,
|
|
90
|
+
});
|
|
91
|
+
const languageSupportSchema = z.discriminatedUnion("support", [
|
|
92
|
+
z.looseObject({
|
|
93
|
+
language: z.string().min(1),
|
|
94
|
+
support: z.literal("supported"),
|
|
95
|
+
}),
|
|
96
|
+
z.looseObject({
|
|
97
|
+
language: z.string().min(1),
|
|
98
|
+
support: z.literal("unsupported"),
|
|
99
|
+
reason: z.string().min(1),
|
|
100
|
+
}),
|
|
101
|
+
]);
|
|
102
|
+
const statusDataSchema = z.looseObject({
|
|
103
|
+
command: z.literal("status"),
|
|
104
|
+
currentRevision: z.looseObject({
|
|
105
|
+
headCommit: gitObjectIdSchema,
|
|
106
|
+
changes: sourceChangeCountsSchema,
|
|
107
|
+
}),
|
|
108
|
+
freshness: z.enum(["current", "stale", "missing"]),
|
|
109
|
+
storeLocation: z.string().min(1),
|
|
110
|
+
languages: z.array(languageSupportSchema),
|
|
111
|
+
});
|
|
112
|
+
const indexDataSchema = z.looseObject({
|
|
113
|
+
command: z.literal("index"),
|
|
114
|
+
snapshotId: contentIdentifierSchema,
|
|
115
|
+
facts: z.looseObject({
|
|
116
|
+
added: countSchema,
|
|
117
|
+
changed: countSchema,
|
|
118
|
+
reused: countSchema,
|
|
119
|
+
removed: countSchema,
|
|
120
|
+
}),
|
|
121
|
+
unknowns: z.looseObject({
|
|
122
|
+
added: countSchema,
|
|
123
|
+
resolved: countSchema,
|
|
124
|
+
total: countSchema,
|
|
125
|
+
}),
|
|
126
|
+
});
|
|
127
|
+
const mapRootsDataSchema = z.looseObject({
|
|
128
|
+
command: z.literal("map.roots"),
|
|
129
|
+
nodes: z.array(mapRootNodeSchema),
|
|
130
|
+
});
|
|
131
|
+
const mapChildrenDataSchema = z.looseObject({
|
|
132
|
+
command: z.literal("map.children"),
|
|
133
|
+
nodeId: z.string().min(1),
|
|
134
|
+
children: z.array(mapNodeSchema),
|
|
135
|
+
});
|
|
136
|
+
const mapSearchDataSchema = z.looseObject({
|
|
137
|
+
command: z.literal("map.search"),
|
|
138
|
+
query: z.string().min(1),
|
|
139
|
+
limit: z.number().int().positive(),
|
|
140
|
+
results: z.array(z.looseObject({
|
|
141
|
+
score: z.number().min(0).max(1),
|
|
142
|
+
node: mapNodeSchema,
|
|
143
|
+
})),
|
|
144
|
+
});
|
|
145
|
+
const neighborSchema = z.union([
|
|
146
|
+
z.looseObject({
|
|
147
|
+
type: structuralRelationTypeSchema,
|
|
148
|
+
direction: z.enum(["incoming", "outgoing"]),
|
|
149
|
+
node: mapNodeSchema,
|
|
150
|
+
certainty: z.null(),
|
|
151
|
+
validity: knowledgeValiditySchema,
|
|
152
|
+
evidence: z.array(evidenceSchema),
|
|
153
|
+
support: structuralSupportSchema,
|
|
154
|
+
}),
|
|
155
|
+
z.looseObject({
|
|
156
|
+
type: businessRelationTypeSchema,
|
|
157
|
+
direction: z.enum(["incoming", "outgoing"]),
|
|
158
|
+
node: mapNodeSchema,
|
|
159
|
+
certainty: assertionCertaintySchema,
|
|
160
|
+
validity: knowledgeValiditySchema,
|
|
161
|
+
evidence: z.array(evidenceSchema).min(1),
|
|
162
|
+
}),
|
|
163
|
+
]);
|
|
164
|
+
const mapShowDataSchema = z.looseObject({
|
|
165
|
+
command: z.literal("map.show"),
|
|
166
|
+
node: mapNodeSchema,
|
|
167
|
+
depth: z.number().int().min(1).max(3),
|
|
168
|
+
neighbors: z.array(neighborSchema),
|
|
169
|
+
invariants: z.array(invariantMapNodeSchema),
|
|
170
|
+
tests: z.array(testMapNodeSchema),
|
|
171
|
+
unknowns: z.array(unknownBoundarySchema),
|
|
172
|
+
});
|
|
173
|
+
const learnDataSchema = z.looseObject({
|
|
174
|
+
command: z.literal("learn"),
|
|
175
|
+
baseSnapshotId: contentIdentifierSchema,
|
|
176
|
+
snapshotId: contentIdentifierSchema,
|
|
177
|
+
applied: z.looseObject({
|
|
178
|
+
nodeOperations: countSchema,
|
|
179
|
+
relationOperations: countSchema,
|
|
180
|
+
}),
|
|
181
|
+
});
|
|
182
|
+
const changeSetSchema = z.looseObject({
|
|
183
|
+
added: z.array(z.string().min(1)),
|
|
184
|
+
changed: z.array(z.string().min(1)),
|
|
185
|
+
removed: z.array(z.string().min(1)),
|
|
186
|
+
});
|
|
187
|
+
const changesDataSchema = z.looseObject({
|
|
188
|
+
command: z.literal("changes"),
|
|
189
|
+
fromSnapshotId: contentIdentifierSchema,
|
|
190
|
+
toSnapshotId: contentIdentifierSchema,
|
|
191
|
+
nodes: changeSetSchema,
|
|
192
|
+
relations: changeSetSchema,
|
|
193
|
+
staleAssertions: z.array(z.string().min(1)),
|
|
194
|
+
});
|
|
195
|
+
export const cliCommandDataSchema = z.discriminatedUnion("command", [
|
|
196
|
+
statusDataSchema,
|
|
197
|
+
indexDataSchema,
|
|
198
|
+
mapRootsDataSchema,
|
|
199
|
+
mapChildrenDataSchema,
|
|
200
|
+
mapSearchDataSchema,
|
|
201
|
+
mapShowDataSchema,
|
|
202
|
+
learnDataSchema,
|
|
203
|
+
changesDataSchema,
|
|
204
|
+
]);
|
|
205
|
+
const errorDataSchema = z.looseObject({
|
|
206
|
+
command: commandNameSchema.nullable(),
|
|
207
|
+
error: z.strictObject({
|
|
208
|
+
code: z.string().regex(/^[A-Z][A-Z0-9_]*$/),
|
|
209
|
+
message: z.string().min(1),
|
|
210
|
+
details: z.json().optional(),
|
|
211
|
+
}),
|
|
212
|
+
});
|
|
213
|
+
const successEnvelopeSchema = z.strictObject({
|
|
214
|
+
schemaVersion: z.literal(1),
|
|
215
|
+
repository: repositoryDescriptorSchema,
|
|
216
|
+
snapshot: snapshotDescriptorSchema.nullable(),
|
|
217
|
+
status: z.enum(["ok", "partial"]),
|
|
218
|
+
data: cliCommandDataSchema,
|
|
219
|
+
warnings: z.array(warningSchema),
|
|
220
|
+
});
|
|
221
|
+
const errorEnvelopeSchema = z.strictObject({
|
|
222
|
+
schemaVersion: z.literal(1),
|
|
223
|
+
repository: repositoryDescriptorSchema.nullable(),
|
|
224
|
+
snapshot: snapshotDescriptorSchema.nullable(),
|
|
225
|
+
status: z.literal("error"),
|
|
226
|
+
data: errorDataSchema,
|
|
227
|
+
warnings: z.array(warningSchema),
|
|
228
|
+
});
|
|
229
|
+
export const cliEnvelopeSchema = z.union([
|
|
230
|
+
successEnvelopeSchema,
|
|
231
|
+
errorEnvelopeSchema,
|
|
232
|
+
]);
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const structuralNodeKindSchema: z.ZodEnum<{
|
|
3
|
+
Repository: "Repository";
|
|
4
|
+
Module: "Module";
|
|
5
|
+
File: "File";
|
|
6
|
+
Symbol: "Symbol";
|
|
7
|
+
Test: "Test";
|
|
8
|
+
UnknownBoundary: "UnknownBoundary";
|
|
9
|
+
}>;
|
|
10
|
+
export declare const businessNodeKindSchema: z.ZodEnum<{
|
|
11
|
+
Capability: "Capability";
|
|
12
|
+
Scenario: "Scenario";
|
|
13
|
+
Operation: "Operation";
|
|
14
|
+
Invariant: "Invariant";
|
|
15
|
+
Interface: "Interface";
|
|
16
|
+
Data: "Data";
|
|
17
|
+
}>;
|
|
18
|
+
export declare const structuralRelationTypeSchema: z.ZodEnum<{
|
|
19
|
+
contains: "contains";
|
|
20
|
+
declares: "declares";
|
|
21
|
+
imports: "imports";
|
|
22
|
+
exports: "exports";
|
|
23
|
+
references: "references";
|
|
24
|
+
calls: "calls";
|
|
25
|
+
extends: "extends";
|
|
26
|
+
implements: "implements";
|
|
27
|
+
instantiates: "instantiates";
|
|
28
|
+
decorated_by: "decorated_by";
|
|
29
|
+
}>;
|
|
30
|
+
export declare const businessRelationTypeSchema: z.ZodEnum<{
|
|
31
|
+
part_of: "part_of";
|
|
32
|
+
invokes: "invokes";
|
|
33
|
+
realized_by: "realized_by";
|
|
34
|
+
reads: "reads";
|
|
35
|
+
writes: "writes";
|
|
36
|
+
publishes: "publishes";
|
|
37
|
+
consumes: "consumes";
|
|
38
|
+
constrained_by: "constrained_by";
|
|
39
|
+
verified_by: "verified_by";
|
|
40
|
+
}>;
|
|
41
|
+
export declare const businessKeySchema: z.ZodString;
|
|
42
|
+
export declare const structuralNodeIdSchema: z.ZodString;
|
|
43
|
+
export declare const relativeSourcePathSchema: z.ZodString;
|
|
44
|
+
export declare const sourcePositionSchema: z.ZodObject<{
|
|
45
|
+
line: z.ZodNumber;
|
|
46
|
+
column: z.ZodNumber;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
export declare const sourceRangeSchema: z.ZodObject<{
|
|
49
|
+
start: z.ZodObject<{
|
|
50
|
+
line: z.ZodNumber;
|
|
51
|
+
column: z.ZodNumber;
|
|
52
|
+
}, z.core.$strict>;
|
|
53
|
+
end: z.ZodObject<{
|
|
54
|
+
line: z.ZodNumber;
|
|
55
|
+
column: z.ZodNumber;
|
|
56
|
+
}, z.core.$strict>;
|
|
57
|
+
}, z.core.$strict>;
|
|
58
|
+
export declare const evidenceSchema: z.ZodObject<{
|
|
59
|
+
symbolId: z.ZodString;
|
|
60
|
+
file: z.ZodString;
|
|
61
|
+
range: z.ZodObject<{
|
|
62
|
+
start: z.ZodObject<{
|
|
63
|
+
line: z.ZodNumber;
|
|
64
|
+
column: z.ZodNumber;
|
|
65
|
+
}, z.core.$strict>;
|
|
66
|
+
end: z.ZodObject<{
|
|
67
|
+
line: z.ZodNumber;
|
|
68
|
+
column: z.ZodNumber;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
}, z.core.$strict>;
|
|
71
|
+
contentHash: z.ZodString;
|
|
72
|
+
}, z.core.$strict>;
|
|
73
|
+
export declare const assertionCertaintySchema: z.ZodEnum<{
|
|
74
|
+
exact: "exact";
|
|
75
|
+
inferred: "inferred";
|
|
76
|
+
hypothesis: "hypothesis";
|
|
77
|
+
}>;
|
|
78
|
+
export declare const knowledgeValiditySchema: z.ZodEnum<{
|
|
79
|
+
valid: "valid";
|
|
80
|
+
stale: "stale";
|
|
81
|
+
}>;
|
|
82
|
+
export declare const structuralSupportStatusSchema: z.ZodEnum<{
|
|
83
|
+
exact: "exact";
|
|
84
|
+
inferred: "inferred";
|
|
85
|
+
unresolved: "unresolved";
|
|
86
|
+
unsupported: "unsupported";
|
|
87
|
+
}>;
|
|
88
|
+
export declare const structuralProvenanceSchema: z.ZodEnum<{
|
|
89
|
+
"tree-sitter": "tree-sitter";
|
|
90
|
+
scip: "scip";
|
|
91
|
+
heuristic: "heuristic";
|
|
92
|
+
backend: "backend";
|
|
93
|
+
}>;
|
|
94
|
+
export declare const structuralSupportSchema: z.ZodObject<{
|
|
95
|
+
status: z.ZodEnum<{
|
|
96
|
+
exact: "exact";
|
|
97
|
+
inferred: "inferred";
|
|
98
|
+
unresolved: "unresolved";
|
|
99
|
+
unsupported: "unsupported";
|
|
100
|
+
}>;
|
|
101
|
+
provenance: z.ZodEnum<{
|
|
102
|
+
"tree-sitter": "tree-sitter";
|
|
103
|
+
scip: "scip";
|
|
104
|
+
heuristic: "heuristic";
|
|
105
|
+
backend: "backend";
|
|
106
|
+
}>;
|
|
107
|
+
}, z.core.$strict>;
|
|
108
|
+
export declare const graphPatchV1Schema: z.ZodObject<{
|
|
109
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
110
|
+
baseSnapshotId: z.ZodString;
|
|
111
|
+
nodeOperations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
112
|
+
op: z.ZodLiteral<"upsert">;
|
|
113
|
+
node: z.ZodObject<{
|
|
114
|
+
key: z.ZodString;
|
|
115
|
+
kind: z.ZodEnum<{
|
|
116
|
+
Capability: "Capability";
|
|
117
|
+
Scenario: "Scenario";
|
|
118
|
+
Operation: "Operation";
|
|
119
|
+
Invariant: "Invariant";
|
|
120
|
+
Interface: "Interface";
|
|
121
|
+
Data: "Data";
|
|
122
|
+
}>;
|
|
123
|
+
label: z.ZodString;
|
|
124
|
+
summary: z.ZodString;
|
|
125
|
+
aliases: z.ZodArray<z.ZodString>;
|
|
126
|
+
certainty: z.ZodEnum<{
|
|
127
|
+
exact: "exact";
|
|
128
|
+
inferred: "inferred";
|
|
129
|
+
hypothesis: "hypothesis";
|
|
130
|
+
}>;
|
|
131
|
+
evidence: z.ZodArray<z.ZodObject<{
|
|
132
|
+
symbolId: z.ZodString;
|
|
133
|
+
file: z.ZodString;
|
|
134
|
+
range: z.ZodObject<{
|
|
135
|
+
start: z.ZodObject<{
|
|
136
|
+
line: z.ZodNumber;
|
|
137
|
+
column: z.ZodNumber;
|
|
138
|
+
}, z.core.$strict>;
|
|
139
|
+
end: z.ZodObject<{
|
|
140
|
+
line: z.ZodNumber;
|
|
141
|
+
column: z.ZodNumber;
|
|
142
|
+
}, z.core.$strict>;
|
|
143
|
+
}, z.core.$strict>;
|
|
144
|
+
contentHash: z.ZodString;
|
|
145
|
+
}, z.core.$strict>>;
|
|
146
|
+
}, z.core.$strict>;
|
|
147
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
148
|
+
op: z.ZodLiteral<"remove">;
|
|
149
|
+
key: z.ZodString;
|
|
150
|
+
}, z.core.$strict>], "op">>;
|
|
151
|
+
relationOperations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
152
|
+
op: z.ZodLiteral<"upsert">;
|
|
153
|
+
relation: z.ZodUnion<readonly [z.ZodObject<{
|
|
154
|
+
from: z.ZodObject<{
|
|
155
|
+
domain: z.ZodLiteral<"business">;
|
|
156
|
+
key: z.ZodString;
|
|
157
|
+
}, z.core.$strict>;
|
|
158
|
+
type: z.ZodEnum<{
|
|
159
|
+
part_of: "part_of";
|
|
160
|
+
invokes: "invokes";
|
|
161
|
+
reads: "reads";
|
|
162
|
+
writes: "writes";
|
|
163
|
+
publishes: "publishes";
|
|
164
|
+
consumes: "consumes";
|
|
165
|
+
constrained_by: "constrained_by";
|
|
166
|
+
}>;
|
|
167
|
+
to: z.ZodObject<{
|
|
168
|
+
domain: z.ZodLiteral<"business">;
|
|
169
|
+
key: z.ZodString;
|
|
170
|
+
}, z.core.$strict>;
|
|
171
|
+
certainty: z.ZodEnum<{
|
|
172
|
+
exact: "exact";
|
|
173
|
+
inferred: "inferred";
|
|
174
|
+
hypothesis: "hypothesis";
|
|
175
|
+
}>;
|
|
176
|
+
evidence: z.ZodArray<z.ZodObject<{
|
|
177
|
+
symbolId: z.ZodString;
|
|
178
|
+
file: z.ZodString;
|
|
179
|
+
range: z.ZodObject<{
|
|
180
|
+
start: z.ZodObject<{
|
|
181
|
+
line: z.ZodNumber;
|
|
182
|
+
column: z.ZodNumber;
|
|
183
|
+
}, z.core.$strict>;
|
|
184
|
+
end: z.ZodObject<{
|
|
185
|
+
line: z.ZodNumber;
|
|
186
|
+
column: z.ZodNumber;
|
|
187
|
+
}, z.core.$strict>;
|
|
188
|
+
}, z.core.$strict>;
|
|
189
|
+
contentHash: z.ZodString;
|
|
190
|
+
}, z.core.$strict>>;
|
|
191
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
192
|
+
from: z.ZodObject<{
|
|
193
|
+
domain: z.ZodLiteral<"business">;
|
|
194
|
+
key: z.ZodString;
|
|
195
|
+
}, z.core.$strict>;
|
|
196
|
+
type: z.ZodEnum<{
|
|
197
|
+
realized_by: "realized_by";
|
|
198
|
+
verified_by: "verified_by";
|
|
199
|
+
}>;
|
|
200
|
+
to: z.ZodObject<{
|
|
201
|
+
domain: z.ZodLiteral<"structural">;
|
|
202
|
+
id: z.ZodString;
|
|
203
|
+
}, z.core.$strict>;
|
|
204
|
+
certainty: z.ZodEnum<{
|
|
205
|
+
exact: "exact";
|
|
206
|
+
inferred: "inferred";
|
|
207
|
+
hypothesis: "hypothesis";
|
|
208
|
+
}>;
|
|
209
|
+
evidence: z.ZodArray<z.ZodObject<{
|
|
210
|
+
symbolId: z.ZodString;
|
|
211
|
+
file: z.ZodString;
|
|
212
|
+
range: z.ZodObject<{
|
|
213
|
+
start: z.ZodObject<{
|
|
214
|
+
line: z.ZodNumber;
|
|
215
|
+
column: z.ZodNumber;
|
|
216
|
+
}, z.core.$strict>;
|
|
217
|
+
end: z.ZodObject<{
|
|
218
|
+
line: z.ZodNumber;
|
|
219
|
+
column: z.ZodNumber;
|
|
220
|
+
}, z.core.$strict>;
|
|
221
|
+
}, z.core.$strict>;
|
|
222
|
+
contentHash: z.ZodString;
|
|
223
|
+
}, z.core.$strict>>;
|
|
224
|
+
}, z.core.$strict>]>;
|
|
225
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
226
|
+
op: z.ZodLiteral<"remove">;
|
|
227
|
+
relation: z.ZodUnion<readonly [z.ZodObject<{
|
|
228
|
+
from: z.ZodObject<{
|
|
229
|
+
domain: z.ZodLiteral<"business">;
|
|
230
|
+
key: z.ZodString;
|
|
231
|
+
}, z.core.$strict>;
|
|
232
|
+
type: z.ZodEnum<{
|
|
233
|
+
part_of: "part_of";
|
|
234
|
+
invokes: "invokes";
|
|
235
|
+
reads: "reads";
|
|
236
|
+
writes: "writes";
|
|
237
|
+
publishes: "publishes";
|
|
238
|
+
consumes: "consumes";
|
|
239
|
+
constrained_by: "constrained_by";
|
|
240
|
+
}>;
|
|
241
|
+
to: z.ZodObject<{
|
|
242
|
+
domain: z.ZodLiteral<"business">;
|
|
243
|
+
key: z.ZodString;
|
|
244
|
+
}, z.core.$strict>;
|
|
245
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
246
|
+
from: z.ZodObject<{
|
|
247
|
+
domain: z.ZodLiteral<"business">;
|
|
248
|
+
key: z.ZodString;
|
|
249
|
+
}, z.core.$strict>;
|
|
250
|
+
type: z.ZodEnum<{
|
|
251
|
+
realized_by: "realized_by";
|
|
252
|
+
verified_by: "verified_by";
|
|
253
|
+
}>;
|
|
254
|
+
to: z.ZodObject<{
|
|
255
|
+
domain: z.ZodLiteral<"structural">;
|
|
256
|
+
id: z.ZodString;
|
|
257
|
+
}, z.core.$strict>;
|
|
258
|
+
}, z.core.$strict>]>;
|
|
259
|
+
}, z.core.$strict>], "op">>;
|
|
260
|
+
}, z.core.$strict>;
|
|
261
|
+
export type GraphPatchV1 = z.infer<typeof graphPatchV1Schema>;
|
|
262
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/contracts/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,wBAAwB;;;;;;;EAOnC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;EAOjC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;EAWvC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;EAUrC,CAAC;AAEH,eAAO,MAAM,iBAAiB,aAK3B,CAAC;AAEJ,eAAO,MAAM,sBAAsB,aAKhC,CAAC;AAMJ,eAAO,MAAM,wBAAwB,aAMlC,CAAC;AAYJ,eAAO,MAAM,oBAAoB;;;kBAG/B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;kBAkB1B,CAAC;AAEL,eAAO,MAAM,cAAc;;;;;;;;;;;;;;kBAMvB,CAAC;AAEL,eAAO,MAAM,wBAAwB;;;;EAInC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;EAA6B,CAAC;AAElE,eAAO,MAAM,6BAA6B;;;;;EAKxC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;EAKrC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;kBAGlC,CAAC;AA4EH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAK7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { contentIdentifierSchema } from "./identifiers.js";
|
|
3
|
+
export const structuralNodeKindSchema = z.enum([
|
|
4
|
+
"Repository",
|
|
5
|
+
"Module",
|
|
6
|
+
"File",
|
|
7
|
+
"Symbol",
|
|
8
|
+
"Test",
|
|
9
|
+
"UnknownBoundary",
|
|
10
|
+
]);
|
|
11
|
+
export const businessNodeKindSchema = z.enum([
|
|
12
|
+
"Capability",
|
|
13
|
+
"Scenario",
|
|
14
|
+
"Operation",
|
|
15
|
+
"Invariant",
|
|
16
|
+
"Interface",
|
|
17
|
+
"Data",
|
|
18
|
+
]);
|
|
19
|
+
export const structuralRelationTypeSchema = z.enum([
|
|
20
|
+
"contains",
|
|
21
|
+
"declares",
|
|
22
|
+
"imports",
|
|
23
|
+
"exports",
|
|
24
|
+
"references",
|
|
25
|
+
"calls",
|
|
26
|
+
"extends",
|
|
27
|
+
"implements",
|
|
28
|
+
"instantiates",
|
|
29
|
+
"decorated_by",
|
|
30
|
+
]);
|
|
31
|
+
export const businessRelationTypeSchema = z.enum([
|
|
32
|
+
"part_of",
|
|
33
|
+
"invokes",
|
|
34
|
+
"realized_by",
|
|
35
|
+
"reads",
|
|
36
|
+
"writes",
|
|
37
|
+
"publishes",
|
|
38
|
+
"consumes",
|
|
39
|
+
"constrained_by",
|
|
40
|
+
"verified_by",
|
|
41
|
+
]);
|
|
42
|
+
export const businessKeySchema = z
|
|
43
|
+
.string()
|
|
44
|
+
.regex(/^[a-z0-9]+(?:[._-][a-z0-9]+)*(?:\/[a-z0-9]+(?:[._-][a-z0-9]+)*)*$/, "Expected a stable hierarchical business key");
|
|
45
|
+
export const structuralNodeIdSchema = z
|
|
46
|
+
.string()
|
|
47
|
+
.regex(/^(?:repository|module|file|symbol|test|unknown):.+$/, "Expected a namespaced structural node ID");
|
|
48
|
+
const evidenceNodeIdSchema = z
|
|
49
|
+
.string()
|
|
50
|
+
.regex(/^(?:symbol|test):.+$/, "Expected an evidence-bearing structural symbol or test ID");
|
|
51
|
+
export const relativeSourcePathSchema = z
|
|
52
|
+
.string()
|
|
53
|
+
.min(1)
|
|
54
|
+
.regex(/^(?!\/)(?!.*\\)(?!.*(?:^|\/)\.\.?(?:\/|$))(?!.*\/\/).+$/, "Expected a normalized repository-relative path");
|
|
55
|
+
const businessNodeReferenceSchema = z.strictObject({
|
|
56
|
+
domain: z.literal("business"),
|
|
57
|
+
key: businessKeySchema,
|
|
58
|
+
});
|
|
59
|
+
const structuralNodeReferenceSchema = z.strictObject({
|
|
60
|
+
domain: z.literal("structural"),
|
|
61
|
+
id: structuralNodeIdSchema,
|
|
62
|
+
});
|
|
63
|
+
export const sourcePositionSchema = z.strictObject({
|
|
64
|
+
line: z.number().int().positive(),
|
|
65
|
+
column: z.number().int().positive(),
|
|
66
|
+
});
|
|
67
|
+
export const sourceRangeSchema = z
|
|
68
|
+
.strictObject({
|
|
69
|
+
start: sourcePositionSchema,
|
|
70
|
+
end: sourcePositionSchema,
|
|
71
|
+
})
|
|
72
|
+
.superRefine((range, context) => {
|
|
73
|
+
const endsBeforeStart = range.end.line < range.start.line ||
|
|
74
|
+
(range.end.line === range.start.line &&
|
|
75
|
+
range.end.column < range.start.column);
|
|
76
|
+
if (endsBeforeStart) {
|
|
77
|
+
context.addIssue({
|
|
78
|
+
code: "custom",
|
|
79
|
+
message: "Source range end must not precede its start",
|
|
80
|
+
path: ["end"],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
export const evidenceSchema = z
|
|
85
|
+
.strictObject({
|
|
86
|
+
symbolId: evidenceNodeIdSchema,
|
|
87
|
+
file: relativeSourcePathSchema,
|
|
88
|
+
range: sourceRangeSchema,
|
|
89
|
+
contentHash: contentIdentifierSchema,
|
|
90
|
+
});
|
|
91
|
+
export const assertionCertaintySchema = z.enum([
|
|
92
|
+
"exact",
|
|
93
|
+
"inferred",
|
|
94
|
+
"hypothesis",
|
|
95
|
+
]);
|
|
96
|
+
export const knowledgeValiditySchema = z.enum(["valid", "stale"]);
|
|
97
|
+
export const structuralSupportStatusSchema = z.enum([
|
|
98
|
+
"exact",
|
|
99
|
+
"inferred",
|
|
100
|
+
"unresolved",
|
|
101
|
+
"unsupported",
|
|
102
|
+
]);
|
|
103
|
+
export const structuralProvenanceSchema = z.enum([
|
|
104
|
+
"tree-sitter",
|
|
105
|
+
"scip",
|
|
106
|
+
"heuristic",
|
|
107
|
+
"backend",
|
|
108
|
+
]);
|
|
109
|
+
export const structuralSupportSchema = z.strictObject({
|
|
110
|
+
status: structuralSupportStatusSchema,
|
|
111
|
+
provenance: structuralProvenanceSchema,
|
|
112
|
+
});
|
|
113
|
+
const businessNodeSchema = z.strictObject({
|
|
114
|
+
key: businessKeySchema,
|
|
115
|
+
kind: businessNodeKindSchema,
|
|
116
|
+
label: z.string().min(1),
|
|
117
|
+
summary: z.string().min(1),
|
|
118
|
+
aliases: z.array(z.string().min(1)),
|
|
119
|
+
certainty: assertionCertaintySchema,
|
|
120
|
+
evidence: z.array(evidenceSchema).min(1),
|
|
121
|
+
});
|
|
122
|
+
const businessTargetRelationTypeSchema = z.enum([
|
|
123
|
+
"part_of",
|
|
124
|
+
"invokes",
|
|
125
|
+
"reads",
|
|
126
|
+
"writes",
|
|
127
|
+
"publishes",
|
|
128
|
+
"consumes",
|
|
129
|
+
"constrained_by",
|
|
130
|
+
]);
|
|
131
|
+
const structuralTargetRelationTypeSchema = z.enum([
|
|
132
|
+
"realized_by",
|
|
133
|
+
"verified_by",
|
|
134
|
+
]);
|
|
135
|
+
const businessTargetRelationSelectorSchema = z.strictObject({
|
|
136
|
+
from: businessNodeReferenceSchema,
|
|
137
|
+
type: businessTargetRelationTypeSchema,
|
|
138
|
+
to: businessNodeReferenceSchema,
|
|
139
|
+
});
|
|
140
|
+
const structuralTargetRelationSelectorSchema = z.strictObject({
|
|
141
|
+
from: businessNodeReferenceSchema,
|
|
142
|
+
type: structuralTargetRelationTypeSchema,
|
|
143
|
+
to: structuralNodeReferenceSchema,
|
|
144
|
+
});
|
|
145
|
+
const relationSelectorSchema = z.union([
|
|
146
|
+
businessTargetRelationSelectorSchema,
|
|
147
|
+
structuralTargetRelationSelectorSchema,
|
|
148
|
+
]);
|
|
149
|
+
const assertionShape = {
|
|
150
|
+
certainty: assertionCertaintySchema,
|
|
151
|
+
evidence: z.array(evidenceSchema).min(1),
|
|
152
|
+
};
|
|
153
|
+
const learnedRelationSchema = z.union([
|
|
154
|
+
businessTargetRelationSelectorSchema.extend(assertionShape),
|
|
155
|
+
structuralTargetRelationSelectorSchema.extend(assertionShape),
|
|
156
|
+
]);
|
|
157
|
+
const nodeOperationSchema = z.discriminatedUnion("op", [
|
|
158
|
+
z.strictObject({
|
|
159
|
+
op: z.literal("upsert"),
|
|
160
|
+
node: businessNodeSchema,
|
|
161
|
+
}),
|
|
162
|
+
z.strictObject({
|
|
163
|
+
op: z.literal("remove"),
|
|
164
|
+
key: businessKeySchema,
|
|
165
|
+
}),
|
|
166
|
+
]);
|
|
167
|
+
const relationOperationSchema = z.discriminatedUnion("op", [
|
|
168
|
+
z.strictObject({
|
|
169
|
+
op: z.literal("upsert"),
|
|
170
|
+
relation: learnedRelationSchema,
|
|
171
|
+
}),
|
|
172
|
+
z.strictObject({
|
|
173
|
+
op: z.literal("remove"),
|
|
174
|
+
relation: relationSelectorSchema,
|
|
175
|
+
}),
|
|
176
|
+
]);
|
|
177
|
+
export const graphPatchV1Schema = z.strictObject({
|
|
178
|
+
schemaVersion: z.literal(1),
|
|
179
|
+
baseSnapshotId: contentIdentifierSchema,
|
|
180
|
+
nodeOperations: z.array(nodeOperationSchema),
|
|
181
|
+
relationOperations: z.array(relationOperationSchema),
|
|
182
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifiers.d.ts","sourceRoot":"","sources":["../../src/contracts/identifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,uBAAuB,aAEuB,CAAC;AAE5D,eAAO,MAAM,iBAAiB,aAEyC,CAAC"}
|