@manifesto-ai/compiler 1.9.0 → 3.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 (80) hide show
  1. package/README.md +17 -5
  2. package/dist/analyzer/entity-primitives.d.ts +3 -0
  3. package/dist/analyzer/expr-type-surface.d.ts +21 -0
  4. package/dist/analyzer/flow-composition.d.ts +7 -0
  5. package/dist/analyzer/index.d.ts +5 -0
  6. package/dist/analyzer/scope.d.ts +76 -0
  7. package/dist/analyzer/validator.d.ts +69 -0
  8. package/dist/api/compile-mel-patch-collector.d.ts +33 -0
  9. package/dist/api/compile-mel-patch-expr.d.ts +8 -0
  10. package/dist/api/compile-mel-patch-location.d.ts +9 -0
  11. package/dist/api/compile-mel-patch.d.ts +5 -0
  12. package/dist/api/compile-mel.d.ts +125 -0
  13. package/dist/api/index.d.ts +9 -0
  14. package/dist/{chunk-4JJQCFJH.js → chunk-7TT6Y5ZC.js} +6 -2
  15. package/dist/chunk-7TT6Y5ZC.js.map +1 -0
  16. package/dist/{chunk-AYZTDA3J.js → chunk-LI5HNMZV.js} +2 -2
  17. package/dist/chunk-VAFXIS7J.js +101 -0
  18. package/dist/chunk-VAFXIS7J.js.map +1 -0
  19. package/dist/diagnostics/codes.d.ts +24 -0
  20. package/dist/diagnostics/format.d.ts +25 -0
  21. package/dist/diagnostics/index.d.ts +6 -0
  22. package/dist/diagnostics/types.d.ts +66 -0
  23. package/dist/esbuild.d.ts +6 -8
  24. package/dist/esbuild.js +3 -3
  25. package/dist/esbuild.js.map +1 -1
  26. package/dist/evaluation/context.d.ts +90 -0
  27. package/dist/evaluation/evaluate-expr.d.ts +23 -0
  28. package/dist/evaluation/evaluate-patch.d.ts +122 -0
  29. package/dist/evaluation/evaluate-runtime-patch.d.ts +59 -0
  30. package/dist/evaluation/index.d.ts +14 -0
  31. package/dist/generator/index.d.ts +6 -0
  32. package/dist/generator/ir.d.ts +185 -0
  33. package/dist/generator/lowering.d.ts +10 -0
  34. package/dist/generator/normalizer.d.ts +15 -0
  35. package/dist/generator/runtime-lowering.d.ts +2 -0
  36. package/dist/index.d.ts +19 -2785
  37. package/dist/index.js +1 -1
  38. package/dist/lexer/index.d.ts +6 -0
  39. package/dist/lexer/lexer.d.ts +58 -0
  40. package/dist/lexer/source-location.d.ts +40 -0
  41. package/dist/lexer/tokens.d.ts +46 -0
  42. package/dist/lowering/context.d.ts +95 -0
  43. package/dist/lowering/errors.d.ts +83 -0
  44. package/dist/lowering/index.d.ts +19 -0
  45. package/dist/lowering/lower-expr.d.ts +79 -0
  46. package/dist/lowering/lower-patch.d.ts +230 -0
  47. package/dist/lowering/lower-runtime-patch.d.ts +126 -0
  48. package/dist/lowering/to-mel-expr.d.ts +12 -0
  49. package/dist/mel-module.d.ts +14 -0
  50. package/dist/node-loader.d.ts +3 -7
  51. package/dist/node-loader.js +2 -2
  52. package/dist/parser/ast.d.ts +367 -0
  53. package/dist/parser/index.d.ts +6 -0
  54. package/dist/parser/parser.d.ts +101 -0
  55. package/dist/parser/precedence.d.ts +43 -0
  56. package/dist/renderer/expr-node.d.ts +171 -0
  57. package/dist/renderer/fragment.d.ts +83 -0
  58. package/dist/renderer/index.d.ts +22 -0
  59. package/dist/renderer/patch-op.d.ts +81 -0
  60. package/dist/renderer/type-expr.d.ts +60 -0
  61. package/dist/rollup.d.ts +6 -8
  62. package/dist/rollup.js +3 -3
  63. package/dist/rollup.js.map +1 -1
  64. package/dist/rspack.d.ts +6 -7
  65. package/dist/rspack.js +3 -3
  66. package/dist/rspack.js.map +1 -1
  67. package/dist/unplugin.d.ts +19 -0
  68. package/dist/utils/unicode-order.d.ts +5 -0
  69. package/dist/vite.d.ts +6 -8
  70. package/dist/vite.js +3 -3
  71. package/dist/vite.js.map +1 -1
  72. package/dist/webpack.d.ts +6 -8
  73. package/dist/webpack.js +3 -3
  74. package/dist/webpack.js.map +1 -1
  75. package/package.json +12 -17
  76. package/dist/chunk-4JJQCFJH.js.map +0 -1
  77. package/dist/chunk-K4IKHGOP.js +0 -74
  78. package/dist/chunk-K4IKHGOP.js.map +0 -1
  79. package/dist/unplugin-6wnvFiEo.d.ts +0 -17
  80. /package/dist/{chunk-AYZTDA3J.js.map → chunk-LI5HNMZV.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  compileMelDomain
3
- } from "./chunk-4JJQCFJH.js";
3
+ } from "./chunk-7TT6Y5ZC.js";
4
4
 
