Architecture & Security Model
Monorepo layering, run state machine, and local security boundaries.
Kipivo is organized as a strict layered monorepo so Web, Desktop, Mobile, the control plane, and the Rust Runner share a single protocol contract without leaking platform or security boundaries.
Monorepo Layers
| Layer | Packages / Apps | Constraints |
|---|---|---|
| Platform-agnostic core | packages/protocol, packages/client, packages/i18n | Zero Node, Bun, or DOM APIs. Shared across Web, Desktop, Mobile, and API. |
| Web rendering | packages/ui, packages/blocks | Web & Desktop only (@base-ui/react, Tailwind v4). Forbidden in apps/mobile. |
| Applications & Docs | apps/api, apps/web, apps/desktop, apps/mobile, docs | docs is static SSG (docs.kipivo.com) and isolated from console/API packages. |
| Native Runner & CLI | crates/runner, crates/cli | Compiled to a single kipivo binary (kipivod daemon mode). |
Run State Machine
All transitions on runs pass through transitionRun() in apps/api using atomic conditional updates (WHERE status = :from):
queued ──▶ dispatching ──▶ running ──▶ awaiting_review ──▶ merging ──▶ merged
│ │
├──▶ completed ├──▶ completed (keep_branch)
├──▶ failed └──▶ rejected (spawns child run)
└──▶ cancelling ──▶ cancelled- A Run auto-completes (
completed) only when the diff is empty and not truncated, and it is not a conflict-resolution child Run. - Merge failures (
merge_conflict,checkout_dirty,not_on_default_branch,runner_lost) safely return the Run toawaiting_review.
Local Security Boundaries
Kipivo enforces strict defense-in-depth between the control plane and your local Runner:
- No server-supplied executable fields:
run.startonly carries schema-validated task fields (run_id,project_id,prompt,feedback?,executor,model?,base_ref, etc.)—never shell commands, paths, or environment variables. - Trusted check configuration:
.kipivo.tomlis always read frombase_sha, never from agent-modified files. - Local path ownership:
local_pathis resolved solely from the Runner's local configuration and validated againstprojects.repo_urlbefore execution. - Process-group timeouts & bounded output: Runs and individual checks enforce separate timeouts that terminate the entire process group and truncate oversized output.
- Credential isolation: Executor processes receive an explicit environment allowlist;
runner_tokenis never passed to executors. - Workspace authorization: Every RPC, SSE topic, file download, and webhook/IM callback is verified against workspace membership roles (
owner,maintainer,member).