@manifesto-ai/compiler 1.8.3 → 1.9.1

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 (72) hide show
  1. package/dist/analyzer/entity-primitives.d.ts +3 -0
  2. package/dist/analyzer/expr-type-surface.d.ts +21 -0
  3. package/dist/analyzer/flow-composition.d.ts +7 -0
  4. package/dist/analyzer/index.d.ts +5 -0
  5. package/dist/analyzer/scope.d.ts +76 -0
  6. package/dist/analyzer/validator.d.ts +69 -0
  7. package/dist/api/compile-mel-patch-collector.d.ts +33 -0
  8. package/dist/api/compile-mel-patch-expr.d.ts +8 -0
  9. package/dist/api/compile-mel-patch-location.d.ts +9 -0
  10. package/dist/api/compile-mel-patch.d.ts +5 -0
  11. package/dist/api/compile-mel.d.ts +125 -0
  12. package/dist/api/index.d.ts +9 -0
  13. package/dist/{chunk-4JJQCFJH.js → chunk-7TT6Y5ZC.js} +6 -2
  14. package/dist/chunk-7TT6Y5ZC.js.map +1 -0
  15. package/dist/{chunk-AYZTDA3J.js → chunk-LI5HNMZV.js} +2 -2
  16. package/dist/{chunk-K4IKHGOP.js → chunk-WZRGVNJK.js} +3 -3
  17. package/dist/diagnostics/codes.d.ts +24 -0
  18. package/dist/diagnostics/format.d.ts +25 -0
  19. package/dist/diagnostics/index.d.ts +6 -0
  20. package/dist/diagnostics/types.d.ts +66 -0
  21. package/dist/esbuild.d.ts +6 -8
  22. package/dist/esbuild.js +3 -3
  23. package/dist/evaluation/context.d.ts +90 -0
  24. package/dist/evaluation/evaluate-expr.d.ts +23 -0
  25. package/dist/evaluation/evaluate-patch.d.ts +122 -0
  26. package/dist/evaluation/evaluate-runtime-patch.d.ts +59 -0
  27. package/dist/evaluation/index.d.ts +14 -0
  28. package/dist/generator/index.d.ts +6 -0
  29. package/dist/generator/ir.d.ts +185 -0
  30. package/dist/generator/lowering.d.ts +10 -0
  31. package/dist/generator/normalizer.d.ts +15 -0
  32. package/dist/generator/runtime-lowering.d.ts +2 -0
  33. package/dist/index.d.ts +19 -2785
  34. package/dist/index.js +1 -1
  35. package/dist/lexer/index.d.ts +6 -0
  36. package/dist/lexer/lexer.d.ts +58 -0
  37. package/dist/lexer/source-location.d.ts +40 -0
  38. package/dist/lexer/tokens.d.ts +46 -0
  39. package/dist/lowering/context.d.ts +95 -0
  40. package/dist/lowering/errors.d.ts +83 -0
  41. package/dist/lowering/index.d.ts +19 -0
  42. package/dist/lowering/lower-expr.d.ts +79 -0
  43. package/dist/lowering/lower-patch.d.ts +230 -0
  44. package/dist/lowering/lower-runtime-patch.d.ts +126 -0
  45. package/dist/lowering/to-mel-expr.d.ts +12 -0
  46. package/dist/mel-module.d.ts +14 -0
  47. package/dist/node-loader.d.ts +3 -7
  48. package/dist/node-loader.js +2 -2
  49. package/dist/parser/ast.d.ts +367 -0
  50. package/dist/parser/index.d.ts +6 -0
  51. package/dist/parser/parser.d.ts +101 -0
  52. package/dist/parser/precedence.d.ts +43 -0
  53. package/dist/renderer/expr-node.d.ts +171 -0
  54. package/dist/renderer/fragment.d.ts +83 -0
  55. package/dist/renderer/index.d.ts +22 -0
  56. package/dist/renderer/patch-op.d.ts +81 -0
  57. package/dist/renderer/type-expr.d.ts +60 -0
  58. package/dist/rollup.d.ts +6 -8
  59. package/dist/rollup.js +3 -3
  60. package/dist/rspack.d.ts +6 -7
  61. package/dist/rspack.js +3 -3
  62. package/dist/unplugin.d.ts +14 -0
  63. package/dist/utils/unicode-order.d.ts +5 -0
  64. package/dist/vite.d.ts +6 -8
  65. package/dist/vite.js +3 -3
  66. package/dist/webpack.d.ts +6 -8
  67. package/dist/webpack.js +3 -3
  68. package/package.json +16 -14
  69. package/dist/chunk-4JJQCFJH.js.map +0 -1
  70. package/dist/unplugin-6wnvFiEo.d.ts +0 -17
  71. /package/dist/{chunk-AYZTDA3J.js.map → chunk-LI5HNMZV.js.map} +0 -0
  72. /package/dist/{chunk-K4IKHGOP.js.map → chunk-WZRGVNJK.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,2788 +1,24 @@
1
- import { ExprNode as ExprNode$2, PatchPath, Patch } from '@manifesto-ai/core';
2
-
3
- /**
4
- * Source Location Types
5
- * Tracks positions in MEL source code for error reporting
6
- */
7
- /**
8
- * A position in source code (1-based line/column)
9
- */
10
- interface Position {
11
- /** 1-based line number */
12
- line: number;
13
- /** 1-based column number */
14
- column: number;
15
- /** 0-based byte offset from start of source */
16
- offset: number;
17
- }
18
- /**
19
- * A span in source code (start to end)
20
- */
21
- interface SourceLocation {
22
- start: Position;
23
- end: Position;
24
- /** Optional source file path */
25
- source?: string;
26
- }
27
- /**
28
- * Create a position
29
- */
30
- declare function createPosition(line: number, column: number, offset: number): Position;
31
- /**
32
- * Create a source location from two positions
33
- */
34
- declare function createLocation(start: Position, end: Position, source?: string): SourceLocation;
35
- /**
36
- * Create a zero-width location at a position
37
- */
38
- declare function createPointLocation(pos: Position, source?: string): SourceLocation;
39
- /**
40
- * Merge two locations into one spanning both
41
- */
42
- declare function mergeLocations(a: SourceLocation, b: SourceLocation): SourceLocation;
43
-
44
- /**
45
- * Token Types for MEL Lexer
46
- * Based on MEL SPEC v0.3.3 Section 3
47
- */
48
-
49
- /**
50
- * All token kinds in MEL
51
- */
52
- type TokenKind = "DOMAIN" | "STATE" | "COMPUTED" | "ACTION" | "EFFECT" | "WHEN" | "ONCE" | "PATCH" | "UNSET" | "MERGE" | "TRUE" | "FALSE" | "NULL" | "AS" | "AVAILABLE" | "FAIL" | "STOP" | "WITH" | "TYPE" | "IMPORT" | "FROM" | "EXPORT" | "PLUS" | "MINUS" | "STAR" | "SLASH" | "PERCENT" | "EQ_EQ" | "BANG_EQ" | "LT" | "LT_EQ" | "GT" | "GT_EQ" | "AMP_AMP" | "PIPE_PIPE" | "BANG" | "QUESTION_QUESTION" | "QUESTION" | "COLON" | "EQ" | "LPAREN" | "RPAREN" | "LBRACE" | "RBRACE" | "LBRACKET" | "RBRACKET" | "COMMA" | "SEMICOLON" | "DOT" | "PIPE" | "NUMBER" | "STRING" | "IDENTIFIER" | "SYSTEM_IDENT" | "ITEM" | "EOF" | "ERROR";
53
- /**
54
- * A token produced by the lexer
55
- */
56
- interface Token {
57
- kind: TokenKind;
58
- /** The raw text of the token */
59
- lexeme: string;
60
- /** Parsed value for literals */
61
- value?: unknown;
62
- /** Location in source */
63
- location: SourceLocation;
64
- }
65
- /**
66
- * Keywords lookup table
67
- */
68
- declare const KEYWORDS: Record<string, TokenKind>;
69
- /**
70
- * Reserved keywords (JS keywords that are forbidden in MEL)
71
- */
72
- declare const RESERVED_KEYWORDS: Set<string>;
73
- /**
74
- * Check if a token is a keyword
75
- */
76
- declare function isKeyword(lexeme: string): boolean;
77
- /**
78
- * Check if a token is a reserved word
79
- */
80
- declare function isReserved(lexeme: string): boolean;
81
- /**
82
- * Get keyword token kind, or undefined if not a keyword
83
- * Note: Uses Object.hasOwn to avoid prototype pollution (e.g., "toString")
84
- */
85
- declare function getKeywordKind(lexeme: string): TokenKind | undefined;
86
- /**
87
- * Create a token
88
- */
89
- declare function createToken(kind: TokenKind, lexeme: string, location: SourceLocation, value?: unknown): Token;
90
-
91
- /**
92
- * Diagnostic Types for MEL Compiler
93
- * Error and warning reporting structures
94
- */
95
-
96
- /**
97
- * Severity level of a diagnostic
98
- */
99
- type DiagnosticSeverity = "error" | "warning" | "info";
100
- /**
101
- * A diagnostic message (error, warning, or info)
102
- */
103
- interface Diagnostic {
104
- /** Severity level */
105
- severity: DiagnosticSeverity;
106
- /** Error code (e.g., "MEL001", "MEL_LEXER") */
107
- code: string;
108
- /** Human-readable message */
109
- message: string;
110
- /** Location in source */
111
- location: SourceLocation;
112
- /** The source line containing the error */
113
- source?: string;
114
- /** Suggested fix */
115
- suggestion?: string;
116
- /** Related diagnostics */
117
- related?: RelatedDiagnostic[];
118
- }
119
- /**
120
- * A related diagnostic (for multi-location errors)
121
- */
122
- interface RelatedDiagnostic {
123
- message: string;
124
- location: SourceLocation;
125
- }
126
- /**
127
- * Create an error diagnostic
128
- */
129
- declare function createError(code: string, message: string, location: SourceLocation, options?: {
130
- source?: string;
131
- suggestion?: string;
132
- related?: RelatedDiagnostic[];
133
- }): Diagnostic;
134
- /**
135
- * Create a warning diagnostic
136
- */
137
- declare function createWarning(code: string, message: string, location: SourceLocation, options?: {
138
- source?: string;
139
- suggestion?: string;
140
- }): Diagnostic;
141
- /**
142
- * Create an info diagnostic
143
- */
144
- declare function createInfo(code: string, message: string, location: SourceLocation): Diagnostic;
145
- /**
146
- * Check if a diagnostic is an error
147
- */
148
- declare function isError(diagnostic: Diagnostic): boolean;
149
- /**
150
- * Check if any diagnostics contain errors
151
- */
152
- declare function hasErrors(diagnostics: Diagnostic[]): boolean;
153
- /**
154
- * Filter diagnostics by severity
155
- */
156
- declare function filterBySeverity(diagnostics: Diagnostic[], severity: DiagnosticSeverity): Diagnostic[];
157
-
158
- /**
159
- * MEL Lexer
160
- * Tokenizes MEL source code based on SPEC v0.3.1 Section 3
161
- */
162
-
163
- /**
164
- * Result of lexical analysis
165
- */
166
- interface LexResult {
167
- tokens: Token[];
168
- diagnostics: Diagnostic[];
169
- }
170
- /**
171
- * Lexer for MEL source code
172
- */
173
- declare class Lexer {
174
- private source;
175
- private sourcePath?;
176
- private tokens;
177
- private diagnostics;
178
- private start;
179
- private current;
180
- private line;
181
- private column;
182
- private lineStart;
183
- constructor(source: string, sourcePath?: string);
184
- /**
185
- * Tokenize the source code
186
- */
187
- tokenize(): LexResult;
188
- private scanToken;
189
- private lineComment;
190
- private blockComment;
191
- private string;
192
- private number;
193
- private identifier;
194
- private systemIdentifier;
195
- private isAtEnd;
196
- private advance;
197
- private peek;
198
- private peekNext;
199
- private match;
200
- private newline;
201
- private isDigit;
202
- private isHexDigit;
203
- private isAlpha;
204
- private isAlphaNumeric;
205
- private currentLocation;
206
- private positionAt;
207
- private addToken;
208
- private error;
209
- private getSourceLine;
210
- }
211
- /**
212
- * Tokenize MEL source code
213
- */
214
- declare function tokenize(source: string, sourcePath?: string): LexResult;
215
-
216
- /**
217
- * AST Node Types for MEL Parser
218
- * Based on MEL SPEC v0.3.3 Section 4
219
- */
220
-
221
- /**
222
- * Base interface for all AST nodes
223
- */
224
- interface ASTNode {
225
- location: SourceLocation;
226
- }
227
- /**
228
- * Root node of a MEL program
229
- */
230
- interface ProgramNode extends ASTNode {
231
- kind: "program";
232
- imports: ImportNode[];
233
- domain: DomainNode;
234
- }
235
- /**
236
- * Import declaration
237
- */
238
- interface ImportNode extends ASTNode {
239
- kind: "import";
240
- names: string[];
241
- from: string;
242
- }
243
- /**
244
- * Domain declaration
245
- */
246
- interface DomainNode extends ASTNode {
247
- kind: "domain";
248
- name: string;
249
- /** v0.3.3: Named type declarations */
250
- types: TypeDeclNode[];
251
- members: DomainMember[];
252
- }
253
- /**
254
- * Domain member types
255
- */
256
- type DomainMember = StateNode | ComputedNode | ActionNode | FlowDeclNode;
257
- /**
258
- * Type declaration (v0.3.3)
259
- * Syntax: type Name = TypeExpr
260
- */
261
- interface TypeDeclNode extends ASTNode {
262
- kind: "typeDecl";
263
- name: string;
264
- typeExpr: TypeExprNode;
265
- }
266
- /**
267
- * State block declaration
268
- */
269
- interface StateNode extends ASTNode {
270
- kind: "state";
271
- fields: StateFieldNode[];
272
- }
273
- /**
274
- * State field declaration
275
- */
276
- interface StateFieldNode extends ASTNode {
277
- kind: "stateField";
278
- name: string;
279
- typeExpr: TypeExprNode;
280
- initializer?: ExprNode$1;
281
- }
282
- /**
283
- * Computed value declaration
284
- */
285
- interface ComputedNode extends ASTNode {
286
- kind: "computed";
287
- name: string;
288
- expression: ExprNode$1;
289
- }
290
- /**
291
- * Action declaration
292
- */
293
- interface ActionNode extends ASTNode {
294
- kind: "action";
295
- name: string;
296
- params: ParamNode[];
297
- /** v0.3.2: Optional availability condition */
298
- available?: ExprNode$1;
299
- body: GuardedStmtNode[];
300
- }
301
- /**
302
- * Flow declaration (v0.7.0 / ADR-013a)
303
- * Raw AST preserves flow declarations until the expansion pass removes them.
304
- */
305
- interface FlowDeclNode extends ASTNode {
306
- kind: "flow";
307
- name: string;
308
- params: ParamNode[];
309
- body: FlowStmtNode[];
310
- }
311
- /**
312
- * Parameter declaration
313
- */
314
- interface ParamNode extends ASTNode {
315
- kind: "param";
316
- name: string;
317
- typeExpr: TypeExprNode;
318
- }
319
- /**
320
- * Guarded statement types (top-level in action body)
321
- */
322
- type GuardedStmtNode = WhenStmtNode | OnceStmtNode | OnceIntentStmtNode | IncludeStmtNode | FailStmtNode | StopStmtNode;
323
- /**
324
- * Raw flow statement types (top-level in flow body).
325
- * Parser stays permissive; validation narrows the allowed subset.
326
- */
327
- type FlowStmtNode = WhenStmtNode | IncludeStmtNode | OnceStmtNode | OnceIntentStmtNode | PatchStmtNode | EffectStmtNode;
328
- /**
329
- * Inner statement types (inside guards)
330
- */
331
- type InnerStmtNode = PatchStmtNode | EffectStmtNode | WhenStmtNode | OnceStmtNode | OnceIntentStmtNode | IncludeStmtNode | FailStmtNode | StopStmtNode;
332
- /**
333
- * When guard statement
334
- */
335
- interface WhenStmtNode extends ASTNode {
336
- kind: "when";
337
- condition: ExprNode$1;
338
- body: InnerStmtNode[];
339
- }
340
- /**
341
- * Once guard statement (per-intent idempotency)
342
- */
343
- interface OnceStmtNode extends ASTNode {
344
- kind: "once";
345
- marker: PathNode;
346
- condition?: ExprNode$1;
347
- body: InnerStmtNode[];
348
- }
349
- /**
350
- * Once-intent guard statement (per-intent idempotency sugar)
351
- */
352
- interface OnceIntentStmtNode extends ASTNode {
353
- kind: "onceIntent";
354
- condition?: ExprNode$1;
355
- body: InnerStmtNode[];
356
- }
357
- /**
358
- * Include statement (v0.7.0 / ADR-013a)
359
- * Raw AST preserves include sites until the expansion pass inlines them.
360
- */
361
- interface IncludeStmtNode extends ASTNode {
362
- kind: "include";
363
- flowName: string;
364
- args: ExprNode$1[];
365
- }
366
- /**
367
- * Patch statement
368
- */
369
- interface PatchStmtNode extends ASTNode {
370
- kind: "patch";
371
- path: PathNode;
372
- op: "set" | "unset" | "merge";
373
- value?: ExprNode$1;
374
- }
375
- /**
376
- * Effect statement
377
- */
378
- interface EffectStmtNode extends ASTNode {
379
- kind: "effect";
380
- effectType: string;
381
- args: EffectArgNode[];
382
- }
383
- /**
384
- * Effect argument
385
- */
386
- interface EffectArgNode extends ASTNode {
387
- kind: "effectArg";
388
- name: string;
389
- value: ExprNode$1 | PathNode;
390
- isPath: boolean;
391
- }
392
- /**
393
- * Fail statement (v0.3.2) - terminates flow with error
394
- * Compiles to FlowNode { kind: "fail", code, message }
395
- */
396
- interface FailStmtNode extends ASTNode {
397
- kind: "fail";
398
- code: string;
399
- message?: ExprNode$1;
400
- }
401
- /**
402
- * Stop statement (v0.3.2) - early exit, no error
403
- * Compiles to FlowNode { kind: "halt", reason }
404
- */
405
- interface StopStmtNode extends ASTNode {
406
- kind: "stop";
407
- reason: string;
408
- }
409
- /**
410
- * Type expression node
411
- */
412
- type TypeExprNode = SimpleTypeNode | UnionTypeNode | ArrayTypeNode | RecordTypeNode | LiteralTypeNode | ObjectTypeNode;
413
- interface SimpleTypeNode extends ASTNode {
414
- kind: "simpleType";
415
- name: string;
416
- }
417
- interface UnionTypeNode extends ASTNode {
418
- kind: "unionType";
419
- types: TypeExprNode[];
420
- }
421
- interface ArrayTypeNode extends ASTNode {
422
- kind: "arrayType";
423
- elementType: TypeExprNode;
424
- }
425
- interface RecordTypeNode extends ASTNode {
426
- kind: "recordType";
427
- keyType: TypeExprNode;
428
- valueType: TypeExprNode;
429
- }
430
- interface LiteralTypeNode extends ASTNode {
431
- kind: "literalType";
432
- value: string | number | boolean | null;
433
- }
434
- /**
435
- * Object type node (v0.3.3)
436
- * Represents inline object types: { field: Type, ... }
437
- * Note: In state fields, this triggers W012 warning (use named type instead)
438
- */
439
- interface ObjectTypeNode extends ASTNode {
440
- kind: "objectType";
441
- fields: TypeFieldNode[];
442
- }
443
- /**
444
- * Type field within an object type
445
- */
446
- interface TypeFieldNode extends ASTNode {
447
- kind: "typeField";
448
- name: string;
449
- typeExpr: TypeExprNode;
450
- optional: boolean;
451
- }
452
- /**
453
- * All expression types
454
- */
455
- type ExprNode$1 = LiteralExprNode | IdentifierExprNode | SystemIdentExprNode | IterationVarExprNode | PropertyAccessExprNode | IndexAccessExprNode | FunctionCallExprNode | UnaryExprNode | BinaryExprNode | TernaryExprNode | ObjectLiteralExprNode | ArrayLiteralExprNode;
456
- /**
457
- * Literal expression (number, string, boolean, null)
458
- */
459
- interface LiteralExprNode extends ASTNode {
460
- kind: "literal";
461
- value: unknown;
462
- literalType: "number" | "string" | "boolean" | "null";
463
- }
464
- /**
465
- * Identifier expression
466
- */
467
- interface IdentifierExprNode extends ASTNode {
468
- kind: "identifier";
469
- name: string;
470
- }
471
- /**
472
- * System identifier expression ($system.*, $meta.*, $input.*)
473
- */
474
- interface SystemIdentExprNode extends ASTNode {
475
- kind: "systemIdent";
476
- path: string[];
477
- }
478
- /**
479
- * Iteration variable expression ($item only)
480
- * v0.3.2: $acc removed - reduce pattern deprecated
481
- */
482
- interface IterationVarExprNode extends ASTNode {
483
- kind: "iterationVar";
484
- name: "item";
485
- }
486
- /**
487
- * Property access expression (a.b)
488
- */
489
- interface PropertyAccessExprNode extends ASTNode {
490
- kind: "propertyAccess";
491
- object: ExprNode$1;
492
- property: string;
493
- }
494
- /**
495
- * Index access expression (a[b])
496
- */
497
- interface IndexAccessExprNode extends ASTNode {
498
- kind: "indexAccess";
499
- object: ExprNode$1;
500
- index: ExprNode$1;
501
- }
502
- /**
503
- * Function call expression
504
- */
505
- interface FunctionCallExprNode extends ASTNode {
506
- kind: "functionCall";
507
- name: string;
508
- args: ExprNode$1[];
509
- }
510
- /**
511
- * Unary expression (!a, -a)
512
- */
513
- interface UnaryExprNode extends ASTNode {
514
- kind: "unary";
515
- operator: "!" | "-";
516
- operand: ExprNode$1;
517
- }
518
- /**
519
- * Binary operators
520
- */
521
- type BinaryOperator = "+" | "-" | "*" | "/" | "%" | "==" | "!=" | "<" | "<=" | ">" | ">=" | "&&" | "||" | "??";
522
- /**
523
- * Binary expression (a + b, a && b, etc.)
524
- */
525
- interface BinaryExprNode extends ASTNode {
526
- kind: "binary";
527
- operator: BinaryOperator;
528
- left: ExprNode$1;
529
- right: ExprNode$1;
530
- }
531
- /**
532
- * Ternary expression (a ? b : c)
533
- */
534
- interface TernaryExprNode extends ASTNode {
535
- kind: "ternary";
536
- condition: ExprNode$1;
537
- consequent: ExprNode$1;
538
- alternate: ExprNode$1;
539
- }
540
- /**
541
- * Object literal expression ({ a: 1, b: 2 })
542
- */
543
- interface ObjectLiteralExprNode extends ASTNode {
544
- kind: "objectLiteral";
545
- properties: ObjectPropertyNode[];
546
- }
547
- interface ObjectPropertyNode extends ASTNode {
548
- kind: "objectProperty";
549
- key: string;
550
- value: ExprNode$1;
551
- }
552
- /**
553
- * Array literal expression ([1, 2, 3])
554
- */
555
- interface ArrayLiteralExprNode extends ASTNode {
556
- kind: "arrayLiteral";
557
- elements: ExprNode$1[];
558
- }
559
- /**
560
- * Path node for patch targets and effect destinations
561
- */
562
- interface PathNode extends ASTNode {
563
- kind: "path";
564
- segments: PathSegmentNode[];
565
- }
566
- type PathSegmentNode = PropertySegmentNode | IndexSegmentNode;
567
- interface PropertySegmentNode extends ASTNode {
568
- kind: "propertySegment";
569
- name: string;
570
- }
571
- interface IndexSegmentNode extends ASTNode {
572
- kind: "indexSegment";
573
- index: ExprNode$1;
574
- }
575
- /**
576
- * Check if a node is an expression
577
- */
578
- declare function isExprNode(node: ASTNode): node is ExprNode$1;
579
- /**
580
- * Check if a node is a statement
581
- */
582
- declare function isStmtNode(node: ASTNode): node is InnerStmtNode;
583
-
584
- /**
585
- * Operator Precedence for MEL Parser
586
- * Based on MEL SPEC v0.3.1 Section 4.9
587
- */
588
-
589
- /**
590
- * Precedence levels (higher = binds tighter)
591
- */
592
- declare const enum Precedence {
593
- NONE = 0,
594
- TERNARY = 1,// ? :
595
- NULLISH = 2,// ??
596
- OR = 3,// ||
597
- AND = 4,// &&
598
- EQUALITY = 5,// == !=
599
- COMPARISON = 6,// < <= > >=
600
- ADDITIVE = 7,// + -
601
- MULTIPLICATIVE = 8,// * / %
602
- UNARY = 9,// ! -
603
- CALL = 10,// ()
604
- ACCESS = 11
605
- }
606
- /**
607
- * Get the precedence of a binary operator token
608
- */
609
- declare function getBinaryPrecedence(kind: TokenKind): Precedence;
610
- /**
611
- * Map token kind to binary operator
612
- */
613
- declare function tokenToBinaryOp(kind: TokenKind): BinaryOperator | null;
614
- /**
615
- * Check if a token is a binary operator
616
- */
617
- declare function isBinaryOp(kind: TokenKind): boolean;
618
- /**
619
- * Check if a token is a unary operator
620
- */
621
- declare function isUnaryOp(kind: TokenKind): boolean;
622
- /**
623
- * Check if operators are right-associative
624
- */
625
- declare function isRightAssociative(kind: TokenKind): boolean;
626
-
627
- /**
628
- * MEL Parser
629
- * Recursive descent parser with Pratt parsing for expressions
630
- * Based on MEL SPEC v0.3.3 Section 4
631
- */
632
-
633
- /**
634
- * Result of parsing
635
- */
636
- interface ParseResult {
637
- program: ProgramNode | null;
638
- diagnostics: Diagnostic[];
639
- }
640
- /**
641
- * Parser for MEL source code
642
- */
643
- declare class Parser {
644
- private tokens;
645
- private current;
646
- private diagnostics;
647
- constructor(tokens: Token[]);
648
- /**
649
- * Parse tokens into an AST
650
- */
651
- parse(): ParseResult;
652
- private parseProgram;
653
- private parseImport;
654
- private parseDomain;
655
- /**
656
- * v0.3.3: Parse type declaration
657
- * Syntax: type Name = TypeExpr
658
- */
659
- private parseTypeDecl;
660
- private parseDomainMember;
661
- private parseState;
662
- private parseStateField;
663
- private parseComputed;
664
- private parseAction;
665
- private parseFlowDecl;
666
- private parseParam;
667
- private parseGuardedStmt;
668
- private parseFlowStmt;
669
- /**
670
- * Skip tokens until we reach a recovery point (closing brace, guard keyword, or EOF).
671
- */
672
- private skipToRecoveryPoint;
673
- private parseWhenStmt;
674
- private parseOnceStmt;
675
- private parseOnceIntentStmt;
676
- private parseInnerStmt;
677
- private parseIncludeStmt;
678
- private parsePatchStmt;
679
- private parseEffectStmt;
680
- private parseEffectArg;
681
- /**
682
- * v0.3.2: Parse fail statement
683
- * FailStmt ::= 'fail' StringLiteral ('with' Expr)?
684
- */
685
- private parseFailStmt;
686
- /**
687
- * v0.3.2: Parse stop statement
688
- * StopStmt ::= 'stop' StringLiteral
689
- */
690
- private parseStopStmt;
691
- private parseTypeExpr;
692
- private parseBaseType;
693
- /**
694
- * v0.3.3: Parse object type
695
- * Syntax: { field: Type, field?: Type, ... }
696
- */
697
- private parseObjectType;
698
- private parseExpression;
699
- private parseTernary;
700
- private parsePrimary;
701
- private parseFunctionCall;
702
- private parsePostfix;
703
- private parseObjectLiteral;
704
- private parseArrayLiteral;
705
- private parsePath;
706
- private isUnaryContext;
707
- private peek;
708
- private peekNext;
709
- private peekAt;
710
- private previous;
711
- private isAtEnd;
712
- private advance;
713
- private check;
714
- private isOnceIntentContext;
715
- private isFlowDeclContext;
716
- private isIncludeContext;
717
- private match;
718
- private consume;
719
- private error;
720
- private errorAtCurrent;
721
- }
722
- /**
723
- * Parse tokens into an AST
724
- */
725
- declare function parse(tokens: Token[]): ParseResult;
726
-
727
- /**
728
- * Scope Analysis for MEL
729
- * Tracks variable scopes and resolves identifiers
730
- * Based on MEL SPEC v0.3.1 Section 4.10
731
- */
732
-
733
- /**
734
- * Symbol kinds
735
- */
736
- type SymbolKind = "state" | "computed" | "param" | "action" | "iteration";
737
- /**
738
- * Symbol information
739
- */
740
- interface Symbol {
741
- name: string;
742
- kind: SymbolKind;
743
- location: SourceLocation;
744
- type?: string;
745
- }
746
- /**
747
- * Scope represents a lexical scope
748
- */
749
- declare class Scope {
750
- readonly parent: Scope | null;
751
- readonly symbols: Map<string, Symbol>;
752
- readonly kind: "domain" | "action" | "guard";
753
- constructor(kind: "domain" | "action" | "guard", parent?: Scope | null);
754
- /**
755
- * Define a new symbol in this scope
756
- */
757
- define(symbol: Symbol): void;
758
- /**
759
- * Look up a symbol, searching parent scopes if not found
760
- */
761
- lookup(name: string): Symbol | undefined;
762
- /**
763
- * Check if a symbol is defined in this scope (not parent scopes)
764
- */
765
- isDefined(name: string): boolean;
766
- }
767
- /**
768
- * Result of scope analysis
769
- */
770
- interface ScopeAnalysisResult {
771
- scopes: Map<string, Scope>;
772
- diagnostics: Diagnostic[];
773
- }
774
- /**
775
- * Scope Analyzer - builds scope tree and checks for errors
776
- */
777
- declare class ScopeAnalyzer {
778
- private diagnostics;
779
- private scopes;
780
- private currentScope;
781
- private domainScope;
782
- /**
783
- * Analyze a MEL program
784
- */
785
- analyze(program: ProgramNode): ScopeAnalysisResult;
786
- private analyzeDomain;
787
- private analyzeComputedExpr;
788
- private analyzeAction;
789
- private analyzeStmt;
790
- private analyzeExpr;
791
- private checkIdentifier;
792
- private checkSystemIdent;
793
- private validatePath;
794
- private defineSymbol;
795
- private error;
796
- }
797
- /**
798
- * Analyze a MEL program for scope issues
799
- */
800
- declare function analyzeScope(program: ProgramNode): ScopeAnalysisResult;
801
-
802
- /**
803
- * Semantic Validator for MEL
804
- * Validates semantic rules beyond syntax
805
- * Based on MEL SPEC v0.3.3 and FDR-MEL-*
806
- */
807
-
808
- /**
809
- * Result of semantic validation
810
- */
811
- interface ValidationResult {
812
- valid: boolean;
813
- diagnostics: Diagnostic[];
814
- }
815
- /**
816
- * Semantic Validator
817
- */
818
- declare class SemanticValidator {
819
- private ctx;
820
- private symbols;
821
- /**
822
- * Validate a MEL program
823
- */
824
- validate(program: ProgramNode): ValidationResult;
825
- private validateDomain;
826
- /**
827
- * v0.3.3: Validate state fields for W012 (anonymous object types)
828
- */
829
- private validateState;
830
- /**
831
- * v0.3.3: Validate state field - check for anonymous object types (W012)
832
- */
833
- private validateStateField;
834
- private validateStateInitializer;
835
- /**
836
- * v0.3.3: Check if a type expression contains anonymous object types
837
- * Issues W012 warning for inline object types in state fields
838
- */
839
- private checkAnonymousObjectType;
840
- private validateAction;
841
- /**
842
- * v0.3.3: Validate available expression is pure (E005)
843
- * No $system.*, no effects, no $input.*
844
- */
845
- private validateAvailableExpr;
846
- private validateGuardedStmt;
847
- private validateWhen;
848
- private validateOnce;
849
- private validateOnceIntent;
850
- private validatePatch;
851
- private validateEffect;
852
- private validateFail;
853
- private validateStop;
854
- private validateCondition;
855
- private validateExpr;
856
- private validateFunctionCall;
857
- private validatePrimitiveEquality;
858
- private inferType;
859
- private requireAssignable;
860
- private requireArrayCompatible;
861
- private requireLenCompatible;
862
- private validateCoalesceTypes;
863
- private error;
864
- private warn;
865
- }
866
- /**
867
- * Validate a MEL program semantically
868
- */
869
- declare function validateSemantics(program: ProgramNode): ValidationResult;
870
-
871
- /**
872
- * MEL Compiler Diagnostic Codes
873
- * Based on MEL SPEC v0.3.3 Appendix A
874
- */
875
- /**
876
- * Diagnostic code information
877
- */
878
- interface DiagnosticCode {
879
- code: string;
880
- message: string;
881
- category: "syntax" | "semantic" | "type" | "system";
882
- }
883
- /**
884
- * All diagnostic codes
885
- */
886
- declare const DIAGNOSTIC_CODES: Record<string, DiagnosticCode>;
887
- /**
888
- * Get diagnostic code information
889
- */
890
- declare function getDiagnosticInfo(code: string): DiagnosticCode | undefined;
891
- /**
892
- * Format a diagnostic code for display
893
- */
894
- declare function formatDiagnosticCode(code: string): string;
895
-
896
- /**
897
- * Plain-text Diagnostic Formatter
898
- *
899
- * Browser-safe (no ANSI colors). Produces human-readable error messages
900
- * with optional source context and caret indicators.
901
- *
902
- * @module
903
- */
904
-
905
- /**
906
- * Format a single diagnostic as plain text.
907
- *
908
- * Without source: `[MEL_PARSER] Expected '{' (3:15)`
909
- * With source:
910
- * ```
911
- * [MEL_PARSER] Expected '{' (3:15)
912
- * 3 | domain Bad bad syntax here }
913
- * ^^^
914
- * ```
915
- */
916
- declare function formatDiagnostic(diagnostic: Diagnostic, source?: string): string;
917
- /**
918
- * Format multiple diagnostics, separated by blank lines.
919
- */
920
- declare function formatDiagnostics(diagnostics: Diagnostic[], source?: string): string;
921
-
922
- /**
923
- * Lowering Context Types
924
- *
925
- * Defines contexts for expression and patch lowering.
926
- *
927
- * @see SPEC v0.4.0 §17.2
928
- */
929
- /**
930
- * Allowed system path prefixes.
931
- *
932
- * In Translator path, only 'meta' and 'input' are allowed.
933
- * 'system' is forbidden (requires Flow execution).
934
- *
935
- * @see FDR-MEL-071
936
- */
937
- type AllowedSysPrefix = "meta" | "input";
938
- /**
939
- * Context for single expression lowering.
940
- *
941
- * @see SPEC v0.4.0 §17.2
942
- */
943
- interface ExprLoweringContext {
944
- /**
945
- * Expression context mode.
946
- * - 'schema': for addComputed, addConstraint, etc.
947
- * - 'action': for guards, patches, effects
948
- */
949
- mode: "schema" | "action";
950
- /**
951
- * Allowed system path prefixes.
952
- * In Translator path: only ["meta", "input"]
953
- *
954
- * @see FDR-MEL-071
955
- */
956
- allowSysPaths?: {
957
- prefixes: AllowedSysPrefix[];
958
- };
959
- /**
960
- * Function table version for call lowering.
961
- */
962
- fnTableVersion: string;
963
- /**
964
- * Action name (for action context).
965
- */
966
- actionName?: string;
967
- /**
968
- * Whether $item is allowed in this context.
969
- * Only true for effect.args fields.
970
- *
971
- * @see FDR-MEL-068
972
- */
973
- allowItem?: boolean;
974
- }
975
- /**
976
- * Context for patch lowering.
977
- *
978
- * NO mode field - Compiler determines context per op-field.
979
- *
980
- * @see SPEC v0.4.0 §17.2, AD-COMP-LOW-002
981
- */
982
- interface PatchLoweringContext {
983
- /**
984
- * Allowed system path prefixes.
985
- * In Translator path: only ["meta", "input"]
986
- *
987
- * @see FDR-MEL-071
988
- */
989
- allowSysPaths?: {
990
- prefixes: AllowedSysPrefix[];
991
- };
992
- /**
993
- * Function table version for call lowering.
994
- */
995
- fnTableVersion: string;
996
- /**
997
- * Action name (for action-related ops).
998
- */
999
- actionName?: string;
1000
- }
1001
- /**
1002
- * Default expression lowering context for schema mode.
1003
- */
1004
- declare const DEFAULT_SCHEMA_CONTEXT: ExprLoweringContext;
1005
- /**
1006
- * Default expression lowering context for action mode.
1007
- */
1008
- declare const DEFAULT_ACTION_CONTEXT: ExprLoweringContext;
1009
- /**
1010
- * Context for effect.args (allows $item).
1011
- */
1012
- declare const EFFECT_ARGS_CONTEXT: ExprLoweringContext;
1013
- /**
1014
- * Default patch lowering context.
1015
- */
1016
- declare const DEFAULT_PATCH_CONTEXT: PatchLoweringContext;
1017
-
1018
- /**
1019
- * Expression Lowering
1020
- *
1021
- * Transforms MEL Canonical IR (8 kinds) to Core Runtime IR (30+ kinds).
1022
- *
1023
- * @see SPEC v0.4.0 §17
1024
- */
1025
-
1026
- /**
1027
- * MEL primitive value.
1028
- */
1029
- type MelPrimitive = null | boolean | number | string;
1030
- /**
1031
- * MEL path segment.
1032
- */
1033
- type MelPathSegment = {
1034
- kind: "prop";
1035
- name: string;
1036
- };
1037
- /**
1038
- * MEL path node array.
1039
- */
1040
- type MelPathNode = MelPathSegment[];
1041
- /**
1042
- * MEL system path as segment array.
1043
- */
1044
- type MelSystemPath = string[];
1045
- /**
1046
- * MEL object field.
1047
- */
1048
- type MelObjField = {
1049
- key: string;
1050
- value: MelExprNode;
1051
- };
1052
- /**
1053
- * MEL Canonical IR (8 kinds).
1054
- *
1055
- * @see SPEC v0.4.0 §17.1.1
1056
- */
1057
- type MelExprNode = {
1058
- kind: "lit";
1059
- value: MelPrimitive;
1060
- } | {
1061
- kind: "var";
1062
- name: "item";
1063
- } | {
1064
- kind: "sys";
1065
- path: MelSystemPath;
1066
- } | {
1067
- kind: "get";
1068
- base?: MelExprNode;
1069
- path: MelPathNode;
1070
- } | {
1071
- kind: "field";
1072
- object: MelExprNode;
1073
- property: string;
1074
- } | {
1075
- kind: "call";
1076
- fn: string;
1077
- args: MelExprNode[];
1078
- } | {
1079
- kind: "obj";
1080
- fields: MelObjField[];
1081
- } | {
1082
- kind: "arr";
1083
- elements: MelExprNode[];
1084
- };
1085
- /**
1086
- * Lower MEL expression to Core expression.
1087
- *
1088
- * @param input - MEL canonical IR expression
1089
- * @param ctx - Lowering context
1090
- * @returns Core runtime IR expression
1091
- * @throws LoweringError if expression cannot be lowered
1092
- *
1093
- * @see SPEC v0.4.0 §17.3
1094
- */
1095
- declare function lowerExprNode(input: MelExprNode, ctx: ExprLoweringContext): ExprNode$2;
1096
-
1097
- /**
1098
- * IR Generator - Transforms MEL AST to Core DomainSchema
1099
- * Based on MEL SPEC v0.3.3 Section 5
1100
- */
1101
-
1102
- /**
1103
- * Core ExprNode types (simplified, matching core/schema/expr.ts)
1104
- */
1105
- type CoreExprNode = {
1106
- kind: "lit";
1107
- value: unknown;
1108
- } | {
1109
- kind: "get";
1110
- path: string;
1111
- } | {
1112
- kind: "eq";
1113
- left: CoreExprNode;
1114
- right: CoreExprNode;
1115
- } | {
1116
- kind: "neq";
1117
- left: CoreExprNode;
1118
- right: CoreExprNode;
1119
- } | {
1120
- kind: "gt";
1121
- left: CoreExprNode;
1122
- right: CoreExprNode;
1123
- } | {
1124
- kind: "gte";
1125
- left: CoreExprNode;
1126
- right: CoreExprNode;
1127
- } | {
1128
- kind: "lt";
1129
- left: CoreExprNode;
1130
- right: CoreExprNode;
1131
- } | {
1132
- kind: "lte";
1133
- left: CoreExprNode;
1134
- right: CoreExprNode;
1135
- } | {
1136
- kind: "and";
1137
- args: CoreExprNode[];
1138
- } | {
1139
- kind: "or";
1140
- args: CoreExprNode[];
1141
- } | {
1142
- kind: "not";
1143
- arg: CoreExprNode;
1144
- } | {
1145
- kind: "if";
1146
- cond: CoreExprNode;
1147
- then: CoreExprNode;
1148
- else: CoreExprNode;
1149
- } | {
1150
- kind: "add";
1151
- left: CoreExprNode;
1152
- right: CoreExprNode;
1153
- } | {
1154
- kind: "sub";
1155
- left: CoreExprNode;
1156
- right: CoreExprNode;
1157
- } | {
1158
- kind: "mul";
1159
- left: CoreExprNode;
1160
- right: CoreExprNode;
1161
- } | {
1162
- kind: "div";
1163
- left: CoreExprNode;
1164
- right: CoreExprNode;
1165
- } | {
1166
- kind: "mod";
1167
- left: CoreExprNode;
1168
- right: CoreExprNode;
1169
- } | {
1170
- kind: "neg";
1171
- arg: CoreExprNode;
1172
- } | {
1173
- kind: "abs";
1174
- arg: CoreExprNode;
1175
- } | {
1176
- kind: "min";
1177
- args: CoreExprNode[];
1178
- } | {
1179
- kind: "max";
1180
- args: CoreExprNode[];
1181
- } | {
1182
- kind: "sumArray";
1183
- array: CoreExprNode;
1184
- } | {
1185
- kind: "minArray";
1186
- array: CoreExprNode;
1187
- } | {
1188
- kind: "maxArray";
1189
- array: CoreExprNode;
1190
- } | {
1191
- kind: "floor";
1192
- arg: CoreExprNode;
1193
- } | {
1194
- kind: "ceil";
1195
- arg: CoreExprNode;
1196
- } | {
1197
- kind: "round";
1198
- arg: CoreExprNode;
1199
- } | {
1200
- kind: "sqrt";
1201
- arg: CoreExprNode;
1202
- } | {
1203
- kind: "pow";
1204
- base: CoreExprNode;
1205
- exponent: CoreExprNode;
1206
- } | {
1207
- kind: "concat";
1208
- args: CoreExprNode[];
1209
- } | {
1210
- kind: "trim";
1211
- str: CoreExprNode;
1212
- } | {
1213
- kind: "toLowerCase";
1214
- str: CoreExprNode;
1215
- } | {
1216
- kind: "toUpperCase";
1217
- str: CoreExprNode;
1218
- } | {
1219
- kind: "strLen";
1220
- str: CoreExprNode;
1221
- } | {
1222
- kind: "substring";
1223
- str: CoreExprNode;
1224
- start: CoreExprNode;
1225
- end?: CoreExprNode;
1226
- } | {
1227
- kind: "len";
1228
- arg: CoreExprNode;
1229
- } | {
1230
- kind: "at";
1231
- array: CoreExprNode;
1232
- index: CoreExprNode;
1233
- } | {
1234
- kind: "first";
1235
- array: CoreExprNode;
1236
- } | {
1237
- kind: "last";
1238
- array: CoreExprNode;
1239
- } | {
1240
- kind: "slice";
1241
- array: CoreExprNode;
1242
- start: CoreExprNode;
1243
- end?: CoreExprNode;
1244
- } | {
1245
- kind: "includes";
1246
- array: CoreExprNode;
1247
- item: CoreExprNode;
1248
- } | {
1249
- kind: "filter";
1250
- array: CoreExprNode;
1251
- predicate: CoreExprNode;
1252
- } | {
1253
- kind: "map";
1254
- array: CoreExprNode;
1255
- mapper: CoreExprNode;
1256
- } | {
1257
- kind: "find";
1258
- array: CoreExprNode;
1259
- predicate: CoreExprNode;
1260
- } | {
1261
- kind: "every";
1262
- array: CoreExprNode;
1263
- predicate: CoreExprNode;
1264
- } | {
1265
- kind: "some";
1266
- array: CoreExprNode;
1267
- predicate: CoreExprNode;
1268
- } | {
1269
- kind: "append";
1270
- array: CoreExprNode;
1271
- items: CoreExprNode[];
1272
- } | {
1273
- kind: "object";
1274
- fields: Record<string, CoreExprNode>;
1275
- } | {
1276
- kind: "field";
1277
- object: CoreExprNode;
1278
- property: string;
1279
- } | {
1280
- kind: "keys";
1281
- obj: CoreExprNode;
1282
- } | {
1283
- kind: "values";
1284
- obj: CoreExprNode;
1285
- } | {
1286
- kind: "entries";
1287
- obj: CoreExprNode;
1288
- } | {
1289
- kind: "merge";
1290
- objects: CoreExprNode[];
1291
- } | {
1292
- kind: "typeof";
1293
- arg: CoreExprNode;
1294
- } | {
1295
- kind: "isNull";
1296
- arg: CoreExprNode;
1297
- } | {
1298
- kind: "coalesce";
1299
- args: CoreExprNode[];
1300
- } | {
1301
- kind: "toString";
1302
- arg: CoreExprNode;
1303
- };
1304
- type CompilerExprNode = MelExprNode;
1305
- /**
1306
- * Core FlowNode types (matching core/schema/flow.ts)
1307
- */
1308
- type CoreFlowNode = {
1309
- kind: "seq";
1310
- steps: CoreFlowNode[];
1311
- } | {
1312
- kind: "if";
1313
- cond: CoreExprNode;
1314
- then: CoreFlowNode;
1315
- else?: CoreFlowNode;
1316
- } | {
1317
- kind: "patch";
1318
- op: "set" | "unset" | "merge";
1319
- path: PatchPath;
1320
- value?: CoreExprNode;
1321
- } | {
1322
- kind: "effect";
1323
- type: string;
1324
- params: Record<string, CoreExprNode>;
1325
- } | {
1326
- kind: "call";
1327
- flow: string;
1328
- } | {
1329
- kind: "halt";
1330
- reason?: string;
1331
- } | {
1332
- kind: "fail";
1333
- code: string;
1334
- message?: CoreExprNode;
1335
- };
1336
- type CompilerFlowNode = {
1337
- kind: "seq";
1338
- steps: CompilerFlowNode[];
1339
- } | {
1340
- kind: "if";
1341
- cond: CompilerExprNode;
1342
- then: CompilerFlowNode;
1343
- else?: CompilerFlowNode;
1344
- } | {
1345
- kind: "patch";
1346
- op: "set" | "unset" | "merge";
1347
- path: PatchPath;
1348
- value?: CompilerExprNode;
1349
- } | {
1350
- kind: "effect";
1351
- type: string;
1352
- params: Record<string, CompilerExprNode>;
1353
- } | {
1354
- kind: "call";
1355
- flow: string;
1356
- } | {
1357
- kind: "halt";
1358
- reason?: string;
1359
- } | {
1360
- kind: "fail";
1361
- code: string;
1362
- message?: CompilerExprNode;
1363
- };
1364
- /**
1365
- * Field type definition
1366
- */
1367
- type FieldType = "string" | "number" | "boolean" | "null" | "object" | "array" | {
1368
- enum: readonly unknown[];
1369
- };
1370
- /**
1371
- * Field specification
1372
- */
1373
- interface FieldSpec {
1374
- type: FieldType;
1375
- required: boolean;
1376
- default?: unknown;
1377
- description?: string;
1378
- fields?: Record<string, FieldSpec>;
1379
- items?: FieldSpec;
1380
- }
1381
- /**
1382
- * State specification
1383
- */
1384
- interface StateSpec {
1385
- fields: Record<string, FieldSpec>;
1386
- }
1387
- /**
1388
- * Computed field specification
1389
- */
1390
- interface ComputedFieldSpec {
1391
- deps: string[];
1392
- expr: CoreExprNode;
1393
- description?: string;
1394
- }
1395
- interface CompilerComputedFieldSpec {
1396
- deps: string[];
1397
- expr: CompilerExprNode;
1398
- description?: string;
1399
- }
1400
- /**
1401
- * Computed specification
1402
- */
1403
- interface ComputedSpec {
1404
- fields: Record<string, ComputedFieldSpec>;
1405
- }
1406
- /**
1407
- * Action specification
1408
- */
1409
- interface ActionSpec {
1410
- flow: CoreFlowNode;
1411
- input?: FieldSpec;
1412
- available?: CoreExprNode;
1413
- description?: string;
1414
- }
1415
- interface CompilerActionSpec {
1416
- flow: CompilerFlowNode;
1417
- input?: FieldSpec;
1418
- available?: CompilerExprNode;
1419
- description?: string;
1420
- }
1421
- /**
1422
- * Domain schema (output IR)
1423
- */
1424
- /**
1425
- * v0.3.3: Type specification (named type declaration)
1426
- */
1427
- interface TypeSpec {
1428
- name: string;
1429
- definition: TypeDefinition;
1430
- }
1431
- /**
1432
- * v0.3.3: Type definition structure
1433
- */
1434
- type TypeDefinition = {
1435
- kind: "primitive";
1436
- type: string;
1437
- } | {
1438
- kind: "array";
1439
- element: TypeDefinition;
1440
- } | {
1441
- kind: "record";
1442
- key: TypeDefinition;
1443
- value: TypeDefinition;
1444
- } | {
1445
- kind: "object";
1446
- fields: Record<string, {
1447
- type: TypeDefinition;
1448
- optional: boolean;
1449
- }>;
1450
- } | {
1451
- kind: "union";
1452
- types: TypeDefinition[];
1453
- } | {
1454
- kind: "literal";
1455
- value: string | number | boolean | null;
1456
- } | {
1457
- kind: "ref";
1458
- name: string;
1459
- };
1460
- interface DomainSchema {
1461
- id: string;
1462
- version: string;
1463
- hash: string;
1464
- /** v0.3.3: Named type declarations */
1465
- types: Record<string, TypeSpec>;
1466
- state: StateSpec;
1467
- computed: ComputedSpec;
1468
- actions: Record<string, ActionSpec>;
1469
- meta?: {
1470
- name?: string;
1471
- description?: string;
1472
- authors?: string[];
1473
- };
1474
- }
1475
- interface CanonicalDomainSchema {
1476
- id: string;
1477
- version: string;
1478
- hash: string;
1479
- types: Record<string, TypeSpec>;
1480
- state: StateSpec;
1481
- computed: {
1482
- fields: Record<string, CompilerComputedFieldSpec>;
1483
- };
1484
- actions: Record<string, CompilerActionSpec>;
1485
- meta?: {
1486
- name?: string;
1487
- description?: string;
1488
- authors?: string[];
1489
- };
1490
- }
1491
- interface GenerateResult {
1492
- schema: DomainSchema | null;
1493
- diagnostics: Diagnostic[];
1494
- }
1495
- interface GenerateCanonicalResult {
1496
- schema: CanonicalDomainSchema | null;
1497
- diagnostics: Diagnostic[];
1498
- }
1499
- declare function generateCanonical(program: ProgramNode): GenerateCanonicalResult;
1500
- /**
1501
- * Generate runtime-ready DomainSchema from MEL AST.
1502
- */
1503
- declare function generate(program: ProgramNode): GenerateResult;
1504
-
1505
- /**
1506
- * Expression Normalizer
1507
- * Converts MEL operators and function calls to Core ExprNode format
1508
- * Based on MEL SPEC v0.3.1 Section 4 and FDR-MEL-038
1509
- */
1510
-
1511
- /**
1512
- * Normalize a binary operator to Core ExprNode
1513
- */
1514
- declare function normalizeExpr(op: BinaryOperator, left: CoreExprNode, right: CoreExprNode): CoreExprNode;
1515
- /**
1516
- * Function name to Core ExprNode mapping
1517
- */
1518
- declare function normalizeFunctionCall(name: string, args: CoreExprNode[]): CoreExprNode;
1519
-
1520
- /**
1521
- * System Value Lowering
1522
- * Transforms $system.* references into effect-based acquisition
1523
- * Based on MEL SPEC v0.3.1 Section 5.4
1524
- */
1525
-
1526
- /**
1527
- * Apply system value lowering to a domain schema
1528
- */
1529
- declare function lowerSystemValues(schema: DomainSchema): DomainSchema;
1530
-
1531
- /**
1532
- * TypeExpr to MEL Renderer
1533
- *
1534
- * Converts TypeExpr AST to MEL type syntax.
1535
- *
1536
- * @example
1537
- * // { kind: "primitive", name: "string" } -> "string"
1538
- * // { kind: "array", element: { kind: "ref", name: "Todo" } } -> "Array<Todo>"
1539
- * // { kind: "union", members: [...] } -> "string | number | null"
1540
- */
1541
- /**
1542
- * TypeExpr type from translator package
1543
- */
1544
- type TypeExpr = {
1545
- kind: "primitive";
1546
- name: "string" | "number" | "boolean" | "null";
1547
- } | {
1548
- kind: "literal";
1549
- value: string | number | boolean | null;
1550
- } | {
1551
- kind: "ref";
1552
- name: string;
1553
- } | {
1554
- kind: "array";
1555
- element: TypeExpr;
1556
- } | {
1557
- kind: "record";
1558
- key: TypeExpr;
1559
- value: TypeExpr;
1560
- } | {
1561
- kind: "union";
1562
- members: TypeExpr[];
1563
- } | {
1564
- kind: "object";
1565
- fields: TypeField[];
1566
- };
1567
- type TypeField = {
1568
- readonly name: string;
1569
- readonly optional: boolean;
1570
- readonly type: TypeExpr;
1571
- };
1572
- /**
1573
- * Renders a TypeExpr to MEL type syntax string.
1574
- *
1575
- * @param typeExpr - The TypeExpr to render
1576
- * @returns MEL type syntax string
1577
- */
1578
- declare function renderTypeExpr(typeExpr: TypeExpr): string;
1579
- /**
1580
- * Renders a TypeField with optional default value.
1581
- *
1582
- * @param field - The TypeField to render
1583
- * @param defaultValue - Optional default value
1584
- * @returns MEL field declaration string
1585
- */
1586
- declare function renderTypeField(field: TypeField, defaultValue?: unknown): string;
1587
- /**
1588
- * Renders a JavaScript value to MEL syntax.
1589
- */
1590
- declare function renderValue(value: unknown): string;
1591
-
1592
- /**
1593
- * ExprNode to MEL Renderer
1594
- *
1595
- * Converts ExprNode AST to MEL expression syntax.
1596
- *
1597
- * @example
1598
- * // { kind: "lit", value: 5 } -> "5"
1599
- * // { kind: "get", path: "count" } -> "count"
1600
- * // { kind: "add", left: { kind: "get", path: "x" }, right: { kind: "lit", value: 1 } } -> "add(x, 1)"
1601
- * // { kind: "gt", left: { kind: "get", path: "count" }, right: { kind: "lit", value: 0 } } -> "gt(count, 0)"
1602
- */
1603
- /**
1604
- * ExprNode type (subset from core package)
1605
- */
1606
- type ExprNode = {
1607
- kind: "lit";
1608
- value: unknown;
1609
- } | {
1610
- kind: "get";
1611
- path: string;
1612
- } | {
1613
- kind: "eq";
1614
- left: ExprNode;
1615
- right: ExprNode;
1616
- } | {
1617
- kind: "neq";
1618
- left: ExprNode;
1619
- right: ExprNode;
1620
- } | {
1621
- kind: "gt";
1622
- left: ExprNode;
1623
- right: ExprNode;
1624
- } | {
1625
- kind: "gte";
1626
- left: ExprNode;
1627
- right: ExprNode;
1628
- } | {
1629
- kind: "lt";
1630
- left: ExprNode;
1631
- right: ExprNode;
1632
- } | {
1633
- kind: "lte";
1634
- left: ExprNode;
1635
- right: ExprNode;
1636
- } | {
1637
- kind: "and";
1638
- args: ExprNode[];
1639
- } | {
1640
- kind: "or";
1641
- args: ExprNode[];
1642
- } | {
1643
- kind: "not";
1644
- arg: ExprNode;
1645
- } | {
1646
- kind: "if";
1647
- cond: ExprNode;
1648
- then: ExprNode;
1649
- else: ExprNode;
1650
- } | {
1651
- kind: "add";
1652
- left: ExprNode;
1653
- right: ExprNode;
1654
- } | {
1655
- kind: "sub";
1656
- left: ExprNode;
1657
- right: ExprNode;
1658
- } | {
1659
- kind: "mul";
1660
- left: ExprNode;
1661
- right: ExprNode;
1662
- } | {
1663
- kind: "div";
1664
- left: ExprNode;
1665
- right: ExprNode;
1666
- } | {
1667
- kind: "mod";
1668
- left: ExprNode;
1669
- right: ExprNode;
1670
- } | {
1671
- kind: "concat";
1672
- args: ExprNode[];
1673
- } | {
1674
- kind: "substring";
1675
- str: ExprNode;
1676
- start: ExprNode;
1677
- end?: ExprNode;
1678
- } | {
1679
- kind: "trim";
1680
- str: ExprNode;
1681
- } | {
1682
- kind: "len";
1683
- arg: ExprNode;
1684
- } | {
1685
- kind: "at";
1686
- array: ExprNode;
1687
- index: ExprNode;
1688
- } | {
1689
- kind: "first";
1690
- array: ExprNode;
1691
- } | {
1692
- kind: "last";
1693
- array: ExprNode;
1694
- } | {
1695
- kind: "slice";
1696
- array: ExprNode;
1697
- start: ExprNode;
1698
- end?: ExprNode;
1699
- } | {
1700
- kind: "includes";
1701
- array: ExprNode;
1702
- item: ExprNode;
1703
- } | {
1704
- kind: "filter";
1705
- array: ExprNode;
1706
- predicate: ExprNode;
1707
- } | {
1708
- kind: "map";
1709
- array: ExprNode;
1710
- mapper: ExprNode;
1711
- } | {
1712
- kind: "find";
1713
- array: ExprNode;
1714
- predicate: ExprNode;
1715
- } | {
1716
- kind: "every";
1717
- array: ExprNode;
1718
- predicate: ExprNode;
1719
- } | {
1720
- kind: "some";
1721
- array: ExprNode;
1722
- predicate: ExprNode;
1723
- } | {
1724
- kind: "append";
1725
- array: ExprNode;
1726
- items: ExprNode[];
1727
- } | {
1728
- kind: "object";
1729
- fields: Record<string, ExprNode>;
1730
- } | {
1731
- kind: "field";
1732
- object: ExprNode;
1733
- property: string;
1734
- } | {
1735
- kind: "keys";
1736
- obj: ExprNode;
1737
- } | {
1738
- kind: "values";
1739
- obj: ExprNode;
1740
- } | {
1741
- kind: "entries";
1742
- obj: ExprNode;
1743
- } | {
1744
- kind: "merge";
1745
- objects: ExprNode[];
1746
- } | {
1747
- kind: "typeof";
1748
- arg: ExprNode;
1749
- } | {
1750
- kind: "isNull";
1751
- arg: ExprNode;
1752
- } | {
1753
- kind: "coalesce";
1754
- args: ExprNode[];
1755
- };
1756
- /**
1757
- * Renders an ExprNode to MEL expression syntax string.
1758
- *
1759
- * @param expr - The ExprNode to render
1760
- * @returns MEL expression syntax string
1761
- */
1762
- declare function renderExprNode(expr: ExprNode): string;
1763
-
1764
- /**
1765
- * PatchOp to MEL Renderer
1766
- *
1767
- * Converts PatchOp AST to MEL syntax snippets.
1768
- *
1769
- * Note: These are fragments, not complete domain definitions.
1770
- * The caller is responsible for assembling fragments into a valid MEL domain.
1771
- */
1772
-
1773
- type AddTypeOp = {
1774
- kind: "addType";
1775
- typeName: string;
1776
- typeExpr: TypeExpr;
1777
- };
1778
- type AddFieldOp = {
1779
- kind: "addField";
1780
- typeName: string;
1781
- field: TypeField & {
1782
- defaultValue?: unknown;
1783
- };
1784
- };
1785
- type SetFieldTypeOp = {
1786
- kind: "setFieldType";
1787
- path: string;
1788
- typeExpr: TypeExpr;
1789
- };
1790
- type SetDefaultValueOp = {
1791
- kind: "setDefaultValue";
1792
- path: string;
1793
- value: unknown;
1794
- };
1795
- type AddConstraintOp = {
1796
- kind: "addConstraint";
1797
- targetPath: string;
1798
- rule: ExprNode;
1799
- message?: string;
1800
- };
1801
- type AddComputedOp = {
1802
- kind: "addComputed";
1803
- name: string;
1804
- expr: ExprNode;
1805
- deps?: string[];
1806
- };
1807
- type AddActionAvailableOp = {
1808
- kind: "addActionAvailable";
1809
- actionName: string;
1810
- expr: ExprNode;
1811
- };
1812
- type PatchOp = AddTypeOp | AddFieldOp | SetFieldTypeOp | SetDefaultValueOp | AddConstraintOp | AddComputedOp | AddActionAvailableOp;
1813
- interface RenderOptions {
1814
- /**
1815
- * Indentation string (default: " ")
1816
- */
1817
- indent?: string;
1818
- /**
1819
- * Include comments with metadata
1820
- */
1821
- includeComments?: boolean;
1822
- /**
1823
- * Comment prefix for metadata
1824
- */
1825
- commentPrefix?: string;
1826
- }
1827
- /**
1828
- * Renders a PatchOp to MEL syntax string.
1829
- *
1830
- * @param op - The PatchOp to render
1831
- * @param options - Rendering options
1832
- * @returns MEL syntax string
1833
- */
1834
- declare function renderPatchOp(op: PatchOp, options?: RenderOptions): string;
1835
- /**
1836
- * Gets the type name from a semantic path.
1837
- *
1838
- * @example
1839
- * // "Todo.title" -> "Todo"
1840
- * // "User.address.city" -> "User"
1841
- * // "count" -> undefined
1842
- */
1843
- declare function extractTypeName(path: string): string | undefined;
1844
-
1845
- /**
1846
- * PatchFragment to MEL Renderer
1847
- *
1848
- * Converts PatchFragment to MEL syntax with metadata comments.
1849
- */
1850
-
1851
- interface PatchFragment {
1852
- /**
1853
- * Unique fragment identifier (content-addressed)
1854
- */
1855
- fragmentId: string;
1856
- /**
1857
- * Source intent identifier
1858
- */
1859
- sourceIntentId: string;
1860
- /**
1861
- * Fragment operation
1862
- */
1863
- op: PatchOp;
1864
- /**
1865
- * Confidence score (0-1)
1866
- */
1867
- confidence: number;
1868
- /**
1869
- * Evidence strings
1870
- */
1871
- evidence: string[];
1872
- /**
1873
- * Creation timestamp (ISO 8601)
1874
- */
1875
- createdAt: string;
1876
- }
1877
- interface FragmentRenderOptions extends RenderOptions {
1878
- /**
1879
- * Include fragment metadata as comments
1880
- */
1881
- includeMetadata?: boolean;
1882
- /**
1883
- * Include evidence as comments
1884
- */
1885
- includeEvidence?: boolean;
1886
- /**
1887
- * Include confidence score
1888
- */
1889
- includeConfidence?: boolean;
1890
- /**
1891
- * Include fragment ID
1892
- */
1893
- includeFragmentId?: boolean;
1894
- }
1895
- /**
1896
- * Renders a PatchFragment to MEL syntax string with optional metadata.
1897
- *
1898
- * @param fragment - The PatchFragment to render
1899
- * @param options - Rendering options
1900
- * @returns MEL syntax string with metadata comments
1901
- */
1902
- declare function renderFragment(fragment: PatchFragment, options?: FragmentRenderOptions): string;
1903
- /**
1904
- * Renders multiple PatchFragments to MEL syntax string.
1905
- *
1906
- * @param fragments - The PatchFragments to render
1907
- * @param options - Rendering options
1908
- * @returns MEL syntax string with all fragments
1909
- */
1910
- declare function renderFragments(fragments: PatchFragment[], options?: FragmentRenderOptions): string;
1911
- /**
1912
- * Renders PatchFragments grouped by operation kind.
1913
- *
1914
- * @param fragments - The PatchFragments to render
1915
- * @param options - Rendering options
1916
- * @returns Object with rendered strings grouped by operation kind
1917
- */
1918
- declare function renderFragmentsByKind(fragments: PatchFragment[], options?: FragmentRenderOptions): Record<string, string>;
1919
- /**
1920
- * Renders PatchFragments as a complete MEL domain block.
1921
- *
1922
- * @param domainName - The domain name
1923
- * @param fragments - The PatchFragments to render
1924
- * @param options - Rendering options
1925
- * @returns Complete MEL domain string
1926
- */
1927
- declare function renderAsDomain(domainName: string, fragments: PatchFragment[], options?: FragmentRenderOptions): string;
1928
-
1929
- /**
1930
- * Lowering Error Types
1931
- *
1932
- * Defines error types for MEL IR → Core IR lowering.
1933
- *
1934
- * @see SPEC v0.4.0 §17.6
1935
- */
1936
- /**
1937
- * Lowering error codes.
1938
- *
1939
- * @see SPEC v0.4.0 §17.6
1940
- */
1941
- type LoweringErrorCode =
1942
- /** var in non-effect context, sys in schema */
1943
- "INVALID_KIND_FOR_CONTEXT"
1944
- /** Unknown function name in call node */
1945
- | "UNKNOWN_CALL_FN"
1946
- /** sys.system in Translator path */
1947
- | "INVALID_SYS_PATH"
1948
- /** get.base is not var(item) */
1949
- | "UNSUPPORTED_BASE"
1950
- /** Malformed node structure */
1951
- | "INVALID_SHAPE"
1952
- /** Unknown node kind */
1953
- | "UNKNOWN_NODE_KIND";
1954
- /**
1955
- * Lowering error class.
1956
- *
1957
- * Thrown when MEL IR cannot be lowered to Core IR.
1958
- *
1959
- * @see SPEC v0.4.0 §17.6
1960
- */
1961
- declare class LoweringError extends Error {
1962
- readonly code: LoweringErrorCode;
1963
- readonly path?: string[];
1964
- readonly details?: Record<string, unknown>;
1965
- constructor(code: LoweringErrorCode, message: string, options?: {
1966
- path?: string[];
1967
- details?: Record<string, unknown>;
1968
- });
1969
- }
1970
- /**
1971
- * Create a lowering error for invalid kind in context.
1972
- *
1973
- * @example
1974
- * throw invalidKindForContext("var", "schema");
1975
- */
1976
- declare function invalidKindForContext(kind: string, context: string, path?: string[]): LoweringError;
1977
- /**
1978
- * Create a lowering error for unknown call function.
1979
- *
1980
- * @example
1981
- * throw unknownCallFn("unknownFunc");
1982
- */
1983
- declare function unknownCallFn(fn: string, path?: string[]): LoweringError;
1984
- /**
1985
- * Create a lowering error for invalid sys path.
1986
- *
1987
- * @example
1988
- * throw invalidSysPath(["system", "uuid"]);
1989
- */
1990
- declare function invalidSysPath(sysPath: string[], path?: string[]): LoweringError;
1991
- /**
1992
- * Create a lowering error for unsupported base expression.
1993
- *
1994
- * @example
1995
- * throw unsupportedBase("call");
1996
- */
1997
- declare function unsupportedBase(baseKind: string, path?: string[]): LoweringError;
1998
- /**
1999
- * Create a lowering error for invalid shape.
2000
- *
2001
- * @example
2002
- * throw invalidShape("missing 'value' field");
2003
- */
2004
- declare function invalidShape(description: string, path?: string[]): LoweringError;
2005
- /**
2006
- * Create a lowering error for unknown node kind.
2007
- *
2008
- * @example
2009
- * throw unknownNodeKind("foo");
2010
- */
2011
- declare function unknownNodeKind(kind: string, path?: string[]): LoweringError;
2012
-
2013
- /**
2014
- * Patch Lowering
2015
- *
2016
- * Transforms PatchFragment[] (MEL IR) to ConditionalPatchOp[] (Core IR).
2017
- *
2018
- * @see SPEC v0.4.0 §17.4, §17.5
2019
- */
2020
-
2021
- /**
2022
- * MEL TypeExpr (Translator output).
2023
- */
2024
- type MelTypeExpr = {
2025
- kind: "primitive";
2026
- name: "string" | "number" | "boolean" | "null";
2027
- } | {
2028
- kind: "array";
2029
- element: MelTypeExpr;
2030
- } | {
2031
- kind: "object";
2032
- fields: MelTypeField[];
2033
- } | {
2034
- kind: "union";
2035
- members: MelTypeExpr[];
2036
- } | {
2037
- kind: "literal";
2038
- value: string | number | boolean | null;
2039
- } | {
2040
- kind: "ref";
2041
- name: string;
2042
- };
2043
- /**
2044
- * MEL TypeField.
2045
- */
2046
- type MelTypeField = {
2047
- name: string;
2048
- type: MelTypeExpr;
2049
- optional?: boolean;
2050
- };
2051
- /**
2052
- * MEL PatchOp (Translator output - schema operations).
2053
- *
2054
- * @see SPEC v0.4.0 §17.4
2055
- */
2056
- type MelPatchOp = {
2057
- kind: "addType";
2058
- typeName: string;
2059
- typeExpr: MelTypeExpr;
2060
- } | {
2061
- kind: "addField";
2062
- typeName: string;
2063
- field: MelTypeField & {
2064
- defaultValue?: unknown;
2065
- };
2066
- } | {
2067
- kind: "setFieldType";
2068
- path: string;
2069
- typeExpr: MelTypeExpr;
2070
- } | {
2071
- kind: "setDefaultValue";
2072
- path: string;
2073
- value: unknown;
2074
- } | {
2075
- kind: "addConstraint";
2076
- targetPath: string;
2077
- rule: MelExprNode;
2078
- message?: string;
2079
- } | {
2080
- kind: "addComputed";
2081
- name: string;
2082
- expr: MelExprNode;
2083
- deps?: string[];
2084
- } | {
2085
- kind: "addActionAvailable";
2086
- actionName: string;
2087
- expr: MelExprNode;
2088
- };
2089
- /**
2090
- * MEL PatchFragment (Translator output).
2091
- *
2092
- * Contains MEL IR expressions that need lowering.
2093
- *
2094
- * @see SPEC v0.4.0 §17.4
2095
- */
2096
- interface MelPatchFragment {
2097
- /**
2098
- * Unique fragment identifier (content-addressed).
2099
- */
2100
- fragmentId: string;
2101
- /**
2102
- * Source intent identifier.
2103
- */
2104
- sourceIntentId: string;
2105
- /**
2106
- * Fragment operation with MEL IR expressions.
2107
- */
2108
- op: MelPatchOp;
2109
- /**
2110
- * Optional condition (MEL IR).
2111
- * Preserved in output as Core IR.
2112
- */
2113
- condition?: MelExprNode;
2114
- /**
2115
- * Confidence score (0-1).
2116
- */
2117
- confidence: number;
2118
- /**
2119
- * Evidence strings.
2120
- */
2121
- evidence: string[];
2122
- /**
2123
- * Creation timestamp (ISO 8601).
2124
- */
2125
- createdAt: string;
2126
- }
2127
- /**
2128
- * Lowered TypeExpr (Core format).
2129
- */
2130
- type LoweredTypeExpr = {
2131
- kind: "primitive";
2132
- name: "string" | "number" | "boolean" | "null";
2133
- } | {
2134
- kind: "array";
2135
- element: LoweredTypeExpr;
2136
- } | {
2137
- kind: "object";
2138
- fields: LoweredTypeField[];
2139
- } | {
2140
- kind: "union";
2141
- members: LoweredTypeExpr[];
2142
- } | {
2143
- kind: "literal";
2144
- value: string | number | boolean | null;
2145
- } | {
2146
- kind: "ref";
2147
- name: string;
2148
- };
2149
- /**
2150
- * Lowered TypeField.
2151
- */
2152
- type LoweredTypeField = {
2153
- name: string;
2154
- type: LoweredTypeExpr;
2155
- optional?: boolean;
2156
- };
2157
- /**
2158
- * Lowered PatchOp (Core IR expressions).
2159
- *
2160
- * Same structure as MelPatchOp but with Core IR expressions.
2161
- */
2162
- type LoweredPatchOp = {
2163
- kind: "addType";
2164
- typeName: string;
2165
- typeExpr: LoweredTypeExpr;
2166
- } | {
2167
- kind: "addField";
2168
- typeName: string;
2169
- field: LoweredTypeField & {
2170
- defaultValue?: unknown;
2171
- };
2172
- } | {
2173
- kind: "setFieldType";
2174
- path: string;
2175
- typeExpr: LoweredTypeExpr;
2176
- } | {
2177
- kind: "setDefaultValue";
2178
- path: string;
2179
- value: unknown;
2180
- } | {
2181
- kind: "addConstraint";
2182
- targetPath: string;
2183
- rule: ExprNode$2;
2184
- message?: string;
2185
- } | {
2186
- kind: "addComputed";
2187
- name: string;
2188
- expr: ExprNode$2;
2189
- deps?: string[];
2190
- } | {
2191
- kind: "addActionAvailable";
2192
- actionName: string;
2193
- expr: ExprNode$2;
2194
- };
2195
- /**
2196
- * Schema conditional patch operation (intermediate IR for Translator → Host).
2197
- *
2198
- * Used for schema evolution operations (addType, addField, addComputed, etc.).
2199
- * Preserves fragment condition for later evaluation.
2200
- *
2201
- * @see SPEC v0.4.0 §17.5
2202
- */
2203
- interface SchemaConditionalPatchOp {
2204
- /**
2205
- * Fragment identifier (for tracing).
2206
- */
2207
- fragmentId: string;
2208
- /**
2209
- * Condition expression (Core IR).
2210
- * If present, op is only applied when condition evaluates to true.
2211
- *
2212
- * @see FDR-MEL-073
2213
- */
2214
- condition?: ExprNode$2;
2215
- /**
2216
- * Lowered patch operation.
2217
- */
2218
- op: LoweredPatchOp;
2219
- /**
2220
- * Confidence (preserved from fragment).
2221
- */
2222
- confidence: number;
2223
- }
2224
- /**
2225
- * @deprecated Use SchemaConditionalPatchOp instead.
2226
- */
2227
- type ConditionalPatchOp = SchemaConditionalPatchOp;
2228
- /**
2229
- * Lower PatchFragment[] to SchemaConditionalPatchOp[].
2230
- *
2231
- * Transforms MEL IR expressions to Core IR expressions.
2232
- * Preserves fragment conditions for evaluation phase.
2233
- *
2234
- * @param fragments - MEL IR patch fragments from Translator
2235
- * @param ctx - Patch lowering context
2236
- * @returns Core IR schema conditional patch operations
2237
- *
2238
- * @see SPEC v0.4.0 §17.5
2239
- */
2240
- declare function lowerPatchFragments(fragments: MelPatchFragment[], ctx: PatchLoweringContext): SchemaConditionalPatchOp[];
2241
-
2242
- /**
2243
- * Runtime Patch Lowering
2244
- *
2245
- * Transforms MEL runtime patches (set/unset/merge) to Core IR.
2246
- *
2247
- * @see SPEC v0.4.0 §17.5
2248
- */
2249
-
2250
- /**
2251
- * MEL runtime patch operation type.
2252
- *
2253
- * @see SPEC v0.4.0 §17.5
2254
- */
2255
- type MelRuntimePatchOp = "set" | "unset" | "merge";
2256
- /**
2257
- * MEL path segment for runtime patches before expression lowering.
2258
- */
2259
- type MelIRPathSegment = {
2260
- kind: "prop";
2261
- name: string;
2262
- } | {
2263
- kind: "expr";
2264
- expr: MelExprNode;
2265
- };
2266
- /**
2267
- * MEL runtime patch path represented as IR segments.
2268
- */
2269
- type MelIRPatchPath = MelIRPathSegment[];
2270
- /**
2271
- * Lowered runtime IR path segment.
2272
- */
2273
- type IRPathSegment = {
2274
- kind: "prop";
2275
- name: string;
2276
- } | {
2277
- kind: "expr";
2278
- expr: ExprNode$2;
2279
- };
2280
- /**
2281
- * Runtime patch path represented as IR segments.
2282
- */
2283
- type IRPatchPath = IRPathSegment[];
2284
- /**
2285
- * MEL runtime patch (Translator output for action patches).
2286
- *
2287
- * Contains MEL IR expressions that need lowering to Core IR.
2288
- */
2289
- interface MelRuntimePatch {
2290
- /**
2291
- * Optional condition (MEL IR).
2292
- * If present, patch is only applied when condition evaluates to true.
2293
- */
2294
- condition?: MelExprNode;
2295
- /**
2296
- * Patch operation type.
2297
- */
2298
- op: MelRuntimePatchOp;
2299
- /**
2300
- * Target path in snapshot.
2301
- * Uses IR segments and is resolved to concrete PatchPath at evaluation time.
2302
- */
2303
- path: MelIRPatchPath;
2304
- /**
2305
- * Value expression (MEL IR) for set/merge operations.
2306
- * Required for "set" and "merge", forbidden for "unset".
2307
- */
2308
- value?: MelExprNode;
2309
- }
2310
- /**
2311
- * Runtime ConditionalPatchOp for snapshot state mutations.
2312
- *
2313
- * This is the intermediate representation between Translator output
2314
- * and final concrete Patch[]. Host must call evaluateRuntimePatches()
2315
- * to get concrete values.
2316
- *
2317
- * @see SPEC v0.4.0 §17.5, §20
2318
- */
2319
- interface RuntimeConditionalPatchOp {
2320
- /**
2321
- * Optional condition expression (Core IR).
2322
- * If present, patch is only applied when condition evaluates to true.
2323
- *
2324
- * @see SPEC v0.4.0 §18.6 (boolean-only conditions)
2325
- */
2326
- condition?: ExprNode$2;
2327
- /**
2328
- * Patch operation type.
2329
- */
2330
- op: "set" | "unset" | "merge";
2331
- /**
2332
- * Target path in IR form.
2333
- * Evaluator resolves this to concrete PatchPath.
2334
- */
2335
- path: IRPatchPath;
2336
- /**
2337
- * Value expression (Core IR) for set/merge operations.
2338
- * Required for "set" and "merge", undefined for "unset".
2339
- */
2340
- value?: ExprNode$2;
2341
- }
2342
- /**
2343
- * Lower MEL runtime patches to Core IR.
2344
- *
2345
- * Transforms MEL IR expressions to Core IR expressions.
2346
- * The returned patches still contain expressions that need to be
2347
- * evaluated by evaluateRuntimePatches() to get concrete values.
2348
- *
2349
- * @param patches - MEL IR runtime patches from Translator
2350
- * @param ctx - Expression lowering context
2351
- * @returns Core IR runtime conditional patches
2352
- *
2353
- * @see SPEC v0.4.0 §17.5
2354
- */
2355
- declare function lowerRuntimePatches(patches: MelRuntimePatch[], ctx: ExprLoweringContext): RuntimeConditionalPatchOp[];
2356
- /**
2357
- * Lower a single MEL runtime patch to Core IR.
2358
- */
2359
- declare function lowerRuntimePatch(patch: MelRuntimePatch, ctx: ExprLoweringContext): RuntimeConditionalPatchOp;
2360
-
2361
- /**
2362
- * Evaluation Context Types
2363
- *
2364
- * Defines context for expression evaluation.
2365
- *
2366
- * @see SPEC v0.4.0 §18.3
2367
- */
2368
- /**
2369
- * Minimal snapshot shape for evaluation.
2370
- *
2371
- * @see SPEC v0.4.0 §18.7
2372
- */
2373
- interface EvaluationSnapshot {
2374
- /**
2375
- * Domain data (matches StateSpec).
2376
- * Path resolution default target.
2377
- */
2378
- data: unknown;
2379
- /**
2380
- * Computed values (matches ComputedSpec).
2381
- * Accessed via bare key paths (e.g., "total", not "computed.total").
2382
- */
2383
- computed: Record<string, unknown>;
2384
- }
2385
- /**
2386
- * Intent metadata for evaluation.
2387
- *
2388
- * @see SPEC v0.4.0 §18.3
2389
- */
2390
- interface EvaluationMeta {
2391
- /**
2392
- * Intent identifier.
2393
- */
2394
- intentId: string;
2395
- /**
2396
- * Actor reference (optional).
2397
- */
2398
- actor?: {
2399
- type: string;
2400
- id: string;
2401
- };
2402
- /**
2403
- * Timestamp (optional).
2404
- */
2405
- timestamp?: number;
2406
- }
2407
- /**
2408
- * Evaluation context.
2409
- *
2410
- * @see SPEC v0.4.0 §18.3
2411
- */
2412
- interface EvaluationContext {
2413
- /**
2414
- * Current snapshot for state lookups.
2415
- * Paths resolve to snapshot.data.* by default.
2416
- */
2417
- snapshot: EvaluationSnapshot;
2418
- /**
2419
- * Intent metadata.
2420
- * Paths starting with "meta.*" resolve here.
2421
- */
2422
- meta: EvaluationMeta;
2423
- /**
2424
- * Intent input.
2425
- * Paths starting with "input.*" resolve here.
2426
- */
2427
- input: Record<string, unknown>;
2428
- /**
2429
- * Current $item value (for effect.args evaluation).
2430
- * Paths starting with "$item.*" resolve here.
2431
- */
2432
- item?: unknown;
2433
- }
2434
- /**
2435
- * Create a minimal evaluation context.
2436
- *
2437
- * @param options - Context options
2438
- * @returns Evaluation context
2439
- */
2440
- declare function createEvaluationContext(options: Partial<EvaluationContext> & {
2441
- meta: EvaluationMeta;
2442
- }): EvaluationContext;
2443
- /**
2444
- * Create a working snapshot by cloning and applying a patch.
2445
- *
2446
- * Used for sequential evaluation semantics.
2447
- *
2448
- * @see FDR-MEL-070
2449
- */
2450
- declare function applyPatchToWorkingSnapshot(snapshot: EvaluationSnapshot, path: string, value: unknown): EvaluationSnapshot;
2451
-
2452
- /**
2453
- * Expression Evaluation
2454
- *
2455
- * Evaluates Core IR expressions against evaluation context.
2456
- *
2457
- * AXIOM A35: Expression evaluation is total; invalid operations return null, never throw.
2458
- *
2459
- * @see SPEC v0.4.0 §18
2460
- */
2461
-
2462
- /**
2463
- * Evaluate a Core IR expression.
2464
- *
2465
- * Total function: returns null on any error, never throws.
2466
- *
2467
- * @param expr - Core IR expression
2468
- * @param ctx - Evaluation context
2469
- * @returns Evaluated value or null on error
2470
- *
2471
- * @see SPEC v0.4.0 §18.4, A35
2472
- */
2473
- declare function evaluateExpr(expr: ExprNode$2, ctx: EvaluationContext): unknown;
2474
-
2475
- /**
2476
- * Patch Evaluation
2477
- *
2478
- * Evaluates ConditionalPatchOp[] to produce concrete schema operations.
2479
- *
2480
- * @see SPEC v0.4.0 §18.5, §18.6
2481
- */
2482
-
2483
- /**
2484
- * Evaluated schema patch operation.
2485
- *
2486
- * All conditions have been evaluated and values resolved where appropriate.
2487
- * Expressions in addComputed, addConstraint, addActionAvailable are preserved
2488
- * for runtime evaluation by Core.
2489
- */
2490
- type EvaluatedPatchOp = LoweredPatchOp;
2491
- /**
2492
- * Result of evaluating a conditional patch.
2493
- */
2494
- interface EvaluatedPatch {
2495
- /**
2496
- * Fragment identifier (for tracing).
2497
- */
2498
- fragmentId: string;
2499
- /**
2500
- * The evaluated operation.
2501
- */
2502
- op: EvaluatedPatchOp;
2503
- /**
2504
- * Confidence (preserved from fragment).
2505
- */
2506
- confidence: number;
2507
- /**
2508
- * Whether condition was evaluated (true) or there was no condition.
2509
- */
2510
- conditionEvaluated: boolean;
2511
- }
2512
- /**
2513
- * Result of patch evaluation.
2514
- */
2515
- interface PatchEvaluationResult {
2516
- /**
2517
- * Patches that passed their conditions.
2518
- */
2519
- patches: EvaluatedPatch[];
2520
- /**
2521
- * Patches that were skipped due to false/null conditions.
2522
- */
2523
- skipped: Array<{
2524
- fragmentId: string;
2525
- reason: "false" | "null" | "non-boolean";
2526
- }>;
2527
- /**
2528
- * Final working snapshot after all evaluations.
2529
- */
2530
- finalSnapshot: EvaluationSnapshot;
2531
- }
2532
- /**
2533
- * Evaluate conditional patch operations.
2534
- *
2535
- * Implements sequential evaluation semantics: later patches see effects
2536
- * of earlier patches via working snapshot.
2537
- *
2538
- * Conditions are boolean-only: true applies, false/null/non-boolean skips.
2539
- *
2540
- * @param ops - Conditional patch operations from lowering phase
2541
- * @param ctx - Initial evaluation context
2542
- * @returns Evaluation result with applied and skipped patches
2543
- *
2544
- * @see SPEC v0.4.0 §18.5, FDR-MEL-070, FDR-MEL-073
2545
- */
2546
- declare function evaluateConditionalPatchOps(ops: ConditionalPatchOp[], ctx: EvaluationContext): PatchEvaluationResult;
2547
- /**
2548
- * Simple evaluation: returns patches that pass conditions.
2549
- *
2550
- * Does not track skipped patches or maintain sequential semantics.
2551
- * Use this for stateless condition evaluation.
2552
- *
2553
- * @param ops - Conditional patch operations
2554
- * @param ctx - Evaluation context
2555
- * @returns Patches that passed their conditions
2556
- */
2557
- declare function evaluatePatches(ops: ConditionalPatchOp[], ctx: EvaluationContext): EvaluatedPatch[];
2558
- /**
2559
- * Evaluate expressions in a patch operation to concrete values.
2560
- *
2561
- * Use this when you need fully concrete values (no expressions).
2562
- *
2563
- * Note: addComputed.expr, addConstraint.rule, and addActionAvailable.expr
2564
- * are meant to remain as expressions for runtime evaluation by Core.
2565
- *
2566
- * @param op - Lowered patch operation
2567
- * @param ctx - Evaluation context
2568
- * @returns Patch operation with evaluated expressions
2569
- */
2570
- declare function evaluatePatchExpressions(op: LoweredPatchOp, ctx: EvaluationContext): LoweredPatchOp;
2571
- /**
2572
- * Check if a condition evaluates to true.
2573
- *
2574
- * Boolean-only: only true returns true.
2575
- * false, null, and non-boolean values return false.
2576
- *
2577
- * @param condition - Condition expression (or undefined for always-true)
2578
- * @param ctx - Evaluation context
2579
- * @returns True if condition passes
2580
- *
2581
- * @see FDR-MEL-073
2582
- */
2583
- declare function evaluateCondition(condition: ExprNode$2 | undefined, ctx: EvaluationContext): boolean;
2584
- /**
2585
- * Classify a condition evaluation result.
2586
- *
2587
- * @param condition - Condition expression
2588
- * @param ctx - Evaluation context
2589
- * @returns Classification of condition result
2590
- */
2591
- declare function classifyCondition(condition: ExprNode$2 | undefined, ctx: EvaluationContext): {
2592
- passes: boolean;
2593
- reason: "no-condition" | "true" | "false" | "null" | "non-boolean";
2594
- };
2595
-
2596
- /**
2597
- * Runtime Patch Evaluation
2598
- *
2599
- * Evaluates RuntimeConditionalPatchOp[] to produce concrete Patch[].
2600
- */
2601
-
2602
- /**
2603
- * Skip reason for runtime patches.
2604
- */
2605
- type RuntimePatchSkipReason = "false" | "null" | "non-boolean" | "invalid-path";
2606
- /**
2607
- * Skipped patch info.
2608
- */
2609
- interface SkippedRuntimePatch {
2610
- /**
2611
- * Index in the original ops array.
2612
- */
2613
- index: number;
2614
- /**
2615
- * Target path (display form).
2616
- */
2617
- path: string;
2618
- /**
2619
- * Reason why patch was skipped.
2620
- */
2621
- reason: RuntimePatchSkipReason;
2622
- }
2623
- /**
2624
- * Result of runtime patch evaluation with trace information.
2625
- */
2626
- interface RuntimePatchEvaluationResult {
2627
- /**
2628
- * Concrete patches that passed conditions.
2629
- * Order is preserved from input.
2630
- */
2631
- patches: Patch[];
2632
- /**
2633
- * Patches that were skipped due to false/null/non-boolean conditions.
2634
- */
2635
- skipped: SkippedRuntimePatch[];
2636
- /**
2637
- * Non-fatal warnings collected during evaluation.
2638
- */
2639
- warnings: string[];
2640
- /**
2641
- * Final working snapshot after all evaluations.
2642
- */
2643
- finalSnapshot: EvaluationSnapshot;
2644
- }
2645
- /**
2646
- * Evaluate runtime conditional patches to concrete Patch[].
2647
- */
2648
- declare function evaluateRuntimePatches(ops: RuntimeConditionalPatchOp[], ctx: EvaluationContext): Patch[];
2649
- /**
2650
- * Evaluate runtime patches with trace information.
2651
- */
2652
- declare function evaluateRuntimePatchesWithTrace(ops: RuntimeConditionalPatchOp[], ctx: EvaluationContext): RuntimePatchEvaluationResult;
2653
-
2654
- /**
2655
- * MEL Text Ingest API
2656
- *
2657
- * Compiles MEL text to DomainSchema or RuntimeConditionalPatchOp[].
2658
- *
2659
- * @see SPEC v0.4.0 §19
2660
- */
2661
-
2662
- /**
2663
- * Trace entry for compilation steps.
2664
- */
2665
- interface CompileTrace {
2666
- phase: "lex" | "parse" | "analyze" | "generate" | "lower";
2667
- durationMs: number;
2668
- details?: Record<string, unknown>;
2669
- }
2670
- /**
2671
- * Domain compilation options.
2672
- */
2673
- interface CompileMelDomainOptions {
2674
- mode: "domain";
2675
- fnTableVersion?: string;
2676
- }
2677
- /**
2678
- * Domain compilation result.
2679
- *
2680
- * @see SPEC v0.4.0 §19.1
2681
- */
2682
- interface CompileMelDomainResult {
2683
- /**
2684
- * Compiled schema, or null if errors occurred.
2685
- */
2686
- schema: DomainSchema | null;
2687
- /**
2688
- * Compilation trace.
2689
- */
2690
- trace: CompileTrace[];
2691
- /**
2692
- * Warning diagnostics.
2693
- */
2694
- warnings: Diagnostic[];
2695
- /**
2696
- * Error diagnostics.
2697
- */
2698
- errors: Diagnostic[];
2699
- }
2700
- /**
2701
- * Patch compilation options.
2702
- */
2703
- interface CompileMelPatchOptions {
2704
- mode: "patch";
2705
- /**
2706
- * Action name for context.
2707
- */
2708
- actionName: string;
2709
- /**
2710
- * Allowed system path prefixes.
2711
- * Default: ["meta", "input"] (system is forbidden per §20.3).
2712
- */
2713
- allowSysPaths?: {
2714
- prefixes: ("meta" | "input")[];
2715
- };
2716
- /**
2717
- * Function table version.
2718
- */
2719
- fnTableVersion?: string;
2720
- }
2721
- /**
2722
- * Patch compilation result.
2723
- *
2724
- * @see SPEC v0.4.0 §19.2
2725
- */
2726
- interface CompileMelPatchResult {
2727
- /**
2728
- * Compiled patch operations.
2729
- * These still contain Core IR expressions that need evaluation.
2730
- */
2731
- ops: RuntimeConditionalPatchOp[];
2732
- /**
2733
- * Compilation trace.
2734
- */
2735
- trace: CompileTrace[];
2736
- /**
2737
- * Warning diagnostics.
2738
- */
2739
- warnings: Diagnostic[];
2740
- /**
2741
- * Error diagnostics.
2742
- */
2743
- errors: Diagnostic[];
2744
- }
2745
- /**
2746
- * Compile MEL text to DomainSchema.
2747
- *
2748
- * Takes a complete MEL domain definition and produces a DomainSchema
2749
- * suitable for use with core.compute().
2750
- *
2751
- * @param melText - MEL domain source text
2752
- * @param options - Compilation options
2753
- * @returns Compilation result with schema or errors
2754
- *
2755
- * @see SPEC v0.4.0 §19.1
2756
- */
2757
- declare function compileMelDomain(melText: string, options?: CompileMelDomainOptions): CompileMelDomainResult;
2758
- /**
2759
- * Compile MEL patch text to RuntimeConditionalPatchOp[].
2760
- *
2761
- * Takes MEL patch statements (set, unset, merge) and produces
2762
- * RuntimeConditionalPatchOp[] with Core IR expressions.
2763
- *
2764
- * The returned ops still contain expressions that need to be evaluated
2765
- * by evaluateRuntimePatches() to get concrete values.
2766
- *
2767
- * Constraints:
2768
- * - §20.3: $system.* is forbidden in Translator path
2769
- *
2770
- * @param melText - MEL patch source text
2771
- * @param options - Compilation options
2772
- * @returns Compilation result with ops or errors
2773
- *
2774
- * @see SPEC v0.4.0 §19.2
2775
- */
2776
- declare function compileMelPatch(melText: string, options: CompileMelPatchOptions): CompileMelPatchResult;
2777
-
2778
1
  /**
2779
2
  * @manifesto-ai/compiler
2780
3
  *
2781
4
  * MEL (Manifesto Expression Language) compiler.
2782
5
  * Provides lexer, parser, analyzer, lowering, evaluation, and rendering.
2783
6
  */
2784
-
2785
- interface CompileOptions {
7
+ export * from "./lexer/index.js";
8
+ export * from "./parser/index.js";
9
+ export * from "./analyzer/index.js";
10
+ export * from "./diagnostics/index.js";
11
+ export * from "./generator/index.js";
12
+ export { renderTypeExpr, renderTypeField, renderValue, renderExprNode, renderPatchOp, extractTypeName, renderFragment, renderFragments, renderFragmentsByKind, renderAsDomain, type TypeExpr, type TypeField, type ExprNode as RendererExprNode, type PatchOp, type AddTypeOp, type AddFieldOp, type SetFieldTypeOp, type SetDefaultValueOp, type AddConstraintOp, type AddComputedOp, type AddActionAvailableOp, type RenderOptions, type PatchFragment, type FragmentRenderOptions, } from "./renderer/index.js";
13
+ export * from "./lowering/index.js";
14
+ export * from "./evaluation/index.js";
15
+ export * from "./api/index.js";
16
+ export type { DomainSchema as DomainModule } from "./generator/ir.js";
17
+ import type { ParseResult } from "./parser/index.js";
18
+ import { type DomainSchema } from "./generator/index.js";
19
+ import type { CompileTrace } from "./api/index.js";
20
+ import type { Diagnostic } from "./diagnostics/types.js";
21
+ export interface CompileOptions {
2786
22
  /** Whether to lower system values during compilation */
2787
23
  lowerSystemValues?: boolean;
2788
24
  /** Skip scope/semantic validation */
@@ -2790,7 +26,7 @@ interface CompileOptions {
2790
26
  /** Backward-compatible passthrough for legacy callers */
2791
27
  mode?: "domain";
2792
28
  }
2793
- interface CompileResult {
29
+ export interface CompileResult {
2794
30
  schema: DomainSchema | null;
2795
31
  trace: CompileTrace[];
2796
32
  warnings: Diagnostic[];
@@ -2808,14 +44,12 @@ interface CompileResult {
2808
44
  * - supports optional `lowerSystemValues` and `skipSemanticAnalysis`
2809
45
  * - includes parse/analyze/generate diagnostics in one result
2810
46
  */
2811
- declare function compile(source: string, options?: CompileOptions): CompileResult;
47
+ export declare function compile(source: string, options?: CompileOptions): CompileResult;
2812
48
  /**
2813
49
  * Backward-compatible token+parse helper.
2814
50
  */
2815
- declare function parseSource(source: string): ParseResult;
51
+ export declare function parseSource(source: string): ParseResult;
2816
52
  /**
2817
53
  * Backward-compatible check helper.
2818
54
  */
2819
- declare function check(source: string): Diagnostic[];
2820
-
2821
- export { type ASTNode, type ActionNode, type ActionSpec, type AddActionAvailableOp, type AddComputedOp, type AddConstraintOp, type AddFieldOp, type AddTypeOp, type AllowedSysPrefix, type ArrayLiteralExprNode, type ArrayTypeNode, type BinaryExprNode, type BinaryOperator, type CanonicalDomainSchema, type CompileMelDomainOptions, type CompileMelDomainResult, type CompileMelPatchOptions, type CompileMelPatchResult, type CompileOptions, type CompileResult, type CompileTrace, type CompilerActionSpec, type CompilerComputedFieldSpec, type CompilerExprNode, type CompilerFlowNode, type ComputedFieldSpec, type ComputedNode, type ComputedSpec, type ConditionalPatchOp, type CoreExprNode, type CoreFlowNode, DEFAULT_ACTION_CONTEXT, DEFAULT_PATCH_CONTEXT, DEFAULT_SCHEMA_CONTEXT, DIAGNOSTIC_CODES, type Diagnostic, type DiagnosticCode, type DiagnosticSeverity, type DomainMember, type DomainSchema as DomainModule, type DomainNode, type DomainSchema, EFFECT_ARGS_CONTEXT, type EffectArgNode, type EffectStmtNode, type EvaluatedPatch, type EvaluatedPatchOp, type EvaluationContext, type EvaluationMeta, type EvaluationSnapshot, type ExprLoweringContext, type ExprNode$1 as ExprNode, type FailStmtNode, type FieldSpec, type FieldType, type FlowDeclNode, type FlowStmtNode, type FragmentRenderOptions, type FunctionCallExprNode, type GenerateCanonicalResult, type GenerateResult, type GuardedStmtNode, type IRPatchPath, type IRPathSegment, type IdentifierExprNode, type ImportNode, type IncludeStmtNode, type IndexAccessExprNode, type IndexSegmentNode, type InnerStmtNode, type IterationVarExprNode, KEYWORDS, type LexResult, Lexer, type LiteralExprNode, type LiteralTypeNode, type LoweredPatchOp, type LoweredTypeExpr, type LoweredTypeField, LoweringError, type LoweringErrorCode, type MelExprNode, type MelIRPatchPath, type MelIRPathSegment, type MelObjField, type MelPatchFragment, type MelPatchOp, type MelPathNode, type MelPathSegment, type MelPrimitive, type MelRuntimePatch, type MelRuntimePatchOp, type MelSystemPath, type MelTypeExpr, type MelTypeField, type ObjectLiteralExprNode, type ObjectPropertyNode, type ObjectTypeNode, type OnceIntentStmtNode, type OnceStmtNode, type ParamNode, type ParseResult, Parser, type PatchEvaluationResult, type PatchFragment, type PatchLoweringContext, type PatchOp, type PatchStmtNode, type PathNode, type PathSegmentNode, type Position, Precedence, type ProgramNode, type PropertyAccessExprNode, type PropertySegmentNode, RESERVED_KEYWORDS, type RecordTypeNode, type RelatedDiagnostic, type RenderOptions, type ExprNode as RendererExprNode, type RuntimeConditionalPatchOp, type RuntimePatchEvaluationResult, type RuntimePatchSkipReason, type SchemaConditionalPatchOp, Scope, type ScopeAnalysisResult, ScopeAnalyzer, SemanticValidator, type SetDefaultValueOp, type SetFieldTypeOp, type SimpleTypeNode, type SkippedRuntimePatch, type SourceLocation, type StateFieldNode, type StateNode, type StateSpec, type StopStmtNode, type Symbol, type SymbolKind, type SystemIdentExprNode, type TernaryExprNode, type Token, type TokenKind, type TypeDeclNode, type TypeDefinition, type TypeExpr, type TypeExprNode, type TypeField, type TypeFieldNode, type TypeSpec, type UnaryExprNode, type UnionTypeNode, type ValidationResult, type WhenStmtNode, analyzeScope, applyPatchToWorkingSnapshot, check, classifyCondition, compile, compileMelDomain, compileMelPatch, createError, createEvaluationContext, createInfo, createLocation, createPointLocation, createPosition, createToken, createWarning, evaluateCondition, evaluateConditionalPatchOps, evaluateExpr, evaluatePatchExpressions, evaluatePatches, evaluateRuntimePatches, evaluateRuntimePatchesWithTrace, extractTypeName, filterBySeverity, formatDiagnostic, formatDiagnosticCode, formatDiagnostics, generate, generateCanonical, getBinaryPrecedence, getDiagnosticInfo, getKeywordKind, hasErrors, invalidKindForContext, invalidShape, invalidSysPath, isBinaryOp, isError, isExprNode, isKeyword, isReserved, isRightAssociative, isStmtNode, isUnaryOp, lowerExprNode, lowerPatchFragments, lowerRuntimePatch, lowerRuntimePatches, lowerSystemValues, mergeLocations, normalizeExpr, normalizeFunctionCall, parse, parseSource, renderAsDomain, renderExprNode, renderFragment, renderFragments, renderFragmentsByKind, renderPatchOp, renderTypeExpr, renderTypeField, renderValue, tokenToBinaryOp, tokenize, unknownCallFn, unknownNodeKind, unsupportedBase, validateSemantics };
55
+ export declare function check(source: string): Diagnostic[];