5
5
  // src/mel-module.ts
6
6
  function formatDiagnostic(diagnostic) {
@@ -30,4 +30,4 @@ export {
30
30
  formatDiagnostic,
31
31
  compileMelToModuleCode
32
32
  };
33
- //# sourceMappingURL=chunk-AYZTDA3J.js.map
33
+ //# sourceMappingURL=chunk-LI5HNMZV.js.map
@@ -0,0 +1,101 @@
1
+ import {
2
+ formatDiagnostic
3
+ } from "./chunk-LI5HNMZV.js";
4
+ import {
5
+ compileMelDomain
6
+ } from "./chunk-7TT6Y5ZC.js";
7
+
8
+ // src/unplugin.ts
9
+ import { createHash } from "crypto";
10
+ import * as nodePath from "path";
11
+ import { createUnplugin } from "unplugin";
12
+ function normalizeId(id) {
13
+ return id.split("?", 1)[0];
14
+ }
15
+ function testRegex(regex, value) {
16
+ regex.lastIndex = 0;
17
+ return regex.test(value);
18
+ }
19
+ function normalizeArtifactSourceId(sourceId) {
20
+ const normalized = normalizeId(sourceId).replace(/\\/g, "/");
21
+ if (!normalized) {
22
+ return "domain.mel";
23
+ }
24
+ if (!nodePath.isAbsolute(sourceId)) {
25
+ return normalized.replace(/^\.\//, "");
26
+ }
27
+ const relative2 = nodePath.relative(process.cwd(), sourceId);
28
+ if (!relative2 || relative2.startsWith("..") || nodePath.isAbsolute(relative2)) {
29
+ return createExternalArtifactSourceId(normalized);
30
+ }
31
+ return relative2.split(nodePath.sep).join("/");
32
+ }
33
+ function createExternalArtifactSourceId(sourceId) {
34
+ const basename = nodePath.posix.basename(sourceId) || "domain.mel";
35
+ const extension = nodePath.posix.extname(basename);
36
+ const stem = basename.slice(0, basename.length - extension.length) || "domain";
37
+ const hash = createHash("sha256").update(sourceId).digest("hex").slice(0, 12);
38
+ const safeStem = sanitizePathSegment(stem);
39
+ return `external/${safeStem}--${hash}${extension}`;
40
+ }
41
+ function sanitizePathSegment(value) {
42
+ const normalized = value.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
43
+ return normalized || "domain";
44
+ }
45
+ function resolveCodegenEmitter(codegen) {
46
+ if (!codegen) {
47
+ return null;
48
+ }
49
+ if (typeof codegen === "function") {
50
+ return codegen;
51
+ }
52
+ if (typeof codegen === "object" && typeof codegen.emit === "function") {
53
+ return codegen.emit;
54
+ }
55
+ throw new TypeError(
56
+ "manifesto:mel codegen must be a function or an object with a callable emit field"
57
+ );
58
+ }
59
+ var unpluginMel = createUnplugin((options = {}) => {
60
+ const include = options.include ?? /\.mel$/;
61
+ const compiledSchemas = /* @__PURE__ */ new Map();
62
+ const codegenEmitter = resolveCodegenEmitter(options.codegen);
63
+ return {
64
+ name: "manifesto:mel",
65
+ enforce: "pre",
66
+ transformInclude(id) {
67
+ return testRegex(include, normalizeId(id));
68
+ },
69
+ transform(source, id) {
70
+ const sourceId = normalizeId(id);
71
+ const result = compileMelDomain(source, { mode: "domain" });
72
+ if (result.errors.length > 0) {
73
+ const details = result.errors.map(formatDiagnostic).join("\n");
74
+ throw new Error(`MEL compilation failed for ${sourceId}
75
+ ${details}`);
76
+ }
77
+ if (!result.schema) {
78
+ throw new Error(`MEL compilation produced no schema for ${sourceId}`);
79
+ }
80
+ if (codegenEmitter) {
81
+ compiledSchemas.set(normalizeArtifactSourceId(sourceId), result.schema);
82
+ }
83
+ const serializedSchema = JSON.stringify(result.schema, null, 2);
84
+ return `export default ${serializedSchema};
85
+ `;
86
+ },
87
+ async buildEnd() {
88
+ if (!codegenEmitter || compiledSchemas.size === 0) {
89
+ return;
90
+ }
91
+ for (const [sourceId, schema] of compiledSchemas) {
92
+ await codegenEmitter({ schema, sourceId });
93
+ }
94
+ }
95
+ };
96
+ });
97
+
98
+ export {
99
+ unpluginMel
100
+ };
101
+ //# sourceMappingURL=chunk-VAFXIS7J.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/unplugin.ts"],"sourcesContent":["/**\n * Unified MEL plugin via unplugin.\n *\n * Single implementation that targets Vite, Webpack, Rollup, esbuild, and Rspack.\n */\n\nimport { createHash } from \"node:crypto\";\nimport * as nodePath from \"node:path\";\nimport { createUnplugin } from \"unplugin\";\nimport type { DomainSchema } from \"@manifesto-ai/core\";\nimport { compileMelDomain } from \"./api/index.js\";\nimport { formatDiagnostic } from \"./mel-module.js\";\n\nexport type MelCodegenArtifact = {\n readonly schema: DomainSchema;\n readonly sourceId: string;\n};\n\nexport type MelCodegenEmitter = (\n artifact: MelCodegenArtifact\n) => unknown | Promise<unknown>;\n\nexport type MelCodegenOptions = {\n readonly emit: MelCodegenEmitter;\n};\n\nexport type MelPluginOptions = {\n readonly include?: RegExp;\n readonly codegen?: MelCodegenEmitter | MelCodegenOptions | false;\n};\n\nfunction normalizeId(id: string): string {\n return id.split(\"?\", 1)[0];\n}\n\nfunction testRegex(regex: RegExp, value: string): boolean {\n regex.lastIndex = 0;\n return regex.test(value);\n}\n\nfunction normalizeArtifactSourceId(sourceId: string): string {\n const normalized = normalizeId(sourceId).replace(/\\\\/g, \"/\");\n if (!normalized) {\n return \"domain.mel\";\n }\n\n if (!nodePath.isAbsolute(sourceId)) {\n return normalized.replace(/^\\.\\//, \"\");\n }\n\n const relative = nodePath.relative(process.cwd(), sourceId);\n if (!relative || relative.startsWith(\"..\") || nodePath.isAbsolute(relative)) {\n return createExternalArtifactSourceId(normalized);\n }\n\n return relative.split(nodePath.sep).join(\"/\");\n}\n\nfunction createExternalArtifactSourceId(sourceId: string): string {\n const basename = nodePath.posix.basename(sourceId) || \"domain.mel\";\n const extension = nodePath.posix.extname(basename);\n const stem = basename.slice(0, basename.length - extension.length) || \"domain\";\n const hash = createHash(\"sha256\").update(sourceId).digest(\"hex\").slice(0, 12);\n const safeStem = sanitizePathSegment(stem);\n return `external/${safeStem}--${hash}${extension}`;\n}\n\nfunction sanitizePathSegment(value: string): string {\n const normalized = value.replace(/[^a-zA-Z0-9._-]+/g, \"-\").replace(/^-+|-+$/g, \"\");\n return normalized || \"domain\";\n}\n\nfunction resolveCodegenEmitter(\n codegen: MelPluginOptions[\"codegen\"]\n): MelCodegenEmitter | null {\n if (!codegen) {\n return null;\n }\n\n if (typeof codegen === \"function\") {\n return codegen;\n }\n\n if (typeof codegen === \"object\" && typeof codegen.emit === \"function\") {\n return codegen.emit;\n }\n\n throw new TypeError(\n \"manifesto:mel codegen must be a function or an object with a callable emit field\"\n );\n}\n\nexport const unpluginMel = createUnplugin((options: MelPluginOptions = {}) => {\n const include = options.include ?? /\\.mel$/;\n const compiledSchemas = new Map<string, DomainSchema>();\n const codegenEmitter = resolveCodegenEmitter(options.codegen);\n\n return {\n name: \"manifesto:mel\",\n enforce: \"pre\" as const,\n\n transformInclude(id: string) {\n return testRegex(include, normalizeId(id));\n },\n\n transform(source: string, id: string) {\n const sourceId = normalizeId(id);\n const result = compileMelDomain(source, { mode: \"domain\" });\n\n if (result.errors.length > 0) {\n const details = result.errors.map(formatDiagnostic).join(\"\\n\");\n throw new Error(`MEL compilation failed for ${sourceId}\\n${details}`);\n }\n\n if (!result.schema) {\n throw new Error(`MEL compilation produced no schema for ${sourceId}`);\n }\n\n if (codegenEmitter) {\n compiledSchemas.set(normalizeArtifactSourceId(sourceId), result.schema);\n }\n\n const serializedSchema = JSON.stringify(result.schema, null, 2);\n return `export default ${serializedSchema};\\n`;\n },\n\n async buildEnd() {\n if (!codegenEmitter || compiledSchemas.size === 0) {\n return;\n }\n\n for (const [sourceId, schema] of compiledSchemas) {\n await codegenEmitter({ schema, sourceId });\n }\n },\n };\n});\n"],"mappings":";;;;;;;;AAMA,SAAS,kBAAkB;AAC3B,YAAY,cAAc;AAC1B,SAAS,sBAAsB;AAuB/B,SA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+ /**
2
+ * MEL Compiler Diagnostic Codes
3
+ * Based on MEL SPEC v0.3.3 Appendix A
4
+ */
5
+ /**
6
+ * Diagnostic code information
7
+ */
8
+ export interface DiagnosticCode {
9
+ code: string;
10
+ message: string;
11
+ category: "syntax" | "semantic" | "type" | "system";
12
+ }
13
+ /**
14
+ * All diagnostic codes
15
+ */
16
+ export declare const DIAGNOSTIC_CODES: Record<string, DiagnosticCode>;
17
+ /**
18
+ * Get diagnostic code information
19
+ */
20
+ export declare function getDiagnosticInfo(code: string): DiagnosticCode | undefined;
21
+ /**
22
+ * Format a diagnostic code for display
23
+ */
24
+ export declare function formatDiagnosticCode(code: string): string;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Plain-text Diagnostic Formatter
3
+ *
4
+ * Browser-safe (no ANSI colors). Produces human-readable error messages
5
+ * with optional source context and caret indicators.
6
+ *
7
+ * @module
8
+ */
9
+ import type { Diagnostic } from "./types.js";
10
+ /**
11
+ * Format a single diagnostic as plain text.
12
+ *
13
+ * Without source: `[MEL_PARSER] Expected '{' (3:15)`
14
+ * With source:
15
+ * ```
16
+ * [MEL_PARSER] Expected '{' (3:15)
17
+ * 3 | domain Bad bad syntax here }
18
+ * ^^^
19
+ * ```
20
+ */
21
+ export declare function formatDiagnostic(diagnostic: Diagnostic, source?: string): string;
22
+ /**
23
+ * Format multiple diagnostics, separated by blank lines.
24
+ */
25
+ export declare function formatDiagnostics(diagnostics: Diagnostic[], source?: string): string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Diagnostics Module - Error and warning reporting
3
+ */
4
+ export * from "./types.js";
5
+ export * from "./codes.js";
6
+ export { formatDiagnostic, formatDiagnostics } from "./format.js";
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Diagnostic Types for MEL Compiler
3
+ * Error and warning reporting structures
4
+ */
5
+ import type { SourceLocation } from "../lexer/source-location.js";
6
+ /**
7
+ * Severity level of a diagnostic
8
+ */
9
+ export type DiagnosticSeverity = "error" | "warning" | "info";
10
+ /**
11
+ * A diagnostic message (error, warning, or info)
12
+ */
13
+ export interface Diagnostic {
14
+ /** Severity level */
15
+ severity: DiagnosticSeverity;
16
+ /** Error code (e.g., "MEL001", "MEL_LEXER") */
17
+ code: string;
18
+ /** Human-readable message */
19
+ message: string;
20
+ /** Location in source */
21
+ location: SourceLocation;
22
+ /** The source line containing the error */
23
+ source?: string;
24
+ /** Suggested fix */
25
+ suggestion?: string;
26
+ /** Related diagnostics */
27
+ related?: RelatedDiagnostic[];
28
+ }
29
+ /**
30
+ * A related diagnostic (for multi-location errors)
31
+ */
32
+ export interface RelatedDiagnostic {
33
+ message: string;
34
+ location: SourceLocation;
35
+ }
36
+ /**
37
+ * Create an error diagnostic
38
+ */
39
+ export declare function createError(code: string, message: string, location: SourceLocation, options?: {
40
+ source?: string;
41
+ suggestion?: string;
42
+ related?: RelatedDiagnostic[];
43
+ }): Diagnostic;
44
+ /**
45
+ * Create a warning diagnostic
46
+ */
47
+ export declare function createWarning(code: string, message: string, location: SourceLocation, options?: {
48
+ source?: string;
49
+ suggestion?: string;
50
+ }): Diagnostic;
51
+ /**
52
+ * Create an info diagnostic
53
+ */
54
+ export declare function createInfo(code: string, message: string, location: SourceLocation): Diagnostic;
55
+ /**
56
+ * Check if a diagnostic is an error
57
+ */
58
+ export declare function isError(diagnostic: Diagnostic): boolean;
59
+ /**
60
+ * Check if any diagnostics contain errors
61
+ */
62
+ export declare function hasErrors(diagnostics: Diagnostic[]): boolean;
63
+ /**
64
+ * Filter diagnostics by severity
65
+ */
66
+ export declare function filterBySeverity(diagnostics: Diagnostic[], severity: DiagnosticSeverity): Diagnostic[];
package/dist/esbuild.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- import * as unplugin from 'unplugin';
2
- import { M as MelPluginOptions } from './unplugin-6wnvFiEo.js';
3
- export { a as MelCodegenOptions } from './unplugin-6wnvFiEo.js';
4
- import '@manifesto-ai/codegen';
5
-
6
- declare const melPlugin: (options: MelPluginOptions) => unplugin.EsbuildPlugin;
7
-
8
- export { MelPluginOptions, melPlugin as default, melPlugin };
1
+ /**
2
+ * esbuild plugin for MEL files.
3
+ */
4
+ export type { MelPluginOptions, MelCodegenOptions, MelCodegenEmitter, MelCodegenArtifact, } from "./unplugin.js";
5
+ export declare const melPlugin: (options: import("./unplugin.js").MelPluginOptions) => import("unplugin").EsbuildPlugin;
6
+ export default melPlugin;
package/dist/esbuild.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  unpluginMel
3
- } from "./chunk-K4IKHGOP.js";
4
- import "./chunk-AYZTDA3J.js";
5
- import "./chunk-4JJQCFJH.js";
3
+ } from "./chunk-VAFXIS7J.js";
4
+ import "./chunk-LI5HNMZV.js";
5
+ import "./chunk-7TT6Y5ZC.js";
6
6
 
