feat: Rename DSL types and add additional safeguards#302
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the pharmsol DSL pipeline and runtime integration to reflect renamed DSL/compiler concepts (e.g., “kernel” → “function”, “lowering” → “compile”) and adds frontend hardening so pathological inputs fail with clear diagnostics instead of panicking or exhausting the stack.
Changes:
- Renames DSL/execution concepts across native/JIT/WASM/AoT paths (analyzed → compiled execution model, kernels → functions, ABI/layout naming updates).
- Centralizes numeric label resolution via
ValidatedModelMetadata::{route_for_label,output_for_label}and updates equation/runtime callers accordingly. - Adds DSL frontend safeguards and UX improvements: nesting-depth limits, number-literal infinity rejection, capped compile-time sizes, unified one-shot
compile_model/compile_moduleAPI, and improved diagnostic rendering.
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/support/runtime_corpus.rs | Updates test compilation pipeline to analyzed→compiled terminology. |
| tests/authoring_parity_corpus.rs | Migrates parity tests to new compile API and layout naming. |
| src/simulator/equation/ode/mod.rs | Renames test helper functions for clarity (kernel→function naming). |
| src/simulator/equation/mod.rs | Switches label resolution to metadata helpers and removes duplicate alias logic. |
| src/simulator/equation/metadata.rs | Adds route_for_label / output_for_label with numeric-alias-only fallback and tests. |
| src/lib.rs | Updates crate docs to reflect “compilation” terminology. |
| src/dsl/wasm.rs | Renames WASM runtime concepts to functions and updates metadata consistency checks. |
| src/dsl/wasm_direct_emitter.rs | Updates direct emitter to new execution/function IR types and math op naming. |
| src/dsl/wasm_compile.rs | Updates WASM compilation pipeline, metadata envelope fields, and browser loader generator. |
| src/dsl/rust_backend.rs | Updates Rust backend emitter to functions and renamed ops/intrinsics. |
| src/dsl/runtime.rs | Updates DSL runtime compilation pipeline to analyzed→compiled and error type renames. |
| src/dsl/native.rs | Renames native runtime ABI concepts (KernelSession→FunctionSession, etc.) and label resolution plumbing. |
| src/dsl/model_info.rs | Updates model info extraction for layout and function IR changes. |
| src/dsl/mod.rs | Updates DSL facade docs and re-exports for renamed pipeline/types. |
| src/dsl/jit.rs | Migrates JIT compiler to function IR and improves diagnostic display formatting. |
| src/dsl/compiled_backend_abi.rs | Renames compiled metadata availability to “functions” and updates symbol mapping. |
| src/dsl/aot.rs | Migrates AoT compile/load pipeline and symbols to functions + analysis/compile error types. |
| pharmsol-macros/src/lib.rs | Renames analytical kernel spec plumbing to function terminology and updates docs. |
| pharmsol-dsl/tests/frontend_hardening.rs | Adds extensive hardening tests for parsing/analyzing/compiling and error UX. |
| pharmsol-dsl/tests/dsl_authoring_edge_cases.rs | Updates edge-case tests to compile terminology and APIs. |
| pharmsol-dsl/src/syntax.rs | Adds module-level documentation for syntax tree types. |
| pharmsol-dsl/src/pipeline.rs | Introduces one-shot compile pipeline and unified DslError. |
| pharmsol-dsl/src/parser.rs | Adds recursion-depth guardrails and fatal-abort handling to prevent cascades/stack exhaustion. |
| pharmsol-dsl/src/lib.rs | Reframes crate as a source-to-execution compiler; updates exports/docs accordingly. |
| pharmsol-dsl/src/lexer.rs | Rejects number literals that overflow to infinity with a clear error/help message. |
| pharmsol-dsl/src/diagnostic.rs | Renames phases/codes and improves rendering (avoid repeating same-line source excerpts). |
| pharmsol-dsl/src/authoring.rs | Updates authoring parsing, route detection, and structure/function guidance. |
| pharmsol-dsl/src/analysis.rs | Renames typed→analyzed structures, refines const conversions, and improves analytical input errors. |
| pharmsol-dsl/README.md | Updates README for new pipeline terminology and APIs. |
| pharmsol-dsl/Cargo.toml | Adds thiserror dependency for unified error types. |
| pharmsol-dsl/browser-compile-bridge/src/lib.rs | Updates JSON metadata shape from kernels to functions. |
| Cargo.toml | Moves thiserror to workspace dependency for shared use. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
437
to
440
| if let Some(name_segment) = lhs_trimmed.strip_prefix("const ") { | ||
| let name_abs = span.start + (lhs.find("const").unwrap() + "const ".len()); | ||
| let name_abs = span.start + (lhs.len() - lhs_trimmed.len()) + "const ".len(); | ||
| let name = parse_ident_segment(name_segment, name_abs)?; | ||
| let value = parse_expr_at(rhs, rhs_abs)?; |
| if (Boolean(available) !== Object.prototype.hasOwnProperty.call(kernels, name)) {{ | ||
| for (const [name, available] of Object.entries(infoEnvelope.functions)) {{ | ||
| if (Boolean(available) !== Object.prototype.hasOwnProperty.call(functions, name)) {{ | ||
| throw new Error(`Kernel metadata mismatch for ${{name}}`); |
Comment on lines
+1401
to
+1402
| let error = | ||
| compile_analyzed_model(&analyzed).expect_err("infusion lag should fail during lowering"); |
Contributor
|
| Project | pharmsol |
| Branch | kimi-dsl-rename |
| Testbed | mhovd-pgx |
🐰 View full continuous benchmarking report in Bencher
⚠️ WARNING: Truncated view!The full continuous benchmarking report exceeds the maximum length allowed on this platform.
Siel
approved these changes
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.