edict-lang 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -5
- package/dist/ast/nodes.d.ts +180 -7
- package/dist/ast/nodes.d.ts.map +1 -1
- package/dist/ast/nodes.js +24 -0
- package/dist/ast/nodes.js.map +1 -1
- package/dist/ast/types.d.ts +42 -1
- package/dist/ast/types.d.ts.map +1 -1
- package/dist/ast/types.js +1 -1
- package/dist/ast/types.js.map +1 -1
- package/dist/ast/walk.d.ts +18 -0
- package/dist/ast/walk.d.ts.map +1 -0
- package/dist/ast/walk.js +95 -0
- package/dist/ast/walk.js.map +1 -0
- package/dist/builtins/builtin-types.d.ts +12 -0
- package/dist/builtins/builtin-types.d.ts.map +1 -1
- package/dist/builtins/domains/core.d.ts.map +1 -1
- package/dist/builtins/domains/core.js +7 -9
- package/dist/builtins/domains/core.js.map +1 -1
- package/dist/builtins/domains/crypto.d.ts.map +1 -1
- package/dist/builtins/domains/crypto.js +9 -10
- package/dist/builtins/domains/crypto.js.map +1 -1
- package/dist/builtins/domains/datetime.d.ts.map +1 -1
- package/dist/builtins/domains/datetime.js +7 -5
- package/dist/builtins/domains/datetime.js.map +1 -1
- package/dist/builtins/domains/http.d.ts.map +1 -1
- package/dist/builtins/domains/http.js +32 -15
- package/dist/builtins/domains/http.js.map +1 -1
- package/dist/builtins/domains/io.d.ts.map +1 -1
- package/dist/builtins/domains/io.js +12 -10
- package/dist/builtins/domains/io.js.map +1 -1
- package/dist/builtins/domains/json.js +5 -5
- package/dist/builtins/domains/json.js.map +1 -1
- package/dist/builtins/domains/random.d.ts.map +1 -1
- package/dist/builtins/domains/random.js +6 -0
- package/dist/builtins/domains/random.js.map +1 -1
- package/dist/builtins/domains/regex.d.ts.map +1 -1
- package/dist/builtins/domains/regex.js +11 -14
- package/dist/builtins/domains/regex.js.map +1 -1
- package/dist/builtins/domains/string.d.ts.map +1 -1
- package/dist/builtins/domains/string.js +28 -33
- package/dist/builtins/domains/string.js.map +1 -1
- package/dist/builtins/host-helpers.d.ts +31 -2
- package/dist/builtins/host-helpers.d.ts.map +1 -1
- package/dist/builtins/host-helpers.js +60 -6
- package/dist/builtins/host-helpers.js.map +1 -1
- package/dist/builtins/registry.d.ts +23 -1
- package/dist/builtins/registry.d.ts.map +1 -1
- package/dist/builtins/registry.js +40 -3
- package/dist/builtins/registry.js.map +1 -1
- package/dist/check.d.ts +8 -0
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +10 -1
- package/dist/check.js.map +1 -1
- package/dist/checker/check.d.ts +7 -1
- package/dist/checker/check.d.ts.map +1 -1
- package/dist/checker/check.js +250 -21
- package/dist/checker/check.js.map +1 -1
- package/dist/checker/complexity.d.ts +8 -0
- package/dist/checker/complexity.d.ts.map +1 -0
- package/dist/checker/complexity.js +87 -0
- package/dist/checker/complexity.js.map +1 -0
- package/dist/checker/type-env.d.ts +4 -1
- package/dist/checker/type-env.d.ts.map +1 -1
- package/dist/checker/type-env.js +10 -0
- package/dist/checker/type-env.js.map +1 -1
- package/dist/checker/types-equal.d.ts.map +1 -1
- package/dist/checker/types-equal.js +21 -0
- package/dist/checker/types-equal.js.map +1 -1
- package/dist/codegen/closures.d.ts.map +1 -1
- package/dist/codegen/closures.js +21 -84
- package/dist/codegen/closures.js.map +1 -1
- package/dist/codegen/codegen.d.ts +13 -2
- package/dist/codegen/codegen.d.ts.map +1 -1
- package/dist/codegen/codegen.js +80 -58
- package/dist/codegen/codegen.js.map +1 -1
- package/dist/codegen/collect-strings.js +12 -0
- package/dist/codegen/collect-strings.js.map +1 -1
- package/dist/codegen/compile-calls.d.ts.map +1 -1
- package/dist/codegen/compile-calls.js +11 -195
- package/dist/codegen/compile-calls.js.map +1 -1
- package/dist/codegen/compile-data.d.ts.map +1 -1
- package/dist/codegen/compile-data.js +50 -71
- package/dist/codegen/compile-data.js.map +1 -1
- package/dist/codegen/compile-expr.d.ts.map +1 -1
- package/dist/codegen/compile-expr.js +10 -0
- package/dist/codegen/compile-expr.js.map +1 -1
- package/dist/codegen/compile-scalars.d.ts.map +1 -1
- package/dist/codegen/compile-scalars.js +69 -26
- package/dist/codegen/compile-scalars.js.map +1 -1
- package/dist/codegen/node-host-adapter.d.ts.map +1 -1
- package/dist/codegen/node-host-adapter.js +6 -5
- package/dist/codegen/node-host-adapter.js.map +1 -1
- package/dist/codegen/recording-adapter.d.ts +14 -0
- package/dist/codegen/recording-adapter.d.ts.map +1 -0
- package/dist/codegen/recording-adapter.js +30 -0
- package/dist/codegen/recording-adapter.js.map +1 -0
- package/dist/codegen/replay-adapter.d.ts +21 -0
- package/dist/codegen/replay-adapter.d.ts.map +1 -0
- package/dist/codegen/replay-adapter.js +76 -0
- package/dist/codegen/replay-adapter.js.map +1 -0
- package/dist/codegen/replay-types.d.ts +24 -0
- package/dist/codegen/replay-types.d.ts.map +1 -0
- package/dist/codegen/replay-types.js +7 -0
- package/dist/codegen/replay-types.js.map +1 -0
- package/dist/codegen/runner.d.ts +56 -0
- package/dist/codegen/runner.d.ts.map +1 -1
- package/dist/codegen/runner.js +312 -5
- package/dist/codegen/runner.js.map +1 -1
- package/dist/codegen/string-table.d.ts +5 -4
- package/dist/codegen/string-table.d.ts.map +1 -1
- package/dist/codegen/string-table.js +15 -5
- package/dist/codegen/string-table.js.map +1 -1
- package/dist/codegen/types.d.ts +12 -5
- package/dist/codegen/types.d.ts.map +1 -1
- package/dist/codegen/types.js +21 -4
- package/dist/codegen/types.js.map +1 -1
- package/dist/compact/expand.d.ts +9 -3
- package/dist/compact/expand.d.ts.map +1 -1
- package/dist/compact/expand.js +15 -3
- package/dist/compact/expand.js.map +1 -1
- package/dist/compose/compose.d.ts +26 -0
- package/dist/compose/compose.d.ts.map +1 -0
- package/dist/compose/compose.js +117 -0
- package/dist/compose/compose.js.map +1 -0
- package/dist/contracts/generate-tests.d.ts +27 -0
- package/dist/contracts/generate-tests.d.ts.map +1 -0
- package/dist/contracts/generate-tests.js +300 -0
- package/dist/contracts/generate-tests.js.map +1 -0
- package/dist/contracts/hash.d.ts +15 -0
- package/dist/contracts/hash.d.ts.map +1 -0
- package/dist/contracts/hash.js +66 -0
- package/dist/contracts/hash.js.map +1 -0
- package/dist/contracts/translate-semantic.d.ts +13 -0
- package/dist/contracts/translate-semantic.d.ts.map +1 -0
- package/dist/contracts/translate-semantic.js +177 -0
- package/dist/contracts/translate-semantic.js.map +1 -0
- package/dist/contracts/translate.d.ts.map +1 -1
- package/dist/contracts/translate.js +37 -0
- package/dist/contracts/translate.js.map +1 -1
- package/dist/contracts/verify.d.ts +64 -4
- package/dist/contracts/verify.d.ts.map +1 -1
- package/dist/contracts/verify.js +299 -17
- package/dist/contracts/verify.js.map +1 -1
- package/dist/effects/call-graph.d.ts +22 -3
- package/dist/effects/call-graph.d.ts.map +1 -1
- package/dist/effects/call-graph.js +51 -96
- package/dist/effects/call-graph.js.map +1 -1
- package/dist/effects/effect-check.d.ts +6 -0
- package/dist/effects/effect-check.d.ts.map +1 -1
- package/dist/effects/effect-check.js +36 -2
- package/dist/effects/effect-check.js.map +1 -1
- package/dist/errors/error-catalog.d.ts +3 -3
- package/dist/errors/error-catalog.d.ts.map +1 -1
- package/dist/errors/error-catalog.js +397 -728
- package/dist/errors/error-catalog.js.map +1 -1
- package/dist/errors/error-registry.d.ts +26 -0
- package/dist/errors/error-registry.d.ts.map +1 -0
- package/dist/errors/error-registry.js +157 -0
- package/dist/errors/error-registry.js.map +1 -0
- package/dist/errors/explain.d.ts +45 -0
- package/dist/errors/explain.d.ts.map +1 -0
- package/dist/errors/explain.js +84 -0
- package/dist/errors/explain.js.map +1 -0
- package/dist/errors/structured-errors.d.ts +151 -2
- package/dist/errors/structured-errors.d.ts.map +1 -1
- package/dist/errors/structured-errors.js +84 -2
- package/dist/errors/structured-errors.js.map +1 -1
- package/dist/incremental/check.d.ts +33 -0
- package/dist/incremental/check.d.ts.map +1 -0
- package/dist/incremental/check.js +157 -0
- package/dist/incremental/check.js.map +1 -0
- package/dist/incremental/dep-graph.d.ts +29 -0
- package/dist/incremental/dep-graph.d.ts.map +1 -0
- package/dist/incremental/dep-graph.js +200 -0
- package/dist/incremental/dep-graph.js.map +1 -0
- package/dist/incremental/diff.d.ts +14 -0
- package/dist/incremental/diff.d.ts.map +1 -0
- package/dist/incremental/diff.js +98 -0
- package/dist/incremental/diff.js.map +1 -0
- package/dist/index.d.ts +44 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +97 -20
- package/dist/index.js.map +1 -1
- package/dist/lint/lint.d.ts +7 -1
- package/dist/lint/lint.d.ts.map +1 -1
- package/dist/lint/lint.js +354 -5
- package/dist/lint/lint.js.map +1 -1
- package/dist/lint/warnings.d.ts +96 -2
- package/dist/lint/warnings.d.ts.map +1 -1
- package/dist/lint/warnings.js +88 -0
- package/dist/lint/warnings.js.map +1 -1
- package/dist/mcp/handlers.d.ts +69 -1
- package/dist/mcp/handlers.d.ts.map +1 -1
- package/dist/mcp/handlers.js +349 -19
- package/dist/mcp/handlers.js.map +1 -1
- package/dist/mcp/tools/check.d.ts.map +1 -1
- package/dist/mcp/tools/check.js +8 -5
- package/dist/mcp/tools/check.js.map +1 -1
- package/dist/mcp/tools/compile.d.ts.map +1 -1
- package/dist/mcp/tools/compile.js +8 -5
- package/dist/mcp/tools/compile.js.map +1 -1
- package/dist/mcp/tools/compose.d.ts +3 -0
- package/dist/mcp/tools/compose.d.ts.map +1 -0
- package/dist/mcp/tools/compose.js +42 -0
- package/dist/mcp/tools/compose.js.map +1 -0
- package/dist/mcp/tools/debug.d.ts +3 -0
- package/dist/mcp/tools/debug.d.ts.map +1 -0
- package/dist/mcp/tools/debug.js +32 -0
- package/dist/mcp/tools/debug.js.map +1 -0
- package/dist/mcp/tools/explain.d.ts +3 -0
- package/dist/mcp/tools/explain.d.ts.map +1 -0
- package/dist/mcp/tools/explain.js +21 -0
- package/dist/mcp/tools/explain.js.map +1 -0
- package/dist/mcp/tools/export.d.ts +3 -0
- package/dist/mcp/tools/export.d.ts.map +1 -0
- package/dist/mcp/tools/export.js +37 -0
- package/dist/mcp/tools/export.js.map +1 -0
- package/dist/mcp/tools/generate_tests.d.ts +3 -0
- package/dist/mcp/tools/generate_tests.d.ts.map +1 -0
- package/dist/mcp/tools/generate_tests.js +29 -0
- package/dist/mcp/tools/generate_tests.js.map +1 -0
- package/dist/mcp/tools/import_skill.d.ts +3 -0
- package/dist/mcp/tools/import_skill.d.ts.map +1 -0
- package/dist/mcp/tools/import_skill.js +52 -0
- package/dist/mcp/tools/import_skill.js.map +1 -0
- package/dist/mcp/tools/index.d.ts.map +1 -1
- package/dist/mcp/tools/index.js +14 -0
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/replay.d.ts +3 -0
- package/dist/mcp/tools/replay.d.ts.map +1 -0
- package/dist/mcp/tools/replay.js +40 -0
- package/dist/mcp/tools/replay.js.map +1 -0
- package/dist/mcp/tools/run.d.ts.map +1 -1
- package/dist/mcp/tools/run.js +5 -3
- package/dist/mcp/tools/run.js.map +1 -1
- package/dist/mcp/uasf.d.ts +57 -0
- package/dist/mcp/uasf.d.ts.map +1 -0
- package/dist/mcp/uasf.js +6 -0
- package/dist/mcp/uasf.js.map +1 -0
- package/dist/migration/migrate.d.ts +51 -0
- package/dist/migration/migrate.d.ts.map +1 -0
- package/dist/migration/migrate.js +174 -0
- package/dist/migration/migrate.js.map +1 -0
- package/dist/multi-module.d.ts +25 -0
- package/dist/multi-module.d.ts.map +1 -0
- package/dist/multi-module.js +215 -0
- package/dist/multi-module.js.map +1 -0
- package/dist/patch/apply.d.ts +11 -0
- package/dist/patch/apply.d.ts.map +1 -1
- package/dist/patch/apply.js +11 -0
- package/dist/patch/apply.js.map +1 -1
- package/dist/resolver/levenshtein.d.ts +9 -0
- package/dist/resolver/levenshtein.d.ts.map +1 -1
- package/dist/resolver/levenshtein.js +9 -0
- package/dist/resolver/levenshtein.js.map +1 -1
- package/dist/resolver/resolve.d.ts +8 -1
- package/dist/resolver/resolve.d.ts.map +1 -1
- package/dist/resolver/resolve.js +81 -2
- package/dist/resolver/resolve.js.map +1 -1
- package/dist/resolver/scope.d.ts +1 -1
- package/dist/resolver/scope.d.ts.map +1 -1
- package/dist/resolver/scope.js.map +1 -1
- package/dist/validator/node-validators.d.ts +1 -5
- package/dist/validator/node-validators.d.ts.map +1 -1
- package/dist/validator/node-validators.js +6 -872
- package/dist/validator/node-validators.js.map +1 -1
- package/dist/validator/schema-walker.d.ts +19 -0
- package/dist/validator/schema-walker.d.ts.map +1 -0
- package/dist/validator/schema-walker.js +539 -0
- package/dist/validator/schema-walker.js.map +1 -0
- package/dist/validator/validate.d.ts +15 -2
- package/dist/validator/validate.d.ts.map +1 -1
- package/dist/validator/validate.js +36 -4
- package/dist/validator/validate.js.map +1 -1
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ Contract Verifier ── unproven? → StructuredError + counterexample → Agen
|
|
|
35
35
|
- **Contract verification** — Pre/post conditions verified at compile time by Z3 (via SMT). Failing contracts return concrete counterexamples.
|
|
36
36
|
- **WASM compilation** — Verified programs compile to WebAssembly via binaryen and run in Node.js.
|
|
37
37
|
- **MCP interface** — All tools exposed via [Model Context Protocol](https://modelcontextprotocol.io/) for direct agent integration.
|
|
38
|
+
- **Schema migration** — ASTs from older schema versions are auto-migrated. No breakage when the language evolves.
|
|
38
39
|
|
|
39
40
|
## Execution Model
|
|
40
41
|
|
|
@@ -51,17 +52,31 @@ Host capabilities available through adapters: filesystem (sandboxed), HTTP, cryp
|
|
|
51
52
|
|
|
52
53
|
```bash
|
|
53
54
|
npm install
|
|
54
|
-
npm test #
|
|
55
|
+
npm test # 1801 tests across 105 files
|
|
55
56
|
npm run mcp # start MCP server (stdio transport)
|
|
56
57
|
```
|
|
57
58
|
|
|
59
|
+
## Docker
|
|
60
|
+
|
|
61
|
+
Run the Edict MCP server in a container — no local Node.js required:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# stdio transport (default — for local MCP clients)
|
|
65
|
+
docker run -i ghcr.io/sowiedu/edict
|
|
66
|
+
|
|
67
|
+
# HTTP transport (for remote/networked MCP clients)
|
|
68
|
+
docker run -p 3000:3000 -e EDICT_TRANSPORT=http ghcr.io/sowiedu/edict
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Supported platforms: `linux/amd64`, `linux/arm64`.
|
|
72
|
+
|
|
58
73
|
## MCP Tools
|
|
59
74
|
|
|
60
75
|
| Tool | Description |
|
|
61
76
|
|---|---|
|
|
62
77
|
| `edict_schema` | Returns the full AST JSON Schema — the spec for how to write programs |
|
|
63
78
|
| `edict_version` | Returns compiler version and capability info |
|
|
64
|
-
| `edict_examples` | Returns
|
|
79
|
+
| `edict_examples` | Returns 38 example programs as JSON ASTs |
|
|
65
80
|
| `edict_validate` | Validates AST structure (field names, types, node kinds) |
|
|
66
81
|
| `edict_check` | Full pipeline: validate → resolve names → type check → effect check → verify contracts |
|
|
67
82
|
| `edict_compile` | Compiles a checked AST to WASM (returns base64-encoded binary) |
|
|
@@ -69,6 +84,13 @@ npm run mcp # start MCP server (stdio transport)
|
|
|
69
84
|
| `edict_patch` | Applies targeted AST patches by nodeId and re-checks |
|
|
70
85
|
| `edict_errors` | Returns machine-readable catalog of all error types |
|
|
71
86
|
| `edict_lint` | Runs non-blocking quality analysis and returns warnings |
|
|
87
|
+
| `edict_debug` | Execution tracing and crash diagnostics |
|
|
88
|
+
| `edict_compose` | Combines composable program fragments into a module |
|
|
89
|
+
| `edict_explain` | Explains AST nodes, errors, or compiler behavior |
|
|
90
|
+
| `edict_export` | Packages a program as a UASF portable skill |
|
|
91
|
+
| `edict_import_skill` | Imports and executes a UASF skill package |
|
|
92
|
+
| `edict_generate_tests` | Generates tests from Z3-verified contracts |
|
|
93
|
+
| `edict_replay` | Records and replays deterministic execution traces |
|
|
72
94
|
|
|
73
95
|
### MCP Resources
|
|
74
96
|
|
|
@@ -156,19 +178,24 @@ src/
|
|
|
156
178
|
│ ├── compile-expr.ts # Expression compilation
|
|
157
179
|
│ ├── compile-*.ts # Specialized compilers (calls, data, match, scalars)
|
|
158
180
|
│ ├── runner.ts # WASM execution (Node.js WebAssembly API)
|
|
159
|
-
│ ├── host-adapter.ts # EdictHostAdapter interface
|
|
181
|
+
│ ├── host-adapter.ts # EdictHostAdapter interface + platform adapters
|
|
160
182
|
│ ├── closures.ts # Closure capture and compilation
|
|
161
183
|
│ ├── hof-generators.ts # Higher-order function WASM generators
|
|
184
|
+
│ ├── recording-adapter.ts # Execution recording for replay
|
|
185
|
+
│ ├── replay-adapter.ts # Deterministic replay from recorded traces
|
|
162
186
|
│ └── string-table.ts # String interning for WASM memory
|
|
163
187
|
├── builtins/ # Builtin registry and domain-specific builtins
|
|
164
188
|
├── compact/ # Compact AST format (token-efficient for agents)
|
|
189
|
+
├── compose/ # Composable program fragments
|
|
190
|
+
├── incremental/ # Incremental checking (dependency graph + diff)
|
|
165
191
|
├── lint/ # Non-blocking quality warnings
|
|
166
192
|
├── patch/ # Surgical AST patching by nodeId
|
|
193
|
+
├── migration/ # Schema version migration (auto-upgrade older ASTs)
|
|
167
194
|
├── mcp/ # MCP server (tools + resources + prompts)
|
|
168
195
|
└── errors/ # Structured error types
|
|
169
196
|
|
|
170
|
-
tests/ #
|
|
171
|
-
examples/ #
|
|
197
|
+
tests/ # 1801 tests across 105 files
|
|
198
|
+
examples/ # 38 example programs (⭐→⭐⭐⭐ difficulty in README)
|
|
172
199
|
schema/ # Auto-generated JSON Schema
|
|
173
200
|
```
|
|
174
201
|
|
package/dist/ast/nodes.d.ts
CHANGED
|
@@ -6,6 +6,42 @@ export type { TypeExpr } from "./types.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export type Effect = "pure" | "reads" | "writes" | "io" | "fails";
|
|
8
8
|
export declare const VALID_EFFECTS: readonly Effect[];
|
|
9
|
+
/**
|
|
10
|
+
* Retry backoff strategy for tool calls.
|
|
11
|
+
*/
|
|
12
|
+
export type BackoffKind = "fixed" | "linear" | "exponential";
|
|
13
|
+
export declare const VALID_BACKOFF_KINDS: readonly BackoffKind[];
|
|
14
|
+
/**
|
|
15
|
+
* Retry policy for tool calls — how often and how to back off.
|
|
16
|
+
*/
|
|
17
|
+
export interface RetryPolicy {
|
|
18
|
+
maxRetries: number;
|
|
19
|
+
backoff: BackoffKind;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Approval scope controls how often approval must be re-obtained.
|
|
23
|
+
*/
|
|
24
|
+
export type ApprovalScope = "per_call" | "per_session" | "per_module";
|
|
25
|
+
export declare const VALID_APPROVAL_SCOPES: readonly ApprovalScope[];
|
|
26
|
+
/**
|
|
27
|
+
* Approval gate on a function — requires explicit host approval before execution.
|
|
28
|
+
* Propagates through call chains: if a callee requires approval, the caller must too.
|
|
29
|
+
*/
|
|
30
|
+
export interface ApprovalGate {
|
|
31
|
+
required: boolean;
|
|
32
|
+
scope: ApprovalScope;
|
|
33
|
+
reason: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Structured blame / provenance annotation.
|
|
37
|
+
* Tracks which agent produced a module or function, when, and with what confidence.
|
|
38
|
+
*/
|
|
39
|
+
export interface BlameAnnotation {
|
|
40
|
+
author: string;
|
|
41
|
+
generatedAt: string;
|
|
42
|
+
confidence: number;
|
|
43
|
+
sourcePrompt?: string;
|
|
44
|
+
}
|
|
9
45
|
/**
|
|
10
46
|
* A complete Edict program / module.
|
|
11
47
|
*/
|
|
@@ -13,8 +49,26 @@ export interface EdictModule {
|
|
|
13
49
|
kind: "module";
|
|
14
50
|
id: string;
|
|
15
51
|
name: string;
|
|
52
|
+
schemaVersion?: string;
|
|
16
53
|
imports: Import[];
|
|
17
54
|
definitions: Definition[];
|
|
55
|
+
budget?: ComplexityConstraints;
|
|
56
|
+
blame?: BlameAnnotation;
|
|
57
|
+
minConfidence?: number;
|
|
58
|
+
capabilities?: string[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A composable program fragment.
|
|
62
|
+
* Agents can validate fragments independently and compose them into a module.
|
|
63
|
+
*/
|
|
64
|
+
export interface EdictFragment {
|
|
65
|
+
kind: "fragment";
|
|
66
|
+
id: string;
|
|
67
|
+
provides: string[];
|
|
68
|
+
requires: string[];
|
|
69
|
+
imports: Import[];
|
|
70
|
+
definitions: Definition[];
|
|
71
|
+
blame?: BlameAnnotation;
|
|
18
72
|
}
|
|
19
73
|
/**
|
|
20
74
|
* Import names from another module.
|
|
@@ -26,7 +80,7 @@ export interface Import {
|
|
|
26
80
|
names: string[];
|
|
27
81
|
types?: Record<string, TypeExpr>;
|
|
28
82
|
}
|
|
29
|
-
export type Definition = FunctionDef | TypeDef | RecordDef | EnumDef | ConstDef;
|
|
83
|
+
export type Definition = FunctionDef | TypeDef | RecordDef | EnumDef | ConstDef | ToolDef;
|
|
30
84
|
/**
|
|
31
85
|
* Function definition with effects, contracts, and body.
|
|
32
86
|
*/
|
|
@@ -38,8 +92,38 @@ export interface FunctionDef {
|
|
|
38
92
|
effects: Effect[];
|
|
39
93
|
returnType?: TypeExpr;
|
|
40
94
|
contracts: Contract[];
|
|
95
|
+
constraints?: ComplexityConstraints;
|
|
96
|
+
intent?: IntentDeclaration;
|
|
97
|
+
approval?: ApprovalGate;
|
|
98
|
+
blame?: BlameAnnotation;
|
|
41
99
|
body: Expression[];
|
|
42
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Structured intent — what the function is trying to accomplish.
|
|
103
|
+
* Agents use this for re-synthesis, blame tracking, and specification diffing.
|
|
104
|
+
* Invariants reuse Expression and SemanticAssertion types for automated matching.
|
|
105
|
+
*/
|
|
106
|
+
export interface IntentDeclaration {
|
|
107
|
+
goal: string;
|
|
108
|
+
inputs: string[];
|
|
109
|
+
outputs: string[];
|
|
110
|
+
invariants: IntentInvariant[];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A structured invariant that can be automatically matched against contracts.
|
|
114
|
+
* Reuses existing Expression and SemanticAssertionKind — zero new vocabulary.
|
|
115
|
+
*/
|
|
116
|
+
export type IntentInvariant = ExpressionInvariant | SemanticInvariant;
|
|
117
|
+
export interface ExpressionInvariant {
|
|
118
|
+
kind: "expression";
|
|
119
|
+
expression: Expression;
|
|
120
|
+
}
|
|
121
|
+
export interface SemanticInvariant {
|
|
122
|
+
kind: "semantic";
|
|
123
|
+
assertion: SemanticAssertionKind;
|
|
124
|
+
target: string;
|
|
125
|
+
args?: string[];
|
|
126
|
+
}
|
|
43
127
|
/**
|
|
44
128
|
* Type alias definition.
|
|
45
129
|
*/
|
|
@@ -48,6 +132,7 @@ export interface TypeDef {
|
|
|
48
132
|
id: string;
|
|
49
133
|
name: string;
|
|
50
134
|
definition: TypeExpr;
|
|
135
|
+
blame?: BlameAnnotation;
|
|
51
136
|
}
|
|
52
137
|
/**
|
|
53
138
|
* Record (struct) definition.
|
|
@@ -57,6 +142,7 @@ export interface RecordDef {
|
|
|
57
142
|
id: string;
|
|
58
143
|
name: string;
|
|
59
144
|
fields: RecordField[];
|
|
145
|
+
blame?: BlameAnnotation;
|
|
60
146
|
}
|
|
61
147
|
/**
|
|
62
148
|
* A field in a record definition.
|
|
@@ -76,6 +162,7 @@ export interface EnumDef {
|
|
|
76
162
|
id: string;
|
|
77
163
|
name: string;
|
|
78
164
|
variants: EnumVariant[];
|
|
165
|
+
blame?: BlameAnnotation;
|
|
79
166
|
}
|
|
80
167
|
/**
|
|
81
168
|
* A variant of an enum. Fields are empty for unit variants (e.g., None).
|
|
@@ -95,6 +182,22 @@ export interface ConstDef {
|
|
|
95
182
|
name: string;
|
|
96
183
|
type: TypeExpr;
|
|
97
184
|
value: Expression;
|
|
185
|
+
blame?: BlameAnnotation;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Tool definition — declares a named external tool with a typed interface.
|
|
189
|
+
* The host provides the actual implementation at runtime.
|
|
190
|
+
* Tool names are in scope like functions; tool_call expressions reference them by name.
|
|
191
|
+
*/
|
|
192
|
+
export interface ToolDef {
|
|
193
|
+
kind: "tool";
|
|
194
|
+
id: string;
|
|
195
|
+
name: string;
|
|
196
|
+
uri: string;
|
|
197
|
+
params: Param[];
|
|
198
|
+
returnType: TypeExpr;
|
|
199
|
+
effects: Effect[];
|
|
200
|
+
blame?: BlameAnnotation;
|
|
98
201
|
}
|
|
99
202
|
/**
|
|
100
203
|
* Function parameter.
|
|
@@ -107,13 +210,39 @@ export interface Param {
|
|
|
107
210
|
}
|
|
108
211
|
/**
|
|
109
212
|
* Pre/post contract on a function.
|
|
213
|
+
* Must have exactly one of `condition` (manual expression) or `semantic` (pre-built assertion).
|
|
214
|
+
* `semantic` is only valid on `post` contracts (v1).
|
|
110
215
|
*/
|
|
111
216
|
export interface Contract {
|
|
112
217
|
kind: "pre" | "post";
|
|
113
218
|
id: string;
|
|
114
|
-
condition
|
|
219
|
+
condition?: Expression;
|
|
220
|
+
semantic?: SemanticAssertion;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* A pre-built semantic assertion that translates to a proven-correct Z3 encoding.
|
|
224
|
+
* Agents use these instead of manually writing Z3-verifiable expressions.
|
|
225
|
+
*/
|
|
226
|
+
export interface SemanticAssertion {
|
|
227
|
+
assertion: SemanticAssertionKind;
|
|
228
|
+
target: string;
|
|
229
|
+
args?: string[];
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* The 7 built-in semantic assertion kinds.
|
|
233
|
+
*/
|
|
234
|
+
export type SemanticAssertionKind = "sorted" | "permutation_of" | "subset_of" | "sum_preserved" | "no_duplicates" | "length_preserved" | "bounded";
|
|
235
|
+
export declare const VALID_SEMANTIC_ASSERTIONS: readonly SemanticAssertionKind[];
|
|
236
|
+
/**
|
|
237
|
+
* Bounds on token complexity and program size to prevent runaway agents.
|
|
238
|
+
*/
|
|
239
|
+
export interface ComplexityConstraints {
|
|
240
|
+
kind: "constraints";
|
|
241
|
+
maxAstNodes?: number;
|
|
242
|
+
maxCallDepth?: number;
|
|
243
|
+
maxBranches?: number;
|
|
115
244
|
}
|
|
116
|
-
export type Expression = Literal | Identifier | BinaryOp | UnaryOp | Call | IfExpr | LetExpr | MatchExpr | ArrayExpr | TupleExpr | RecordExpr | EnumConstructor | FieldAccess | LambdaExpr | BlockExpr | StringInterp;
|
|
245
|
+
export type Expression = Literal | Identifier | BinaryOp | UnaryOp | Call | IfExpr | LetExpr | MatchExpr | ArrayExpr | TupleExpr | RecordExpr | EnumConstructor | FieldAccess | LambdaExpr | BlockExpr | StringInterp | ForallExpr | ExistsExpr | ToolCallExpr;
|
|
117
246
|
export interface Literal {
|
|
118
247
|
kind: "literal";
|
|
119
248
|
id: string;
|
|
@@ -249,10 +378,54 @@ export interface StringInterp {
|
|
|
249
378
|
id: string;
|
|
250
379
|
parts: Expression[];
|
|
251
380
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
381
|
+
/**
|
|
382
|
+
* Universal quantifier — contract-only.
|
|
383
|
+
* forall variable in [range.from, range.to): body
|
|
384
|
+
* Translates to Z3 ForAll. Body must evaluate to Bool.
|
|
385
|
+
*/
|
|
386
|
+
export interface ForallExpr {
|
|
387
|
+
kind: "forall";
|
|
388
|
+
id: string;
|
|
389
|
+
variable: string;
|
|
390
|
+
range: {
|
|
391
|
+
from: Expression;
|
|
392
|
+
to: Expression;
|
|
393
|
+
};
|
|
394
|
+
body: Expression;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Existential quantifier — contract-only.
|
|
398
|
+
* exists variable in [range.from, range.to): body
|
|
399
|
+
* Translates to Z3 Exists. Body must evaluate to Bool.
|
|
400
|
+
*/
|
|
401
|
+
export interface ExistsExpr {
|
|
402
|
+
kind: "exists";
|
|
403
|
+
id: string;
|
|
404
|
+
variable: string;
|
|
405
|
+
range: {
|
|
406
|
+
from: Expression;
|
|
407
|
+
to: Expression;
|
|
408
|
+
};
|
|
409
|
+
body: Expression;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Tool call expression — invokes a declared tool by name.
|
|
413
|
+
* Named args via FieldInit (same pattern as RecordExpr/EnumConstructor).
|
|
414
|
+
* Always returns Result<T, String> where T is the tool's returnType.
|
|
415
|
+
*/
|
|
416
|
+
export interface ToolCallExpr {
|
|
417
|
+
kind: "tool_call";
|
|
418
|
+
id: string;
|
|
419
|
+
tool: string;
|
|
420
|
+
args: FieldInit[];
|
|
421
|
+
timeout?: number;
|
|
422
|
+
retryPolicy?: RetryPolicy;
|
|
423
|
+
fallback?: Expression;
|
|
424
|
+
}
|
|
425
|
+
export declare const VALID_DEFINITION_KINDS: readonly ["fn", "type", "record", "enum", "const", "tool"];
|
|
426
|
+
export declare const VALID_EXPRESSION_KINDS: readonly ["literal", "ident", "binop", "unop", "call", "if", "let", "match", "array", "tuple_expr", "record_expr", "enum_constructor", "access", "lambda", "block", "string_interp", "forall", "exists", "tool_call"];
|
|
427
|
+
export declare const VALID_TYPE_KINDS: readonly ["basic", "array", "option", "result", "unit_type", "refined", "fn_type", "named", "tuple", "confidence", "provenance", "capability", "fresh"];
|
|
255
428
|
export declare const VALID_PATTERN_KINDS: readonly ["literal_pattern", "wildcard", "binding", "constructor"];
|
|
256
429
|
export declare const VALID_BASIC_TYPE_NAMES: readonly ["Int", "Int64", "Float", "String", "Bool"];
|
|
257
|
-
export declare const ALL_VALID_KINDS: readonly ["module", "import", "fn", "type", "record", "enum", "const", "param", "field", "variant", "pre", "post", "arm", "field_init", "literal", "ident", "binop", "unop", "call", "if", "let", "match", "array", "tuple_expr", "record_expr", "enum_constructor", "access", "lambda", "block", "string_interp", "basic", "array", "option", "result", "unit_type", "refined", "fn_type", "named", "tuple", "literal_pattern", "wildcard", "binding", "constructor"];
|
|
430
|
+
export declare const ALL_VALID_KINDS: readonly ["module", "fragment", "import", "fn", "type", "record", "enum", "const", "tool", "param", "field", "variant", "pre", "post", "arm", "field_init", "constraints", "literal", "ident", "binop", "unop", "call", "if", "let", "match", "array", "tuple_expr", "record_expr", "enum_constructor", "access", "lambda", "block", "string_interp", "forall", "exists", "tool_call", "basic", "array", "option", "result", "unit_type", "refined", "fn_type", "named", "tuple", "confidence", "provenance", "capability", "fresh", "literal_pattern", "wildcard", "binding", "constructor"];
|
|
258
431
|
//# sourceMappingURL=nodes.d.ts.map
|
package/dist/ast/nodes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/ast/nodes.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAM3C;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC;AAElE,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAMjC,CAAC;AAMX;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,QAAQ,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,UAAU,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/ast/nodes.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAM3C;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC;AAElE,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAMjC,CAAC;AAMX;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,aAAa,CAAC;AAE7D,eAAO,MAAM,mBAAmB,EAAE,SAAS,WAAW,EAI5C,CA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
11
11
|
"fails",
|
|
12
12
|
];
|
|
13
|
+
export const VALID_BACKOFF_KINDS = [
|
|
14
|
+
"fixed",
|
|
15
|
+
"linear",
|
|
16
|
+
"exponential",
|
|
17
|
+
];
|
|
18
|
+
export const VALID_APPROVAL_SCOPES = [
|
|
19
|
+
"per_call",
|
|
20
|
+
"per_session",
|
|
21
|
+
"per_module",
|
|
22
|
+
];
|
|
23
|
+
export const VALID_SEMANTIC_ASSERTIONS = [
|
|
24
|
+
"sorted", "permutation_of", "subset_of", "sum_preserved",
|
|
25
|
+
"no_duplicates", "length_preserved", "bounded",
|
|
26
|
+
];
|
|
13
27
|
export const VALID_BINARY_OPS = [
|
|
14
28
|
"+",
|
|
15
29
|
"-",
|
|
@@ -36,6 +50,7 @@ export const VALID_DEFINITION_KINDS = [
|
|
|
36
50
|
"record",
|
|
37
51
|
"enum",
|
|
38
52
|
"const",
|
|
53
|
+
"tool",
|
|
39
54
|
];
|
|
40
55
|
export const VALID_EXPRESSION_KINDS = [
|
|
41
56
|
"literal",
|
|
@@ -54,6 +69,9 @@ export const VALID_EXPRESSION_KINDS = [
|
|
|
54
69
|
"lambda",
|
|
55
70
|
"block",
|
|
56
71
|
"string_interp",
|
|
72
|
+
"forall",
|
|
73
|
+
"exists",
|
|
74
|
+
"tool_call",
|
|
57
75
|
];
|
|
58
76
|
export const VALID_TYPE_KINDS = [
|
|
59
77
|
"basic",
|
|
@@ -65,6 +83,10 @@ export const VALID_TYPE_KINDS = [
|
|
|
65
83
|
"fn_type",
|
|
66
84
|
"named",
|
|
67
85
|
"tuple",
|
|
86
|
+
"confidence",
|
|
87
|
+
"provenance",
|
|
88
|
+
"capability",
|
|
89
|
+
"fresh",
|
|
68
90
|
];
|
|
69
91
|
export const VALID_PATTERN_KINDS = [
|
|
70
92
|
"literal_pattern",
|
|
@@ -81,6 +103,7 @@ export const VALID_BASIC_TYPE_NAMES = [
|
|
|
81
103
|
];
|
|
82
104
|
export const ALL_VALID_KINDS = [
|
|
83
105
|
"module",
|
|
106
|
+
"fragment",
|
|
84
107
|
"import",
|
|
85
108
|
...VALID_DEFINITION_KINDS,
|
|
86
109
|
"param",
|
|
@@ -90,6 +113,7 @@ export const ALL_VALID_KINDS = [
|
|
|
90
113
|
"post",
|
|
91
114
|
"arm",
|
|
92
115
|
"field_init",
|
|
116
|
+
"constraints",
|
|
93
117
|
...VALID_EXPRESSION_KINDS,
|
|
94
118
|
...VALID_TYPE_KINDS,
|
|
95
119
|
...VALID_PATTERN_KINDS,
|
package/dist/ast/nodes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../src/ast/nodes.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,6BAA6B;AAC7B,gFAAgF;AAChF,0EAA0E;AAC1E,uDAAuD;AAiBvD,MAAM,CAAC,MAAM,aAAa,GAAsB;IAC5C,MAAM;IACN,OAAO;IACP,QAAQ;IACR,IAAI;IACJ,OAAO;CACD,CAAC;
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../src/ast/nodes.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,6BAA6B;AAC7B,gFAAgF;AAChF,0EAA0E;AAC1E,uDAAuD;AAiBvD,MAAM,CAAC,MAAM,aAAa,GAAsB;IAC5C,MAAM;IACN,OAAO;IACP,QAAQ;IACR,IAAI;IACJ,OAAO;CACD,CAAC;AAWX,MAAM,CAAC,MAAM,mBAAmB,GAA2B;IACvD,OAAO;IACP,QAAQ;IACR,aAAa;CACP,CAAC;AAmBX,MAAM,CAAC,MAAM,qBAAqB,GAA6B;IAC3D,UAAU;IACV,aAAa;IACb,YAAY;CACN,CAAC;AAoQX,MAAM,CAAC,MAAM,yBAAyB,GAAqC;IACvE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,eAAe;IACxD,eAAe,EAAE,kBAAkB,EAAE,SAAS;CACxC,CAAC;AAkEX,MAAM,CAAC,MAAM,gB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L,MAAM;IACN,KAAK;IACL,YAAY;IACZ,aAAa;IACb,GAAG,sBAAsB;IACzB,GAAG,gBAAgB;IACnB,GAAG,mBAAmB;CAChB,CAAC"}
|
package/dist/ast/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Union of all type expressions in Edict.
|
|
3
3
|
*/
|
|
4
|
-
export type TypeExpr = BasicType | ArrayType | OptionType | ResultType | UnitType | RefinedType | FunctionType | NamedType | TupleType;
|
|
4
|
+
export type TypeExpr = BasicType | ArrayType | OptionType | ResultType | UnitType | RefinedType | FunctionType | NamedType | TupleType | ConfidenceType | ProvenanceType | CapabilityType | FreshnessType;
|
|
5
5
|
/**
|
|
6
6
|
* Primitive types.
|
|
7
7
|
*/
|
|
@@ -74,5 +74,46 @@ export interface TupleType {
|
|
|
74
74
|
kind: "tuple";
|
|
75
75
|
elements: TypeExpr[];
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Confidence-typed value — tracks LLM uncertainty at the type level.
|
|
79
|
+
* Erased after type checking (zero runtime cost). Structurally transparent:
|
|
80
|
+
* Confidence<T, 0.9> is assignable to/from T.
|
|
81
|
+
*/
|
|
82
|
+
export interface ConfidenceType {
|
|
83
|
+
kind: "confidence";
|
|
84
|
+
base: TypeExpr;
|
|
85
|
+
confidence: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Provenance-typed value — tracks data origin at the type level.
|
|
89
|
+
* Erased after type checking (zero runtime cost). Structurally transparent:
|
|
90
|
+
* Provenance<T, "api:x"> is assignable to/from T.
|
|
91
|
+
*/
|
|
92
|
+
export interface ProvenanceType {
|
|
93
|
+
kind: "provenance";
|
|
94
|
+
base: TypeExpr;
|
|
95
|
+
sources: string[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Capability token — compile-time verified, unforgeable permission.
|
|
99
|
+
* Not a type wrapper (unlike confidence/provenance). Capabilities ARE the type.
|
|
100
|
+
* Erased at codegen (zero runtime cost). The host mints them; agents cannot forge them.
|
|
101
|
+
* Permissions are hierarchical: "net:smtp" subsumes "net:smtp:max_10" via prefix matching.
|
|
102
|
+
*/
|
|
103
|
+
export interface CapabilityType {
|
|
104
|
+
kind: "capability";
|
|
105
|
+
permissions: string[];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Freshness-typed value — tracks temporal validity at the type level.
|
|
109
|
+
* Erased after type checking (zero runtime cost). Structurally transparent:
|
|
110
|
+
* Fresh<T, "5m"> is assignable to/from T.
|
|
111
|
+
* maxAge is a duration string: "30s", "5m", "1h", "200ms".
|
|
112
|
+
*/
|
|
113
|
+
export interface FreshnessType {
|
|
114
|
+
kind: "fresh";
|
|
115
|
+
base: TypeExpr;
|
|
116
|
+
maxAge: string;
|
|
117
|
+
}
|
|
77
118
|
import type { Expression, Effect } from "./nodes.js";
|
|
78
119
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/ast/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ast/types.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,MAAM,QAAQ,GACd,SAAS,GACT,SAAS,GACT,UAAU,GACV,UAAU,GACV,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,SAAS,GACT,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ast/types.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,MAAM,QAAQ,GACd,SAAS,GACT,SAAS,GACT,UAAU,GACV,UAAU,GACV,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,SAAS,GACT,SAAS,GACT,cAAc,GACd,cAAc,GACd,cAAc,GACd,aAAa,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,OAAO,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ED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB;AAID,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/ast/types.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
// Edict AST Type Expressions
|
|
3
3
|
// =============================================================================
|
|
4
4
|
// Every possible type in the Edict type system.
|
|
5
|
-
// Types are compile-time only — unit types are erased after type checking.
|
|
5
|
+
// Types are compile-time only — unit types and confidence types are erased after type checking.
|
|
6
6
|
export {};
|
|
7
7
|
//# sourceMappingURL=types.js.map
|
package/dist/ast/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ast/types.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,6BAA6B;AAC7B,gFAAgF;AAChF,gDAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ast/types.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,6BAA6B;AAC7B,gFAAgF;AAChF,gDAAgD;AAChD,gGAAgG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Expression } from "./nodes.js";
|
|
2
|
+
export interface AstVisitor {
|
|
3
|
+
/**
|
|
4
|
+
* Called before a node's children are visited.
|
|
5
|
+
* Return `false` to prevent the walker from recursing into this node's children.
|
|
6
|
+
*/
|
|
7
|
+
enter?: (node: Expression) => void | false;
|
|
8
|
+
/**
|
|
9
|
+
* Called after a node's children have been visited.
|
|
10
|
+
*/
|
|
11
|
+
leave?: (node: Expression) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Recursively walks an Edict expression tree.
|
|
15
|
+
* Guarantees traversal over all child expressions.
|
|
16
|
+
*/
|
|
17
|
+
export declare function walkExpression(expr: Expression, visitor: AstVisitor | ((node: Expression) => void)): void;
|
|
18
|
+
//# sourceMappingURL=walk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../src/ast/walk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,UAAU;IACvB;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,GAAG,KAAK,CAAC;IAE3C;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAAG,CAAC,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC,GAAG,IAAI,CAkFzG"}
|
package/dist/ast/walk.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively walks an Edict expression tree.
|
|
3
|
+
* Guarantees traversal over all child expressions.
|
|
4
|
+
*/
|
|
5
|
+
export function walkExpression(expr, visitor) {
|
|
6
|
+
let enter;
|
|
7
|
+
let leave;
|
|
8
|
+
if (typeof visitor === "function") {
|
|
9
|
+
enter = visitor;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
enter = visitor.enter;
|
|
13
|
+
leave = visitor.leave;
|
|
14
|
+
}
|
|
15
|
+
if (enter && enter(expr) === false) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
switch (expr.kind) {
|
|
19
|
+
case "literal":
|
|
20
|
+
case "ident":
|
|
21
|
+
break;
|
|
22
|
+
case "call":
|
|
23
|
+
walkExpression(expr.fn, visitor);
|
|
24
|
+
for (const arg of expr.args)
|
|
25
|
+
walkExpression(arg, visitor);
|
|
26
|
+
break;
|
|
27
|
+
case "if":
|
|
28
|
+
walkExpression(expr.condition, visitor);
|
|
29
|
+
for (const e of expr.then)
|
|
30
|
+
walkExpression(e, visitor);
|
|
31
|
+
if (expr.else) {
|
|
32
|
+
for (const e of expr.else)
|
|
33
|
+
walkExpression(e, visitor);
|
|
34
|
+
}
|
|
35
|
+
break;
|
|
36
|
+
case "let":
|
|
37
|
+
walkExpression(expr.value, visitor);
|
|
38
|
+
break;
|
|
39
|
+
case "match":
|
|
40
|
+
walkExpression(expr.target, visitor);
|
|
41
|
+
for (const arm of expr.arms) {
|
|
42
|
+
for (const e of arm.body)
|
|
43
|
+
walkExpression(e, visitor);
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
case "block":
|
|
47
|
+
case "lambda":
|
|
48
|
+
for (const e of expr.body)
|
|
49
|
+
walkExpression(e, visitor);
|
|
50
|
+
break;
|
|
51
|
+
case "binop":
|
|
52
|
+
walkExpression(expr.left, visitor);
|
|
53
|
+
walkExpression(expr.right, visitor);
|
|
54
|
+
break;
|
|
55
|
+
case "unop":
|
|
56
|
+
walkExpression(expr.operand, visitor);
|
|
57
|
+
break;
|
|
58
|
+
case "array":
|
|
59
|
+
case "tuple_expr":
|
|
60
|
+
for (const e of expr.elements)
|
|
61
|
+
walkExpression(e, visitor);
|
|
62
|
+
break;
|
|
63
|
+
case "record_expr":
|
|
64
|
+
case "enum_constructor":
|
|
65
|
+
for (const f of expr.fields)
|
|
66
|
+
walkExpression(f.value, visitor);
|
|
67
|
+
break;
|
|
68
|
+
case "access":
|
|
69
|
+
walkExpression(expr.target, visitor);
|
|
70
|
+
break;
|
|
71
|
+
case "string_interp":
|
|
72
|
+
for (const part of expr.parts)
|
|
73
|
+
walkExpression(part, visitor);
|
|
74
|
+
break;
|
|
75
|
+
case "forall":
|
|
76
|
+
case "exists":
|
|
77
|
+
walkExpression(expr.range.from, visitor);
|
|
78
|
+
walkExpression(expr.range.to, visitor);
|
|
79
|
+
walkExpression(expr.body, visitor);
|
|
80
|
+
break;
|
|
81
|
+
case "tool_call":
|
|
82
|
+
for (const f of expr.args)
|
|
83
|
+
walkExpression(f.value, visitor);
|
|
84
|
+
if (expr.fallback)
|
|
85
|
+
walkExpression(expr.fallback, visitor);
|
|
86
|
+
break;
|
|
87
|
+
default:
|
|
88
|
+
// Ensure all kinds are completely covered
|
|
89
|
+
void expr;
|
|
90
|
+
}
|
|
91
|
+
if (leave) {
|
|
92
|
+
leave(expr);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=walk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk.js","sourceRoot":"","sources":["../../src/ast/walk.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAgB,EAAE,OAAkD;IAC/F,IAAI,KAAuD,CAAC;IAC5D,IAAI,KAA+C,CAAC;IAEpD,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QAChC,KAAK,GAAG,OAAO,CAAC;IACpB,CAAC;SAAM,CAAC;QACJ,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QACtB,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC;QACjC,OAAO;IACX,CAAC;IAED,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAChB,KAAK,SAAS,CAAC;QACf,KAAK,OAAO;YACR,MAAM;QACV,KAAK,MAAM;YACP,cAAc,CAAC,IAAI,C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