chore: initial scaffold — workspace, docs, blueprint
Sets up the PiCloud monorepo as a Cargo workspace organised around the
three-service architecture (manager / orchestrator / executor), each
backed by a *-core library crate so the same logic powers both the MVP
all-in-one `picloud` binary and the future split-process cluster mode.
* crates/shared, executor-core, orchestrator-core, manager-core
define the library surface and trait seams between the three
services (`ExecutorClient`, `ScriptResolver`, `ScriptRepository`).
* crates/picloud is the MVP entrypoint; serves /healthz on 8080
(override via PICLOUD_BIND).
* crates/picloud-{manager,orchestrator,executor} are skeleton
binaries that keep the crate boundaries honest until cluster
mode is built out in v1.3+.
* docs/git-workflow.md defines the trunk-based workflow:
short-lived branches, Conventional Commits, separate hotfix
flow with mandatory reproduction tests.
* CLAUDE.md captures the working rules for future Claude sessions.
Workspace passes `cargo fmt`, `cargo clippy -D warnings` (with
pedantic enabled), and `cargo test --workspace`. The all-in-one
binary responds on `/healthz` and `/`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
48
crates/executor-core/src/engine.rs
Normal file
48
crates/executor-core/src/engine.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
use crate::sandbox::Limits;
|
||||
use crate::types::{ExecError, ExecRequest, ExecResponse};
|
||||
|
||||
/// Preconfigured Rhai engine with sandbox limits applied.
|
||||
///
|
||||
/// One `Engine` is constructed at process startup and reused across
|
||||
/// invocations. `execute` is the only entry point — it owns the per-call
|
||||
/// scope and log buffer, then returns a complete `ExecResponse`.
|
||||
pub struct Engine {
|
||||
limits: Limits,
|
||||
// The actual `rhai::Engine` lands with the first execution implementation.
|
||||
// Keep this opaque for now so callers don't bind to it.
|
||||
}
|
||||
|
||||
impl Engine {
|
||||
#[must_use]
|
||||
pub fn new(limits: Limits) -> Self {
|
||||
Self { limits }
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn limits(&self) -> &Limits {
|
||||
&self.limits
|
||||
}
|
||||
|
||||
/// Parse-only validation, used by the manager at script-upload time
|
||||
/// so syntax errors are surfaced before the first invocation.
|
||||
pub fn validate(&self, _source: &str) -> Result<(), ExecError> {
|
||||
// TODO(executor-core): wire `rhai::Engine::compile`
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Execute `source` against `req` under the configured sandbox.
|
||||
///
|
||||
/// `async` is part of the contract: v1.1+ SDK calls (kv, docs, http)
|
||||
/// will await injected service providers from inside this method.
|
||||
#[allow(clippy::unused_async)]
|
||||
pub async fn execute(
|
||||
&self,
|
||||
_source: &str,
|
||||
_req: ExecRequest,
|
||||
) -> Result<ExecResponse, ExecError> {
|
||||
// TODO(executor-core): wire `rhai::Engine::eval_with_scope`
|
||||
Err(ExecError::Runtime(
|
||||
"executor-core::Engine::execute not yet implemented".into(),
|
||||
))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user