Initial Implementation Product Requirements Doc #5
markurtz
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Rustarium Initial Product Requirements Document
Executive Summary
Problem Statement
Executing untrusted agentic code, benchmarking LLM frameworks, and distributing High-Performance Computing (HPC) workloads typically requires managing disparate, heavy-weight solutions such as custom system daemons, complex cluster managers, or nested container environments. Developers and researchers lack a unified, lightweight framework that delivers strict execution isolation, minimal startup latency, and seamless integration into standard Python workflows without imposing significant infrastructure overhead.
Product Value Proposition
Rustarium is a high-performance, telemetrized process orchestrator and sandbox designed primarily for Python, and architected to seamlessly extend to WebAssembly (WASM) and other runtimes in the future. It provides a simple, zero-friction framework—accessible via a standard
pip install—for submitting arbitrary computational tasks and mapping them to secure, ephemeral sandboxes or networked cluster nodes. By leveraging Rust's native performance, standardized interfaces for compute execution, deep telemetry, and direct OS/Kernel primitives, Rustarium offers a transparent, auditable, and highly reliable platform for process orchestration and distributed workload management.Strategic Alignment
Rustarium targets the rapidly converging needs of Agentic workflows, HPC workloads, and evaluation/benchmarking scenarios. By enforcing a dichotomous security profile (strict isolation vs. trusted, high performance) and a robust local-first leader/follower orchestration model, the platform aligns with the strategic vision of delivering an elite, intuitive developer experience. This positions Rustarium as a foundational orchestration layer focused entirely on high-performance, sandboxed local execution for the MVP.
User Stories
pip install.Requirements
Functional Requirements
The functional requirements are organized around the core pillars of the Rustarium platform, ensuring a robust, scalable, and secure orchestration experience for developers and system administrators.
1. Developer Interfaces (API & CLI)
The platform must expose intuitive interfaces that abstract away the complexity of distributed process orchestration. The ultimate goal is an elite developer experience: a simple
pip installthat immediately unlocks performant, Docker/VM-level process orchestration.pip installablepackage containing the Rust orchestration engine. It must provide deep integration within existing Python codebases with zero-friction installation.rustarium doctororrustarium setuputility to gracefully diagnose and guide users through system-level environmental requirements (e.g., cgroups v2 permissions, Docker socket access) during FTUX.2. Workload & Process Orchestration
Rustarium must orchestrate process lifecycles and workload scheduling efficiently, utilizing native Rust performance while exposing high-level Python abstractions.
venv,conda) inside the Tier 1 sandbox.SIGKILLwhen ceilings are breached.3. Inter-Process Communication (IPC)
The platform must seamlessly handle data transfer between the orchestrator and worker processes with minimal serialization overhead.
async/awaitsyntax for all communication interfaces.4. Security, Isolation & Sandboxing
Workers must run in secure, isolated environments to prevent accidental or malicious state changes from escaping to the host system.
SECURE_ISOLATEDprofile (Agentic workflows) offering fully restricted IPC and locked-down host access to prevent sandbox escapes. TheHIGH_PERFORMANCE_TRUSTEDprofile (zero-copy memory mapping) is deferred to Phase 2.OverlayFS. Instead, implement a lightweight user-space emulated sandbox filesystem. The engine exposes external host file locations as read-only streams. Any file modification, creation, or deletion performed by the worker process is transparently intercepted and routed to an isolated, temporary scratchpad directory. Changes remain isolated and are never written back to the host system until an explicit caller-initiated commit trigger is executed.5. Observability (Telemetry, Metrics & Tracing)
Rustarium must provide deep, standardized visibility into both system health and workload performance, integrating seamlessly with modern observability stacks.
JobConfigschema includes amask_patterns: list[str]parameter. The Rust daemon intercepts stdout/stderr streams and applies these string/regex masking rules on-the-fly before the logs are pushed into the host process's logging framework.6. Container Runtime Integrations
To support complex and diverse environments, the framework must interface smoothly with standard container runtimes.
.sockendpoints) for Linux and macOS environments. Windows platform abstraction (Named Pipes) is deferred to Phase 2.7. Reliability, Fault Tolerance & Configuration Management
The platform must be resilient to failures and easily configurable across diverse deployments.
Non-Functional Requirements (NFRs)
To guarantee Rustarium meets the needs of High-Performance Computing (HPC) and fast agentic workflows, the system must adhere to strict performance and resource constraints:
< 10msfor Tier 1 (Rootless) operations on Linux and macOS. When initializing Tier 3 (Delegated Docker containers), the overhead must not exceed< 50msbeyond the baseline performance of the underlying host container system. All worker processes will launch cleanly on-demand to guarantee an untainted state machine; persistent pre-warmed process pools are explicitly out-of-scope for safety.1,000+concurrent worker processes without degradation in telemetry collection or scheduling loops.< 50MB, and baseline CPU utilization (when idle) should be< 1%.Technical Specs
APIs & SDK Interfaces
The Python SDK serves as the primary entry point for developers. It leverages PyO3 to wrap the underlying Rust/Tokio orchestration engine, prioritizing a streamlined, high-performance developer experience.
1. Core Client Design (
RustariumClient&AsyncRustariumClient)The client manages the local orchestrator and the pool of worker processes.
AsyncRustariumClient: The.submit()method returns a native asynchronous generator (AsyncIterable).RustariumClient: Exposes a fully synchronous API. To minimize code duplication, the synchronous client internally wraps, drives, and blocks on the core async execution pathway.RustariumClient.submit(), the SDK must offload iteration to a separate background worker thread (e.g.,loop.run_in_executor()) to prevent blocking Python I/O from disrupting the orchestration loop.2. Job Submission & Workload Context
Workloads are submitted via a typed interface that gracefully bridges Python and Rust concurrency models, emphasizing contextual defaults and specific overrides.
client.submit(workloads: Iterable[Any], default_config: JobConfig | None = None)Workloadobjects.default_configsettings for execution (or fail if no default was provided).3. Standardized Update Flow & Result Streaming
The client does not return distinct streams for logs or metrics. Instead, it returns a unified iterable (asynchronous in
AsyncRustariumClient) that yields comprehensive updates.async for update in client.submit(...):updateobject contains:job_context: Overall job-level metadata and aggregated metrics.rustarium_context: System-level orchestration health and state.workload_status: Status transitions for the specific workload (e.g., executing, completed, failed).result: The actual execution output (if completed).metrics: Telemetry, latency, and resource statistics specifically tied to that workload's execution.loguru/standard logging). Logs are automatically routed to the main process's configured handlers.4. Job Constraints & Custom Logic
Job constraints are treated as first-class citizens, controlling precisely when a job should naturally complete or forcibly terminate.
max_errors,max_error_rate,max_workloads, andmax_execution_time. By default, a job runs until the provided iterable is exhausted.5. Error Topology
Native Rust panics and underlying orchestration errors are caught and surfaced to Python via a typed exception hierarchy, grouped logically for the caller to handle easily.
RustariumError(Base Class)ConfigurationError: Invalid constraints, unparseable objects, or bad environment state.OrchestrationError: General engine failures, communication timeouts, or scheduling issues.WorkerError: Process crashes, user-code exceptions, or application-level panics.SecurityError: Isolation violations such as attempting aSandboxEscape, or breaching memory/resource ceilings.Workload & Configuration Definitions
To ensure a clean boundary between the Python SDK and the Rust orchestration engine, all configuration rules must be clearly defined. The system must support general object passthrough while allowing users to apply specific configuration parameters.
Pydantic v2on the Python layer to handle configuration validation, applying sensible defaults and managing object instantiation.serdewithbincode) mapping to its internal types without needing to strictly constrain the arbitrary payload data.1. JobConfig Schema
The
JobConfigacts as the overarching policy for a submitted batch of workloads. It defines the environment, resources, and rules for the execution.min_workers,max_workersallow_process_reuse: Boolean flag (default:False). If set toTrue, the orchestrator uses the Execution Match-Key to safely cache and reuse idle workers. IfFalse, workers are forcibly destroyed and spawned on a per-submission basis for maximum safety.venv/conda), and verifying that specific dependencies are installed and available to the process before execution.env_vars: Allow/deny lists for environment variables.mask_patterns: Alist[str]of sensitive strings or regex patterns that must be scrubbed from standard output before entering host logging pipelines.filesystem_access: A boolean toggle (if true, the sandbox inherits the runner's access; if false, it only has access to its local sandbox). Alternatively, an explicit list of allowed/disallowed paths, globs, or regexes specifying read, write, or execute permissions.network_access: A boolean toggle for overall network availability. Must also support explicit lists of IP addresses, namespaces, domains, path-level addresses, globs, or regexes to strictly control ingress and egress routing.SecurityProfile.SECURE_ISOLATED: Strict lockdown, disables shared memory (shm), severs network access by default, and enforces strict filesystem scoping.SecurityProfile.HIGH_PERFORMANCE_TRUSTED: (Phase 2) Relaxed isolation allowing zero-copy memory mapping for massive tensor transfers.2. Workload Object Schema
A
Workloadrepresents a single unit of execution. The system supports general passthrough where arbitrary Python objects (without any constraints on their type or implementation) can be submitted.3. Scheduling Strategy Payloads
Concrete sub-configurations are required depending on the chosen distribution model:
target_workloads(int) - The active number of workloads that are supposed to be running and submitted at any one point in time (not strictly the number of processes) (able to run down to 1 for synchronous execution).tasks_per_second(float) - Ensures an even distribution of tasks over time.arrival_rate_lambda(float) - The average rate of incoming tasks to simulate natural, randomized traffic.4. Constraints & Hard Limits (The Poison Pill)
To protect the host system from runaway code, strict limits must be enforceable per workload.
cpu_time_limit_ms: Maximum CPU time allowed.wall_time_limit_ms: Maximum real-world elapsed time.max_memory_bytes: Peak memory ceiling.max_errors/max_error_rate: Job-level constraints that halt execution if too many workloads fail.ViolationPolicy.GRACEFUL: Issues aSIGTERMand waits for a predefined grace period before killing.ViolationPolicy.SIGKILL: The "Poison Pill" — immediate, uncatchable process termination.Logging, Telemetry & Performance
To guarantee observability and maintain maximum execution speed, Rustarium's telemetry and logging subsystems are designed around a high-performance "push-to-main" architecture. Data sanitization and masking are explicitly out-of-scope for the orchestrator, delegating these responsibilities to external log collectors or aggregators.
1. Centralized Application Logging
Worker processes are automatically injected with a unified logging setup upon startup.
logging,loguru). This ensures proper formatting for OpenTelemetry and allows developers to leverage existing ecosystem tooling.2. System & Application Metrics
Standard system health and application execution metrics follow the same unified pipeline as application logs.
3. Custom Performance & User Statistics
To support massively data-intensive benchmarking and evaluation frameworks (like GuideLLM), the platform provides an entirely separate, highly flexible interface dedicated specifically to generic timing and value collection.
Sandboxing & Capability Matrix
The Sandboxing & Capability Matrix defines how Rustarium enforces security boundaries and resource limits across different operating systems. It maps high-level job configuration settings (e.g.,
network_access,filesystem_access,SecurityProfile) to the specific, underlying native kernel primitives available on the host platform.1. Cross-Platform Primitives Matrix (MVP)
The orchestrator utilizes a multi-tiered approach, automatically selecting the appropriate primitives based on the host OS and the requested Isolation Tier:
pivot_rootseccomp-bpf2. Tier 1 Sandboxing Architecture & Memory Isolation
Tier 1 is the default execution mode, designed to provide the highest level of isolation possible without requiring root access or external daemon installations (like Docker).
3. Capability Mapping to Security Profiles
The user's declared
SecurityProfiledetermines which kernel primitives are engaged during worker instantiation:SECURE_ISOLATED(Agentic Profile)pivot_root/chroot(Linux) to jail the process. Access is strictly limited to an ephemeral tmpfs and explicitly configured volume mounts./dev/shm) access. Cross-process data transfer relies entirely on serialized payloads over UDS.HIGH_PERFORMANCE_TRUSTED(HPC Profile) [Phase 2]Lifecycle State Machines
The orchestration engine relies on strict, deterministic state machines to govern both individual worker processes and the overarching job submissions. This ensures predictable resource scaling, precise telemetry tracking, and robust failure recovery.
1. Worker State Machine
The Worker State Machine manages the lifecycle of an individual isolated process. Workers are launched purely on-demand to guarantee state purity. Idle workers may only be reused if their footprint matches the deterministic Execution Match-Key (a hash of
python_env_path,requirements,code_source, andJobConfig) andallow_process_reuseis set toTrue.Valid States:
Pending: The worker has been requested by the scheduler, but the host OS primitives (namespaces, cgroups, or Docker socket) are still initializing.Ready: The worker is fully initialized, connected via UDS to the Leader, and awaiting a workload payload.Executing: The worker has received a workload and is actively processing the user-defined logic. Telemetry and logs are actively streaming.Throttled: A temporary state triggered by resource ceiling proximity. The worker pauses workload ingestion or CPU cycles until limits normalize.Terminated: The worker has been cleanly shut down (either by natural job completion, failure to match new execution keys, or explicit termination viaSIGTERM).Failed: The worker exited unexpectedly, breached a hard isolation limit (Sandbox Escape attempt), or was killed by the Poison Pill (SIGKILL) due to exceeding limits.Transition Rules:
Pending->Ready: Normal startup sequence.Ready->Executing: Workload is assigned and dispatched via IPC.Executing->Ready: Workload completes successfully, andallow_process_reuseis True.Executing<->Throttled: Triggered by internal orchestration metrics to prevent host starvation.Executing->Failed: Worker crashes, times out (wall_time_limit_msbreached), or violates security constraints.Failed->Pending: If the orchestrator's automatic recovery policy permits restarting the worker.Any State->Terminated: The orchestrator initiates a teardown sequence (or process reuse is disabled).2. Job State Machine
The Job State Machine governs the collective execution of the batch of workloads submitted by the user. It aggregates the states of its associated workers to provide a high-level status to the Python SDK.
Valid States:
Submitted: The Python SDK has validated the payload and dispatched the configuration to the Rust daemon, but scheduling has not yet begun.Running: The job is actively processing workloads. At least one worker is in theExecutingstate, and the source iterable is not yet exhausted.Draining: The source iterable has been completely consumed. The orchestrator is waiting for the final active workers to transition fromExecutingtoReadyorFailed.Completed: All workloads have been processed. This state is reached even if some workloads failed, provided the total failures remain strictly under the configuredmax_errorsormax_error_ratelimits defined in theJobConfig.Aborted: The job was forcibly halted. This occurs if a user explicitly cancels the job, if themax_errorsthreshold is breached, or if the Leader node experiences a critical failure.Transition Rules & Partial Failure Policies:
Submitted->Running: The scheduler begins assigning workloads toReadyworkers.Running->Draining: The end of the workload iterable is reached.Draining->Completed: All active workers finish processing. The system aggregates final telemetry.Running/Draining->Aborted: A workload failure causes the total error count to breach themax_errorsceiling. The orchestrator immediately broadcasts a termination signal to all remaining workers processing this job.Any State->Aborted: User-initiated cancellation via the SDK.Testing
Test Scopes & Levels
test:unit): Isolated function-level validation.cargo testfor Rust internals (e.g., cgroup parser, namespace instantiation) andpytest tests/unitfor Python SDK components (e.g., configuration validation, workload serialization).test:integration): Component boundary validation. Ensures the PythonRustariumClientcan successfully initiate the Rust daemon, establish the IPC channel (UDS), and pass basic payloads back and forth.test:e2e): Full lifecycle validation. Simulates real-world workloads from job submission to final telemetry collection, involving actual process forking, isolation enforcement, and workload execution.smoke: Quick tests to check basic functionality.sanity: Detailed tests to ensure major functions work correctly.regression: Tests to ensure that new changes do not break existing functionality.smoke,sanity) and Integration (smoke) to provide fast feedback during active development.smoke,sanity), Integration (smoke,sanity), and E2E (smoke) to validate core behaviors upon merging.smoke,sanity,regression), Integration (smoke,sanity), and E2E (smoke,sanity) across the full span of supported Python versions.Unit,Integration,E2E) across all markers (smoke,sanity,regression) to guarantee immutable build stability prior to tagging.cargo testfor cgroup parsing and UDS throughput) from Python-level integration tests (pytestfor SDK ergonomics and asynchronous generators).Functional & Compatibility Testing
Workloadwrappers survive the round-trip from Leader to Follower unchanged.max_execution_timecleanly triggersViolationPolicy.GRACEFULand subsequentSIGTERM, while memory limit breaches trigger the Poison Pill (SIGKILL).pivot_rootappropriately restricts file reads..sockendpoints) across standard and Tier 3 Docker environments.Performance & Scalability Validation
noopworkloads per second across 100 worker processes without inducing lag in the unified update stream.<10ms(Tier 1) and<50ms(Tier 3) limits.<50MB.Security, Resilience & Negative Testing
Data Privacy & Exception Isolation:
Penetration & Escape Verification: Design automated tests that attempt standard container escape tactics (e.g., executing unauthorized chroot sequences, trying to open network connections under
SECURE_ISOLATED, writing outside explicit volume mounts) and assert that they are cleanly intercepted.Resilience & Recovery Validation:
SecurityError, and spins up a replacement worker without halting the broader job.max_error_rateconstraint is set to50%, the job ultimately reachesCompletedstate and yields the partial valid results.Chaos Engineering Harness: Outline tests that simulate sudden, unannounced worker process terminations (
SIGKILL) and verification of backoff recovery loops.Documentation
The project documentation is built on MkDocs Material and automatically deployed via GitHub Pages (
.github/workflows/_docs.yml). The structure is split across Getting Started, Guides, Examples, Reference, and Community sections to ensure clear navigation for users at all experience levels.Getting Started & Installation
pip install rustariumflow, showcasing a 5-line "Hello World" sandboxed execution snippet directly on the landing page (docs/index.md). Maintain a comprehensive installation matrix forpip,uv,hatch, and Docker deployments indocs/getting-started/installation.md.rustarium doctor): Detail the terminal output design and FTUX workflow for therustarium doctorutility. This must act as a distinct subcommand under the primaryrustariumCLI entry point. Document its automated checks for OS support, cgroups v2 availability, Docker socket permissions, and Python virtual environment state. This guide will be located indocs/getting-started/quickstart.md, replacing the template bootstrap instructions.Workflow Guides & Architectural Concepts
Guides focus on conceptual underpinnings and comprehensive walkthroughs of core features (architecture, security, custom scheduling), decoupled from specific single-file runnable examples.
docs/guides/architecture.md.HIGH_PERFORMANCE_TRUSTEDprofile, located indocs/guides/hpc-tensors.md.docs/guides/custom-scheduling.md.Core Use Case Examples
Examples provide complete, runnable code files demonstrating core functionality and specific use cases across all major capabilities of the orchestrator.
SECURE_ISOLATEDprofile. This will live underdocs/examples/agentic-execution.md.docs/examples/llm-benchmarking.md.API & SDK Reference
mkdocstringsplugin to pull directly from Python source files insrc/. The generation is automated viamkdocs-gen-filesrunningdocs/scripts/gen_ref_pages.py, creating a dynamic literate navigation structure for the API reference atdocs/reference/api/..pyifiles) exported by PyO3 are correctly parsed by the documentation generator so that the Python auto-generated docs match the underlying Rust signatures perfectly. All public interfaces must include comprehensive Sphinx-style docstrings.Roadmap
MVP (Must Have): Local-First Secure Sandbox
Phase 2 (Should Have): Multi-Node & High Performance
Future (Could Have): Extensibility & Simulation
Beta Was this translation helpful? Give feedback.
All reactions