Petri is a self-hosted agentic coding harness, multi-agent orchestrator and agentic development environment built for running in a container.
- Harness: a controlled runtime around the model. Every model response, tool call and tool result is persisted. File changes and test runs are proposals that need explicit approval, run inside disposable Git worktrees and rootless sandboxes, and are bounded by budgets, leases and server-enforced tool allowlists.
- Orchestrator: a deterministic state machine drives isolated Orchestrator, Planner, Implementer and Reviewer agents through gated stages (plan → approval → implement → review → final gate). Model output is validated evidence; it can never change workflow state on its own.
- Development environment: a browser workspace with a file explorer, Monaco editor, Git controls, diffs and a durable chat, so you can plan, review, edit and ship in one place.
Petri is written in Java 25 on Spring Boot, runs on a single node with an embedded H2 database or on PostgreSQL, and works with OpenAI, LiteLLM, Ollama and any OpenAI-compatible endpoint.
A tour of Petri: the project dashboard, vulnerability scanning with fixes, pipelines, pull requests and the workspace.
One gated workflow, start to finish: plan, approval, implementation, a rework loop at the evidence gate, and the Petri net verifying each acceptance criterion against real changes.
- Gated multi-agent workflows with four isolated roles, each with its own provider, model, budgets, attempt limit and prompt addendum, snapshotted when a task is submitted.
- Planner questions (single-select, multi-select, free text) and revision-bound plan approval with warnings, revision requests and guidance at safe boundaries.
- Deterministic evidence gates: workflow-only task diffs, final file hashes, test results and structured reviewer findings feed the implementation and final gates.
- Automatic application of approved patches and sandboxed tests, scoped to the approved plan and to the workflow's own worktree.
- Final-gate summary written by the orchestrator, and user approval to finish when only executed tests are missing.
- Fail-closed holds with automatic stopping after exhausted attempts, plus a manual Retry that always grants a fresh attempt budget.
- Queueing and cancellation: follow-up tasks queue in order; cancelling preserves applied changes and releases the worktree at a safe boundary.
- Direct mode for plain single-agent chats with optional per-chat auto-approval.
- MCP servers: each user connects their own remote MCP servers (bearer, headers or OAuth 2.1 sign-in) and switches them on per project; read-only tools run directly, other tool calls wait for approval in the review tray.
- Skills: lazy-loaded
SKILL.mdworkflows with a manifest (extends,requires,produces). Skills add guidance and can only narrow, never widen, the tools a run gets. Admins can install prompt-only skills and export any skill.
- Actions (code review, review and comment, review and improve, vulnerability scan / comment / improve, vulnerability fix PR, fix and merge) are database rows; admins add custom actions in the UI with no code change.
- Triggers: new or updated pull requests, a cron schedule, or Run once on a pull request or a branch. Unattended runs can plan, approve, implement, commit, push and open a pull request, with the final gate left to a person unless you allow completion without approval.
- Reviews are posted to GitHub, GitLab and Forgejo pull requests, or held as drafts until a person approves them.
- Vulnerability scanning with Trivy: dependencies are resolved first (Maven, Gradle, npm, Cargo, Composer, Bundler), findings are stored per branch and shown on a sortable Vulnerabilities tab with per-finding and Fix all buttons. An offline database can ship in the image, with admin-configurable registry and credentials.
- Workspace UI: lazy file explorer, Monaco tabs with persistent drafts, optimistic saves and conflict-safe reloads, side-by-side or inline diffs.
- Kubernetes workspaces: per project, the repository, terminal, tests and agent tools can live in a
pod on your own cluster (any image with
shandgit), with a volume that outlives the idle-stopped pod. - Terminal panel below the editor; agents get an approval-gated
run_commandtool (per-project auto-approve) whose commands run as an OS-level user confined to the worktree. - Live workflow panel shown as a Petri net with per-goal verification, status, attempts and cancel; it stays on Done until the next workflow starts.
- Streaming chat with timestamped tool calls, agent messages and artifacts, reconnect recovery and a "guide active task" toggle to steer the running task or queue a new one.
- Git bar and Changes panel: branches, worktrees, fetch, pull (fast-forward), rebase, commit, push, force-with-lease, and stage / unstage / revert per file, section or all changes.
- Review tray for patch and test proposals with inline diffs.
- Controlled bare mirror per project and branch-bound disposable worktrees.
- Personal and global GitHub, GitLab and Forgejo connections (PAT/OAuth) with live repository catalogs and bulk import, or simple per-project HTTPS credentials.
- Git runs without a shell, with prompts disabled, global/system config ignored, bounded and redacted output, and credentials supplied only through a temporary owner-only askpass helper.
- Dirty-state baselines so workflow evidence only includes what the workflow touched.
- OpenAI Responses API, LiteLLM Responses API, Ollama and generic OpenAI-compatible Chat Completions.
- Per-provider base URL, model, output budget and optional encrypted API key; per-task overrides, reasoning effort and verbosity, token streaming and context-window summaries.
- Native tools:
list_files,read_file,search_files,create_patch,create_file,show_diff,run_tests,install_packages,run_command,list_skills,load_skill. - Approval-gated Alpine package installs: agents request tools (
jq,python3,nodejs, …) with a reason; installs run only after approval (or per-project auto-approve) into an unprivileged toolchain prefix. Models are told they run on Alpine and how installs work. - Path, symlink and
.gitprotections; SHA-256 guarded edits that recordCONFLICTinstead of overwriting concurrent changes. - Tests run only as fixed Maven/Gradle commands, by default in rootless Podman with an immutable root
filesystem, dropped capabilities, resource limits and project-isolated caches. An opt-in
localexecutor (the Alpine image default) runs them in Petri's own container instead.
- Remotes per package manager: apk, Maven, Gradle, npm, pip, Go, Cargo, Composer, RubyGems and NuGet, plus dedicated docker.io and ghcr.io mirrors for Podman and Trivy.
- Instance defaults with per-project overrides, replace-or-add semantics, encrypted credentials, a Test button per remote, an extra CA bundle and an "ignore TLS errors" switch.
- Petri writes each tool's native configuration into the run's private home (and mounts it into Podman containers); credentials never appear on command lines.
- Local administrator login and optional OIDC with verified-email account linking.
- Owner-scoped projects and API keys; administrator-only global providers, models and sandbox profiles.
- AES-256-GCM encryption of Git and model secrets; secrets are never rendered back.
- Audit log, persistent run events with JSON replay and Server-Sent Events, health and Prometheus endpoints.
- Flyway-managed schema, durable runs with execution leases and restart recovery.
- REST API under
/api/v1/**for runs, worktrees, events and tools.
Requirements: JDK 25 and Maven 3.9+ (the wrapper is included). Rootless Podman is needed only to run tests.
./mvnw test
./mvnw spring-boot:runOpen http://localhost:8080 and sign in with admin@petri.local / admin for local evaluation.
Set PETRI_ADMIN_EMAIL and PETRI_ADMIN_PASSWORD before exposing the service beyond localhost.
Then:
- Add a model provider at
/model-settings(administrators), then add your API key under LLM providers if the provider needs one. - Register a repository at
/projects(or connect a Git account at/git-accounts) and synchronize its mirror. - Open the project workspace, pick or create a branch, and start a chat in Workflow mode.
See Getting started for the full first-task walkthrough.
Images are published to GHCR on every merge to main, built on Alpine (JDK 25), signed with
Cosign and shipped with SLSA provenance and a CycloneDX SBOM:
docker run --rm -p 8080:8080 -v petri-data:/app/data ghcr.io/wenisch-tech/petri:latestThe Helm chart lives in charts/petri and is published to the
Wenisch Tech Helm repository:
helm repo add wenisch-tech https://charts.wenisch.tech
helm install petri wenisch-tech/petri -n petri --create-namespace| Variable | Purpose |
|---|---|
PETRI_ADMIN_EMAIL, PETRI_ADMIN_PASSWORD |
Initial administrator account. |
PETRI_SECRETS_MASTER_KEY / PETRI_SECRETS_MASTER_KEY_FILE |
Base64 32-byte key, or key file location (generated at ./data/petri-master.key if unset). Back it up; losing it makes stored secrets unrecoverable. |
PETRI_WORKSPACE_ROOT |
Mirrors and worktrees (default ./data/workspaces). |
PETRI_SKILLS_ROOT |
Skill directory (default ./skills). |
PETRI_SKILLS_INSTALLED_ROOT |
Writable directory for skills installed by admins (installing is off when unset). |
PETRI_PACKAGES_PKI_DIR |
Generated CA bundle and trust store for package sources (default ./data/pki). |
SPRING_DATASOURCE_* |
Switch from embedded H2 (./data) to PostgreSQL. |
The full reference, including limits, timeouts and OIDC setup, is in Configuration.
| Topic | Document |
|---|---|
| Overview and index | docs/README.md |
| Run Petri, first task | Getting started |
| What exists today | Implemented features |
| Environment and OIDC | Configuration |
| Providers and endpoints | LLM providers |
| Mirrors, branches, worktrees | Git workspaces |
| GitHub / GitLab / Forgejo | Git provider accounts |
| Model loop and approvals | Agent workflow |
| Multi-agent gates | Gated orchestration |
| Workspaces in a Kubernetes pod | Kubernetes workspaces |
| Test isolation | Test sandboxes |
| Skills and actions | Skills |
| Automations and vulnerability fixes | Automations |
| MCP servers | MCP |
| Package sources, CA, mirrors | Configuration |
| API reference | HTTP API |
| Trust boundaries | Security model |
| Build and project layout | Development |
| Kubernetes | Helm chart · charts.wenisch.tech |
Petri is licensed under the GNU Affero General Public License v3.0.


