maple.state.store
State management for the MAPLE daemon.
This module provides persistent state tracking using SQLite for the MAPLE daemon. It manages policies, environments, containers, and evaluation runs with a robust database-backed storage system.
Key features: - SQLite-based persistent storage with WAL mode for concurrency - Policy and environment registry tracking - Container lifecycle management (both policies and environments) - Evaluation run history and statistics - Automatic database initialization and schema management - Context manager for safe database operations
The database schema includes: - policies: Downloaded/pulled policy models - envs: Downloaded environment images - containers: Currently running containers (policies and envs) - runs: Evaluation run history with metrics and outcomes
All database operations use proper transaction handling and support concurrent access through SQLite’s WAL (Write-Ahead Logging) mode.
Functions
|
Register a running container. |
|
Add or update a pulled environment. |
|
Add or update a pulled policy. |
|
Start tracking a run. |
Clear all container records. |
|
|
Record run completion. |
|
Get a container by ID. |
|
Get a container by name. |
|
Get a pulled environment. |
|
Get a pulled policy. |
|
Get a run by ID. |
|
Get aggregate statistics for runs. |
|
Initialize database schema. |
|
List containers with optional filters. |
List all pulled environments. |
|
List all pulled policies. |
|
|
List runs with optional filters. |
Legacy function for backwards compatibility. |
|
|
Remove a container from tracking. |
|
Remove a pulled environment. |
|
Remove a pulled policy. |
|
Update container status. |