-
Notifications
You must be signed in to change notification settings - Fork 0
Scripting Supporting Components
To provide a full-featured scripting environment, several other components work in conjunction with the ScriptEngine and CompiledScript.
Ensures the integrity and correctness of scripts before they are compiled or executed.
- Purpose: To validate script source code for syntax, semantic errors, and adherence to any predefined contracts or required interfaces.
-
Key Method:
-
suspend fun validate(scriptSource: String): ValidationResult: Analyzes the script source and returns aValidationResult.
-
-
Supporting Data Classes:
-
data class ValidationResult(val isValid: Boolean, val errors: List<ValidationError> = emptyList()): Indicates if the script is valid and provides a list of errors if not. -
data class ValidationError(val message: String, val line: Int, val column: Int): Details a specific validation error, including its location.
-
Manages different versions of scripts, allowing for history tracking and rollbacks.
- Purpose: To enable robust script lifecycle management by maintaining multiple versions and providing a mechanism to revert to previous states.
-
Key Methods:
-
suspend fun addVersion(scriptName: String, scriptSource: String): Int: Stores a new version of the script source and returns its assigned version number. -
suspend fun getVersion(scriptName: String, version: Int): String?: Retrieves the source code for a specific version of a named script. -
suspend fun getLatestVersion(scriptName: String): Pair<Int, String>?: Fetches the most recent version number and source code for a script. -
suspend fun rollback(scriptName: String, version: Int): Boolean: Intended to facilitate reverting a script to a specified older version (the exact mechanics of how this impacts runningScriptActors would depend on its interaction withScriptEngineandScriptActor.reloadScript()).
-
Handles the persistent storage and retrieval of script source code and associated metadata.
- Purpose: To provide a durable store for scripts, allowing them to be loaded across application sessions or shared in a distributed environment.
-
Key Methods:
-
suspend fun saveScript(scriptName: String, scriptSource: String, metadata: Map<String, Any> = emptyMap()): Persists the script source and any additional metadata. -
suspend fun loadScript(scriptName: String): Pair<String, Map<String, Any>>?: Loads a script's source code and its metadata from storage. -
suspend fun listScripts(): List<String>: Returns a list of names of all scripts available in the storage. -
suspend fun deleteScript(scriptName: String): Boolean: Removes a script from persistent storage.
-
A specialized Actor implementation whose behavior is defined by a dynamically loaded and compiled Kotlin script.
- Purpose: To enable actors with logic that can be updated at runtime (hot-reloading) without restarting the actor or the system.
-
Inheritance: Extends
io.github.solaceharmony.core.actor.Actor. -
Key Features:
-
Constructor: Takes a
ScriptEngine, initialscriptSourcestring, andscriptName. -
Script Execution:
- During initialization (via a custom
initializemethod or itsstartoverride), it compiles itsscriptSourceinto aCompiledScriptusing the providedScriptEngine. - When its input port receives a message, the
processMessagehandler passes the message and a reference to theScriptActorinstance itself (this) as parameters toscriptEngine.execute(compiledScript, parameters). The executed script is expected to use these parameters to perform its logic (e.g., accessactor.getPort(...).send(...)to send results).
- During initialization (via a custom
-
Hot-Reloading (
reloadScript(newScriptSource: String)):- Allows updating the actor's behavior by providing new script source code.
- The method updates the internal
scriptSourceand recompiles it using theScriptEngine, replacing the existingcompiledScript. This change takes effect for subsequent message processing.
-
Port Setup: The
initializemethod (which can be called with input/output port names and types) uses the baseActor.createPort()to set up communication channels. The input port's handler is wired to theScriptActor's internalprocessMessagemethod.
-
Constructor: Takes a
classDiagram
direction LR
package "io.github.solaceharmony.core.actor" {
abstract class Actor { <<Abstract>> }
}
package "io.github.solaceharmony.core.scripting" {
interface ScriptEngine { <<Interface>> }
interface CompiledScript { <<Interface>> }
interface ScriptValidator { <<Interface>> }
class ValidationResult { +isValid: Boolean }
interface ScriptVersionManager { <<Interface>> }
interface ScriptStorage { <<Interface>> }
ScriptEngine ..> CompiledScript : creates
class ScriptActor {
-scriptEngine: ScriptEngine
-scriptSource: String
-scriptName: String
-compiledScript: CompiledScript?
+initialize(inputPortName, inputClass, outputPortName, outputClass)
+reloadScript(newScriptSource: String)
#processMessage(message: Any)
}
Actor <|-- ScriptActor
ScriptActor o-- ScriptEngine : uses
ScriptActor o-- CompiledScript : holds
ScriptValidator ..> ValidationResult : produces
}
note for ScriptActor "Script logic is executed via ScriptEngine,\nscript can access 'actor' instance and 'message'."
The scripting module, with these components, offers a powerful way to introduce dynamic and manageable custom logic into the SolaceCore system, especially for defining actor behaviors.
SolaceCore SSOT wiki · published from wiki/ by .github/workflows/publish-wiki.yml · edit the source in the repo, not the wiki.
Orientation
- Architectural Deep Dive
- Architecture Overview
- Design vs Implementation
- Framework Actor System
- Framework Architectural Vision
- Framework Concurrency and Communication
- Framework Data Storage and Management
- Framework Deployment and Containerization
- Framework Development Roadmap
- Framework Hot-Pluggable System
- Framework Implementation Status
- Framework Observability and Monitoring
- Framework Port System
- Framework System Architecture
- Framework Workflow Management
- Project Status
- Project Status Report
- Quick Status
- Solace Core Framework Architecture
- SolaceCore Architecture Overview
- Vision & Solace AI
Runtime
- Actor Builder
- Actor Communication Sequence Diagram
- Actor Core Definitions
- Actor Graph View
- Actor Metrics
- Actor Module Architecture
- Actor Queue Hibernation and Correlation
- Actor Roadmap
- Actor State Recovery Subsystem
- Actor State Serialization Subsystem
- Actor Supervision Module
- Actor System Architecture
- Actor System Class Diagram
- Actor Usage Examples
- Compose App Features
- JVM Scripting Implementations
- Kernel & Ports
- Kernel Channel System
- Kernel Future Enhancements
- Kernel Module Architecture
- Kernel Port Implementations and Exceptions
- Kernel Port Usage Example
- Kernel Testing Strategy
- Lifecycle Class Diagram
- Lifecycle Management Architecture
- Pipeline DSL
- Real-Time UI Implementation
- Scripting Module Architecture
- Scripting Module Design
- Scripting Supporting Components
- Shared Memory
- Storage & Persistence
- Storage Abstractions Architecture
- Storage Caching Subsystem
- Storage Checklist
- Storage Compression Subsystem
- Storage Core Interfaces
- Storage Encryption Subsystem
- Storage File-Based Architecture
- Storage File-Based Implementations
- Storage In-Memory Architecture
- Storage In-Memory Implementations
- Storage JVM Serialization Utilities
- Storage Module Architecture
- Storage Serialization Compression Encryption
- Storage Specialized Interfaces Architecture
- Storage Status and Future Plans
- Storage Testing
- Storage Thread Safety Guide
- Storage Thread Safety and Deadlock Prevention
- Storage Transactions
- Storage Usage Examples
- Supervisor and Hot Swap
- SupervisorActor
- System Architecture Diagram
- Workflow Management Architecture
- Workflow Management Design Concept
- Workflow Orchestration
Solace AI
- Confusion Corrector
- Inference Cube
- Inference Cube Technical Architecture
- Long-Term Memory
- MCP and Tool Format
- Memory & Reflection
- Memory Compression
- Memory Feature Overview
- Memory Retrieval
- Mood & Emotional Model
- Mood Module Implementation
- Mouth Tool Technical Spec
- Multimodal Nudging
- Perception Actors
- Provider Specs
- Reflection Memory
- Solace AI Overview
- Supervisor AI
- Supervisor Emotional Model Integration
- Time Actor
- Voice & Mouth Tool
- Working Memory
- Zoom Level Technical Spec
- Zoom Levels
Reference
- Advanced Workflow Example
- Basic Actor Usage
- Build System and Dependencies
- Development Tooling and Practices
- Documentation Catalog
- Documentation Index
- Feature Index
- Glossary
- How the Wiki Publishes
- JVM Utilities
- Kotlin Implementation Details
- Kotlin-Aligned Architecture Overview
- Kotlin-Aligned Contributing
- Kotlin-Aligned Core Architectural Principles
- Kotlin-Aligned Daily Development Workflow
- Kotlin-Aligned Development Examples
- Kotlin-Aligned Development Workflow
- Kotlin-Aligned Documentation
- Kotlin-Aligned Implementation Status
- Kotlin-Aligned Key Concepts
- Kotlin-Aligned Known Issues
- Kotlin-Aligned Quick Start
- Kotlin-Aligned Running the System
- Kotlin-Aligned System Architecture
- LangChain Actor Code Changes
- LangChain Actor Usage Improvements
- LangChain ActorInterface Code Changes
- LangChain Best Practices
- LangChain Bugs
- LangChain Chain Implementation
- LangChain Code Changes
- LangChain Code Changes Rollout and Impact
- LangChain Configuration Management Improvements
- LangChain Configuration Recommendations
- LangChain Core Architecture Recommendations
- LangChain Directory Structure Changes
- LangChain Documentation Improvements
- LangChain Dynamic Wiring Rollout Notes
- LangChain Fix Proposal
- LangChain Implementation Priorities
- LangChain Lifecycle Management Improvements
- LangChain Memory Integration Recommendations
- LangChain Metrics and Observability Recommendations
- LangChain Migration Strategy
- LangChain New Files Needed
- LangChain New Packages to Add
- LangChain Package-by-Package Improvements
- LangChain Patterns
- LangChain Port Code Changes
- LangChain Port System Recommendations
- LangChain Port Usability Improvements
- LangChain Prompt Management Recommendations
- LangChain Recommendations
- LangChain Recommendations Rollout Plan
- LangChain Required Interface Changes
- LangChain Testing Changes
- LangChain Testing Improvements
- LangChain Testing Recommendations
- LangChain Tool Integration Recommendations
- LangChain Type-Safe Dynamic Wiring
- LangChain Type-Safe Dynamic Wiring System
- LangChain Usage Design Improvements
- Master Checklist
- Roadmap
- Roadmap Issues
- Roadmap Phase 1 Stability and Testing
- Roadmap Phase 2 Production Infrastructure
- Roadmap Phase 3 Documentation and Developer Experience
- Roadmap Phase 4 Graph Database Integration
- Roadmap Phase 5 Security Framework
- Roadmap Phase 6 Distributed System
- Roadmap Phase 7 Advanced Features
- Roadmap Phase 8 Ecosystem Development
- Roadmap Timeline and Success Metrics
- Setup Instructions
- Sketch Architecture
- Status Documentation
- Task 1 Core Tests
- Task 2 Connection Wiring
- Task 3 Concurrency Issues
- Task 4 Dynamic Registration
- Task 5 Integration Tests
- Task 6 Deadlock Detection
- Task Documentation
- Test Coverage Checklist
- Testing Strategy