@kernlang/core 3.5.9-canary.220.1.c398cd95 → 4.0.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 (104) hide show
  1. package/dist/capability-matrix.js +8 -6
  2. package/dist/capability-matrix.js.map +1 -1
  3. package/dist/closure-eligibility.d.ts +104 -0
  4. package/dist/closure-eligibility.js +443 -0
  5. package/dist/closure-eligibility.js.map +1 -0
  6. package/dist/closure-python-lowering.d.ts +26 -0
  7. package/dist/closure-python-lowering.js +132 -22
  8. package/dist/closure-python-lowering.js.map +1 -1
  9. package/dist/codegen/body-ts.js +13 -0
  10. package/dist/codegen/body-ts.js.map +1 -1
  11. package/dist/codegen/type-system.js +50 -3
  12. package/dist/codegen/type-system.js.map +1 -1
  13. package/dist/codegen-core.js +29 -0
  14. package/dist/codegen-core.js.map +1 -1
  15. package/dist/codegen-expression.js +7 -0
  16. package/dist/codegen-expression.js.map +1 -1
  17. package/dist/constructor-super.d.ts +34 -0
  18. package/dist/constructor-super.js +122 -0
  19. package/dist/constructor-super.js.map +1 -0
  20. package/dist/core-contracts/boolean.d.ts +147 -0
  21. package/dist/core-contracts/boolean.js +110 -0
  22. package/dist/core-contracts/boolean.js.map +1 -0
  23. package/dist/core-contracts/function.d.ts +6 -0
  24. package/dist/core-contracts/function.js +7 -0
  25. package/dist/core-contracts/function.js.map +1 -0
  26. package/dist/core-contracts/index.d.ts +1032 -0
  27. package/dist/core-contracts/index.js +30 -0
  28. package/dist/core-contracts/index.js.map +1 -0
  29. package/dist/core-contracts/list.d.ts +87 -0
  30. package/dist/core-contracts/list.js +54 -0
  31. package/dist/core-contracts/list.js.map +1 -0
  32. package/dist/core-contracts/nullish.d.ts +12 -0
  33. package/dist/core-contracts/nullish.js +13 -0
  34. package/dist/core-contracts/nullish.js.map +1 -0
  35. package/dist/core-contracts/number.d.ts +291 -0
  36. package/dist/core-contracts/number.js +214 -0
  37. package/dist/core-contracts/number.js.map +1 -0
  38. package/dist/core-contracts/record.d.ts +60 -0
  39. package/dist/core-contracts/record.js +32 -0
  40. package/dist/core-contracts/record.js.map +1 -0
  41. package/dist/core-contracts/schema.d.ts +71 -0
  42. package/dist/core-contracts/schema.js +98 -0
  43. package/dist/core-contracts/schema.js.map +1 -0
  44. package/dist/core-contracts/semantics.d.ts +7 -0
  45. package/dist/core-contracts/semantics.js +221 -0
  46. package/dist/core-contracts/semantics.js.map +1 -0
  47. package/dist/core-contracts/string.d.ts +414 -0
  48. package/dist/core-contracts/string.js +335 -0
  49. package/dist/core-contracts/string.js.map +1 -0
  50. package/dist/core-runtime/contract-adapter.d.ts +8 -0
  51. package/dist/core-runtime/contract-adapter.js +73 -0
  52. package/dist/core-runtime/contract-adapter.js.map +1 -0
  53. package/dist/core-runtime/index.d.ts +109 -0
  54. package/dist/core-runtime/index.js +1946 -0
  55. package/dist/core-runtime/index.js.map +1 -0
  56. package/dist/core-runtime/shape-validator.d.ts +61 -0
  57. package/dist/core-runtime/shape-validator.js +564 -0
  58. package/dist/core-runtime/shape-validator.js.map +1 -0
  59. package/dist/core-runtime/value-brand.d.ts +2 -0
  60. package/dist/core-runtime/value-brand.js +6 -0
  61. package/dist/core-runtime/value-brand.js.map +1 -0
  62. package/dist/decompiler.js +46 -0
  63. package/dist/decompiler.js.map +1 -1
  64. package/dist/eligibility-taxonomy.d.ts +58 -0
  65. package/dist/eligibility-taxonomy.generated.d.ts +472 -0
  66. package/dist/eligibility-taxonomy.generated.js +566 -0
  67. package/dist/eligibility-taxonomy.generated.js.map +1 -0
  68. package/dist/eligibility-taxonomy.js +55 -0
  69. package/dist/eligibility-taxonomy.js.map +1 -0
  70. package/dist/index.d.ts +19 -2
  71. package/dist/index.js +17 -1
  72. package/dist/index.js.map +1 -1
  73. package/dist/instanceof-rhs.d.ts +53 -0
  74. package/dist/instanceof-rhs.js +74 -0
  75. package/dist/instanceof-rhs.js.map +1 -0
  76. package/dist/ir/semantics/lambda.js +9 -1
  77. package/dist/ir/semantics/lambda.js.map +1 -1
  78. package/dist/native-eligibility-ast.d.ts +5 -0
  79. package/dist/native-eligibility-ast.js +242 -63
  80. package/dist/native-eligibility-ast.js.map +1 -1
  81. package/dist/parser-expression.d.ts +1 -1
  82. package/dist/parser-expression.js +90 -1
  83. package/dist/parser-expression.js.map +1 -1
  84. package/dist/rag-assertions.d.ts +3 -0
  85. package/dist/rag-assertions.js +15 -0
  86. package/dist/rag-assertions.js.map +1 -0
  87. package/dist/rag-runtime.d.ts +169 -0
  88. package/dist/rag-runtime.js +823 -0
  89. package/dist/rag-runtime.js.map +1 -0
  90. package/dist/schema.d.ts +1 -0
  91. package/dist/schema.js +197 -2
  92. package/dist/schema.js.map +1 -1
  93. package/dist/semantic-substrate.d.ts +108 -0
  94. package/dist/semantic-substrate.js +263 -0
  95. package/dist/semantic-substrate.js.map +1 -0
  96. package/dist/semantic-validator.d.ts +332 -0
  97. package/dist/semantic-validator.js +3387 -0
  98. package/dist/semantic-validator.js.map +1 -1
  99. package/dist/spec.d.ts +2 -2
  100. package/dist/spec.js +15 -1
  101. package/dist/spec.js.map +1 -1
  102. package/dist/value-ir.d.ts +11 -1
  103. package/dist/value-ir.js.map +1 -1
  104. package/package.json +5 -1