7
7
  // src/esbuild.ts
8
8
  var melPlugin = unpluginMel.esbuild;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/esbuild.ts"],"sourcesContent":["/**\n * esbuild plugin for MEL files.\n */\n\nimport { unpluginMel } from \"./unplugin.js\";\n\nexport type { MelPluginOptions, MelCodegenOptions } from \"./unplugin.js\";\nexport const melPlugin = unpluginMel.esbuild;\nexport default melPlugin;\n"],"mappings":";;;;;;;AAOO,IAAM,YAAY,YAAY;AACrC,IAAO,kBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/esbuild.ts"],"sourcesContent":["/**\n * esbuild plugin for MEL files.\n */\n\nimport { unpluginMel } from \"./unplugin.js\";\n\nexport type {\n MelPluginOptions,\n MelCodegenOptions,\n MelCodegenEmitter,\n MelCodegenArtifact,\n} from \"./unplugin.js\";\nexport const melPlugin = unpluginMel.esbuild;\nexport default melPlugin;\n"],"mappings":";;;;;;;AAYO,IAAM,YAAY,YAAY;AACrC,IAAO,kBAAQ;","names":[]}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Evaluation Context Types
3
+ *
4
+ * Defines context for expression evaluation.
5
+ *
6
+ * @see SPEC v0.4.0 §18.3
7
+ */
8
+ /**
9
+ * Minimal snapshot shape for evaluation.
10
+ *
11
+ * @see SPEC v0.4.0 §18.7
12
+ */
13
+ export interface EvaluationSnapshot {
14
+ /**
15
+ * Domain data (matches StateSpec).
16
+ * Path resolution default target.
17
+ */
18
+ data: unknown;
19
+ /**
20
+ * Computed values (matches ComputedSpec).
21
+ * Accessed via bare key paths (e.g., "total", not "computed.total").
22
+ */
23
+ computed: Record<string, unknown>;
24
+ }
25
+ /**
26
+ * Intent metadata for evaluation.
27
+ *
28
+ * @see SPEC v0.4.0 §18.3
29
+ */
30
+ export interface EvaluationMeta {
31
+ /**
32
+ * Intent identifier.
33
+ */
34
+ intentId: string;
35
+ /**
36
+ * Actor reference (optional).
37
+ */
38
+ actor?: {
39
+ type: string;
40
+ id: string;
41
+ };
42
+ /**
43
+ * Timestamp (optional).
44
+ */
45
+ timestamp?: number;
46
+ }
47
+ /**
48
+ * Evaluation context.
49
+ *
50
+ * @see SPEC v0.4.0 §18.3
51
+ */
52
+ export interface EvaluationContext {
53
+ /**
54
+ * Current snapshot for state lookups.
55
+ * Paths resolve to snapshot.data.* by default.
56
+ */
57
+ snapshot: EvaluationSnapshot;
58
+ /**
59
+ * Intent metadata.
60
+ * Paths starting with "meta.*" resolve here.
61
+ */
62
+ meta: EvaluationMeta;
63
+ /**
64
+ * Intent input.
65
+ * Paths starting with "input.*" resolve here.
66
+ */
67
+ input: Record<string, unknown>;
68
+ /**
69
+ * Current $item value (for effect.args evaluation).
70
+ * Paths starting with "$item.*" resolve here.
71
+ */
72
+ item?: unknown;
73
+ }
74
+ /**
75
+ * Create a minimal evaluation context.
76
+ *
77
+ * @param options - Context options
78
+ * @returns Evaluation context
79
+ */
80
+ export declare function createEvaluationContext(options: Partial<EvaluationContext> & {
81
+ meta: EvaluationMeta;
82
+ }): EvaluationContext;
83
+ /**
84
+ * Create a working snapshot by cloning and applying a patch.
85
+ *
86
+ * Used for sequential evaluation semantics.
87
+ *
88
+ * @see FDR-MEL-070
89
+ */
90
+ export declare function applyPatchToWorkingSnapshot(snapshot: EvaluationSnapshot, path: string, value: unknown): EvaluationSnapshot;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Expression Evaluation
3
+ *
4
+ * Evaluates Core IR expressions against evaluation context.
5
+ *
6
+ * AXIOM A35: Expression evaluation is total; invalid operations return null, never throw.
7
+ *
8
+ * @see SPEC v0.4.0 §18
9
+ */
10
+ import type { ExprNode } from "@manifesto-ai/core";
11
+ import type { EvaluationContext } from "./context.js";
12
+ /**
13
+ * Evaluate a Core IR expression.
14
+ *
15
+ * Total function: returns null on any error, never throws.
16
+ *
17
+ * @param expr - Core IR expression
18
+ * @param ctx - Evaluation context
19
+ * @returns Evaluated value or null on error
20
+ *
21
+ * @see SPEC v0.4.0 §18.4, A35
22
+ */
23
+ export declare function evaluateExpr(expr: ExprNode, ctx: EvaluationContext): unknown;
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Patch Evaluation
3
+ *
4
+ * Evaluates ConditionalPatchOp[] to produce concrete schema operations.
5
+ *
6
+ * @see SPEC v0.4.0 §18.5, §18.6
7
+ */
8
+ import type { ExprNode as CoreExprNode } from "@manifesto-ai/core";
9
+ import type { ConditionalPatchOp, LoweredPatchOp } from "../lowering/lower-patch.js";
10
+ import type { EvaluationContext, EvaluationSnapshot } from "./context.js";
11
+ /**
12
+ * Evaluated schema patch operation.
13
+ *
14
+ * All conditions have been evaluated and values resolved where appropriate.
15
+ * Expressions in addComputed, addConstraint, addActionAvailable are preserved
16
+ * for runtime evaluation by Core.
17
+ */
18
+ export type EvaluatedPatchOp = LoweredPatchOp;
19
+ /**
20
+ * Result of evaluating a conditional patch.
21
+ */
22
+ export interface EvaluatedPatch {
23
+ /**
24
+ * Fragment identifier (for tracing).
25
+ */
26
+ fragmentId: string;
27
+ /**
28
+ * The evaluated operation.
29
+ */
30
+ op: EvaluatedPatchOp;
31
+ /**
32
+ * Confidence (preserved from fragment).
33
+ */
34
+ confidence: number;
35
+ /**
36
+ * Whether condition was evaluated (true) or there was no condition.
37
+ */
38
+ conditionEvaluated: boolean;
39
+ }
40
+ /**
41
+ * Result of patch evaluation.
42
+ */
43
+ export interface PatchEvaluationResult {
44
+ /**
45
+ * Patches that passed their conditions.
46
+ */
47
+ patches: EvaluatedPatch[];
48
+ /**
49
+ * Patches that were skipped due to false/null conditions.
50
+ */
51
+ skipped: Array<{
52
+ fragmentId: string;
53
+ reason: "false" | "null" | "non-boolean";
54
+ }>;
55
+ /**
56
+ * Final working snapshot after all evaluations.
57
+ */
58
+ finalSnapshot: EvaluationSnapshot;
59
+ }
60
+ /**
61
+ * Evaluate conditional patch operations.
62
+ *
63
+ * Implements sequential evaluation semantics: later patches see effects
64
+ * of earlier patches via working snapshot.
65
+ *
66
+ * Conditions are boolean-only: true applies, false/null/non-boolean skips.
67
+ *
68
+ * @param ops - Conditional patch operations from lowering phase
69
+ * @param ctx - Initial evaluation context
70
+ * @returns Evaluation result with applied and skipped patches
71
+ *
72
+ * @see SPEC v0.4.0 §18.5, FDR-MEL-070, FDR-MEL-073
73
+ */
74
+ export declare function evaluateConditionalPatchOps(ops: ConditionalPatchOp[], ctx: EvaluationContext): PatchEvaluationResult;
75
+ /**
76
+ * Simple evaluation: returns patches that pass conditions.
77
+ *
78
+ * Does not track skipped patches or maintain sequential semantics.
79
+ * Use this for stateless condition evaluation.
80
+ *
81
+ * @param ops - Conditional patch operations
82
+ * @param ctx - Evaluation context
83
+ * @returns Patches that passed their conditions
84
+ */
85
+ export declare function evaluatePatches(ops: ConditionalPatchOp[], ctx: EvaluationContext): EvaluatedPatch[];
86
+ /**
87
+ * Evaluate expressions in a patch operation to concrete values.
88
+ *
89
+ * Use this when you need fully concrete values (no expressions).
90
+ *
91
+ * Note: addComputed.expr, addConstraint.rule, and addActionAvailable.expr
92
+ * are meant to remain as expressions for runtime evaluation by Core.
93
+ *
94
+ * @param op - Lowered patch operation
95
+ * @param ctx - Evaluation context
96
+ * @returns Patch operation with evaluated expressions
97
+ */
98
+ export declare function evaluatePatchExpressions(op: LoweredPatchOp, ctx: EvaluationContext): LoweredPatchOp;
99
+ /**
100
+ * Check if a condition evaluates to true.
101
+ *
102
+ * Boolean-only: only true returns true.
103
+ * false, null, and non-boolean values return false.
104
+ *
105
+ * @param condition - Condition expression (or undefined for always-true)
106
+ * @param ctx - Evaluation context
107
+ * @returns True if condition passes
108
+ *
109
+ * @see FDR-MEL-073
110
+ */
111
+ export declare function evaluateCondition(condition: CoreExprNode | undefined, ctx: EvaluationContext): boolean;
112
+ /**
113
+ * Classify a condition evaluation result.
114
+ *
115
+ * @param condition - Condition expression
116
+ * @param ctx - Evaluation context
117
+ * @returns Classification of condition result
118
+ */
119
+ export declare function classifyCondition(condition: CoreExprNode | undefined, ctx: EvaluationContext): {
120
+ passes: boolean;
121
+ reason: "no-condition" | "true" | "false" | "null" | "non-boolean";
122
+ };
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Runtime Patch Evaluation
3
+ *
4
+ * Evaluates RuntimeConditionalPatchOp[] to produce concrete Patch[].
5
+ */
6
+ import type { Patch } from "@manifesto-ai/core";
7
+ import type { RuntimeConditionalPatchOp } from "../lowering/lower-runtime-patch.js";
8
+ import type { EvaluationContext, EvaluationSnapshot } from "./context.js";
9
+ /**
10
+ * Skip reason for runtime patches.
11
+ */
12
+ export type RuntimePatchSkipReason = "false" | "null" | "non-boolean" | "invalid-path";
13
+ /**
14
+ * Skipped patch info.
15
+ */
16
+ export interface SkippedRuntimePatch {
17
+ /**
18
+ * Index in the original ops array.
19
+ */
20
+ index: number;
21
+ /**
22
+ * Target path (display form).
23
+ */
24
+ path: string;
25
+ /**
26
+ * Reason why patch was skipped.
27
+ */
28
+ reason: RuntimePatchSkipReason;
29
+ }
30
+ /**
31
+ * Result of runtime patch evaluation with trace information.
32
+ */
33
+ export interface RuntimePatchEvaluationResult {
34
+ /**
35
+ * Concrete patches that passed conditions.
36
+ * Order is preserved from input.
37
+ */
38
+ patches: Patch[];
39
+ /**
40
+ * Patches that were skipped due to false/null/non-boolean conditions.
41
+ */
42
+ skipped: SkippedRuntimePatch[];
43
+ /**
44
+ * Non-fatal warnings collected during evaluation.
45
+ */
46
+ warnings: string[];
47
+ /**
48
+ * Final working snapshot after all evaluations.
49
+ */
50
+ finalSnapshot: EvaluationSnapshot;
51
+ }
52
+ /**
53
+ * Evaluate runtime conditional patches to concrete Patch[].
54
+ */
55
+ export declare function evaluateRuntimePatches(ops: RuntimeConditionalPatchOp[], ctx: EvaluationContext): Patch[];
56
+ /**
57
+ * Evaluate runtime patches with trace information.
58
+ */
59
+ export declare function evaluateRuntimePatchesWithTrace(ops: RuntimeConditionalPatchOp[], ctx: EvaluationContext): RuntimePatchEvaluationResult;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Evaluation Module
3
+ *
4
+ * Evaluates Core IR expressions and conditional patches.
5
+ *
6
+ * @see SPEC v0.4.0 §18
7
+ */
8
+ export type { EvaluationSnapshot, EvaluationMeta, EvaluationContext, } from "./context.js";
9
+ export { createEvaluationContext, applyPatchToWorkingSnapshot, } from "./context.js";
10
+ export { evaluateExpr } from "./evaluate-expr.js";
11
+ export type { EvaluatedPatchOp, EvaluatedPatch, PatchEvaluationResult, } from "./evaluate-patch.js";
12
+ export { evaluateConditionalPatchOps, evaluatePatches, evaluatePatchExpressions, evaluateCondition, classifyCondition, } from "./evaluate-patch.js";
13
+ export type { RuntimePatchSkipReason, SkippedRuntimePatch, RuntimePatchEvaluationResult, } from "./evaluate-runtime-patch.js";
14
+ export { evaluateRuntimePatches, evaluateRuntimePatchesWithTrace, } from "./evaluate-runtime-patch.js";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generator Module - Transforms MEL AST to Core IR
3
+ */
4
+ export * from "./ir.js";
5
+ export * from "./normalizer.js";
6
+ export * from "./lowering.js";