#200 Apps: Implement app executor and loader
Description
Edit## Parent Epic: #195
## Description
Create the AppExecutor class that loads and executes apps.
## Location
engine/apps/executor.py, engine/apps/loader.py
## AppLoader Class
### Responsibilities
- Load app class from different entrypoint types
- Cache loaded apps (LRU with TTL)
- Validate app structure
### Entrypoint Types
1. python_module
- Load from installed Python module
- Config: {'module': 'path.to.module', 'class': 'ClassName'}
2. python_code
- Load from database-stored code
- Config: {'code_hash': 'sha256:...', 'class_name': 'MyApp'}
- Security: Restricted execution environment
3. webhook
- HTTP webhook for external apps
- Config: {'url': '...', 'auth_type': 'bearer', 'auth_secret': '...'}
### Security
- Sandbox for python_code (no os, eval, exec, etc.)
- Timeout for loading
- Memory limits
## AppExecutor Class
### Constructor
- pool: ConnectionPool
- app_cache: LRUCache(maxsize=100, ttl=300)
### execute() Method
1. Load app definition (cached)
2. Verify tenant has app installed
3. Check app status == 'enabled'
4. Load tenant configuration
5. Load secrets from Vault
6. Create AppMetadata
7. Create AppContext wrapper
8. Execute action
9. Log execution to app_execution_log
10. Return result
### Error Handling
- AppNotInstalledError
- AppDisabledError
- ActionNotFoundError
- AppExecutionError
- SecretNotFoundError
### Integration Points
- Called by tool registry wrapper
- Uses absurd_client for checkpoints
## Testing
- Test each entrypoint type
- Test caching behavior
- Test error scenarios
- Test execution logging
Comments
Loading comments...
Context
Loading context...
Audit History
View AllLoading audit history...