Conversation
New files:
- compiler/src/config.rs - Configuration types for compiler extensibility
Key types:
// Define external builtins
let builtin = ExternalBuiltin::new("journal-append", "seq_actors_journal_append");
// Configure the compiler
let config = CompilerConfig::new()
.with_builtin(builtin)
.with_library_path("/path/to/actor/lib")
.with_library("seq_actors");
// Compile with config
compile_file_with_config(source, output, false, &config)?;
What it enables:
1. External builtins - seq-actors can define journal-append, actor-send, etc. that Seq code can call
2. Custom linking - seq-actors can link its own runtime library alongside seq-runtime
3. Clean separation - patch-seq has no actor knowledge; seq-actors owns actor semantics entirely
API surface:
- ExternalBuiltin::new(seq_name, symbol) - Define an external function
- CompilerConfig::new().with_builtin(...) - Builder pattern
- compile_file_with_config() / compile_to_ir_with_config() - Config-aware compilation
Tests added:
- External builtin declaration in IR
- External builtin calls in generated code
- Multiple external builtins
- Library path configuration
The seq-actors project can now embed patch-seq and extend it without modifying the core.
Pull Request Review: Compiler ExtensionSummaryThis PR adds extensibility to the Seq compiler by introducing a ✅ StrengthsArchitecture & Design
Code Quality
Test CoverageExcellent test coverage with 4 new tests:
🔍 Issues & Recommendations1. Missing TypeChecker Integration
|
Issue #1: Missing TypeChecker Integration ✅ Fixed Added registration of external builtins with the TypeChecker in both: - compile_file_with_config() (lib.rs:98-106) - compile_to_ir_with_config() (lib.rs:185-193) New tests added: - test_external_builtin_full_pipeline - Verifies the complete pipeline works (parser → AST validation → TypeChecker → codegen) - test_external_builtin_without_config_fails - Verifies unknown builtins are properly rejected All 7 external builtin tests pass. The other suggestions from the review are documentation/style improvements that could be addressed separately if desired.
Pull Request Review: Compiler ExtensionSummaryThis PR adds a compiler configuration system that enables external projects to extend the Seq compiler with custom builtins without modifying core compiler code. This is a well-designed extensibility feature that maintains clean separation of concerns. Code Quality ✅Excellent design patterns:
Code organization:
Potential Issues and Recommendations1. Missing validation in validate_word_calls_with_externals (
|
…views: From Review #1: - ✅ TypeChecker integration - Added registration of external builtins with TypeChecker in both compile functions From Review #2: - ✅ Symbol validation - Added validate_symbol() to prevent LLVM IR injection - Validates symbols contain only alphanumeric, underscores, periods - Panics with clear message on invalid symbols - 4 new tests for validation (valid symbols, rejects hyphen, rejects @, rejects empty) Test count: - 11 external builtin related tests now pass - Full test suite passes - hello-world sanity check passes Ready to merge.
Pull Request Review: Compiler ExtensionThis PR adds a well-designed compiler configuration system that allows external projects to extend the Seq compiler with additional builtins. The implementation is thoughtful and follows good practices. Here's my detailed review: ✅ Strengths1. Clean API DesignThe CompilerConfig::new()
.with_builtin(ExternalBuiltin::new("my-op", "runtime_my_op"))
.with_library_path("/custom/lib")2. Security - Symbol ValidationThe 3. Comprehensive TestingThe PR includes 7 new tests covering:
4. Backward CompatibilityThe changes maintain full backward compatibility by:
5. Consistent IntegrationThe external builtins are properly integrated across all compilation stages:
🔍 Code Quality ObservationsDocumentationExcellent: The new Suggestion: Consider adding a doc comment to Error HandlingThe implementation properly propagates errors throughout the pipeline. The Type SafetyThe integration with the type checker allows external builtins to optionally specify their stack effects. This maintains the language's static typing guarantees while providing flexibility for builtins with complex/unknown effects.
|
- ✅ TypeChecker integration - ✅ Symbol validation (security) - ✅ Type safety documentation - ✅ Full pipeline tests Ready to merge when you are.
PR Review: Compiler ExtensionSummaryThis PR adds extensibility to the Seq compiler, allowing external projects to register custom builtins without modifying the core compiler. This is a well-designed feature that enables runtime extensions (like actor systems) to integrate cleanly. ✅ Strengths1. Excellent Architecture
2. Security First
3. Documentation
4. Test Coverage
🔍 Issues & RecommendationsCritical IssuesNone identified - This is production-ready code. Medium Priority1. Error Handling: Panics vs Results (config.rs:97-105, 117-119)The pub fn new(seq_name: impl Into<String>, symbol: impl Into<String>) -> Self {
let symbol = symbol.into();
Self::validate_symbol(&symbol).expect("Invalid symbol name"); // Panics!
// ...
}Recommendation: Consider providing fallible constructors for library use: pub fn try_new(seq_name: impl Into<String>, symbol: impl Into<String>)
-> Result<Self, String> {
let symbol = symbol.into();
Self::validate_symbol(&symbol)?;
Ok(ExternalBuiltin { /* ... */ })
}
// Keep the panicking version for ergonomics
pub fn new(seq_name: impl Into<String>, symbol: impl Into<String>) -> Self {
Self::try_new(seq_name, symbol).expect("Invalid symbol name")
}This allows library consumers to handle validation errors gracefully when dealing with untrusted input. 2. Documentation: Runtime Behavior (config.rs:59-67)The documentation warns about using Recommendation: Add documentation about runtime crash behavior: /// **Warning**: Using `None` can hide type errors until runtime.
/// If the actual runtime function expects a different stack layout,
/// the program will crash or produce undefined behavior.
/// Prefer providing an explicit effect when the signature is known.
Low Priority3. Performance: Repeated External Builtin Checks (codegen.rs:844-848)In if let Some(symbol) = self.external_builtins.get(name) {
symbol.clone()
} else {
format!("seq_{}", mangle_name(name))
}Analysis: This is called during codegen, which happens once per compilation. The performance impact is negligible. No action needed, but worth noting for future optimization if compilation speed becomes a bottleneck. 4. Symbol Validation: Unicode Considerations (config.rs:79-80)The validation uses if !c.is_alphanumeric() && c != '_' && c != '.' {Question: Does LLVM support Unicode identifiers? If not, consider restricting to ASCII: if !c.is_ascii_alphanumeric() && c != '_' && c != '.' {This is a minor point - current behavior is likely fine, but worth validating against LLVM specs. 5. API Consistency (config.rs:173-179)The config.external_builtins.iter().map(|b| &b.seq_name) // Direct access
config.external_names() // Helper methodRecommendation: This is fine as-is for convenience, but consider making 🚀 Performance Considerations
🔒 Security Analysis✅ Strong Security Properties
Potential ConcernsNone - the validation is thorough and happens at the right layer. 🧪 Test Coverage AssessmentWell Covered
Could Add (Optional)
Current coverage is excellent for an initial implementation. 📝 Code QualityRust Best Practices ✅
Documentation ✅
Final VerdictLGTM with minor suggestions This is high-quality code that follows Rust best practices and adds valuable functionality to the compiler. The security considerations are well-handled, and the test coverage is comprehensive. The only actionable suggestion is providing fallible constructors ( Recommended Action: Merge after considering the Great work! 🎉 |
No description provided.