@@ -22,8 +22,340 @@ export interface SemanticViolation {
22
22
  line?: number;
23
23
  col?: number;
24
24
  }
25
+ export type ClassSemanticMemberKind = 'field' | 'method' | 'getter' | 'setter';
26
+ export type ClassSemanticOverrideStatus = 'compatible' | 'kind-mismatch' | 'arity-mismatch' | 'return-mismatch' | 'param-mismatch';
27
+ export interface ClassSemanticLocation {
28
+ readonly line: number;
29
+ readonly col: number;
30
+ }
31
+ export interface ClassSemanticMemberFact {
32
+ readonly className: string;
33
+ readonly owner: string;
34
+ readonly name: string;
35
+ readonly kind: ClassSemanticMemberKind;
36
+ readonly static: boolean;
37
+ readonly private?: boolean;
38
+ readonly async?: boolean;
39
+ readonly stream?: boolean;
40
+ readonly generator?: boolean;
41
+ readonly type?: string;
42
+ readonly returns?: string;
43
+ readonly paramTypes?: readonly string[];
44
+ readonly arity: number;
45
+ readonly readable: boolean;
46
+ readonly writable: boolean;
47
+ readonly inheritedFrom?: string;
48
+ readonly loc?: ClassSemanticLocation;
49
+ }
50
+ export interface ClassSemanticClassFact {
51
+ readonly name: string;
52
+ readonly baseName?: string;
53
+ readonly hasConstructor: boolean;
54
+ readonly constructorCount: number;
55
+ readonly members: readonly ClassSemanticMemberFact[];
56
+ readonly effectiveMembers: readonly ClassSemanticMemberFact[];
57
+ readonly loc?: ClassSemanticLocation;
58
+ }
59
+ export type ClassSemanticConstructorSuperStatus = 'not-required' | 'satisfied' | 'missing' | 'conditional' | 'double' | 'this-before-super';
60
+ export interface ClassSemanticConstructorFact {
61
+ readonly className: string;
62
+ readonly hasConstructor: boolean;
63
+ readonly constructorCount: number;
64
+ readonly hasBase: boolean;
65
+ readonly requiresSuper: boolean;
66
+ readonly superStatus: ClassSemanticConstructorSuperStatus;
67
+ readonly superCallCount: number;
68
+ readonly thisBeforeSuper: boolean;
69
+ readonly declaredFields: readonly string[];
70
+ readonly initializedFields: readonly string[];
71
+ readonly uninitializedRequiredFields: readonly string[];
72
+ readonly provenance: 'static-analysis';
73
+ readonly loc?: ClassSemanticLocation;
74
+ }
75
+ export interface ClassSemanticInheritanceEdge {
76
+ readonly from: string;
77
+ readonly to: string;
78
+ readonly relation: 'extends';
79
+ readonly resolved: boolean;
80
+ readonly builtin: boolean;
81
+ }
82
+ export interface ClassSemanticImplementsEdge {
83
+ readonly from: string;
84
+ readonly to: string;
85
+ readonly relation: 'implements';
86
+ readonly resolved: boolean;
87
+ readonly external: boolean;
88
+ }
89
+ export interface ClassSemanticOverrideFact {
90
+ readonly className: string;
91
+ readonly memberName: string;
92
+ readonly static: boolean;
93
+ readonly kind: ClassSemanticMemberKind;
94
+ readonly arity: number;
95
+ readonly baseClassName: string;
96
+ readonly baseKind: ClassSemanticMemberKind;
97
+ readonly baseArity: number;
98
+ readonly status: ClassSemanticOverrideStatus;
99
+ readonly loc?: ClassSemanticLocation;
100
+ }
101
+ export type ClassSemanticProtocolStatus = 'satisfied' | 'missing-members' | 'external' | 'unknown-interface' | 'invalid-interface' | 'unsupported-protocol';
102
+ export interface ClassSemanticProtocolConformanceFact {
103
+ readonly className: string;
104
+ readonly interfaceName: string;
105
+ readonly status: ClassSemanticProtocolStatus;
106
+ readonly missingMembers: readonly string[];
107
+ readonly satisfiedMembers: readonly string[];
108
+ readonly missingStaticMembers: readonly string[];
109
+ readonly satisfiedStaticMembers: readonly string[];
110
+ readonly diagnostics?: readonly string[];
111
+ readonly unsupportedReasons?: readonly string[];
112
+ readonly loc?: ClassSemanticLocation;
113
+ }
114
+ export interface ClassSemanticFacts {
115
+ readonly classes: readonly ClassSemanticClassFact[];
116
+ readonly constructorFacts: readonly ClassSemanticConstructorFact[];
117
+ readonly inheritanceEdges: readonly ClassSemanticInheritanceEdge[];
118
+ readonly implementsEdges: readonly ClassSemanticImplementsEdge[];
119
+ readonly overrides: readonly ClassSemanticOverrideFact[];
120
+ readonly unresolvedBases: readonly string[];
121
+ readonly unresolvedImplements: readonly string[];
122
+ readonly protocolConformance: readonly ClassSemanticProtocolConformanceFact[];
123
+ readonly cycles: readonly (readonly string[])[];
124
+ }
125
+ export interface RagSemanticLocation {
126
+ readonly line: number;
127
+ readonly col: number;
128
+ }
129
+ export interface RagSemanticSourceFact {
130
+ readonly name?: string;
131
+ readonly corpusName?: string;
132
+ readonly kind?: string;
133
+ readonly uri: string;
134
+ readonly resourceName?: string;
135
+ readonly media?: string;
136
+ readonly acl?: string;
137
+ readonly loc?: RagSemanticLocation;
138
+ }
139
+ export interface RagSemanticChunkingFact {
140
+ readonly name?: string;
141
+ readonly corpusName?: string;
142
+ readonly sourceName?: string;
143
+ readonly strategy?: string;
144
+ readonly maxTokens?: number;
145
+ readonly overlap?: number;
146
+ readonly unit?: string;
147
+ readonly loc?: RagSemanticLocation;
148
+ }
149
+ export interface RagSemanticEmbedFact {
150
+ readonly name: string;
151
+ readonly corpusName: string;
152
+ readonly model?: string;
153
+ readonly dims?: number;
154
+ readonly metric?: string;
155
+ readonly loc?: RagSemanticLocation;
156
+ }
157
+ export interface RagSemanticCorpusFact {
158
+ readonly name: string;
159
+ readonly title?: string;
160
+ readonly tenant?: string;
161
+ readonly refresh?: string;
162
+ readonly sources: readonly RagSemanticSourceFact[];
163
+ readonly chunking: readonly RagSemanticChunkingFact[];
164
+ readonly embeds: readonly RagSemanticEmbedFact[];
165
+ readonly loc?: RagSemanticLocation;
166
+ }
167
+ export interface RagSemanticRetrieverFact {
168
+ readonly name: string;
169
+ readonly corpusName: string;
170
+ readonly embedName?: string;
171
+ readonly mode?: string;
172
+ readonly topK?: number;
173
+ readonly minScore?: number;
174
+ readonly rerank?: string;
175
+ readonly loc?: RagSemanticLocation;
176
+ }
177
+ export interface RagSemanticGroundingFact {
178
+ readonly name?: string;
179
+ readonly ragName?: string;
180
+ readonly requireCitations: boolean;
181
+ readonly policy?: string;
182
+ readonly maxContext?: number;
183
+ readonly loc?: RagSemanticLocation;
184
+ }
185
+ export interface RagSemanticEvalFact {
186
+ readonly name?: string;
187
+ readonly ragName?: string;
188
+ readonly metric?: string;
189
+ readonly threshold?: number;
190
+ readonly mode?: string;
191
+ readonly caseCount?: number;
192
+ readonly assertCount?: number;
193
+ readonly cases?: readonly RagSemanticEvalCaseFact[];
194
+ readonly loc?: RagSemanticLocation;
195
+ }
196
+ export interface RagSemanticEvalCaseFact {
197
+ readonly name: string;
198
+ readonly ragName?: string;
199
+ readonly evalName?: string;
200
+ readonly query: string;
201
+ readonly tags: readonly string[];
202
+ readonly expected: {
203
+ readonly topK?: number;
204
+ readonly minScore?: number;
205
+ readonly chunkCount?: number;
206
+ readonly sources?: readonly string[];
207
+ };
208
+ readonly asserts: readonly RagSemanticEvalAssertFact[];
209
+ readonly loc?: RagSemanticLocation;
210
+ }
211
+ export interface RagSemanticEvalAssertFact {
212
+ readonly ragName?: string;
213
+ readonly evalName?: string;
214
+ readonly caseName?: string;
215
+ readonly kind: string;
216
+ readonly target: 'retrieved-chunk' | 'retrieved-chunks' | 'grounding' | 'latency';
217
+ readonly op: 'eq' | 'gte' | 'lte' | 'contains' | 'glob' | 'present';
218
+ readonly value?: string | number | boolean;
219
+ readonly required: boolean;
220
+ readonly loc?: RagSemanticLocation;
221
+ }
222
+ export interface RagSemanticAnswerSpanFact {
223
+ readonly start: number;
224
+ readonly end: number;
225
+ readonly chunkIds: readonly string[];
226
+ readonly required: boolean;
227
+ readonly loc?: RagSemanticLocation;
228
+ }
229
+ export interface RagSemanticAnswerContractFact {
230
+ readonly name: string;
231
+ readonly ragName?: string;
232
+ readonly query: string;
233
+ readonly answer: string;
234
+ readonly prompt?: string;
235
+ readonly requireCitations: boolean;
236
+ readonly minGroundingCoverage?: number;
237
+ readonly spans: readonly RagSemanticAnswerSpanFact[];
238
+ readonly loc?: RagSemanticLocation;
239
+ }
240
+ export interface RagSemanticPipelineFact {
241
+ readonly name: string;
242
+ readonly retrieverName: string;
243
+ readonly prompt?: string;
244
+ readonly answer?: string;
245
+ readonly citations: boolean;
246
+ readonly groundings: readonly RagSemanticGroundingFact[];
247
+ readonly evals: readonly RagSemanticEvalFact[];
248
+ readonly answerContracts: readonly RagSemanticAnswerContractFact[];
249
+ readonly loc?: RagSemanticLocation;
250
+ }
251
+ export interface RagSemanticMcpRetrievalFact {
252
+ readonly containerKind?: 'tool' | 'prompt';
253
+ readonly containerName?: string;
254
+ readonly targetKind: 'retriever' | 'rag';
255
+ readonly targetName: string;
256
+ readonly name?: string;
257
+ readonly queryParam?: string;
258
+ readonly query?: string;
259
+ readonly as?: string;
260
+ readonly topK?: number;
261
+ readonly minScore?: number;
262
+ readonly requireGrounding: boolean;
263
+ readonly outputShape?: string;
264
+ readonly outputItemShape?: string;
265
+ readonly requireCitations?: boolean;
266
+ readonly effectiveRequiresCitations: boolean;
267
+ readonly provenance?: string;
268
+ readonly citationField?: string;
269
+ readonly sourceField?: string;
270
+ readonly scoreField?: string;
271
+ readonly contractStatus: 'absent' | 'valid' | 'invalid';
272
+ readonly loc?: RagSemanticLocation;
273
+ }
274
+ export interface RagSemanticResourceFeedFact {
275
+ readonly corpusName?: string;
276
+ readonly sourceName?: string;
277
+ readonly resourceName: string;
278
+ readonly uri: string;
279
+ readonly loc?: RagSemanticLocation;
280
+ }
281
+ export interface RagSemanticFacts {
282
+ readonly corpora: readonly RagSemanticCorpusFact[];
283
+ readonly retrievers: readonly RagSemanticRetrieverFact[];
284
+ readonly pipelines: readonly RagSemanticPipelineFact[];
285
+ readonly mcpRetrievals: readonly RagSemanticMcpRetrievalFact[];
286
+ readonly resourceFeedsCorpora: readonly RagSemanticResourceFeedFact[];
287
+ readonly unresolvedCorpusRefs: readonly string[];
288
+ readonly unresolvedRetrieverRefs: readonly string[];
289
+ readonly unresolvedEmbedRefs: readonly string[];
290
+ readonly unresolvedRagRefs: readonly string[];
291
+ readonly unresolvedSourceRefs: readonly string[];
292
+ readonly unresolvedResourceRefs: readonly string[];
293
+ }
25
294
  /**
26
295
  * Run semantic validation on an IR tree.
27
296
  * Returns an empty array when the tree is valid.
28
297
  */
