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.
Files changed (175) hide show
  1. package/.agents/skills/semantic-atlas/SKILL.md +172 -0
  2. package/.agents/skills/semantic-atlas/references/graph-patch.md +109 -0
  3. package/.agents/skills/semantic-atlas/references/result-routing.md +91 -0
  4. package/LICENSE +21 -0
  5. package/README.md +118 -0
  6. package/dist/business-flow/business-flow-derivation-service.d.ts +11 -0
  7. package/dist/business-flow/business-flow-derivation-service.d.ts.map +1 -0
  8. package/dist/business-flow/business-flow-derivation-service.js +151 -0
  9. package/dist/business-flow/business-flow-draft.d.ts +16 -0
  10. package/dist/business-flow/business-flow-draft.d.ts.map +1 -0
  11. package/dist/business-flow/business-flow-draft.js +150 -0
  12. package/dist/business-flow/framework-business-strategy.d.ts +7 -0
  13. package/dist/business-flow/framework-business-strategy.d.ts.map +1 -0
  14. package/dist/business-flow/framework-business-strategy.js +1 -0
  15. package/dist/business-flow/strategies/bullmq-business-strategy.d.ts +10 -0
  16. package/dist/business-flow/strategies/bullmq-business-strategy.d.ts.map +1 -0
  17. package/dist/business-flow/strategies/bullmq-business-strategy.js +79 -0
  18. package/dist/business-flow/strategies/called-operation-derivation.d.ts +13 -0
  19. package/dist/business-flow/strategies/called-operation-derivation.d.ts.map +1 -0
  20. package/dist/business-flow/strategies/called-operation-derivation.js +32 -0
  21. package/dist/business-flow/strategies/graphql-business-strategy.d.ts +8 -0
  22. package/dist/business-flow/strategies/graphql-business-strategy.d.ts.map +1 -0
  23. package/dist/business-flow/strategies/graphql-business-strategy.js +65 -0
  24. package/dist/business-flow/strategies/nestjs-business-strategy.d.ts +8 -0
  25. package/dist/business-flow/strategies/nestjs-business-strategy.d.ts.map +1 -0
  26. package/dist/business-flow/strategies/nestjs-business-strategy.js +72 -0
  27. package/dist/business-flow/strategies/strategy-helpers.d.ts +32 -0
  28. package/dist/business-flow/strategies/strategy-helpers.d.ts.map +1 -0
  29. package/dist/business-flow/strategies/strategy-helpers.js +49 -0
  30. package/dist/business-flow/strategies/typeorm-business-strategy.d.ts +10 -0
  31. package/dist/business-flow/strategies/typeorm-business-strategy.d.ts.map +1 -0
  32. package/dist/business-flow/strategies/typeorm-business-strategy.js +136 -0
  33. package/dist/business-flow/strategies/verified-invariant-strategy.d.ts +5 -0
  34. package/dist/business-flow/strategies/verified-invariant-strategy.d.ts.map +1 -0
  35. package/dist/business-flow/strategies/verified-invariant-strategy.js +38 -0
  36. package/dist/business-flow/strategies/verified-test-strategy.d.ts +5 -0
  37. package/dist/business-flow/strategies/verified-test-strategy.d.ts.map +1 -0
  38. package/dist/business-flow/strategies/verified-test-strategy.js +26 -0
  39. package/dist/business-flow/structural-flow-catalog.d.ts +21 -0
  40. package/dist/business-flow/structural-flow-catalog.d.ts.map +1 -0
  41. package/dist/business-flow/structural-flow-catalog.js +125 -0
  42. package/dist/business-flow/types.d.ts +51 -0
  43. package/dist/business-flow/types.d.ts.map +1 -0
  44. package/dist/business-flow/types.js +1 -0
  45. package/dist/cli/argument-parser.d.ts +3 -0
  46. package/dist/cli/argument-parser.d.ts.map +1 -0
  47. package/dist/cli/argument-parser.js +174 -0
  48. package/dist/cli/bin.d.ts +3 -0
  49. package/dist/cli/bin.d.ts.map +1 -0
  50. package/dist/cli/bin.js +23 -0
  51. package/dist/cli/cli-application.d.ts +38 -0
  52. package/dist/cli/cli-application.d.ts.map +1 -0
  53. package/dist/cli/cli-application.js +515 -0
  54. package/dist/cli/cli-error.d.ts +12 -0
  55. package/dist/cli/cli-error.d.ts.map +1 -0
  56. package/dist/cli/cli-error.js +44 -0
  57. package/dist/cli/cli-presenter.d.ts +14 -0
  58. package/dist/cli/cli-presenter.d.ts.map +1 -0
  59. package/dist/cli/cli-presenter.js +36 -0
  60. package/dist/cli/main.d.ts +3 -0
  61. package/dist/cli/main.d.ts.map +1 -0
  62. package/dist/cli/main.js +45 -0
  63. package/dist/cli/types.d.ts +46 -0
  64. package/dist/cli/types.d.ts.map +1 -0
  65. package/dist/cli/types.js +1 -0
  66. package/dist/contracts/cli.d.ts +2139 -0
  67. package/dist/contracts/cli.d.ts.map +1 -0
  68. package/dist/contracts/cli.js +232 -0
  69. package/dist/contracts/graph.d.ts +262 -0
  70. package/dist/contracts/graph.d.ts.map +1 -0
  71. package/dist/contracts/graph.js +182 -0
  72. package/dist/contracts/identifiers.d.ts +4 -0
  73. package/dist/contracts/identifiers.d.ts.map +1 -0
  74. package/dist/contracts/identifiers.js +7 -0
  75. package/dist/contracts/public-contracts.d.ts +4 -0
  76. package/dist/contracts/public-contracts.d.ts.map +1 -0
  77. package/dist/contracts/public-contracts.js +3 -0
  78. package/dist/evaluation/comparison.d.ts +30 -0
  79. package/dist/evaluation/comparison.d.ts.map +1 -0
  80. package/dist/evaluation/comparison.js +108 -0
  81. package/dist/evaluation/contracts.d.ts +204 -0
  82. package/dist/evaluation/contracts.d.ts.map +1 -0
  83. package/dist/evaluation/contracts.js +269 -0
  84. package/dist/graph/graph-store.d.ts +47 -0
  85. package/dist/graph/graph-store.d.ts.map +1 -0
  86. package/dist/graph/graph-store.js +719 -0
  87. package/dist/graph/types.d.ts +168 -0
  88. package/dist/graph/types.d.ts.map +1 -0
  89. package/dist/graph/types.js +1 -0
  90. package/dist/index.d.ts +19 -0
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +9 -0
  93. package/dist/knowledge/business-knowledge-service.d.ts +24 -0
  94. package/dist/knowledge/business-knowledge-service.d.ts.map +1 -0
  95. package/dist/knowledge/business-knowledge-service.js +200 -0
  96. package/dist/knowledge/graph-patch-conflict-error.d.ts +8 -0
  97. package/dist/knowledge/graph-patch-conflict-error.d.ts.map +1 -0
  98. package/dist/knowledge/graph-patch-conflict-error.js +12 -0
  99. package/dist/knowledge/structural-target-binding.d.ts +14 -0
  100. package/dist/knowledge/structural-target-binding.d.ts.map +1 -0
  101. package/dist/knowledge/structural-target-binding.js +11 -0
  102. package/dist/repository/git-command.d.ts +3 -0
  103. package/dist/repository/git-command.d.ts.map +1 -0
  104. package/dist/repository/git-command.js +25 -0
  105. package/dist/repository/repository-inspector.d.ts +7 -0
  106. package/dist/repository/repository-inspector.d.ts.map +1 -0
  107. package/dist/repository/repository-inspector.js +84 -0
  108. package/dist/repository/repository-language-support.d.ts +14 -0
  109. package/dist/repository/repository-language-support.d.ts.map +1 -0
  110. package/dist/repository/repository-language-support.js +64 -0
  111. package/dist/repository/types.d.ts +9 -0
  112. package/dist/repository/types.d.ts.map +1 -0
  113. package/dist/repository/types.js +1 -0
  114. package/dist/snapshots/repository-snapshot.d.ts +4 -0
  115. package/dist/snapshots/repository-snapshot.d.ts.map +1 -0
  116. package/dist/snapshots/repository-snapshot.js +119 -0
  117. package/dist/snapshots/types.d.ts +30 -0
  118. package/dist/snapshots/types.d.ts.map +1 -0
  119. package/dist/snapshots/types.js +1 -0
  120. package/dist/storage/atlas-database.d.ts +14 -0
  121. package/dist/storage/atlas-database.d.ts.map +1 -0
  122. package/dist/storage/atlas-database.js +552 -0
  123. package/dist/storage/snapshot-store.d.ts +19 -0
  124. package/dist/storage/snapshot-store.d.ts.map +1 -0
  125. package/dist/storage/snapshot-store.js +77 -0
  126. package/dist/structural-backend/codegraph-backend.d.ts +54 -0
  127. package/dist/structural-backend/codegraph-backend.d.ts.map +1 -0
  128. package/dist/structural-backend/codegraph-backend.js +1224 -0
  129. package/dist/structural-backend/codegraph-worker-client.d.ts +5 -0
  130. package/dist/structural-backend/codegraph-worker-client.d.ts.map +1 -0
  131. package/dist/structural-backend/codegraph-worker-client.js +118 -0
  132. package/dist/structural-backend/codegraph-worker-protocol.d.ts +35 -0
  133. package/dist/structural-backend/codegraph-worker-protocol.d.ts.map +1 -0
  134. package/dist/structural-backend/codegraph-worker-protocol.js +1 -0
  135. package/dist/structural-backend/codegraph-worker.d.ts +2 -0
  136. package/dist/structural-backend/codegraph-worker.d.ts.map +1 -0
  137. package/dist/structural-backend/codegraph-worker.js +131 -0
  138. package/dist/structural-backend/process-instance.d.ts +18 -0
  139. package/dist/structural-backend/process-instance.d.ts.map +1 -0
  140. package/dist/structural-backend/process-instance.js +207 -0
  141. package/dist/structural-backend/structural-fact-changes.d.ts +7 -0
  142. package/dist/structural-backend/structural-fact-changes.d.ts.map +1 -0
  143. package/dist/structural-backend/structural-fact-changes.js +78 -0
  144. package/dist/structural-backend/structural-publication.d.ts +12 -0
  145. package/dist/structural-backend/structural-publication.d.ts.map +1 -0
  146. package/dist/structural-backend/structural-publication.js +252 -0
  147. package/dist/structural-backend/structural-write-lock.d.ts +8 -0
  148. package/dist/structural-backend/structural-write-lock.d.ts.map +1 -0
  149. package/dist/structural-backend/structural-write-lock.js +415 -0
  150. package/dist/structural-backend/types.d.ts +144 -0
  151. package/dist/structural-backend/types.d.ts.map +1 -0
  152. package/dist/structural-backend/types.js +11 -0
  153. package/dist/world/types.d.ts +77 -0
  154. package/dist/world/types.d.ts.map +1 -0
  155. package/dist/world/types.js +1 -0
  156. package/dist/world/world-graph-query.d.ts +31 -0
  157. package/dist/world/world-graph-query.d.ts.map +1 -0
  158. package/dist/world/world-graph-query.js +453 -0
  159. package/dist/world/world-model-service.d.ts +21 -0
  160. package/dist/world/world-model-service.d.ts.map +1 -0
  161. package/dist/world/world-model-service.js +211 -0
  162. package/dist/world/world-snapshot-store.d.ts +40 -0
  163. package/dist/world/world-snapshot-store.d.ts.map +1 -0
  164. package/dist/world/world-snapshot-store.js +555 -0
  165. package/docs/architecture/codegraph-backend.md +193 -0
  166. package/docs/contracts/cli-v1.md +119 -0
  167. package/docs/contracts/graph-model.md +102 -0
  168. package/docs/contracts/graph-patch-v1.md +98 -0
  169. package/docs/evaluation.md +128 -0
  170. package/docs/product-contract.md +148 -0
  171. package/package.json +78 -0
  172. package/schemas/cli-envelope-v1.schema.json +1359 -0
  173. package/schemas/evaluation-plan-v1.schema.json +211 -0
  174. package/schemas/evaluation-run-v1.schema.json +365 -0
  175. package/schemas/graph-patch-v1.schema.json +392 -0
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAG5B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
@@ -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,4 @@
1
+ import { z } from "zod";
2
+ export declare const contentIdentifierSchema: z.ZodString;
3
+ export declare const gitObjectIdSchema: z.ZodString;
4
+ //# sourceMappingURL=identifiers.d.ts.map
@@ -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"}