29
298
  export declare function validateSemantics(root: IRNode): SemanticViolation[];
299
+ export declare function validateClassSemantics(root: IRNode | readonly IRNode[]): SemanticViolation[];
300
+ export declare function validateRagSemantics(root: IRNode | readonly IRNode[]): SemanticViolation[];
301
+ export declare function collectRagSemanticFacts(root: IRNode | readonly IRNode[]): RagSemanticFacts;
302
+ export type ClassMemberKind = 'field' | 'method' | 'getter' | 'setter';
303
+ export interface ClassInfo {
304
+ node: IRNode;
305
+ rootIndex: number;
306
+ name: string;
307
+ baseName?: string;
308
+ implementsNames: string[];
309
+ implementsMalformed: boolean;
310
+ members: ClassMemberInfo[];
311
+ constructors: IRNode[];
312
+ }
313
+ export interface ClassMemberInfo {
314
+ node: IRNode;
315
+ owner: string;
316
+ name: string;
317
+ kind: ClassMemberKind;
318
+ static: boolean;
319
+ private: boolean;
320
+ async: boolean;
321
+ stream: boolean;
322
+ generator: boolean;
323
+ type?: string;
324
+ returns?: string;
325
+ paramTypes: readonly string[];
326
+ arity: number;
327
+ }
328
+ export declare const RAG_MCP_RETRIEVE_OUTPUT_SHAPE = "RetrievedChunk[]";
329
+ export declare const RAG_MCP_RETRIEVE_OUTPUT_ITEM_SHAPE = "RetrievedChunk";
330
+ export declare function collectClassInfos(root: IRNode, rootIndex?: number): ClassInfo[];
331
+ export declare function collectClassSemanticFacts(root: IRNode | readonly IRNode[]): ClassSemanticFacts;
332
+ /**
333
+ * Liskov substitutability check for a member override against its base member.
334
+ *
335
+ * Runs ONLY when kinds are strictly equal (method/method, getter/getter,
336
+ * setter/setter). Mixed accessor pairs (getter overriding setter, or vice
337
+ * versa) and fields return null (skip) to preserve existing behavior. For
338
+ * methods, it assumes arity has already matched (arity-mismatch fires first).
339
+ *
340
+ * Variance rules:
341
+ * - Return position is COVARIANT: an override may narrow the return type
342
+ * (override.returns must be a subtype of base.returns). A non-subtype is a
343
+ * 'return-mismatch'.
344
+ * - Param positions are CONTRAVARIANT: an override may widen a param type
345
+ * (base.paramTypes[i] must be a subtype of override.paramTypes[i]). A
346
+ * non-subtype is a 'param-mismatch'.
347
+ *
348
+ * 'unknown' subtype results (gradual typing — primitives, unannotated, or
349
+ * non-class names) are skipped, so the check produces zero false positives.
350
+ */
351
+ export declare function checkOverrideVariance(member: ClassMemberInfo, baseMember: ClassMemberInfo, classByName: ReadonlyMap<string, ClassInfo>): 'return-mismatch' | 'param-mismatch' | null;
352
+ /**
353
+ * Nominal subtype check: is `sub` a (non-strict) subtype of `sup`?
354
+ * - undefined on either side → 'unknown' (gradual: caller skips).
355
+ * - sub === sup → true.
356
+ * - either name not a known class in classByName → 'unknown' (primitives /
357
+ * external / unresolved types are not compared).
358
+ * - else cycle-safe walk of sub's baseName chain; reaching sup → true; chain
359
+ * ends or cycles without reaching sup → false.
360
+ */
361
+ export declare function isNominalSubtype(sub: string | undefined, sup: string | undefined, classByName: ReadonlyMap<string, ClassInfo>): true | false | 'unknown';